Re: [PATCH v3 23/27] KVM: nSVM: Do not reset TLB_CONTROL in vmcb02 on nested VM-Enter

From: Jim Mattson

Date: Thu Oct 15 2026 - 19:17:22 EST


On Mon, Oct 12, 2026 at 4:36 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
>
> Stop clearing TLB_CONTROL when preparing the control area of vmcb02, as
> this potentially undoes pending TLB flushes for L2 (e.g. through
> KVM_REQ_TLB_FLUSH while L1 is running), and remove the associated TODO
> comment.
>
> This is currently harmless, because nested_svm_entry_tlb_flush() always
> requests KVM_REQ_TLB_FLUSH_CURRENT on nested VM-Enter, which sets
> TLB_CONTROL again before L2 is actually run. However, always flushing
> will soon go away with proper TLB handling for L2, at which point always
> clearing TLB_CONTROL would be a bug.
>
> Clearing TLB_CONTROL on nested VM-Enter was probably done because
> TLB_CONTROL is not cleared by the CPU on VM-Exit. However, KVM always
> clears TLB_CONTROL in the active VMCB after a successful VMRUN. Hence,
> at nested VM-Enter, TLB_CONTROL in vmcb02 can only be non-zero if a TLB
> flush is queued for L2 while L1 is running (i.e. KVM_REQ_TLB_FLUSH), and

Nit: s/i.e./e.g./

> that should never be ignored.
>
> Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>