From: "Nicholas Piggin" <npiggin@gmail.com>
To: "BALATON Zoltan" <balaton@eik.bme.hu>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"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>
Subject: Re: [PATCH 4/4] target/ppc: Make checkstop stop the system
Date: Sun, 25 Jun 2023 19:15:40 +1000 [thread overview]
Message-ID: <CTLM8MKHV82Y.234W43DPGDJMA@wheely> (raw)
In-Reply-To: <04636e8a-de3f-d963-b64e-07cc60bc2538@eik.bme.hu>
On Fri Jun 23, 2023 at 9:51 PM AEST, BALATON Zoltan wrote:
> On Fri, 23 Jun 2023, Nicholas Piggin wrote:
> > checkstop state does not halt the system, interrupts continue to be
> > serviced, and other CPUs run.
> >
> > Stop the machine with vm_stop(), and print a register dump too.
> >
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> > target/ppc/excp_helper.c | 35 +++++++++++++++++++++--------------
> > 1 file changed, 21 insertions(+), 14 deletions(-)
> >
> > diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> > index 4bfcfc3c3d..51e83d7f07 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"
> > @@ -165,6 +166,24 @@ static void ppc_excp_debug_sw_tlb(CPUPPCState *env, int excp)
> > env->error_code);
> > }
> >
> > +static void powerpc_checkstop(PowerPCCPU *cpu, const char *reason)
> > +{
> > + CPUState *cs = CPU(cpu);
> > +
> > + vm_stop(RUN_STATE_GUEST_PANICKED);
> > +
> > + fprintf(stderr, "Entering checkstop state: %s\n", reason);
> > + cpu_dump_state(cs, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP);
> > + if (qemu_log_separate()) {
> > + FILE *logfile = qemu_log_trylock();
> > + if (logfile) {
> > + fprintf(logfile, "Entering checkstop state: %s\n", reason);
> > + cpu_dump_state(cs, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
> > + qemu_log_unlock(logfile);
> > + }
> > + }
> > +}
> > +
> > #if defined(TARGET_PPC64)
> > static int powerpc_reset_wakeup(CPUState *cs, CPUPPCState *env, int excp,
> > target_ulong *msr)
> > @@ -406,21 +425,9 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, target_ulong vector,
> >
> > static void powerpc_mcheck_test_and_checkstop(CPUPPCState *env)
> > {
> > - CPUState *cs = env_cpu(env);
> > -
> > - 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");
> > + if (!FIELD_EX64(env->msr, MSR, ME)) {
> > + powerpc_checkstop(env_archcpu(env), "machine check with MSR[ME]=0");
>
> I don't mind you twaeking the patch and renaming the function but now this
> has become another one line function which just clutters code. Either keep
> this together in one function or inline the if at callers, otherwise this
> will start to look like Forth where every simple operation gets a new
> name. :-)
Yeah good point. I did want to have a powerpc_checkstop function with a
reason because other places might start to also call it in future.
As far as the machine check ME test goes... we could re-inline that I
suppose.
Thanks,
Nick
next prev parent reply other threads:[~2023-06-25 9:16 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 8:19 [PATCH 0/4] target/ppc: Catch invalid real address accesses Nicholas Piggin
2023-06-23 8:19 ` [PATCH 1/4] target/ppc: Machine check on invalid real address access Nicholas Piggin
2023-06-23 8:19 ` [PATCH 2/4] target/ppc: Add POWER9/10 invalid-real machine check codes Nicholas Piggin
2023-06-23 8:19 ` [PATCH 3/4] target/ppc: Move common check in machne check handlers to a function Nicholas Piggin
2023-06-23 13:20 ` Fabiano Rosas
2023-06-23 16:16 ` BALATON Zoltan
2023-06-25 9:20 ` Nicholas Piggin
2023-06-23 8:19 ` [PATCH 4/4] target/ppc: Make checkstop stop the system Nicholas Piggin
2023-06-23 11:51 ` BALATON Zoltan
2023-06-25 9:15 ` Nicholas Piggin [this message]
2023-06-23 9:10 ` [PATCH 0/4] target/ppc: Catch invalid real address accesses Peter Maydell
2023-06-23 12:37 ` Cédric Le Goater
2023-06-23 23:35 ` Philippe Mathieu-Daudé
2023-06-24 9:50 ` BALATON Zoltan
2023-06-26 13:35 ` Cédric Le Goater
2023-06-26 23:28 ` Nicholas Piggin
2023-06-27 6:49 ` Cédric Le Goater
2023-06-27 8:14 ` Mark Cave-Ayland
2023-06-27 10:28 ` Howard Spoelstra
2023-06-27 11:24 ` Mark Cave-Ayland
2023-06-27 12:05 ` Howard Spoelstra
2023-06-27 12:41 ` Cédric Le Goater
2023-06-27 20:26 ` Mark Cave-Ayland
2023-06-28 7:02 ` Cédric Le Goater
2023-06-28 7:17 ` Cédric Le Goater
2023-06-29 8:29 ` Mark Cave-Ayland
2023-06-29 9:05 ` Cédric Le Goater
2023-06-29 9:41 ` Nicholas Piggin
2023-06-27 12:03 ` Cédric Le Goater
2023-06-27 20:24 ` Mark Cave-Ayland
2023-06-25 9:18 ` Nicholas Piggin
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=CTLM8MKHV82Y.234W43DPGDJMA@wheely \
--to=npiggin@gmail.com \
--cc=balaton@eik.bme.hu \
--cc=christophe.leroy@csgroup.eu \
--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 \
/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).