From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v2 3/4] x86/boot: Don't map 0 during boot
Date: Thu, 9 Jan 2020 19:32:40 +0000 [thread overview]
Message-ID: <20200109193241.14542-4-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20200109193241.14542-1-andrew.cooper3@citrix.com>
In particular, it causes accidental NULL pointer dereferences to go unnoticed.
The majority of the early operation takes place either in Real mode, or
Protected Unpaged mode. The only bit which requires pagetable mappings is the
trampoline transition into Long mode and jump to the higher mappings, so there
is no need for the whole bottom 2M to be mapped.
Introduce a new l1_bootmap in .init.data, and use it instead of l1_identmap.
The EFI boot path doesn't pass through the trampoline, so doesn't need any
adjustment.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
xen/arch/x86/boot/head.S | 14 ++++++++------
xen/arch/x86/boot/x86_64.S | 4 ++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 0b75d33a25..d246e374f1 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -689,12 +689,14 @@ trampoline_setup:
sub $(L2_PAGETABLE_ENTRIES*8),%eax
loop 1b
- /*
- * During boot, hook 4kB mappings of first 2MB of memory into L2.
- * This avoids mixing cachability for the legacy VGA region.
- */
- lea __PAGE_HYPERVISOR+sym_esi(l1_identmap),%edi
- mov %edi,sym_fs(l2_bootmap)
+ /* Map the permanent trampoline page into l{1,2}_bootmap[]. */
+ mov sym_esi(trampoline_phys), %ecx
+ lea __PAGE_HYPERVISOR_RX(%ecx), %edx /* %edx = PTE to write */
+ shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */
+ mov %edx, sym_offs(l1_bootmap)(%esi, %ecx, 8)
+
+ lea __PAGE_HYPERVISOR + sym_esi(l1_bootmap), %edx
+ mov %edx, sym_esi(l2_bootmap)
/* Apply relocations to bootstrap trampoline. */
mov sym_fs(trampoline_phys),%edx
diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index de555f87f4..af62850589 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -155,6 +155,10 @@ GLOBAL(__page_tables_end)
.section .init.data, "aw", @progbits
.align PAGE_SIZE, 0
+l1_bootmap:
+ .fill L1_PAGETABLE_ENTRIES, 8, 0
+ .size l1_bootmap, . - l1_bootmap
+
GLOBAL(l2_bootmap)
.fill 4 * L2_PAGETABLE_ENTRIES, 8, 0
.size l2_bootmap, . - l2_bootmap
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-01-09 19:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-09 19:32 [Xen-devel] [PATCH v2 0/4] x86/boot: Remove mappings at 0 Andrew Cooper
2020-01-09 19:32 ` [Xen-devel] [PATCH v2 1/4] x86/boot: Remove the preconstructed low 16M superpage mappings Andrew Cooper
2020-01-10 16:43 ` Jan Beulich
2020-01-09 19:32 ` [Xen-devel] [PATCH v2 2/4] x86/boot: Clean up l?_bootmap[] construction Andrew Cooper
2020-01-10 16:47 ` Jan Beulich
2020-01-09 19:32 ` Andrew Cooper [this message]
2020-01-09 19:32 ` [Xen-devel] [PATCH v2 4/4] x86/boot: Drop INVALID_VCPU Andrew Cooper
2020-01-10 16:52 ` Jan Beulich
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=20200109193241.14542-4-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.