x86: drop MEMORY_GUARD
authorJan Beulich <jbeulich@suse.com>
Wed, 15 Dec 2021 09:23:51 +0000 (10:23 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 15 Dec 2021 09:23:51 +0000 (10:23 +0100)
The functions it guards are dead code. Worse, while intended to exist in
debug builds only, as of commit bacbf0cb7349 ("build: convert debug to
Kconfig") they also get compiled in release builds.

The remaining uses in show_stack_overflow() aren't really related to any
memory guarding anymore - with CET-SS support the stacks now get set up
the same in debug and release builds. Drop them as well; there's no harm
providing the information there in all cases.

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

index 883c2ef0df12ff09e84ec0bb46e3b5bfcd5d83b0..de206425243974a4b947a7b058c971072c230323 100644 (file)
 
 #define NR_hypercalls 64
 
-#ifndef NDEBUG
-#define MEMORY_GUARD
-#endif
-
 #define STACK_ORDER 3
 #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
 
index cb9052749963c4be1f3dccf62cd351aede08e6a7..5dbcee869624d22bc62c859d31c73cfd72b014e5 100644 (file)
@@ -530,14 +530,6 @@ extern struct rangeset *mmio_ro_ranges;
 #define compat_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
 #define compat_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
 
-#ifdef MEMORY_GUARD
-void memguard_guard_range(void *p, unsigned long l);
-void memguard_unguard_range(void *p, unsigned long l);
-#else
-#define memguard_guard_range(_p,_l)    ((void)0)
-#define memguard_unguard_range(_p,_l)  ((void)0)
-#endif
-
 void memguard_guard_stack(void *p);
 void memguard_unguard_stack(void *p);
 
index 4a9ac8d5e650ccb641358ffbba6500af94a0b0b9..1397f83e41b421c7a8252c34e7f91418f1aaf755 100644 (file)
@@ -6109,36 +6109,6 @@ void free_perdomain_mappings(struct domain *d)
     d->arch.perdomain_l3_pg = NULL;
 }
 
-#ifdef MEMORY_GUARD
-
-static void __memguard_change_range(void *p, unsigned long l, int guard)
-{
-    unsigned long _p = (unsigned long)p;
-    unsigned long _l = (unsigned long)l;
-    unsigned int flags = __PAGE_HYPERVISOR_RW | MAP_SMALL_PAGES;
-
-    /* Ensure we are dealing with a page-aligned whole number of pages. */
-    ASSERT(IS_ALIGNED(_p, PAGE_SIZE));
-    ASSERT(IS_ALIGNED(_l, PAGE_SIZE));
-
-    if ( guard )
-        flags &= ~_PAGE_PRESENT;
-
-    map_pages_to_xen(_p, virt_to_mfn(p), PFN_DOWN(_l), flags);
-}
-
-void memguard_guard_range(void *p, unsigned long l)
-{
-    __memguard_change_range(p, l, 1);
-}
-
-void memguard_unguard_range(void *p, unsigned long l)
-{
-    __memguard_change_range(p, l, 0);
-}
-
-#endif
-
 static void write_sss_token(unsigned long *ptr)
 {
     /*
index 2ddcd95dced9d7d8b93bb3aa5e1dbce82a7c7e33..df7ffc448b9d2ead065f541f4dac42c9949f17fc 100644 (file)
@@ -642,15 +642,12 @@ void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs)
 {
     unsigned long esp = regs->rsp;
     unsigned long curr_stack_base = esp & ~(STACK_SIZE - 1);
-#ifdef MEMORY_GUARD
     unsigned long esp_top, esp_bottom;
-#endif
 
     if ( _p(curr_stack_base) != stack_base[cpu] )
         printk("Current stack base %p differs from expected %p\n",
                _p(curr_stack_base), stack_base[cpu]);
 
-#ifdef MEMORY_GUARD
     esp_bottom = (esp | (STACK_SIZE - 1)) + 1;
     esp_top    = esp_bottom - PRIMARY_STACK_SIZE;
 
@@ -678,7 +675,6 @@ void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs)
     _show_trace(esp, regs->rbp);
 
     printk("\n");
-#endif
 }
 
 void show_execution_state(const struct cpu_user_regs *regs)