From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from userp2130.oracle.com ([156.151.31.86]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fJVPm-0005Ne-0t for speck@linutronix.de; Fri, 18 May 2018 04:46:42 +0200 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4I2fDJU078063 for ; Fri, 18 May 2018 02:46:35 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2hx29wkm7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 May 2018 02:46:35 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4I2kYUG029977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 May 2018 02:46:34 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4I2kXI5029279 for ; Fri, 18 May 2018 02:46:33 GMT Message-Id: <20180517031815.016936086@localhost.localdomain> Date: Wed, 16 May 2018 23:18:10 -0400 From: konrad.wilk@oracle.com Subject: [MODERATED] [PATCH v17.1 2/2] [PATCH v17.1 2/2] SSB Fix #2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") added a call to get_cpu_cap() to properly set boot_cpu_has(X86_FEATURE_NX) which is needed to correctly initialize __supported_pte_mask. Doing this so early in the boot can be dangerous --- while this currently works, there is no telling what get_cpu_cap() may decide to add in the future. For example, if it decides to do a printk (which is not something impossible to imagine) a PV guest will not be able to cope with it. To avoid these problems check CPUID explicitly for NX support and open-code setting __supported_pte_mask. Signed-off-by: Boris Ostrovsky Reviewed-by: Juergen Gross Signed-off-by: Konrad Rzeszutek Wilk --- arch/x86/xen/enlighten_pv.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index c36d23aa6c35..f9f892488670 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -88,8 +88,6 @@ #include "multicalls.h" #include "pmu.h" -#include "../kernel/cpu/cpu.h" /* get_cpu_cap() */ - void *xen_initial_gdt; static int xen_cpu_up_prepare_pv(unsigned int cpu); @@ -1253,6 +1251,13 @@ asmlinkage __visible void __init xen_start_kernel(void) /* Prevent unwanted bits from being set in PTEs. */ __supported_pte_mask &= ~_PAGE_GLOBAL; + /* Work out if we support NX. */ + if ((cpuid_eax(0x80000000) >= 0x80000001) && + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) + __supported_pte_mask |= _PAGE_NX; + else + __supported_pte_mask &= ~_PAGE_NX; + /* * Prevent page tables from being allocated in highmem, even * if CONFIG_HIGHPTE is enabled. @@ -1268,10 +1273,6 @@ asmlinkage __visible void __init xen_start_kernel(void) */ xen_setup_gdt(0); - /* Work out if we support NX */ - get_cpu_cap(&boot_cpu_data); - x86_configure_nx(); - xen_init_irq_ops(); /* Let's presume PV guests always boot on vCPU with id 0. */ -- 2.14.3