mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
parent
9d83281382
commit
d38559f0b6
@ -345,7 +345,9 @@ AC_CHECK_SIZEOF([long])
|
|||||||
dnl Availability of various common functions (non-fatal if missing),
|
dnl Availability of various common functions (non-fatal if missing),
|
||||||
dnl and various less common threadsafe functions
|
dnl and various less common threadsafe functions
|
||||||
AC_CHECK_FUNCS_ONCE([\
|
AC_CHECK_FUNCS_ONCE([\
|
||||||
|
elf_aux_info \
|
||||||
fallocate \
|
fallocate \
|
||||||
|
getauxval \
|
||||||
getegid \
|
getegid \
|
||||||
geteuid \
|
geteuid \
|
||||||
getgid \
|
getgid \
|
||||||
@ -374,6 +376,7 @@ AC_CHECK_FUNCS_ONCE([\
|
|||||||
|
|
||||||
dnl Availability of various common headers (non-fatal if missing).
|
dnl Availability of various common headers (non-fatal if missing).
|
||||||
AC_CHECK_HEADERS([\
|
AC_CHECK_HEADERS([\
|
||||||
|
asm/hwcap.h \
|
||||||
ifaddrs.h \
|
ifaddrs.h \
|
||||||
libtasn1.h \
|
libtasn1.h \
|
||||||
util.h \
|
util.h \
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#if defined(__aarch64__)
|
#if defined(__aarch64__)
|
||||||
# include <asm/hwcap.h>
|
# if defined(HAVE_ASM_HWCAP_H)
|
||||||
|
# include <asm/hwcap.h>
|
||||||
|
# endif
|
||||||
# include <sys/auxv.h>
|
# include <sys/auxv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -518,11 +520,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data)
|
|||||||
int cpu_feature_index = 0;
|
int cpu_feature_index = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
# if defined(HAVE_GETAUXVAL)
|
||||||
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
|
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("CPUID registers unavailable"));
|
_("CPUID registers unavailable"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
/* read the cpuid data from MIDR_EL1 register */
|
/* read the cpuid data from MIDR_EL1 register */
|
||||||
asm("mrs %0, MIDR_EL1" : "=r" (cpuid));
|
asm("mrs %0, MIDR_EL1" : "=r" (cpuid));
|
||||||
@ -533,7 +537,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data)
|
|||||||
/* parse the corresponding vendor_id bits */
|
/* parse the corresponding vendor_id bits */
|
||||||
data->vendor_id = (cpuid >> 24) & 0xff;
|
data->vendor_id = (cpuid >> 24) & 0xff;
|
||||||
|
|
||||||
|
# if defined(HAVE_GETAUXVAL)
|
||||||
hwcaps = getauxval(AT_HWCAP);
|
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);
|
VIR_DEBUG("CPU flags read from register: 0x%016lx", hwcaps);
|
||||||
|
|
||||||
features = g_new0(char *, MAX_CPU_FLAGS + 1);
|
features = g_new0(char *, MAX_CPU_FLAGS + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user