Skip to content

Commit cbbaa27

Browse files
committed
KVM: x86: fix presentation of TSX feature in ARCH_CAPABILITIES
KVM does not implement MSR_IA32_TSX_CTRL, so it must not be presented to the guests. It is also confusing to have !ARCH_CAP_TSX_CTRL_MSR && !RTM && ARCH_CAP_TAA_NO: lack of MSR_IA32_TSX_CTRL suggests TSX was not hidden (it actually was), yet the value says that TSX is not vulnerable to microarchitectural data sampling. Fix both. Cc: [email protected] Tested-by: Jim Mattson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9cb09e7 commit cbbaa27

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arch/x86/kvm/x86.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,12 +1327,18 @@ static u64 kvm_get_arch_capabilities(void)
13271327
* If TSX is disabled on the system, guests are also mitigated against
13281328
* TAA and clear CPU buffer mitigation is not required for guests.
13291329
*/
1330-
if (boot_cpu_has_bug(X86_BUG_TAA) && boot_cpu_has(X86_FEATURE_RTM) &&
1331-
(data & ARCH_CAP_TSX_CTRL_MSR))
1330+
if (!boot_cpu_has(X86_FEATURE_RTM))
1331+
data &= ~ARCH_CAP_TAA_NO;
1332+
else if (!boot_cpu_has_bug(X86_BUG_TAA))
1333+
data |= ARCH_CAP_TAA_NO;
1334+
else if (data & ARCH_CAP_TSX_CTRL_MSR)
13321335
data &= ~ARCH_CAP_MDS_NO;
13331336

1337+
/* KVM does not emulate MSR_IA32_TSX_CTRL. */
1338+
data &= ~ARCH_CAP_TSX_CTRL_MSR;
13341339
return data;
13351340
}
1341+
EXPORT_SYMBOL_GPL(kvm_get_arch_capabilities);
13361342

13371343
static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
13381344
{

0 commit comments

Comments
 (0)