Skip to contentSkip to conversation

pvg: clean up Kconfig

PATCH In review Paolo Bonzini 2 participants 6 messages Feb 20, 2025 – Feb 24, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover pvg: clean up Kconfig

Do not enable Apple ParavirtualizedGraphics on cross-architecture targets, where it is not supported by the drivers, and add an option to configure it out just like most others external dependencies.

Only compile-tested on non-Mac for now, but CI is in progress.

Paolo

Paolo Bonzini (2):
pvg: do not enable it on cross-architecture targets
pvg: add option to configure it out

 meson.build                   | 16 +++++++++++++---
 Kconfig.host                  |  3 +++
 hw/display/Kconfig            |  4 ----
 hw/display/meson.build        |  9 +++------
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.sh |  3 +++
 6 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 pvg: do not enable it on cross-architecture targets

PVG is not cross-architecture; the PVG guest drivers with x86-64 macOS do not give useful results with the aarch64 macOS host PVG framework, and vice versa. To express this repurpose CONFIG_MAC_PVG, making it true only if the target has the same architecture as the host. Furthermore, remove apple-gfx.m unless one of the devices is actually present.

---
 meson.build            | 6 ++++++
 Kconfig.host           | 3 +++
 hw/display/Kconfig     | 4 ----
 hw/display/meson.build | 9 +++------
 4 files changed, 12 insertions(+), 10 deletions(-)
meson.build +6 -0
index 0ee79c664d3..ad2c6b61930 100644
@@ -3367,6 +3367,12 @@ foreach target : target_dirs
     target_kconfig += 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'
     target_kconfig += 'CONFIG_TARGET_BIG_ENDIAN=' + config_target['TARGET_BIG_ENDIAN']
 
+    # PVG is not cross-architecture.  Use accelerator_targets as a proxy to
+    # figure out which target can support PVG on this host
+    if pvg.found() and target in accelerator_targets.get('CONFIG_HVF', [])
+      target_kconfig += 'CONFIG_MAC_PVG=y'
+    endif
+
     config_input = meson.get_external_property(target, 'default')
     config_devices_mak = target + '-config-devices.mak'
     config_devices_mak = configure_file(
Kconfig.host +3 -0
index 842cbe0d6c5..933425c74b4 100644
@@ -61,3 +61,6 @@ config HV_BALLOON_POSSIBLE
 
 config HAVE_RUST
     bool
+
+config MAC_PVG
+    bool
hw/display/Kconfig +0 -4
index 2b53dfd7d26..1e95ab28ef4 100644
@@ -141,10 +141,6 @@ config XLNX_DISPLAYPORT
 config DM163
     bool
 
-config MAC_PVG
-    bool
-    default y
-
 config MAC_PVG_MMIO
     bool
     depends on MAC_PVG && AARCH64
hw/display/meson.build +3 -6
index 94f4f05d36f..b9bdf219103 100644
@@ -61,12 +61,9 @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c'))
 
 system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman])
 
-if host_os == 'darwin'
-  system_ss.add(when: 'CONFIG_MAC_PVG',         if_true: [files('apple-gfx.m'), pvg, metal])
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx-pci.m'), pvg, metal])
-  if cpu == 'aarch64'
-    system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',  if_true: [files('apple-gfx-mmio.m'), pvg, metal])
-  endif
+if pvg.found()
+  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx.m', 'apple-gfx-pci.m'), pvg, metal])
+  system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',    if_true: [files('apple-gfx.m', 'apple-gfx-mmio.m'), pvg, metal])
 endif
 
 if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
Signature · 1 line
2.48.1
#2 lore raw

Re: [PATCH 1/2] pvg: do not enable it on cross-architecture targets

Quoted 47 lines · Paolo Bonzini

PVG is not cross-architecture; the PVG guest drivers with x86-64 macOS do not give useful results with the aarch64 macOS host PVG framework, and vice versa. To express this repurpose CONFIG_MAC_PVG, making it true only if the target has the same architecture as the host. Furthermore, remove apple-gfx.m unless one of the devices is actually present.

---
  meson.build            | 6 ++++++
  Kconfig.host           | 3 +++
  hw/display/Kconfig     | 4 ----
  hw/display/meson.build | 9 +++------
  4 files changed, 12 insertions(+), 10 deletions(-)
meson.build +6 -0
index 0ee79c664d3..ad2c6b61930 100644
@@ -3367,6 +3367,12 @@ foreach target : target_dirs
      target_kconfig += 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'
      target_kconfig += 'CONFIG_TARGET_BIG_ENDIAN=' + config_target['TARGET_BIG_ENDIAN']
 
