From: He Chen <he.chen@linux.intel.com>
To: Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wu Feng <feng.wu@intel.com>, Wang Yong <yong.y.wang@intel.com>,
Nakajima Jun <jun.nakajima@intel.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: [PATCH] xen: enable/disable SMAP/SMEP for Xen itself
Date: Tue, 9 Aug 2016 17:13:59 +0800 [thread overview]
Message-ID: <1470734039-15758-2-git-send-email-he.chen@linux.intel.com> (raw)
In-Reply-To: <1470734039-15758-1-git-send-email-he.chen@linux.intel.com>
SMAP/SMEP may affect the 32-bit pv guests.
Users can determine whether turn SMAP/SMEP on for Xen hyperviosr when
running 32-bit pv guests.
Signed-off-by: He Chen <he.chen@linux.intel.com>
---
docs/misc/xen-command-line.markdown | 14 ++++++++++++++
xen/arch/x86/setup.c | 12 ++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown
index 3a250cb..a48c4aa 100644
--- a/docs/misc/xen-command-line.markdown
+++ b/docs/misc/xen-command-line.markdown
@@ -1434,6 +1434,13 @@ Set the serial transmit buffer size.
Flag to enable Supervisor Mode Execution Protection
+### xen_smep
+> `= <boolean>`
+
+> Default: `true`
+
+Flag to enable SMEP for Xen itself
+
### smap
> `= <boolean>`
@@ -1441,6 +1448,13 @@ Flag to enable Supervisor Mode Execution Protection
Flag to enable Supervisor Mode Access Prevention
+### xen_smap
+> `= <boolean>`
+
+> Default: `true`
+
+Flag to enable SMAP for Xen itself
+
### snb\_igd\_quirk
> `= <boolean> | cap | <integer>`
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 217c775..84debc3 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -65,10 +65,18 @@ integer_param("maxcpus", max_cpus);
static bool_t __initdata opt_smep = 1;
boolean_param("smep", opt_smep);
+/* xen_smep: Enable/disable SMEP for Xen itself (default on). */
+static bool_t __initdata opt_xen_smep = 1;
+boolean_param("xen_smep", opt_xen_smep);
+
/* smap: Enable/disable Supervisor Mode Access Prevention (default on). */
static bool_t __initdata opt_smap = 1;
boolean_param("smap", opt_smap);
+/* xen_smap: Enable/disable SMAP for Xen itself (default on). */
+static bool_t __initdata opt_xen_smap = 1;
+boolean_param("xen_smap", opt_xen_smap);
+
unsigned long __read_mostly cr4_pv32_mask;
/* Boot dom0 in pvh mode */
@@ -1403,12 +1411,12 @@ void __init noreturn __start_xen(unsigned long mbi_p)
if ( !opt_smep )
setup_clear_cpu_cap(X86_FEATURE_SMEP);
- if ( cpu_has_smep )
+ if ( cpu_has_smep && opt_xen_smep )
set_in_cr4(X86_CR4_SMEP);
if ( !opt_smap )
setup_clear_cpu_cap(X86_FEATURE_SMAP);
- if ( cpu_has_smap )
+ if ( cpu_has_smap && opt_xen_smap )
set_in_cr4(X86_CR4_SMAP);
cr4_pv32_mask = mmu_cr4_features & XEN_CR4_PV32_BITS;
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-09 9:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-09 9:13 [PATCH] solve SMAP/SMEP issues with 32-bit pv guests He Chen
2016-08-09 9:13 ` He Chen [this message]
2016-08-09 12:19 ` [PATCH] xen: enable/disable SMAP/SMEP for Xen itself Jan Beulich
2016-08-10 10:23 ` [PATCH] solve SMAP/SMEP issues with 32-bit pv guests George Dunlap
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=1470734039-15758-2-git-send-email-he.chen@linux.intel.com \
--to=he.chen@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=feng.wu@intel.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=xen-devel@lists.xen.org \
--cc=yong.y.wang@intel.com \
/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.