Skip to contentSkip to conversation

Fix dependencies in arm machines and update OpenBSD to 7.7

PATCH Superseded Thomas Huth 5 participants 15 messages May 8, 2025 – May 10, 2025

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/5 include/hw/dma/xlnx_dpdma: Remove dependency on console.h

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

console.h brings a dependency on the <epoxy/opengl.h> and the pixman header file (if available), so we should avoid to include this file if it is not really necessary (otherwise we have to specify the dependency in the meson.build file, too, to get the right include paths everywhere). console.h does not seem to be necessary for the xlnx_dpdma code, so drop the include here.

---
 include/hw/dma/xlnx_dpdma.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/dma/xlnx_dpdma.h +0 -1
index 1ec0d265be2..484b2e377f0 100644
@@ -26,7 +26,6 @@
 #define XLNX_DPDMA_H
 
 #include "hw/sysbus.h"
-#include "ui/console.h"
 #include "system/dma.h"
 #include "qom/object.h"
 
Signature · 1 line
2.49.0
#2 lore raw

PATCH 2/5 hw/display/bcm2835_fb: Move inclusion of console.h to the .c file

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

The definitions from console.h are not needed in the bcm2835_fb.h header file yet, so let's move it to the place that really needs its definitions, i.e. into the bcm2835_fb.c file.
This way the header can also be used by code that is not compiled with the CFLAGS that are required for pixman or OpenGL (in case their headers do not reside under /usr/include).

---
 include/hw/display/bcm2835_fb.h | 1 -
 hw/display/bcm2835_fb.c         | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
include/hw/display/bcm2835_fb.h +0 -1
index 49541bf08f4..acc9230b6a8 100644
@@ -13,7 +13,6 @@
 #define BCM2835_FB_H
 
 #include "hw/sysbus.h"
-#include "ui/console.h"
 #include "qom/object.h"
 
 #define UPPER_RAM_BASE 0x40000000
hw/display/bcm2835_fb.c +1 -0
index 820e67ac8bb..1bb2ee45a01 100644
@@ -27,6 +27,7 @@
 #include "hw/display/bcm2835_fb.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
+#include "ui/console.h"
 #include "framebuffer.h"
 #include "ui/pixel_ops.h"
 #include "hw/misc/bcm2835_mbox_defs.h"
Signature · 1 line
2.49.0
#6 lore raw

PATCH 4/5 tests/vm: Update OpenBSD to 7.7

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

OpenBSD 7.7 has been released at the end of April 2025, so let's update to that version.

---
 tests/vm/openbsd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/vm/openbsd +2 -2
index 5e4f76f3988..2ea86a01bad 100755
@@ -22,8 +22,8 @@ class OpenBSDVM(basevm.BaseVM):
     name = "openbsd"
     arch = "x86_64"
 
