[PATCH] cpu_arm: fix build on non-Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 - 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@xxxxxxxxx>
---
 configure.ac      |  3 +++
 src/cpu/cpu_arm.c | 12 +++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 79055db9b1..40a326c1aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 \
diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index cd4f720c95..fbc363e9c7 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -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 coresponding 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);
-- 
2.27.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux