Skip to content

Commit 8e0b2b9

Browse files
bonziniKAGA-KOKO
authored andcommitted
x86/speculation: Use ARCH_CAPABILITIES to skip L1D flush on vmentry
Bit 3 of ARCH_CAPABILITIES tells a hypervisor that L1D flush on vmentry is not needed. Add a new value to enum vmx_l1d_flush_state, which is used either if there is no L1TF bug at all, or if bit 3 is set in ARCH_CAPABILITIES. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent ea156d1 commit 8e0b2b9

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#define MSR_IA32_ARCH_CAPABILITIES 0x0000010a
7171
#define ARCH_CAP_RDCL_NO (1 << 0) /* Not susceptible to Meltdown */
7272
#define ARCH_CAP_IBRS_ALL (1 << 1) /* Enhanced IBRS support */
73+
#define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH (1 << 3) /* Skip L1D flush on vmentry */
7374
#define ARCH_CAP_SSB_NO (1 << 4) /*
7475
* Not susceptible to Speculative Store Bypass
7576
* attack, so no Speculative Store Bypass

arch/x86/include/asm/vmx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ enum vmx_l1d_flush_state {
582582
VMENTER_L1D_FLUSH_COND,
583583
VMENTER_L1D_FLUSH_ALWAYS,
584584
VMENTER_L1D_FLUSH_EPT_DISABLED,
585+
VMENTER_L1D_FLUSH_NOT_REQUIRED,
585586
};
586587

587588
extern enum vmx_l1d_flush_state l1tf_vmx_mitigation;

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ static const char *l1tf_vmx_states[] = {
755755
[VMENTER_L1D_FLUSH_COND] = "conditional cache flushes",
756756
[VMENTER_L1D_FLUSH_ALWAYS] = "cache flushes",
757757
[VMENTER_L1D_FLUSH_EPT_DISABLED] = "EPT disabled",
758+
[VMENTER_L1D_FLUSH_NOT_REQUIRED] = "flush not necessary"
758759
};
759760

760761
static ssize_t l1tf_show_state(char *buf)

arch/x86/kvm/vmx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ static int vmx_setup_l1d_flush(enum vmx_l1d_flush_state l1tf)
218218
return 0;
219219
}
220220

221+
if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES)) {
222+
u64 msr;
223+
224+
rdmsrl(MSR_IA32_ARCH_CAPABILITIES, msr);
225+
if (msr & ARCH_CAP_SKIP_VMENTRY_L1DFLUSH) {
226+
l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_NOT_REQUIRED;
227+
return 0;
228+
}
229+
}
230+
221231
/* If set to auto use the default l1tf mitigation method */
222232
if (l1tf == VMENTER_L1D_FLUSH_AUTO) {
223233
switch (l1tf_mitigation) {

0 commit comments

Comments
 (0)