From: Harsh Prateek Bora <harshpb@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, Daniel Henrique Barboza <danielhb413@gmail.com>
Subject: Re: [PATCH] target/ppc: Do not clear MSR[ME] on MCE interrupts to supervisor
Date: Fri, 22 Mar 2024 14:02:43 +0530 [thread overview]
Message-ID: <a6ec42e1-b07f-4535-8c8f-2fffa3beab0c@linux.ibm.com> (raw)
In-Reply-To: <20240321055415.2441812-1-npiggin@gmail.com>
On 3/21/24 11:24, Nicholas Piggin wrote:
> Hardware clears the MSR[ME] bit when delivering a machine check
> interrupt, so that is what QEMU does.
>
> The spapr environment runs in supervisor mode though, and receives
> machine check interrupts after they are processed by the hypervisor,
> and MSR[ME] must always be enabled in supervisor mode (otherwise it
> could checkstop the system). So MSR[ME] must not be cleared when
> delivering machine checks to the supervisor.
>
> The fix to prevent supervisor mode from modifying MSR[ME] also
> prevented it from re-enabling the incorrectly cleared MSR[ME] bit
> when returning from handling the interrupt. Before that fix, the
> problem was not very noticable with well-behaved code. So the
> Fixes tag is not strictly correct, but practically they go together.
>
> Found by kvm-unit-tests machine check tests (not yet upstream).
>
> Fixes: 678b6f1af75ef ("target/ppc: Prevent supervisor from modifying MSR[ME]")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
> ---
> target/ppc/excp_helper.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index 80f584f933..674c05a2ce 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -1345,9 +1345,10 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp)
> * clear (e.g., see FWNMI in PAPR).
> */
> new_msr |= (target_ulong)MSR_HVB;
> +
> + /* HV machine check exceptions don't have ME set */
> + new_msr &= ~((target_ulong)1 << MSR_ME);
> }
> - /* machine check exceptions don't have ME set */
> - new_msr &= ~((target_ulong)1 << MSR_ME);
>
> msr |= env->error_code;
> break;
prev parent reply other threads:[~2024-03-22 8:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 5:54 [PATCH] target/ppc: Do not clear MSR[ME] on MCE interrupts to supervisor Nicholas Piggin
2024-03-22 8:32 ` Harsh Prateek Bora [this message]
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=a6ec42e1-b07f-4535-8c8f-2fffa3beab0c@linux.ibm.com \
--to=harshpb@linux.ibm.com \
--cc=danielhb413@gmail.com \
--cc=npiggin@gmail.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).