All of lore.kernel.org
 help / color / mirror / Atom feed
From: konrad.wilk@oracle.com
To: speck@linutronix.de
Subject: [MODERATED] [PATCH v17.1 2/2] [PATCH v17.1 2/2] SSB Fix #2
Date: Wed, 16 May 2018 23:18:10 -0400	[thread overview]
Message-ID: <20180517031815.016936086@localhost.localdomain> (raw)

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

             reply	other threads:[~2018-05-18  2:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17  3:18 konrad.wilk [this message]
2018-05-18  8:20 ` [MODERATED] Re: [PATCH v17.1 2/2] [PATCH v17.1 2/2] SSB Fix #2 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180517031815.016936086@localhost.localdomain \
    --to=konrad.wilk@oracle.com \
    --cc=speck@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.