]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86/xpti: don't map stack guard pages
authorJan Beulich <jbeulich@suse.com>
Tue, 6 Mar 2018 15:46:57 +0000 (16:46 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 6 Mar 2018 15:46:57 +0000 (16:46 +0100)
Other than for the main mappings, don't even do this in release builds,
as there are no huge page shattering concerns here.

Note that since we don't run on the restructed page tables while HVM
guests execute, the non-present mappings won't trigger the triple fault
issue AMD SVM is susceptible to with our current placement of STGI vs
TR loading.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm.c
xen/arch/x86/smpboot.c
xen/include/asm-x86/mm.h

index 829a26295032539bca822dd94aaa5ffa7e9388cc..8021f93a63edd70e204064f1741df7675a3b7819 100644 (file)
@@ -5576,6 +5576,14 @@ void memguard_unguard_stack(void *p)
                            STACK_SIZE - PRIMARY_STACK_SIZE - IST_MAX * PAGE_SIZE);
 }
 
+bool memguard_is_stack_guard_page(unsigned long addr)
+{
+    addr &= STACK_SIZE - 1;
+
+    return addr >= IST_MAX * PAGE_SIZE &&
+           addr < STACK_SIZE - PRIMARY_STACK_SIZE;
+}
+
 void arch_dump_shared_mem_info(void)
 {
     printk("Shared frames %u -- Saved frames %u\n",
index 06207931f39de5f0652d5385c2dea11461c99aac..d376c69c426b6480607808f6b487b4292a17661c 100644 (file)
@@ -799,7 +799,8 @@ static int setup_cpu_root_pgt(unsigned int cpu)
 
     /* Install direct map page table entries for stack, IDT, and TSS. */
     for ( off = rc = 0; !rc && off < STACK_SIZE; off += PAGE_SIZE )
-        rc = clone_mapping(__va(__pa(stack_base[cpu])) + off, rpt);
+        if ( !memguard_is_stack_guard_page(off) )
+            rc = clone_mapping(__va(__pa(stack_base[cpu])) + off, rpt);
 
     if ( !rc )
         rc = clone_mapping(idt_tables[cpu], rpt);
index 3013c266fe7f7e24c6d8d2a93eac8719923609b0..96f3a34fc3f7733a5e29ccd384b9a57d2ec643a6 100644 (file)
@@ -519,6 +519,7 @@ void memguard_unguard_range(void *p, unsigned long l);
 
 void memguard_guard_stack(void *p);
 void memguard_unguard_stack(void *p);
+bool __attribute_const__ memguard_is_stack_guard_page(unsigned long addr);
 
 struct mmio_ro_emulate_ctxt {
         unsigned long cr2;