Commit 03916db9 authored by Paolo Bonzini's avatar Paolo Bonzini

Replace NR_VMX_MSR with its definition

Using ARRAY_SIZE directly makes it easier to read the code.  While touching
the code, replace the division by a multiplication in the recently added
BUILD_BUG_ON.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 0123be42
...@@ -823,7 +823,6 @@ static const u32 vmx_msr_index[] = { ...@@ -823,7 +823,6 @@ static const u32 vmx_msr_index[] = {
#endif #endif
MSR_EFER, MSR_TSC_AUX, MSR_STAR, MSR_EFER, MSR_TSC_AUX, MSR_STAR,
}; };
#define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index)
static inline bool is_page_fault(u32 intr_info) static inline bool is_page_fault(u32 intr_info)
{ {
...@@ -4441,7 +4440,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx) ...@@ -4441,7 +4440,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
vmx->vcpu.arch.pat = host_pat; vmx->vcpu.arch.pat = host_pat;
} }
for (i = 0; i < NR_VMX_MSR; ++i) { for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i) {
u32 index = vmx_msr_index[i]; u32 index = vmx_msr_index[i];
u32 data_low, data_high; u32 data_low, data_high;
int j = vmx->nmsrs; int j = vmx->nmsrs;
...@@ -7608,7 +7607,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) ...@@ -7608,7 +7607,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
goto free_vcpu; goto free_vcpu;
vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL); vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
BUILD_BUG_ON(PAGE_SIZE / sizeof(struct shared_msr_entry) < NR_VMX_MSR); BUILD_BUG_ON(ARRAY_SIZE(vmx_msr_index) * sizeof(vmx->guest_msrs[0])
> PAGE_SIZE);
err = -ENOMEM; err = -ENOMEM;
if (!vmx->guest_msrs) { if (!vmx->guest_msrs) {
...@@ -8960,7 +8960,7 @@ static int __init vmx_init(void) ...@@ -8960,7 +8960,7 @@ static int __init vmx_init(void)
rdmsrl_safe(MSR_EFER, &host_efer); rdmsrl_safe(MSR_EFER, &host_efer);
for (i = 0; i < NR_VMX_MSR; ++i) for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i)
kvm_define_shared_msr(i, vmx_msr_index[i]); kvm_define_shared_msr(i, vmx_msr_index[i]);
vmx_io_bitmap_a = (unsigned long *)__get_free_page(GFP_KERNEL); vmx_io_bitmap_a = (unsigned long *)__get_free_page(GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment