| * SPDX-License-Identifier: GPL-2.0-or-later |
| * Host specific cpu indentification for AArch64. |
| #include "host/cpuinfo.h" |
| static bool sysctl_for_bool(const char *name) |
| size_t len = sizeof(val); |
| if (sysctlbyname(name, &val, &len, NULL, 0) == 0) { |
| * We might in the future ask for properties not present in older kernels, |
| * but we're only asking about static properties, all of which should be |
| * 'int'. So we shouln't see ENOMEM (val too small), or any of the other |
| /* Called both as constructor and (possibly) via other constructors. */ |
| unsigned __attribute__((constructor)) cpuinfo_init(void) |
| unsigned long hwcap = qemu_getauxval(AT_HWCAP); |
| info |= (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0); |
| info |= (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0); |
| info |= (hwcap & HWCAP_AES ? CPUINFO_AES: 0); |
| info |= sysctl_for_bool("hw.optional.arm.FEAT_LSE") * CPUINFO_LSE; |
| info |= sysctl_for_bool("hw.optional.arm.FEAT_LSE2") * CPUINFO_LSE2; |
| info |= sysctl_for_bool("hw.optional.arm.FEAT_AES") * CPUINFO_AES; |