qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "BALATON Zoltan" <balaton@eik.bme.hu>, <qemu-devel@nongnu.org>,
	<qemu-ppc@nongnu.org>
Cc: <clg@kaod.org>, "Greg Kurz" <groug@kaod.org>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>
Subject: Re: [PATCH v2 03/10] target/ppc: Move common check in exception handlers to a function
Date: Thu, 15 Jun 2023 13:28:28 +1000	[thread overview]
Message-ID: <CTCWLCE09SUS.1G1XXO54L2XD6@wheely> (raw)
In-Reply-To: <9cfffaa35aa894086dd092af6b0b26f2d62ff3de.1686776990.git.balaton@eik.bme.hu>

On Thu Jun 15, 2023 at 7:34 AM AEST, BALATON Zoltan wrote:
> All powerpc exception handlers share some code when handling machine
> check exceptions. Move this to a common function.
>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> ---
>  target/ppc/excp_helper.c | 114 +++++++++------------------------------
>  1 file changed, 25 insertions(+), 89 deletions(-)
>
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index 3783315fdb..79f5ca1034 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -403,6 +403,25 @@ static void powerpc_set_excp_state(PowerPCCPU *cpu, target_ulong vector,
>      env->reserve_addr = -1;
>  }
>  
> +static void powerpc_mcheck_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");
> +    }
> +    cs->halted = 1;
> +    cpu_interrupt_exittb(cs);
> +}
> +
>  static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)
>  {
>      CPUState *cs = CPU(cpu);
> @@ -445,21 +464,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp)
>          srr1 = SPR_40x_SRR3;
>          break;
>      case POWERPC_EXCP_MCHECK:    /* Machine check exception                  */
> -        if (!FIELD_EX64(env->msr, MSR, ME)) {
> -            /*
> -             * 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");
> -            }
> -            cs->halted = 1;
> -            cpu_interrupt_exittb(cs);
> -        }
> -
> +        powerpc_mcheck_checkstop(env);
>          /* machine check exceptions don't have ME set */
>          new_msr &= ~((target_ulong)1 << MSR_ME);
>  
> @@ -576,21 +581,7 @@ static void powerpc_excp_6xx(PowerPCCPU *cpu, int excp)
>      case POWERPC_EXCP_CRITICAL:    /* Critical input                         */
>          break;
>      case POWERPC_EXCP_MCHECK:    /* Machine check exception                  */
> -        if (!FIELD_EX64(env->msr, MSR, ME)) {
> -            /*
> -             * 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");
> -            }
> -            cs->halted = 1;
> -            cpu_interrupt_exittb(cs);
> -        }
> -
> +        powerpc_mcheck_checkstop(env);
>          /* machine check exceptions don't have ME set */
>          new_msr &= ~((target_ulong)1 << MSR_ME);
>  
> @@ -749,21 +740,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp)
>  
>      switch (excp) {
>      case POWERPC_EXCP_MCHECK:    /* Machine check exception                  */
> -        if (!FIELD_EX64(env->msr, MSR, ME)) {
> -            /*
> -             * 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");
> -            }
> -            cs->halted = 1;
> -            cpu_interrupt_exittb(cs);
> -        }
> -
> +        powerpc_mcheck_checkstop(env);
>          /* machine check exceptions don't have ME set */
>          new_msr &= ~((target_ulong)1 << MSR_ME);
>  
> @@ -934,21 +911,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp)
>  
>      switch (excp) {
>      case POWERPC_EXCP_MCHECK:    /* Machine check exception                  */
> -        if (!FIELD_EX64(env->msr, MSR, ME)) {
> -            /*
> -             * 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");
> -            }
> -            cs->halted = 1;
> -            cpu_interrupt_exittb(cs);
> -        }
> -
> +        powerpc_mcheck_checkstop(env);
>          /* machine check exceptions don't have ME set */
>          new_msr &= ~((target_ulong)1 << MSR_ME);
>  
> @@ -1129,21 +1092,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int excp)
>          srr1 = SPR_BOOKE_CSRR1;
>          break;
>      case POWERPC_EXCP_MCHECK:    /* Machine check exception                  */
> -        if (!FIELD_EX64(env->msr, MSR, ME)) {
> -            /*
> -             * 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");
> -            }
> -            cs->halted = 1;
> -            cpu_interrupt_exittb(cs);
> -        }
> -
> +        powerpc_mcheck_checkstop(env);
>          /* machine check exceptions don't have ME set */
>          new_msr &= ~((target_ulong)1 << MSR_ME);
>  
> @@ -1376,20 +1325,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
>  
>      switch (excp) {
>      case POWERPC_EXCP_MCHECK:    /* Machine check exception                  */
> -        if (!FIELD_EX64(env->msr, MSR, ME)) {
> -            /*
> -             * 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");
> -            }
> -            cs->halted = 1;
> -            cpu_interrupt_exittb(cs);
> -        }
> +        powerpc_mcheck_checkstop(env);
>          if (env->msr_mask & MSR_HVB) {
>              /*
>               * ISA specifies HV, but can be delivered to guest with HV
> -- 
> 2.30.9



  reply	other threads:[~2023-06-15  3:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 21:34 [PATCH v2 00/10] Misc clean ups to target/ppc exception handling BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 01/10] target/ppc: Remove some superfluous parentheses BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 02/10] target/ppc: Remove unneeded parameter from powerpc_reset_wakeup() BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 03/10] target/ppc: Move common check in exception handlers to a function BALATON Zoltan
2023-06-15  3:28   ` Nicholas Piggin [this message]
2023-06-14 21:34 ` [PATCH v2 04/10] target/ppc: Use env_cpu for cpu_abort in excp_helper BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 05/10] target/ppc: Change parameter of cpu_interrupt_exittb() to an env pointer BALATON Zoltan
2023-06-15  3:32   ` Nicholas Piggin
2023-06-15  9:19     ` BALATON Zoltan
2023-06-15 11:40       ` Nicholas Piggin
2023-06-15 23:00         ` BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 06/10] target/ppc: Readability improvements in exception handlers BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 07/10] target/ppd: Remove unused define BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 08/10] target/ppc: Fix gen_sc to use correct nip BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 09/10] target/ppc: Simplify syscall exception handlers BALATON Zoltan
2023-06-15  3:34   ` Nicholas Piggin
2023-06-15  9:25     ` BALATON Zoltan
2023-06-15 11:46       ` Nicholas Piggin
2023-06-15 23:02         ` BALATON Zoltan
2023-06-14 21:34 ` [PATCH v2 10/10] target/ppc: Get CPUState in one step BALATON Zoltan
2023-06-15  3:35   ` 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=CTCWLCE09SUS.1G1XXO54L2XD6@wheely \
    --to=npiggin@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=groug@kaod.org \
    --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).