Re: [PATCH v4 4/8] KVM: VMX: Handle MMIO Stale Data in VM-Enter assembly via ALTERNATIVES_2
From: Borislav Petkov
Date: Wed Nov 12 2025 - 11:42:06 EST
On Thu, Oct 30, 2025 at 05:30:36PM -0700, Sean Christopherson wrote:
> @@ -137,6 +138,12 @@ SYM_FUNC_START(__vmx_vcpu_run)
> /* Load @regs to RAX. */
> mov (%_ASM_SP), %_ASM_AX
>
> + /* Stash "clear for MMIO" in EFLAGS.ZF (used below). */
Oh wow. Alternatives interdependence. What can go wrong. :)
> + ALTERNATIVE_2 "", \
> + __stringify(test $VMX_RUN_CLEAR_CPU_BUFFERS_FOR_MMIO, %ebx), \
So this VMX_RUN_CLEAR_CPU_BUFFERS_FOR_MMIO bit gets set here:
if (cpu_feature_enabled(X86_FEATURE_CLEAR_CPU_BUF_MMIO) &&
kvm_vcpu_can_access_host_mmio(&vmx->vcpu))
flags |= VMX_RUN_CLEAR_CPU_BUFFERS_FOR_MMIO;
So how static and/or dynamic is this?
IOW, can you stick this into a simple variable which is unconditionally
updated and you can use it in X86_FEATURE_CLEAR_CPU_BUF_MMIO case and
otherwise it simply remains unused?
Because then you get rid of that yuckiness.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette