From: Paul Floyd Date: Wed, 22 May 2024 05:34:34 +0000 (+0200) Subject: FreeBSD: synthesize AT_HWCAP on arm64 X-Git-Tag: VALGRIND_3_24_0~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22730282bf240afa7d1215615be9c50eedf49d5a;p=thirdparty%2Fvalgrind.git FreeBSD: synthesize AT_HWCAP on arm64 Not used on amd64. Less hardware variation? --- diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index 53dbf7961..8c2c6b0e8 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -713,12 +713,35 @@ static Addr setup_client_stack(const void* init_sp, case VKI_AT_CANARYLEN: #if (FREEBSD_VERS >= FREEBSD_11) - // FreeBSD 11+ also have HWCAP and HWCAP2 case VKI_AT_EHDRFLAGS: #endif /* All these are pointerless, so we don't need to do anything about them. */ break; +#if defined(VGP_arm64_freebsd) + // FreeBSD 11+ also have HWCAP and HWCAP2 + // but they aren't used on amd64 + case VKI_AT_HWCAP: +#define ARM64_SUPPORTED_HWCAP (VKI_HWCAP_ATOMICS \ + | VKI_HWCAP_AES \ + | VKI_HWCAP_PMULL \ + | VKI_HWCAP_SHA1 \ + | VKI_HWCAP_SHA2 \ + | VKI_HWCAP_SHA512 \ + | VKI_HWCAP_CRC32 \ + | VKI_HWCAP_ASIMDRDM \ + | VKI_HWCAP_FP \ + | VKI_HWCAP_ASIMD \ + | VKI_HWCAP_ASIMDDP) + auxv->u.a_val &= ARM64_SUPPORTED_HWCAP; + break; +#undef ARM64_SUPPORTED_HWCAP + // not yet + /* + case VKI_AT_HWCAP2: + break; + */ +#endif case VKI_AT_EXECPATH: auxv->u.a_ptr = copy_str(&strtab, resolved_name); diff --git a/include/vki/vki-arm64-freebsd.h b/include/vki/vki-arm64-freebsd.h index 32e81db1e..e535fe7fe 100644 --- a/include/vki/vki-arm64-freebsd.h +++ b/include/vki/vki-arm64-freebsd.h @@ -70,16 +70,6 @@ typedef struct { // Used by PTRACE and coredump-elf.h */ //---------------------------------------------------------------------- -/* -struct vki_reg { - vki_uint64_t x[30]; - vki_uint64_t lr; - vki_uint64_t sp; - vki_uint64_t elr; - vki_uint64_t spsr; -}; -*/ - struct vki_dbreg { vki_uint8_t db_debug_ver; vki_uint8_t db_nbkpts; @@ -177,4 +167,61 @@ struct vki_vdso_timehands { VKI_VDSO_TIMEHANDS_MD }; +//---------------------------------------------------------------------- +// machine/elf.h +//---------------------------------------------------------------------- + +#define VKI_HWCAP_FP 0x00000001 +#define VKI_HWCAP_ASIMD 0x00000002 +#define VKI_HWCAP_EVTSTRM 0x00000004 +#define VKI_HWCAP_AES 0x00000008 +#define VKI_HWCAP_PMULL 0x00000010 +#define VKI_HWCAP_SHA1 0x00000020 +#define VKI_HWCAP_SHA2 0x00000040 +#define VKI_HWCAP_CRC32 0x00000080 +#define VKI_HWCAP_ATOMICS 0x00000100 +#define VKI_HWCAP_FPHP 0x00000200 +#define VKI_HWCAP_ASIMDHP 0x00000400 +#define VKI_HWCAP_CPUID 0x00000800 +#define VKI_HWCAP_ASIMDRDM 0x00001000 +#define VKI_HWCAP_JSCVT 0x00002000 +#define VKI_HWCAP_FCMA 0x00004000 +#define VKI_HWCAP_LRCPC 0x00008000 +#define VKI_HWCAP_DCPOP 0x00010000 +#define VKI_HWCAP_SHA3 0x00020000 +#define VKI_HWCAP_SM3 0x00040000 +#define VKI_HWCAP_SM4 0x00080000 +#define VKI_HWCAP_ASIMDDP 0x00100000 +#define VKI_HWCAP_SHA512 0x00200000 +#define VKI_HWCAP_SVE 0x00400000 +#define VKI_HWCAP_ASIMDFHM 0x00800000 +#define VKI_HWCAP_DIT 0x01000000 +#define VKI_HWCAP_USCAT 0x02000000 +#define VKI_HWCAP_ILRCPC 0x04000000 +#define VKI_HWCAP_FLAGM 0x08000000 +#define VKI_HWCAP_SSBS 0x10000000 +#define VKI_HWCAP_SB 0x20000000 +#define VKI_HWCAP_PACA 0x40000000 +#define VKI_HWCAP_PACG 0x80000000 + +#define VKI_HWCAP2_DCPODP 0x00000001 +#define VKI_HWCAP2_SVE2 0x00000002 +#define VKI_HWCAP2_SVEAES 0x00000004 +#define VKI_HWCAP2_SVEPMULL 0x00000008 +#define VKI_HWCAP2_SVEBITPERM 0x00000010 +#define VKI_HWCAP2_SVESHA3 0x00000020 +#define VKI_HWCAP2_SVESM4 0x00000040 +#define VKI_HWCAP2_FLAGM2 0x00000080 +#define VKI_HWCAP2_FRINT 0x00000100 +#define VKI_HWCAP2_SVEI8MM 0x00000200 +#define VKI_HWCAP2_SVEF32MM 0x00000400 +#define VKI_HWCAP2_SVEF64MM 0x00000800 +#define VKI_HWCAP2_SVEBF16 0x00001000 +#define VKI_HWCAP2_I8MM 0x00002000 +#define VKI_HWCAP2_BF16 0x00004000 +#define VKI_HWCAP2_DGH 0x00008000 +#define VKI_HWCAP2_RNG 0x00010000 +#define VKI_HWCAP2_BTI 0x00020000 + + #endif /* VKI_ARM64_FREEBSD_H */ diff --git a/none/tests/freebsd/auxv.stderr.exp-arm64 b/none/tests/freebsd/auxv.stderr.exp-arm64 index 949e740d4..738a284dc 100644 --- a/none/tests/freebsd/auxv.stderr.exp-arm64 +++ b/none/tests/freebsd/auxv.stderr.exp-arm64 @@ -16,7 +16,7 @@ val: AT_PAGESIZES int: 20 ptr: 0x........ val: AT_PAGESIZESLEN int: 21 ptr: 0x........ val: AT_IGNORE int: 01 ptr: 0x........ val: AT_STACKPROT int: 23 ptr: 0x........ -val: AT_IGNORE int: 01 ptr: 0x........ +val: AT_HWCAP int: 25 ptr: 0x........ val: AT_IGNORE int: 01 ptr: 0x........ val: AT_IGNORE int: 01 ptr: 0x........ val: AT_ARGC int: 28 ptr: 0x........