All of lore.kernel.org
 help / color / mirror / Atom feed
* [MODERATED] [PATCH v17.1 2/2] [PATCH v17.1 2/2] SSB Fix #2
@ 2018-05-17  3:18 konrad.wilk
  2018-05-18  8:20 ` [MODERATED] " Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: konrad.wilk @ 2018-05-17  3:18 UTC (permalink / raw)
  To: speck

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 <boris.ostrovsky@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-05-19  8:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-17  3:18 [MODERATED] [PATCH v17.1 2/2] [PATCH v17.1 2/2] SSB Fix #2 konrad.wilk
2018-05-18  8:20 ` [MODERATED] " Greg KH
2018-05-18  9:02   ` Thomas Gleixner
2018-05-18 11:46   ` [MODERATED] " Konrad Rzeszutek Wilk
2018-05-18  9:14 ` Thomas Gleixner
2018-05-18 11:43   ` [MODERATED] " Konrad Rzeszutek Wilk
2018-05-18 12:03     ` Greg KH
2018-05-18 13:21 ` Greg KH
2018-05-18 18:22   ` Konrad Rzeszutek Wilk
2018-05-18 19:57     ` Thomas Gleixner
2018-05-18 20:34       ` [MODERATED] " Konrad Rzeszutek Wilk
2018-05-18 20:40         ` Linus Torvalds
2018-05-18 21:05           ` Konrad Rzeszutek Wilk
2018-05-18 21:10             ` Linus Torvalds
2018-05-19  8:33         ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.