ANDROID: KVM: arm64: Fix hyp events ELF section order

It is not possible to assume the compiler will order events in the
sections _hyp_events and .hyp.event_ids the same way. So force that
order using the linker script SORT.

Somehow this worked on previous Android version until ftrace shuffled
things out.

Bug: 357781595
Bug: 268495982
Bug: 273748186
Change-Id: I21ca85b7aa321367f0c126bf6b74d56db87eb19d
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort
2024-10-01 10:24:59 +01:00
parent 4821a718ef
commit b556e0c960
6 changed files with 14 additions and 5 deletions
@@ -50,7 +50,7 @@
#define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \
static char hyp_event_print_fmt_##__name[] = __printk; \
static bool hyp_event_enabled_##__name; \
struct hyp_event __section("_hyp_events") hyp_event_##__name = {\
struct hyp_event __section("_hyp_events."#__name) hyp_event_##__name = {\
.name = #__name, \
.enabled = &hyp_event_enabled_##__name, \
.fields = hyp_event_fields_##__name, \
+7
View File
@@ -41,7 +41,13 @@ SECTIONS {
. = ALIGN(PAGE_SIZE);
}
.hyp.event_ids : ALIGN(PAGE_SIZE) {
/*
* Yet empty, without that *(.hyp.event_ids) input section
* (named after the output section), the location counter
* page-alignment below is ignored.
*/
*(.hyp.event_ids)
*(SORT(.hyp.event_ids.*))
*(.hyp.printk_fmt_offset)
. = ALIGN(PAGE_SIZE);
}
@@ -50,5 +56,6 @@ SECTIONS {
. = ALIGN(PAGE_SIZE);
}
.hyp.reloc : ALIGN(4) { *(.hyp.reloc) }
_hyp_events : { *(SORT(_hyp_events.*)) }
#endif
}
+1 -1
View File
@@ -224,7 +224,7 @@ SECTIONS
#ifdef CONFIG_TRACING
.rodata.hyp_events : {
__hyp_events_start = .;
*(_hyp_events)
*(SORT(_hyp_events.*))
__hyp_events_end = .;
}
.rodata.hyp_printk_fmts : {
@@ -10,7 +10,7 @@
#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") = { \
__section(".hyp.event_ids." # __name) = { \
.data = (void *)&__name##_enabled, \
}
+3 -1
View File
@@ -18,7 +18,9 @@ SECTIONS {
HYP_SECTION(.rodata)
#ifdef CONFIG_TRACING
. = ALIGN(PAGE_SIZE);
HYP_SECTION(.event_ids)
BEGIN_HYP_SECTION(.event_ids)
*(SORT(.hyp.event_ids.*))
END_HYP_SECTION
#endif
/*
+1 -1
View File
@@ -21,7 +21,7 @@ SECTIONS {
.hyp.event_ids : {
HYP_SECTION_SYMBOL_NAME(.event_ids) = .;
*(HYP_SECTION_NAME(.event_ids))
*(SORT(HYP_SECTION_NAME(.event_ids.*)))
*(HYP_SECTION_NAME(.printk_fmt_offset))
}