ANDROID: KVM: arm64: Fix pKVM module tracing section check
Even if no events is created, the linker will add the section
.hyp.event_ids. To check for the presence of events in the EL2 code, we
need to look at the section size.
Bug: 278749606
Bug: 268495982
Change-Id: I3b764a2040b6a40bbdd5205cb00c591b828bb614
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
index 634dd07..6eb1b3b 100644
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -655,8 +655,9 @@ static int module_init_hyp(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
mod->name);
}
} else {
- WARN(find_section(hdr, sechdrs, ".hyp.event_ids"),
- "%s: Did you forget define_events.h in the EL1 code?",
+ s = find_section(hdr, sechdrs, ".hyp.event_ids");
+ WARN(s && s->sh_size,
+ "%s: Did you forget kvm_define_hypevents.h in the EL1 code?",
mod->name);
}
#endif
diff --git a/arch/arm64/kvm/hyp/nvhe/alloc.c b/arch/arm64/kvm/hyp/nvhe/alloc.c
index 5c520ae..9e0c2d2 100644
--- a/arch/arm64/kvm/hyp/nvhe/alloc.c
+++ b/arch/arm64/kvm/hyp/nvhe/alloc.c
@@ -15,6 +15,8 @@
#include <linux/kvm_host.h>
#include <linux/list.h>
+#include <asm/kvm_hypevents.h>
+
#define MIN_ALLOC 8UL
static DEFINE_PER_CPU(int, hyp_allocator_errno);
@@ -556,6 +558,8 @@ void *hyp_alloc(size_t size)
unsigned long chunk_addr;
int missing_map, ret = 0;
+ trace_hyp_printk("hyp_alloc: size=%lld", size);
+
size = ALIGN(size, MIN_ALLOC);
hyp_spin_lock(&allocator->lock);