Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Dec 2023 20:31:13 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        Warner Losh <imp@bsdimp.com>, Current FreeBSD <freebsd-current@freebsd.org>, FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>
Cc:        dan@langille.org
Subject:   aarch64 and armv6 vs. armv7 support: armv6 is not supported, despite what "man arch" reports
Message-ID:  <3C33BBA5-A84D-4F46-B38E-B67F9FE0196D@yahoo.com>
References:  <3C33BBA5-A84D-4F46-B38E-B67F9FE0196D.ref@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
man arch reports:

QUOTE
     Some machines support more than one FreeBSD ABI.  Typically these =
are
     64-bit machines, where the =E2=80=9Cnative=E2=80=9D LP64 execution =
environment is
     accompanied by the =E2=80=9Clegacy=E2=80=9D 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 !=3D 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 =3D
#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=3D256132 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.ht=
ml

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

=3D=3D=3D
Mark Millard
marklmi at yahoo.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C33BBA5-A84D-4F46-B38E-B67F9FE0196D>