cpu: Fix build on some aarch64 platforms

On platforms that lack both getauxval() and elf_aux_info(),
such as OpenBSD and macOS, host CPU detection can't work.

https://gitlab.com/libvirt/libvirt/-/issues/121

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Andrea Bolognani 2021-02-05 14:07:27 +01:00
parent 03af15c024
commit f834c341fb

View File

@ -529,7 +529,7 @@ virCPUarmValidateFeatures(virCPUDefPtr cpu)
return 0;
}
#if defined(__aarch64__)
#if defined(__aarch64__) && (defined(WITH_GETAUXVAL) || defined(WITH_ELF_AUX_INFO))
/* Generate human readable flag list according to the order of */
/* AT_HWCAP bit map */
const char *aarch64_cpu_flags[MAX_CPU_FLAGS] = {
@ -560,8 +560,6 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data)
hwcaps = getauxval(AT_HWCAP);
# elif defined(WITH_ELF_AUX_INFO)
elf_aux_info(AT_HWCAP, &hwcaps, sizeof(u_long));
# else
# error No routines to retrieve a value from the auxiliary vector
# endif
VIR_DEBUG("CPU flags read from register: 0x%016lx", hwcaps);
@ -674,7 +672,7 @@ struct cpuArchDriver cpuDriverArm = {
.arch = archs,
.narch = G_N_ELEMENTS(archs),
.compare = virCPUarmCompare,
#if defined(__aarch64__)
#if defined(__aarch64__) && (defined(WITH_GETAUXVAL) || defined(WITH_ELF_AUX_INFO))
.getHost = virCPUarmGetHost,
#endif
.decode = NULL,