1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

cpu_arm: fix build on non-Linux

- Add a check for asm/hwcap.h header presence,
 - Add a check for getauxval() function that is used
   on Linux, and for elf_aux_info() which is a FreeBSD
   equivalent.

This is based on a patch submitted by Mikael Urankar in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247722.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Roman Bogorodskiy 2020-07-08 17:39:36 +04:00
parent 9d83281382
commit d38559f0b6
2 changed files with 14 additions and 1 deletions

View File

@ -345,7 +345,9 @@ AC_CHECK_SIZEOF([long])
dnl Availability of various common functions (non-fatal if missing),
dnl and various less common threadsafe functions
AC_CHECK_FUNCS_ONCE([\
elf_aux_info \
fallocate \
getauxval \
getegid \
geteuid \
getgid \
@ -374,6 +376,7 @@ AC_CHECK_FUNCS_ONCE([\
dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([\
asm/hwcap.h \
ifaddrs.h \
libtasn1.h \
util.h \

View File

@ -22,7 +22,9 @@
#include <config.h>
#if defined(__aarch64__)
# include <asm/hwcap.h>
# if defined(HAVE_ASM_HWCAP_H)
# include <asm/hwcap.h>
# endif
# include <sys/auxv.h>
#endif
@ -518,11 +520,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data)
int cpu_feature_index = 0;
size_t i;
# if defined(HAVE_GETAUXVAL)
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("CPUID registers unavailable"));
return -1;
}
# endif
/* read the cpuid data from MIDR_EL1 register */
asm("mrs %0, MIDR_EL1" : "=r" (cpuid));
@ -533,7 +537,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data)
/* parse the corresponding vendor_id bits */
data->vendor_id = (cpuid >> 24) & 0xff;
# if defined(HAVE_GETAUXVAL)
hwcaps = getauxval(AT_HWCAP);
# elif defined(HAVE_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);
features = g_new0(char *, MAX_CPU_FLAGS + 1);