aarch64 and armv6 vs. armv7 support: armv6 is not supported, despite what "man arch" reports

From: Mark Millard <marklmi_at_yahoo.com>
Date: Thu, 07 Dec 2023 04:31:13 UTC
man arch reports:

QUOTE
     Some machines support more than one FreeBSD ABI.  Typically these are
     64-bit machines, where the “native” LP64 execution environment is
     accompanied by the “legacy” ILP32 environment, which was the historical
     32-bit predecessor for 64-bit evolution.  Examples are:

           LP64         ILP32 counterpart
           amd64        i386
           powerpc64    powerpc
           aarch64      armv6/armv7

     aarch64 will support execution of armv6 or armv7 binaries if the CPU
     implements AArch32 execution state, however older armv4 and armv5
     binaries aren't supported.
END QUOTE

(I take "armv6 or armv7 binaries" as what was built targeting a FreeBSD
architecture triple for one of those. FreeBSD keeps them distinct.)

However, the armv6 part of that is wrong: The infrastructure supports
only one 32-bit alternative for a given kernel, not a family of them at
once . . .

sys/kern/kern_mib.c :

static const char *
proc_machine_arch(struct proc *p)
{
          if (p->p_sysent->sv_machine_arch != NULL)
                return (p->p_sysent->sv_machine_arch(p));
#ifdef COMPAT_FREEBSD32
        if (SV_PROC_FLAG(p, SV_ILP32))
                return (MACHINE_ARCH32);
#endif
        return (MACHINE_ARCH);
}
. . .
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));
}


sys/arm64/include/param.h :

#define MACHINE_ARCHES MACHINE_ARCH " " MACHINE_ARCH32
. . .
#define MACHINE_ARCH32 "armv7"

(There is no "armv6" alternative present.)

But with something like:

#define MACHINE_ARCH32 "armv7 armv6"

MACHINE_ARCH32 is not interpreted as a list of alternatives, each
supported. There is code that would have to be reworked to allow
a list of alternatives to work.

One can build a custom kernel with:

#define MACHINE_ARCH32 "armv6"

and then, having booted that kernel, then run armv6 on aarch64
--but, then, not armv7.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256132 is
about this and has my messy notes as I explored and discovered
that multiple 32-bit alternatives did not work. I see that I
forgot various quote (") symbols.


This note was prompted by:

https://lists.freebsd.org/archives/freebsd-hackers/2023-December/002728.html

that mentions "the list of valid MACHINE_ARCH" that reminded me
of this old issue.

===
Mark Millard
marklmi at yahoo.com