git: 0aa93010c571 - main - arm64: do not register elf32 brand if hardware cannot exec aarch32
Date: Thu, 16 Nov 2023 22:06:10 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0aa93010c571b88a6402405be22745fa05a5baab commit 0aa93010c571b88a6402405be22745fa05a5baab Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-11-16 19:45:52 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-11-16 22:04:40 +0000 arm64: do not register elf32 brand if hardware cannot exec aarch32 Reviewed by: imp, jrtc27 Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42639 --- sys/arm64/arm64/elf32_machdep.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c index 26aa2cddfdb2..4acb68b09108 100644 --- a/sys/arm64/arm64/elf32_machdep.c +++ b/sys/arm64/arm64/elf32_machdep.c @@ -153,8 +153,16 @@ static Elf32_Brandinfo freebsd32_brand_info = { .header_supported= elf32_arm_abi_supported, }; -SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST, - (sysinit_cfunc_t)elf32_insert_brand_entry, &freebsd32_brand_info); +static void +register_elf32_brand(void *arg) +{ + /* Check if we support AArch32 */ + if (ID_AA64PFR0_EL0_VAL(READ_SPECIALREG(id_aa64pfr0_el1)) == + ID_AA64PFR0_EL0_64_32) { + elf32_insert_brand_entry(&freebsd32_brand_info); + } +} +SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST, register_elf32_brand, NULL); static bool elf32_arm_abi_supported(struct image_params *imgp, int32_t *osrel __unused, @@ -162,11 +170,6 @@ elf32_arm_abi_supported(struct image_params *imgp, int32_t *osrel __unused, { const Elf32_Ehdr *hdr; - /* Check if we support AArch32 */ - if (ID_AA64PFR0_EL0_VAL(READ_SPECIALREG(id_aa64pfr0_el1)) != - ID_AA64PFR0_EL0_64_32) - return (false); - #define EF_ARM_EABI_FREEBSD_MIN EF_ARM_EABI_VER4 hdr = (const Elf32_Ehdr *)imgp->image_header; if (EF_ARM_EABI_VERSION(hdr->e_flags) < EF_ARM_EABI_FREEBSD_MIN) {