+    # PVG is not cross-architecture.  Use accelerator_targets as a proxy to
+    # figure out which target can support PVG on this host
+    if pvg.found() and target in accelerator_targets.get('CONFIG_HVF', [])
+      target_kconfig += 'CONFIG_MAC_PVG=y'
+    endif
+
      config_input = meson.get_external_property(target, 'default')
      config_devices_mak = target + '-config-devices.mak'
      config_devices_mak = configure_file(
Kconfig.host +3 -0
index 842cbe0d6c5..933425c74b4 100644
@@ -61,3 +61,6 @@ config HV_BALLOON_POSSIBLE
 
  config HAVE_RUST
      bool
+
+config MAC_PVG
+    bool
hw/display/Kconfig +0 -0
index 2b53dfd7d26..1e95ab28ef4 100644

hw/display/Kconfig config XLNX_DISPLAYPORT · line 146

Quoted 10 lines
hw/display/Kconfig +0 -4
@@ -141,10 +141,6 @@ config XLNX_DISPLAYPORT
  config DM163
      bool
 
-config MAC_PVG
-    bool
-    default y
-
  config MAC_PVG_MMIO
      bool
      depends on MAC_PVG && AARCH64

Hmm what about keeping a MAC_PVG_COMMON instead:

-- >8 --

hw/display/Kconfig +6 -4
@@ -141,15 +141,17 @@ config XLNX_DISPLAYPORT
 config DM163
     bool
 
-config MAC_PVG
+config MAC_PVG_COMMON
     bool
-    default y
+    depends on MAC_PVG
 
 config MAC_PVG_MMIO
     bool
-    depends on MAC_PVG && AARCH64
+    depends on AARCH64
+    select MAC_PVG_COMMON
 
 config MAC_PVG_PCI
     bool
-    depends on MAC_PVG && PCI
+    depends on PCI
+    select MAC_PVG_COMMON
     default y if PCI_DEVICES

---

Quoted 8 lines
hw/display/meson.build +0 -0
index 94f4f05d36f..b9bdf219103 100644
@@ -61,12 +61,9 @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c'))
 
  system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman])
 

hw/display/meson.build system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) · line 67

Quoted 10 lines
hw/display/meson.build +3 -6
-if host_os == 'darwin'
-  system_ss.add(when: 'CONFIG_MAC_PVG',         if_true: [files('apple-gfx.m'), pvg, metal])
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx-pci.m'), pvg, metal])
-  if cpu == 'aarch64'
-    system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',  if_true: [files('apple-gfx-mmio.m'), pvg, metal])
-  endif
+if pvg.found()
+  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx.m', 'apple-gfx-pci.m'), pvg, metal])
+  system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',    if_true: [files('apple-gfx.m', 'apple-gfx-mmio.m'), pvg, metal])
  endif

Directly using here:

-- >8 --

hw/display/meson.build +0 -0
index 94f4f05d36f..f636ca0999c 100644
@@ -61,13 +61,9 @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c'))
 
 system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 

'ati_2d.c', 'ati_dbg.c'), pixman])

-if host_os == 'darwin'

-  system_ss.add(when: 'CONFIG_MAC_PVG',         if_true: [files('apple-gfx.m'), pvg, metal])
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx-pci.m'), pvg, metal])
-  if cpu == 'aarch64'

- system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal])
- endif
-endif
+system_ss.add(when: 'CONFIG_MAC_PVG_COMMON', if_true: [files('apple-gfx.m'), pvg, metal])
+system_ss.add(when: 'CONFIG_MAC_PVG_PCI', if_true: [files('apple-gfx-pci.m'), pvg, metal])
+system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal])

if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
virtio_gpu_ss = ss.source_set()
---

?

#3 lore raw

Re: [PATCH 1/2] pvg: do not enable it on cross-architecture targets

Quoted 9 lines · Philippe Mathieu-Daudé

Hmm what about keeping a MAC_PVG_COMMON instead:

-- >8 --

hw/display/Kconfig +0 -0
@@ -141,15 +141,17 @@ config XLNX_DISPLAYPORT
  config DM163
      bool
 

hw/display/Kconfig config XLNX_DISPLAYPORT · line 150

Quoted 10 lines
hw/display/Kconfig +3 -3
-config MAC_PVG
+config MAC_PVG_COMMON
      bool
-    default y
+    depends on MAC_PVG
 
  config MAC_PVG_MMIO
      bool
-    depends on MAC_PVG && AARCH64
+    depends on AARCH64

