Commit 2423a4c0 authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Paolo Bonzini

KVM: nVMX: Rename vmcs_to_field_offset{,_table}

vmcs_to_field_offset{,_table} may sound misleading as VMCS is an opaque
blob which is not supposed to be accessed directly. In fact,
vmcs_to_field_offset{,_table} are related to KVM defined VMCS12 structure.

Rename vmcs_field_to_offset() to get_vmcs12_field_offset() for clarity.

No functional change intended.
Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20220112170134.1904308-4-vkuznets@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 7a601e2c
...@@ -5113,7 +5113,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu) ...@@ -5113,7 +5113,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
/* Decode instruction info and find the field to read */ /* Decode instruction info and find the field to read */
field = kvm_register_read(vcpu, (((instr_info) >> 28) & 0xf)); field = kvm_register_read(vcpu, (((instr_info) >> 28) & 0xf));
offset = vmcs_field_to_offset(field); offset = get_vmcs12_field_offset(field);
if (offset < 0) if (offset < 0)
return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT); return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);
...@@ -5216,7 +5216,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu) ...@@ -5216,7 +5216,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
field = kvm_register_read(vcpu, (((instr_info) >> 28) & 0xf)); field = kvm_register_read(vcpu, (((instr_info) >> 28) & 0xf));
offset = vmcs_field_to_offset(field); offset = get_vmcs12_field_offset(field);
if (offset < 0) if (offset < 0)
return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT); return nested_vmx_fail(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);
...@@ -6464,7 +6464,7 @@ static u64 nested_vmx_calc_vmcs_enum_msr(void) ...@@ -6464,7 +6464,7 @@ static u64 nested_vmx_calc_vmcs_enum_msr(void)
max_idx = 0; max_idx = 0;
for (i = 0; i < nr_vmcs12_fields; i++) { for (i = 0; i < nr_vmcs12_fields; i++) {
/* The vmcs12 table is very, very sparsely populated. */ /* The vmcs12 table is very, very sparsely populated. */
if (!vmcs_field_to_offset_table[i]) if (!vmcs12_field_offsets[i])
continue; continue;
idx = vmcs_field_index(VMCS12_IDX_TO_ENC(i)); idx = vmcs_field_index(VMCS12_IDX_TO_ENC(i));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
FIELD(number, name), \ FIELD(number, name), \
[ROL16(number##_HIGH, 6)] = VMCS12_OFFSET(name) + sizeof(u32) [ROL16(number##_HIGH, 6)] = VMCS12_OFFSET(name) + sizeof(u32)
const unsigned short vmcs_field_to_offset_table[] = { const unsigned short vmcs12_field_offsets[] = {
FIELD(VIRTUAL_PROCESSOR_ID, virtual_processor_id), FIELD(VIRTUAL_PROCESSOR_ID, virtual_processor_id),
FIELD(POSTED_INTR_NV, posted_intr_nv), FIELD(POSTED_INTR_NV, posted_intr_nv),
FIELD(GUEST_ES_SELECTOR, guest_es_selector), FIELD(GUEST_ES_SELECTOR, guest_es_selector),
...@@ -151,4 +151,4 @@ const unsigned short vmcs_field_to_offset_table[] = { ...@@ -151,4 +151,4 @@ const unsigned short vmcs_field_to_offset_table[] = {
FIELD(HOST_RSP, host_rsp), FIELD(HOST_RSP, host_rsp),
FIELD(HOST_RIP, host_rip), FIELD(HOST_RIP, host_rip),
}; };
const unsigned int nr_vmcs12_fields = ARRAY_SIZE(vmcs_field_to_offset_table); const unsigned int nr_vmcs12_fields = ARRAY_SIZE(vmcs12_field_offsets);
...@@ -361,10 +361,10 @@ static inline void vmx_check_vmcs12_offsets(void) ...@@ -361,10 +361,10 @@ static inline void vmx_check_vmcs12_offsets(void)
CHECK_OFFSET(guest_pml_index, 996); CHECK_OFFSET(guest_pml_index, 996);
} }
extern const unsigned short vmcs_field_to_offset_table[]; extern const unsigned short vmcs12_field_offsets[];
extern const unsigned int nr_vmcs12_fields; extern const unsigned int nr_vmcs12_fields;
static inline short vmcs_field_to_offset(unsigned long field) static inline short get_vmcs12_field_offset(unsigned long field)
{ {
unsigned short offset; unsigned short offset;
unsigned int index; unsigned int index;
...@@ -377,7 +377,7 @@ static inline short vmcs_field_to_offset(unsigned long field) ...@@ -377,7 +377,7 @@ static inline short vmcs_field_to_offset(unsigned long field)
return -ENOENT; return -ENOENT;
index = array_index_nospec(index, nr_vmcs12_fields); index = array_index_nospec(index, nr_vmcs12_fields);
offset = vmcs_field_to_offset_table[index]; offset = vmcs12_field_offsets[index];
if (offset == 0) if (offset == 0)
return -ENOENT; return -ENOENT;
return offset; return offset;
......
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