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
This commit is contained in:
Konstantin Belousov 2023-11-16 21:45:52 +02:00
parent 4c6cded216
commit 0aa93010c5

View file

@ -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) {