[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] VMX: ensure MSR index enum and array remain in sync



commit d86ad7cb287b5ea05cfee20cdd277005d771886f
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Jun 23 17:47:44 2016 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jun 23 17:47:44 2016 +0200

    VMX: ensure MSR index enum and array remain in sync
    
    ... by using dedicated initializers. Also add an ASSERT() to make sure
    unintentional addition of holes to the array gets noticed. Ditch
    MSR_INDEX_SIZE as redundant with VMX_MSR_COUNT.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Kevin Tian <kevin.tian@xxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 65ee89e..54cdb86 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -321,20 +321,23 @@ static void vmx_vcpu_destroy(struct vcpu *v)
 
 static DEFINE_PER_CPU(struct vmx_msr_state, host_msr_state);
 
-static const u32 msr_index[] =
+static const u32 msr_index[VMX_MSR_COUNT] =
 {
-    MSR_LSTAR, MSR_STAR, MSR_SYSCALL_MASK
+    [VMX_INDEX_MSR_LSTAR]        = MSR_LSTAR,
+    [VMX_INDEX_MSR_STAR]         = MSR_STAR,
+    [VMX_INDEX_MSR_SYSCALL_MASK] = MSR_SYSCALL_MASK
 };
 
-#define MSR_INDEX_SIZE (ARRAY_SIZE(msr_index))
-
 void vmx_save_host_msrs(void)
 {
     struct vmx_msr_state *host_msr_state = &this_cpu(host_msr_state);
-    int i;
+    unsigned int i;
 
-    for ( i = 0; i < MSR_INDEX_SIZE; i++ )
+    for ( i = 0; i < ARRAY_SIZE(msr_index); i++ )
+    {
+        ASSERT(msr_index[i]);
         rdmsrl(msr_index[i], host_msr_state->msrs[i]);
+    }
 }
 
 #define WRITE_MSR(address) do {                                         \
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.