aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2013-06-26 14:36:21 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2013-07-18 06:29:28 -0400
commitc2bae8939487c101b0516c4c8ad80f543b22bb29 (patch)
treed68d39e7a80b252a002a36aa5f70777b12c084cf /arch/x86/kvm
parenta25eb114d50d6e60ef586f2466c874581c31594c (diff)
KVM: VMX: Use proper types to access const arrays
Use a const pointer type instead of casting away the const qualifier from const arrays. Keep the pointer array on the stack, nonetheless. Making it static just increases the object size. Signed-off-by: Mathias Krause <minipli@googlemail.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2cd1be8ce384..183dc72b2523 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5971,8 +5971,8 @@ static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
5971 unsigned long field; 5971 unsigned long field;
5972 u64 field_value; 5972 u64 field_value;
5973 struct vmcs *shadow_vmcs = vmx->nested.current_shadow_vmcs; 5973 struct vmcs *shadow_vmcs = vmx->nested.current_shadow_vmcs;
5974 unsigned long *fields = (unsigned long *)shadow_read_write_fields; 5974 const unsigned long *fields = shadow_read_write_fields;
5975 int num_fields = max_shadow_read_write_fields; 5975 const int num_fields = max_shadow_read_write_fields;
5976 5976
5977 vmcs_load(shadow_vmcs); 5977 vmcs_load(shadow_vmcs);
5978 5978
@@ -6001,12 +6001,11 @@ static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
6001 6001
6002static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx) 6002static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx)
6003{ 6003{
6004 unsigned long *fields[] = { 6004 const unsigned long *fields[] = {
6005 (unsigned long *)shadow_read_write_fields, 6005 shadow_read_write_fields,
6006 (unsigned long *)shadow_read_only_fields 6006 shadow_read_only_fields
6007 }; 6007 };
6008 int num_lists = ARRAY_SIZE(fields); 6008 const int max_fields[] = {
6009 int max_fields[] = {
6010 max_shadow_read_write_fields, 6009 max_shadow_read_write_fields,
6011 max_shadow_read_only_fields 6010 max_shadow_read_only_fields
6012 }; 6011 };
@@ -6017,7 +6016,7 @@ static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx)
6017 6016
6018 vmcs_load(shadow_vmcs); 6017 vmcs_load(shadow_vmcs);
6019 6018
6020 for (q = 0; q < num_lists; q++) { 6019 for (q = 0; q < ARRAY_SIZE(fields); q++) {
6021 for (i = 0; i < max_fields[q]; i++) { 6020 for (i = 0; i < max_fields[q]; i++) {
6022 field = fields[q][i]; 6021 field = fields[q][i];
6023 vmcs12_read_any(&vmx->vcpu, field, &field_value); 6022 vmcs12_read_any(&vmx->vcpu, field, &field_value);