|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v7 38/50] x86/spec-ctrl: add the vmap-strict sub-option of asi=
map_domain_pages() falls back to vmap() where the loaded page tables
have no slots for a multipage mapping: before the first page-table
switch in boot, or with the idle vCPU's page tables loaded. Currently
no calls are made during boot, and the only known way to reach
map_domain_pages() with the idle page tables loaded is on an error path
that will already ultimately crash the host. The fallback briefly
exposes the pages to every context, and requires a system-wide TLB
shootdown on unmap, but allows execution to continue.
For those who want stricter isolation guarantees, at the risk that
more situations might come up in the future, a new sub-option,
asi=vmap-strict, off by default, makes the fallback a BUG() instead.
The boot log reports its setting.
Assisted-by: Claude Code:claude-fable-5, Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v7:
- Split out of "x86/domain_page: introduce map_domain_pages()", which
now comes before the asi= option.
---
docs/misc/xen-command-line.pandoc | 10 +++++++++-
xen/arch/x86/domain_page.c | 2 ++
xen/arch/x86/include/asm/spec_ctrl.h | 1 +
xen/arch/x86/spec_ctrl.c | 7 +++++++
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/docs/misc/xen-command-line.pandoc
b/docs/misc/xen-command-line.pandoc
index 092c858f34..52e10eb393 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -203,7 +203,7 @@ to appropriate auditing by Xen. Argo is disabled by
default.
buggy or malicious other domain spamming the ring.
### asi (x86)
-> `= List of [ <bool>, {pv,hvm,dom0}=<bool>, directmap=<bool>,
+> `= List of [ <bool>, {pv,hvm,dom0}=<bool>, {directmap,vmap-strict}=<bool>,
> vcpu-pt=<bool> | vcpu-pt=hvm=<bool> ]`
> Default: `false`
@@ -245,6 +245,14 @@ are meant to be used for debugging purposes only.**
and `dom0=`) set this too, on builds that support it; on other builds they
leave it off.
+* `vmap-strict` crashes the host when a multipage transient mapping
+ (`map_domain_pages()`) is requested where the loaded page-tables
+ have no slots for one: in early boot, or on the idle vCPU's
+ page-tables. By default such a mapping falls back to `vmap()`,
+ which maps the pages in every context. The first such mapping is
+ logged. The option is for hosts where a crash is preferable to such
+ a mapping; none is known to be made in normal operation.
+
### asid (x86)
> `= <boolean>`
diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
index 5fcce759dd..df1b78ccc5 100644
--- a/xen/arch/x86/domain_page.c
+++ b/xen/arch/x86/domain_page.c
@@ -18,6 +18,7 @@
#include <asm/flushtlb.h>
#include <asm/hardirq.h>
#include <asm/setup.h>
+#include <asm/spec_ctrl.h>
/* Whether the vCPU supports mapcache usage, might not be in use. */
static bool has_mapcache(const struct vcpu *v)
@@ -417,6 +418,7 @@ void *map_domain_pages(const mfn_t *mfn, unsigned int nr)
v = pgtable_current_vcpu();
if ( !v || is_idle_vcpu(v) )
{
+ BUG_ON(opt_vmap_strict);
printk_once(XENLOG_WARNING
"%pS: map_domain_pages() falling back to vmap()\n",
__builtin_return_address(0));
diff --git a/xen/arch/x86/include/asm/spec_ctrl.h
b/xen/arch/x86/include/asm/spec_ctrl.h
index b62229ab5d..d9ad94ddb0 100644
--- a/xen/arch/x86/include/asm/spec_ctrl.h
+++ b/xen/arch/x86/include/asm/spec_ctrl.h
@@ -88,6 +88,7 @@ extern uint8_t default_scf;
extern int8_t opt_xpti_hwdom, opt_xpti_domu;
extern bool opt_vcpu_pt_hwdom, opt_vcpu_pt_hvm;
+extern bool opt_vmap_strict;
extern bool cpu_has_bug_l1tf;
extern int8_t opt_pv_l1tf_hwdom, opt_pv_l1tf_domu;
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 5ed81b950c..3a1755aba4 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -86,6 +86,9 @@ bool __ro_after_init opt_bp_spec_reduce = true;
static bool __initdata opt_ibpb_alt;
+/* BUG() where map_domain_pages() would fall back to vmap() (vmap-strict). */
+bool __ro_after_init opt_vmap_strict;
+
/* Give each vCPU of an HVM domain its own per-domain area (vCPU-PT). */
bool __ro_after_init opt_vcpu_pt_hvm;
bool __ro_after_init opt_vcpu_pt_hwdom;
@@ -591,6 +594,8 @@ static int __init cf_check parse_asi(const char *s)
rc = -EINVAL;
}
}
+ else if ( (val = parse_boolean("vmap-strict", s, ss)) >= 0 )
+ opt_vmap_strict = val;
else if ( (val = parse_boolean("vcpu-pt", s, ss)) != -1 )
{
switch ( val )
@@ -841,6 +846,8 @@ static void __init print_details(enum ind_thunk thunk)
printk(" ASI features for PV VMs:%s\n",
sparse_dmap_pv() && !opt_xpti_domu
? " sparse-directmap" : " None");
+ printk(" ASI vmap-strict: %s\n",
+ opt_vmap_strict ? "enabled" : "disabled");
}
}
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |