On 07.03.24 18:01, Jason Andryuk wrote:
On 2024-03-07 04:30, Roger Pau Monné wrote:On Wed, Mar 06, 2024 at 01:50:32PM -0500, Jason Andryuk wrote:Xen tries to load a PVH dom0 kernel at the fixed guest physical address from the elf headers. For Linux, this defaults to 0x1000000 (16MB), but it can be configured.Unfortunately there exist firmwares that have reserved regions at this address, so Xen fails to load the dom0 kernel since it's not RAM. The PVH entry code is not relocatable - it loads from absolute addresses, which fail when the kernel is loaded at a different address. With a suitably modified kernel, a reloctable entry point is possible. Add the XENFEAT_pvh_relocatable flag to let a kernel indicate that it supports a relocatable entry path. Change the loading to check for an acceptable load address. If the kernel is relocatable, support finding an alternate load address. Linux cares about its physical alignment. This can be pulled out of the bzImage header, but not from the vmlinux ELF file. If an alignment can't be found, use 2MB.While I'm fine with having a Linux specific way, there needs to be a generic way of passing the alignment for non-bzImage kernels. ELF program headers have an align field, would that be suitable to use?Unfortunately, it doesn't seem correct. Linux has CONFIG_PHYSICAL_ALIGN, and it doesn't seem to be used in the elf headers. As a quick test, I set CONFIG_PHYSICAL_ALIGN=0x800000, but the elf align values are still 0x200000.
An excerpt from the kernel's arch/x86/Makefile: # # The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to # the linker to force 2MB page size regardless of the default page size used # by the linker. # ifdef CONFIG_X86_64 LDFLAGS_vmlinux += -z max-page-size=0x200000 endif Juergen
OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature