Re: [PATCH 1/5 v6] KVM: SVM: Define actual size of IOPM and MSRPM tables

Sean Christopherson
2021-04-02T17:52:42Z

On Thu, Apr 01, 2021, Krish Sadhukhan wrote:
> Define the actual size of the IOPM and MSRPM tables so that the actual size
> can be used when initializing them and when checking the consistency of the
> physical addresses. These #defines are placed in svm.h so that they can be
> shared.
> static void svm_prepare_guest_switch(struct kvm_vcpu *vcpu)
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index 39e071fdab0c..d0a4d7ce8445 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -28,6 +28,9 @@ static const u32 host_save_user_msrs[] = {
> };
> #define NR_HOST_SAVE_USER_MSRS ARRAY_SIZE(host_save_user_msrs)
>
> +#define IOPM_ALLOC_SIZE PAGE_SIZE * 3
> +#define MSRPM_ALLOC_SIZE PAGE_SIZE * 2

Drop the "ALLOC", this is the architectural size, not the size that's allocated.

It'd also be nice to align the values. My personal preference would be to have
the number of pages come first, i.e. "3 pages" versus "4096 3-byte chunks", but
that's definitely getting deep into nitpick territory. :-)

#define IOPM_ALLOC_SIZE 3 * PAGE_SIZE
#define MSRPM_ALLOC_SIZE 2 * PAGE_SIZE
> +
> #define MAX_DIRECT_ACCESS_MSRS 18
> #define MSRPM_OFFSETS 16
> extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly;
> --
> 2.27.0
>