As elf_check_arch() is used for native userspace executables, it checks the purecap EF_AARCH64_CHERI_PURECAP ELF flag when CONFIG_CHERI_PURECAP_UABI=y. This doesn't work for kernel modules which are not purecap binaries and don't have the flag. Use the newly defined module_elf_check_arch() helper to not require the flag for modules. This enables modules to be loaded on a PCuABI kernel.
Signed-off-by: Kristina Martsenko kristina.martsenko@arm.com --- arch/arm64/include/asm/elf.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 6189c8614dd6..73b3d9ef6a32 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -95,16 +95,10 @@ * This is used to ensure we don't load something for the wrong architecture. */ #ifdef CONFIG_CHERI_PURECAP_UABI -/* - * TODO [PCuABI] - elf_check_arch() is also used by the kernel module loader to - * verify the ELF headers. However, kernel modules, just like the kernel, are - * currently hybrid binaries and therefore do not have the - * EF_AARCH64_CHERI_PURECAP flag. As a result elf_check_arch() currently fails - * for kernel modules. This could be solved by introducing a new macro to check - * kernel modules. - */ #define elf_check_arch(x) ((x)->e_machine == EM_AARCH64 && \ (x)->e_flags & EF_AARCH64_CHERI_PURECAP) +#define module_elf_check_arch(x) ((x)->e_machine == EM_AARCH64 && \ + !((x)->e_flags & EF_AARCH64_CHERI_PURECAP)) #else #define elf_check_arch(x) ((x)->e_machine == EM_AARCH64) #endif