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,9 @@ #include #include -FEATURE(compat_freebsd_32bit, "Compatible with 32-bit FreeBSD"); +int compat_freebsd_32bit = 1; +FEATURE_DYN(compat_freebsd_32bit, compat_freebsd_32bit, + "Compatible with 32-bit FreeBSD"); 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) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -927,6 +927,9 @@ #define FEATURE(name, desc) \ SYSCTL_INT_WITH_LABEL(_kern_features, OID_AUTO, name, \ CTLFLAG_RD | CTLFLAG_CAPRD, SYSCTL_NULL_INT_PTR, 1, desc, "feature") +#define FEATURE_DYN(name, ptr, desc) \ + SYSCTL_INT_WITH_LABEL(_kern_features, OID_AUTO, name, \ + CTLFLAG_RD | CTLFLAG_CAPRD, &ptr, 0, desc, "feature") #endif /* _KERNEL */