It's possible, but the two "depends on MAC_PVG" cannot be removed here, because otherwise MAC_PVG_PCI would be selected by "default y". The only reason to do so, in my opinion, was if one wanted to build pvg as a module, otherwise it's just (a handful) more lines of code with no particular benefit.

Quoted 11 lines
hw/display/Kconfig +0 -5
-if host_os == 'darwin'
-  system_ss.add(when: 'CONFIG_MAC_PVG',         if_true: [files('apple- 
 gfx.m'), pvg, metal])
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple- 
 gfx-pci.m'), pvg, metal])
-  if cpu == 'aarch64'
-    system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',  if_true: [files('apple- 

gfx-mmio.m'), pvg, metal])
-  endif

hw/display/Kconfig +1 -1
-endif
+system_ss.add(when: 'CONFIG_MAC_PVG_COMMON', if_true: [files('apple- 
Quoted 5 lines

gfx.m'), pvg, metal])
+system_ss.add(when: 'CONFIG_MAC_PVG_PCI',    if_true: [files('apple- gfx-pci.m'), pvg, metal])
+system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',   if_true: [files('apple- gfx-mmio.m'), pvg, metal])

Removing the "if" is independent of whether you keep CONFIG_MAC_PVG_COMMON. I can squash that in patch 2:

-if pvg.found()

-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx.m', 'apple-gfx-pci.m'), pvg])
-  system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',    if_true: [files('apple-gfx.m', 'apple-gfx-mmio.m'), pvg])

-endif
+system_ss.add(when: [pvg, 'CONFIG_MAC_PVG_PCI'], if_true: [files('apple-gfx.m', 'apple-gfx-pci.m')])
+system_ss.add(when: [pvg, 'CONFIG_MAC_PVG_MMIO'], if_true: [files('apple-gfx.m', 'apple-gfx-mmio.m')])

(you need to keep the conditional, whether as "if" or "when:"; otherwise, because Meson cannot know that the .m files will never be built, it complains that you don't have an Objective-C compiler).

Paolo

#4 lore raw

Re: [PATCH 1/2] pvg: do not enable it on cross-architecture targets

Quoted 58 lines · Paolo Bonzini
Quoted 15 lines · Philippe Mathieu-Daudé

Hmm what about keeping a MAC_PVG_COMMON instead:

-- >8 --

hw/display/Kconfig +0 -0
@@ -141,15 +141,17 @@ config XLNX_DISPLAYPORT

  config DM163
      bool

hw/display/Kconfig +1 -1
-config MAC_PVG
+config MAC_PVG_COMMON

      bool
-    default y
+    depends on MAC_PVG

Quoted 4 lines

  config MAC_PVG_MMIO
      bool
-    depends on MAC_PVG && AARCH64
+    depends on AARCH64

It's possible, but the two "depends on MAC_PVG" cannot be removed here, because otherwise MAC_PVG_PCI would be selected by "default y".  The only reason to do so, in my opinion, was if one wanted to build pvg as a module, otherwise it's just (a handful) more lines of code with no particular benefit.

Quoted 11 lines

-if host_os == 'darwin'
-  system_ss.add(when: 'CONFIG_MAC_PVG',         if_true:
[files('apple- gfx.m'), pvg, metal])
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true:
[files('apple- gfx-pci.m'), pvg, metal])
-  if cpu == 'aarch64'
-    system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',  if_true:
[files('apple- gfx-mmio.m'), pvg, metal])
-  endif

hw/display/Kconfig +1 -1
-endif
+system_ss.add(when: 'CONFIG_MAC_PVG_COMMON', if_true: [files('apple- 
Quoted 5 lines

gfx.m'), pvg, metal])
+system_ss.add(when: 'CONFIG_MAC_PVG_PCI',    if_true: [files('apple- gfx-pci.m'), pvg, metal])
+system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',   if_true: [files('apple- gfx-mmio.m'), pvg, metal])

Removing the "if" is independent of whether you keep CONFIG_MAC_PVG_COMMON. I can squash that in patch 2:

-if pvg.found()
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple- gfx.m', 'apple-gfx-pci.m'), pvg])
-  system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',    if_true: [files('apple- gfx.m', 'apple-gfx-mmio.m'), pvg])

(quoted diff) +1 -1
-endif
+system_ss.add(when: [pvg, 'CONFIG_MAC_PVG_PCI'],     if_true: 

[files('apple-gfx.m', 'apple-gfx-pci.m')]) +system_ss.add(when: [pvg, 'CONFIG_MAC_PVG_MMIO'],    if_true:
[files('apple-gfx.m', 'apple-gfx-mmio.m')])

Quoted 3 lines

(you need to keep the conditional, whether as "if" or "when:"; otherwise, because Meson cannot know that the .m files will never be built, it complains that you don't have an Objective-C compiler).

Ah, I haven't thought of that.

Series:

#5 lore raw

PATCH 2/2 pvg: add option to configure it out

In reply to Paolo Bonzini

... and also to require it (--enable-pvg). While at it, unify the dependency() call for pvg and metal, which simplifies the logic a bit.

Note that all other Apple frameworks are either required or always-present, therefore do not add them to the summary in the same way as PVG.

---
 meson.build                   |  8 +++++---
 hw/display/meson.build        |  4 ++--
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 14 insertions(+), 5 deletions(-)
meson.build +5 -3
index ad2c6b61930..ad8e7c1890e 100644
@@ -821,7 +821,6 @@ version_res = []
 coref = []
 iokit = []
 pvg = not_found
-metal = []
 emulator_link_args = []
 midl = not_found
 widl = not_found
@@ -843,8 +842,8 @@ elif host_os == 'darwin'
   coref = dependency('appleframeworks', modules: 'CoreFoundation')
   iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
   host_dsosuf = '.dylib'
-  pvg = dependency('appleframeworks', modules: 'ParavirtualizedGraphics')
-  metal = dependency('appleframeworks', modules: 'Metal')
+  pvg = dependency('appleframeworks', modules: ['ParavirtualizedGraphics', 'Metal'],
+                   required: get_option('pvg'))
 elif host_os == 'sunos'
   socket = [cc.find_library('socket'),
             cc.find_library('nsl'),
@@ -4846,6 +4847,9 @@ summary_info += {'libdw':             libdw}
 if host_os == 'freebsd'
   summary_info += {'libinotify-kqueue': inotify}
 endif
+if host_os == 'darwin'
+  summary_info += {'ParavirtualizedGraphics support': pvg}
+endif
 summary(summary_info, bool_yn: true, section: 'Dependencies')
 
 if host_arch == 'unknown'
hw/display/meson.build +2 -2
index b9bdf219103..9d82fbc9c89 100644
@@ -62,8 +62,8 @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c'))
 system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman])
 
 if pvg.found()
-  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx.m', 'apple-gfx-pci.m'), pvg, metal])
-  system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',    if_true: [files('apple-gfx.m', 'apple-gfx-mmio.m'), pvg, metal])
+  system_ss.add(when: 'CONFIG_MAC_PVG_PCI',     if_true: [files('apple-gfx.m', 'apple-gfx-pci.m'), pvg])
+  system_ss.add(when: 'CONFIG_MAC_PVG_MMIO',    if_true: [files('apple-gfx.m', 'apple-gfx-mmio.m'), pvg])
 endif
 
 if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
meson_options.txt +2 -0
index 5eeaf3eee5c..59d973bca00 100644
@@ -198,6 +198,8 @@ option('lzfse', type : 'feature', value : 'auto',
        description: 'lzfse support for DMG images')
 option('lzo', type : 'feature', value : 'auto',
        description: 'lzo compression support')
+option('pvg', type: 'feature', value: 'auto',
+       description: 'macOS paravirtualized graphics support')
 option('rbd', type : 'feature', value : 'auto',
        description: 'Ceph block device driver')
 option('opengl', type : 'feature', value : 'auto',
scripts/meson-buildoptions.sh +3 -0
index a8066aab037..3e8e00852b2 100644
@@ -168,6 +168,7 @@ meson_options_help() {
   printf "%s\n" '  pixman          pixman support'
   printf "%s\n" '  plugins         TCG plugins via shared library loading'
   printf "%s\n" '  png             PNG support with libpng'
+  printf "%s\n" '  pvg             macOS paravirtualized graphics support'
   printf "%s\n" '  qatzip          QATzip compression support'
   printf "%s\n" '  qcow1           qcow1 image format support'
   printf "%s\n" '  qed             qed image format support'
@@ -436,6 +437,8 @@ _meson_option_parse() {
     --enable-png) printf "%s" -Dpng=enabled ;;
     --disable-png) printf "%s" -Dpng=disabled ;;
     --prefix=*) quote_sh "-Dprefix=$2" ;;
+    --enable-pvg) printf "%s" -Dpvg=enabled ;;
+    --disable-pvg) printf "%s" -Dpvg=disabled ;;
     --enable-qatzip) printf "%s" -Dqatzip=enabled ;;
     --disable-qatzip) printf "%s" -Dqatzip=disabled ;;
     --enable-qcow1) printf "%s" -Dqcow1=enabled ;;
Signature · 1 line
2.48.1