diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index 1f10cd529b48..e727c51a53eb 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -511,9 +511,13 @@ static int module_init_hyp(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, #ifdef CONFIG_KVM const Elf_Shdr *s; + /* + * If the .hyp.text is missing or empty, this is not a hypervisor + * module so ignore the rest of it. + */ s = find_section(hdr, sechdrs, ".hyp.text"); - if (!s) - return -ENOEXEC; + if (!s || !s->sh_size) + return 0; mod->arch.hyp.text = (struct pkvm_module_section) { .start = (void *)s->sh_addr,