[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86: drop/replace MEMORY_GUARD


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 14 Dec 2021 16:13:06 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LFhltr32nVeBPERlqPOzT0ScrNpALWIB781vsRvEsbk=; b=LxbY3faQh/etsREWJKLycxzmL/rV0x34E6q6oFS9W4RejMoswe1dcSEigq3H5uL5eq8jBrgKy3ycZYEUDI5u3Z9OBdm+asAc66snAYmuSMU30HtJaiX3FqOS4JgflZoMqCpFWvg2PEjkCjCvh8LUswXOiAwA0q73shys/4xMdsqWq7CKTjdHPxdk/rvVT+uA6DbAnzxR+ZeKuoafdqzXWWNXn3qxXAWvc1Dfb89jLt7bzWnOXZF9oCCoHt2MVcuPeNYemjTvmHYb7bMN3rwjllEewkZxMEu0EbafstKJ4VpTJg6fuLmdD51dt+rij4yKFLLHM3x7kk9toA8wIYuIGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MIv0tdKOoo3rcjxCgyU35RiRbwWAX693dcOjrNbvjJE1xZ/ju26wHpGSgcVE/OC14T+C4XmDeVmJ7nFS9Eg46y1LSKwaoQnhUYCBb2Mgjf7YuE0e0KGkdz/HgD8QP0rxG59E/ViCc712CcCAH6iF16AUEA9enNgYaGqJ+y3YXlgFYWRllps9Niy7hV1il0WmDeU9FFPV7fZ2oQhkr9nAIvR+q0TGFRxZ/JPXA+BvWLrc5nzMepn1fFqdT3/LaGtP5ny1GSC29AfqWCc4d0Y9/9PHB2W9N3vQlCj5H5J9miK/INgqa/Xr7SjS7MrC1aDDKcIBAh6QyfO+mPJ6kZefnw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 14 Dec 2021 15:13:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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. Use CONFIG_DEBUG there instead.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -6109,36 +6109,6 @@ void free_perdomain_mappings(struct doma
     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)
 {
     /*
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -642,7 +642,7 @@ void show_stack_overflow(unsigned int cp
 {
     unsigned long esp = regs->rsp;
     unsigned long curr_stack_base = esp & ~(STACK_SIZE - 1);
-#ifdef MEMORY_GUARD
+#ifdef CONFIG_DEBUG
     unsigned long esp_top, esp_bottom;
 #endif
 
@@ -650,7 +650,7 @@ void show_stack_overflow(unsigned int cp
         printk("Current stack base %p differs from expected %p\n",
                _p(curr_stack_base), stack_base[cpu]);
 
-#ifdef MEMORY_GUARD
+#ifdef CONFIG_DEBUG
     esp_bottom = (esp | (STACK_SIZE - 1)) + 1;
     esp_top    = esp_bottom - PRIMARY_STACK_SIZE;
 
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -57,10 +57,6 @@
 
 #define NR_hypercalls 64
 
-#ifndef NDEBUG
-#define MEMORY_GUARD
-#endif
-
 #define STACK_ORDER 3
 #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
 
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -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);
 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.