-    link = "https://cdn.openbsd.org/pub/OpenBSD/7.6/amd64/install76.iso"
-    csum = "60cba8cb391b50bba8fa10fc768bd0529636f5345d82133c93e22c798d8e5269"
+    link = "https://cdn.openbsd.org/pub/OpenBSD/7.7/amd64/install77.iso"
+    csum = "da0106e39463f015524dca806f407c37a9bdd17e6dfffe533b06a2dd2edd8a27"
     size = "20G"
     pkgs = [
         # tools
Signature · 1 line
2.49.0
#0 lore raw

cover Fix dependencies in arm machines and update OpenBSD to 7.7

At the end of April, OpenBSD 7.7 has been released, so we could update our test VM to that version now. However, I noticed that some arm machines now fail to compile since they fail to include the <epoxy/gl.h> header. This header resides in /usr/X11R6/include instead of /usr/include in OpenBSD, so we have to make sure that the machines are compiled with the right CFLAGS (or don't include the header at all if it is not really necessary). Thus the first patches of this series clean up this first before we can finally switch to OpenBSD 7.7. The last patch then also reverts a hack for OpenBSD in the main meson.build file since the related problem has finally been fixed there.

Thomas Huth (5):
include/hw/dma/xlnx_dpdma: Remove dependency on console.h hw/display/bcm2835_fb: Move inclusion of console.h to the .c file hw/arm: Compile musicpal and the xlnx machines with the right CFLAGS tests/vm: Update OpenBSD to 7.7
Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

 meson.build                     | 6 +-----
 include/hw/display/bcm2835_fb.h | 1 -
 include/hw/dma/xlnx_dpdma.h     | 1 -
 hw/display/bcm2835_fb.c         | 1 +
 hw/arm/meson.build              | 4 ++--
 tests/vm/openbsd                | 4 ++--
 6 files changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
2.49.0
#7 lore raw

PATCH 5/5 Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

From: Thomas Huth <[email protected]>

This reverts commit 2d6d995709482cc8b6a76dbb5334a28001a14a9a.

OpenBSD 7.7 fixed the problem with the -fzero-call-used-regs on OpenBSD, see https://github.com/openbsd/src/commit/03eca72d1e030b7a542cd6aec1 for the fix there.

---
 meson.build | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
meson.build +1 -5
index 6c61e1dcaec..5f0e6a65cb0 100644
@@ -699,11 +699,7 @@ hardening_flags = [
 #
 # NB: Clang 17 is broken and SEGVs
 # https://github.com/llvm/llvm-project/issues/75168
-#
-# NB2: This clashes with the "retguard" extension of OpenBSD's Clang
-# https://gitlab.com/qemu-project/qemu/-/issues/2278
-if host_os != 'openbsd' and \
-   cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
+if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
                name: '-fzero-call-used-regs=used-gpr',
                args: ['-O2', '-fzero-call-used-regs=used-gpr'])
     hardening_flags += '-fzero-call-used-regs=used-gpr'
Signature · 1 line
2.49.0
#3 lore raw

PATCH 3/5 hw/arm: Compile musicpal and the xlnx machines with the right CFLAGS

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

These machines include ui/console.h, which in turn includes the pixman headers and <epoxy/gl.h> via ui/surface.h. If these library headers are located outside of /usr/include (like gl.h on OpenBSD 7.7), we must make sure to compile this code with the right CFLAGS so that the headers can be found.

---
 hw/arm/meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/meson.build +2 -2
index 5098795f61d..51d0c055abf 100644
@@ -8,7 +8,7 @@ arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c'))
 arm_common_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c'))
 arm_common_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
 arm_common_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c'))
-arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [pixman, files('musicpal.c')])
+arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [files('musicpal.c'), pixman, opengl])
 arm_common_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c'))
 arm_common_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c'))
 arm_common_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c'))
@@ -34,7 +34,7 @@ arm_common_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'
 arm_common_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
 arm_common_ss.add(when: 'CONFIG_B_L475E_IOT01A', if_true: files('b-l475e-iot01a.c'))
 arm_common_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_soc.c'))
-arm_common_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp.c', 'xlnx-zcu102.c'))
+arm_common_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: [files('xlnx-zynqmp.c', 'xlnx-zcu102.c'), pixman, opengl])
 arm_common_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal.c', 'xlnx-versal-virt.c'))
 arm_common_ss.add(when: 'CONFIG_FSL_IMX25', if_true: files('fsl-imx25.c', 'imx25_pdk.c'))
 arm_common_ss.add(when: 'CONFIG_FSL_IMX31', if_true: files('fsl-imx31.c', 'kzm.c'))
Signature · 1 line
2.49.0
#8 lore raw

Re: [PATCH 5/5] Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

In reply to Thomas Huth
Quoted 7 lines · Thomas Huth

From: Thomas Huth <[email protected]>

This reverts commit 2d6d995709482cc8b6a76dbb5334a28001a14a9a.

OpenBSD 7.7 fixed the problem with the -fzero-call-used-regs on OpenBSD, see https://github.com/openbsd/src/commit/03eca72d1e030b7a542cd6aec1 for the fix there.

Is that fix also backported to OpenBS 7.6 ?

We support the 2 most recent releases of each platform, so for OpenBSD thats currently 7.6 and 7.7.

If it wasn't backported to 7.6, we must wait until 7.8 before we can rely on the fix being present.

Quoted 27 lines
---
 meson.build | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
