Bug 256903

Summary: arm64: ELF auxiliary vectors for armv7 processors miss VFP information
Product: Base System Reporter: Robert Clausecker <fuz>
Component: armAssignee: freebsd-arm (Nobody) <freebsd-arm>
Status: Closed DUPLICATE    
Severity: Affects Only Me CC: emaste, mikael
Priority: ---    
Version: 13.0-RELEASE   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256897

Description Robert Clausecker freebsd_committer freebsd_triage 2021-06-30 12:19:48 UTC
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.
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2021-07-14 10:40:31 UTC
Bug #256897 has a DR (review D31175) fixing this issue.  Marking as duplicate.

*** This bug has been marked as a duplicate of bug 256897 ***