The attached very trivial patch fixes a startup bug that prevents at
least Qemu 3.1 and later from working on FreeBSD/powerpc64.

- Justin
>From 74a70fdcfa5347e7637aa36276c55781f19de72a Mon Sep 17 00:00:00 2001
From: Justin Hibbits <chmeeed...@gmail.com>
Date: Fri, 7 Jun 2019 13:44:51 -0500
Subject: [PATCH] Fix cacheline detection on FreeBSD/powerpc.

machdep.cacheline_size is an integer, not a long.  Since PowerPC is
big-endian this causes sysctlbyname() to fill in the upper bits of the
argument, rather than the correct 'lower bits' of the word.  Specify the
correct type to fix this.

Signed-off-by: Justin Hibbits <chmeeed...@gmail.com>
---
 util/cacheinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/cacheinfo.c b/util/cacheinfo.c
index eebe1ce9c5..516f837748 100644
--- a/util/cacheinfo.c
+++ b/util/cacheinfo.c
@@ -77,7 +77,7 @@ static void sys_cache_info(int *isize, int *dsize)
 static void sys_cache_info(int *isize, int *dsize)
 {
     /* There's only a single sysctl for both I/D cache line sizes.  */
-    long size;
+    int size;
     size_t len = sizeof(size);
     if (!sysctlbyname(SYSCTL_CACHELINE_NAME, &size, &len, NULL, 0)) {
         *isize = *dsize = size;
-- 
2.21.0

Reply via email to