aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-07-24 08:21:57 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-24 08:21:57 -0400
commit03916db9348c079d8d214f971cc114bb51c6b869 (patch)
treeac1511a292ad97f810f03b5ed45805a9e45d0fbc /arch/x86/kvm/vmx.c
parent0123be429fef40f067e5b1811576c3994229f59e (diff)
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: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 3397a88b7463..a3845b8e2b80 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -823,7 +823,6 @@ static const u32 vmx_msr_index[] = {
823#endif 823#endif
824 MSR_EFER, MSR_TSC_AUX, MSR_STAR, 824 MSR_EFER, MSR_TSC_AUX, MSR_STAR,
825}; 825};
826#define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index)
827 826
828static inline bool is_page_fault(u32 intr_info) 827static inline bool is_page_fault(u32 intr_info)
829{ 828{
@@ -4441,7 +4440,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
4441 vmx->vcpu.arch.pat = host_pat; 4440 vmx->vcpu.arch.pat = host_pat;
4442 } 4441 }
4443 4442
4444 for (i = 0; i < NR_VMX_MSR; ++i) { 4443 for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i) {
4445 u32 index = vmx_msr_index[i]; 4444 u32 index = vmx_msr_index[i];
4446 u32 data_low, data_high; 4445 u32 data_low, data_high;
4447 int j = vmx->nmsrs; 4446 int j = vmx->nmsrs;
@@ -7608,7 +7607,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
7608 goto free_vcpu; 7607 goto free_vcpu;
7609 7608
7610 vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL); 7609 vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
7611 BUILD_BUG_ON(PAGE_SIZE / sizeof(struct shared_msr_entry) < NR_VMX_MSR); 7610 BUILD_BUG_ON(ARRAY_SIZE(vmx_msr_index) * sizeof(vmx->guest_msrs[0])
7611 > PAGE_SIZE);
7612 7612
7613 err = -ENOMEM; 7613 err = -ENOMEM;
7614 if (!vmx->guest_msrs) { 7614 if (!vmx->guest_msrs) {
@@ -8960,7 +8960,7 @@ static int __init vmx_init(void)
8960 8960
8961 rdmsrl_safe(MSR_EFER, &host_efer); 8961 rdmsrl_safe(MSR_EFER, &host_efer);
8962 8962
8963 for (i = 0; i < NR_VMX_MSR; ++i) 8963 for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i)
8964 kvm_define_shared_msr(i, vmx_msr_index[i]); 8964 kvm_define_shared_msr(i, vmx_msr_index[i]);
8965 8965
8966 vmx_io_bitmap_a = (unsigned long *)__get_free_page(GFP_KERNEL); 8966 vmx_io_bitmap_a = (unsigned long *)__get_free_page(GFP_KERNEL);