]> xenbits.xensource.com Git - xen.git/commit
x86/head: check base address alignment
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 3 May 2023 11:36:25 +0000 (13:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 3 May 2023 11:36:25 +0000 (13:36 +0200)
commit0946068e7faea22868c577d7afa54ba4970ff520
tree1b8d9623415c5cd624817f68e21d14e06c464fb0
parent19c6cbd90965b1440bd551069373d6fa3f2f365d
x86/head: check base address alignment

Ensure that the base address is 2M aligned, or else the page table
entries created would be corrupt as reserved bits on the PDE end up
set.

We have encountered a broken firmware where grub2 would end up loading
Xen at a non 2M aligned region when using the multiboot2 protocol, and
that caused a very difficult to debug triple fault.

If the alignment is not as required by the page tables print an error
message and stop the boot.  Also add a build time check that the
calculation of symbol offsets don't break alignment of passed
addresses.

The check could be performed earlier, but so far the alignment is
required by the page tables, and hence feels more natural that the
check lives near to the piece of code that requires it.

Note that when booted as an EFI application from the PE entry point
the alignment check is already performed by
efi_arch_load_addr_check(), and hence there's no need to add another
check at the point where page tables get built in
efi_arch_memory_setup().

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/boot/head.S