x86/pvh: Make PVH entrypoint PIC for x86-64
authorJason Andryuk <jason.andryuk@amd.com>
Fri, 23 Aug 2024 19:36:27 +0000 (15:36 -0400)
committerJuergen Gross <jgross@suse.com>
Wed, 25 Sep 2024 12:15:08 +0000 (14:15 +0200)
commit1db29f99edb056d8445876292f53a63459142309
treedd0cf65846c6e09df7587b349186785cfed6950d
parent08377ed24feef66866d0c6aabcae0aec515cf2ca
x86/pvh: Make PVH entrypoint PIC for x86-64

The PVH entrypoint is 32bit non-PIC code running the uncompressed
vmlinux at its load address CONFIG_PHYSICAL_START - default 0x1000000
(16MB).  The kernel is loaded at that physical address inside the VM by
the VMM software (Xen/QEMU).

When running a Xen PVH Dom0, the host reserved addresses are mapped 1-1
into the PVH container.  There exist system firmwares (Coreboot/EDK2)
with reserved memory at 16MB.  This creates a conflict where the PVH
kernel cannot be loaded at that address.

Modify the PVH entrypoint to be position-indepedent to allow flexibility
in load address.  Only the 64bit entry path is converted.  A 32bit
kernel is not PIC, so calling into other parts of the kernel, like
xen_prepare_pvh() and mk_pgtable_32(), don't work properly when
relocated.

This makes the code PIC, but the page tables need to be updated as well
to handle running from the kernel high map.

The UNWIND_HINT_END_OF_STACK is to silence:
vmlinux.o: warning: objtool: pvh_start_xen+0x7f: unreachable instruction
after the lret into 64bit code.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Message-ID: <20240823193630.2583107-3-jason.andryuk@amd.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
arch/x86/platform/pvh/head.S