diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c --- a/sys/arm64/arm64/elf32_machdep.c +++ b/sys/arm64/arm64/elf32_machdep.c @@ -160,6 +160,8 @@ if (ID_AA64PFR0_EL0_VAL(READ_SPECIALREG(id_aa64pfr0_el1)) == ID_AA64PFR0_EL0_64_32) { elf32_insert_brand_entry(&freebsd32_brand_info); + } else { + compat_freebsd_32bit = 0; } } SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST, register_elf32_brand, NULL); diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -123,7 +123,30 @@ #include #include -FEATURE(compat_freebsd_32bit, "Compatible with 32-bit FreeBSD"); +int compat_freebsd_32bit = 1; + +static void +register_compat32_feature_sysctl(const char *name, const char *descr) +{ + sysctl_add_oid(NULL, SYSCTL_CHILDREN(&sysctl___kern_features), + OID_AUTO, name, + CTLFLAG_RD | CTLFLAG_CAPRD | CTLTYPE_INT | CTLFLAG_MPSAFE, + NULL, 1, sysctl_handle_int, "I", descr, "feature"); +} + +static void +register_compat32_feature(void *arg) +{ + if (!compat_freebsd_32bit) + return; + + register_compat32_feature_sysctl("compat_freebsd32", + "Compatible with 32-bit FreeBSD"); + register_compat32_feature_sysctl("compat_freebsd_32bit", + "Compatible with 32-bit FreeBSD (legacy feature name)"); +} +SYSINIT(freebsd32, SI_SUB_EXEC, SI_ORDER_ANY, register_compat32_feature, + NULL); struct ptrace_io_desc32 { int piod_op; diff --git a/sys/compat/freebsd32/freebsd32_util.h b/sys/compat/freebsd32/freebsd32_util.h --- a/sys/compat/freebsd32/freebsd32_util.h +++ b/sys/compat/freebsd32/freebsd32_util.h @@ -122,4 +122,6 @@ int freebsd32_exec_copyin_args(struct image_args *args, const char *fname, enum uio_seg segflg, uint32_t *argv, uint32_t *envv); +extern int compat_freebsd_32bit; + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */ diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -316,16 +316,25 @@ CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine_arch, "A", "System architecture"); -#ifndef MACHINE_ARCHES #ifdef COMPAT_FREEBSD32 -#define MACHINE_ARCHES MACHINE_ARCH " " MACHINE_ARCH32 -#else -#define MACHINE_ARCHES MACHINE_ARCH -#endif +#include #endif -SYSCTL_STRING(_kern, OID_AUTO, supported_archs, CTLFLAG_RD | CTLFLAG_MPSAFE, - MACHINE_ARCHES, 0, "Supported architectures for binaries"); +static int +sysctl_kern_supported_archs(SYSCTL_HANDLER_ARGS) +{ + const char *supported_archs; + + supported_archs = +#ifdef COMPAT_FREEBSD32 + compat_freebsd_32bit ? MACHINE_ARCH " " MACHINE_ARCH32 : +#endif + MACHINE_ARCH; + return (SYSCTL_OUT(req, supported_archs, strlen(supported_archs) + 1)); +} +SYSCTL_PROC(_kern, OID_AUTO, supported_archs, CTLFLAG_RD | CTLFLAG_MPSAFE | + CTLFLAG_CAPRD | CTLTYPE_STRING, NULL, 0, sysctl_kern_supported_archs, "A", + "Supported architectures for binaries"); static int sysctl_hostname(SYSCTL_HANDLER_ARGS)