linux/arch/x86/kvm/svm
Mingwei Zhang bb2baeb214 KVM: SVM: improve the code readability for ASID management
KVM SEV code uses bitmaps to manage ASID states. ASID 0 was always skipped
because it is never used by VM. Thus, in existing code, ASID value and its
bitmap postion always has an 'offset-by-1' relationship.

Both SEV and SEV-ES shares the ASID space, thus KVM uses a dynamic range
[min_asid, max_asid] to handle SEV and SEV-ES ASIDs separately.

Existing code mixes the usage of ASID value and its bitmap position by
using the same variable called 'min_asid'.

Fix the min_asid usage: ensure that its usage is consistent with its name;
allocate extra size for ASID 0 to ensure that each ASID has the same value
with its bitmap position. Add comments on ASID bitmap allocation to clarify
the size change.

Signed-off-by: Mingwei Zhang <mizhang@google.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Marc Orr <marcorr@google.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Alper Gun <alpergun@google.com>
Cc: Dionna Glaze <dionnaglaze@google.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Vipin Sharma <vipinsh@google.com>
Cc: Peter Gonda <pgonda@google.com>
Cc: Joerg Roedel <joro@8bytes.org>
Message-Id: <20210802180903.159381-1-mizhang@google.com>
[Fix up sev_asid_free to also index by ASID, as suggested by Sean
 Christopherson, and use nr_asids in sev_cpu_init. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-08-04 09:43:03 -04:00
..
avic.c KVM: SVM: use vmcb01 in svm_refresh_apicv_exec_ctrl 2021-07-27 16:59:01 -04:00
nested.c KVM: SVM: tweak warning about enabled AVIC on nested entry 2021-07-27 16:59:01 -04:00
pmu.c KVM: x86/vPMU: Forbid writing to MSR_F15H_PERF MSRs when guest doesn't have X86_FEATURE_PERFCTR_CORE 2021-03-30 13:07:10 -04:00
sev.c KVM: SVM: improve the code readability for ASID management 2021-08-04 09:43:03 -04:00
svm_onhyperv.c KVM: SVM: hyper-v: Direct Virtual Flush support 2021-06-17 13:09:38 -04:00
svm_onhyperv.h KVM: SVM: delay svm_vcpu_init_msrpm after svm->vmcb is initialized 2021-07-27 16:59:00 -04:00
svm_ops.h KVM: SVM: use vmsave/vmload for saving/restoring additional host state 2021-02-04 05:27:34 -05:00
svm.c KVM: SVM: svm_set_vintr don't warn if AVIC is active but is about to be deactivated 2021-07-27 16:59:00 -04:00
svm.h KVM: nSVM: Swap the parameter order for svm_copy_vmrun_state()/svm_copy_vmloadsave_state() 2021-07-26 08:09:46 -04:00
vmenter.S KVM/SVM: Move vmenter.S exception fixups out of line 2021-03-15 04:43:56 -04:00