[Bug 256132] arm64 kernels with aarch32 support should claim support for armv6 in addition to armv7

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 24 May 2021 19:29:45 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256132

            Bug ID: 256132
           Summary: arm64 kernels with aarch32 support should claim
                    support for armv6 in addition to armv7
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: arm64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: fuz@fuz.su

If I read the value of the sysctl kern.supported_archs on an arm64 FreeBSD
13.0-RELEASE system, I get the output

    kern.supported_archs: aarch64 armv7

However, this list is incomplete.  Clearly, the kernel is also capable of
executing armv6 binaries.  This unfortunately means that Poudriere refuses to
install an armv6 jail on the system, making it difficult for me to test armv6
ports.

It seems like this is the consequence of unfortunate programming. 
sys/kern/kern_mib.c defines the sysctl like such:

---
#ifdef COMPAT_FREEBSD32
#define MACHINE_ARCHES  MACHINE_ARCH " " MACHINE_ARCH32
#else
#define MACHINE_ARCHES  MACHINE_ARCH
#endif
#endif

SYSCTL_STRING(_kern, OID_AUTO, supported_archs, CTLFLAG_RD | CTLFLAG_MPSAFE,
    MACHINE_ARCHES, 0, "Supported architectures for binaries");
---

so if COMPAT_FREEBSD32 is enabled, the kernel claims support for exactly one
additional 32 bit architecture, which is clearly insufficient: (a) there can be
multiple supported 32 bit architectures and (b) support for 32 bit programs may
depend on processor features.  For example, on arm64 not all cores support
executing 32 bit binaries, but the way the sysctl is set up, the kernel just
wrongly claims it can, probably failing only when execution is tried (I have no
such system to test this, but e.g. the Apple M1 chip is like this).  This seems
quite unexpected.

Please fix the way kern.supported_archs is set up such that the list reflects
both armv6 and armv7 for arm64 cores and that only if the AArch32 execution
state is supported at all.

-- 
You are receiving this mail because:
You are the assignee for the bug.