All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: qemu-ppc@nongnu.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
	qemu-devel@nongnu.org, Chalapathi V <chalapathi.v@linux.ibm.com>,
	Harsh Prateek Bora <harshpb@linux.ibm.com>,
	Glenn Miles <milesg@linux.ibm.com>
Subject: [PATCH 1/4] target/ppc: Fix non-maskable interrupt while halted
Date: Mon, 25 Nov 2024 23:20:38 +1000	[thread overview]
Message-ID: <20241125132042.325734-2-npiggin@gmail.com> (raw)
In-Reply-To: <20241125132042.325734-1-npiggin@gmail.com>

The ppc (pnv and spapr) NMI injection code does not go through the
asynchronous interrupt path and set a bit in env->pending_interrupts
and raise an interrupt request that the cpu_exec() loop can see.
Instead it injects the exception directly into registers.

This can lead to cpu_exec() missing that the thread has work to do,
if a NMI is injected while it was idle.

Fix this by clearing halted when injecting the interrupt. Probably
NMI injection should be reworked to use the interrupt request interface,
but this seems to work as a minimal fix.

Fixes: 3431648272d3 ("spapr: Add support for new NMI interface")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 target/ppc/excp_helper.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index 70daa5076a..9f811af0a4 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -2495,10 +2495,16 @@ static void ppc_deliver_interrupt(CPUPPCState *env, int interrupt)
     }
 }
 
+/*
+ * system reset is not delivered via normal irq method, so have to set
+ * halted = 0 to resume CPU running if it was halted. Possibly we should
+ * move it over to using PPC_INTERRUPT_RESET rather than async_run_on_cpu.
+ */
 void ppc_cpu_do_system_reset(CPUState *cs)
 {
     PowerPCCPU *cpu = POWERPC_CPU(cs);
 
+    cs->halted = 0;
     powerpc_excp(cpu, POWERPC_EXCP_RESET);
 }
 
@@ -2520,6 +2526,7 @@ void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector)
 
     /* Anything for nested required here? MSR[HV] bit? */
 
+    cs->halted = 0;
     powerpc_set_excp_state(cpu, vector, msr);
 }
 
-- 
2.45.2



  reply	other threads:[~2024-11-25 13:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 13:20 [PATCH 0/4] ppc: various fixes for 9.2 Nicholas Piggin
2024-11-25 13:20 ` Nicholas Piggin [this message]
2024-11-25 16:26   ` [PATCH 1/4] target/ppc: Fix non-maskable interrupt while halted Miles Glenn
2024-11-25 13:20 ` [PATCH 2/4] ppc/pnv: Fix direct controls quiesce Nicholas Piggin
2024-11-25 16:31   ` Miles Glenn
2024-11-25 13:20 ` [PATCH 3/4] target/ppc: Fix THREAD_SIBLING_FOREACH for mult-socket Nicholas Piggin
2024-11-25 16:26   ` Miles Glenn
2024-11-25 13:20 ` [PATCH 4/4] ppc/pnv: Add xscom- prefix to pervasive-control region name Nicholas Piggin
2024-11-25 16:28   ` Miles Glenn
2024-11-25 19:28   ` Philippe Mathieu-Daudé
2024-11-26  3:54     ` Nicholas Piggin
2024-11-26  5:19       ` Philippe Mathieu-Daudé
2024-11-26 15:43         ` Peter Xu

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=20241125132042.325734-2-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=chalapathi.v@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=milesg@linux.ibm.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.