From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] xen/x86: Unilaterally remove .init mappings
Date: Thu, 18 Feb 2016 18:03:42 +0000 [thread overview]
Message-ID: <1455818622-30625-5-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1455818622-30625-1-git-send-email-andrew.cooper3@citrix.com>
Because of the new 2M alignment of .init and .bss, the existing memory
guarding infrastructure causes a shattered 2M superpage with non-present
entries for .init, and present entries for the alignment space.
Do away with the difference in behaviour between debug and non-debug builds;
always destroy the .init mappings, and reuse the space for xenheap.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/setup.c | 24 +++++++++++-------------
xen/arch/x86/xen.lds.S | 3 +++
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index c360fbc..e6d1fe6 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -176,16 +176,6 @@ void __init discard_initial_images(void)
initial_images = NULL;
}
-static void free_xen_data(char *s, char *e)
-{
-#ifndef MEMORY_GUARD
- init_xenheap_pages(__pa(s), __pa(e));
-#endif
- memguard_guard_range(s, e-s);
- /* Also zap the mapping in the 1:1 area. */
- memguard_guard_range(__va(__pa(s)), e-s);
-}
-
extern char __init_begin[], __init_end[], __bss_start[], __bss_end[];
static void __init init_idle_domain(void)
@@ -509,13 +499,21 @@ static void __init kexec_reserve_area(struct e820map *e820)
static void noinline init_done(void)
{
+ void *va;
+
system_state = SYS_STATE_active;
domain_unpause_by_systemcontroller(hardware_domain);
- /* Free (or page-protect) the init areas. */
- memset(__init_begin, 0xcc, __init_end - __init_begin); /* int3 poison */
- free_xen_data(__init_begin, __init_end);
+ /* Zero the .init code and data. */
+ for ( va = __init_begin; va < _p(__init_end); va += PAGE_SIZE )
+ clear_page(va);
+
+ /* Destroy Xen's mappings, and reuse the pages. */
+ destroy_xen_mappings((unsigned long)&__2M_init_start,
+ (unsigned long)&__2M_init_end);
+ init_xenheap_pages(__pa(__2M_init_start), __pa(__2M_init_end));
+
printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
startup_cpu_idle_loop();
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 6c23c02..72578f0 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -263,3 +263,6 @@ ASSERT(IS_ALIGNED(__2M_bss_start, MB(2)), "__2M_bss_start misaligned")
ASSERT(IS_ALIGNED(__2M_bss_end, MB(2)), "__2M_bss_end misaligned")
ASSERT(IS_ALIGNED(cpu0_stack, STACK_SIZE), "cpu0_stack misaligned")
+
+ASSERT(IS_ALIGNED(__init_begin, PAGE_SIZE), "__init_begin misaligned")
+ASSERT(IS_ALIGNED(__init_end, PAGE_SIZE), "__init_end misaligned")
--
2.1.4
next prev parent reply other threads:[~2016-02-18 18:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 18:03 [PATCH] xen/x86: Map Xen code/data/bss with superpages Andrew Cooper
2016-02-18 18:03 ` [PATCH] xen: Introduce IS_ALIGNED() Andrew Cooper
2016-02-18 18:03 ` [PATCH] xen/memguard: Drop memguard_init() entirely Andrew Cooper
2016-02-19 14:44 ` Jan Beulich
2016-02-19 16:18 ` Andrew Cooper
2016-02-22 10:02 ` Jan Beulich
2016-02-22 10:29 ` Andrew Cooper
2016-02-22 10:41 ` Jan Beulich
2016-02-18 18:03 ` [PATCH] xen/x86: Use 2M superpages for text/data/bss mappings Andrew Cooper
2016-02-19 14:58 ` Jan Beulich
2016-02-19 15:51 ` Andrew Cooper
2016-02-22 9:55 ` Jan Beulich
2016-02-22 10:24 ` Andrew Cooper
2016-02-22 10:43 ` Jan Beulich
2016-02-18 18:03 ` Andrew Cooper [this message]
2016-02-19 15:02 ` [PATCH] xen/x86: Unilaterally remove .init mappings Jan Beulich
2016-02-18 18:20 ` [PATCH] xen/x86: Map Xen code/data/bss with superpages Andrew Cooper
-- strict thread matches above, loose matches on Subject: below --
2016-02-24 19:07 [PATCH] " Andrew Cooper
2016-02-24 19:07 ` [PATCH] xen/x86: Unilaterally remove .init mappings Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455818622-30625-5-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).