[PATCH] x86/speculation/mds: Apply more accurate check on hypervisor platform

From: Zhenzhong Duan
Date: Wed Jul 24 2019 - 22:40:06 EST


X86_HYPER_NATIVE isn't accurate for checking if running on native
platform, e.g. CONFIG_HYPERVISOR_GUEST isn't set or "nopv" is enabled.

Checking cpu flag X86_FEATURE_HYPERVISOR to determine if it's running
on native platform is more accurate.

This still doesn't consider the old platform where even
X86_FEATURE_HYPERVISOR is unsupported, e.g. vmware.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
arch/x86/kernel/cpu/bugs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 66ca906..801ecd1 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1226,7 +1226,7 @@ static ssize_t l1tf_show_state(char *buf)

static ssize_t mds_show_state(char *buf)
{
- if (!hypervisor_is_type(X86_HYPER_NATIVE)) {
+ if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
return sprintf(buf, "%s; SMT Host state unknown\n",
mds_strings[mds_mitigation]);
}
--
1.8.3.1