Skip to content

Commit 81ac7e5

Browse files
Daniel Sneddonhansendc
authored andcommitted
KVM: Add GDS_NO support to KVM
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]>
1 parent 53cf579 commit 81ac7e5

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
@@ -674,6 +674,13 @@ static const char * const gds_strings[] = {
674674
[GDS_MITIGATION_HYPERVISOR] = "Unknown: Dependent on hypervisor status",
675675
};
676676

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

arch/x86/kvm/x86.c

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

315315
static struct kmem_cache *x86_emulator_cache;
316316

317+
extern bool gds_ucode_mitigated(void);
318+
317319
/*
318320
* When called, it means the previous get/set msr reached an invalid msr.
319321
* Return true if we want to ignore/silent this failed msr access.
@@ -1607,7 +1609,7 @@ static bool kvm_is_immutable_feature_msr(u32 msr)
16071609
ARCH_CAP_SKIP_VMENTRY_L1DFLUSH | ARCH_CAP_SSB_NO | ARCH_CAP_MDS_NO | \
16081610
ARCH_CAP_PSCHANGE_MC_NO | ARCH_CAP_TSX_CTRL_MSR | ARCH_CAP_TAA_NO | \
16091611
ARCH_CAP_SBDR_SSDP_NO | ARCH_CAP_FBSDP_NO | ARCH_CAP_PSDP_NO | \
1610-
ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO)
1612+
ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO | ARCH_CAP_GDS_NO)
16111613

16121614
static u64 kvm_get_arch_capabilities(void)
16131615
{
@@ -1664,6 +1666,9 @@ static u64 kvm_get_arch_capabilities(void)
16641666
*/
16651667
}
16661668

1669+
if (!boot_cpu_has_bug(X86_BUG_GDS) || gds_ucode_mitigated())
1670+
data |= ARCH_CAP_GDS_NO;
1671+
16671672
return data;
16681673
}
16691674

0 commit comments

Comments
 (0)