Skip to content

Commit 465932d

Browse files
robert-hoobonzini
authored andcommitted
x86/cpu: Add new VMX feature, Tertiary VM-Execution control
A new 64-bit control field "tertiary processor-based VM-execution controls", is defined [1]. It's controlled by bit 17 of the primary processor-based VM-execution controls. Different from its brother VM-execution fields, this tertiary VM- execution controls field is 64 bit. So it occupies 2 vmx_feature_leafs, TERTIARY_CTLS_LOW and TERTIARY_CTLS_HIGH. Its companion VMX capability reporting MSR,MSR_IA32_VMX_PROCBASED_CTLS3 (0x492), is also semantically different from its brothers, whose 64 bits consist of all allow-1, rather than 32-bit allow-0 and 32-bit allow-1 [1][2]. Therefore, its init_vmx_capabilities() is a little different from others. [1] ISE 6.2 "VMCS Changes" https://www.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html [2] SDM Vol3. Appendix A.3 Reviewed-by: Sean Christopherson <[email protected]> Reviewed-by: Maxim Levitsky <[email protected]> Signed-off-by: Robert Hoo <[email protected]> Signed-off-by: Zeng Guang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent b8b9156 commit 465932d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@
980980
#define MSR_IA32_VMX_TRUE_EXIT_CTLS 0x0000048f
981981
#define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490
982982
#define MSR_IA32_VMX_VMFUNC 0x00000491
983+
#define MSR_IA32_VMX_PROCBASED_CTLS3 0x00000492
983984

984985
/* VMX_BASIC bits and bitmasks */
985986
#define VMX_BASIC_VMCS_SIZE_SHIFT 32

arch/x86/include/asm/vmxfeatures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/*
66
* Defines VMX CPU feature bits
77
*/
8-
#define NVMXINTS 3 /* N 32-bit words worth of info */
8+
#define NVMXINTS 5 /* N 32-bit words worth of info */
99

1010
/*
1111
* Note: If the comment begins with a quoted string, that string is used
@@ -43,6 +43,7 @@
4343
#define VMX_FEATURE_RDTSC_EXITING ( 1*32+ 12) /* "" VM-Exit on RDTSC */
4444
#define VMX_FEATURE_CR3_LOAD_EXITING ( 1*32+ 15) /* "" VM-Exit on writes to CR3 */
4545
#define VMX_FEATURE_CR3_STORE_EXITING ( 1*32+ 16) /* "" VM-Exit on reads from CR3 */
46+
#define VMX_FEATURE_TERTIARY_CONTROLS ( 1*32+ 17) /* "" Enable Tertiary VM-Execution Controls */
4647
#define VMX_FEATURE_CR8_LOAD_EXITING ( 1*32+ 19) /* "" VM-Exit on writes to CR8 */
4748
#define VMX_FEATURE_CR8_STORE_EXITING ( 1*32+ 20) /* "" VM-Exit on reads from CR8 */
4849
#define VMX_FEATURE_VIRTUAL_TPR ( 1*32+ 21) /* "vtpr" TPR virtualization, a.k.a. TPR shadow */

arch/x86/kernel/cpu/feat_ctl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ enum vmx_feature_leafs {
1515
MISC_FEATURES = 0,
1616
PRIMARY_CTLS,
1717
SECONDARY_CTLS,
18+
TERTIARY_CTLS_LOW,
19+
TERTIARY_CTLS_HIGH,
1820
NR_VMX_FEATURE_WORDS,
1921
};
2022

2123
#define VMX_F(x) BIT(VMX_FEATURE_##x & 0x1f)
2224

2325
static void init_vmx_capabilities(struct cpuinfo_x86 *c)
2426
{
25-
u32 supported, funcs, ept, vpid, ign;
27+
u32 supported, funcs, ept, vpid, ign, low, high;
2628

2729
BUILD_BUG_ON(NVMXINTS != NR_VMX_FEATURE_WORDS);
2830

@@ -42,6 +44,11 @@ static void init_vmx_capabilities(struct cpuinfo_x86 *c)
4244
rdmsr_safe(MSR_IA32_VMX_PROCBASED_CTLS2, &ign, &supported);
4345
c->vmx_capability[SECONDARY_CTLS] = supported;
4446

47+
/* All 64 bits of tertiary controls MSR are allowed-1 settings. */
48+
rdmsr_safe(MSR_IA32_VMX_PROCBASED_CTLS3, &low, &high);
49+
c->vmx_capability[TERTIARY_CTLS_LOW] = low;
50+
c->vmx_capability[TERTIARY_CTLS_HIGH] = high;
51+
4552
rdmsr(MSR_IA32_VMX_PINBASED_CTLS, ign, supported);
4653
rdmsr_safe(MSR_IA32_VMX_VMFUNC, &ign, &funcs);
4754

0 commit comments

Comments
 (0)