Bug 256903 - arm64: ELF auxiliary vectors for armv7 processors miss VFP information
Summary: arm64: ELF auxiliary vectors for armv7 processors miss VFP information
Status: Closed DUPLICATE of bug 256897
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-30 12:19 UTC by Robert Clausecker
Modified: 2021-07-14 10:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Clausecker 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 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 ***