Skip to content

Commit b6fd07c

Browse files
Daniel Sneddongregkh
authored andcommitted
KVM: Add GDS_NO support to KVM
commit 81ac7e5 upstream Gather Data Sampling (GDS) is a transient execution attack using gather instructions from the AVX2 and AVX512 extensions. This attack allows malicious code to infer data that was previously stored in vector registers. Systems that are not vulnerable to GDS will set the GDS_NO bit of the IA32_ARCH_CAPABILITIES MSR. This is useful for VM guests that may think they are on vulnerable systems that are, in fact, not affected. Guests that are running on affected hosts where the mitigation is enabled are protected as if they were running on an unaffected system. On all hosts that are not affected or that are mitigated, set the GDS_NO bit. Signed-off-by: Daniel Sneddon <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Signed-off-by: Daniel Sneddon <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c04579e commit b6fd07c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,13 @@ static const char * const gds_strings[] = {
673673
[GDS_MITIGATION_HYPERVISOR] = "Unknown: Dependent on hypervisor status",
674674
};
675675

676+
bool gds_ucode_mitigated(void)
677+
{
678+
return (gds_mitigation == GDS_MITIGATION_FULL ||
679+
gds_mitigation == GDS_MITIGATION_FULL_LOCKED);
680+
}
681+
EXPORT_SYMBOL_GPL(gds_ucode_mitigated);
682+
676683
void update_gds_msr(void)
677684
{
678685
u64 mcu_ctrl_after;

arch/x86/kvm/x86.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ u64 __read_mostly host_xcr0;
311311

312312
static struct kmem_cache *x86_emulator_cache;
313313

314+
extern bool gds_ucode_mitigated(void);
315+
314316
/*
315317
* When called, it means the previous get/set msr reached an invalid msr.
316318
* Return true if we want to ignore/silent this failed msr access.
@@ -1613,7 +1615,7 @@ static unsigned int num_msr_based_features;
16131615
ARCH_CAP_SKIP_VMENTRY_L1DFLUSH | ARCH_CAP_SSB_NO | ARCH_CAP_MDS_NO | \
16141616
ARCH_CAP_PSCHANGE_MC_NO | ARCH_CAP_TSX_CTRL_MSR | ARCH_CAP_TAA_NO | \
16151617
ARCH_CAP_SBDR_SSDP_NO | ARCH_CAP_FBSDP_NO | ARCH_CAP_PSDP_NO | \
1616-
ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO)
1618+
ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO | ARCH_CAP_GDS_NO)
16171619

16181620
static u64 kvm_get_arch_capabilities(void)
16191621
{
@@ -1670,6 +1672,9 @@ static u64 kvm_get_arch_capabilities(void)
16701672
*/
16711673
}
16721674

1675+
if (!boot_cpu_has_bug(X86_BUG_GDS) || gds_ucode_mitigated())
1676+
data |= ARCH_CAP_GDS_NO;
1677+
16731678
return data;
16741679
}
16751680

0 commit comments

Comments
 (0)