Message ID | 20200106155423.9508-6-andrew.cooper3@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | x86/boot: Remove mappings at 0 | expand |
On 06.01.2020 16:54, Andrew Cooper wrote: > --- a/xen/arch/x86/boot/head.S > +++ b/xen/arch/x86/boot/head.S > @@ -689,12 +689,15 @@ 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 permentant trampoline page into l{1,2}_bootmap[]. */ "permanent"? > + mov sym_esi(trampoline_phys), %edx > + mov %edx, %ecx > + or $__PAGE_HYPERVISOR_RX, %edx /* %edx = PTE to write */ > + shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */ Following the LEA model further down, how about mov sym_esi(trampoline_phys), %ecx lea __PAGE_HYPERVISOR_RX(%ecx), %edx /* %edx = PTE to write */ shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */ ? Anyway, with or without this adjustment Reviewed-by: Jan Beulich <jbeulich@suse.com> Jan
On 07/01/2020 16:35, Jan Beulich wrote: > On 06.01.2020 16:54, Andrew Cooper wrote: >> --- a/xen/arch/x86/boot/head.S >> +++ b/xen/arch/x86/boot/head.S >> @@ -689,12 +689,15 @@ 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 permentant trampoline page into l{1,2}_bootmap[]. */ > "permanent"? Fixed. > >> + mov sym_esi(trampoline_phys), %edx >> + mov %edx, %ecx >> + or $__PAGE_HYPERVISOR_RX, %edx /* %edx = PTE to write */ >> + shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */ > Following the LEA model further down, how about > > mov sym_esi(trampoline_phys), %ecx > lea __PAGE_HYPERVISOR_RX(%ecx), %edx /* %edx = PTE to write */ > shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */ > > ? LGTM > Anyway, with or without this adjustment > Reviewed-by: Jan Beulich <jbeulich@suse.com> Thanks. ~Andrew
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index f7d273ca36..b338d4ba5c 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -689,12 +689,15 @@ 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 permentant trampoline page into l{1,2}_bootmap[]. */ + mov sym_esi(trampoline_phys), %edx + mov %edx, %ecx + or $__PAGE_HYPERVISOR_RX, %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_offs(l2_bootmap)(%esi) /* 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 30c82f9d5c..e0763a90e3 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -156,6 +156,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
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> --- 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 | 15 +++++++++------ xen/arch/x86/boot/x86_64.S | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-)