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

This Linux kernel change "x86/speculation/mds: Apply more accurate check on hypervisor platform" is included in the Linux 4.4.187 release. This change is authored by Zhenzhong Duan <zhenzhong.duan [at] oracle.com> on Thu Jul 25 10:39:09 2019 +0800. The commit for this change in Linux stable tree is cef8887 (patch) which is from upstream commit 517c3ba. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 517c3ba.

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

commit 517c3ba00916383af6411aec99442c307c23f684 upstream.

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 the CPU feature bit X86_FEATURE_HYPERVISOR to determine if it's
running on native platform is more accurate.

This still doesn't cover the platforms on which X86_FEATURE_HYPERVISOR is
unsupported, e.g. VMware, but there is nothing which can be done about this
scenario.

Fixes: 8a4b06d391b0 ("x86/speculation/mds: Add sysfs reporting for MDS")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/1564022349-17338-1-git-send-email-zhenzhong.duan@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 310e279..ab2df0f 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1094,7 +1094,7 @@ static void __init l1tf_select_mitigation(void)
 static ssize_t mds_show_state(char *buf)
 {
 #ifdef CONFIG_HYPERVISOR_GUEST
-   if (x86_hyper) {
+   if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) {
        return sprintf(buf, "%s; SMT Host state unknown\n",
                   mds_strings[mds_mitigation]);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *