xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Bandan Das" <bsd@redhat.com>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Sergio Lopez" <slp@redhat.com>,
	"Alexey Kardashevskiy" <aik@ozlabs.ru>,
	"Xiaojuan Yang" <yangxiaojuan@loongson.cn>,
	"Cameron Esfahani" <dirty@apple.com>,
	"Michael Rolnik" <mrolnik@gmail.com>,
	"Song Gao" <gaosong@loongson.cn>,
	"Jagannathan Raman" <jag.raman@oracle.com>,
	"Greg Kurz" <groug@kaod.org>,
	"Kamil Rytarowski" <kamil@netbsd.org>,
	"Peter Xu" <peterx@redhat.com>, "Joel Stanley" <joel@jms.id.au>,
	"Alistair Francis" <Alistair.Francis@wdc.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	haxm-team@intel.com, "Roman Bolshakov" <r.bolshakov@yadro.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	qemu-block@nongnu.org, "Eduardo Habkost" <eduardo@habkost.net>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	qemu-ppc@nongnu.org, "Cornelia Huck" <cohuck@redhat.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Helge Deller" <deller@gmx.de>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-riscv@nongnu.org, "Stafford Horne" <shorne@gmail.com>,
	"Paul Durrant" <paul@xen.org>,
	"Havard Skinnemoen" <hskinnemoen@google.com>,
	"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
	"Alexander Graf" <agraf@csgraf.de>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Wenchao Wang" <wenchao.wang@intel.com>,
	"Tony Krowiak" <akrowiak@linux.ibm.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	qemu-s390x@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Reinoud Zandijk" <reinoud@netbsd.org>,
	"Alexander Bulekov" <alxndr@bu.edu>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Tyrone Ting" <kfting@nuvoton.com>,
	xen-devel@lists.xenproject.org,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"John Snow" <jsnow@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Darren Kenny" <darren.kenny@oracle.com>,
	kvm@vger.kernel.org, "Qiuhao Li" <Qiuhao.Li@outlook.com>,
	"John G Johnson" <john.g.johnson@oracle.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Sunil Muthuswamy" <sunilmut@microsoft.com>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	qemu-arm@nongnu.org, "Marcelo Tosatti" <mtosatti@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Jason Herne" <jjherne@linux.ibm.com>,
	"Bernhard Beschow" <shentey@gmail.com>
Subject: [PATCH 0/9] Deprecate sysbus_get_default() and get_system_memory() et. al
Date: Tue, 20 Sep 2022 01:17:11 +0200	[thread overview]
Message-ID: <20220919231720.163121-1-shentey@gmail.com> (raw)

In address-spaces.h it can be read that get_system_memory() and
get_system_io() are temporary interfaces which "should only be used temporarily
until a proper bus interface is available". This statement certainly extends to
the address_space_memory and address_space_io singletons. This series attempts
to stop further proliferation of their use by turning TYPE_SYSTEM_BUS into an
object-oriented, "proper bus interface" inspired by PCIBus.

While at it, also the main_system_bus singleton is turned into an attribute of
MachineState. Together, this resolves five singletons in total, making the
ownership relations much more obvious which helps comprehension.

The series is structured as follows: Patch 1 fixes a memory corruption issue
uncovered by running `make check` on the last but one patch of this series.
Patches 2 and 3 turn the main_system_bus singleton into an attribute of
MachineState which provides an alternative to sysbus_get_default(). Patches 4-7
resolve the address space singletons and deprecate the legacy
get_system_memory() et. al functions. Patch 8 attempts to optimize the new
implementations of these legacy functions.

Testing done:
* make check (passes without any issues)
* make check-avocado (no new issues seem to be introduced compared to master)

