git: 608e56cfe934 - stable/14 - FEATURE compat_freebsd_32bit: only report on arm64 when support is present

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 28 Nov 2023 11:40:47 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=608e56cfe93478ff4d6e544b99ef027b98066ae5

commit 608e56cfe93478ff4d6e544b99ef027b98066ae5
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-11-16 21:06:36 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-11-28 11:39:38 +0000

    FEATURE compat_freebsd_32bit: only report on arm64 when support is present
    
    (cherry picked from commit 5a2bbacea56f40e91c5371d5d6a210afd797fd3b)
---
 sys/arm64/arm64/elf32_machdep.c       |  2 ++
 sys/compat/freebsd32/freebsd32_misc.c | 13 ++++++++++++-
 sys/compat/freebsd32/freebsd32_util.h |  2 ++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c
index 4acb68b09108..de0ee9607ad1 100644
--- a/sys/arm64/arm64/elf32_machdep.c
+++ b/sys/arm64/arm64/elf32_machdep.c
@@ -160,6 +160,8 @@ register_elf32_brand(void *arg)
 	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
index c26e7b97e717..d9266f57ac94 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -123,7 +123,18 @@
 #include <compat/freebsd32/freebsd32_signal.h>
 #include <compat/freebsd32/freebsd32_proto.h>
 
-FEATURE(compat_freebsd_32bit, "Compatible with 32-bit FreeBSD");
+int compat_freebsd_32bit = 1;
+
+static void
+register_compat32_feature(void *arg)
+{
+	if (!compat_freebsd_32bit)
+		return;
+
+	FEATURE_ADD("compat_freebsd_32bit", "Compatible with 32-bit FreeBSD");
+}
+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
index 67f0c099792a..c32c7a2ef4c1 100644
--- a/sys/compat/freebsd32/freebsd32_util.h
+++ b/sys/compat/freebsd32/freebsd32_util.h
@@ -122,4 +122,6 @@ struct image_args;
 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_ */