This patch series was spun off from "[PATCH v2 00/15] Fix memory region leaks and use-after-finalization": https://lore.kernel.org/qemu-devel/[email protected]/
It is a common requirement of qdev to delete memory subregions to hide them from address spaces during unrealization. pci automatically deletes the IO subregions, but this process is manually implemented in other places, which is tedious and error-prone. Implement the logic to delete subregions in qdev to cover all devices. Note that some code removed in this series to delete subregions are apparently just unnecessary and can be removed without a change of qdev. They are still included in this series and follows the qdev change since removing them without the qdev change will cause regression if I fail to distinguish necessary and unnecessary code. Signed-off-by: Akihiko Odaki <[email protected]> --- Changes in v2: - Dropped patch "hw/pci-bridge: Do not assume immediate MemoryRegion finalization" as it was unnecessary as pointed out by Peter Xu. - Dropped patch "[PATCH] vfio-user: Do not delete the subregion". It is a fix unlike the other patches so I submitted it separately. - Expanded the patch message of "qdev: Automatically delete memory subregions" to explain that existing memory_region_del_subregion() calls in the device-specific code will be no-op. - Link to v1: https://lore.kernel.org/qemu-devel/[email protected] --- Akihiko Odaki (12): qdev: Automatically delete memory subregions hw/char/diva-gsp: Do not delete the subregion hw/char/serial-pci-multi: Do not delete the subregion secondary-vga: Do not delete the subregions cmd646: Do not delete the subregions hw/ide/piix: Do not delete the subregions hw/ide/via: Do not delete the subregions hw/nvme: Do not delete the subregion pci: Do not delete the subregions hw/ppc/spapr_pci: Do not delete the subregions hw/usb/hcd-ehci: Do not delete the subregions hw/usb/hcd-xhci: Do not delete the subregions MAINTAINERS | 1 + include/hw/qdev-core.h | 1 + hw/char/diva-gsp.c | 1 - hw/char/serial-pci-multi.c | 1 - hw/core/qdev.c | 14 ++++++++++++++ hw/display/vga-pci.c | 8 -------- hw/ide/cmd646.c | 12 ------------ hw/ide/piix.c | 13 ------------- hw/ide/via.c | 12 ------------ hw/nvme/ctrl.c | 2 -- hw/pci/pci.c | 20 -------------------- hw/ppc/spapr_pci.c | 22 ---------------------- hw/usb/hcd-ehci.c | 4 ---- hw/usb/hcd-xhci.c | 10 ---------- stubs/memory.c | 9 +++++++++ stubs/meson.build | 1 + 16 files changed, 26 insertions(+), 105 deletions(-) --- base-commit: 94474a7733a57365d5a27efc28c05462e90e8944 change-id: 20250917-subregion-907ced7da1ed Best regards, -- Akihiko Odaki <[email protected]>