Bernhard Beschow (9):
  hw/riscv/sifive_e: Fix inheritance of SiFiveEState
  exec/hwaddr.h: Add missing include
  hw/core/sysbus: Resolve main_system_bus singleton
  hw/ppc/spapr: Fix code style problems reported by checkpatch
  exec/address-spaces: Wrap address space singletons into functions
  target/loongarch/cpu: Remove unneeded include directive
  hw/sysbus: Introduce dedicated struct SysBusState for TYPE_SYSTEM_BUS
  softmmu/physmem: Let SysBusState absorb memory region and address
    space singletons
  exec/address-spaces: Inline legacy functions

 accel/hvf/hvf-accel-ops.c            |  2 +-
 accel/kvm/kvm-all.c                  | 12 +++----
 hw/alpha/dp264.c                     |  4 +--
 hw/alpha/typhoon.c                   |  4 +--
 hw/arm/smmu-common.c                 |  4 +--
 hw/arm/smmuv3.c                      | 14 ++++----
 hw/arm/virt.c                        |  2 +-
 hw/char/goldfish_tty.c               |  4 +--
 hw/core/bus.c                        |  5 ++-
 hw/core/loader.c                     |  2 +-
 hw/core/machine.c                    |  3 ++
 hw/core/sysbus.c                     | 24 ++++----------
 hw/dma/pl330.c                       |  2 +-
 hw/dma/rc4030.c                      |  2 +-
 hw/dma/xlnx-zynq-devcfg.c            |  4 +--
 hw/dma/xlnx_dpdma.c                  |  8 ++---
 hw/hppa/machine.c                    |  4 +--
 hw/hyperv/hyperv.c                   |  2 +-
 hw/hyperv/vmbus.c                    |  2 +-
 hw/i386/amd_iommu.c                  | 18 +++++-----
 hw/i386/fw_cfg.c                     |  2 +-
 hw/i386/intel_iommu.c                | 24 +++++++-------
 hw/i386/microvm.c                    |  4 +--
 hw/i386/pc.c                         |  2 +-
 hw/i386/xen/xen-hvm.c                |  4 +--
 hw/ide/ahci.c                        |  2 +-
 hw/ide/macio.c                       | 10 +++---
 hw/intc/apic.c                       |  2 +-
 hw/intc/openpic_kvm.c                |  2 +-
 hw/intc/pnv_xive.c                   |  6 ++--
 hw/intc/pnv_xive2.c                  |  6 ++--
 hw/intc/riscv_aplic.c                |  2 +-
 hw/intc/spapr_xive.c                 |  2 +-
 hw/intc/xive.c                       |  4 +--
 hw/intc/xive2.c                      |  4 +--
 hw/mips/jazz.c                       |  4 +--
 hw/misc/lasi.c                       |  2 +-
 hw/misc/macio/mac_dbdma.c            |  8 ++---
 hw/net/ftgmac100.c                   | 16 ++++-----
 hw/net/i82596.c                      | 24 +++++++-------
 hw/net/imx_fec.c                     | 22 ++++++-------
 hw/net/lasi_i82596.c                 |  2 +-
 hw/net/npcm7xx_emc.c                 | 14 ++++----
 hw/openrisc/boot.c                   |  2 +-
 hw/pci-host/dino.c                   |  6 ++--
 hw/pci-host/pnv_phb3.c               |  6 ++--
 hw/pci-host/pnv_phb3_msi.c           |  6 ++--
 hw/pci-host/pnv_phb4.c               | 10 +++---
 hw/pci/pci.c                         |  2 +-
 hw/ppc/pnv_psi.c                     |  2 +-
 hw/ppc/spapr.c                       |  4 +--
 hw/ppc/spapr_events.c                |  2 +-
 hw/ppc/spapr_hcall.c                 |  4 +--
 hw/ppc/spapr_iommu.c                 |  4 +--
 hw/ppc/spapr_ovec.c                  |  8 ++---
 hw/ppc/spapr_rtas.c                  |  2 +-
 hw/remote/iommu.c                    |  2 +-
 hw/remote/message.c                  |  4 +--
 hw/remote/proxy-memory-listener.c    |  2 +-
 hw/riscv/boot.c                      |  6 ++--
 hw/riscv/sifive_e.c                  |  2 +-
 hw/riscv/sifive_u.c                  |  2 +-
 hw/riscv/virt.c                      |  2 +-
 hw/s390x/css.c                       | 16 ++++-----
 hw/s390x/ipl.h                       |  2 +-
 hw/s390x/s390-pci-bus.c              |  4 +--
 hw/s390x/s390-pci-inst.c             | 10 +++---
 hw/s390x/s390-skeys.c                |  2 +-
 hw/s390x/virtio-ccw.c                | 10 +++---
 hw/sd/sdhci.c                        |  2 +-
 hw/sh4/r2d.c                         |  4 +--
 hw/sparc/sun4m.c                     |  2 +-
 hw/sparc/sun4m_iommu.c               |  4 +--
 hw/sparc64/sun4u_iommu.c             |  4 +--
 hw/timer/hpet.c                      |  2 +-
 hw/usb/hcd-ehci-pci.c                |  2 +-
 hw/usb/hcd-ehci-sysbus.c             |  2 +-
 hw/usb/hcd-ohci.c                    |  2 +-
 hw/usb/hcd-xhci-sysbus.c             |  2 +-
 hw/vfio/ap.c                         |  2 +-
 hw/vfio/ccw.c                        |  2 +-
 hw/vfio/common.c                     |  8 ++---
 hw/vfio/platform.c                   |  2 +-
 hw/virtio/vhost-vdpa.c               |  2 +-
 hw/virtio/vhost.c                    |  2 +-
 hw/virtio/virtio-bus.c               |  4 +--
 hw/virtio/virtio-iommu.c             |  6 ++--
 hw/virtio/virtio-pci.c               |  2 +-
 hw/xen/xen_pt.c                      |  4 +--
 include/exec/address-spaces.h        | 49 +++++++++++++++++++++++-----
 include/exec/hwaddr.h                |  1 +
 include/hw/boards.h                  |  2 ++
 include/hw/elf_ops.h                 |  4 +--
 include/hw/misc/macio/macio.h        |  2 +-
 include/hw/ppc/spapr.h               |  6 ++--
 include/hw/ppc/vof.h                 |  4 +--
 include/hw/riscv/sifive_e.h          |  3 +-
 include/hw/sysbus.h                  | 14 ++++++--
 monitor/misc.c                       |  4 +--
 softmmu/ioport.c                     | 12 +++----
 softmmu/memory_mapping.c             |  2 +-
 softmmu/physmem.c                    | 41 ++++++++---------------
 target/arm/hvf/hvf.c                 |  4 +--
 target/arm/kvm.c                     |  4 +--
 target/avr/helper.c                  |  8 ++---
 target/i386/hax/hax-all.c            |  2 +-
 target/i386/hax/hax-mem.c            |  2 +-
 target/i386/hvf/hvf.c                |  2 +-
 target/i386/hvf/vmx.h                |  2 +-
 target/i386/hvf/x86_mmu.c            |  6 ++--
 target/i386/nvmm/nvmm-all.c          |  4 +--
 target/i386/sev.c                    |  4 +--
 target/i386/tcg/sysemu/misc_helper.c | 12 +++----
 target/i386/whpx/whpx-all.c          |  4 +--
 target/loongarch/cpu.h               |  1 -
 target/s390x/diag.c                  |  2 +-
 target/s390x/mmu_helper.c            |  2 +-
 target/s390x/sigp.c                  |  2 +-
 target/xtensa/dbg_helper.c           |  2 +-
 tests/qtest/fuzz/generic_fuzz.c      |  4 +--
 120 files changed, 355 insertions(+), 328 deletions(-)

