]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Make gen-hyprel endianness agnostic
authorMarc Zyngier <maz@kernel.org>
Sat, 30 Jan 2021 13:07:51 +0000 (13:07 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 1 Feb 2021 12:02:49 +0000 (12:02 +0000)
commitb0c2cafe7f7466896af044dc6a62f9299af6df22
tree157d1697a246f6e28aa3d58bd9ac730d32bb61d6
parent4d11e14136a52854627bd6a325bde444330edf10
KVM: arm64: Make gen-hyprel endianness agnostic

gen-hyprel is, for better or worse, a native-endian program:
it assumes that the ELF data structures are in the host's
endianness, and even assumes that the compiled kernel is
little-endian in one particular case.

None of these assumptions hold true though: people actually build
(use?) BE arm64 kernels, and seem to avoid doing so on BE hosts.
Madness!

In order to solve this, wrap each access to the ELF data structures
with the required byte-swapping magic. This requires to obtain
the kernel data structure, and provide per-endianess wrappers.

This result in a kernel that links and even boots in a model.

Fixes: f1712f34f6d4 ("KVM: arm64: Generate hyp relocation data")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/nvhe/Makefile
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c