meson.build +1 -5
index 6c61e1dcaec..5f0e6a65cb0 100644
@@ -699,11 +699,7 @@ hardening_flags = [
 #
 # NB: Clang 17 is broken and SEGVs
 # https://github.com/llvm/llvm-project/issues/75168
-#
-# NB2: This clashes with the "retguard" extension of OpenBSD's Clang
-# https://gitlab.com/qemu-project/qemu/-/issues/2278
-if host_os != 'openbsd' and \
-   cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
+if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
                name: '-fzero-call-used-regs=used-gpr',
                args: ['-O2', '-fzero-call-used-regs=used-gpr'])
     hardening_flags += '-fzero-call-used-regs=used-gpr'
Signature · 1 line
2.49.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#9 lore raw

Re: [PATCH 5/5] Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

Quoted 5 lines · Daniel P. Berrangé
Quoted 4 lines · Thomas Huth

From: Thomas Huth <[email protected]>

This reverts commit 2d6d995709482cc8b6a76dbb5334a28001a14a9a.

Quoted 8 lines
Quoted 3 lines

OpenBSD 7.7 fixed the problem with the -fzero-call-used-regs on OpenBSD, see https://github.com/openbsd/src/commit/03eca72d1e030b7a542cd6aec1 for the fix there.

Is that fix also backported to OpenBS 7.6 ?

We support the 2 most recent releases of each platform, so for OpenBSD thats currently 7.6 and 7.7.

Sure about that? We claim to "support the most recent major version at all times" and "Support for the previous major version will be dropped 2 years after the new major version is released or when the vendor itself drops support, whichever comes first.".

So for me that sounds like we only support 7.7 now, since the support for the previous major release - which was 6.x - has ended already.

(Apart from that: Does 7.6 still get updates or does the OpenBSD team drop the support once 7.7 was released?)

Thomas

#10 lore raw

Re: [PATCH 5/5] Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

Quoted 10 lines · Thomas Huth
Quoted 2 lines

We support the 2 most recent releases of each platform, so for OpenBSD thats currently 7.6 and 7.7.

Sure about that? We claim to "support the most recent major version at all times" and "Support for the previous major version will be dropped 2 years after the new major version is released or when the vendor itself drops support, whichever comes first.".

So for me that sounds like we only support 7.7 now, since the support for the previous major release - which was 6.x - has ended already.

OpenBSD does not really have major/minor releases. It just rolls over from x.9 to (x+1).0, so the supported releases are 7.6 and 7.7.

Paolo

#11 lore raw

Re: [PATCH 5/5] Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

Quoted 9 lines · Paolo Bonzini
Quoted 8 lines · Thomas Huth
Quoted 2 lines

We support the 2 most recent releases of each platform, so for OpenBSD thats currently 7.6 and 7.7.

Sure about that? We claim to "support the most recent major version at all times" and "Support for the previous major version will be dropped 2 years after the new major version is released or when the vendor itself drops support, whichever comes first.".

Quoted 5 lines
Quoted 2 lines

So for me that sounds like we only support 7.7 now, since the support for the previous major release - which was 6.x - has ended already.

OpenBSD does not really have major/minor releases. It just rolls over from x.9 to (x+1).0, so the supported releases are 7.6 and 7.7.

Ok, but then maybe someone should adjust docs/about/build-platforms.rst to avoid confusion here.

Thomas

#4 lore raw

Re: [PATCH 3/5] hw/arm: Compile musicpal and the xlnx machines with the right CFLAGS

In reply to Thomas Huth
Quoted 19 lines · Thomas Huth

From: Thomas Huth <[email protected]>

These machines include ui/console.h, which in turn includes the pixman headers and <epoxy/gl.h> via ui/surface.h. If these library headers are located outside of /usr/include (like gl.h on OpenBSD 7.7), we must make sure to compile this code with the right CFLAGS so that the headers can be found.

---
 hw/arm/meson.build | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/meson.build +0 -0
index 5098795f61d..51d0c055abf 100644

hw/arm/meson.build arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c')) · line 11

Quoted 5 lines
hw/arm/meson.build +1 -1
@@ -8,7 +8,7 @@ arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c'))
 arm_common_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c'))
 arm_common_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
 arm_common_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c'))
-arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [pixman, files('musicpal.c')])
+arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [files('musicpal.c'), pixman, opengl])

Is there not some better way to do this with Meson? If we're building with the opengl dependency then the header files should go on the include path for all the compilation objects, not just ones where we explicitly ask for it. Otherwise you get bugs like this because there's nothing that will check that you only used header X in C files which say they're using the dependency.

I think that either:
* the build system should ensure it gets the headers right when it's building things
* there should be some check such that "use header X without declaring dependency on it" is a build failure everywhere, not just on the oddball hosts where X isn't in the default include path

thanks
-- PMM

#13 lore raw
In reply to Thomas Huth
Quoted 11 lines · Thomas Huth

At the end of April, OpenBSD 7.7 has been released, so we could update our test VM to that version now. However, I noticed that some arm machines now fail to compile since they fail to include the <epoxy/gl.h> header. This header resides in /usr/X11R6/include instead of /usr/include in OpenBSD, so we have to make sure that the machines are compiled with the right CFLAGS (or don't include the header at all if it is not really necessary). Thus the first patches of this series clean up this first before we can finally switch to OpenBSD 7.7. The last patch then also reverts a hack for OpenBSD in the main meson.build file since the related problem has finally been fixed there.

It looks like you forgot to cc qemu-devel; would you mind reposting so the series gets picked up by patchew etc and gets seen by people who only read -devel?

thanks
-- PMM

#14 lore raw
Quoted 13 lines · Peter Maydell
Quoted 11 lines · Thomas Huth

At the end of April, OpenBSD 7.7 has been released, so we could update our test VM to that version now. However, I noticed that some arm machines now fail to compile since they fail to include the <epoxy/gl.h> header. This header resides in /usr/X11R6/include instead of /usr/include in OpenBSD, so we have to make sure that the machines are compiled with the right CFLAGS (or don't include the header at all if it is not really necessary). Thus the first patches of this series clean up this first before we can finally switch to OpenBSD 7.7. The last patch then also reverts a hack for OpenBSD in the main meson.build file since the related problem has finally been fixed there.

Quoted 3 lines

It looks like you forgot to cc qemu-devel; would you mind reposting so the series gets picked up by patchew etc and gets seen by people who only read -devel?

Ooops, sorry, will do! Thanks for noticing it!

Thomas

Reviewed-by Philippe Mathieu-Daudé
#5 lore raw

Re: [PATCH 3/5] hw/arm: Compile musicpal and the xlnx machines with the right CFLAGS

In reply to Peter Maydell
Quoted 11 lines · Peter Maydell

hw/arm/meson.build arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c')) · line 11

Quoted 10 lines
hw/arm/meson.build +1 -1
index 5098795f61d..51d0c055abf 100644
@@ -8,7 +8,7 @@ arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c'))
  arm_common_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c'))
  arm_common_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
  arm_common_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c'))
-arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [pixman, files('musicpal.c')])
+arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [files('musicpal.c'), pixman, opengl])
Quoted 8 lines

Is there not some better way to do this with Meson? I think that either:
* the build system should ensure it gets the headers right when it's building things
* there should be some check such that "use header X without declaring dependency on it" is a build failure everywhere, not just on the oddball hosts where X isn't in the default include path

The former was already happening for specific_ss

  # allow using headers from the dependencies but do not include the sources
  lib_deps = []
  foreach dep : arch_deps
    lib_deps += dep.partial_dependency(compile_args: true, includes: true)
  endforeach

