[Bug 256903] arm64: ELF auxiliary vectors for armv7 processors miss VFP information

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 30 Jun 2021 12:19:48 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256903

            Bug ID: 256903
           Summary: arm64: ELF auxiliary vectors for armv7 processors miss
                    VFP information
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: fuz@fuz.su

While trying to run armv7 Go programs in a native armv7 jail on arm64 FreeBSD
13.0-RELEASE, I noticed that they refuse to run:

    $ /usr/local/bin/go                                                         
    runtime: this CPU has no floating point hardware, so it cannot run
    this GOARM=7 binary. Recompile using GOARM=5.

This error message is produced by src/runtime/os_freebsd_arm.go in the Go
toolchain:

        if goarm > 5 && cpu.HWCap&_HWCAP_VFP == 0 {
                print("runtime: this CPU has no floating point hardware, so it
cannot run\n")
                print("this GOARM=", goarm, " binary. Recompile using
GOARM=5.\n")
                exit(1)
        }

and cpu.HWCap is set from the _AT_HWCAP ELF auxillary vector:

func archauxv(tag, val uintptr) {
        switch tag {
        case _AT_HWCAP:
                cpu.HWCap = uint(val)
        case _AT_HWCAP2:
                cpu.HWCap2 = uint(val)
        }
}

Checking these vectors with a simple test program shows that they are missing:

#include <sys/auxv.h>
#include <stdio.h>

int main() {
        unsigned long hwcap, hwcap2;

        if (elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap) != 0) {
                perror("elf_aux_info(AT_HWCAP)");
        }

        if (elf_aux_info(AT_HWCAP2, &hwcap2, sizeof hwcap2) != 0) {
                perror("elf_aux_info(AT_HWCAP2)");
        }

        printf("0x%08lx 0x%08lx\n", hwcap, hwcap2);
}

On an ARMv7 machine, this prints 0x001fb8d6 0x00000000 as expected.

However, in a native armv7 jail on an arm64 machine, we instead get

    elf_aux_info(AT_HWCAP): No such file or directory
    elf_aux_info(AT_HWCAP2): No such file or directory
    0x00000000 0x00000000

showing that the auxillary vectors are missing.

Please make sure these auxillary vectors are present when running armv7
binaries on arm64 FreeBSD.

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