All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: lvivier@redhat.com, qemu-devel@nongnu.org,
	"Nicholas Piggin" <npiggin@gmail.com>,
	groug@kaod.org, qemu-ppc@nongnu.org,
	"Cédric Le Goater" <clg@kaod.org>,
	philmd@redhat.com, "David Gibson" <david@gibson.dropbear.id.au>
Subject: [PULL 01/15] ppc/pnv: Fix NMI system reset SRR1 value
Date: Wed, 27 May 2020 15:37:55 +1000	[thread overview]
Message-ID: <20200527053809.356168-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20200527053809.356168-1-david@gibson.dropbear.id.au>

From: Nicholas Piggin <npiggin@gmail.com>

Commit a77fed5bd926 ("ppc/pnv: Add support for NMI interface") got the
SRR1 setting wrong for sresets that hit outside of power-save states.

Fix this, better documenting the source for the bit definitions.

Fixes: 01b552b05b0f ("ppc/pnv: Add support for NMI interface")
Cc: Cédric Le Goater <clg@kaod.org>
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200507114824.788942-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
[dwg: Fixed up some tab indentation]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index da637822f9..f48a61d6d1 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1984,12 +1984,26 @@ static void pnv_cpu_do_nmi_on_cpu(CPUState *cs, run_on_cpu_data arg)
 
     cpu_synchronize_state(cs);
     ppc_cpu_do_system_reset(cs);
-    /*
-     * SRR1[42:45] is set to 0100 which the ISA defines as implementation
-     * dependent. POWER processors use this for xscom triggered interrupts,
-     * which come from the BMC or NMI IPIs.
-     */
-    env->spr[SPR_SRR1] |= PPC_BIT(43);
+    if (env->spr[SPR_SRR1] & PPC_BITMASK(46, 47)) {
+        /*
+         * Power-save wakeups, as indicated by non-zero SRR1[46:47] put the
+         * wakeup reason in SRR1[42:45], system reset is indicated with 0b0100
+         * (PPC_BIT(43)).
+         */
+        if (!(env->spr[SPR_SRR1] & PPC_BIT(43))) {
+            warn_report("ppc_cpu_do_system_reset does not set system reset wakeup reason");
+            env->spr[SPR_SRR1] |= PPC_BIT(43);
+        }
+    } else {
+        /*
+         * For non-powersave system resets, SRR1[42:45] are defined to be
+         * implementation-dependent. The POWER9 User Manual specifies that
+         * an external (SCOM driven, which may come from a BMC nmi command or
+         * another CPU requesting a NMI IPI) system reset exception should be
+         * 0b0010 (PPC_BIT(44)).
+         */
+        env->spr[SPR_SRR1] |= PPC_BIT(44);
+    }
 }
 
 static void pnv_nmi(NMIState *n, int cpu_index, Error **errp)
-- 
2.26.2



  reply	other threads:[~2020-05-27  5:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  5:37 [PULL 00/15] ppc-for-5.1 queue 20200527 David Gibson
2020-05-27  5:37 ` David Gibson [this message]
2020-05-27  5:37 ` [PULL 02/15] ppc/spapr: add a POWER10 CPU model David Gibson
2020-05-27  5:37 ` [PULL 03/15] target/ppc: Untabify excp_helper.c David Gibson
2020-05-27  5:37 ` [PULL 04/15] target/ppc: Add support for scv and rfscv instructions David Gibson
2020-05-27  5:37 ` [PULL 05/15] ppc/spapr: Add hotremovable flag on DIMM LMBs on drmem_v2 David Gibson
2020-05-27  5:38 ` [PULL 06/15] target/ppc: Pass const pointer to ppc_radix64_get_prot_amr() David Gibson
2020-05-27  5:38 ` [PULL 07/15] target/ppc: Pass const pointer to ppc_radix64_get_fully_qualified_addr() David Gibson
2020-05-27  5:38 ` [PULL 08/15] target/ppc: Don't initialize some local variables in ppc_radix64_xlate() David Gibson
2020-05-27  5:38 ` [PULL 09/15] target/ppc: Add missing braces in ppc_radix64_partition_scoped_xlate() David Gibson
2020-05-27  5:38 ` [PULL 10/15] target/ppc: Fix arguments to ppc_radix64_partition_scoped_xlate() David Gibson
2020-05-27  5:38 ` [PULL 11/15] target/ppc: Don't update radix PTE R/C bits with gdbstub David Gibson
2020-05-27  5:38 ` [PULL 12/15] hw/pci-bridge/dec: Remove dead debug code David Gibson
2020-05-27  5:38 ` [PULL 13/15] hw/nvram/mac_nvram: Convert debug printf()s to trace events David Gibson
2020-05-27  5:38 ` [PULL 14/15] target/ppc: Fix argument to ppc_radix64_partition_scoped_xlate() again David Gibson
2020-05-27  5:38 ` [PULL 15/15] vfio/nvlink: Remove exec permission to avoid SELinux AVCs David Gibson
2020-05-27  6:39 ` [PULL 00/15] ppc-for-5.1 queue 20200527 no-reply
2020-05-28 10:20 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200527053809.356168-2-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.