lib = static_library('qemu-' + target,
sources: arch_srcs + genh,
dependencies: lib_deps,

and the commit message shows that it was for a similar case:

commit 727bb5b477e66b6cd8a558bf2cdf9a666b914f27
Author: Paolo Bonzini <[email protected]>
Date: Tue May 7 12:22:31 2024 +0200

meson: pick libfdt from common_ss when building target-specific files

Avoid having to list dependencies such as libfdt twice, both on common_ss and specific_ss. Instead, just take all the dependencies in common_ss and allow the target-specific libqemu-*.fa library to use them.

(Note that the partial_dependency() stuff is not strictly needed. It's only there to document *why* the dependency are added).

Plus, there is an older workaround (that should be unnecessary these days) in ui/meson.build:

specific_ss.add(when: ['CONFIG_SYSTEM_ONLY'], if_true: pixman) # for the include path
specific_ss.add(when: ['CONFIG_SYSTEM_ONLY'], if_true: opengl) # for the include path

The root cause is that specific_ss (and now hw_common_arch[]) is built as a separate target so the common code's include paths have to be added either by hand as in Thomas's patch, or with a for loop as in the above commit.

So, the problem is that a loop similar to the one above was not added when building hw_common_arch_libs. Something like this should work:

meson.build +17 -12
index bfddcc07dfd..812d6f90adb 100644
@@ -3237,6 +3237,7 @@ config_devices_mak_list = []
 config_devices_h = {}
 config_target_h = {}
 config_target_mak = {}
+config_base_arch_mak = {}
 
 disassemblers = {
   'alpha' : ['CONFIG_ALPHA_DIS'],
@@ -3428,6 +3429,11 @@ foreach target : target_dirs
     config_all_devices += config_devices
   endif
   config_target_mak += {target: config_target}
+
+  # build a merged config for all targets with the same TARGET_BASE_ARCH
+  target_base_arch = config_target['TARGET_BASE_ARCH']
+  config_base_arch = config_base_arch_mak.get(target_base_arch, {}) + config_target
+  config_base_arch_mak += {target_base_arch: config_base_arch}
 endforeach
 target_dirs = actual_target_dirs
 
@@ -4107,28 +4113,27 @@ common_all = static_library('common',
 
 # construct common libraries per base architecture
 hw_common_arch_libs = {}
-foreach target : target_dirs
-  config_target = config_target_mak[target]
-  target_base_arch = config_target['TARGET_BASE_ARCH']
-
-  # check if already generated
-  if target_base_arch in hw_common_arch_libs
-    continue
-  endif
-
+foreach target_base_arch, config_base_arch : config_base_arch_mak
   if target_base_arch in hw_common_arch
+    base_arch_hw = hw_common_arch[target_base_arch].apply(config_base_arch, strict: false)
+    base_arch_common = common_ss.apply(config_base_arch, strict: false)
+
+    lib_deps = base_arch_hw.dependencies()
+    foreach dep : base_arch_common.dependencies()
+      lib_deps += dep.partial_dependency(compile_args: true, includes: true)
+    endforeach
+
     target_inc = [include_directories('target' / target_base_arch)]
-    src = hw_common_arch[target_base_arch]
     lib = static_library(
       'hw_' + target_base_arch,
       build_by_default: false,
-      sources: src.all_sources() + genh,
+      sources: base_arch_hw.sources() + genh,
       include_directories: common_user_inc + target_inc,
       implicit_include_directories: false,
       # prevent common code to access cpu compile time
       # definition, but still allow access to cpu.h
       c_args: ['-DCPU_DEFS_H', '-DCOMPILING_SYSTEM_VS_USER', '-DCONFIG_SOFTMMU'],
-      dependencies: src.all_dependencies())
+      dependencies: lib_deps)
     hw_common_arch_libs += {target_base_arch: lib}
   endif
 endforeach

(It passes at least "make libhw_arm.a" here).

Paolo

#12 lore raw

Re: [PATCH 5/5] Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD"

In reply to Daniel P. Berrangé
Quoted 8 lines · Daniel P. Berrangé
Quoted 7 lines · Thomas Huth

From: Thomas Huth<[email protected]>

This reverts commit 2d6d995709482cc8b6a76dbb5334a28001a14a9a.

OpenBSD 7.7 fixed the problem with the -fzero-call-used-regs on OpenBSD, seehttps://github.com/openbsd/src/commit/03eca72d1e030b7a542cd6aec1 for the fix there.

Quoted 7 lines

Is that fix also backported to OpenBS 7.6 ?

We support the 2 most recent releases of each platform, so for OpenBSD thats currently 7.6 and 7.7.

If it wasn't backported to 7.6, we must wait until 7.8 before we can rely on the fix being present.

I was under the impression it was only 1.

Oh well. Just means waiting until end of Oct for the next release.