From 16d9a0f908b08f78d0b34bc58572e90e24637608 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Fri, 17 Feb 2023 15:19:56 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Rename nVHE hyp event ELF sections The ELF sections and delimiters used by the hyp events were not following the convention used by other hyp sections. Align them all. Bug: 249050813 Change-Id: I7b3ee4915c8904cd531911df59c1fd1853bbbe9f Signed-off-by: Will Deacon Signed-off-by: Vincent Donnefort --- arch/arm64/kernel/vmlinux.lds.S | 29 ++++++++++++----------------- arch/arm64/kvm/hyp/nvhe/events.c | 2 +- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 2 +- arch/arm64/kvm/hyp_events.c | 17 ++++++++--------- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 271ec8f29f17..c6772b86ba65 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -15,10 +15,10 @@ #ifdef CONFIG_TRACING #define HYPERVISOR_EVENT_IDS \ - . = ALIGN(PAGE_SIZE); \ - __hyp_event_ids_start = .; \ - *(HYP_SECTION_NAME(_hyp_event_ids)) \ - __hyp_event_ids_end = .; + . = ALIGN(PAGE_SIZE); \ + __hyp_event_ids_start = .; \ + *(HYP_SECTION_NAME(.event_ids)) \ + __hyp_event_ids_end = .; #else #define HYPERVISOR_EVENT_IDS #endif @@ -62,17 +62,6 @@ . = ALIGN(PAGE_SIZE); \ __hyp_bss_end = .; -#ifdef CONFIG_TRACING -#define HYPERVISOR_EVENTS \ - .hyp.events : { \ - __start_hyp_events = .; \ - *(_hyp_events) \ - __stop_hyp_events = .; \ - } -#else -#define HYPERVISOR_EVENTS -#endif - /* * We require that __hyp_bss_start and __bss_start are aligned, and enforce it * with an assertion. But the BSS_SECTION macro places an empty .sbss section @@ -214,10 +203,16 @@ SECTIONS /* everything from this point to __init_begin will be marked RO NX */ RO_DATA(PAGE_SIZE) - HYPERVISOR_EVENTS - HYPERVISOR_RODATA_SECTIONS +#ifdef CONFIG_TRACING + .rodata.hyp_events : { + __hyp_events_start = .; + *(_hyp_events) + __hyp_events_end = .; + } +#endif + idmap_pg_dir = .; . += IDMAP_DIR_SIZE; idmap_pg_end = .; diff --git a/arch/arm64/kvm/hyp/nvhe/events.c b/arch/arm64/kvm/hyp/nvhe/events.c index 9deb2c31db5e..69b300ab1bcc 100644 --- a/arch/arm64/kvm/hyp/nvhe/events.c +++ b/arch/arm64/kvm/hyp/nvhe/events.c @@ -12,7 +12,7 @@ extern struct hyp_event_id __hyp_event_ids_end[]; #undef HYP_EVENT #define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \ atomic_t __ro_after_init __name##_enabled = ATOMIC_INIT(0); \ - struct hyp_event_id hyp_event_id_##__name __section("_hyp_event_ids") = { \ + struct hyp_event_id hyp_event_id_##__name __section(".hyp.event_ids") = { \ .data = (void *)&__name##_enabled, \ } diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S index 8254ef9fc81c..b9ad9e662c32 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -18,7 +18,7 @@ SECTIONS { HYP_SECTION(.rodata) #ifdef CONFIG_TRACING . = ALIGN(PAGE_SIZE); - HYP_SECTION(_hyp_event_ids) + HYP_SECTION(.event_ids) #endif /* diff --git a/arch/arm64/kvm/hyp_events.c b/arch/arm64/kvm/hyp_events.c index 64b88dc85093..d47dafe75214 100644 --- a/arch/arm64/kvm/hyp_events.c +++ b/arch/arm64/kvm/hyp_events.c @@ -82,8 +82,8 @@ struct hyp_event { #undef __ARM64_KVM_HYPEVENTS_H_ #include -extern struct hyp_event __start_hyp_events[]; -extern struct hyp_event __stop_hyp_events[]; +extern struct hyp_event __hyp_events_start[]; +extern struct hyp_event __hyp_events_end[]; /* hyp_event section used by the hypervisor */ extern struct hyp_event_id __hyp_event_ids_start[]; @@ -91,9 +91,9 @@ extern struct hyp_event_id __hyp_event_ids_end[]; static struct hyp_event *find_hyp_event(const char *name) { - struct hyp_event *event = __start_hyp_events; + struct hyp_event *event = __hyp_events_start; - for (; (unsigned long)event < (unsigned long)__stop_hyp_events; + for (; (unsigned long)event < (unsigned long)__hyp_events_end; event++) { if (!strncmp(name, event->name, HYP_EVENT_NAME_MAX)) return event; @@ -319,7 +319,7 @@ bool kvm_hyp_events_enable_early(void) void kvm_hyp_init_events_tracefs(struct dentry *parent) { - struct hyp_event *event = __start_hyp_events; + struct hyp_event *event = __hyp_events_start; struct dentry *d, *event_dir; parent = tracefs_create_dir("events", parent); @@ -333,8 +333,7 @@ void kvm_hyp_init_events_tracefs(struct dentry *parent) if (!d) pr_err("Failed to create events/header_page\n"); - - for (; (unsigned long)event < (unsigned long)__stop_hyp_events; event++) { + for (; (unsigned long)event < (unsigned long)__hyp_events_end; event++) { event_dir = tracefs_create_dir(event->name, parent); if (!event_dir) { pr_err("Failed to create events/hyp/%s\n", event->name); @@ -364,13 +363,13 @@ void kvm_hyp_init_events_tracefs(struct dentry *parent) */ int kvm_hyp_init_events(void) { - struct hyp_event *event = __start_hyp_events; + struct hyp_event *event = __hyp_events_start; struct hyp_event_id *hyp_event_id = __hyp_event_ids_start; int ret, err = -ENODEV; /* TODO: BUILD_BUG nr events host side / hyp side */ - for (; (unsigned long)event < (unsigned long)__stop_hyp_events; + for (; (unsigned long)event < (unsigned long)__hyp_events_end; event++, hyp_event_id++) { event->call->name = event->name; ret = register_trace_event(&event->call->event);