|
Line 0
Link Here
|
|
|
1 |
--- src/cpu/cpu_arm.c.orig 2020-07-02 18:19:46 UTC |
| 2 |
+++ src/cpu/cpu_arm.c |
| 3 |
@@ -22,7 +22,9 @@ |
| 4 |
|
| 5 |
#include <config.h> |
| 6 |
#if defined(__aarch64__) |
| 7 |
-# include <asm/hwcap.h> |
| 8 |
+# if defined(__linux__) |
| 9 |
+# include <asm/hwcap.h> |
| 10 |
+# endif |
| 11 |
# include <sys/auxv.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
@@ -518,11 +520,13 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data) |
| 15 |
int cpu_feature_index = 0; |
| 16 |
size_t i; |
| 17 |
|
| 18 |
+#if defined(__linux__) |
| 19 |
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) { |
| 20 |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", |
| 21 |
_("CPUID registers unavailable")); |
| 22 |
return -1; |
| 23 |
} |
| 24 |
+#endif |
| 25 |
|
| 26 |
/* read the cpuid data from MIDR_EL1 register */ |
| 27 |
asm("mrs %0, MIDR_EL1" : "=r" (cpuid)); |
| 28 |
@@ -533,7 +537,11 @@ virCPUarmCpuDataFromRegs(virCPUarmData *data) |
| 29 |
/* parse the coresponding vendor_id bits */ |
| 30 |
data->vendor_id = (cpuid >> 24) & 0xff; |
| 31 |
|
| 32 |
+#if defined(__linux__) |
| 33 |
hwcaps = getauxval(AT_HWCAP); |
| 34 |
+#elif defined(__FreeBSD__) |
| 35 |
+ elf_aux_info(AT_HWCAP, &hwcaps, sizeof(u_long)); |
| 36 |
+#endif |
| 37 |
VIR_DEBUG("CPU flags read from register: 0x%016lx", hwcaps); |
| 38 |
|
| 39 |
features = g_new0(char *, MAX_CPU_FLAGS + 1); |