82 lines
3.8 KiB
Diff
82 lines
3.8 KiB
Diff
From 9a4b34729f1bb92eea1e1efe52e6face9f0b17ae Mon Sep 17 00:00:00 2001
|
|
From: George Dunlap <george.dunlap@citrix.com>
|
|
Date: Fri, 22 Sep 2017 11:46:55 +0100
|
|
Subject: [PATCH 2/2] x86/mm: Disable PV linear pagetables by default
|
|
|
|
Allowing pagetables to point to other pagetables of the same level
|
|
(often called 'linear pagetables') has been included in Xen since its
|
|
inception. But it is not used by the most common PV guests (Linux,
|
|
NetBSD, minios), and has been the source of a number of subtle
|
|
reference-counting bugs.
|
|
|
|
Add a command-line option to control whether PV linear pagetables are
|
|
allowed (disabled by default).
|
|
|
|
Reported-by: Jann Horn <jannh@google.com>
|
|
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
|
|
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
|
|
---
|
|
Changes since v2:
|
|
- s/_/-/; in command-line option
|
|
- Added __read_mostly
|
|
---
|
|
docs/misc/xen-command-line.markdown | 15 +++++++++++++++
|
|
xen/arch/x86/mm.c | 9 +++++++++
|
|
2 files changed, 24 insertions(+)
|
|
|
|
diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown
|
|
index 73f5265fc6..061aff5edc 100644
|
|
--- a/docs/misc/xen-command-line.markdown
|
|
+++ b/docs/misc/xen-command-line.markdown
|
|
@@ -1280,6 +1280,21 @@ The following resources are available:
|
|
CDP, one COS will corespond two CBMs other than one with CAT, due to the
|
|
sum of CBMs is fixed, that means actual `cos_max` in use will automatically
|
|
reduce to half when CDP is enabled.
|
|
+
|
|
+### pv-linear-pt
|
|
+> `= <boolean>`
|
|
+
|
|
+> Default: `false`
|
|
+
|
|
+Allow PV guests to have pagetable entries pointing to other pagetables
|
|
+of the same level (i.e., allowing L2 PTEs to point to other L2 pages).
|
|
+This technique is often called "linear pagetables", and is sometimes
|
|
+used to allow operating systems a simple way to consistently map the
|
|
+current process's pagetables into its own virtual address space.
|
|
+
|
|
+None of the most common PV operating systems (Linux, NetBSD, MiniOS)
|
|
+use this technique, but there may be custom operating systems which
|
|
+do.
|
|
|
|
### reboot
|
|
> `= t[riple] | k[bd] | a[cpi] | p[ci] | P[ower] | e[fi] | n[o] [, [w]arm | [c]old]`
|
|
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
|
|
index e81a461b91..f748d4a221 100644
|
|
--- a/xen/arch/x86/mm.c
|
|
+++ b/xen/arch/x86/mm.c
|
|
@@ -799,6 +799,9 @@ static void dec_linear_uses(struct page_info *pg)
|
|
* frame if it is mapped by a different root table. This is sufficient and
|
|
* also necessary to allow validation of a root table mapping itself.
|
|
*/
|
|
+static bool_t __read_mostly pv_linear_pt_enable = 0;
|
|
+boolean_param("pv-linear-pt", pv_linear_pt_enable);
|
|
+
|
|
#define define_get_linear_pagetable(level) \
|
|
static int \
|
|
get_##level##_linear_pagetable( \
|
|
@@ -808,6 +811,12 @@ get_##level##_linear_pagetable( \
|
|
struct page_info *page; \
|
|
unsigned long pfn; \
|
|
\
|
|
+ if ( !pv_linear_pt_enable ) \
|
|
+ { \
|
|
+ MEM_LOG("Attempt to create linear p.t. (feature disabled)"); \
|
|
+ return 0; \
|
|
+ } \
|
|
+ \
|
|
if ( (level##e_get_flags(pde) & _PAGE_RW) ) \
|
|
{ \
|
|
MEM_LOG("Attempt to create linear p.t. with write perms"); \
|
|
--
|
|
2.14.1
|
|
|