hw/vfio: Build various objects once
Subsystems (2)
v3 cover hw/vfio: Build various objects once
Hi Cédric,
Here are the VFIO cleanup patches ready enough for 10.0, with Richard and Eric comments from v2 addressed.
I'd prefer the rest (of v2) to wait for 10.1.
Thanks,
Phil.
Philippe Mathieu-Daudé (8):
system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' hw/vfio/spapr: Do not include <linux/kvm.h> hw/vfio/common: Include missing 'system/tcg.h' header hw/vfio/common: Get target page size using runtime helpers hw/vfio: Compile some common objects once
hw/vfio: Compile more objects once
hw/vfio: Compile iommufd.c once
hw/vfio: Compile display.c once
include/exec/ram_addr.h | 3 --- include/system/hostmem.h | 3 +++ hw/ppc/spapr_caps.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + hw/vfio/common.c | 9 ++++++--- hw/vfio/iommufd.c | 1 - hw/vfio/migration.c | 1 - hw/vfio/spapr.c | 4 +--- hw/vfio/meson.build | 27 ++++++++++++++++----------- 9 files changed, 28 insertions(+), 22 deletions(-)
Signature · 1 line
2.47.1
PATCH v3 1/8 system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
Both qemu_minrampagesize() and qemu_maxrampagesize() are related to host memory backends, having the following call stack:
qemu_minrampagesize()
-> find_min_backend_pagesize()
-> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND) qemu_maxrampagesize()
-> find_max_backend_pagesize()
-> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)Having TYPE_MEMORY_BACKEND defined in "system/hostmem.h":
include/system/hostmem.h:23:#define TYPE_MEMORY_BACKEND "memory-backend"
Move their prototype declaration to "system/hostmem.h".
Message-Id: <[email protected]>
--- include/exec/ram_addr.h | 3 --- include/system/hostmem.h | 3 +++ hw/ppc/spapr_caps.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + hw/vfio/spapr.c | 1 + 5 files changed, 6 insertions(+), 3 deletions(-)
include/exec/ram_addr.h +0 -3
@@ -102,9 +102,6 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,bool ramblock_is_pmem (RAMBlock *rb); -long qemu_minrampagesize (void ); -long qemu_maxrampagesize (void ); -/** * qemu_ram_alloc_from_file, * qemu_ram_alloc_from_fd: Allocate a ram block from the specified backing
include/system/hostmem.h +3 -0
@@ -93,4 +93,7 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend);size_t host_memory_backend_pagesize (HostMemoryBackend *memdev);char *host_memory_backend_get_name (HostMemoryBackend *backend); +long qemu_minrampagesize (void ); +long qemu_maxrampagesize (void ); +#endif
hw/ppc/spapr_caps.c +1 -0
@@ -34,6 +34,7 @@#include "kvm_ppc.h" #include "migration/vmstate.h" #include "system/tcg.h" +#include "system/hostmem.h" #include "hw/ppc/spapr.h"
hw/s390x/s390-virtio-ccw.c +1 -0
@@ -41,6 +41,7 @@#include "hw/s390x/tod.h" #include "system/system.h" #include "system/cpus.h" +#include "system/hostmem.h" #include "target/s390x/kvm/pv.h" #include "migration/blocker.h" #include "qapi/visitor.h"
hw/vfio/spapr.c +1 -0
@@ -15,6 +15,7 @@#include <linux/kvm.h> #endif #include "system/kvm.h" +#include "system/hostmem.h" #include "exec/address-spaces.h" #include "hw/vfio/vfio-common.h"
Signature · 1 line
2.47.1
Re: [PATCH-for-10.0 v3 1/8] system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h'
Quoted 16 lines · Philippe Mathieu-Daudé
Both
qemu_minrampagesize()andqemu_maxrampagesize()are related to host memory backends, having the following call stack:qemu_minrampagesize() -> find_min_backend_pagesize() -> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND) qemu_maxrampagesize() -> find_max_backend_pagesize() -> object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)Having
TYPE_MEMORY_BACKENDdefined in "system/hostmem.h":include/system/hostmem.h:23:#define
TYPE_MEMORY_BACKEND"memory-backend"
Quoted 7 lines
Move their prototype declaration to "
system/hostmem.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Pierrick Bouvier <[email protected]>Reviewed-by Eric Auger <[email protected]>Message-Id: <[email protected]>
---
Signature · 3 lines
Cheers, David / dhildenb
PATCH v3 2/8 hw/vfio/spapr: Do not include <linux/kvm.h>
In reply to Philippe Mathieu-Daudé<linux/kvm.h> is already included by "system/kvm.h" in the next line.
Message-Id: <[email protected]>
--- hw/vfio/spapr.c | 3 --- 1 file changed, 3 deletions(-)
hw/vfio/spapr.c +0 -3
@@ -11,9 +11,6 @@#include "qemu/osdep.h" #include <sys/ioctl.h> #include <linux/vfio.h> -#ifdef CONFIG_KVM -#include <linux/kvm.h> -#endif #include "system/kvm.h" #include "system/hostmem.h" #include "exec/address-spaces.h"
Signature · 1 line
2.47.1
PATCH v3 3/8 hw/vfio/common: Include missing 'system/tcg.h' header
In reply to Philippe Mathieu-DaudéAlways include necessary headers explicitly, to avoid when refactoring unrelated ones:
hw/vfio/common.c:1176:45: error: implicit declaration of function ‘tcg_enabled’;
1176 | tcg_enabled() ? DIRTY_CLIENTS_ALL :
| ^~~~~~~~~~~Message-Id: <[email protected]>
--- hw/vfio/common.c | 1 + 1 file changed, 1 insertion(+)
hw/vfio/common.c +1 -0
@@ -42,6 +42,7 @@#include "migration/misc.h" #include "migration/blocker.h" #include "migration/qemu-file.h" +#include "system/tcg.h" #include "system/tpm.h" VFIODeviceList vfio_device_list =
Signature · 1 line
2.47.1
PATCH v3 4/8 hw/vfio/common: Get target page size using runtime helpers
In reply to Philippe Mathieu-DaudéPrefer runtime helpers to get target page size.
Message-Id: <[email protected]>
--- hw/vfio/common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/vfio/common.c +5 -3
@@ -30,6 +30,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "exec/target_page.h" #include "hw/hw.h" #include "qemu/error-report.h" #include "qemu/main-loop.h"
@@ -393,13 +394,14 @@ static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer, MemoryRegionSection *section) {RamDiscardManager *rdm =memory_region_get_ram_discard_manager (section->mr); +int target_page_size =qemu_target_page_size ();VFIORamDiscardListener *vrdl;/* Ignore some corner cases not relevant in practice. */ -g_assert (QEMU_IS_ALIGNED (section->offset_within_region,TARGET_PAGE_SIZE )); +g_assert (QEMU_IS_ALIGNED (section->offset_within_region, target_page_size));g_assert (QEMU_IS_ALIGNED (section->offset_within_address_space, -TARGET_PAGE_SIZE )); -g_assert (QEMU_IS_ALIGNED (int128_get64 (section->size),TARGET_PAGE_SIZE )); + target_page_size)); +g_assert (QEMU_IS_ALIGNED (int128_get64 (section->size), target_page_size)); vrdl =g_new0 (VFIORamDiscardListener,1 ); vrdl->bcontainer = bcontainer;
Signature · 1 line
2.47.1
PATCH v3 5/8 hw/vfio: Compile some common objects once
In reply to Philippe Mathieu-DaudéSome files don't rely on any target-specific knowledge and can be compiled once:
- helpers.c
- container-base.c
- migration.c (removing unnecessary "exec/ram_addr.h")
- migration-multifd.c
- cpr.c
Message-Id: <[email protected]>
--- hw/vfio/migration.c | 1 - hw/vfio/meson.build | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)
hw/vfio/migration.c +0 -1
@@ -27,7 +27,6 @@#include "qapi/error.h" #include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" -#include "exec/ram_addr.h" #include "pci.h" #include "trace.h" #include "hw/hw.h"
hw/vfio/meson.build +8 -5
@@ -1,12 +1,7 @@ vfio_ss = ss.source_set() vfio_ss.add(files( - 'helpers.c', 'common.c', - 'container-base.c', 'container.c', - 'migration.c', - 'migration-multifd.c', - 'cpr.c', )) vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c')) vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files(
@@ -25,3 +20,11 @@ vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c')) vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c')) specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) + +system_ss.add(when: 'CONFIG_VFIO', if_true: files( + 'helpers.c', + 'container-base.c', + 'migration.c', + 'migration-multifd.c', + 'cpr.c', +))
Signature · 1 line
2.47.1
PATCH v3 6/8 hw/vfio: Compile more objects once
In reply to Philippe Mathieu-DaudéThese files depend on the VFIO symbol in their Kconfig definition. They don't rely on target specific definitions, move them to system_ss[] to build them once.
Message-Id: <[email protected]>
--- hw/vfio/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/vfio/meson.build +2 -2
@@ -14,13 +14,13 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( )) vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c')) vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c')) -vfio_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c')) -vfio_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c')) vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c')) specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) +system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c')) +system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) system_ss.add(when: 'CONFIG_VFIO', if_true: files( 'helpers.c', 'container-base.c',
Signature · 1 line
2.47.1
PATCH v3 7/8 hw/vfio: Compile iommufd.c once
In reply to Philippe Mathieu-DaudéRemoving unused "exec/ram_addr.h" header allow to compile iommufd.c once for all targets.
Message-Id: <[email protected]>
--- hw/vfio/iommufd.c | 1 - hw/vfio/meson.build | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-)
hw/vfio/iommufd.c +0 -1
@@ -25,7 +25,6 @@#include "qemu/cutils.h" #include "qemu/chardev_open.h" #include "pci.h" -#include "exec/ram_addr.h" static int iommufd_cdev_map (const VFIOContainerBase *bcontainer,hwaddr iova,ram_addr_t size,void *vaddr,bool readonly)
hw/vfio/meson.build +3 -3
@@ -4,9 +4,6 @@ vfio_ss.add(files( 'container.c', )) vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c')) -vfio_ss.add(when: 'CONFIG_IOMMUFD', if_true: files( - 'iommufd.c', -)) vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( 'display.c', 'pci-quirks.c',
@@ -28,3 +25,6 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files( 'migration-multifd.c', 'cpr.c', )) +system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( + 'iommufd.c', +))
Signature · 1 line
2.47.1
PATCH v3 8/8 hw/vfio: Compile display.c once
In reply to Philippe Mathieu-Daudédisplay.c doesn't rely on target specific definitions, move it to system_ss[] to build it once.
Message-Id: <[email protected]>
--- hw/vfio/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/vfio/meson.build +3 -1
@@ -5,7 +5,6 @@ vfio_ss.add(files( )) vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c')) vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( - 'display.c', 'pci-quirks.c', 'pci.c', ))
@@ -28,3 +27,6 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files( system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files( 'iommufd.c', )) +system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( + 'display.c', +))
Signature · 1 line
2.47.1
Quoted 4 lines · Philippe Mathieu-Daudé
Hi Cédric,
Here are the VFIO cleanup patches ready enough for 10.0, with Richard and Eric comments from v2 addressed.
I dropped the previously applied patches from the v2 series and applied this v3 in vfio-next instead.
Quoted 1 line
I'd prefer the rest (of v2) to wait for 10.1.
yes.
Thanks,
C.
Quoted 25 lines
Thanks,
Phil.
Philippe Mathieu-Daudé (8):
system: Declare qemu_[min/max]rampagesize() in 'system/hostmem.h' hw/vfio/spapr: Do not include <linux/kvm.h> hw/vfio/common: Include missing 'system/tcg.h' header hw/vfio/common: Get target page size using runtime helpers hw/vfio: Compile some common objects once
hw/vfio: Compile more objects once
hw/vfio: Compileiommufd.conce
hw/vfio: Compiledisplay.conceinclude/exec/ram_addr.h | 3 --- include/system/hostmem.h | 3 +++ hw/ppc/spapr_caps.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + hw/vfio/common.c | 9 ++++++--- hw/vfio/iommufd.c | 1 - hw/vfio/migration.c | 1 - hw/vfio/spapr.c | 4 +--- hw/vfio/meson.build | 27 ++++++++++++++++----------- 9 files changed, 28 insertions(+), 22 deletions(-)