Re: [PATCH] KVM: VMX: Don't disable FB_CLEAR when doing the MMIO Stale Data VERW
From: Pawan Gupta
Date: Tue Nov 24 2026 - 18:26:33 EST
On Tue, Nov 24, 2026 at 07:06:13PM +0100, Amirmohammad Eftekhar wrote:
> Don't set FB_CLEAR_DIS for a VM-Enter that does the MMIO Stale Data VERW.
> VERW doesn't overwrite the fill buffers while FB_CLEAR_DIS is set, so the
> buffer clear that is meant to protect the host from a guest with access
> to host MMIO currently does nothing. Keep using FB_CLEAR_DIS for vCPUs
> that can't access host MMIO, which are the guests it was added for.
Thanks for the patch, the problem is real. I believe the affected use case
is a guest with MMIO device on ICX, and none of MDS_NO/TAA_NO/FB_CLEAR
exported to guest.
...
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 68fa251dda60..490cad070c13 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -482,11 +482,24 @@ static const struct kernel_param_ops vmentry_l1d_flush_ops = {
> };
> module_param_cb(vmentry_l1d_flush, &vmentry_l1d_flush_ops, NULL, 0644);
>
> -static __always_inline void vmx_disable_fb_clear(struct vcpu_vmx *vmx)
> +/*
> + * VERW doesn't overwrite the fill buffers if FB_CLEAR_DIS is set, so leave
> + * FB_CLEAR enabled for a VM-Enter that does the MMIO Stale Data VERW. The
> + * unconditional VERW is already handled by vmx_update_fb_clear_dis().
> + */
> +static __always_inline bool vmx_should_disable_fb_clear(struct vcpu_vmx *vmx,
> + unsigned int flags)
> +{
> + return vmx->disable_fb_clear &&
> + !(flags & KVM_ENTER_CLEAR_CPU_BUFFERS_FOR_MMIO);
This doesn't seem right, FB_CLEAR_DIS's main use case is FOR_MMIO.
The ideal fix would be to set FB_CLEAR_DIS after VERW in KVM-entry. But,
thats quite late in the entry path, moving the MSR-write past that is
non-trivial.
I believe it is best to restore the earlier order just for the MMIO case,
i.e. do VERW for CLEAR_CPU_BUFFERS_FOR_MMIO before setting FB_CLEAR_DIS
like:
vmx_disable_fb_clear()
{
if (!vmx->disable_fb_clear)
return;
if (flags & KVM_ENTER_CLEAR_CPU_BUFFERS_FOR_MMIO)
x86_clear_cpu_buffers(); <-------- here
msr = native_rdmsrq(MSR_IA32_MCU_OPT_CTRL);
...
Sean, would you agree?