Re: [PATCH v3 4/4] KVM: x86: Unify L1TF flushing under per-CPU variable

Pawan Gupta
2025-10-22T01:59:15Z

On Thu, Oct 16, 2025 at 01:04:17PM -0700, Sean Christopherson wrote:
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -395,26 +395,16 @@ static noinstr bool vmx_l1d_flush(struct kvm_vcpu *vcpu)
> * 'always'
> */
> if (static_branch_likely(&vmx_l1d_flush_cond)) {
> - bool flush_l1d;
> -
> /*
> - * Clear the per-vcpu flush bit, it gets set again if the vCPU
> + * Clear the per-cpu flush bit, it gets set again if the vCPU
> * is reloaded, i.e. if the vCPU is scheduled out or if KVM
> * exits to userspace, or if KVM reaches one of the unsafe
> - * VMEXIT handlers, e.g. if KVM calls into the emulator.
> + * VMEXIT handlers, e.g. if KVM calls into the emulator,
> + * or from the interrupt handlers.
> */
> - flush_l1d = vcpu->arch.l1tf_flush_l1d;
> - vcpu->arch.l1tf_flush_l1d = false;
> -
> - /*
> - * Clear the per-cpu flush bit, it gets set again from
> - * the interrupt handlers.
> - */
> - flush_l1d |= kvm_get_cpu_l1tf_flush_l1d();
> + if (!kvm_get_cpu_l1tf_flush_l1d())
> + return;

This should be returning false here.

> kvm_clear_cpu_l1tf_flush_l1d();
> -
> - if (!flush_l1d)
> - return false;
> }