From: Nicholas Piggin <npiggin@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Nicholas Piggin" <npiggin@gmail.com>,
qemu-ppc@nongnu.org,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Cédric Le Goater" <clg@kaod.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Greg Kurz" <groug@kaod.org>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"BALATON Zoltan" <balaton@eik.bme.hu>
Subject: [PATCH v3] target/ppc: Make checkstop actually stop the system
Date: Mon, 3 Jul 2023 22:03:39 +1000 [thread overview]
Message-ID: <20230703120340.45349-1-npiggin@gmail.com> (raw)
checkstop state does not halt the system, interrupts continue to be
serviced, and other CPUs run. Stop the machine with
qemu_system_guest_panicked.
Change the logging not to print separately to stderr because a
checkstop is a guest error (or perhaps a simulated machine error)
rather than a QEMU error. CPU registers are dumped.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Since v1:
- Fix loop exit so it stops on the checkstop-causing instruction, rather than
after it.
Since v2:
- Rebase on ppc-next.
- Use qemu_system_guest_panicked rather than vm_stop (Richard)
- Move away from printing to stderr (Zoltan)
- Reduce changes to log messages.
- Split out from larger series since it's independent (will skip attn
instruction for now).
---
target/ppc/excp_helper.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index e49e13a30d..a588285ef1 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
#include "qemu/log.h"
+#include "sysemu/runstate.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "internal.h"
@@ -427,20 +428,29 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, target_ulong vector,
static void powerpc_mcheck_checkstop(CPUPPCState *env)
{
CPUState *cs = env_cpu(env);
+ FILE *f;
if (FIELD_EX64(env->msr, MSR, ME)) {
return;
}
- /* Machine check exception is not enabled. Enter checkstop state. */
- fprintf(stderr, "Machine check while not allowed. "
- "Entering checkstop state\n");
- if (qemu_log_separate()) {
- qemu_log("Machine check while not allowed. "
- "Entering checkstop state\n");
+ /*
+ * This stops the machine and logs CPU state without killing QEMU
+ * (like cpu_abort()) so the machine can still be debugged (because
+ * it is often a guest error).
+ */
+
+ f = qemu_log_trylock();
+ if (f) {
+ fprintf(f, "Machine check while not allowed. "
+ "Entering checkstop state.\n");
+ cpu_dump_state(cs, f, CPU_DUMP_FPU | CPU_DUMP_CCOP);
+ qemu_log_unlock(f);
}
- cs->halted = 1;
- cpu_interrupt_exittb(cs);
+
+ qemu_system_guest_panicked(NULL);
+
+ cpu_loop_exit_noexc(cs);
}
static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)
--
2.40.1
next reply other threads:[~2023-07-03 12:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 12:03 Nicholas Piggin [this message]
2023-07-03 12:26 ` [PATCH v3] target/ppc: Make checkstop actually stop the system BALATON Zoltan
2023-07-03 12:38 ` Daniel Henrique Barboza
2023-07-03 13:07 ` Nicholas Piggin
2023-07-03 15:06 ` BALATON Zoltan
2023-07-05 2:59 ` Nicholas Piggin
2023-07-06 11:33 ` BALATON Zoltan
2023-07-03 13:26 ` Philippe Mathieu-Daudé
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=20230703120340.45349-1-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=harshpb@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).