Skip to content

Commit dc1e67f

Browse files
committed
KVM VMX: Move MSR_IA32_VMX_MISC bit defines to asm/vmx.h
Move the handful of MSR_IA32_VMX_MISC bit defines that are currently in msr-indx.h to vmx.h so that all of the VMX_MISC defines and wrappers can be found in a single location. Opportunistically use BIT_ULL() instead of open coding hex values, add defines for feature bits that are architecturally defined, and move the defines down in the file so that they are colocated with the helpers for getting fields from VMX_MISC. No functional change intended. Cc: Shan Kang <shan.kang@intel.com> Cc: Kai Huang <kai.huang@intel.com> Signed-off-by: Xin Li <xin3.li@intel.com> [sean: split to separate patch, write changelog] Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Reviewed-by: Kai Huang <kai.huang@intel.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Link: https://lore.kernel.org/r/20240605231918.2915961-9-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 92e6480 commit dc1e67f

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

arch/x86/include/asm/msr-index.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,11 +1194,6 @@
11941194
#define MSR_IA32_SMBA_BW_BASE 0xc0000280
11951195
#define MSR_IA32_EVT_CFG_BASE 0xc0000400
11961196

1197-
/* MSR_IA32_VMX_MISC bits */
1198-
#define MSR_IA32_VMX_MISC_INTEL_PT (1ULL << 14)
1199-
#define MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS (1ULL << 29)
1200-
#define MSR_IA32_VMX_MISC_PREEMPTION_TIMER_SCALE 0x1F
1201-
12021197
/* AMD-V MSRs */
12031198
#define MSR_VM_CR 0xc0010114
12041199
#define MSR_VM_IGNNE 0xc0010115

arch/x86/include/asm/vmx.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,6 @@
122122

123123
#define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR 0x000011ff
124124

125-
#define VMX_MISC_PREEMPTION_TIMER_RATE_MASK 0x0000001f
126-
#define VMX_MISC_SAVE_EFER_LMA 0x00000020
127-
#define VMX_MISC_ACTIVITY_HLT 0x00000040
128-
#define VMX_MISC_ACTIVITY_WAIT_SIPI 0x00000100
129-
#define VMX_MISC_ZERO_LEN_INS 0x40000000
130-
#define VMX_MISC_MSR_LIST_MULTIPLIER 512
131-
132125
/* VMFUNC functions */
133126
#define VMFUNC_CONTROL_BIT(x) BIT((VMX_FEATURE_##x & 0x1f) - 28)
134127

@@ -160,6 +153,18 @@ static inline u64 vmx_basic_encode_vmcs_info(u32 revision, u16 size, u8 memtype)
160153
return revision | ((u64)size << 32) | ((u64)memtype << 50);
161154
}
162155

156+
#define VMX_MISC_PREEMPTION_TIMER_RATE_MASK GENMASK_ULL(4, 0)
157+
#define VMX_MISC_SAVE_EFER_LMA BIT_ULL(5)
158+
#define VMX_MISC_ACTIVITY_HLT BIT_ULL(6)
159+
#define VMX_MISC_ACTIVITY_SHUTDOWN BIT_ULL(7)
160+
#define VMX_MISC_ACTIVITY_WAIT_SIPI BIT_ULL(8)
161+
#define VMX_MISC_INTEL_PT BIT_ULL(14)
162+
#define VMX_MISC_RDMSR_IN_SMM BIT_ULL(15)
163+
#define VMX_MISC_VMXOFF_BLOCK_SMI BIT_ULL(28)
164+
#define VMX_MISC_VMWRITE_SHADOW_RO_FIELDS BIT_ULL(29)
165+
#define VMX_MISC_ZERO_LEN_INS BIT_ULL(30)
166+
#define VMX_MISC_MSR_LIST_MULTIPLIER 512
167+
163168
static inline int vmx_misc_preemption_timer_rate(u64 vmx_misc)
164169
{
165170
return vmx_misc & VMX_MISC_PREEMPTION_TIMER_RATE_MASK;

arch/x86/kvm/vmx/capabilities.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static inline bool cpu_has_vmx_vmfunc(void)
223223
static inline bool cpu_has_vmx_shadow_vmcs(void)
224224
{
225225
/* check if the cpu supports writing r/o exit information fields */
226-
if (!(vmcs_config.misc & MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS))
226+
if (!(vmcs_config.misc & VMX_MISC_VMWRITE_SHADOW_RO_FIELDS))
227227
return false;
228228

229229
return vmcs_config.cpu_based_2nd_exec_ctrl &
@@ -365,7 +365,7 @@ static inline bool cpu_has_vmx_invvpid_global(void)
365365

366366
static inline bool cpu_has_vmx_intel_pt(void)
367367
{
368-
return (vmcs_config.misc & MSR_IA32_VMX_MISC_INTEL_PT) &&
368+
return (vmcs_config.misc & VMX_MISC_INTEL_PT) &&
369369
(vmcs_config.cpu_based_2nd_exec_ctrl & SECONDARY_EXEC_PT_USE_GPA) &&
370370
(vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_RTIT_CTL);
371371
}

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7062,7 +7062,7 @@ static void nested_vmx_setup_misc_data(struct vmcs_config *vmcs_conf,
70627062
{
70637063
msrs->misc_low = (u32)vmcs_conf->misc & VMX_MISC_SAVE_EFER_LMA;
70647064
msrs->misc_low |=
7065-
MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS |
7065+
VMX_MISC_VMWRITE_SHADOW_RO_FIELDS |
70667066
VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE |
70677067
VMX_MISC_ACTIVITY_HLT |
70687068
VMX_MISC_ACTIVITY_WAIT_SIPI;

arch/x86/kvm/vmx/nested.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static inline unsigned nested_cpu_vmx_misc_cr3_count(struct kvm_vcpu *vcpu)
109109
static inline bool nested_cpu_has_vmwrite_any_field(struct kvm_vcpu *vcpu)
110110
{
111111
return to_vmx(vcpu)->nested.msrs.misc_low &
112-
MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS;
112+
VMX_MISC_VMWRITE_SHADOW_RO_FIELDS;
113113
}
114114

115115
static inline bool nested_cpu_has_zero_length_injection(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)