linux-stable/arch/x86/platform/pvh
Ard Biesheuvel 5c6808d1a9 x86/pvh: Avoid absolute symbol references in .head.text
The .head.text section contains code that may execute from a different
address than it was linked at. This is fragile, given that the x86 ABI
can refer to global symbols via absolute or relative references, and the
toolchain assumes that these are interchangeable, which they are not in
this particular case.

For this reason, all absolute symbol references are being removed from
code that is emitted into .head.text. Subsequently, build time
validation may be added that ensures that no absolute ELF relocations
exist at all in that ELF section.

In the case of the PVH code, the absolute references are in 32-bit code,
which gets emitted with R_X86_64_32 relocations, and these are even more
problematic going forward, as it prevents running the linker in PIE
mode.

So update the 64-bit code to avoid _pa(), and to only rely on relative
symbol references: these are always 32-bits wide, even in 64-bit code,
and are resolved by the linker at build time.

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Tested-by: Jason Andryuk <jason.andryuk@amd.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Message-ID: <20241009160438.3884381-12-ardb+git@google.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
2024-10-29 17:23:38 +01:00
..
enlighten.c xen, pvh: fix unbootable VMs by inlining memset() in xen_prepare_pvh() 2024-09-12 08:25:12 +02:00
head.S x86/pvh: Avoid absolute symbol references in .head.text 2024-10-29 17:23:38 +01:00
Makefile xen, pvh: fix unbootable VMs (PVH + KASAN - AMD_MEM_ENCRYPT) 2024-09-12 08:25:12 +02:00