Commit ed3905ba authored by Robert Hoo's avatar Robert Hoo Committed by Paolo Bonzini

KVM: VMX: Extend BUILD_CONTROLS_SHADOW macro to support 64-bit variation

The Tertiary VM-Exec Control, different from previous control fields, is 64
bit. So extend BUILD_CONTROLS_SHADOW() by adding a 'bit' parameter, to
support both 32 bit and 64 bit fields' auxiliary functions building.
Suggested-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarRobert Hoo <robert.hu@linux.intel.com>
Signed-off-by: default avatarZeng Guang <guang.zeng@intel.com>
Message-Id: <20220419153318.11595-1-guang.zeng@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 465932db
...@@ -456,35 +456,35 @@ static inline u8 vmx_get_rvi(void) ...@@ -456,35 +456,35 @@ static inline u8 vmx_get_rvi(void)
return vmcs_read16(GUEST_INTR_STATUS) & 0xff; return vmcs_read16(GUEST_INTR_STATUS) & 0xff;
} }
#define BUILD_CONTROLS_SHADOW(lname, uname) \ #define BUILD_CONTROLS_SHADOW(lname, uname, bits) \
static inline void lname##_controls_set(struct vcpu_vmx *vmx, u32 val) \ static inline void lname##_controls_set(struct vcpu_vmx *vmx, u##bits val) \
{ \ { \
if (vmx->loaded_vmcs->controls_shadow.lname != val) { \ if (vmx->loaded_vmcs->controls_shadow.lname != val) { \
vmcs_write32(uname, val); \ vmcs_write##bits(uname, val); \
vmx->loaded_vmcs->controls_shadow.lname = val; \ vmx->loaded_vmcs->controls_shadow.lname = val; \
} \ } \
} \ } \
static inline u32 __##lname##_controls_get(struct loaded_vmcs *vmcs) \ static inline u##bits __##lname##_controls_get(struct loaded_vmcs *vmcs) \
{ \ { \
return vmcs->controls_shadow.lname; \ return vmcs->controls_shadow.lname; \
} \ } \
static inline u32 lname##_controls_get(struct vcpu_vmx *vmx) \ static inline u##bits lname##_controls_get(struct vcpu_vmx *vmx) \
{ \ { \
return __##lname##_controls_get(vmx->loaded_vmcs); \ return __##lname##_controls_get(vmx->loaded_vmcs); \
} \ } \
static inline void lname##_controls_setbit(struct vcpu_vmx *vmx, u32 val) \ static inline void lname##_controls_setbit(struct vcpu_vmx *vmx, u##bits val) \
{ \ { \
lname##_controls_set(vmx, lname##_controls_get(vmx) | val); \ lname##_controls_set(vmx, lname##_controls_get(vmx) | val); \
} \ } \
static inline void lname##_controls_clearbit(struct vcpu_vmx *vmx, u32 val) \ static inline void lname##_controls_clearbit(struct vcpu_vmx *vmx, u##bits val) \
{ \ { \
lname##_controls_set(vmx, lname##_controls_get(vmx) & ~val); \ lname##_controls_set(vmx, lname##_controls_get(vmx) & ~val); \
} }
BUILD_CONTROLS_SHADOW(vm_entry, VM_ENTRY_CONTROLS) BUILD_CONTROLS_SHADOW(vm_entry, VM_ENTRY_CONTROLS, 32)
BUILD_CONTROLS_SHADOW(vm_exit, VM_EXIT_CONTROLS) BUILD_CONTROLS_SHADOW(vm_exit, VM_EXIT_CONTROLS, 32)
BUILD_CONTROLS_SHADOW(pin, PIN_BASED_VM_EXEC_CONTROL) BUILD_CONTROLS_SHADOW(pin, PIN_BASED_VM_EXEC_CONTROL, 32)
BUILD_CONTROLS_SHADOW(exec, CPU_BASED_VM_EXEC_CONTROL) BUILD_CONTROLS_SHADOW(exec, CPU_BASED_VM_EXEC_CONTROL, 32)
BUILD_CONTROLS_SHADOW(secondary_exec, SECONDARY_VM_EXEC_CONTROL) BUILD_CONTROLS_SHADOW(secondary_exec, SECONDARY_VM_EXEC_CONTROL, 32)
/* /*
* VMX_REGS_LAZY_LOAD_SET - The set of registers that will be updated in the * VMX_REGS_LAZY_LOAD_SET - The set of registers that will be updated in the
......
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