* [PATCH] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS
@ 2025-10-08 20:25 Jon Kohler
2025-10-09 7:12 ` Pawan Gupta
2025-10-11 7:02 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: Jon Kohler @ 2025-10-08 20:25 UTC (permalink / raw)
To: Paolo Bonzini, Marcelo Tosatti, kvm, qemu-devel
Cc: Jon Kohler, Pawan Gupta, Sean Christopherson
Newer Intel hardware (Sapphire Rapids and higher) sets multiple MDS
immunity bits in MSR_IA32_ARCH_CAPABILITIES but lacks the hardware-level
MSR_ARCH_CAP_FB_CLEAR (bit 17):
ARCH_CAP_MDS_NO
ARCH_CAP_TAA_NO
ARCH_CAP_PSDP_NO
ARCH_CAP_FBSDP_NO
ARCH_CAP_SBDR_SSDP_NO
This prevents VMs with fb-clear=on from migrating from older hardware
(Cascade Lake, Ice Lake) to newer hardware, limiting live migration
capabilities. Note fb-clear was first introduced in v8.1.0 [1].
Expose MSR_ARCH_CAP_FB_CLEAR for MDS-invulnerable systems to enable
seamless migration between hardware generations.
Note: There is no impact when a guest migrates to newer hardware as
the existing bit combinations already mark the host as MMIO-immune and
disable FB_CLEAR operations in the kernel (see Linux's
arch_cap_mmio_immune() and vmx_update_fb_clear_dis()). See kernel side
discussion for [2] for additional context.
[1] 22e1094ca82 ("target/i386: add support for FB_CLEAR feature")
[2] https://patchwork.kernel.org/project/kvm/patch/20250401044931.793203-1-jon@nutanix.com/
Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Jon Kohler <jon@nutanix.com>
---
target/i386/kvm/kvm.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 6a3a1c1ed8..610d786310 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -657,6 +657,23 @@ uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index)
must_be_one = (uint32_t)value;
can_be_one = (uint32_t)(value >> 32);
return can_be_one & ~must_be_one;
+ case MSR_IA32_ARCH_CAPABILITIES:
+ /*
+ * Special handling for fb-clear bit in ARCH_CAPABILITIES MSR.
+ * KVM will only report the bit if it is enabled in the host,
+ * but, for live migration capability purposes, we want to
+ * expose the bit to the guest even if it is disabled in the
+ * host, as long as the host itself is not vulnerable to
+ * the issue that the fb-clear bit is meant to mitigate.
+ */
+ if ((value & MSR_ARCH_CAP_MDS_NO) &&
+ (value & MSR_ARCH_CAP_TAA_NO) &&
+ (value & MSR_ARCH_CAP_SBDR_SSDP_NO) &&
+ (value & MSR_ARCH_CAP_FBSDP_NO) &&
+ (value & MSR_ARCH_CAP_PSDP_NO)) {
+ value |= MSR_ARCH_CAP_FB_CLEAR;
+ }
+ return value;
default:
return value;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS
2025-10-08 20:25 [PATCH] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS Jon Kohler
@ 2025-10-09 7:12 ` Pawan Gupta
2025-10-11 7:02 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Pawan Gupta @ 2025-10-09 7:12 UTC (permalink / raw)
To: Jon Kohler
Cc: Paolo Bonzini, Marcelo Tosatti, kvm, qemu-devel,
Sean Christopherson
On Wed, Oct 08, 2025 at 01:25:57PM -0700, Jon Kohler wrote:
> Newer Intel hardware (Sapphire Rapids and higher) sets multiple MDS
> immunity bits in MSR_IA32_ARCH_CAPABILITIES but lacks the hardware-level
> MSR_ARCH_CAP_FB_CLEAR (bit 17):
> ARCH_CAP_MDS_NO
> ARCH_CAP_TAA_NO
> ARCH_CAP_PSDP_NO
> ARCH_CAP_FBSDP_NO
> ARCH_CAP_SBDR_SSDP_NO
>
> This prevents VMs with fb-clear=on from migrating from older hardware
> (Cascade Lake, Ice Lake) to newer hardware, limiting live migration
> capabilities. Note fb-clear was first introduced in v8.1.0 [1].
>
> Expose MSR_ARCH_CAP_FB_CLEAR for MDS-invulnerable systems to enable
> seamless migration between hardware generations.
LGTM, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS
2025-10-08 20:25 [PATCH] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS Jon Kohler
2025-10-09 7:12 ` Pawan Gupta
@ 2025-10-11 7:02 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2025-10-11 7:02 UTC (permalink / raw)
To: Jon Kohler
Cc: Marcelo Tosatti, kvm, qemu-devel, Pawan Gupta,
Sean Christopherson
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-11 7:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-08 20:25 [PATCH] i386/kvm: Expose ARCH_CAP_FB_CLEAR when invulnerable to MDS Jon Kohler
2025-10-09 7:12 ` Pawan Gupta
2025-10-11 7:02 ` Paolo Bonzini
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).