From: "Carlos López" <clopez@suse.de>
To: Sean Christopherson <seanjc@google.com>, Tony Luck <tony.luck@intel.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: Fix array_index_nospec() protection in kvm_vcpu_ioctl_x86_set_mce()
Date: Tue, 2 Jun 2026 22:22:17 +0200 [thread overview]
Message-ID: <a6c36a35-c39c-4dec-b1e6-238297aa7159@suse.de> (raw)
In-Reply-To: <b43be54c-329c-4b75-bd53-29ac63c1dd37@suse.de>
On 6/2/26 9:56 PM, Carlos López wrote:
> ...
> * Non-UCNA error logging is broken, at least on the count that logging
> is gated based on MCi_CTL, when it should not. The spec is ambiguous
> on whether MCG_CTL controls logging for these. Current behavior in KVM
> is to *do* the gating based on MCG_CTL; the spec suggests that this
> may be correct at least on AMD (but it is not symmetric with MCi_CTL
> behavior).
So something like this?
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c9e40f2a5996..259dba2a3299 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5505,24 +5505,31 @@ static int kvm_vcpu_ioctl_x86_set_mce(struct kvm_vcpu *vcpu,
if ((mce->status & MCI_STATUS_UC) && (mcg_cap & MCG_CTL_P) &&
vcpu->arch.mcg_ctl != ~(u64)0)
return 0;
- /*
- * if IA32_MCi_CTL is not all 1s, the uncorrected error
- * reporting is disabled for the bank
- */
- if ((mce->status & MCI_STATUS_UC) && banks[0] != ~(u64)0)
- return 0;
+
if (mce->status & MCI_STATUS_UC) {
+ /*
+ * Per the SDM, error logging always happens independently of
+ * IA32_MCi_CTL
+ */
+ if (banks[1] & MCI_STATUS_VAL)
+ mce->status |= MCI_STATUS_OVER;
+ banks[2] = mce->addr;
+ banks[3] = mce->misc;
+ banks[1] = mce->status;
+
+ /*
+ * if IA32_MCi_CTL is not all 1s, the uncorrected error
+ * reporting is disabled for the bank
+ */
+ if (banks[0] != ~(u64)0)
+ return 0;
+
if ((vcpu->arch.mcg_status & MCG_STATUS_MCIP) ||
!kvm_is_cr4_bit_set(vcpu, X86_CR4_MCE)) {
kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
return 0;
}
- if (banks[1] & MCI_STATUS_VAL)
- mce->status |= MCI_STATUS_OVER;
- banks[2] = mce->addr;
- banks[3] = mce->misc;
vcpu->arch.mcg_status = mce->mcg_status;
- banks[1] = mce->status;
kvm_queue_exception(vcpu, MC_VECTOR);
} else if (!(banks[1] & MCI_STATUS_VAL)
|| !(banks[1] & MCI_STATUS_UC)) {
prev parent reply other threads:[~2026-06-02 20:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-16 16:34 Carlos López
2026-05-18 14:46 ` Sean Christopherson
2026-05-18 15:16 ` Sean Christopherson
2026-06-02 19:56 ` Carlos López
2026-06-02 20:22 ` Carlos López [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=a6c36a35-c39c-4dec-b1e6-238297aa7159@suse.de \
--to=clopez@suse.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®