Re: [PATCH v1 02/28] KVM: SVM: Document number of ASIDs CPUID setting

From: Yosry Ahmed

Date: Sat Aug 01 2026 - 02:10:40 EST


On Mon, Jul 27, 2026 at 5:36 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
>
> KVM arbitrarly advertises 8 ASIDs in KVM_GET_SUPPORTED_CPUID for
> historical reasons. Advertising a small number of ASIDs to L1 is
> currently harmless, as KVM (L0) uses the same ASID for both L1 and L2,
> and flushes that ASID on nested transitions.
>
> However, following changes will add proper ASID emulation and a separate
> ASID for L2, minimizing the TLB flushes on nested transitions. At that
> point, a full TLB flush from a KVM guest (L1) would flush both L1 and L2
> ASIDs, so should be avoided as much as possible by advertising more
> ASIDs to L1.
>
> Increasing the value advertised by KVM is tricky, because a VMM copying
> the number of ASIDs from KVM_GET_SUPPORTED_CPUID may perceive a new VM
> with a higher number of ASIDs as incompatible with older KVM (which is
> not true).
>
> Avoid changing the value advertised by KVM, but document that it is
> essentially meaningless and does not represent a limit or a hint. Also,
> more-or-less encourage userspace to advertise a higher value to avoid
> potential unnecessary TLB flushes from an L1 hypervisor.
>
> Suggested-by: Jim Mattson <jmattson@xxxxxxxxxx>
> Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> ---
> Documentation/virt/kvm/api.rst | 20 ++++++++++++++++++++
> arch/x86/kvm/cpuid.c | 4 ++--
> 2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index a5f9ee92f43e8..2d24bf708d77e 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -9542,6 +9542,26 @@ the APIC ID is found in EDX for all subleaves of 0x0b and 0x1f, and in EAX
> for 0x8000001e; the latter also encodes the core id and node id in bits
> 7:0 of EBX and ECX respectively.
>
> +Number of ASIDs (nested SVM)
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +CPUID[0x8000000A]:EBX reports the number of ASIDs supported by the processor
> +on AMD CPUs. KVM's ``KVM_GET_SUPPORTED_CPUID`` hardcodes this value to 8 for
> +historical reasons. This is value is arbitrary and does not represent a

This value*