Re: [PATCH v3 05/27] KVM: SVM: Add helpers to set/clear ASID flush in VMCB
From: Jim Mattson
Date: Wed Oct 14 2026 - 18:00:35 EST
On Mon, Oct 12, 2026 at 4:36 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
>
> Introduce set/clear helpers to set tlb_ctl to
> TLB_CONTROL_FLUSH_ASID or TLB_CONTROL_DO_NOTHING. Incoming changes will
> eliminate the use of TLB_CONTROL_FLUSH_ALL_ASID except as a fallback
> when FLUSHBYASID is not available, so the helpers will create a common
> path for this.
No functional change intended? :)
>
> Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> ---
> arch/x86/kvm/svm/nested.c | 2 +-
> arch/x86/kvm/svm/sev.c | 2 +-
> arch/x86/kvm/svm/svm.c | 4 ++--
> arch/x86/kvm/svm/svm.h | 10 ++++++++++
> 4 files changed, 14 insertions(+), 4 deletions(-)
>
[ ... ]
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index 6d0242966dc87..ba5077b9838c0 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -480,6 +480,16 @@ static inline void vmcb_set_gpat(struct vmcb *vmcb, u64 data)
> vmcb_mark_dirty(vmcb, VMCB_NPT);
> }
>
> +static inline void vmcb_set_flush_asid(struct vmcb *vmcb)
> +{
> + vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ASID;
> +}
> +
> +static inline void vmcb_clr_flush_asid(struct vmcb *vmcb)
The name of this function makes it sound like the inverse of
vmcb_set_flush_asid(), which it isn't. Maybe vmcb_clr_tlb_ctl()?
> +{
> + vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
> +}
> +
> static __always_inline struct vcpu_svm *to_svm(struct kvm_vcpu *vcpu)
> {
> return container_of(vcpu, struct vcpu_svm, vcpu);
> --
> 2.56.0.385.gd3acb90ef8-goog
>