From: Joao Martins <joao.m.martins@oracle.com>
To: John Allen <john.allen@amd.com>
Cc: yazen.ghannam@amd.com, michael.roth@amd.com, babu.moger@amd.com,
william.roche@oracle.com, Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] i386: Fix MCE support for AMD hosts
Date: Thu, 6 Jul 2023 22:07:05 +0100 [thread overview]
Message-ID: <d700de55-a7ba-0857-99e9-0af4703312be@oracle.com> (raw)
In-Reply-To: <20230706194022.2485195-3-john.allen@amd.com>
+x86 qemu folks
On 06/07/2023 20:40, John Allen wrote:
> For the most part, AMD hosts can use the same MCE injection code as Intel but,
> there are instances where the qemu implementation is Intel specific. First, MCE
> deliviery works differently on AMD and does not support broadcast. Second,
> kvm_mce_inject generates MCEs that include a number of Intel specific status
> bits. Modify kvm_mce_inject to properly generate MCEs on AMD platforms.
>
> Reported-by: William Roche <william.roche@oracle.com>
> Signed-off-by: John Allen <john.allen@amd.com>
> ---
> target/i386/helper.c | 4 ++++
> target/i386/kvm/kvm.c | 17 +++++++++++------
> 2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/target/i386/helper.c b/target/i386/helper.c
> index 533b29cb91..a6523858e0 100644
> --- a/target/i386/helper.c
> +++ b/target/i386/helper.c
> @@ -76,6 +76,10 @@ int cpu_x86_support_mca_broadcast(CPUX86State *env)
> int family = 0;
> int model = 0;
>
> + if (IS_AMD_CPU(env)) {
> + return 0;
> + }
> +
> cpu_x86_version(env, &family, &model);
> if ((family == 6 && model >= 14) || family > 6) {
> return 1;
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index f25837f63f..63bd7a7d3a 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -530,16 +530,21 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code)
> CPUState *cs = CPU(cpu);
> CPUX86State *env = &cpu->env;
> uint64_t status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN |
> - MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S;
> + MCI_STATUS_MISCV | MCI_STATUS_ADDRV;
> uint64_t mcg_status = MCG_STATUS_MCIP;
> int flags = 0;
>
> - if (code == BUS_MCEERR_AR) {
> - status |= MCI_STATUS_AR | 0x134;
> - mcg_status |= MCG_STATUS_EIPV;
> + if (!IS_AMD_CPU(env)) {
> + status |= MCI_STATUS_S;
> + if (code == BUS_MCEERR_AR) {
> + status |= MCI_STATUS_AR | 0x134;
> + mcg_status |= MCG_STATUS_EIPV;
> + } else {
> + status |= 0xc0;
> + mcg_status |= MCG_STATUS_RIPV;
> + }
> } else {
> - status |= 0xc0;
> - mcg_status |= MCG_STATUS_RIPV;
> + mcg_status |= MCG_STATUS_EIPV | MCG_STATUS_RIPV;
> }
>
I was gonna say that we should only handle BUS_MCEERR_AR for AMD, but the way
you came up with, does seem to work from quick testing. And it's better to log
an error that silently ignore it obviously.
> flags = cpu_x86_support_mca_broadcast(env) ? MCE_INJECT_BROADCAST : 0;
prev parent reply other threads:[~2023-07-06 21:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 19:40 [PATCH 0/2] Fix MCE handling on AMD hosts John Allen
2023-07-06 19:40 ` [PATCH 1/2] i386: Add support for SUCCOR feature John Allen
2023-07-06 20:22 ` Moger, Babu
2023-07-06 21:07 ` Joao Martins
2023-07-07 14:25 ` Paolo Bonzini
2023-07-12 19:11 ` John Allen
2023-07-20 13:29 ` Joao Martins
2023-07-06 19:40 ` [PATCH 2/2] i386: Fix MCE support for AMD hosts John Allen
2023-07-06 21:07 ` Joao Martins [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=d700de55-a7ba-0857-99e9-0af4703312be@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=babu.moger@amd.com \
--cc=eduardo@habkost.net \
--cc=john.allen@amd.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=william.roche@oracle.com \
--cc=yazen.ghannam@amd.com \
/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).