-- 
2.37.3



             reply	other threads:[~2022-09-19 23:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 23:17 Bernhard Beschow [this message]
2022-09-19 23:17 ` [PATCH 1/9] hw/riscv/sifive_e: Fix inheritance of SiFiveEState Bernhard Beschow
2022-09-19 23:31   ` Alistair Francis
2022-09-20 11:36     ` Markus Armbruster
2022-09-20 23:23       ` Bernhard Beschow
2022-09-21  4:55         ` Markus Armbruster
2022-09-22  7:55           ` B
2022-09-20  4:47   ` Philippe Mathieu-Daudé
2022-09-19 23:17 ` [PATCH 2/9] exec/hwaddr.h: Add missing include Bernhard Beschow
2022-09-20  4:50   ` Philippe Mathieu-Daudé
2022-09-20 23:03     ` Bernhard Beschow
2022-09-19 23:17 ` [PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton Bernhard Beschow
2022-09-20  4:52   ` Philippe Mathieu-Daudé
2022-09-19 23:17 ` [PATCH 4/9] hw/ppc/spapr: Fix code style problems reported by checkpatch Bernhard Beschow
2022-09-20 14:00   ` Daniel Henrique Barboza
2022-09-19 23:17 ` [PATCH 5/9] exec/address-spaces: Wrap address space singletons into functions Bernhard Beschow
2022-09-20  5:36   ` Philippe Mathieu-Daudé
2022-09-19 23:17 ` [PATCH 6/9] target/loongarch/cpu: Remove unneeded include directive Bernhard Beschow
2022-09-20  4:57   ` Philippe Mathieu-Daudé
2022-09-19 23:17 ` [PATCH 7/9] hw/sysbus: Introduce dedicated struct SysBusState for TYPE_SYSTEM_BUS Bernhard Beschow
2022-09-19 23:17 ` [PATCH 8/9] softmmu/physmem: Let SysBusState absorb memory region and address space singletons Bernhard Beschow
2022-09-20  5:11   ` Philippe Mathieu-Daudé
2022-09-20  8:50     ` BALATON Zoltan
2022-09-20 23:13       ` Bernhard Beschow
2022-09-19 23:17 ` [PATCH 9/9] exec/address-spaces: Inline legacy functions Bernhard Beschow
2022-09-20  5:15   ` Philippe Mathieu-Daudé
2022-09-20  5:29     ` Philippe Mathieu-Daudé
2022-09-20  9:02     ` BALATON Zoltan
2022-09-20 23:20       ` Bernhard Beschow
2022-09-20  9:55 ` [PATCH 0/9] Deprecate sysbus_get_default() and get_system_memory() et. al Peter Maydell
2022-09-20 15:36   ` Mark Cave-Ayland
2022-09-20 22:59     ` Bernhard Beschow
2022-09-20 22:50   ` Bernhard Beschow
2022-09-21  9:47     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220919231720.163121-1-shentey@gmail.com \
    --to=shentey@gmail.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=Qiuhao.Li@outlook.com \
    --cc=agraf@csgraf.de \
    --cc=aik@ozlabs.ru \
    --cc=akrowiak@linux.ibm.com \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=alex.williamson@redhat.com \
    --cc=alistair@alistair23.me \
    --cc=alxndr@bu.edu \
    --cc=andrew@aj.id.au \
    --cc=anthony.perard@citrix.com \
    --cc=armbru@redhat.com \
    --cc=atar4qemu@gmail.com \
    --cc=berrange@redhat.com \
    --cc=bin.meng@windriver.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=bsd@redhat.com \
    --cc=clg@kaod.org \
    --cc=cohuck@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=darren.kenny@oracle.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=deller@gmx.de \
    --cc=dgilbert@redhat.com \
    --cc=dirty@apple.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=elena.ufimtseva@oracle.com \
    --cc=eric.auger@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=farman@linux.ibm.com \
    --cc=gaosong@loongson.cn \
    --cc=groug@kaod.org \
    --cc=haxm-team@intel.com \
    --cc=hpoussin@reactos.org \
    --cc=hskinnemoen@google.com \
    --cc=jag.raman@oracle.com \
    --cc=jasowang@redhat.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jjherne@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=john.g.johnson@oracle.com \
    --cc=jsnow@redhat.com \
    --cc=kamil@netbsd.org \
    --cc=kfting@nuvoton.com \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=laurent@vivier.eu \
    --cc=maciej.szmigiero@oracle.com \
    --cc=magnus.damm@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mjrosato@linux.ibm.com \
    --cc=mrolnik@gmail.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pasic@linux.ibm.com \
    --cc=paul@xen.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    --cc=reinoud@netbsd.org \
    --cc=richard.henderson@linaro.org \
    --cc=shorne@gmail.com \
    --cc=slp@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanha@redhat.com \
    --cc=sunilmut@microsoft.com \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.com \
    --cc=wenchao.wang@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yangxiaojuan@loongson.cn \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).