All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu)
@ 2021-05-17 11:11 Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 01/11] NOTFORMERGE target/arm: Restrict KVM files to softmmu Philippe Mathieu-Daudé
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

Hi,

This series restricts various system emulation specific headers
by moving them under sysemu/ and adding #error if included from
user emulation.
We could avoid the sysemu/ rename if too much churn, but enforcing
error of headers that must not be included in user emulation allows
further cleanups (to be sent later).

I had to split the ioport.c file to cpu-io (generic to any target
having access to I/O bus, but I haven't checked the TCG implementation
details for user emulation) VS ioport (system specific, access to
hardware).

Many files are changed, but this is mostly one-line mechanical
updates of old path to new path using sed.

Regards,

Phil.

Philippe Mathieu-Daudé (11):
  NOTFORMERGE target/arm: Restrict KVM files to softmmu
  exec: Restrict hwaddr.h to sysemu/
  exec: Restrict cputlb.h to sysemu/
  exec: Restrict memory.h to sysemu/
  exec: Restrict memory-internal.h to sysemu/
  exec: Restrict address-spaces.h to sysemu/
  exec: Extract CPU I/O instructions to "cpu-io.h"
  exec: Restrict ioport.h to sysemu/
  exec: Restrict ram_addr.h to sysemu/
  exec: Restrict ramblock.h to sysemu/
  exec: Restrict confidential-guest-support.h to sysemu/

 docs/devel/memory.rst                         |  2 +-
 hw/arm/strongarm.h                            |  2 +-
 hw/audio/lm4549.h                             |  2 +-
 hw/display/framebuffer.h                      |  2 +-
 hw/display/vga_int.h                          |  4 +-
 hw/net/can/can_sja1000.h                      |  2 +-
 hw/net/can/ctucan_core.h                      |  2 +-
 hw/net/i82596.h                               |  4 +-
 hw/net/net_tx_pkt.h                           |  2 +-
 hw/net/pcnet.h                                |  2 +-
 hw/ppc/mac.h                                  |  2 +-
 hw/s390x/ipl.h                                |  2 +-
 hw/tpm/tpm_ppi.h                              |  2 +-
 hw/usb/hcd-uhci.h                             |  2 +-
 hw/vfio/pci.h                                 |  2 +-
 include/disas/disas.h                         |  4 +-
 include/exec/cpu-all.h                        |  6 +-
 include/exec/cpu-common.h                     |  2 +-
 include/exec/cpu-defs.h                       |  2 +-
 include/exec/cpu-io.h                         | 30 +++++++
 include/exec/{ => sysemu}/address-spaces.h    | 14 +--
 include/exec/{ => sysemu}/cputlb.h            | 11 ++-
 include/exec/{ => sysemu}/hwaddr.h            |  7 +-
 include/exec/{ => sysemu}/memory-internal.h   |  7 +-
 include/exec/{ => sysemu}/memory.h            |  8 +-
 include/hw/acpi/acpi.h                        |  2 +-
 include/hw/acpi/tco.h                         |  2 +-
 include/hw/arm/fsl-imx25.h                    |  2 +-
 include/hw/arm/fsl-imx31.h                    |  2 +-
 include/hw/arm/fsl-imx6.h                     |  2 +-
 include/hw/arm/fsl-imx6ul.h                   |  2 +-
 include/hw/arm/omap.h                         |  2 +-
 include/hw/arm/pxa.h                          |  2 +-
 include/hw/arm/sharpsl.h                      |  2 +-
 include/hw/arm/soc_dma.h                      |  2 +-
 include/hw/arm/sysbus-fdt.h                   |  2 +-
 include/hw/arm/virt.h                         |  2 +-
 include/hw/block/block.h                      |  2 +-
 include/hw/block/fdc.h                        |  2 +-
 include/hw/block/flash.h                      |  2 +-
 include/hw/boards.h                           |  2 +-
 include/hw/char/riscv_htif.h                  |  2 +-
 include/hw/char/serial.h                      |  2 +-
 include/hw/core/cpu.h                         |  4 +-
 include/hw/cris/etraxfs_dma.h                 |  2 +-
 include/hw/display/macfb.h                    |  2 +-
 include/hw/display/vga.h                      |  2 +-
 include/hw/dma/i8257.h                        |  2 +-
 include/hw/gpio/npcm7xx_gpio.h                |  2 +-
 include/hw/i2c/npcm7xx_smbus.h                |  2 +-
 include/hw/i2c/pm_smbus.h                     |  2 +-
 include/hw/i386/apic_internal.h               |  2 +-
 include/hw/i386/ioapic_internal.h             |  2 +-
 include/hw/i386/microvm.h                     |  2 +-
 include/hw/i386/x86.h                         |  2 +-
 include/hw/ide.h                              |  2 +-
 include/hw/input/lasips2.h                    |  2 +-
 include/hw/ipmi/ipmi.h                        |  2 +-
 include/hw/isa/apm.h                          |  2 +-
 include/hw/isa/isa.h                          |  4 +-
 include/hw/loader-fit.h                       |  2 +-
 include/hw/mem/npcm7xx_mc.h                   |  2 +-
 include/hw/mem/pc-dimm.h                      |  2 +-
 include/hw/mips/mips.h                        |  2 +-
 include/hw/misc/allwinner-h3-dramc.h          |  2 +-
 include/hw/misc/auxbus.h                      |  2 +-
 include/hw/misc/empty_slot.h                  |  2 +-
 include/hw/misc/mac_via.h                     |  2 +-
 include/hw/misc/mos6522.h                     |  2 +-
 include/hw/misc/npcm7xx_clk.h                 |  2 +-
 include/hw/misc/npcm7xx_gcr.h                 |  2 +-
 include/hw/misc/npcm7xx_mft.h                 |  2 +-
 include/hw/net/msf2-emac.h                    |  2 +-
 include/hw/nubus/nubus.h                      |  2 +-
 include/hw/nvram/fw_cfg.h                     |  2 +-
 include/hw/nvram/npcm7xx_otp.h                |  2 +-
 include/hw/pci-host/gpex.h                    |  2 +-
 include/hw/pci-host/pam.h                     |  2 +-
 include/hw/pci-host/remote.h                  |  2 +-
 include/hw/pci/pci.h                          |  2 +-
 include/hw/pci/pcie_host.h                    |  2 +-
 include/hw/pci/shpc.h                         |  2 +-
 include/hw/ppc/mac_dbdma.h                    |  2 +-
 include/hw/ppc/ppc4xx.h                       |  2 +-
 include/hw/ppc/xics.h                         |  2 +-
 include/hw/register.h                         |  2 +-
 include/hw/remote/memory.h                    |  2 +-
 include/hw/remote/mpqemu-link.h               |  2 +-
 include/hw/remote/proxy-memory-listener.h     |  2 +-
 include/hw/rtc/m48t59.h                       |  2 +-
 include/hw/rtc/sun4v-rtc.h                    |  2 +-
 include/hw/sh4/sh_intc.h                      |  2 +-
 include/hw/sysbus.h                           |  2 +-
 include/hw/timer/npcm7xx_timer.h              |  2 +-
 include/hw/timer/tmu012.h                     |  2 +-
 include/hw/tricore/triboard.h                 |  2 +-
 include/hw/tricore/tricore.h                  |  2 +-
 include/hw/usb.h                              |  2 +-
 include/hw/vfio/vfio-common.h                 |  2 +-
 include/hw/virtio/vhost-backend.h             |  2 +-
 include/hw/virtio/vhost.h                     |  2 +-
 include/hw/virtio/virtio-access.h             |  2 +-
 include/hw/virtio/virtio.h                    |  2 +-
 include/hw/xtensa/mx_pic.h                    |  2 +-
 include/monitor/monitor.h                     |  2 +-
 include/qemu/accel.h                          |  4 +-
 include/qemu/iova-tree.h                      |  4 +-
 include/qemu/userfaultfd.h                    |  2 +-
 .../confidential-guest-support.h              |  6 +-
 include/sysemu/dma.h                          |  4 +-
 include/sysemu/hostmem.h                      |  2 +-
 include/{exec => sysemu}/ioport.h             | 19 ++--
 include/sysemu/kvm_int.h                      |  2 +-
 include/sysemu/memory_mapping.h               |  2 +-
 include/{exec => sysemu}/ram_addr.h           | 13 +--
 include/{exec => sysemu}/ramblock.h           | 13 +--
 include/sysemu/vhost-user-backend.h           |  2 +-
 target/arm/kvm_arm.h                          |  2 +-
 target/i386/hvf/vmx.h                         |  2 +-
 accel/kvm/kvm-all.c                           |  4 +-
 accel/tcg/cputlb.c                            |  8 +-
 accel/tcg/translate-all.c                     |  8 +-
 backends/confidential-guest-support.c         |  2 +-
 backends/tpm/tpm_util.c                       |  2 +-
 cpu.c                                         |  2 +-
 dump/dump.c                                   |  2 +-
 dump/win_dump.c                               |  2 +-
 hw/arm/collie.c                               |  2 +-
 hw/arm/exynos4_boards.c                       |  2 +-
 hw/arm/fsl-imx31.c                            |  2 +-
 hw/arm/gumstix.c                              |  2 +-
 hw/arm/integratorcp.c                         |  2 +-
 hw/arm/kzm.c                                  |  2 +-
 hw/arm/mainstone.c                            |  2 +-
 hw/arm/microbit.c                             |  2 +-
 hw/arm/mps2-tz.c                              |  2 +-
 hw/arm/mps2.c                                 |  2 +-
 hw/arm/msf2-soc.c                             |  2 +-
 hw/arm/msf2-som.c                             |  2 +-
 hw/arm/musca.c                                |  2 +-
 hw/arm/omap1.c                                |  2 +-
 hw/arm/omap2.c                                |  2 +-
 hw/arm/omap_sx1.c                             |  2 +-
 hw/arm/orangepi.c                             |  2 +-
 hw/arm/sbsa-ref.c                             |  2 +-
 hw/arm/spitz.c                                |  2 +-
 hw/arm/stellaris.c                            |  2 +-
 hw/arm/stm32f205_soc.c                        |  2 +-
 hw/arm/stm32f405_soc.c                        |  2 +-
 hw/arm/tosa.c                                 |  2 +-
 hw/arm/z2.c                                   |  2 +-
 hw/avr/atmega.c                               |  4 +-
 hw/block/nvme.c                               |  2 +-
 hw/block/onenand.c                            |  2 +-
 hw/char/goldfish_tty.c                        |  2 +-
 hw/char/omap_uart.c                           |  2 +-
 hw/core/loader-fit.c                          |  2 +-
 hw/core/loader.c                              |  2 +-
 hw/core/machine.c                             |  2 +-
 hw/core/null-machine.c                        |  2 +-
 hw/core/sysbus.c                              |  2 +-
 hw/display/edid-region.c                      |  2 +-
 hw/display/tc6393xb.c                         |  2 +-
 hw/dma/etraxfs_dma.c                          |  2 +-
 hw/dma/rc4030.c                               |  2 +-
 hw/hyperv/hyperv.c                            |  2 +-
 hw/i386/acpi-common.c                         |  2 +-
 hw/i386/acpi-microvm.c                        |  2 +-
 hw/i386/pc.c                                  |  2 +-
 hw/i386/pc_piix.c                             |  2 +-
 hw/i386/xen/xen-hvm.c                         |  1 +
 hw/input/lasips2.c                            |  4 +-
 hw/intc/mips_gic.c                            |  2 +-
 hw/intc/ompic.c                               |  2 +-
 hw/m68k/next-cube.c                           |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c           |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c      |  2 +-
 hw/microblaze/xlnx-zynqmp-pmu.c               |  2 +-
 hw/misc/allwinner-h3-dramc.c                  |  2 +-
 hw/misc/omap_gpmc.c                           |  4 +-
 hw/net/ne2000.c                               |  2 +-
 hw/nios2/10m50_devboard.c                     |  4 +-
 hw/nios2/generic_nommu.c                      |  4 +-
 hw/pci-bridge/pci_bridge_dev.c                |  2 +-
 hw/pci-host/mv64361.c                         |  2 +-
 hw/pci-host/remote.c                          |  2 +-
 hw/ppc/pef.c                                  |  2 +-
 hw/ppc/pegasos2.c                             |  2 +-
 hw/ppc/pnv_homer.c                            |  4 +-
 hw/ppc/ppc405_uc.c                            |  2 +-
 hw/ppc/ppc440_uc.c                            |  2 +-
 hw/ppc/ppc4xx_devs.c                          |  2 +-
 hw/ppc/prep_systemio.c                        |  2 +-
 hw/ppc/rs6000_mc.c                            |  2 +-
 hw/ppc/sam460ex.c                             |  2 +-
 hw/ppc/spapr.c                                |  2 +-
 hw/ppc/spapr_caps.c                           |  2 +-
 hw/ppc/spapr_ovec.c                           |  2 +-
 hw/ppc/spapr_pci.c                            |  2 +-
 hw/remote/machine.c                           |  2 +-
 hw/remote/memory.c                            |  2 +-
 hw/remote/proxy-memory-listener.c             |  4 +-
 hw/riscv/shakti_c.c                           |  2 +-
 hw/s390x/css.c                                |  2 +-
 hw/s390x/pv.c                                 |  2 +-
 hw/s390x/s390-pci-inst.c                      |  2 +-
 hw/s390x/s390-stattrib-kvm.c                  |  2 +-
 hw/s390x/s390-stattrib.c                      |  2 +-
 hw/s390x/s390-virtio-ccw.c                    |  2 +-
 hw/sparc/sun4m_iommu.c                        |  2 +-
 hw/sparc64/sun4u_iommu.c                      |  2 +-
 hw/timer/hpet.c                               |  2 +-
 hw/timer/sh_timer.c                           |  2 +-
 hw/vfio/ap.c                                  |  2 +-
 hw/vfio/ccw.c                                 |  2 +-
 hw/vfio/common.c                              |  6 +-
 hw/vfio/migration.c                           |  2 +-
 hw/vfio/platform.c                            |  4 +-
 hw/vfio/spapr.c                               |  2 +-
 hw/virtio/virtio-balloon.c                    |  2 +-
 hw/virtio/virtio-bus.c                        |  2 +-
 hw/virtio/virtio-mem.c                        |  2 +-
 hw/xtensa/sim.c                               |  2 +-
 hw/xtensa/virt.c                              |  2 +-
 hw/xtensa/xtensa_memory.c                     |  2 +-
 hw/xtensa/xtfpga.c                            |  2 +-
 migration/dirtyrate.c                         |  2 +-
 migration/multifd.c                           |  2 +-
 migration/postcopy-ram.c                      |  2 +-
 migration/ram.c                               |  2 +-
 migration/rdma.c                              |  2 +-
 migration/savevm.c                            |  2 +-
 monitor/misc.c                                |  4 +-
 plugins/api.c                                 |  2 +-
 semihosting/arm-compat-semi.c                 |  2 +-
 softmmu/cpu-io.c                              | 88 +++++++++++++++++++
 softmmu/ioport.c                              | 66 +-------------
 softmmu/memory.c                              |  6 +-
 softmmu/memory_mapping.c                      |  4 +-
 softmmu/physmem.c                             |  8 +-
 softmmu/qtest.c                               |  5 +-
 softmmu/vl.c                                  |  2 +-
 stubs/ram-block.c                             |  2 +-
 target/arm/cpu.c                              |  2 +-
 target/arm/cpu64.c                            |  2 +-
 target/arm/kvm.c                              |  2 +-
 target/arm/mte_helper.c                       |  2 +-
 target/avr/helper.c                           |  2 +-
 target/i386/cpu-sysemu.c                      |  2 +-
 target/i386/cpu.c                             |  2 +-
 target/i386/hax/hax-all.c                     |  2 +-
 target/i386/hax/hax-mem.c                     |  2 +-
 target/i386/nvmm/nvmm-all.c                   |  4 +-
 target/i386/sev.c                             |  2 +-
 target/i386/tcg/sysemu/misc_helper.c          |  2 +-
 target/i386/tcg/sysemu/tcg-cpu.c              |  2 +-
 target/i386/whpx/whpx-all.c                   |  4 +-
 target/ppc/kvm.c                              |  2 +-
 target/s390x/excp_helper.c                    |  2 +-
 target/s390x/kvm.c                            |  2 +-
 target/s390x/misc_helper.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 +-
 tests/qtest/fuzz/qos_fuzz.c                   |  2 +-
 tests/qtest/fuzz/qtest_wrappers.c             |  3 +-
 tests/qtest/microbit-test.c                   |  2 +-
 ui/console.c                                  |  2 +-
 util/vfio-helpers.c                           |  2 +-
 MAINTAINERS                                   | 12 +--
 scripts/analyze-inclusions                    |  2 +-
 .../codeconverter/test_regexps.py             |  4 +-
 softmmu/meson.build                           |  3 +-
 target/arm/meson.build                        |  4 +-
 275 files changed, 491 insertions(+), 409 deletions(-)
 create mode 100644 include/exec/cpu-io.h
 rename include/exec/{ => sysemu}/address-spaces.h (80%)
 rename include/exec/{ => sysemu}/cputlb.h (86%)
 rename include/exec/{ => sysemu}/hwaddr.h (81%)
 rename include/exec/{ => sysemu}/memory-internal.h (94%)
 rename include/exec/{ => sysemu}/memory.h (99%)
 rename include/{exec => sysemu}/confidential-guest-support.h (95%)
 rename include/{exec => sysemu}/ioport.h (86%)
 rename include/{exec => sysemu}/ram_addr.h (99%)
 rename include/{exec => sysemu}/ramblock.h (92%)
 create mode 100644 softmmu/cpu-io.c

-- 
2.26.3



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/11] NOTFORMERGE target/arm: Restrict KVM files to softmmu
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/ Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

The following patches require the "arm cleanup experiment for
kvm-only build" [*] series with split various user/sysemu and
tcg/kvm code from the target/arm/ directory.

To be able to build the following patches waiting the series
get merged, simply restrict the KVM files to the softmmu source
set.

[*] https://lists.gnu.org/archive/html/qemu-devel/2021-04/msg02908.html

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/arm/cpu.c       | 2 +-
 target/arm/cpu64.c     | 2 +-
 target/arm/meson.build | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index f29649ecba7..e443cfb3d96 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -35,10 +35,10 @@
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
 #include "hw/boards.h"
+#include "kvm_arm.h"
 #endif
 #include "sysemu/tcg.h"
 #include "sysemu/hw_accel.h"
-#include "kvm_arm.h"
 #include "disas/capstone.h"
 #include "fpu/softfloat.h"
 
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index f0a9e968c9c..08fba3ec29a 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -27,9 +27,9 @@
 #include "qemu/module.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
+#include "kvm_arm.h"
 #endif
 #include "sysemu/kvm.h"
-#include "kvm_arm.h"
 #include "qapi/visitor.h"
 #include "hw/qdev-properties.h"
 
diff --git a/target/arm/meson.build b/target/arm/meson.build
index 09802ba1a17..6143e736079 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -35,8 +35,6 @@
 ))
 arm_ss.add(zlib)
 
-arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: files('kvm-stub.c'))
-
 arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
   'cpu64.c',
   'gdbstub64.c',
@@ -49,6 +47,8 @@
 
 arm_softmmu_ss = ss.source_set()
 
+arm_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: files('kvm-stub.c'))
+
 arm_softmmu_ss.add(when: 'TARGET_AARCH64', if_true: files(
   'mte_helper.c',
 ))
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 01/11] NOTFORMERGE target/arm: Restrict KVM files to softmmu Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-26 18:15   ` Richard Henderson
                     ` (2 more replies)
  2021-05-17 11:11 ` [PATCH 03/11] exec: Restrict cputlb.h " Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  11 siblings, 3 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

Guard declarations within hwaddr.h against inclusion
from user-mode emulation.

To make it clearer this header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/hwaddr.h,exec/sysemu/hwaddr.h, $(git grep -l exec/hwaddr.h)

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/audio/lm4549.h                                   | 2 +-
 hw/net/can/can_sja1000.h                            | 2 +-
 hw/net/can/ctucan_core.h                            | 2 +-
 hw/net/net_tx_pkt.h                                 | 2 +-
 include/disas/disas.h                               | 4 +++-
 include/exec/cpu-all.h                              | 2 +-
 include/exec/cpu-common.h                           | 2 +-
 include/exec/cpu-defs.h                             | 2 +-
 include/exec/memory.h                               | 2 +-
 include/exec/{ => sysemu}/hwaddr.h                  | 7 +++++--
 include/hw/arm/sharpsl.h                            | 2 +-
 include/hw/arm/soc_dma.h                            | 2 +-
 include/hw/arm/sysbus-fdt.h                         | 2 +-
 include/hw/arm/virt.h                               | 2 +-
 include/hw/block/block.h                            | 2 +-
 include/hw/block/fdc.h                              | 2 +-
 include/hw/block/flash.h                            | 2 +-
 include/hw/core/cpu.h                               | 4 +++-
 include/hw/cris/etraxfs_dma.h                       | 2 +-
 include/hw/display/vga.h                            | 2 +-
 include/hw/i386/microvm.h                           | 2 +-
 include/hw/i386/x86.h                               | 2 +-
 include/hw/input/lasips2.h                          | 2 +-
 include/hw/loader-fit.h                             | 2 +-
 include/hw/misc/allwinner-h3-dramc.h                | 2 +-
 include/hw/misc/empty_slot.h                        | 2 +-
 include/hw/nvram/fw_cfg.h                           | 2 +-
 include/hw/pci-host/gpex.h                          | 2 +-
 include/hw/remote/memory.h                          | 2 +-
 include/hw/remote/mpqemu-link.h                     | 2 +-
 include/hw/rtc/m48t59.h                             | 2 +-
 include/hw/rtc/sun4v-rtc.h                          | 2 +-
 include/hw/timer/tmu012.h                           | 2 +-
 include/hw/virtio/virtio-access.h                   | 2 +-
 include/monitor/monitor.h                           | 2 +-
 include/qemu/accel.h                                | 4 +++-
 include/qemu/iova-tree.h                            | 2 +-
 include/qemu/userfaultfd.h                          | 2 +-
 dump/dump.c                                         | 2 +-
 dump/win_dump.c                                     | 2 +-
 hw/arm/sbsa-ref.c                                   | 2 +-
 hw/input/lasips2.c                                  | 2 +-
 hw/m68k/next-cube.c                                 | 2 +-
 hw/ppc/pnv_homer.c                                  | 2 +-
 tests/qtest/microbit-test.c                         | 2 +-
 MAINTAINERS                                         | 1 +
 scripts/codeconverter/codeconverter/test_regexps.py | 4 ++--
 47 files changed, 58 insertions(+), 48 deletions(-)
 rename include/exec/{ => sysemu}/hwaddr.h (81%)

diff --git a/hw/audio/lm4549.h b/hw/audio/lm4549.h
index aba9bb5b077..5d53c2f2179 100644
--- a/hw/audio/lm4549.h
+++ b/hw/audio/lm4549.h
@@ -13,7 +13,7 @@
 #define HW_LM4549_H
 
 #include "audio/audio.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 typedef void (*lm4549_callback)(void *opaque);
 
diff --git a/hw/net/can/can_sja1000.h b/hw/net/can/can_sja1000.h
index 7ca9cd681ed..57e6d4d34e4 100644
--- a/hw/net/can/can_sja1000.h
+++ b/hw/net/can/can_sja1000.h
@@ -27,7 +27,7 @@
 #ifndef HW_CAN_SJA1000_H
 #define HW_CAN_SJA1000_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "net/can_emu.h"
 
 #define CAN_SJA_MEM_SIZE      128
diff --git a/hw/net/can/ctucan_core.h b/hw/net/can/ctucan_core.h
index bbc09ae0678..c0e4beafba2 100644
--- a/hw/net/can/ctucan_core.h
+++ b/hw/net/can/ctucan_core.h
@@ -28,7 +28,7 @@
 #ifndef HW_CAN_CTUCAN_CORE_H
 #define HW_CAN_CTUCAN_CORE_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "net/can_emu.h"
 
 #ifndef HOST_WORDS_BIGENDIAN
diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h
index 4ec8bbe9bd9..86548b4f613 100644
--- a/hw/net/net_tx_pkt.h
+++ b/hw/net/net_tx_pkt.h
@@ -19,7 +19,7 @@
 #define NET_TX_PKT_H
 
 #include "net/eth.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 /* define to enable packet dump functions */
 /*#define NET_TX_PKT_DEBUG*/
diff --git a/include/disas/disas.h b/include/disas/disas.h
index d363e95edeb..1b85d121a7a 100644
--- a/include/disas/disas.h
+++ b/include/disas/disas.h
@@ -1,7 +1,9 @@
 #ifndef QEMU_DISAS_H
 #define QEMU_DISAS_H
 
-#include "exec/hwaddr.h"
+#ifndef CONFIG_USER_ONLY
+#include "exec/sysemu/hwaddr.h"
+#endif
 
 #ifdef NEED_CPU_H
 #include "cpu.h"
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 32cfb634c6a..3e7edddead5 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -175,7 +175,7 @@ extern unsigned long reserved_va;
 
 #else
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 #define SUFFIX
 #define ARG1         as
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index ccabed4003a..1a64b0b5ac6 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -4,7 +4,7 @@
 /* CPU interfaces that are target independent.  */
 
 #ifndef CONFIG_USER_ONLY
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #endif
 
 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index ba3cd32a1ec..52a2b93493d 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -26,7 +26,7 @@
 #include "qemu/host-utils.h"
 #include "qemu/thread.h"
 #ifndef CONFIG_USER_ONLY
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #endif
 #include "exec/memattrs.h"
 #include "hw/core/cpu.h"
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c8b90889241..52a2659b396 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -17,7 +17,7 @@
 #ifndef CONFIG_USER_ONLY
 
 #include "exec/cpu-common.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "exec/memattrs.h"
 #include "exec/memop.h"
 #include "exec/ramlist.h"
diff --git a/include/exec/hwaddr.h b/include/exec/sysemu/hwaddr.h
similarity index 81%
rename from include/exec/hwaddr.h
rename to include/exec/sysemu/hwaddr.h
index 8f16d179a88..9693cd516b4 100644
--- a/include/exec/hwaddr.h
+++ b/include/exec/sysemu/hwaddr.h
@@ -1,8 +1,9 @@
 /* Define hwaddr if it exists.  */
 
-#ifndef HWADDR_H
-#define HWADDR_H
+#ifndef EXEC_SYSEMU_HWADDR_H
+#define EXEC_SYSEMU_HWADDR_H
 
+#ifndef CONFIG_USER_ONLY
 
 #define HWADDR_BITS 64
 /* hwaddr is the type of a physical address (its size can
@@ -23,4 +24,6 @@ typedef struct MemMapEntry {
     hwaddr size;
 } MemMapEntry;
 
+#endif /* !CONFIG_USER_ONLY */
+
 #endif
diff --git a/include/hw/arm/sharpsl.h b/include/hw/arm/sharpsl.h
index e986b28c527..36ed1df72a7 100644
--- a/include/hw/arm/sharpsl.h
+++ b/include/hw/arm/sharpsl.h
@@ -7,7 +7,7 @@
 #ifndef QEMU_SHARPSL_H
 #define QEMU_SHARPSL_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 /* zaurus.c */
 
diff --git a/include/hw/arm/soc_dma.h b/include/hw/arm/soc_dma.h
index e93a7499a80..14b802c2330 100644
--- a/include/hw/arm/soc_dma.h
+++ b/include/hw/arm/soc_dma.h
@@ -21,7 +21,7 @@
 #ifndef HW_SOC_DMA_H
 #define HW_SOC_DMA_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 struct soc_dma_s;
 struct soc_dma_ch_s;
diff --git a/include/hw/arm/sysbus-fdt.h b/include/hw/arm/sysbus-fdt.h
index 340c382cdde..7a8ace37b4c 100644
--- a/include/hw/arm/sysbus-fdt.h
+++ b/include/hw/arm/sysbus-fdt.h
@@ -24,7 +24,7 @@
 #ifndef HW_ARM_SYSBUS_FDT_H
 #define HW_ARM_SYSBUS_FDT_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 /**
  * platform_bus_add_all_fdt_nodes - create all the platform bus nodes
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 921416f918b..504b0bb6e57 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -30,7 +30,7 @@
 #ifndef QEMU_ARM_VIRT_H
 #define QEMU_ARM_VIRT_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qemu/notify.h"
 #include "hw/boards.h"
 #include "hw/arm/boot.h"
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index c172cbe65f1..0f36b1f0277 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -11,7 +11,7 @@
 #ifndef HW_BLOCK_H
 #define HW_BLOCK_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qapi/qapi-types-block-core.h"
 #include "hw/qdev-properties-system.h"
 
diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h
index 1ecca7cac7f..7f0fb3d3986 100644
--- a/include/hw/block/fdc.h
+++ b/include/hw/block/fdc.h
@@ -1,7 +1,7 @@
 #ifndef HW_FDC_H
 #define HW_FDC_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qapi/qapi-types-block.h"
 
 /* fdc.c */
diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h
index 86d8363bb09..e184df092eb 100644
--- a/include/hw/block/flash.h
+++ b/include/hw/block/flash.h
@@ -3,7 +3,7 @@
 
 /* NOR flash devices */
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qom/object.h"
 
 /* pflash_cfi01.c */
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index e4328de8d41..7aa5c82fa20 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -22,7 +22,9 @@
 
 #include "hw/qdev-core.h"
 #include "disas/dis-asm.h"
-#include "exec/hwaddr.h"
+#if !defined(CONFIG_USER_ONLY)
+#include "exec/sysemu/hwaddr.h"
+#endif
 #include "exec/memattrs.h"
 #include "qapi/qapi-types-run-state.h"
 #include "qemu/bitmap.h"
diff --git a/include/hw/cris/etraxfs_dma.h b/include/hw/cris/etraxfs_dma.h
index 095d76b9560..f0a4038c8ae 100644
--- a/include/hw/cris/etraxfs_dma.h
+++ b/include/hw/cris/etraxfs_dma.h
@@ -1,7 +1,7 @@
 #ifndef HW_ETRAXFS_DMA_H
 #define HW_ETRAXFS_DMA_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 struct dma_context_metadata {
 	/* data descriptor md */
diff --git a/include/hw/display/vga.h b/include/hw/display/vga.h
index 5f7825e0e36..d63e0bb9c94 100644
--- a/include/hw/display/vga.h
+++ b/include/hw/display/vga.h
@@ -9,7 +9,7 @@
 #ifndef QEMU_HW_DISPLAY_VGA_H
 #define QEMU_HW_DISPLAY_VGA_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 /*
  * modules can reference this symbol to avoid being loaded
diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
index f25f8374413..e6931917ed1 100644
--- a/include/hw/i386/microvm.h
+++ b/include/hw/i386/microvm.h
@@ -19,7 +19,7 @@
 #define HW_I386_MICROVM_H
 
 #include "qemu-common.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qemu/notify.h"
 
 #include "hw/boards.h"
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index c09b648dff2..b594f829cdb 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -18,7 +18,7 @@
 #define HW_I386_X86_H
 
 #include "qemu-common.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qemu/notify.h"
 
 #include "hw/i386/topology.h"
diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
index 0cd7b59064a..f4c1e787d2b 100644
--- a/include/hw/input/lasips2.h
+++ b/include/hw/input/lasips2.h
@@ -7,7 +7,7 @@
 #ifndef HW_INPUT_LASIPS2_H
 #define HW_INPUT_LASIPS2_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 #define TYPE_LASIPS2 "lasips2"
 
diff --git a/include/hw/loader-fit.h b/include/hw/loader-fit.h
index 0832e379dc9..138da77d664 100644
--- a/include/hw/loader-fit.h
+++ b/include/hw/loader-fit.h
@@ -20,7 +20,7 @@
 #ifndef HW_LOADER_FIT_H
 #define HW_LOADER_FIT_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 struct fit_loader_match {
     const char *compatible;
diff --git a/include/hw/misc/allwinner-h3-dramc.h b/include/hw/misc/allwinner-h3-dramc.h
index 0b6c877ef74..93e640b23af 100644
--- a/include/hw/misc/allwinner-h3-dramc.h
+++ b/include/hw/misc/allwinner-h3-dramc.h
@@ -22,7 +22,7 @@
 
 #include "qom/object.h"
 #include "hw/sysbus.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 /**
  * Constants
diff --git a/include/hw/misc/empty_slot.h b/include/hw/misc/empty_slot.h
index dec56e56ae4..d942aebd3e7 100644
--- a/include/hw/misc/empty_slot.h
+++ b/include/hw/misc/empty_slot.h
@@ -12,7 +12,7 @@
 #ifndef HW_EMPTY_SLOT_H
 #define HW_EMPTY_SLOT_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 void empty_slot_init(const char *name, hwaddr addr, uint64_t slot_size);
 
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 0e7a8bc7af2..af1f8df9cf0 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -1,7 +1,7 @@
 #ifndef FW_CFG_H
 #define FW_CFG_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "standard-headers/linux/qemu_fw_cfg.h"
 #include "hw/sysbus.h"
 #include "sysemu/dma.h"
diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h
index fcf8b638200..52da437057e 100644
--- a/include/hw/pci-host/gpex.h
+++ b/include/hw/pci-host/gpex.h
@@ -20,7 +20,7 @@
 #ifndef HW_GPEX_H
 #define HW_GPEX_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "hw/sysbus.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pcie_host.h"
diff --git a/include/hw/remote/memory.h b/include/hw/remote/memory.h
index bc2e30945f5..200fc982a00 100644
--- a/include/hw/remote/memory.h
+++ b/include/hw/remote/memory.h
@@ -11,7 +11,7 @@
 #ifndef REMOTE_MEMORY_H
 #define REMOTE_MEMORY_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "hw/remote/mpqemu-link.h"
 
 void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp);
diff --git a/include/hw/remote/mpqemu-link.h b/include/hw/remote/mpqemu-link.h
index 4ec09158851..9b56b30a311 100644
--- a/include/hw/remote/mpqemu-link.h
+++ b/include/hw/remote/mpqemu-link.h
@@ -14,7 +14,7 @@
 #include "qom/object.h"
 #include "qemu/thread.h"
 #include "io/channel.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "io/channel-socket.h"
 #include "hw/remote/proxy.h"
 
diff --git a/include/hw/rtc/m48t59.h b/include/hw/rtc/m48t59.h
index d9b45eb1612..dda5ef4a20a 100644
--- a/include/hw/rtc/m48t59.h
+++ b/include/hw/rtc/m48t59.h
@@ -26,7 +26,7 @@
 #ifndef HW_RTC_M48T59_H
 #define HW_RTC_M48T59_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "qom/object.h"
 
 #define TYPE_NVRAM "nvram"
diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h
index fd868f6ed2f..b2e27447121 100644
--- a/include/hw/rtc/sun4v-rtc.h
+++ b/include/hw/rtc/sun4v-rtc.h
@@ -12,7 +12,7 @@
 #ifndef HW_RTC_SUN4V
 #define HW_RTC_SUN4V
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 void sun4v_rtc_init(hwaddr addr);
 
diff --git a/include/hw/timer/tmu012.h b/include/hw/timer/tmu012.h
index 808ed8de1d7..ea98ff0b3f1 100644
--- a/include/hw/timer/tmu012.h
+++ b/include/hw/timer/tmu012.h
@@ -9,7 +9,7 @@
 #ifndef HW_TIMER_TMU012_H
 #define HW_TIMER_TMU012_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 #define TMU012_FEAT_TOCR   (1 << 0)
 #define TMU012_FEAT_3CHAN  (1 << 1)
diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
index 6818a23a2d3..b18e0109d9f 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -16,7 +16,7 @@
 #ifndef QEMU_VIRTIO_ACCESS_H
 #define QEMU_VIRTIO_ACCESS_H
 
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-bus.h"
 
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index af3887bb71d..b70fb361e3a 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -4,7 +4,7 @@
 #include "block/block.h"
 #include "qapi/qapi-types-misc.h"
 #include "qemu/readline.h"
-#include "include/exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 typedef struct MonitorHMP MonitorHMP;
 typedef struct MonitorOptions MonitorOptions;
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 4f4c283f6fc..2fc5feddff2 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -24,7 +24,9 @@
 #define QEMU_ACCEL_H
 
 #include "qom/object.h"
-#include "exec/hwaddr.h"
+#ifndef CONFIG_USER_ONLY
+#include "exec/sysemu/hwaddr.h"
+#endif
 
 typedef struct AccelState {
     /*< private >*/
diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h
index b66cf93c4bc..1530cf0e95e 100644
--- a/include/qemu/iova-tree.h
+++ b/include/qemu/iova-tree.h
@@ -24,7 +24,7 @@
  */
 
 #include "exec/memory.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 #define  IOVA_OK           (0)
 #define  IOVA_ERR_INVALID  (-1) /* Invalid parameters */
diff --git a/include/qemu/userfaultfd.h b/include/qemu/userfaultfd.h
index 6b74f92792d..2cdce404edf 100644
--- a/include/qemu/userfaultfd.h
+++ b/include/qemu/userfaultfd.h
@@ -14,7 +14,7 @@
 #define USERFAULTFD_H
 
 #include "qemu/osdep.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include <linux/userfaultfd.h>
 
 int uffd_query_features(uint64_t *features);
diff --git a/dump/dump.c b/dump/dump.c
index ab625909f30..544553d3579 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -15,7 +15,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "elf.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "monitor/monitor.h"
 #include "sysemu/kvm.h"
 #include "sysemu/dump.h"
diff --git a/dump/win_dump.c b/dump/win_dump.c
index c5eb5a9aacd..6c30c98fb09 100644
--- a/dump/win_dump.c
+++ b/dump/win_dump.c
@@ -12,7 +12,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "elf.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "monitor/monitor.h"
 #include "sysemu/kvm.h"
 #include "sysemu/dump.h"
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 43c19b49234..d01d93eb8f9 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -27,7 +27,7 @@
 #include "sysemu/numa.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "kvm_arm.h"
 #include "hw/arm/boot.h"
 #include "hw/block/flash.h"
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index e7faf24058b..f84f37411fd 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -26,7 +26,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/input/ps2.h"
 #include "hw/input/lasips2.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "trace.h"
 #include "exec/address-spaces.h"
 #include "migration/vmstate.h"
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index de951ffe5d3..84c346e7420 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -10,7 +10,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/qtest.h"
 #include "hw/irq.h"
diff --git a/hw/ppc/pnv_homer.c b/hw/ppc/pnv_homer.c
index 9a262629b73..394425232ed 100644
--- a/hw/ppc/pnv_homer.c
+++ b/hw/ppc/pnv_homer.c
@@ -19,7 +19,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "qapi/error.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "exec/memory.h"
 #include "sysemu/cpus.h"
 #include "hw/qdev-core.h"
diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c
index 2b255579dfd..4d1c7fd863b 100644
--- a/tests/qtest/microbit-test.c
+++ b/tests/qtest/microbit-test.c
@@ -15,7 +15,7 @@
 
 
 #include "qemu/osdep.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 #include "libqos/libqtest.h"
 
 #include "hw/arm/nrf51.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index 78561a223f9..f1ae9934349 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -129,6 +129,7 @@ F: include/exec/cpu*.h
 F: include/exec/exec-all.h
 F: include/exec/helper*.h
 F: include/exec/tb-hash.h
+F: include/exec/sysemu/hwaddr.h
 F: include/sysemu/cpus.h
 F: include/sysemu/tcg.h
 F: include/hw/core/tcg-cpu-ops.h
diff --git a/scripts/codeconverter/codeconverter/test_regexps.py b/scripts/codeconverter/codeconverter/test_regexps.py
index a445634d88a..41a2cd9c14c 100644
--- a/scripts/codeconverter/codeconverter/test_regexps.py
+++ b/scripts/codeconverter/codeconverter/test_regexps.py
@@ -228,7 +228,7 @@ def test_initial_includes():
 /* NOR flash devices */
 
 #include "qom/object.h"
-#include "exec/hwaddr.h"
+#include "exec/sysemu/hwaddr.h"
 
 /* pflash_cfi01.c */
 '''
@@ -236,7 +236,7 @@ def test_initial_includes():
     m = InitialIncludes.domatch(c)
     assert m
     print(repr(m.group(0)))
-    assert m.group(0).endswith('#include "exec/hwaddr.h"\n')
+    assert m.group(0).endswith('#include "exec/sysemu/hwaddr.h"\n')
 
     c = '''#ifndef QEMU_VIRTIO_9P_H
 #define QEMU_VIRTIO_9P_H
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/11] exec: Restrict cputlb.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 01/11] NOTFORMERGE target/arm: Restrict KVM files to softmmu Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/ Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 04/11] exec: Restrict memory.h " Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the cputlb.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/cputlb.h,exec/sysemu/cputlb.h, $(git grep -l exec/cputlb.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/exec/{ => sysemu}/cputlb.h | 11 +++++++----
 accel/tcg/cputlb.c                 |  2 +-
 accel/tcg/translate-all.c          |  6 +++---
 MAINTAINERS                        |  1 +
 4 files changed, 12 insertions(+), 8 deletions(-)
 rename include/exec/{ => sysemu}/cputlb.h (86%)

diff --git a/include/exec/cputlb.h b/include/exec/sysemu/cputlb.h
similarity index 86%
rename from include/exec/cputlb.h
rename to include/exec/sysemu/cputlb.h
index 19b16e58f84..5a37a870343 100644
--- a/include/exec/cputlb.h
+++ b/include/exec/sysemu/cputlb.h
@@ -17,15 +17,18 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef CPUTLB_H
-#define CPUTLB_H
+#ifndef EXEC_SYSEMU_CPUTLB_H
+#define EXEC_SYSEMU_CPUTLB_H
+
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
 
 #include "exec/cpu-common.h"
 
-#if !defined(CONFIG_USER_ONLY)
 /* cputlb.c */
 void tlb_protect_code(ram_addr_t ram_addr);
 void tlb_unprotect_code(ram_addr_t ram_addr);
 void tlb_flush_counts(size_t *full, size_t *part, size_t *elide);
-#endif
+
 #endif
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 84e7d91a5ca..452029e8193 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -23,7 +23,7 @@
 #include "exec/exec-all.h"
 #include "exec/memory.h"
 #include "exec/cpu_ldst.h"
-#include "exec/cputlb.h"
+#include "exec/sysemu/cputlb.h"
 #include "exec/tb-hash.h"
 #include "exec/memory-internal.h"
 #include "exec/ram_addr.h"
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index ae7e873713a..98a07ce4e4e 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -42,11 +42,11 @@
 #include <libutil.h>
 #endif
 #endif
-#else
+#else /* !CONFIG_USER_ONLY */
+#include "exec/sysemu/cputlb.h"
 #include "exec/ram_addr.h"
-#endif
+#endif /* CONFIG_USER_ONLY */
 
-#include "exec/cputlb.h"
 #include "exec/tb-hash.h"
 #include "exec/translate-all.h"
 #include "qemu/bitmap.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index f1ae9934349..4378ec47a2c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -131,6 +131,7 @@ F: include/exec/helper*.h
 F: include/exec/tb-hash.h
 F: include/exec/sysemu/hwaddr.h
 F: include/sysemu/cpus.h
+F: include/exec/sysemu/cputlb.h
 F: include/sysemu/tcg.h
 F: include/hw/core/tcg-cpu-ops.h
 
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/11] exec: Restrict memory.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 03/11] exec: Restrict cputlb.h " Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 05/11] exec: Restrict memory-internal.h " Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the memory.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/memory.h,exec/sysemu/memory.h, $(git grep -l exec/memory.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 docs/devel/memory.rst                     | 2 +-
 hw/arm/strongarm.h                        | 2 +-
 hw/display/framebuffer.h                  | 2 +-
 hw/display/vga_int.h                      | 2 +-
 hw/net/i82596.h                           | 2 +-
 hw/net/pcnet.h                            | 2 +-
 hw/ppc/mac.h                              | 2 +-
 hw/usb/hcd-uhci.h                         | 2 +-
 hw/vfio/pci.h                             | 2 +-
 include/exec/address-spaces.h             | 2 +-
 include/exec/cpu-all.h                    | 4 +++-
 include/exec/ioport.h                     | 2 +-
 include/exec/{ => sysemu}/memory.h        | 6 +++---
 include/hw/acpi/acpi.h                    | 2 +-
 include/hw/acpi/tco.h                     | 2 +-
 include/hw/arm/fsl-imx25.h                | 2 +-
 include/hw/arm/fsl-imx31.h                | 2 +-
 include/hw/arm/fsl-imx6.h                 | 2 +-
 include/hw/arm/fsl-imx6ul.h               | 2 +-
 include/hw/arm/omap.h                     | 2 +-
 include/hw/arm/pxa.h                      | 2 +-
 include/hw/boards.h                       | 2 +-
 include/hw/char/riscv_htif.h              | 2 +-
 include/hw/char/serial.h                  | 2 +-
 include/hw/display/macfb.h                | 2 +-
 include/hw/gpio/npcm7xx_gpio.h            | 2 +-
 include/hw/i2c/npcm7xx_smbus.h            | 2 +-
 include/hw/i2c/pm_smbus.h                 | 2 +-
 include/hw/i386/apic_internal.h           | 2 +-
 include/hw/i386/ioapic_internal.h         | 2 +-
 include/hw/ide.h                          | 2 +-
 include/hw/ipmi/ipmi.h                    | 2 +-
 include/hw/isa/apm.h                      | 2 +-
 include/hw/isa/isa.h                      | 2 +-
 include/hw/mem/npcm7xx_mc.h               | 2 +-
 include/hw/mem/pc-dimm.h                  | 2 +-
 include/hw/mips/mips.h                    | 2 +-
 include/hw/misc/auxbus.h                  | 2 +-
 include/hw/misc/mac_via.h                 | 2 +-
 include/hw/misc/mos6522.h                 | 2 +-
 include/hw/misc/npcm7xx_clk.h             | 2 +-
 include/hw/misc/npcm7xx_gcr.h             | 2 +-
 include/hw/misc/npcm7xx_mft.h             | 2 +-
 include/hw/net/msf2-emac.h                | 2 +-
 include/hw/nvram/npcm7xx_otp.h            | 2 +-
 include/hw/pci-host/pam.h                 | 2 +-
 include/hw/pci-host/remote.h              | 2 +-
 include/hw/pci/pci.h                      | 2 +-
 include/hw/pci/pcie_host.h                | 2 +-
 include/hw/pci/shpc.h                     | 2 +-
 include/hw/ppc/mac_dbdma.h                | 2 +-
 include/hw/ppc/ppc4xx.h                   | 2 +-
 include/hw/ppc/xics.h                     | 2 +-
 include/hw/register.h                     | 2 +-
 include/hw/remote/proxy-memory-listener.h | 2 +-
 include/hw/sh4/sh_intc.h                  | 2 +-
 include/hw/sysbus.h                       | 2 +-
 include/hw/timer/npcm7xx_timer.h          | 2 +-
 include/hw/tricore/tricore.h              | 2 +-
 include/hw/usb.h                          | 2 +-
 include/hw/vfio/vfio-common.h             | 2 +-
 include/hw/virtio/vhost-backend.h         | 2 +-
 include/hw/virtio/vhost.h                 | 2 +-
 include/hw/virtio/virtio.h                | 2 +-
 include/hw/xtensa/mx_pic.h                | 2 +-
 include/qemu/iova-tree.h                  | 2 +-
 include/sysemu/dma.h                      | 2 +-
 include/sysemu/hostmem.h                  | 2 +-
 include/sysemu/kvm_int.h                  | 2 +-
 include/sysemu/memory_mapping.h           | 2 +-
 include/sysemu/vhost-user-backend.h       | 2 +-
 target/arm/kvm_arm.h                      | 2 +-
 accel/kvm/kvm-all.c                       | 2 +-
 accel/tcg/cputlb.c                        | 2 +-
 backends/tpm/tpm_util.c                   | 2 +-
 hw/avr/atmega.c                           | 2 +-
 hw/block/nvme.c                           | 2 +-
 hw/block/onenand.c                        | 2 +-
 hw/core/loader-fit.c                      | 2 +-
 hw/core/loader.c                          | 2 +-
 hw/display/edid-region.c                  | 2 +-
 hw/display/tc6393xb.c                     | 2 +-
 hw/i386/acpi-common.c                     | 2 +-
 hw/i386/acpi-microvm.c                    | 2 +-
 hw/i386/pc.c                              | 2 +-
 hw/i386/pc_piix.c                         | 2 +-
 hw/intc/mips_gic.c                        | 2 +-
 hw/intc/ompic.c                           | 2 +-
 hw/misc/omap_gpmc.c                       | 2 +-
 hw/net/ne2000.c                           | 2 +-
 hw/nios2/10m50_devboard.c                 | 2 +-
 hw/nios2/generic_nommu.c                  | 2 +-
 hw/pci-bridge/pci_bridge_dev.c            | 2 +-
 hw/pci-host/remote.c                      | 2 +-
 hw/ppc/pnv_homer.c                        | 2 +-
 hw/ppc/ppc440_uc.c                        | 2 +-
 hw/ppc/sam460ex.c                         | 2 +-
 hw/remote/machine.c                       | 2 +-
 hw/remote/proxy-memory-listener.c         | 2 +-
 hw/timer/sh_timer.c                       | 2 +-
 hw/vfio/common.c                          | 2 +-
 hw/vfio/platform.c                        | 2 +-
 hw/xtensa/sim.c                           | 2 +-
 hw/xtensa/virt.c                          | 2 +-
 hw/xtensa/xtensa_memory.c                 | 2 +-
 hw/xtensa/xtfpga.c                        | 2 +-
 migration/rdma.c                          | 2 +-
 migration/savevm.c                        | 2 +-
 monitor/misc.c                            | 2 +-
 softmmu/ioport.c                          | 2 +-
 softmmu/memory.c                          | 2 +-
 softmmu/memory_mapping.c                  | 2 +-
 softmmu/physmem.c                         | 2 +-
 softmmu/qtest.c                           | 2 +-
 stubs/ram-block.c                         | 2 +-
 target/s390x/misc_helper.c                | 2 +-
 tests/qtest/fuzz/generic_fuzz.c           | 2 +-
 tests/qtest/fuzz/qos_fuzz.c               | 2 +-
 ui/console.c                              | 2 +-
 util/vfio-helpers.c                       | 2 +-
 MAINTAINERS                               | 2 +-
 scripts/analyze-inclusions                | 2 +-
 122 files changed, 126 insertions(+), 124 deletions(-)
 rename include/exec/{ => sysemu}/memory.h (99%)

diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst
index 5dc8a126829..69d8d81f8ee 100644
--- a/docs/devel/memory.rst
+++ b/docs/devel/memory.rst
@@ -365,4 +365,4 @@ callbacks are called:
 API Reference
 -------------
 
-.. kernel-doc:: include/exec/memory.h
+.. kernel-doc:: include/exec/sysemu/memory.h
diff --git a/hw/arm/strongarm.h b/hw/arm/strongarm.h
index 192821f6aab..a4d881b5b42 100644
--- a/hw/arm/strongarm.h
+++ b/hw/arm/strongarm.h
@@ -1,7 +1,7 @@
 #ifndef STRONGARM_H
 #define STRONGARM_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "target/arm/cpu-qom.h"
 
 #define SA_CS0          0x00000000
diff --git a/hw/display/framebuffer.h b/hw/display/framebuffer.h
index 38fa0dcec61..04bcf53ed59 100644
--- a/hw/display/framebuffer.h
+++ b/hw/display/framebuffer.h
@@ -1,7 +1,7 @@
 #ifndef QEMU_FRAMEBUFFER_H
 #define QEMU_FRAMEBUFFER_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 /* Framebuffer device helper routines.  */
 
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 847e784ca6a..b923633cc4f 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -26,7 +26,7 @@
 #define HW_VGA_INT_H
 
 #include "exec/ioport.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "ui/console.h"
 
 #include "hw/display/bochs-vbe.h"
diff --git a/hw/net/i82596.h b/hw/net/i82596.h
index f0bbe810eb2..de5cc7d0c5b 100644
--- a/hw/net/i82596.h
+++ b/hw/net/i82596.h
@@ -3,7 +3,7 @@
 
 #define I82596_IOPORT_SIZE       0x20
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 
 #define PORT_RESET              0x00    /* reset 82596 */
diff --git a/hw/net/pcnet.h b/hw/net/pcnet.h
index f49b213c57f..0ad6bab1f90 100644
--- a/hw/net/pcnet.h
+++ b/hw/net/pcnet.h
@@ -7,7 +7,7 @@
 #define PCNET_LOOPTEST_CRC	1
 #define PCNET_LOOPTEST_NOCRC	2
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/irq.h"
 
 /* BUS CONFIGURATION REGISTERS */
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 22c8408078d..104fab63ccf 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -27,7 +27,7 @@
 #define PPC_MAC_H
 
 #include "qemu/units.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/boards.h"
 #include "hw/sysbus.h"
 #include "hw/input/adb.h"
diff --git a/hw/usb/hcd-uhci.h b/hw/usb/hcd-uhci.h
index e61d8fcb192..04a9a517318 100644
--- a/hw/usb/hcd-uhci.h
+++ b/hw/usb/hcd-uhci.h
@@ -28,7 +28,7 @@
 #ifndef HW_USB_HCD_UHCI_H
 #define HW_USB_HCD_UHCI_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/timer.h"
 #include "hw/pci/pci.h"
 #include "hw/usb.h"
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 64777516d16..ee647a03d6c 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -12,7 +12,7 @@
 #ifndef HW_VFIO_VFIO_PCI_H
 #define HW_VFIO_VFIO_PCI_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/pci/pci.h"
 #include "hw/vfio/vfio-common.h"
 #include "qemu/event_notifier.h"
diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h
index db8bfa9a92b..b7533b33f72 100644
--- a/include/exec/address-spaces.h
+++ b/include/exec/address-spaces.h
@@ -19,7 +19,7 @@
  * you're one of them.
  */
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 #ifndef CONFIG_USER_ONLY
 
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 3e7edddead5..8f897b4fec6 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -20,7 +20,9 @@
 #define CPU_ALL_H
 
 #include "exec/cpu-common.h"
-#include "exec/memory.h"
+#if !defined(CONFIG_USER_ONLY)
+#include "exec/sysemu/memory.h"
+#endif
 #include "qemu/thread.h"
 #include "hw/core/cpu.h"
 #include "qemu/rcu.h"
diff --git a/include/exec/ioport.h b/include/exec/ioport.h
index e34f668998d..d5ca8abff76 100644
--- a/include/exec/ioport.h
+++ b/include/exec/ioport.h
@@ -24,7 +24,7 @@
 #ifndef IOPORT_H
 #define IOPORT_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 #define MAX_IOPORTS     (64 * 1024)
 #define IOPORTS_MASK    (MAX_IOPORTS - 1)
diff --git a/include/exec/memory.h b/include/exec/sysemu/memory.h
similarity index 99%
rename from include/exec/memory.h
rename to include/exec/sysemu/memory.h
index 52a2659b396..13288b110e0 100644
--- a/include/exec/memory.h
+++ b/include/exec/sysemu/memory.h
@@ -14,7 +14,9 @@
 #ifndef MEMORY_H
 #define MEMORY_H
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
 
 #include "exec/cpu-common.h"
 #include "exec/sysemu/hwaddr.h"
@@ -2632,5 +2634,3 @@ bool ram_block_discard_is_disabled(void);
 bool ram_block_discard_is_required(void);
 
 #endif
-
-#endif
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index 9e8a76f2e2a..485cab42a93 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -21,7 +21,7 @@
  */
 
 #include "qemu/notify.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/acpi/acpi_dev_interface.h"
 
 /*
diff --git a/include/hw/acpi/tco.h b/include/hw/acpi/tco.h
index a1e0da82134..2bed10d1ab1 100644
--- a/include/hw/acpi/tco.h
+++ b/include/hw/acpi/tco.h
@@ -10,7 +10,7 @@
 #ifndef HW_ACPI_TCO_H
 #define HW_ACPI_TCO_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 /* As per ICH9 spec, the internal timer has an error of ~0.6s on every tick */
 #define TCO_TICK_NSEC 600000000LL
diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h
index 1b1086e9458..e37e1c3afbd 100644
--- a/include/hw/arm/fsl-imx25.h
+++ b/include/hw/arm/fsl-imx25.h
@@ -30,7 +30,7 @@
 #include "hw/sd/sdhci.h"
 #include "hw/usb/chipidea.h"
 #include "hw/watchdog/wdt_imx2.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "target/arm/cpu.h"
 #include "qom/object.h"
 
diff --git a/include/hw/arm/fsl-imx31.h b/include/hw/arm/fsl-imx31.h
index c116a73e0b3..28c819b6cde 100644
--- a/include/hw/arm/fsl-imx31.h
+++ b/include/hw/arm/fsl-imx31.h
@@ -26,7 +26,7 @@
 #include "hw/i2c/imx_i2c.h"
 #include "hw/gpio/imx_gpio.h"
 #include "hw/watchdog/wdt_imx2.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "target/arm/cpu.h"
 #include "qom/object.h"
 
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
index 83291457cf2..3b6e5b086ca 100644
--- a/include/hw/arm/fsl-imx6.h
+++ b/include/hw/arm/fsl-imx6.h
@@ -32,7 +32,7 @@
 #include "hw/net/imx_fec.h"
 #include "hw/usb/chipidea.h"
 #include "hw/usb/imx-usb-phy.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "cpu.h"
 #include "qom/object.h"
 
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
index 7812e516a52..0dbd6e74861 100644
--- a/include/hw/arm/fsl-imx6ul.h
+++ b/include/hw/arm/fsl-imx6ul.h
@@ -36,7 +36,7 @@
 #include "hw/net/imx_fec.h"
 #include "hw/usb/chipidea.h"
 #include "hw/usb/imx-usb-phy.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "cpu.h"
 #include "qom/object.h"
 
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
index ff6a173f8a6..5e60cd3f0d5 100644
--- a/include/hw/arm/omap.h
+++ b/include/hw/arm/omap.h
@@ -20,7 +20,7 @@
 #ifndef HW_ARM_OMAP_H
 #define HW_ARM_OMAP_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/input/tsc2xxx.h"
 #include "target/arm/cpu-qom.h"
 #include "qemu/log.h"
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
index 1095504b86f..91360a1973f 100644
--- a/include/hw/arm/pxa.h
+++ b/include/hw/arm/pxa.h
@@ -10,7 +10,7 @@
 #ifndef PXA_H
 #define PXA_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "target/arm/cpu-qom.h"
 #include "hw/pcmcia.h"
 #include "qom/object.h"
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3d55d2bd62c..e209b8ff3d0 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -3,7 +3,7 @@
 #ifndef HW_BOARDS_H
 #define HW_BOARDS_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "sysemu/hostmem.h"
 #include "sysemu/blockdev.h"
 #include "qemu/accel.h"
diff --git a/include/hw/char/riscv_htif.h b/include/hw/char/riscv_htif.h
index fb9452cf51d..d7c6e0cce35 100644
--- a/include/hw/char/riscv_htif.h
+++ b/include/hw/char/riscv_htif.h
@@ -22,7 +22,7 @@
 
 #include "chardev/char.h"
 #include "chardev/char-fe.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "target/riscv/cpu.h"
 
 #define TYPE_HTIF_UART "riscv.htif.uart"
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 8ba7eca3d67..09310c27658 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -27,7 +27,7 @@
 #define HW_SERIAL_H
 
 #include "chardev/char-fe.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/fifo8.h"
 #include "chardev/char.h"
 #include "hw/sysbus.h"
diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h
index 80806b0306a..34dde745fa9 100644
--- a/include/hw/display/macfb.h
+++ b/include/hw/display/macfb.h
@@ -13,7 +13,7 @@
 #ifndef MACFB_H
 #define MACFB_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "ui/console.h"
 #include "qom/object.h"
 
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index b1d771bd776..fd7a98174db 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -15,7 +15,7 @@
 #ifndef NPCM7XX_GPIO_H
 #define NPCM7XX_GPIO_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 
 /* Number of pins managed by each controller. */
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
index 7d59ee917eb..f2092e37e34 100644
--- a/include/hw/i2c/npcm7xx_smbus.h
+++ b/include/hw/i2c/npcm7xx_smbus.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_SMBUS_H
 #define NPCM7XX_SMBUS_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/i2c/i2c.h"
 #include "hw/irq.h"
 #include "hw/sysbus.h"
diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h
index 0d74207efb5..c52e79de5e4 100644
--- a/include/hw/i2c/pm_smbus.h
+++ b/include/hw/i2c/pm_smbus.h
@@ -1,7 +1,7 @@
 #ifndef PM_SMBUS_H
 #define PM_SMBUS_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/i2c/smbus_master.h"
 
 #define PM_SMBUS_MAX_MSG_SIZE 32
diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h
index c175e7e7181..ecf7cc3d156 100644
--- a/include/hw/i386/apic_internal.h
+++ b/include/hw/i386/apic_internal.h
@@ -22,7 +22,7 @@
 #define QEMU_APIC_INTERNAL_H
 
 #include "cpu.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/timer.h"
 #include "target/i386/cpu-qom.h"
 #include "qom/object.h"
diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_internal.h
index 021e715f113..c824b7d138a 100644
--- a/include/hw/i386/ioapic_internal.h
+++ b/include/hw/i386/ioapic_internal.h
@@ -22,7 +22,7 @@
 #ifndef QEMU_IOAPIC_INTERNAL_H
 #define QEMU_IOAPIC_INTERNAL_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 #include "qemu/notify.h"
 #include "qom/object.h"
diff --git a/include/hw/ide.h b/include/hw/ide.h
index c5ce5da4f47..50d07d7e6fe 100644
--- a/include/hw/ide.h
+++ b/include/hw/ide.h
@@ -2,7 +2,7 @@
 #define HW_IDE_H
 
 #include "hw/isa/isa.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 /* ide-isa.c */
 ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index 77a7213ed93..03f71e6b9bd 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -25,7 +25,7 @@
 #ifndef HW_IPMI_H
 #define HW_IPMI_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
diff --git a/include/hw/isa/apm.h b/include/hw/isa/apm.h
index b6e070c00e9..e66f27badeb 100644
--- a/include/hw/isa/apm.h
+++ b/include/hw/isa/apm.h
@@ -1,7 +1,7 @@
 #ifndef APM_H
 #define APM_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 #define APM_CNT_IOPORT  0xb2
 #define ACPI_PORT_SMI_CMD APM_CNT_IOPORT
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index ddaae89a853..9c9aabfc3b0 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -3,7 +3,7 @@
 
 /* ISA bus */
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/ioport.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
diff --git a/include/hw/mem/npcm7xx_mc.h b/include/hw/mem/npcm7xx_mc.h
index 7ed38be2431..a10a29cea41 100644
--- a/include/hw/mem/npcm7xx_mc.h
+++ b/include/hw/mem/npcm7xx_mc.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_MC_H
 #define NPCM7XX_MC_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 
 /**
diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 1473e6db625..5a88c767631 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -16,7 +16,7 @@
 #ifndef QEMU_PC_DIMM_H
 #define QEMU_PC_DIMM_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h
index 6c9c8805f3f..dc9fbea121e 100644
--- a/include/hw/mips/mips.h
+++ b/include/hw/mips/mips.h
@@ -7,7 +7,7 @@
 /* Kernels can be configured with 64KB pages */
 #define INITRD_PAGE_SIZE (64 * KiB)
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 /* gt64xxx.c */
 PCIBus *gt64120_register(qemu_irq *pic);
diff --git a/include/hw/misc/auxbus.h b/include/hw/misc/auxbus.h
index b05799d2f7a..4e2db11d705 100644
--- a/include/hw/misc/auxbus.h
+++ b/include/hw/misc/auxbus.h
@@ -25,7 +25,7 @@
 #ifndef HW_MISC_AUXBUS_H
 #define HW_MISC_AUXBUS_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h
index 3058b30685a..56f44198e2e 100644
--- a/include/hw/misc/mac_via.h
+++ b/include/hw/misc/mac_via.h
@@ -9,7 +9,7 @@
 #ifndef HW_MISC_MAC_VIA_H
 #define HW_MISC_MAC_VIA_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 #include "hw/misc/mos6522.h"
 #include "qom/object.h"
diff --git a/include/hw/misc/mos6522.h b/include/hw/misc/mos6522.h
index fc95d22b0fd..9ae8d861c8e 100644
--- a/include/hw/misc/mos6522.h
+++ b/include/hw/misc/mos6522.h
@@ -27,7 +27,7 @@
 #ifndef MOS6522_H
 #define MOS6522_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 #include "hw/input/adb.h"
 #include "qom/object.h"
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
index d5c8d16ca42..9a425b5cba6 100644
--- a/include/hw/misc/npcm7xx_clk.h
+++ b/include/hw/misc/npcm7xx_clk.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_CLK_H
 #define NPCM7XX_CLK_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/clock.h"
 #include "hw/sysbus.h"
 
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
index 13109d9d324..e1f0ebdef38 100644
--- a/include/hw/misc/npcm7xx_gcr.h
+++ b/include/hw/misc/npcm7xx_gcr.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_GCR_H
 #define NPCM7XX_GCR_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 
 /*
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
index 36785e3ba81..dd6ec3dba94 100644
--- a/include/hw/misc/npcm7xx_mft.h
+++ b/include/hw/misc/npcm7xx_mft.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_MFT_H
 #define NPCM7XX_MFT_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/clock.h"
 #include "hw/irq.h"
 #include "hw/sysbus.h"
diff --git a/include/hw/net/msf2-emac.h b/include/hw/net/msf2-emac.h
index 846ba6e6dce..eea742f9758 100644
--- a/include/hw/net/msf2-emac.h
+++ b/include/hw/net/msf2-emac.h
@@ -23,7 +23,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "net/net.h"
 #include "net/eth.h"
 #include "qom/object.h"
diff --git a/include/hw/nvram/npcm7xx_otp.h b/include/hw/nvram/npcm7xx_otp.h
index 156bbd151ab..f7700a2a8e7 100644
--- a/include/hw/nvram/npcm7xx_otp.h
+++ b/include/hw/nvram/npcm7xx_otp.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_OTP_H
 #define NPCM7XX_OTP_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 
 /* Each OTP module holds 8192 bits of one-time programmable storage */
diff --git a/include/hw/pci-host/pam.h b/include/hw/pci-host/pam.h
index c1fd06ba2ae..5814a9dbc09 100644
--- a/include/hw/pci-host/pam.h
+++ b/include/hw/pci-host/pam.h
@@ -50,7 +50,7 @@
  * 0xf0000 - 0xfffff System BIOS Area Memory Segments
  */
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 #define SMRAM_C_BASE    0xa0000
 #define SMRAM_C_END     0xc0000
diff --git a/include/hw/pci-host/remote.h b/include/hw/pci-host/remote.h
index 3dcf6aa51d1..1f71b9af138 100644
--- a/include/hw/pci-host/remote.h
+++ b/include/hw/pci-host/remote.h
@@ -11,7 +11,7 @@
 #ifndef REMOTE_PCIHOST_H
 #define REMOTE_PCIHOST_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/pci/pcie_host.h"
 
 #define TYPE_REMOTE_PCIHOST "remote-pcihost"
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 6be4e0c460c..331421d02f5 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -1,7 +1,7 @@
 #ifndef QEMU_PCI_H
 #define QEMU_PCI_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "sysemu/dma.h"
 
 /* PCI includes legacy ISA access.  */
diff --git a/include/hw/pci/pcie_host.h b/include/hw/pci/pcie_host.h
index 076457b270e..a084c4b2e81 100644
--- a/include/hw/pci/pcie_host.h
+++ b/include/hw/pci/pcie_host.h
@@ -22,7 +22,7 @@
 #define PCIE_HOST_H
 
 #include "hw/pci/pci_host.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qom/object.h"
 
 #define TYPE_PCIE_HOST_BRIDGE "pcie-host-bridge"
diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h
index d5683b73990..a51d47b5b9f 100644
--- a/include/hw/pci/shpc.h
+++ b/include/hw/pci/shpc.h
@@ -1,7 +1,7 @@
 #ifndef SHPC_H
 #define SHPC_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/hotplug.h"
 #include "hw/pci/pci.h"
 #include "migration/vmstate.h"
diff --git a/include/hw/ppc/mac_dbdma.h b/include/hw/ppc/mac_dbdma.h
index 4a3f644516b..09cee8eff45 100644
--- a/include/hw/ppc/mac_dbdma.h
+++ b/include/hw/ppc/mac_dbdma.h
@@ -23,7 +23,7 @@
 #ifndef HW_MAC_DBDMA_H
 #define HW_MAC_DBDMA_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/iov.h"
 #include "sysemu/dma.h"
 #include "hw/sysbus.h"
diff --git a/include/hw/ppc/ppc4xx.h b/include/hw/ppc/ppc4xx.h
index 980f964b5a9..f6360ea1218 100644
--- a/include/hw/ppc/ppc4xx.h
+++ b/include/hw/ppc/ppc4xx.h
@@ -26,7 +26,7 @@
 #define PPC4XX_H
 
 #include "hw/ppc/ppc.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 /* PowerPC 4xx core initialization */
 PowerPCCPU *ppc4xx_init(const char *cpu_model,
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 00b80b08c27..7ee4c6bb4a9 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -28,7 +28,7 @@
 #ifndef XICS_H
 #define XICS_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
diff --git a/include/hw/register.h b/include/hw/register.h
index b480e3882cd..e5d3ac63494 100644
--- a/include/hw/register.h
+++ b/include/hw/register.h
@@ -12,7 +12,7 @@
 #define REGISTER_H
 
 #include "hw/qdev-core.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/registerfields.h"
 #include "qom/object.h"
 
diff --git a/include/hw/remote/proxy-memory-listener.h b/include/hw/remote/proxy-memory-listener.h
index c4f3efb9285..0158b9d599c 100644
--- a/include/hw/remote/proxy-memory-listener.h
+++ b/include/hw/remote/proxy-memory-listener.h
@@ -9,7 +9,7 @@
 #ifndef PROXY_MEMORY_LISTENER_H
 #define PROXY_MEMORY_LISTENER_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "io/channel.h"
 
 typedef struct ProxyMemoryListener {
diff --git a/include/hw/sh4/sh_intc.h b/include/hw/sh4/sh_intc.h
index 65f34250572..0a1b8ae6edb 100644
--- a/include/hw/sh4/sh_intc.h
+++ b/include/hw/sh4/sh_intc.h
@@ -1,7 +1,7 @@
 #ifndef SH_INTC_H
 #define SH_INTC_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 typedef unsigned char intc_enum;
 
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 3564b7b6a22..79a757d8c90 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -4,7 +4,7 @@
 /* Devices attached directly to the main system bus.  */
 
 #include "hw/qdev-core.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qom/object.h"
 
 #define QDEV_MAX_MMIO 32
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
index d45c051b56a..ad80f8be284 100644
--- a/include/hw/timer/npcm7xx_timer.h
+++ b/include/hw/timer/npcm7xx_timer.h
@@ -16,7 +16,7 @@
 #ifndef NPCM7XX_TIMER_H
 #define NPCM7XX_TIMER_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 #include "qemu/timer.h"
 
diff --git a/include/hw/tricore/tricore.h b/include/hw/tricore/tricore.h
index c19ed3f013e..f12edcc390b 100644
--- a/include/hw/tricore/tricore.h
+++ b/include/hw/tricore/tricore.h
@@ -1,7 +1,7 @@
 #ifndef HW_TRICORE_H
 #define HW_TRICORE_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 struct tricore_boot_info {
     uint64_t ram_size;
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 436e07b3040..81936ea296e 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -25,7 +25,7 @@
  * THE SOFTWARE.
  */
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-core.h"
 #include "qemu/iov.h"
 #include "qemu/queue.h"
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 6141162d7ae..d9153b59eb9 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -21,7 +21,7 @@
 #ifndef HW_VFIO_VFIO_COMMON_H
 #define HW_VFIO_VFIO_COMMON_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/queue.h"
 #include "qemu/notify.h"
 #include "ui/console.h"
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index 8a6f8e2a7a3..92e09ab4cd2 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -11,7 +11,7 @@
 #ifndef VHOST_BACKEND_H
 #define VHOST_BACKEND_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 typedef enum VhostBackendType {
     VHOST_BACKEND_TYPE_NONE = 0,
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 4a8bc75415f..58c61d44da0 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -3,7 +3,7 @@
 
 #include "hw/virtio/vhost-backend.h"
 #include "hw/virtio/virtio.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 /* Generic structures common for any vhost based device. */
 
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 8bab9cfb750..c0e7dec20ca 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -14,7 +14,7 @@
 #ifndef QEMU_VIRTIO_H
 #define QEMU_VIRTIO_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-core.h"
 #include "net/net.h"
 #include "migration/vmstate.h"
diff --git a/include/hw/xtensa/mx_pic.h b/include/hw/xtensa/mx_pic.h
index 500424c8d35..a2baeb4bbbd 100644
--- a/include/hw/xtensa/mx_pic.h
+++ b/include/hw/xtensa/mx_pic.h
@@ -28,7 +28,7 @@
 #ifndef XTENSA_MX_PIC_H
 #define XTENSA_MX_PIC_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 struct XtensaMxPic;
 typedef struct XtensaMxPic XtensaMxPic;
diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h
index 1530cf0e95e..6cced122ac3 100644
--- a/include/qemu/iova-tree.h
+++ b/include/qemu/iova-tree.h
@@ -23,7 +23,7 @@
  * for the thread safety issue.
  */
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/sysemu/hwaddr.h"
 
 #define  IOVA_OK           (0)
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
index 3201e7901db..d06482d8c54 100644
--- a/include/sysemu/dma.h
+++ b/include/sysemu/dma.h
@@ -10,7 +10,7 @@
 #ifndef DMA_H
 #define DMA_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 #include "block/block.h"
 #include "block/accounting.h"
diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
index df5644723a3..1693e762e15 100644
--- a/include/sysemu/hostmem.h
+++ b/include/sysemu/hostmem.h
@@ -16,7 +16,7 @@
 #include "sysemu/numa.h"
 #include "qapi/qapi-types-machine.h"
 #include "qom/object.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/bitmap.h"
 
 #define TYPE_MEMORY_BACKEND "memory-backend"
diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
index ccb8869f01b..974179cbc4a 100644
--- a/include/sysemu/kvm_int.h
+++ b/include/sysemu/kvm_int.h
@@ -9,7 +9,7 @@
 #ifndef QEMU_KVM_INT_H
 #define QEMU_KVM_INT_H
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/accel.h"
 #include "sysemu/kvm.h"
 
diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h
index 4b20f1a639e..435e99988d8 100644
--- a/include/sysemu/memory_mapping.h
+++ b/include/sysemu/memory_mapping.h
@@ -16,7 +16,7 @@
 
 #include "qemu/queue.h"
 #include "exec/cpu-defs.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 typedef struct GuestPhysBlock {
     /* visible to guest, reflects PCI hole, etc */
diff --git a/include/sysemu/vhost-user-backend.h b/include/sysemu/vhost-user-backend.h
index 327b0b84f1f..7c8bcfd4fc9 100644
--- a/include/sysemu/vhost-user-backend.h
+++ b/include/sysemu/vhost-user-backend.h
@@ -13,7 +13,7 @@
 #define QEMU_VHOST_USER_BACKEND_H
 
 #include "qom/object.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/option.h"
 #include "qemu/bitmap.h"
 #include "hw/virtio/vhost.h"
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index 34f8daa3775..8aea3cd9171 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -12,7 +12,7 @@
 #define QEMU_KVM_ARM_H
 
 #include "sysemu/kvm.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/error-report.h"
 
 #define KVM_ARM_VGIC_V2   (1 << 0)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4e0168e88b9..204fc0403ca 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -31,7 +31,7 @@
 #include "sysemu/runstate.h"
 #include "sysemu/cpus.h"
 #include "qemu/bswap.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/ram_addr.h"
 #include "qemu/event_notifier.h"
 #include "qemu/main-loop.h"
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 452029e8193..9ecc45180a5 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -21,7 +21,7 @@
 #include "qemu/main-loop.h"
 #include "hw/core/tcg-cpu-ops.h"
 #include "exec/exec-all.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/cpu_ldst.h"
 #include "exec/sysemu/cputlb.h"
 #include "exec/tb-hash.h"
diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index a6e6d3e72f1..9a7ee6281db 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -24,7 +24,7 @@
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "tpm_int.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/qdev-properties.h"
 #include "sysemu/tpm_backend.h"
 #include "sysemu/tpm_util.h"
diff --git a/hw/avr/atmega.c b/hw/avr/atmega.c
index 80b8a41cb5a..7ccbb80194c 100644
--- a/hw/avr/atmega.c
+++ b/hw/avr/atmega.c
@@ -12,7 +12,7 @@
 #include "qemu/module.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 5fe082ec34c..486a1a00f6d 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -147,7 +147,7 @@
 #include "qapi/visitor.h"
 #include "sysemu/hostmem.h"
 #include "sysemu/block-backend.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qemu/cutils.h"
diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index afc0cd3a0ff..15f18871344 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -26,7 +26,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "sysemu/block-backend.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
 #include "qemu/error-report.h"
diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c
index b7c7b3ba94d..37266aa19ee 100644
--- a/hw/core/loader-fit.c
+++ b/hw/core/loader-fit.c
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/units.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/loader.h"
 #include "hw/loader-fit.h"
 #include "qemu/cutils.h"
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 5b34869a541..8807367dd9e 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -56,7 +56,7 @@
 #include "uboot_image.h"
 #include "hw/loader.h"
 #include "hw/nvram/fw_cfg.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/boards.h"
 #include "qemu/cutils.h"
 #include "sysemu/runstate.h"
diff --git a/hw/display/edid-region.c b/hw/display/edid-region.c
index 675429dc18b..174e26066f7 100644
--- a/hw/display/edid-region.c
+++ b/hw/display/edid-region.c
@@ -1,5 +1,5 @@
 #include "qemu/osdep.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/display/edid.h"
 
 static uint64_t edid_region_read(void *ptr, hwaddr addr, unsigned size)
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
index 1f28223c7be..f1dfa7f0b6b 100644
--- a/hw/display/tc6393xb.c
+++ b/hw/display/tc6393xb.c
@@ -16,7 +16,7 @@
 #include "qemu/host-utils.h"
 #include "hw/irq.h"
 #include "hw/display/tc6393xb.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/block/flash.h"
 #include "ui/console.h"
 #include "ui/pixel_ops.h"
diff --git a/hw/i386/acpi-common.c b/hw/i386/acpi-common.c
index 1f5947fcf96..2c89ac4b53d 100644
--- a/hw/i386/acpi-common.c
+++ b/hw/i386/acpi-common.c
@@ -23,7 +23,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
 #include "hw/acpi/utils.h"
diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
index 1a0f77b9111..dd6eeead376 100644
--- a/hw/i386/acpi-microvm.c
+++ b/hw/i386/acpi-microvm.c
@@ -24,7 +24,7 @@
 #include "qemu/cutils.h"
 #include "qapi/error.h"
 
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
 #include "hw/acpi/bios-linker-loader.h"
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 8cfaf216e7b..c56dc38fde7 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -64,7 +64,7 @@
 #include "hw/xen/xen.h"
 #include "hw/xen/start_info.h"
 #include "ui/qemu-spice.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "sysemu/arch_init.h"
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 30b8bd6ea92..a310cd6d608 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -46,7 +46,7 @@
 #include "sysemu/arch_init.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/xen/xen-x86.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/acpi/acpi.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
diff --git a/hw/intc/mips_gic.c b/hw/intc/mips_gic.c
index bda45499258..4f51fc5a1cc 100644
--- a/hw/intc/mips_gic.c
+++ b/hw/intc/mips_gic.c
@@ -14,7 +14,7 @@
 #include "qemu/module.h"
 #include "qapi/error.h"
 #include "hw/sysbus.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "sysemu/kvm.h"
 #include "sysemu/reset.h"
 #include "kvm_mips.h"
diff --git a/hw/intc/ompic.c b/hw/intc/ompic.c
index 1f10314807d..6a899eef19d 100644
--- a/hw/intc/ompic.c
+++ b/hw/intc/ompic.c
@@ -13,7 +13,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qom/object.h"
 
 #define TYPE_OR1K_OMPIC "or1k-ompic"
diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c
index 10de7a55236..cec48723d63 100644
--- a/hw/misc/omap_gpmc.c
+++ b/hw/misc/omap_gpmc.c
@@ -23,7 +23,7 @@
 #include "hw/irq.h"
 #include "hw/block/flash.h"
 #include "hw/arm/omap.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 
 /* General-Purpose Memory Controller */
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 6c17ee1ae21..1cfdb8bb8ed 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "net/eth.h"
 #include "qemu/module.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/irq.h"
 #include "migration/vmstate.h"
 #include "ne2000.h"
diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c
index 3d1205b8bd7..1efc61ee7c4 100644
--- a/hw/nios2/10m50_devboard.c
+++ b/hw/nios2/10m50_devboard.c
@@ -30,7 +30,7 @@
 #include "hw/qdev-properties.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 #include "qemu/config-file.h"
 
diff --git a/hw/nios2/generic_nommu.c b/hw/nios2/generic_nommu.c
index fbc18dbd04c..2888de27086 100644
--- a/hw/nios2/generic_nommu.c
+++ b/hw/nios2/generic_nommu.c
@@ -32,7 +32,7 @@
 
 #include "hw/char/serial.h"
 #include "hw/boards.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 #include "qemu/config-file.h"
 
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index 657a06ddbe8..36e3abea0e2 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -28,7 +28,7 @@
 #include "hw/pci/shpc.h"
 #include "hw/pci/slotid_cap.h"
 #include "hw/qdev-properties.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/hotplug.h"
 #include "qom/object.h"
diff --git a/hw/pci-host/remote.c b/hw/pci-host/remote.c
index eee45444ef7..b1efe292f75 100644
--- a/hw/pci-host/remote.c
+++ b/hw/pci-host/remote.c
@@ -29,7 +29,7 @@
 #include "hw/pci/pcie_host.h"
 #include "hw/qdev-properties.h"
 #include "hw/pci-host/remote.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 static const char *remote_pcihost_root_bus_path(PCIHostState *host_bridge,
                                                 PCIBus *rootbus)
diff --git a/hw/ppc/pnv_homer.c b/hw/ppc/pnv_homer.c
index 394425232ed..164106d0628 100644
--- a/hw/ppc/pnv_homer.c
+++ b/hw/ppc/pnv_homer.c
@@ -20,7 +20,7 @@
 #include "qemu/log.h"
 #include "qapi/error.h"
 #include "exec/sysemu/hwaddr.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "sysemu/cpus.h"
 #include "hw/qdev-core.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c
index 993e3ba955d..56cbec984a6 100644
--- a/hw/ppc/ppc440_uc.c
+++ b/hw/ppc/ppc440_uc.c
@@ -15,7 +15,7 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "hw/irq.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/ppc/ppc.h"
 #include "hw/qdev-properties.h"
 #include "hw/pci/pci.h"
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 0737234d66e..0f3bf1c5e42 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -24,7 +24,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
 #include "elf.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "ppc440.h"
 #include "ppc405.h"
 #include "hw/block/flash.h"
diff --git a/hw/remote/machine.c b/hw/remote/machine.c
index 952105eab5a..3adac7186f5 100644
--- a/hw/remote/machine.c
+++ b/hw/remote/machine.c
@@ -17,7 +17,7 @@
 #include "qemu-common.h"
 
 #include "hw/remote/machine.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qapi/error.h"
 #include "hw/pci/pci_host.h"
 #include "hw/remote/iohub.h"
diff --git a/hw/remote/proxy-memory-listener.c b/hw/remote/proxy-memory-listener.c
index 901dbf13573..d9bed35fa2f 100644
--- a/hw/remote/proxy-memory-listener.c
+++ b/hw/remote/proxy-memory-listener.c
@@ -12,7 +12,7 @@
 #include "qemu/compiler.h"
 #include "qemu/int128.h"
 #include "qemu/range.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/cpu-common.h"
 #include "exec/ram_addr.h"
 #include "qapi/error.h"
diff --git a/hw/timer/sh_timer.c b/hw/timer/sh_timer.c
index 58af1a1edbd..c40c1fd7467 100644
--- a/hw/timer/sh_timer.c
+++ b/hw/timer/sh_timer.c
@@ -9,7 +9,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
 #include "hw/sh4/sh.h"
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index ae5654fcdb8..472ab394109 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -28,7 +28,7 @@
 #include "hw/vfio/vfio-common.h"
 #include "hw/vfio/vfio.h"
 #include "exec/address-spaces.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/ram_addr.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index cc3f66f7e44..ea9bcdf2bf7 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -26,7 +26,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "qemu/range.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 #include "qemu/queue.h"
 #include "hw/sysbus.h"
diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c
index 2028fe793d9..5571f96728d 100644
--- a/hw/xtensa/sim.c
+++ b/hw/xtensa/sim.c
@@ -32,7 +32,7 @@
 #include "hw/boards.h"
 #include "hw/loader.h"
 #include "elf.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/error-report.h"
 #include "xtensa_memory.h"
 #include "xtensa_sim.h"
diff --git a/hw/xtensa/virt.c b/hw/xtensa/virt.c
index a18e3fc910e..c184919958c 100644
--- a/hw/xtensa/virt.c
+++ b/hw/xtensa/virt.c
@@ -33,7 +33,7 @@
 #include "hw/pci-host/gpex.h"
 #include "net/net.h"
 #include "elf.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/error-report.h"
 #include "xtensa_memory.h"
 #include "xtensa_sim.h"
diff --git a/hw/xtensa/xtensa_memory.c b/hw/xtensa/xtensa_memory.c
index 2c1095f0170..1793869a96e 100644
--- a/hw/xtensa/xtensa_memory.c
+++ b/hw/xtensa/xtensa_memory.c
@@ -27,7 +27,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/error-report.h"
 #include "xtensa_memory.h"
 
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 17f087b3951..caaf223a997 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -34,7 +34,7 @@
 #include "hw/loader.h"
 #include "hw/qdev-properties.h"
 #include "elf.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/char/serial.h"
 #include "net/net.h"
 #include "hw/sysbus.h"
diff --git a/migration/rdma.c b/migration/rdma.c
index 00eac34232e..7c541ffae0e 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -29,7 +29,7 @@
 #include "qemu/sockets.h"
 #include "qemu/bitmap.h"
 #include "qemu/coroutine.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include <sys/socket.h>
 #include <netdb.h>
 #include <arpa/inet.h>
diff --git a/migration/savevm.c b/migration/savevm.c
index 52e2d72e4b0..83f3df249f1 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -48,7 +48,7 @@
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "sysemu/cpus.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/target_page.h"
 #include "trace.h"
 #include "qemu/iov.h"
diff --git a/monitor/misc.c b/monitor/misc.c
index f3a393ea590..c1fcd995805 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -59,7 +59,7 @@
 #ifdef CONFIG_TRACE_SIMPLE
 #include "trace/simple.h"
 #endif
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/exec-all.h"
 #include "qemu/option.h"
 #include "qemu/thread.h"
diff --git a/softmmu/ioport.c b/softmmu/ioport.c
index cb8adb0b936..dfb9fbc7ffa 100644
--- a/softmmu/ioport.c
+++ b/softmmu/ioport.c
@@ -28,7 +28,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/ioport.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 #include "trace.h"
 
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 3bb533c0bce..d5ab46d76a9 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -16,7 +16,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "qapi/error.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qapi/visitor.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
index e7af2765466..60ff72790ea 100644
--- a/softmmu/memory_mapping.c
+++ b/softmmu/memory_mapping.c
@@ -15,7 +15,7 @@
 #include "qapi/error.h"
 
 #include "sysemu/memory_mapping.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/address-spaces.h"
 
 //#define DEBUG_GUEST_PHYS_REGION_ADD
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index e1da81ed2f9..20e69b09d68 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -41,7 +41,7 @@
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "qemu/qemu-print.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/ioport.h"
 #include "sysemu/dma.h"
 #include "sysemu/hostmem.h"
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 130c3666154..f1ee4fbc369 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -18,7 +18,7 @@
 #include "sysemu/runstate.h"
 #include "chardev/char-fe.h"
 #include "exec/ioport.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "hw/irq.h"
 #include "qemu/accel.h"
 #include "sysemu/cpu-timers.h"
diff --git a/stubs/ram-block.c b/stubs/ram-block.c
index 108197683bb..02ebd94ebaf 100644
--- a/stubs/ram-block.c
+++ b/stubs/ram-block.c
@@ -1,7 +1,7 @@
 #include "qemu/osdep.h"
 #include "exec/ramlist.h"
 #include "exec/cpu-common.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 
 void *qemu_ram_get_host_addr(RAMBlock *rb)
 {
diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
index 7ea90d414aa..286460bcc05 100644
--- a/target/s390x/misc_helper.c
+++ b/target/s390x/misc_helper.c
@@ -23,7 +23,6 @@
 #include "qemu/main-loop.h"
 #include "cpu.h"
 #include "internal.h"
-#include "exec/memory.h"
 #include "qemu/host-utils.h"
 #include "exec/helper-proto.h"
 #include "qemu/timer.h"
@@ -34,6 +33,7 @@
 #include "s390-tod.h"
 
 #if !defined(CONFIG_USER_ONLY)
+#include "exec/sysemu/memory.h"
 #include "sysemu/cpus.h"
 #include "sysemu/sysemu.h"
 #include "hw/s390x/ebcdic.h"
diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
index cea7d4058e8..05f9c9b06f9 100644
--- a/tests/qtest/fuzz/generic_fuzz.c
+++ b/tests/qtest/fuzz/generic_fuzz.c
@@ -20,7 +20,7 @@
 #include "fuzz.h"
 #include "fork_fuzz.h"
 #include "string.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "exec/ramblock.h"
 #include "hw/qdev-core.h"
 #include "hw/pci/pci.h"
diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c
index 7a244c951e5..8301c1d9c69 100644
--- a/tests/qtest/fuzz/qos_fuzz.c
+++ b/tests/qtest/fuzz/qos_fuzz.c
@@ -20,7 +20,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "qemu/main-loop.h"
 
 #include "tests/qtest/libqos/libqtest.h"
diff --git a/ui/console.c b/ui/console.c
index 2de5f4105b5..e9728a816d0 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -32,7 +32,7 @@
 #include "qemu/timer.h"
 #include "chardev/char-fe.h"
 #include "trace.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "io/channel-file.h"
 #include "qom/object.h"
 
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 911115b86e6..28cca261c2c 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -16,7 +16,7 @@
 #include "qapi/error.h"
 #include "exec/ramlist.h"
 #include "exec/cpu-common.h"
-#include "exec/memory.h"
+#include "exec/sysemu/memory.h"
 #include "trace.h"
 #include "qemu/error-report.h"
 #include "standard-headers/linux/pci_regs.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index 4378ec47a2c..d515a954b2b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2400,7 +2400,7 @@ M: Paolo Bonzini <pbonzini@redhat.com>
 S: Supported
 F: include/exec/ioport.h
 F: include/exec/memop.h
-F: include/exec/memory.h
+F: include/exec/sysemu/memory.h
 F: include/exec/ram_addr.h
 F: include/exec/ramblock.h
 F: softmmu/dma-helpers.c
diff --git a/scripts/analyze-inclusions b/scripts/analyze-inclusions
index 14806e18c6e..28e60791a61 100644
--- a/scripts/analyze-inclusions
+++ b/scripts/analyze-inclusions
@@ -54,7 +54,7 @@ echo $(grep_include -F 'trace/generated-tracers.h') files include generated-trac
 echo $(grep_include -F 'qapi/error.h') files include qapi/error.h
 echo $(grep_include -F 'qom/object.h') files include qom/object.h
 echo $(grep_include -F 'block/aio.h') files include block/aio.h
-echo $(grep_include -F 'exec/memory.h') files include exec/memory.h
+echo $(grep_include -F 'exec/sysemu/memory.h') files include exec/memory.h
 echo $(grep_include -F 'fpu/softfloat.h') files include fpu/softfloat.h
 echo $(grep_include -F 'qemu/bswap.h') files include qemu/bswap.h
 echo
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/11] exec: Restrict memory-internal.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 04/11] exec: Restrict memory.h " Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 06/11] exec: Restrict address-spaces.h " Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the memory-internal.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/memory-internal.h,exec/sysemu/memory-internal.h, $(git grep -l exec/memory-internal.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/exec/{ => sysemu}/memory-internal.h | 7 +++++--
 accel/tcg/cputlb.c                          | 2 +-
 hw/s390x/s390-pci-inst.c                    | 2 +-
 softmmu/memory.c                            | 2 +-
 softmmu/physmem.c                           | 2 +-
 MAINTAINERS                                 | 2 +-
 6 files changed, 10 insertions(+), 7 deletions(-)
 rename include/exec/{ => sysemu}/memory-internal.h (94%)

diff --git a/include/exec/memory-internal.h b/include/exec/sysemu/memory-internal.h
similarity index 94%
rename from include/exec/memory-internal.h
rename to include/exec/sysemu/memory-internal.h
index 9fcc2af25c8..f3459d687ad 100644
--- a/include/exec/memory-internal.h
+++ b/include/exec/sysemu/memory-internal.h
@@ -20,9 +20,12 @@
 #ifndef MEMORY_INTERNAL_H
 #define MEMORY_INTERNAL_H
 
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
+
 #include "cpu.h"
 
-#ifndef CONFIG_USER_ONLY
 static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv)
 {
     return fv->dispatch;
@@ -49,5 +52,5 @@ void address_space_dispatch_free(AddressSpaceDispatch *d);
 
 void mtree_print_dispatch(struct AddressSpaceDispatch *d,
                           MemoryRegion *root);
-#endif
+
 #endif
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 9ecc45180a5..14a4ee4ed63 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -25,7 +25,7 @@
 #include "exec/cpu_ldst.h"
 #include "exec/sysemu/cputlb.h"
 #include "exec/tb-hash.h"
-#include "exec/memory-internal.h"
+#include "exec/sysemu/memory-internal.h"
 #include "exec/ram_addr.h"
 #include "tcg/tcg.h"
 #include "qemu/error-report.h"
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 9ec277d50e7..0c88787d134 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "exec/memop.h"
-#include "exec/memory-internal.h"
+#include "exec/sysemu/memory-internal.h"
 #include "qemu/error-report.h"
 #include "sysemu/hw_accel.h"
 #include "hw/s390x/s390-pci-inst.h"
diff --git a/softmmu/memory.c b/softmmu/memory.c
index d5ab46d76a9..cdc935cdd27 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -25,7 +25,7 @@
 #include "qom/object.h"
 #include "trace.h"
 
-#include "exec/memory-internal.h"
+#include "exec/sysemu/memory-internal.h"
 #include "exec/ram_addr.h"
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 20e69b09d68..31e490185f3 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -58,7 +58,7 @@
 #include "exec/translate-all.h"
 #include "sysemu/replay.h"
 
-#include "exec/memory-internal.h"
+#include "exec/sysemu/memory-internal.h"
 #include "exec/ram_addr.h"
 #include "exec/log.h"
 
diff --git a/MAINTAINERS b/MAINTAINERS
index d515a954b2b..48ae2145513 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2407,7 +2407,7 @@ F: softmmu/dma-helpers.c
 F: softmmu/ioport.c
 F: softmmu/memory.c
 F: softmmu/physmem.c
-F: include/exec/memory-internal.h
+F: include/exec/sysemu/memory-internal.h
 F: scripts/coccinelle/memory-region-housekeeping.cocci
 
 SPICE
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/11] exec: Restrict address-spaces.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 05/11] exec: Restrict memory-internal.h " Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 07/11] exec: Extract CPU I/O instructions to "cpu-io.h" Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the address-spaces.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/address-spaces.h,exec/sysemu/address-spaces.h, $(git grep -l exec/address-spaces.h)

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/net/i82596.h                            |  2 +-
 hw/s390x/ipl.h                             |  2 +-
 hw/tpm/tpm_ppi.h                           |  2 +-
 include/exec/{ => sysemu}/address-spaces.h | 12 ++++++------
 include/hw/nubus/nubus.h                   |  2 +-
 include/hw/tricore/triboard.h              |  2 +-
 include/sysemu/dma.h                       |  2 +-
 target/i386/hvf/vmx.h                      |  2 +-
 cpu.c                                      |  2 +-
 hw/arm/collie.c                            |  2 +-
 hw/arm/exynos4_boards.c                    |  2 +-
 hw/arm/fsl-imx31.c                         |  2 +-
 hw/arm/gumstix.c                           |  2 +-
 hw/arm/integratorcp.c                      |  2 +-
 hw/arm/kzm.c                               |  2 +-
 hw/arm/mainstone.c                         |  2 +-
 hw/arm/microbit.c                          |  2 +-
 hw/arm/mps2-tz.c                           |  2 +-
 hw/arm/mps2.c                              |  2 +-
 hw/arm/msf2-soc.c                          |  2 +-
 hw/arm/msf2-som.c                          |  2 +-
 hw/arm/musca.c                             |  2 +-
 hw/arm/omap1.c                             |  2 +-
 hw/arm/omap2.c                             |  2 +-
 hw/arm/omap_sx1.c                          |  2 +-
 hw/arm/orangepi.c                          |  2 +-
 hw/arm/spitz.c                             |  2 +-
 hw/arm/stellaris.c                         |  2 +-
 hw/arm/stm32f205_soc.c                     |  2 +-
 hw/arm/stm32f405_soc.c                     |  2 +-
 hw/arm/tosa.c                              |  2 +-
 hw/arm/z2.c                                |  2 +-
 hw/avr/atmega.c                            |  2 +-
 hw/char/goldfish_tty.c                     |  2 +-
 hw/char/omap_uart.c                        |  2 +-
 hw/core/null-machine.c                     |  2 +-
 hw/core/sysbus.c                           |  2 +-
 hw/dma/etraxfs_dma.c                       |  2 +-
 hw/dma/rc4030.c                            |  2 +-
 hw/hyperv/hyperv.c                         |  2 +-
 hw/input/lasips2.c                         |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c        |  2 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c   |  2 +-
 hw/microblaze/xlnx-zynqmp-pmu.c            |  2 +-
 hw/misc/allwinner-h3-dramc.c               |  2 +-
 hw/misc/omap_gpmc.c                        |  2 +-
 hw/nios2/10m50_devboard.c                  |  2 +-
 hw/nios2/generic_nommu.c                   |  2 +-
 hw/pci-host/mv64361.c                      |  2 +-
 hw/ppc/pegasos2.c                          |  2 +-
 hw/ppc/ppc405_uc.c                         |  2 +-
 hw/ppc/ppc4xx_devs.c                       |  2 +-
 hw/ppc/prep_systemio.c                     |  2 +-
 hw/ppc/rs6000_mc.c                         |  2 +-
 hw/ppc/spapr_ovec.c                        |  2 +-
 hw/riscv/shakti_c.c                        |  2 +-
 hw/s390x/css.c                             |  2 +-
 hw/sparc/sun4m_iommu.c                     |  2 +-
 hw/sparc64/sun4u_iommu.c                   |  2 +-
 hw/timer/hpet.c                            |  2 +-
 hw/vfio/ap.c                               |  2 +-
 hw/vfio/ccw.c                              |  2 +-
 hw/vfio/common.c                           |  2 +-
 hw/vfio/platform.c                         |  2 +-
 hw/virtio/virtio-balloon.c                 |  2 +-
 hw/virtio/virtio-bus.c                     |  2 +-
 semihosting/arm-compat-semi.c              |  2 +-
 softmmu/ioport.c                           |  2 +-
 softmmu/memory_mapping.c                   |  2 +-
 target/arm/kvm.c                           |  2 +-
 target/avr/helper.c                        |  2 +-
 target/i386/cpu-sysemu.c                   |  2 +-
 target/i386/cpu.c                          |  2 +-
 target/i386/hax/hax-all.c                  |  2 +-
 target/i386/hax/hax-mem.c                  |  2 +-
 target/i386/nvmm/nvmm-all.c                |  2 +-
 target/i386/tcg/sysemu/misc_helper.c       |  2 +-
 target/i386/tcg/sysemu/tcg-cpu.c           |  2 +-
 target/i386/whpx/whpx-all.c                |  2 +-
 target/s390x/excp_helper.c                 |  2 +-
 target/s390x/mmu_helper.c                  |  2 +-
 target/s390x/sigp.c                        |  2 +-
 target/xtensa/dbg_helper.c                 |  2 +-
 83 files changed, 88 insertions(+), 88 deletions(-)
 rename include/exec/{ => sysemu}/address-spaces.h (84%)

diff --git a/hw/net/i82596.h b/hw/net/i82596.h
index de5cc7d0c5b..478b5237b3e 100644
--- a/hw/net/i82596.h
+++ b/hw/net/i82596.h
@@ -4,7 +4,7 @@
 #define I82596_IOPORT_SIZE       0x20
 
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 #define PORT_RESET              0x00    /* reset 82596 */
 #define PORT_SELFTEST           0x01    /* selftest */
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index dfc6dfd89c8..6f3ca5ba57f 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -14,7 +14,7 @@
 #define HW_S390_IPL_H
 
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
diff --git a/hw/tpm/tpm_ppi.h b/hw/tpm/tpm_ppi.h
index 6f773c25a0b..c88c24facdb 100644
--- a/hw/tpm/tpm_ppi.h
+++ b/hw/tpm/tpm_ppi.h
@@ -12,7 +12,7 @@
 #ifndef TPM_TPM_PPI_H
 #define TPM_TPM_PPI_H
 
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 typedef struct TPMPPI {
     MemoryRegion ram;
diff --git a/include/exec/address-spaces.h b/include/exec/sysemu/address-spaces.h
similarity index 84%
rename from include/exec/address-spaces.h
rename to include/exec/sysemu/address-spaces.h
index b7533b33f72..800c0206ddd 100644
--- a/include/exec/address-spaces.h
+++ b/include/exec/sysemu/address-spaces.h
@@ -11,8 +11,12 @@
  *
  */
 
-#ifndef EXEC_ADDRESS_SPACES_H
-#define EXEC_ADDRESS_SPACES_H
+#ifndef EXEC_SYSEMU_ADDRESS_SPACES_H
+#define EXEC_SYSEMU_ADDRESS_SPACES_H
+
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
 
 /*
  * Internal interfaces between memory.c/exec.c/vl.c.  Do not #include unless
@@ -21,8 +25,6 @@
 
 #include "exec/sysemu/memory.h"
 
-#ifndef CONFIG_USER_ONLY
-
 /* Get the root memory region.  This interface should only be used temporarily
  * until a proper bus interface is available.
  */
@@ -37,5 +39,3 @@ extern AddressSpace address_space_memory;
 extern AddressSpace address_space_io;
 
 #endif
-
-#endif
diff --git a/include/hw/nubus/nubus.h b/include/hw/nubus/nubus.h
index e2b5cf260ba..9ea894f2fd0 100644
--- a/include/hw/nubus/nubus.h
+++ b/include/hw/nubus/nubus.h
@@ -10,7 +10,7 @@
 #define HW_NUBUS_NUBUS_H
 
 #include "hw/qdev-properties.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qom/object.h"
 
 #define NUBUS_SUPER_SLOT_SIZE 0x10000000U
diff --git a/include/hw/tricore/triboard.h b/include/hw/tricore/triboard.h
index f3844be447a..e2f1787df7c 100644
--- a/include/hw/tricore/triboard.h
+++ b/include/hw/tricore/triboard.h
@@ -23,7 +23,7 @@
 #include "hw/boards.h"
 #include "hw/arm/boot.h"
 #include "sysemu/sysemu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qom/object.h"
 
 #include "hw/tricore/tc27x_soc.h"
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
index d06482d8c54..3f69547ef24 100644
--- a/include/sysemu/dma.h
+++ b/include/sysemu/dma.h
@@ -11,7 +11,7 @@
 #define DMA_H
 
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "block/block.h"
 #include "block/accounting.h"
 
diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h
index 24c4cdf0be0..7ef6064ee94 100644
--- a/target/i386/hvf/vmx.h
+++ b/target/i386/hvf/vmx.h
@@ -31,7 +31,7 @@
 #include "cpu.h"
 #include "x86.h"
 
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 static inline uint64_t rreg(hv_vcpuid_t vcpu, hv_x86_reg_t reg)
 {
diff --git a/cpu.c b/cpu.c
index 164fefeaa35..0df444c7358 100644
--- a/cpu.c
+++ b/cpu.c
@@ -30,7 +30,7 @@
 #include "qemu.h"
 #else
 #include "hw/core/sysemu-cpu-ops.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #endif
 #include "sysemu/tcg.h"
 #include "sysemu/kvm.h"
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index 8df31e27932..c989fcbbe93 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -16,7 +16,7 @@
 #include "strongarm.h"
 #include "hw/arm/boot.h"
 #include "hw/block/flash.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "cpu.h"
 #include "qom/object.h"
 
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index 35dd9875da1..59cfd1d1e01 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -28,7 +28,7 @@
 #include "hw/sysbus.h"
 #include "net/net.h"
 #include "hw/arm/boot.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/arm/exynos4210.h"
 #include "hw/net/lan9118.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index def27bb9136..1af0987b87f 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -23,7 +23,7 @@
 #include "qapi/error.h"
 #include "hw/arm/fsl-imx31.h"
 #include "sysemu/sysemu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/qdev-properties.h"
 #include "chardev/char.h"
 
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 3a4bc332c42..aea5e69efc0 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -41,7 +41,7 @@
 #include "hw/block/flash.h"
 #include "hw/net/smc91c111.h"
 #include "hw/boards.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/qtest.h"
 #include "cpu.h"
 
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 16e89859539..dd96c63e362 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -17,7 +17,7 @@
 #include "hw/misc/arm_integrator_debug.h"
 #include "hw/net/smc91c111.h"
 #include "net/net.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
 #include "qemu/log.h"
diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c
index 39559c44c29..4a9996b3387 100644
--- a/hw/arm/kzm.c
+++ b/hw/arm/kzm.c
@@ -18,7 +18,7 @@
 #include "hw/arm/fsl-imx31.h"
 #include "hw/boards.h"
 #include "qemu/error-report.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "net/net.h"
 #include "hw/net/lan9118.h"
 #include "hw/char/serial.h"
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 8454b654585..53a6f6a643e 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -21,7 +21,7 @@
 #include "hw/boards.h"
 #include "hw/block/flash.h"
 #include "hw/sysbus.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "cpu.h"
 
 /* Device addresses */
diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c
index e9494334ce7..8c8dc96f75f 100644
--- a/hw/arm/microbit.c
+++ b/hw/arm/microbit.c
@@ -13,7 +13,7 @@
 #include "hw/boards.h"
 #include "hw/arm/boot.h"
 #include "sysemu/sysemu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 #include "hw/arm/nrf51_soc.h"
 #include "hw/i2c/microbit_i2c.h"
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
index 70aa31a7f6c..d8df945188d 100644
--- a/hw/arm/mps2-tz.c
+++ b/hw/arm/mps2-tz.c
@@ -53,7 +53,7 @@
 #include "hw/arm/armv7m.h"
 #include "hw/or-irq.h"
 #include "hw/boards.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/reset.h"
 #include "hw/misc/unimp.h"
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
index 81413b7133e..cb6cf03ecc5 100644
--- a/hw/arm/mps2.c
+++ b/hw/arm/mps2.c
@@ -33,7 +33,7 @@
 #include "hw/arm/armv7m.h"
 #include "hw/or-irq.h"
 #include "hw/boards.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "hw/misc/unimp.h"
 #include "hw/char/cmsdk-apb-uart.h"
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 5cfe7caf834..e977aa4b378 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "qapi/error.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/char/serial.h"
 #include "hw/arm/msf2-soc.h"
 #include "hw/misc/unimp.h"
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
index 343ec977c07..e007bcbe1e4 100644
--- a/hw/arm/msf2-som.c
+++ b/hw/arm/msf2-som.c
@@ -29,7 +29,7 @@
 #include "hw/boards.h"
 #include "hw/qdev-properties.h"
 #include "hw/arm/boot.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/arm/msf2-soc.h"
 
 #define DDR_BASE_ADDRESS      0xA0000000
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
index 7a83f7dda7d..71d34f0dac3 100644
--- a/hw/arm/musca.c
+++ b/hw/arm/musca.c
@@ -22,7 +22,7 @@
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "hw/arm/boot.h"
 #include "hw/arm/armsse.h"
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 180d3788f89..56e2ec3937b 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -23,7 +23,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index 02b1aa8c974..0984fdb46ad 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -22,7 +22,7 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/qtest.h"
 #include "sysemu/reset.h"
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index 57829b37441..5bc01c4645c 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -33,7 +33,7 @@
 #include "hw/arm/boot.h"
 #include "hw/block/flash.h"
 #include "sysemu/qtest.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "cpu.h"
 #include "qemu/cutils.h"
 
diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c
index 0cf9895ce79..ade08fb688d 100644
--- a/hw/arm/orangepi.c
+++ b/hw/arm/orangepi.c
@@ -19,7 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qapi/error.h"
 #include "hw/boards.h"
 #include "hw/qdev-properties.h"
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index b45a929cbd9..9634138ce5d 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -32,7 +32,7 @@
 #include "hw/sysbus.h"
 #include "hw/misc/max111x.h"
 #include "migration/vmstate.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "cpu.h"
 #include "qom/object.h"
 
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 8b4dab9b79f..9f13c5f649f 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -17,7 +17,7 @@
 #include "net/net.h"
 #include "hw/boards.h"
 #include "qemu/log.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "hw/arm/armv7m.h"
 #include "hw/char/pl011.h"
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 9cd41bf56da..5f0c603aabb 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -26,7 +26,7 @@
 #include "qapi/error.h"
 #include "qemu/module.h"
 #include "hw/arm/boot.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/arm/stm32f205_soc.h"
 #include "hw/qdev-properties.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index cb04c111987..bdd93f0127a 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -25,7 +25,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "hw/arm/stm32f405_soc.h"
 #include "hw/misc/unimp.h"
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index d5a6763cf9a..73dd2cff0bb 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -25,7 +25,7 @@
 #include "hw/ssi/ssi.h"
 #include "hw/sysbus.h"
 #include "hw/misc/led.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qom/object.h"
 
 #define TOSA_RAM 0x04000000
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 9c1e876207b..6d1c458b922 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -23,7 +23,7 @@
 #include "ui/console.h"
 #include "hw/audio/wm8750.h"
 #include "audio/audio.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "cpu.h"
 #include "qom/object.h"
 
diff --git a/hw/avr/atmega.c b/hw/avr/atmega.c
index 7ccbb80194c..e9b218f0270 100644
--- a/hw/avr/atmega.c
+++ b/hw/avr/atmega.c
@@ -13,7 +13,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/sysemu.h"
 #include "hw/qdev-properties.h"
 #include "hw/sysbus.h"
diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c
index 8365a187614..f882fd1ee25 100644
--- a/hw/char/goldfish_tty.c
+++ b/hw/char/goldfish_tty.c
@@ -15,7 +15,7 @@
 #include "chardev/char-fe.h"
 #include "qemu/log.h"
 #include "trace.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/char/goldfish_tty.h"
 
 #define GOLDFISH_TTY_VERSION 1
diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c
index e8da9333782..7ac760f60b0 100644
--- a/hw/char/omap_uart.c
+++ b/hw/char/omap_uart.c
@@ -21,7 +21,7 @@
 #include "chardev/char.h"
 #include "hw/arm/omap.h"
 #include "hw/char/serial.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 /* UARTs */
 struct omap_uart_s {
diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
index f586a4bef54..9586c1716ac 100644
--- a/hw/core/null-machine.c
+++ b/hw/core/null-machine.c
@@ -14,7 +14,7 @@
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
 #include "hw/boards.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/core/cpu.h"
 
 static void machine_none_init(MachineState *mch)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index aaae8e23cc4..f7ae45677d2 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -22,7 +22,7 @@
 #include "qemu/module.h"
 #include "hw/sysbus.h"
 #include "monitor/monitor.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 static char *sysbus_get_fw_dev_path(DeviceState *dev);
diff --git a/hw/dma/etraxfs_dma.c b/hw/dma/etraxfs_dma.c
index c4334e87bf5..9356f54e846 100644
--- a/hw/dma/etraxfs_dma.c
+++ b/hw/dma/etraxfs_dma.c
@@ -27,7 +27,7 @@
 #include "hw/irq.h"
 #include "qemu/main-loop.h"
 #include "sysemu/runstate.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 #include "hw/cris/etraxfs_dma.h"
 
diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
index e4d2f1725bc..e23bd30a10a 100644
--- a/hw/dma/rc4030.c
+++ b/hw/dma/rc4030.c
@@ -32,7 +32,7 @@
 #include "qemu/timer.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "trace.h"
 #include "qom/object.h"
 
diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index cb1074f234c..c3ef86f4f16 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -11,7 +11,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "qapi/error.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "sysemu/kvm.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index f84f37411fd..f5bd98b65cd 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -28,7 +28,7 @@
 #include "hw/input/lasips2.h"
 #include "exec/sysemu/hwaddr.h"
 #include "trace.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "migration/vmstate.h"
 #include "hw/irq.h"
 
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 159db6cbe22..17bd4a0f905 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -36,7 +36,7 @@
 #include "hw/boards.h"
 #include "hw/char/serial.h"
 #include "hw/qdev-properties.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/ssi/ssi.h"
 
 #include "boot.h"
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index 9d959d1ad80..82156e6e69f 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -33,7 +33,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
 #include "hw/misc/unimp.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/char/xilinx_uartlite.h"
 
 #include "boot.h"
diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index 5a2016672a3..2982461559b 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -17,7 +17,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/boards.h"
 #include "cpu.h"
 #include "boot.h"
diff --git a/hw/misc/allwinner-h3-dramc.c b/hw/misc/allwinner-h3-dramc.c
index 1d37cf422cd..cc050049089 100644
--- a/hw/misc/allwinner-h3-dramc.c
+++ b/hw/misc/allwinner-h3-dramc.c
@@ -24,7 +24,7 @@
 #include "migration/vmstate.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/qdev-properties.h"
 #include "qapi/error.h"
 #include "hw/misc/allwinner-h3-dramc.h"
diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c
index cec48723d63..99c803baec8 100644
--- a/hw/misc/omap_gpmc.c
+++ b/hw/misc/omap_gpmc.c
@@ -24,7 +24,7 @@
 #include "hw/block/flash.h"
 #include "hw/arm/omap.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 /* General-Purpose Memory Controller */
 struct omap_gpmc_s {
diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c
index 1efc61ee7c4..38452c0841c 100644
--- a/hw/nios2/10m50_devboard.c
+++ b/hw/nios2/10m50_devboard.c
@@ -31,7 +31,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/config-file.h"
 
 #include "boot.h"
diff --git a/hw/nios2/generic_nommu.c b/hw/nios2/generic_nommu.c
index 2888de27086..a1af8ba45d2 100644
--- a/hw/nios2/generic_nommu.c
+++ b/hw/nios2/generic_nommu.c
@@ -33,7 +33,7 @@
 #include "hw/char/serial.h"
 #include "hw/boards.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/config-file.h"
 
 #include "boot.h"
diff --git a/hw/pci-host/mv64361.c b/hw/pci-host/mv64361.c
index 20510d86803..ea7eb05c337 100644
--- a/hw/pci-host/mv64361.c
+++ b/hw/pci-host/mv64361.c
@@ -19,7 +19,7 @@
 #include "hw/irq.h"
 #include "hw/intc/i8259.h"
 #include "hw/qdev-properties.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/log.h"
 #include "qemu/error-report.h"
 #include "trace.h"
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index 0bfd0928aa5..e9454f123af 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -30,7 +30,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "trace.h"
 #include "qemu/datadir.h"
 #include "sysemu/device_tree.h"
diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c
index e632c408bdf..bbc1fb06a88 100644
--- a/hw/ppc/ppc405_uc.c
+++ b/hw/ppc/ppc405_uc.c
@@ -34,7 +34,7 @@
 #include "qemu/timer.h"
 #include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/intc/ppc-uic.h"
 #include "hw/qdev-properties.h"
 #include "qapi/error.h"
diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
index 980c48944fc..516c2bff74d 100644
--- a/hw/ppc/ppc4xx_devs.c
+++ b/hw/ppc/ppc4xx_devs.c
@@ -32,7 +32,7 @@
 #include "hw/intc/ppc-uic.h"
 #include "hw/qdev-properties.h"
 #include "qemu/log.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 
diff --git a/hw/ppc/prep_systemio.c b/hw/ppc/prep_systemio.c
index b2bd7832487..a89d24b8881 100644
--- a/hw/ppc/prep_systemio.c
+++ b/hw/ppc/prep_systemio.c
@@ -28,7 +28,7 @@
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qom/object.h"
 #include "qemu/error-report.h" /* for error_report() */
 #include "qemu/module.h"
diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
index c0bc212e924..f79df1cf01e 100644
--- a/hw/ppc/rs6000_mc.c
+++ b/hw/ppc/rs6000_mc.c
@@ -22,7 +22,7 @@
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qapi/error.h"
 #include "trace.h"
 #include "qom/object.h"
diff --git a/hw/ppc/spapr_ovec.c b/hw/ppc/spapr_ovec.c
index b2567caa5cf..5255d349c42 100644
--- a/hw/ppc/spapr_ovec.c
+++ b/hw/ppc/spapr_ovec.c
@@ -15,7 +15,7 @@
 #include "hw/ppc/spapr_ovec.h"
 #include "migration/vmstate.h"
 #include "qemu/bitmap.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/error-report.h"
 #include "trace.h"
 #include <libfdt.h>
diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c
index 18f70fadaa9..4c60b97ac72 100644
--- a/hw/riscv/shakti_c.c
+++ b/hw/riscv/shakti_c.c
@@ -24,7 +24,7 @@
 #include "hw/intc/sifive_clint.h"
 #include "sysemu/sysemu.h"
 #include "hw/qdev-properties.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/riscv/boot.h"
 
 
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index bed46f5ec3a..3b1fbb41295 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -14,7 +14,7 @@
 #include "qapi/visitor.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/s390x/ioinst.h"
 #include "hw/qdev-properties.h"
 #include "hw/s390x/css.h"
diff --git a/hw/sparc/sun4m_iommu.c b/hw/sparc/sun4m_iommu.c
index 71f5465249f..4cdce4af5c5 100644
--- a/hw/sparc/sun4m_iommu.c
+++ b/hw/sparc/sun4m_iommu.c
@@ -29,7 +29,7 @@
 #include "hw/sysbus.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "trace.h"
 
 /*
diff --git a/hw/sparc64/sun4u_iommu.c b/hw/sparc64/sun4u_iommu.c
index 9178277f824..189e2a13ec2 100644
--- a/hw/sparc64/sun4u_iommu.c
+++ b/hw/sparc64/sun4u_iommu.c
@@ -27,7 +27,7 @@
 #include "qemu/osdep.h"
 #include "hw/sysbus.h"
 #include "hw/sparc/sun4u_iommu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "trace.h"
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 9520471be2c..134fa55ecf5 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -36,7 +36,7 @@
 #include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
 #include "hw/timer/i8254.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qom/object.h"
 
 //#define HPET_DEBUG
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index 4b32aca1a05..18c35fd1982 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -25,7 +25,7 @@
 #include "migration/vmstate.h"
 #include "hw/qdev-properties.h"
 #include "hw/s390x/ap-bridge.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qom/object.h"
 
 #define TYPE_VFIO_AP_DEVICE      "vfio-ap"
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index e752c845e9e..2e4d1f27b6c 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -26,7 +26,7 @@
 #include "hw/s390x/vfio-ccw.h"
 #include "hw/qdev-properties.h"
 #include "hw/s390x/ccw-device.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 472ab394109..91171e4f658 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -27,7 +27,7 @@
 
 #include "hw/vfio/vfio-common.h"
 #include "hw/vfio/vfio.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "exec/sysemu/memory.h"
 #include "exec/ram_addr.h"
 #include "hw/hw.h"
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index ea9bcdf2bf7..9779aed8d8b 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -27,7 +27,7 @@
 #include "qemu/module.h"
 #include "qemu/range.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/queue.h"
 #include "hw/sysbus.h"
 #include "trace.h"
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 4b5d9e5e503..7d0533059d6 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -23,7 +23,7 @@
 #include "hw/boards.h"
 #include "sysemu/balloon.h"
 #include "hw/virtio/virtio-balloon.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qapi/error.h"
 #include "qapi/qapi-events-machine.h"
 #include "qapi/visitor.h"
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index d6332d45c3b..a324e3e251e 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -28,7 +28,7 @@
 #include "qapi/error.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 /* #define DEBUG_VIRTIO_BUS */
 
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 1c29146dcfa..9dfbc7b5a1e 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -144,7 +144,7 @@ typedef struct GuestFD {
 static GArray *guestfd_array;
 
 #ifndef CONFIG_USER_ONLY
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 /*
  * Find the base of a RAM region containing the specified address
  */
diff --git a/softmmu/ioport.c b/softmmu/ioport.c
index dfb9fbc7ffa..6ace5ec966a 100644
--- a/softmmu/ioport.c
+++ b/softmmu/ioport.c
@@ -29,7 +29,7 @@
 #include "cpu.h"
 #include "exec/ioport.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "trace.h"
 
 typedef struct MemoryRegionPortioList {
diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
index 60ff72790ea..646d3d184d7 100644
--- a/softmmu/memory_mapping.c
+++ b/softmmu/memory_mapping.c
@@ -16,7 +16,7 @@
 
 #include "sysemu/memory_mapping.h"
 #include "exec/sysemu/memory.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 //#define DEBUG_GUEST_PHYS_REGION_ADD
 
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index d8381ba2245..aff19af3561 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -28,7 +28,7 @@
 #include "internals.h"
 #include "hw/pci/pci.h"
 #include "exec/memattrs.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/boards.h"
 #include "hw/irq.h"
 #include "qemu/log.h"
diff --git a/target/avr/helper.c b/target/avr/helper.c
index 35e10195940..1dba5ffa6eb 100644
--- a/target/avr/helper.c
+++ b/target/avr/helper.c
@@ -22,7 +22,7 @@
 #include "cpu.h"
 #include "hw/core/tcg-cpu-ops.h"
 #include "exec/exec-all.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "exec/helper-proto.h"
 
 bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c
index 6477584313a..2746a592d9b 100644
--- a/target/i386/cpu-sysemu.c
+++ b/target/i386/cpu-sysemu.c
@@ -29,7 +29,7 @@
 #include "qapi/qapi-commands-machine-target.h"
 #include "hw/qdev-properties.h"
 
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/i386/apic_internal.h"
 
 #include "cpu-internal.h"
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 839b9d9f8b2..ec8b7745381 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -34,7 +34,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/i386/topology.h"
 #ifndef CONFIG_USER_ONLY
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "hw/boards.h"
 #endif
 
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
index bf65ed6fa92..29fe6577e7d 100644
--- a/target/i386/hax/hax-all.c
+++ b/target/i386/hax/hax-all.c
@@ -25,7 +25,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 #include "qemu-common.h"
 #include "qemu/accel.h"
diff --git a/target/i386/hax/hax-mem.c b/target/i386/hax/hax-mem.c
index 8d44edbffdd..06c8f6ccfdd 100644
--- a/target/i386/hax/hax-mem.c
+++ b/target/i386/hax/hax-mem.c
@@ -10,7 +10,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "qemu/error-report.h"
 
 #include "hax-accel-ops.h"
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index dfa690d65da..8adbfcb82d9 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -9,7 +9,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "exec/ioport.h"
 #include "qemu-common.h"
 #include "qemu/accel.h"
diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/misc_helper.c
index 66e7939537f..54c6bfeb2d5 100644
--- a/target/i386/tcg/sysemu/misc_helper.c
+++ b/target/i386/tcg/sysemu/misc_helper.c
@@ -22,7 +22,7 @@
 #include "cpu.h"
 #include "exec/helper-proto.h"
 #include "exec/cpu_ldst.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "tcg/helper-tcg.h"
 
 void helper_outb(CPUX86State *env, uint32_t port, uint32_t data)
diff --git a/target/i386/tcg/sysemu/tcg-cpu.c b/target/i386/tcg/sysemu/tcg-cpu.c
index c223c0fe9bc..a6227564590 100644
--- a/target/i386/tcg/sysemu/tcg-cpu.c
+++ b/target/i386/tcg/sysemu/tcg-cpu.c
@@ -23,7 +23,7 @@
 
 #include "sysemu/sysemu.h"
 #include "qemu/units.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 #include "tcg/tcg-cpu.h"
 
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index f832f286ac3..7abc77d1c1f 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -10,7 +10,7 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "exec/ioport.h"
 #include "qemu-common.h"
 #include "qemu/accel.h"
diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c
index 20625c2c8f6..bcdde18e366 100644
--- a/target/s390x/excp_helper.c
+++ b/target/s390x/excp_helper.c
@@ -26,9 +26,9 @@
 #include "exec/exec-all.h"
 #include "exec/cpu_ldst.h"
 #include "hw/s390x/ioinst.h"
-#include "exec/address-spaces.h"
 #include "tcg_s390x.h"
 #ifndef CONFIG_USER_ONLY
+#include "exec/sysemu/address-spaces.h"
 #include "hw/s390x/s390_flic.h"
 #include "hw/boards.h"
 #endif
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index d492b23a177..11dfb873df9 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -17,7 +17,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "cpu.h"
 #include "internal.h"
 #include "kvm_s390x.h"
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
index c604f177100..2546675d5f0 100644
--- a/target/s390x/sigp.c
+++ b/target/s390x/sigp.c
@@ -13,7 +13,7 @@
 #include "internal.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/runstate.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 #include "exec/exec-all.h"
 #include "sysemu/tcg.h"
 #include "trace.h"
diff --git a/target/xtensa/dbg_helper.c b/target/xtensa/dbg_helper.c
index be1f81107b4..5b1356b9792 100644
--- a/target/xtensa/dbg_helper.c
+++ b/target/xtensa/dbg_helper.c
@@ -31,7 +31,7 @@
 #include "exec/helper-proto.h"
 #include "qemu/host-utils.h"
 #include "exec/exec-all.h"
-#include "exec/address-spaces.h"
+#include "exec/sysemu/address-spaces.h"
 
 static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr)
 {
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/11] exec: Extract CPU I/O instructions to "cpu-io.h"
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 06/11] exec: Restrict address-spaces.h " Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 08/11] exec: Restrict ioport.h to sysemu/ Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

Not all architectures use an I/O bus. Extract the CPU I/O
instruction helpers into a specific unit named cpu-io.c
(and its equivalent "cpu-io.h" header).

Since what is left in ioport.c is no more target specific,
build the file with the other softmmu objects by moving the
file to the softmmu_ss Meson source set.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/exec/cpu-io.h             | 30 +++++++++++
 include/exec/ioport.h             |  7 ---
 hw/i386/xen/xen-hvm.c             |  1 +
 monitor/misc.c                    |  2 +-
 softmmu/cpu-io.c                  | 88 +++++++++++++++++++++++++++++++
 softmmu/ioport.c                  | 60 ---------------------
 softmmu/qtest.c                   |  1 +
 tests/qtest/fuzz/qtest_wrappers.c |  3 +-
 softmmu/meson.build               |  3 +-
 9 files changed, 125 insertions(+), 70 deletions(-)
 create mode 100644 include/exec/cpu-io.h
 create mode 100644 softmmu/cpu-io.c

diff --git a/include/exec/cpu-io.h b/include/exec/cpu-io.h
new file mode 100644
index 00000000000..6538c451177
--- /dev/null
+++ b/include/exec/cpu-io.h
@@ -0,0 +1,30 @@
+/*
+ * QEMU CPU I/O instructions
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CPU_IO_H
+#define CPU_IO_H
+
+void cpu_outb(uint32_t addr, uint8_t val);
+void cpu_outw(uint32_t addr, uint16_t val);
+void cpu_outl(uint32_t addr, uint32_t val);
+uint8_t cpu_inb(uint32_t addr);
+uint16_t cpu_inw(uint32_t addr);
+uint32_t cpu_inl(uint32_t addr);
+
+#endif /* CPU_IO_H */
diff --git a/include/exec/ioport.h b/include/exec/ioport.h
index d5ca8abff76..f94f71b19f0 100644
--- a/include/exec/ioport.h
+++ b/include/exec/ioport.h
@@ -44,13 +44,6 @@ typedef struct MemoryRegionPortio {
 extern const MemoryRegionOps unassigned_io_ops;
 #endif
 
-void cpu_outb(uint32_t addr, uint8_t val);
-void cpu_outw(uint32_t addr, uint16_t val);
-void cpu_outl(uint32_t addr, uint32_t val);
-uint8_t cpu_inb(uint32_t addr);
-uint16_t cpu_inw(uint32_t addr);
-uint32_t cpu_inl(uint32_t addr);
-
 typedef struct PortioList {
     const struct MemoryRegionPortio *ports;
     Object *owner;
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index 9b432773f02..c8de325a809 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -33,6 +33,7 @@
 #include "sysemu/xen.h"
 #include "sysemu/xen-mapcache.h"
 #include "trace.h"
+#include "exec/cpu-io.h"
 
 #include <xen/hvm/ioreq.h>
 #include <xen/hvm/e820.h>
diff --git a/monitor/misc.c b/monitor/misc.c
index c1fcd995805..60ee9c91a9f 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -76,7 +76,7 @@
 #include "qapi/qmp-event.h"
 #include "sysemu/cpus.h"
 #include "qemu/cutils.h"
-
+#include "exec/cpu-io.h"
 #if defined(TARGET_S390X)
 #include "hw/s390x/storage-keys.h"
 #include "hw/s390x/storage-attributes.h"
diff --git a/softmmu/cpu-io.c b/softmmu/cpu-io.c
new file mode 100644
index 00000000000..98da9d693f9
--- /dev/null
+++ b/softmmu/cpu-io.c
@@ -0,0 +1,88 @@
+/*
+ * QEMU CPU I/O instructions
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "exec/sysemu/address-spaces.h"
+#include "exec/cpu-io.h"
+#include "cpu.h"
+#include "trace.h"
+
+void cpu_outb(uint32_t addr, uint8_t val)
+{
+    trace_cpu_out(addr, 'b', val);
+    address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
+                        &val, 1);
+}
+
+void cpu_outw(uint32_t addr, uint16_t val)
+{
+    uint8_t buf[2];
+
+    trace_cpu_out(addr, 'w', val);
+    stw_p(buf, val);
+    address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
+                        buf, 2);
+}
+
+void cpu_outl(uint32_t addr, uint32_t val)
+{
+    uint8_t buf[4];
+
+    trace_cpu_out(addr, 'l', val);
+    stl_p(buf, val);
+    address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
+                        buf, 4);
+}
+
+uint8_t cpu_inb(uint32_t addr)
+{
+    uint8_t val;
+
+    address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
+                       &val, 1);
+    trace_cpu_in(addr, 'b', val);
+    return val;
+}
+
+uint16_t cpu_inw(uint32_t addr)
+{
+    uint8_t buf[2];
+    uint16_t val;
+
+    address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED, buf, 2);
+    val = lduw_p(buf);
+    trace_cpu_in(addr, 'w', val);
+    return val;
+}
+
+uint32_t cpu_inl(uint32_t addr)
+{
+    uint8_t buf[4];
+    uint32_t val;
+
+    address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED, buf, 4);
+    val = ldl_p(buf);
+    trace_cpu_in(addr, 'l', val);
+    return val;
+}
diff --git a/softmmu/ioport.c b/softmmu/ioport.c
index 6ace5ec966a..6f297027cfe 100644
--- a/softmmu/ioport.c
+++ b/softmmu/ioport.c
@@ -26,7 +26,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
 #include "exec/ioport.h"
 #include "exec/sysemu/memory.h"
 #include "exec/sysemu/address-spaces.h"
@@ -54,65 +53,6 @@ const MemoryRegionOps unassigned_io_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-void cpu_outb(uint32_t addr, uint8_t val)
-{
-    trace_cpu_out(addr, 'b', val);
-    address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
-                        &val, 1);
-}
-
-void cpu_outw(uint32_t addr, uint16_t val)
-{
-    uint8_t buf[2];
-
-    trace_cpu_out(addr, 'w', val);
-    stw_p(buf, val);
-    address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
-                        buf, 2);
-}
-
-void cpu_outl(uint32_t addr, uint32_t val)
-{
-    uint8_t buf[4];
-
-    trace_cpu_out(addr, 'l', val);
-    stl_p(buf, val);
-    address_space_write(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
-                        buf, 4);
-}
-
-uint8_t cpu_inb(uint32_t addr)
-{
-    uint8_t val;
-
-    address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED,
-                       &val, 1);
-    trace_cpu_in(addr, 'b', val);
-    return val;
-}
-
-uint16_t cpu_inw(uint32_t addr)
-{
-    uint8_t buf[2];
-    uint16_t val;
-
-    address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED, buf, 2);
-    val = lduw_p(buf);
-    trace_cpu_in(addr, 'w', val);
-    return val;
-}
-
-uint32_t cpu_inl(uint32_t addr)
-{
-    uint8_t buf[4];
-    uint32_t val;
-
-    address_space_read(&address_space_io, addr, MEMTXATTRS_UNSPECIFIED, buf, 4);
-    val = ldl_p(buf);
-    trace_cpu_in(addr, 'l', val);
-    return val;
-}
-
 void portio_list_init(PortioList *piolist,
                       Object *owner,
                       const MemoryRegionPortio *callbacks,
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index f1ee4fbc369..2551296c727 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -31,6 +31,7 @@
 #ifdef CONFIG_PSERIES
 #include "hw/ppc/spapr_rtas.h"
 #endif
+#include "exec/cpu-io.h"
 
 #define MAX_IRQ 256
 
diff --git a/tests/qtest/fuzz/qtest_wrappers.c b/tests/qtest/fuzz/qtest_wrappers.c
index 0580f8df860..25cf1b72705 100644
--- a/tests/qtest/fuzz/qtest_wrappers.c
+++ b/tests/qtest/fuzz/qtest_wrappers.c
@@ -12,8 +12,9 @@
  */
 
 #include "qemu/osdep.h"
+#include "exec/sysemu/address-spaces.h"
+#include "exec/cpu-io.h"
 #include "hw/core/cpu.h"
-#include "exec/ioport.h"
 
 #include "fuzz.h"
 
diff --git a/softmmu/meson.build b/softmmu/meson.build
index d8e03018abf..ebf063b8990 100644
--- a/softmmu/meson.build
+++ b/softmmu/meson.build
@@ -2,11 +2,11 @@
   'arch_init.c',
   'balloon.c',
   'cpus.c',
+  'cpu-io.c',
   'cpu-throttle.c',
   'datadir.c',
   'globals.c',
   'physmem.c',
-  'ioport.c',
   'rtc.c',
   'runstate.c',
   'memory.c',
@@ -24,6 +24,7 @@
 softmmu_ss.add(files(
   'bootdevice.c',
   'dma-helpers.c',
+  'ioport.c',
   'qdev-monitor.c',
 ), sdl, libpmem, libdaxctl)
 
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/11] exec: Restrict ioport.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 07/11] exec: Extract CPU I/O instructions to "cpu-io.h" Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 09/11] exec: Restrict ram_addr.h " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the ioport.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/ioport.h,sysemu/ioport.h, $(git grep -l exec/ioport.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/display/vga_int.h              |  2 +-
 include/hw/dma/i8257.h            |  2 +-
 include/hw/isa/isa.h              |  2 +-
 include/{exec => sysemu}/ioport.h | 10 ++++++----
 softmmu/ioport.c                  |  2 +-
 softmmu/physmem.c                 |  2 +-
 softmmu/qtest.c                   |  2 +-
 target/i386/nvmm/nvmm-all.c       |  2 +-
 target/i386/whpx/whpx-all.c       |  2 +-
 MAINTAINERS                       |  2 +-
 10 files changed, 15 insertions(+), 13 deletions(-)
 rename include/{exec => sysemu}/ioport.h (93%)

diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index b923633cc4f..8db43e898a3 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -25,7 +25,7 @@
 #ifndef HW_VGA_INT_H
 #define HW_VGA_INT_H
 
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "exec/sysemu/memory.h"
 #include "ui/console.h"
 
diff --git a/include/hw/dma/i8257.h b/include/hw/dma/i8257.h
index f652345d65a..e987a22fdd8 100644
--- a/include/hw/dma/i8257.h
+++ b/include/hw/dma/i8257.h
@@ -2,7 +2,7 @@
 #define HW_I8257_H
 
 #include "hw/isa/isa.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "qom/object.h"
 
 #define TYPE_I8257 "i8257"
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 9c9aabfc3b0..a63f1841111 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -4,7 +4,7 @@
 /* ISA bus */
 
 #include "exec/sysemu/memory.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "hw/qdev-core.h"
 #include "qom/object.h"
 
diff --git a/include/exec/ioport.h b/include/sysemu/ioport.h
similarity index 93%
rename from include/exec/ioport.h
rename to include/sysemu/ioport.h
index f94f71b19f0..b37c54ce4e5 100644
--- a/include/exec/ioport.h
+++ b/include/sysemu/ioport.h
@@ -21,8 +21,12 @@
  * IO ports API
  */
 
-#ifndef IOPORT_H
-#define IOPORT_H
+#ifndef SYSEMU_IOPORT_H
+#define SYSEMU_IOPORT_H
+
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
 
 #include "exec/sysemu/memory.h"
 
@@ -40,9 +44,7 @@ typedef struct MemoryRegionPortio {
 
 #define PORTIO_END_OF_LIST() { }
 
-#ifndef CONFIG_USER_ONLY
 extern const MemoryRegionOps unassigned_io_ops;
-#endif
 
 typedef struct PortioList {
     const struct MemoryRegionPortio *ports;
diff --git a/softmmu/ioport.c b/softmmu/ioport.c
index 6f297027cfe..5fabbb1832a 100644
--- a/softmmu/ioport.c
+++ b/softmmu/ioport.c
@@ -26,7 +26,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "exec/sysemu/memory.h"
 #include "exec/sysemu/address-spaces.h"
 #include "trace.h"
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 31e490185f3..51f05eb989c 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -42,7 +42,7 @@
 #include "qemu/error-report.h"
 #include "qemu/qemu-print.h"
 #include "exec/sysemu/memory.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "sysemu/dma.h"
 #include "sysemu/hostmem.h"
 #include "sysemu/hw_accel.h"
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 2551296c727..5faf99fca13 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -17,7 +17,7 @@
 #include "sysemu/qtest.h"
 #include "sysemu/runstate.h"
 #include "chardev/char-fe.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "exec/sysemu/memory.h"
 #include "hw/irq.h"
 #include "qemu/accel.h"
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index 8adbfcb82d9..181e7378b41 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -10,7 +10,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/sysemu/address-spaces.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "qemu-common.h"
 #include "qemu/accel.h"
 #include "sysemu/nvmm.h"
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 7abc77d1c1f..c7aafa4140b 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -11,7 +11,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/sysemu/address-spaces.h"
-#include "exec/ioport.h"
+#include "sysemu/ioport.h"
 #include "qemu-common.h"
 #include "qemu/accel.h"
 #include "sysemu/whpx.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index 48ae2145513..ca8d0feb2bd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2398,7 +2398,7 @@ F: tests/tcg/multiarch/gdbstub/
 Memory API
 M: Paolo Bonzini <pbonzini@redhat.com>
 S: Supported
-F: include/exec/ioport.h
+F: include/sysemu/ioport.h
 F: include/exec/memop.h
 F: include/exec/sysemu/memory.h
 F: include/exec/ram_addr.h
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/11] exec: Restrict ram_addr.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 08/11] exec: Restrict ioport.h to sysemu/ Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 10/11] exec: Restrict ramblock.h " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the ram_addr.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/ram_addr.h,sysemu/ram_addr.h, $(git grep -l exec/ram_addr.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/{exec => sysemu}/ram_addr.h | 11 +++++++----
 accel/kvm/kvm-all.c                 |  2 +-
 accel/tcg/cputlb.c                  |  2 +-
 accel/tcg/translate-all.c           |  2 +-
 hw/ppc/spapr.c                      |  2 +-
 hw/ppc/spapr_caps.c                 |  2 +-
 hw/ppc/spapr_pci.c                  |  2 +-
 hw/remote/memory.c                  |  2 +-
 hw/remote/proxy-memory-listener.c   |  2 +-
 hw/s390x/s390-stattrib-kvm.c        |  2 +-
 hw/s390x/s390-stattrib.c            |  2 +-
 hw/s390x/s390-virtio-ccw.c          |  2 +-
 hw/vfio/common.c                    |  2 +-
 hw/vfio/migration.c                 |  2 +-
 hw/vfio/spapr.c                     |  2 +-
 hw/virtio/virtio-mem.c              |  2 +-
 migration/ram.c                     |  2 +-
 plugins/api.c                       |  2 +-
 softmmu/memory.c                    |  2 +-
 softmmu/physmem.c                   |  2 +-
 target/arm/mte_helper.c             |  2 +-
 target/ppc/kvm.c                    |  2 +-
 target/s390x/kvm.c                  |  2 +-
 MAINTAINERS                         |  2 +-
 24 files changed, 30 insertions(+), 27 deletions(-)
 rename include/{exec => sysemu}/ram_addr.h (99%)

diff --git a/include/exec/ram_addr.h b/include/sysemu/ram_addr.h
similarity index 99%
rename from include/exec/ram_addr.h
rename to include/sysemu/ram_addr.h
index 3cb9791df3b..d495c969f9f 100644
--- a/include/exec/ram_addr.h
+++ b/include/sysemu/ram_addr.h
@@ -16,10 +16,13 @@
  * The functions declared here will be removed soon.
  */
 
-#ifndef RAM_ADDR_H
-#define RAM_ADDR_H
+#ifndef SYSEMU_RAM_ADDR_H
+#define SYSEMU_RAM_ADDR_H
+
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
 
-#ifndef CONFIG_USER_ONLY
 #include "cpu.h"
 #include "sysemu/xen.h"
 #include "sysemu/tcg.h"
@@ -513,5 +516,5 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb,
 
     return num_dirty;
 }
-#endif
+
 #endif
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 204fc0403ca..bc40fa4fee7 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -32,7 +32,7 @@
 #include "sysemu/cpus.h"
 #include "qemu/bswap.h"
 #include "exec/sysemu/memory.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "qemu/event_notifier.h"
 #include "qemu/main-loop.h"
 #include "trace.h"
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 14a4ee4ed63..d93e37c9c3e 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -26,7 +26,7 @@
 #include "exec/sysemu/cputlb.h"
 #include "exec/tb-hash.h"
 #include "exec/sysemu/memory-internal.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "tcg/tcg.h"
 #include "qemu/error-report.h"
 #include "exec/log.h"
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 98a07ce4e4e..86340e4989b 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -44,7 +44,7 @@
 #endif
 #else /* !CONFIG_USER_ONLY */
 #include "exec/sysemu/cputlb.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #endif /* CONFIG_USER_ONLY */
 
 #include "exec/tb-hash.h"
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 8f40319aee8..bf8f0a4b347 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -69,7 +69,7 @@
 #include "hw/virtio/virtio-scsi.h"
 #include "hw/virtio/vhost-scsi-common.h"
 
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "hw/usb.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 9ea7ddd1e9a..97f2b5aafa3 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -27,7 +27,7 @@
 #include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "sysemu/hw_accel.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "target/ppc/cpu.h"
 #include "target/ppc/mmu-hash64.h"
 #include "cpu-models.h"
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 7a725855f91..b0b6204870f 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -34,7 +34,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/spapr.h"
 #include "hw/pci-host/spapr.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include <libfdt.h>
 #include "trace.h"
 #include "qemu/error-report.h"
diff --git a/hw/remote/memory.c b/hw/remote/memory.c
index 2d4174614af..8606ae15eb5 100644
--- a/hw/remote/memory.c
+++ b/hw/remote/memory.c
@@ -12,7 +12,7 @@
 #include "qemu-common.h"
 
 #include "hw/remote/memory.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "qapi/error.h"
 
 static void remote_sysmem_reset(void)
diff --git a/hw/remote/proxy-memory-listener.c b/hw/remote/proxy-memory-listener.c
index d9bed35fa2f..25779463523 100644
--- a/hw/remote/proxy-memory-listener.c
+++ b/hw/remote/proxy-memory-listener.c
@@ -14,7 +14,7 @@
 #include "qemu/range.h"
 #include "exec/sysemu/memory.h"
 #include "exec/cpu-common.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "qapi/error.h"
 #include "hw/remote/mpqemu-link.h"
 #include "hw/remote/proxy-memory-listener.h"
diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c
index f0b11a74e49..8354c4bc750 100644
--- a/hw/s390x/s390-stattrib-kvm.c
+++ b/hw/s390x/s390-stattrib-kvm.c
@@ -15,7 +15,7 @@
 #include "hw/s390x/storage-attributes.h"
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "kvm_s390x.h"
 
 Object *kvm_s390_stattrib_create(void)
diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c
index 9eda1c3b2a2..4bc34fbd069 100644
--- a/hw/s390x/s390-stattrib.c
+++ b/hw/s390x/s390-stattrib.c
@@ -15,7 +15,7 @@
 #include "migration/register.h"
 #include "hw/s390x/storage-attributes.h"
 #include "qemu/error-report.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
 
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 7af27ca3057..9a8d6405a13 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "hw/s390x/s390-virtio-hcall.h"
 #include "hw/s390x/sclp.h"
 #include "hw/s390x/s390_flic.h"
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 91171e4f658..66ecb1f458a 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -29,7 +29,7 @@
 #include "hw/vfio/vfio.h"
 #include "exec/sysemu/address-spaces.h"
 #include "exec/sysemu/memory.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 201642d75e6..343069065e8 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -23,7 +23,7 @@
 #include "migration/misc.h"
 #include "qapi/error.h"
 #include "exec/ramlist.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "pci.h"
 #include "trace.h"
 #include "hw/hw.h"
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index ea3f70bd2fa..7db2901db86 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -14,7 +14,7 @@
 
 #include "hw/vfio/vfio-common.h"
 #include "hw/hw.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "trace.h"
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index 75aa7d6f1b1..b09cd5001ea 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -25,7 +25,7 @@
 #include "hw/virtio/virtio-mem.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "migration/misc.h"
 #include "hw/boards.h"
 #include "hw/qdev-properties.h"
diff --git a/migration/ram.c b/migration/ram.c
index 60ea913c543..1a92983fb50 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -45,7 +45,7 @@
 #include "qapi/qapi-events-migration.h"
 #include "qapi/qmp/qerror.h"
 #include "trace.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "exec/target_page.h"
 #include "qemu/rcu_queue.h"
 #include "migration/colo.h"
diff --git a/plugins/api.c b/plugins/api.c
index 817c9b6b69c..b114246c357 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -38,7 +38,7 @@
 #include "qemu/plugin.h"
 #include "tcg/tcg.h"
 #include "exec/exec-all.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "disas/disas.h"
 #include "plugin.h"
 #ifndef CONFIG_USER_ONLY
diff --git a/softmmu/memory.c b/softmmu/memory.c
index cdc935cdd27..411f6f9ac25 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -26,7 +26,7 @@
 #include "trace.h"
 
 #include "exec/sysemu/memory-internal.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
 #include "sysemu/tcg.h"
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 51f05eb989c..d8a5deb18ea 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -59,7 +59,7 @@
 #include "sysemu/replay.h"
 
 #include "exec/sysemu/memory-internal.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "exec/log.h"
 
 #include "qemu/pmem.h"
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
index a6fccc6e69e..455c2e80d31 100644
--- a/target/arm/mte_helper.c
+++ b/target/arm/mte_helper.c
@@ -21,7 +21,7 @@
 #include "cpu.h"
 #include "internals.h"
 #include "exec/exec-all.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "exec/cpu_ldst.h"
 #include "exec/helper-proto.h"
 #include "qapi/error.h"
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 104a308abb5..5b9ce0a25a5 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -43,7 +43,7 @@
 #include "trace.h"
 #include "exec/gdbstub.h"
 #include "exec/memattrs.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "sysemu/hostmem.h"
 #include "qemu/cutils.h"
 #include "qemu/main-loop.h"
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index 4fb3bbfef50..aa135acb7aa 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -42,7 +42,7 @@
 #include "sysemu/runstate.h"
 #include "sysemu/device_tree.h"
 #include "exec/gdbstub.h"
-#include "exec/ram_addr.h"
+#include "sysemu/ram_addr.h"
 #include "trace.h"
 #include "hw/s390x/s390-pci-inst.h"
 #include "hw/s390x/s390-pci-bus.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index ca8d0feb2bd..8caf3891dba 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2401,7 +2401,7 @@ S: Supported
 F: include/sysemu/ioport.h
 F: include/exec/memop.h
 F: include/exec/sysemu/memory.h
-F: include/exec/ram_addr.h
+F: include/sysemu/ram_addr.h
 F: include/exec/ramblock.h
 F: softmmu/dma-helpers.c
 F: softmmu/ioport.c
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/11] exec: Restrict ramblock.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 09/11] exec: Restrict ram_addr.h " Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-17 11:11 ` [PATCH 11/11] exec: Restrict confidential-guest-support.h " Philippe Mathieu-Daudé
  2021-05-25 14:13 ` [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the ramblock.h header is sysemu specific,
move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/ramblock.h,sysemu/ramblock.h, $(git grep -l exec/ramblock.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/ram_addr.h           |  2 +-
 include/{exec => sysemu}/ramblock.h | 13 ++++++++-----
 migration/dirtyrate.c               |  2 +-
 migration/multifd.c                 |  2 +-
 migration/postcopy-ram.c            |  2 +-
 tests/qtest/fuzz/generic_fuzz.c     |  2 +-
 MAINTAINERS                         |  2 +-
 7 files changed, 14 insertions(+), 11 deletions(-)
 rename include/{exec => sysemu}/ramblock.h (92%)

diff --git a/include/sysemu/ram_addr.h b/include/sysemu/ram_addr.h
index d495c969f9f..aea30dfeb4e 100644
--- a/include/sysemu/ram_addr.h
+++ b/include/sysemu/ram_addr.h
@@ -27,7 +27,7 @@
 #include "sysemu/xen.h"
 #include "sysemu/tcg.h"
 #include "exec/ramlist.h"
-#include "exec/ramblock.h"
+#include "sysemu/ramblock.h"
 
 /**
  * clear_bmap_size: calculate clear bitmap size
diff --git a/include/exec/ramblock.h b/include/sysemu/ramblock.h
similarity index 92%
rename from include/exec/ramblock.h
rename to include/sysemu/ramblock.h
index 664701b7594..12a1b90a19b 100644
--- a/include/exec/ramblock.h
+++ b/include/sysemu/ramblock.h
@@ -16,11 +16,14 @@
  * The functions declared here will be removed soon.
  */
 
-#ifndef QEMU_EXEC_RAMBLOCK_H
-#define QEMU_EXEC_RAMBLOCK_H
+#ifndef QEMU_SYSEMU_RAMBLOCK_H
+#define QEMU_SYSEMU_RAMBLOCK_H
 
-#ifndef CONFIG_USER_ONLY
-#include "cpu-common.h"
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
+
+#include "exec/cpu-common.h"
 
 struct RAMBlock {
     struct rcu_head rcu;
@@ -70,5 +73,5 @@ struct RAMBlock {
      */
     ram_addr_t postcopy_length;
 };
-#endif
+
 #endif
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index ccb98147e89..5422b39784f 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -14,7 +14,7 @@
 #include <zlib.h>
 #include "qapi/error.h"
 #include "cpu.h"
-#include "exec/ramblock.h"
+#include "sysemu/ramblock.h"
 #include "qemu/rcu_queue.h"
 #include "qapi/qapi-commands-migration.h"
 #include "ram.h"
diff --git a/migration/multifd.c b/migration/multifd.c
index 0a4803cfccb..519f8dd4393 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -14,7 +14,7 @@
 #include "qemu/rcu.h"
 #include "exec/target_page.h"
 #include "sysemu/sysemu.h"
-#include "exec/ramblock.h"
+#include "sysemu/ramblock.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "ram.h"
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 2e9697bdd2e..fb8c625ffc3 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -31,7 +31,7 @@
 #include "qemu/error-report.h"
 #include "trace.h"
 #include "hw/boards.h"
-#include "exec/ramblock.h"
+#include "sysemu/ramblock.h"
 
 /* Arbitrary limit on size of each discard command,
  * keeps them around ~200 bytes
diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
index 05f9c9b06f9..613427f1a57 100644
--- a/tests/qtest/fuzz/generic_fuzz.c
+++ b/tests/qtest/fuzz/generic_fuzz.c
@@ -21,7 +21,7 @@
 #include "fork_fuzz.h"
 #include "string.h"
 #include "exec/sysemu/memory.h"
-#include "exec/ramblock.h"
+#include "sysemu/ramblock.h"
 #include "hw/qdev-core.h"
 #include "hw/pci/pci.h"
 #include "hw/boards.h"
diff --git a/MAINTAINERS b/MAINTAINERS
index 8caf3891dba..cea4f2e438a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2402,7 +2402,7 @@ F: include/sysemu/ioport.h
 F: include/exec/memop.h
 F: include/exec/sysemu/memory.h
 F: include/sysemu/ram_addr.h
-F: include/exec/ramblock.h
+F: include/sysemu/ramblock.h
 F: softmmu/dma-helpers.c
 F: softmmu/ioport.c
 F: softmmu/memory.c
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 11/11] exec: Restrict confidential-guest-support.h to sysemu/
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 10/11] exec: Restrict ramblock.h " Philippe Mathieu-Daudé
@ 2021-05-17 11:11 ` Philippe Mathieu-Daudé
  2021-05-25 14:13 ` [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
  11 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-17 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Claudio Fontana, Laurent Vivier

To make it clearer the confidential-guest-support.h header is
sysemu specific, move it to the sysemu/ directory.

Patch created mechanically using:

  $ sed -i s,exec/confidential-guest-support.h,sysemu/confidential-guest-support.h, \
    $(git grep -l exec/confidential-guest-support.h)

Then the #ifdef'ry conditional on CONFIG_USER_ONLY has
been replaced by an #error.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/{exec => sysemu}/confidential-guest-support.h | 6 +++---
 backends/confidential-guest-support.c                 | 2 +-
 hw/core/machine.c                                     | 2 +-
 hw/ppc/pef.c                                          | 2 +-
 hw/s390x/pv.c                                         | 2 +-
 softmmu/vl.c                                          | 2 +-
 target/i386/sev.c                                     | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)
 rename include/{exec => sysemu}/confidential-guest-support.h (95%)

diff --git a/include/exec/confidential-guest-support.h b/include/sysemu/confidential-guest-support.h
similarity index 95%
rename from include/exec/confidential-guest-support.h
rename to include/sysemu/confidential-guest-support.h
index ba2dd4b5dfc..3b52d086642 100644
--- a/include/exec/confidential-guest-support.h
+++ b/include/sysemu/confidential-guest-support.h
@@ -18,7 +18,9 @@
 #ifndef QEMU_CONFIDENTIAL_GUEST_SUPPORT_H
 #define QEMU_CONFIDENTIAL_GUEST_SUPPORT_H
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_USER_ONLY
+#error Cannot include sysemu specific header from user emulation
+#endif
 
 #include "qom/object.h"
 
@@ -57,6 +59,4 @@ typedef struct ConfidentialGuestSupportClass {
     ObjectClass parent;
 } ConfidentialGuestSupportClass;
 
-#endif /* !CONFIG_USER_ONLY */
-
 #endif /* QEMU_CONFIDENTIAL_GUEST_SUPPORT_H */
diff --git a/backends/confidential-guest-support.c b/backends/confidential-guest-support.c
index 052fde8db04..bc141504451 100644
--- a/backends/confidential-guest-support.c
+++ b/backends/confidential-guest-support.c
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 
-#include "exec/confidential-guest-support.h"
+#include "sysemu/confidential-guest-support.h"
 
 OBJECT_DEFINE_ABSTRACT_TYPE(ConfidentialGuestSupport,
                             confidential_guest_support,
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 1bf0e687b94..6ab11140ef0 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -32,7 +32,7 @@
 #include "hw/mem/nvdimm.h"
 #include "migration/global_state.h"
 #include "migration/vmstate.h"
-#include "exec/confidential-guest-support.h"
+#include "sysemu/confidential-guest-support.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-pci.h"
 
diff --git a/hw/ppc/pef.c b/hw/ppc/pef.c
index 573be3ed79b..d469326a480 100644
--- a/hw/ppc/pef.c
+++ b/hw/ppc/pef.c
@@ -14,7 +14,7 @@
 #include "qom/object_interfaces.h"
 #include "sysemu/kvm.h"
 #include "migration/blocker.h"
-#include "exec/confidential-guest-support.h"
+#include "sysemu/confidential-guest-support.h"
 #include "hw/ppc/pef.h"
 
 #define TYPE_PEF_GUEST "pef-guest"
diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
index 401b63d6cb6..799d8b047b2 100644
--- a/hw/s390x/pv.c
+++ b/hw/s390x/pv.c
@@ -17,7 +17,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/kvm.h"
 #include "qom/object_interfaces.h"
-#include "exec/confidential-guest-support.h"
+#include "sysemu/confidential-guest-support.h"
 #include "hw/s390x/ipl.h"
 #include "hw/s390x/pv.h"
 
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 93e78469bce..d79c15cd4dc 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -102,7 +102,7 @@
 #include "qemu/plugin.h"
 #include "qemu/queue.h"
 #include "sysemu/arch_init.h"
-#include "exec/confidential-guest-support.h"
+#include "sysemu/confidential-guest-support.h"
 
 #include "ui/qemu-spice.h"
 #include "qapi/string-input-visitor.h"
diff --git a/target/i386/sev.c b/target/i386/sev.c
index 41f7800b5f7..f2a92cf9126 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -31,7 +31,7 @@
 #include "migration/blocker.h"
 #include "qom/object.h"
 #include "monitor/monitor.h"
-#include "exec/confidential-guest-support.h"
+#include "sysemu/confidential-guest-support.h"
 #include "hw/i386/pc.h"
 
 #define TYPE_SEV_GUEST "sev-guest"
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu)
  2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2021-05-17 11:11 ` [PATCH 11/11] exec: Restrict confidential-guest-support.h " Philippe Mathieu-Daudé
@ 2021-05-25 14:13 ` Philippe Mathieu-Daudé
  2021-11-06 14:58   ` Philippe Mathieu-Daudé
  11 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-05-25 14:13 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Claudio Fontana, Laurent Vivier

Ping for review? :)

On 5/17/21 1:11 PM, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> This series restricts various system emulation specific headers
> by moving them under sysemu/ and adding #error if included from
> user emulation.
> We could avoid the sysemu/ rename if too much churn, but enforcing
> error of headers that must not be included in user emulation allows
> further cleanups (to be sent later).
> 
> I had to split the ioport.c file to cpu-io (generic to any target
> having access to I/O bus, but I haven't checked the TCG implementation
> details for user emulation) VS ioport (system specific, access to
> hardware).
> 
> Many files are changed, but this is mostly one-line mechanical
> updates of old path to new path using sed.
> 
> Regards,
> 
> Phil.
> 
> Philippe Mathieu-Daudé (11):
>   NOTFORMERGE target/arm: Restrict KVM files to softmmu
>   exec: Restrict hwaddr.h to sysemu/
>   exec: Restrict cputlb.h to sysemu/
>   exec: Restrict memory.h to sysemu/
>   exec: Restrict memory-internal.h to sysemu/
>   exec: Restrict address-spaces.h to sysemu/
>   exec: Extract CPU I/O instructions to "cpu-io.h"
>   exec: Restrict ioport.h to sysemu/
>   exec: Restrict ram_addr.h to sysemu/
>   exec: Restrict ramblock.h to sysemu/
>   exec: Restrict confidential-guest-support.h to sysemu/

>  275 files changed, 491 insertions(+), 409 deletions(-)
>  create mode 100644 include/exec/cpu-io.h
>  rename include/exec/{ => sysemu}/address-spaces.h (80%)
>  rename include/exec/{ => sysemu}/cputlb.h (86%)
>  rename include/exec/{ => sysemu}/hwaddr.h (81%)
>  rename include/exec/{ => sysemu}/memory-internal.h (94%)
>  rename include/exec/{ => sysemu}/memory.h (99%)
>  rename include/{exec => sysemu}/confidential-guest-support.h (95%)
>  rename include/{exec => sysemu}/ioport.h (86%)
>  rename include/{exec => sysemu}/ram_addr.h (99%)
>  rename include/{exec => sysemu}/ramblock.h (92%)
>  create mode 100644 softmmu/cpu-io.c
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2021-05-17 11:11 ` [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/ Philippe Mathieu-Daudé
@ 2021-05-26 18:15   ` Richard Henderson
  2022-12-06 14:32     ` Philippe Mathieu-Daudé
  2022-12-06 14:53   ` Claudio Fontana
  2022-12-06 15:01   ` Peter Maydell
  2 siblings, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2021-05-26 18:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Paolo Bonzini, Claudio Fontana, Laurent Vivier

On 5/17/21 4:11 AM, Philippe Mathieu-Daudé wrote:
> --- a/include/exec/hwaddr.h
> +++ b/include/exec/sysemu/hwaddr.h
> @@ -1,8 +1,9 @@
>   /* Define hwaddr if it exists.  */
>   
> -#ifndef HWADDR_H
> -#define HWADDR_H
> +#ifndef EXEC_SYSEMU_HWADDR_H
> +#define EXEC_SYSEMU_HWADDR_H
>   
> +#ifndef CONFIG_USER_ONLY
>   
>   #define HWADDR_BITS 64
>   /* hwaddr is the type of a physical address (its size can
> @@ -23,4 +24,6 @@ typedef struct MemMapEntry {
>       hwaddr size;
>   } MemMapEntry;
>   
> +#endif /* !CONFIG_USER_ONLY */
> +
>   #endif

Why no #error on this one, unlike the next patch.


r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu)
  2021-05-25 14:13 ` [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
@ 2021-11-06 14:58   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-06 14:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Richard Henderson, Claudio Fontana, Laurent Vivier

6 months passed, heavy rebased required, dropping for now.

On 5/25/21 16:13, Philippe Mathieu-Daudé wrote:
> Ping for review? :)
> 
> On 5/17/21 1:11 PM, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> This series restricts various system emulation specific headers
>> by moving them under sysemu/ and adding #error if included from
>> user emulation.
>> We could avoid the sysemu/ rename if too much churn, but enforcing
>> error of headers that must not be included in user emulation allows
>> further cleanups (to be sent later).
>>
>> I had to split the ioport.c file to cpu-io (generic to any target
>> having access to I/O bus, but I haven't checked the TCG implementation
>> details for user emulation) VS ioport (system specific, access to
>> hardware).
>>
>> Many files are changed, but this is mostly one-line mechanical
>> updates of old path to new path using sed.
>>
>> Regards,
>>
>> Phil.
>>
>> Philippe Mathieu-Daudé (11):
>>   NOTFORMERGE target/arm: Restrict KVM files to softmmu
>>   exec: Restrict hwaddr.h to sysemu/
>>   exec: Restrict cputlb.h to sysemu/
>>   exec: Restrict memory.h to sysemu/
>>   exec: Restrict memory-internal.h to sysemu/
>>   exec: Restrict address-spaces.h to sysemu/
>>   exec: Extract CPU I/O instructions to "cpu-io.h"
>>   exec: Restrict ioport.h to sysemu/
>>   exec: Restrict ram_addr.h to sysemu/
>>   exec: Restrict ramblock.h to sysemu/
>>   exec: Restrict confidential-guest-support.h to sysemu/
> 
>>  275 files changed, 491 insertions(+), 409 deletions(-)
>>  create mode 100644 include/exec/cpu-io.h
>>  rename include/exec/{ => sysemu}/address-spaces.h (80%)
>>  rename include/exec/{ => sysemu}/cputlb.h (86%)
>>  rename include/exec/{ => sysemu}/hwaddr.h (81%)
>>  rename include/exec/{ => sysemu}/memory-internal.h (94%)
>>  rename include/exec/{ => sysemu}/memory.h (99%)
>>  rename include/{exec => sysemu}/confidential-guest-support.h (95%)
>>  rename include/{exec => sysemu}/ioport.h (86%)
>>  rename include/{exec => sysemu}/ram_addr.h (99%)
>>  rename include/{exec => sysemu}/ramblock.h (92%)
>>  create mode 100644 softmmu/cpu-io.c
>>
> 


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2021-05-26 18:15   ` Richard Henderson
@ 2022-12-06 14:32     ` Philippe Mathieu-Daudé
  2022-12-06 14:40       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-06 14:32 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel
  Cc: Claudio Fontana, Laurent Vivier, Paolo Bonzini

On 26/5/21 20:15, Richard Henderson wrote:
> On 5/17/21 4:11 AM, Philippe Mathieu-Daudé wrote:
>> --- a/include/exec/hwaddr.h
>> +++ b/include/exec/sysemu/hwaddr.h
>> @@ -1,8 +1,9 @@
>>   /* Define hwaddr if it exists.  */
>> -#ifndef HWADDR_H
>> -#define HWADDR_H
>> +#ifndef EXEC_SYSEMU_HWADDR_H
>> +#define EXEC_SYSEMU_HWADDR_H
>> +#ifndef CONFIG_USER_ONLY
>>   #define HWADDR_BITS 64
>>   /* hwaddr is the type of a physical address (its size can
>> @@ -23,4 +24,6 @@ typedef struct MemMapEntry {
>>       hwaddr size;
>>   } MemMapEntry;
>> +#endif /* !CONFIG_USER_ONLY */
>> +
>>   #endif
> 
> Why no #error on this one, unlike the next patch.

Because many files in user emulation include "exec/hwaddr.h" :(


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2022-12-06 14:32     ` Philippe Mathieu-Daudé
@ 2022-12-06 14:40       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-06 14:40 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel, Alex Bennée
  Cc: Claudio Fontana, Laurent Vivier, Paolo Bonzini

On 6/12/22 15:32, Philippe Mathieu-Daudé wrote:
> On 26/5/21 20:15, Richard Henderson wrote:
>> On 5/17/21 4:11 AM, Philippe Mathieu-Daudé wrote:
>>> --- a/include/exec/hwaddr.h
>>> +++ b/include/exec/sysemu/hwaddr.h
>>> @@ -1,8 +1,9 @@
>>>   /* Define hwaddr if it exists.  */
>>> -#ifndef HWADDR_H
>>> -#define HWADDR_H
>>> +#ifndef EXEC_SYSEMU_HWADDR_H
>>> +#define EXEC_SYSEMU_HWADDR_H
>>> +#ifndef CONFIG_USER_ONLY
>>>   #define HWADDR_BITS 64
>>>   /* hwaddr is the type of a physical address (its size can
>>> @@ -23,4 +24,6 @@ typedef struct MemMapEntry {
>>>       hwaddr size;
>>>   } MemMapEntry;
>>> +#endif /* !CONFIG_USER_ONLY */
>>> +
>>>   #endif
>>
>> Why no #error on this one, unlike the next patch.
> 
> Because many files in user emulation include "exec/hwaddr.h" :(

See for example gdbstub/user.c:

int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len)

I suppose we should change the two hwaddr by vaddr:

/**
  * vaddr:
  * Type wide enough to contain any #target_ulong virtual address.
  */


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2021-05-17 11:11 ` [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/ Philippe Mathieu-Daudé
  2021-05-26 18:15   ` Richard Henderson
@ 2022-12-06 14:53   ` Claudio Fontana
  2022-12-06 15:38     ` Claudio Fontana
  2022-12-06 15:01   ` Peter Maydell
  2 siblings, 1 reply; 23+ messages in thread
From: Claudio Fontana @ 2022-12-06 14:53 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson

On 5/17/21 13:11, Philippe Mathieu-Daudé wrote:
> Guard declarations within hwaddr.h against inclusion
> from user-mode emulation.
> 
> To make it clearer this header is sysemu specific,
> move it to the sysemu/ directory.

Hi Philippe,

do we need include/exec/sysemu/... .h

as opposed to just use the existing

include/sysemu/

?

Thanks,

Claudio

> 
> Patch created mechanically using:
> 
>   $ sed -i s,exec/hwaddr.h,exec/sysemu/hwaddr.h, $(git grep -l exec/hwaddr.h)
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/audio/lm4549.h                                   | 2 +-
>  hw/net/can/can_sja1000.h                            | 2 +-
>  hw/net/can/ctucan_core.h                            | 2 +-
>  hw/net/net_tx_pkt.h                                 | 2 +-
>  include/disas/disas.h                               | 4 +++-
>  include/exec/cpu-all.h                              | 2 +-
>  include/exec/cpu-common.h                           | 2 +-
>  include/exec/cpu-defs.h                             | 2 +-
>  include/exec/memory.h                               | 2 +-
>  include/exec/{ => sysemu}/hwaddr.h                  | 7 +++++--
>  include/hw/arm/sharpsl.h                            | 2 +-
>  include/hw/arm/soc_dma.h                            | 2 +-
>  include/hw/arm/sysbus-fdt.h                         | 2 +-
>  include/hw/arm/virt.h                               | 2 +-
>  include/hw/block/block.h                            | 2 +-
>  include/hw/block/fdc.h                              | 2 +-
>  include/hw/block/flash.h                            | 2 +-
>  include/hw/core/cpu.h                               | 4 +++-
>  include/hw/cris/etraxfs_dma.h                       | 2 +-
>  include/hw/display/vga.h                            | 2 +-
>  include/hw/i386/microvm.h                           | 2 +-
>  include/hw/i386/x86.h                               | 2 +-
>  include/hw/input/lasips2.h                          | 2 +-
>  include/hw/loader-fit.h                             | 2 +-
>  include/hw/misc/allwinner-h3-dramc.h                | 2 +-
>  include/hw/misc/empty_slot.h                        | 2 +-
>  include/hw/nvram/fw_cfg.h                           | 2 +-
>  include/hw/pci-host/gpex.h                          | 2 +-
>  include/hw/remote/memory.h                          | 2 +-
>  include/hw/remote/mpqemu-link.h                     | 2 +-
>  include/hw/rtc/m48t59.h                             | 2 +-
>  include/hw/rtc/sun4v-rtc.h                          | 2 +-
>  include/hw/timer/tmu012.h                           | 2 +-
>  include/hw/virtio/virtio-access.h                   | 2 +-
>  include/monitor/monitor.h                           | 2 +-
>  include/qemu/accel.h                                | 4 +++-
>  include/qemu/iova-tree.h                            | 2 +-
>  include/qemu/userfaultfd.h                          | 2 +-
>  dump/dump.c                                         | 2 +-
>  dump/win_dump.c                                     | 2 +-
>  hw/arm/sbsa-ref.c                                   | 2 +-
>  hw/input/lasips2.c                                  | 2 +-
>  hw/m68k/next-cube.c                                 | 2 +-
>  hw/ppc/pnv_homer.c                                  | 2 +-
>  tests/qtest/microbit-test.c                         | 2 +-
>  MAINTAINERS                                         | 1 +
>  scripts/codeconverter/codeconverter/test_regexps.py | 4 ++--
>  47 files changed, 58 insertions(+), 48 deletions(-)
>  rename include/exec/{ => sysemu}/hwaddr.h (81%)
> 
> diff --git a/hw/audio/lm4549.h b/hw/audio/lm4549.h
> index aba9bb5b077..5d53c2f2179 100644
> --- a/hw/audio/lm4549.h
> +++ b/hw/audio/lm4549.h
> @@ -13,7 +13,7 @@
>  #define HW_LM4549_H
>  
>  #include "audio/audio.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  typedef void (*lm4549_callback)(void *opaque);
>  
> diff --git a/hw/net/can/can_sja1000.h b/hw/net/can/can_sja1000.h
> index 7ca9cd681ed..57e6d4d34e4 100644
> --- a/hw/net/can/can_sja1000.h
> +++ b/hw/net/can/can_sja1000.h
> @@ -27,7 +27,7 @@
>  #ifndef HW_CAN_SJA1000_H
>  #define HW_CAN_SJA1000_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "net/can_emu.h"
>  
>  #define CAN_SJA_MEM_SIZE      128
> diff --git a/hw/net/can/ctucan_core.h b/hw/net/can/ctucan_core.h
> index bbc09ae0678..c0e4beafba2 100644
> --- a/hw/net/can/ctucan_core.h
> +++ b/hw/net/can/ctucan_core.h
> @@ -28,7 +28,7 @@
>  #ifndef HW_CAN_CTUCAN_CORE_H
>  #define HW_CAN_CTUCAN_CORE_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "net/can_emu.h"
>  
>  #ifndef HOST_WORDS_BIGENDIAN
> diff --git a/hw/net/net_tx_pkt.h b/hw/net/net_tx_pkt.h
> index 4ec8bbe9bd9..86548b4f613 100644
> --- a/hw/net/net_tx_pkt.h
> +++ b/hw/net/net_tx_pkt.h
> @@ -19,7 +19,7 @@
>  #define NET_TX_PKT_H
>  
>  #include "net/eth.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  /* define to enable packet dump functions */
>  /*#define NET_TX_PKT_DEBUG*/
> diff --git a/include/disas/disas.h b/include/disas/disas.h
> index d363e95edeb..1b85d121a7a 100644
> --- a/include/disas/disas.h
> +++ b/include/disas/disas.h
> @@ -1,7 +1,9 @@
>  #ifndef QEMU_DISAS_H
>  #define QEMU_DISAS_H
>  
> -#include "exec/hwaddr.h"
> +#ifndef CONFIG_USER_ONLY
> +#include "exec/sysemu/hwaddr.h"
> +#endif
>  
>  #ifdef NEED_CPU_H
>  #include "cpu.h"
> diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
> index 32cfb634c6a..3e7edddead5 100644
> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -175,7 +175,7 @@ extern unsigned long reserved_va;
>  
>  #else
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  #define SUFFIX
>  #define ARG1         as
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index ccabed4003a..1a64b0b5ac6 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -4,7 +4,7 @@
>  /* CPU interfaces that are target independent.  */
>  
>  #ifndef CONFIG_USER_ONLY
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #endif
>  
>  /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */
> diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
> index ba3cd32a1ec..52a2b93493d 100644
> --- a/include/exec/cpu-defs.h
> +++ b/include/exec/cpu-defs.h
> @@ -26,7 +26,7 @@
>  #include "qemu/host-utils.h"
>  #include "qemu/thread.h"
>  #ifndef CONFIG_USER_ONLY
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #endif
>  #include "exec/memattrs.h"
>  #include "hw/core/cpu.h"
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index c8b90889241..52a2659b396 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -17,7 +17,7 @@
>  #ifndef CONFIG_USER_ONLY
>  
>  #include "exec/cpu-common.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "exec/memattrs.h"
>  #include "exec/memop.h"
>  #include "exec/ramlist.h"
> diff --git a/include/exec/hwaddr.h b/include/exec/sysemu/hwaddr.h
> similarity index 81%
> rename from include/exec/hwaddr.h
> rename to include/exec/sysemu/hwaddr.h
> index 8f16d179a88..9693cd516b4 100644
> --- a/include/exec/hwaddr.h
> +++ b/include/exec/sysemu/hwaddr.h
> @@ -1,8 +1,9 @@
>  /* Define hwaddr if it exists.  */
>  
> -#ifndef HWADDR_H
> -#define HWADDR_H
> +#ifndef EXEC_SYSEMU_HWADDR_H
> +#define EXEC_SYSEMU_HWADDR_H
>  
> +#ifndef CONFIG_USER_ONLY
>  
>  #define HWADDR_BITS 64
>  /* hwaddr is the type of a physical address (its size can
> @@ -23,4 +24,6 @@ typedef struct MemMapEntry {
>      hwaddr size;
>  } MemMapEntry;
>  
> +#endif /* !CONFIG_USER_ONLY */
> +
>  #endif
> diff --git a/include/hw/arm/sharpsl.h b/include/hw/arm/sharpsl.h
> index e986b28c527..36ed1df72a7 100644
> --- a/include/hw/arm/sharpsl.h
> +++ b/include/hw/arm/sharpsl.h
> @@ -7,7 +7,7 @@
>  #ifndef QEMU_SHARPSL_H
>  #define QEMU_SHARPSL_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  /* zaurus.c */
>  
> diff --git a/include/hw/arm/soc_dma.h b/include/hw/arm/soc_dma.h
> index e93a7499a80..14b802c2330 100644
> --- a/include/hw/arm/soc_dma.h
> +++ b/include/hw/arm/soc_dma.h
> @@ -21,7 +21,7 @@
>  #ifndef HW_SOC_DMA_H
>  #define HW_SOC_DMA_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  struct soc_dma_s;
>  struct soc_dma_ch_s;
> diff --git a/include/hw/arm/sysbus-fdt.h b/include/hw/arm/sysbus-fdt.h
> index 340c382cdde..7a8ace37b4c 100644
> --- a/include/hw/arm/sysbus-fdt.h
> +++ b/include/hw/arm/sysbus-fdt.h
> @@ -24,7 +24,7 @@
>  #ifndef HW_ARM_SYSBUS_FDT_H
>  #define HW_ARM_SYSBUS_FDT_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  /**
>   * platform_bus_add_all_fdt_nodes - create all the platform bus nodes
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index 921416f918b..504b0bb6e57 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -30,7 +30,7 @@
>  #ifndef QEMU_ARM_VIRT_H
>  #define QEMU_ARM_VIRT_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qemu/notify.h"
>  #include "hw/boards.h"
>  #include "hw/arm/boot.h"
> diff --git a/include/hw/block/block.h b/include/hw/block/block.h
> index c172cbe65f1..0f36b1f0277 100644
> --- a/include/hw/block/block.h
> +++ b/include/hw/block/block.h
> @@ -11,7 +11,7 @@
>  #ifndef HW_BLOCK_H
>  #define HW_BLOCK_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qapi/qapi-types-block-core.h"
>  #include "hw/qdev-properties-system.h"
>  
> diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h
> index 1ecca7cac7f..7f0fb3d3986 100644
> --- a/include/hw/block/fdc.h
> +++ b/include/hw/block/fdc.h
> @@ -1,7 +1,7 @@
>  #ifndef HW_FDC_H
>  #define HW_FDC_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qapi/qapi-types-block.h"
>  
>  /* fdc.c */
> diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h
> index 86d8363bb09..e184df092eb 100644
> --- a/include/hw/block/flash.h
> +++ b/include/hw/block/flash.h
> @@ -3,7 +3,7 @@
>  
>  /* NOR flash devices */
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qom/object.h"
>  
>  /* pflash_cfi01.c */
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index e4328de8d41..7aa5c82fa20 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -22,7 +22,9 @@
>  
>  #include "hw/qdev-core.h"
>  #include "disas/dis-asm.h"
> -#include "exec/hwaddr.h"
> +#if !defined(CONFIG_USER_ONLY)
> +#include "exec/sysemu/hwaddr.h"
> +#endif
>  #include "exec/memattrs.h"
>  #include "qapi/qapi-types-run-state.h"
>  #include "qemu/bitmap.h"
> diff --git a/include/hw/cris/etraxfs_dma.h b/include/hw/cris/etraxfs_dma.h
> index 095d76b9560..f0a4038c8ae 100644
> --- a/include/hw/cris/etraxfs_dma.h
> +++ b/include/hw/cris/etraxfs_dma.h
> @@ -1,7 +1,7 @@
>  #ifndef HW_ETRAXFS_DMA_H
>  #define HW_ETRAXFS_DMA_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  struct dma_context_metadata {
>  	/* data descriptor md */
> diff --git a/include/hw/display/vga.h b/include/hw/display/vga.h
> index 5f7825e0e36..d63e0bb9c94 100644
> --- a/include/hw/display/vga.h
> +++ b/include/hw/display/vga.h
> @@ -9,7 +9,7 @@
>  #ifndef QEMU_HW_DISPLAY_VGA_H
>  #define QEMU_HW_DISPLAY_VGA_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  /*
>   * modules can reference this symbol to avoid being loaded
> diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h
> index f25f8374413..e6931917ed1 100644
> --- a/include/hw/i386/microvm.h
> +++ b/include/hw/i386/microvm.h
> @@ -19,7 +19,7 @@
>  #define HW_I386_MICROVM_H
>  
>  #include "qemu-common.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qemu/notify.h"
>  
>  #include "hw/boards.h"
> diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
> index c09b648dff2..b594f829cdb 100644
> --- a/include/hw/i386/x86.h
> +++ b/include/hw/i386/x86.h
> @@ -18,7 +18,7 @@
>  #define HW_I386_X86_H
>  
>  #include "qemu-common.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qemu/notify.h"
>  
>  #include "hw/i386/topology.h"
> diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h
> index 0cd7b59064a..f4c1e787d2b 100644
> --- a/include/hw/input/lasips2.h
> +++ b/include/hw/input/lasips2.h
> @@ -7,7 +7,7 @@
>  #ifndef HW_INPUT_LASIPS2_H
>  #define HW_INPUT_LASIPS2_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  #define TYPE_LASIPS2 "lasips2"
>  
> diff --git a/include/hw/loader-fit.h b/include/hw/loader-fit.h
> index 0832e379dc9..138da77d664 100644
> --- a/include/hw/loader-fit.h
> +++ b/include/hw/loader-fit.h
> @@ -20,7 +20,7 @@
>  #ifndef HW_LOADER_FIT_H
>  #define HW_LOADER_FIT_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  struct fit_loader_match {
>      const char *compatible;
> diff --git a/include/hw/misc/allwinner-h3-dramc.h b/include/hw/misc/allwinner-h3-dramc.h
> index 0b6c877ef74..93e640b23af 100644
> --- a/include/hw/misc/allwinner-h3-dramc.h
> +++ b/include/hw/misc/allwinner-h3-dramc.h
> @@ -22,7 +22,7 @@
>  
>  #include "qom/object.h"
>  #include "hw/sysbus.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  /**
>   * Constants
> diff --git a/include/hw/misc/empty_slot.h b/include/hw/misc/empty_slot.h
> index dec56e56ae4..d942aebd3e7 100644
> --- a/include/hw/misc/empty_slot.h
> +++ b/include/hw/misc/empty_slot.h
> @@ -12,7 +12,7 @@
>  #ifndef HW_EMPTY_SLOT_H
>  #define HW_EMPTY_SLOT_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  void empty_slot_init(const char *name, hwaddr addr, uint64_t slot_size);
>  
> diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
> index 0e7a8bc7af2..af1f8df9cf0 100644
> --- a/include/hw/nvram/fw_cfg.h
> +++ b/include/hw/nvram/fw_cfg.h
> @@ -1,7 +1,7 @@
>  #ifndef FW_CFG_H
>  #define FW_CFG_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "standard-headers/linux/qemu_fw_cfg.h"
>  #include "hw/sysbus.h"
>  #include "sysemu/dma.h"
> diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h
> index fcf8b638200..52da437057e 100644
> --- a/include/hw/pci-host/gpex.h
> +++ b/include/hw/pci-host/gpex.h
> @@ -20,7 +20,7 @@
>  #ifndef HW_GPEX_H
>  #define HW_GPEX_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "hw/sysbus.h"
>  #include "hw/pci/pci.h"
>  #include "hw/pci/pcie_host.h"
> diff --git a/include/hw/remote/memory.h b/include/hw/remote/memory.h
> index bc2e30945f5..200fc982a00 100644
> --- a/include/hw/remote/memory.h
> +++ b/include/hw/remote/memory.h
> @@ -11,7 +11,7 @@
>  #ifndef REMOTE_MEMORY_H
>  #define REMOTE_MEMORY_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "hw/remote/mpqemu-link.h"
>  
>  void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp);
> diff --git a/include/hw/remote/mpqemu-link.h b/include/hw/remote/mpqemu-link.h
> index 4ec09158851..9b56b30a311 100644
> --- a/include/hw/remote/mpqemu-link.h
> +++ b/include/hw/remote/mpqemu-link.h
> @@ -14,7 +14,7 @@
>  #include "qom/object.h"
>  #include "qemu/thread.h"
>  #include "io/channel.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "io/channel-socket.h"
>  #include "hw/remote/proxy.h"
>  
> diff --git a/include/hw/rtc/m48t59.h b/include/hw/rtc/m48t59.h
> index d9b45eb1612..dda5ef4a20a 100644
> --- a/include/hw/rtc/m48t59.h
> +++ b/include/hw/rtc/m48t59.h
> @@ -26,7 +26,7 @@
>  #ifndef HW_RTC_M48T59_H
>  #define HW_RTC_M48T59_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "qom/object.h"
>  
>  #define TYPE_NVRAM "nvram"
> diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h
> index fd868f6ed2f..b2e27447121 100644
> --- a/include/hw/rtc/sun4v-rtc.h
> +++ b/include/hw/rtc/sun4v-rtc.h
> @@ -12,7 +12,7 @@
>  #ifndef HW_RTC_SUN4V
>  #define HW_RTC_SUN4V
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  void sun4v_rtc_init(hwaddr addr);
>  
> diff --git a/include/hw/timer/tmu012.h b/include/hw/timer/tmu012.h
> index 808ed8de1d7..ea98ff0b3f1 100644
> --- a/include/hw/timer/tmu012.h
> +++ b/include/hw/timer/tmu012.h
> @@ -9,7 +9,7 @@
>  #ifndef HW_TIMER_TMU012_H
>  #define HW_TIMER_TMU012_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  #define TMU012_FEAT_TOCR   (1 << 0)
>  #define TMU012_FEAT_3CHAN  (1 << 1)
> diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h
> index 6818a23a2d3..b18e0109d9f 100644
> --- a/include/hw/virtio/virtio-access.h
> +++ b/include/hw/virtio/virtio-access.h
> @@ -16,7 +16,7 @@
>  #ifndef QEMU_VIRTIO_ACCESS_H
>  #define QEMU_VIRTIO_ACCESS_H
>  
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "hw/virtio/virtio.h"
>  #include "hw/virtio/virtio-bus.h"
>  
> diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
> index af3887bb71d..b70fb361e3a 100644
> --- a/include/monitor/monitor.h
> +++ b/include/monitor/monitor.h
> @@ -4,7 +4,7 @@
>  #include "block/block.h"
>  #include "qapi/qapi-types-misc.h"
>  #include "qemu/readline.h"
> -#include "include/exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  typedef struct MonitorHMP MonitorHMP;
>  typedef struct MonitorOptions MonitorOptions;
> diff --git a/include/qemu/accel.h b/include/qemu/accel.h
> index 4f4c283f6fc..2fc5feddff2 100644
> --- a/include/qemu/accel.h
> +++ b/include/qemu/accel.h
> @@ -24,7 +24,9 @@
>  #define QEMU_ACCEL_H
>  
>  #include "qom/object.h"
> -#include "exec/hwaddr.h"
> +#ifndef CONFIG_USER_ONLY
> +#include "exec/sysemu/hwaddr.h"
> +#endif
>  
>  typedef struct AccelState {
>      /*< private >*/
> diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h
> index b66cf93c4bc..1530cf0e95e 100644
> --- a/include/qemu/iova-tree.h
> +++ b/include/qemu/iova-tree.h
> @@ -24,7 +24,7 @@
>   */
>  
>  #include "exec/memory.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  #define  IOVA_OK           (0)
>  #define  IOVA_ERR_INVALID  (-1) /* Invalid parameters */
> diff --git a/include/qemu/userfaultfd.h b/include/qemu/userfaultfd.h
> index 6b74f92792d..2cdce404edf 100644
> --- a/include/qemu/userfaultfd.h
> +++ b/include/qemu/userfaultfd.h
> @@ -14,7 +14,7 @@
>  #define USERFAULTFD_H
>  
>  #include "qemu/osdep.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include <linux/userfaultfd.h>
>  
>  int uffd_query_features(uint64_t *features);
> diff --git a/dump/dump.c b/dump/dump.c
> index ab625909f30..544553d3579 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -15,7 +15,7 @@
>  #include "qemu-common.h"
>  #include "qemu/cutils.h"
>  #include "elf.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "monitor/monitor.h"
>  #include "sysemu/kvm.h"
>  #include "sysemu/dump.h"
> diff --git a/dump/win_dump.c b/dump/win_dump.c
> index c5eb5a9aacd..6c30c98fb09 100644
> --- a/dump/win_dump.c
> +++ b/dump/win_dump.c
> @@ -12,7 +12,7 @@
>  #include "qemu-common.h"
>  #include "qemu/cutils.h"
>  #include "elf.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "monitor/monitor.h"
>  #include "sysemu/kvm.h"
>  #include "sysemu/dump.h"
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index 43c19b49234..d01d93eb8f9 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -27,7 +27,7 @@
>  #include "sysemu/numa.h"
>  #include "sysemu/runstate.h"
>  #include "sysemu/sysemu.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "kvm_arm.h"
>  #include "hw/arm/boot.h"
>  #include "hw/block/flash.h"
> diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
> index e7faf24058b..f84f37411fd 100644
> --- a/hw/input/lasips2.c
> +++ b/hw/input/lasips2.c
> @@ -26,7 +26,7 @@
>  #include "hw/qdev-properties.h"
>  #include "hw/input/ps2.h"
>  #include "hw/input/lasips2.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "trace.h"
>  #include "exec/address-spaces.h"
>  #include "migration/vmstate.h"
> diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
> index de951ffe5d3..84c346e7420 100644
> --- a/hw/m68k/next-cube.c
> +++ b/hw/m68k/next-cube.c
> @@ -10,7 +10,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "sysemu/sysemu.h"
>  #include "sysemu/qtest.h"
>  #include "hw/irq.h"
> diff --git a/hw/ppc/pnv_homer.c b/hw/ppc/pnv_homer.c
> index 9a262629b73..394425232ed 100644
> --- a/hw/ppc/pnv_homer.c
> +++ b/hw/ppc/pnv_homer.c
> @@ -19,7 +19,7 @@
>  #include "qemu/osdep.h"
>  #include "qemu/log.h"
>  #include "qapi/error.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "exec/memory.h"
>  #include "sysemu/cpus.h"
>  #include "hw/qdev-core.h"
> diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c
> index 2b255579dfd..4d1c7fd863b 100644
> --- a/tests/qtest/microbit-test.c
> +++ b/tests/qtest/microbit-test.c
> @@ -15,7 +15,7 @@
>  
>  
>  #include "qemu/osdep.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  #include "libqos/libqtest.h"
>  
>  #include "hw/arm/nrf51.h"
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 78561a223f9..f1ae9934349 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -129,6 +129,7 @@ F: include/exec/cpu*.h
>  F: include/exec/exec-all.h
>  F: include/exec/helper*.h
>  F: include/exec/tb-hash.h
> +F: include/exec/sysemu/hwaddr.h
>  F: include/sysemu/cpus.h
>  F: include/sysemu/tcg.h
>  F: include/hw/core/tcg-cpu-ops.h
> diff --git a/scripts/codeconverter/codeconverter/test_regexps.py b/scripts/codeconverter/codeconverter/test_regexps.py
> index a445634d88a..41a2cd9c14c 100644
> --- a/scripts/codeconverter/codeconverter/test_regexps.py
> +++ b/scripts/codeconverter/codeconverter/test_regexps.py
> @@ -228,7 +228,7 @@ def test_initial_includes():
>  /* NOR flash devices */
>  
>  #include "qom/object.h"
> -#include "exec/hwaddr.h"
> +#include "exec/sysemu/hwaddr.h"
>  
>  /* pflash_cfi01.c */
>  '''
> @@ -236,7 +236,7 @@ def test_initial_includes():
>      m = InitialIncludes.domatch(c)
>      assert m
>      print(repr(m.group(0)))
> -    assert m.group(0).endswith('#include "exec/hwaddr.h"\n')
> +    assert m.group(0).endswith('#include "exec/sysemu/hwaddr.h"\n')
>  
>      c = '''#ifndef QEMU_VIRTIO_9P_H
>  #define QEMU_VIRTIO_9P_H



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2021-05-17 11:11 ` [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/ Philippe Mathieu-Daudé
  2021-05-26 18:15   ` Richard Henderson
  2022-12-06 14:53   ` Claudio Fontana
@ 2022-12-06 15:01   ` Peter Maydell
  2 siblings, 0 replies; 23+ messages in thread
From: Peter Maydell @ 2022-12-06 15:01 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Claudio Fontana,
	Laurent Vivier

On Mon, 17 May 2021 at 12:16, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Guard declarations within hwaddr.h against inclusion
> from user-mode emulation.

They're all safe, though; none of them are target-dependent.

I wonder if we should move MemMapEntry somewhere else -- it's used
in less than 20 files and doesn't really warrant putting
it in hwaddr.h.

-- PMM


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2022-12-06 14:53   ` Claudio Fontana
@ 2022-12-06 15:38     ` Claudio Fontana
  2022-12-06 17:09       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 23+ messages in thread
From: Claudio Fontana @ 2022-12-06 15:38 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson

On 12/6/22 15:53, Claudio Fontana wrote:
> On 5/17/21 13:11, Philippe Mathieu-Daudé wrote:
>> Guard declarations within hwaddr.h against inclusion
>> from user-mode emulation.
>>
>> To make it clearer this header is sysemu specific,
>> move it to the sysemu/ directory.
> 
> Hi Philippe,
> 
> do we need include/exec/sysemu/... .h
> 
> as opposed to just use the existing
> 
> include/sysemu/
> 
> ?

...and I would if anything go include/sysemu/exec/ not include/exec/sysemu ,

to highlight first that it is part of the sysemu build, when trying to reason about what gets built for sysemu vs anything else.

Ciao

C






^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2022-12-06 15:38     ` Claudio Fontana
@ 2022-12-06 17:09       ` Philippe Mathieu-Daudé
  2022-12-06 17:17         ` Richard Henderson
  2022-12-07 10:09         ` Claudio Fontana
  0 siblings, 2 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-12-06 17:09 UTC (permalink / raw)
  To: Claudio Fontana, Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson

On 6/12/22 16:38, Claudio Fontana wrote:
> On 12/6/22 15:53, Claudio Fontana wrote:
>> On 5/17/21 13:11, Philippe Mathieu-Daudé wrote:
>>> Guard declarations within hwaddr.h against inclusion
>>> from user-mode emulation.
>>>
>>> To make it clearer this header is sysemu specific,
>>> move it to the sysemu/ directory.
>>
>> Hi Philippe,
>>
>> do we need include/exec/sysemu/... .h
>>
>> as opposed to just use the existing
>>
>> include/sysemu/
>>
>> ?
> 
> ...and I would if anything go include/sysemu/exec/ not include/exec/sysemu ,
> 
> to highlight first that it is part of the sysemu build, when trying to reason about what gets built for sysemu vs anything else.

While refreshing this series I moved these files directly in 
include/sysemu/. Do you think the exec/ subdirectory {help|meaning}ful?


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2022-12-06 17:09       ` Philippe Mathieu-Daudé
@ 2022-12-06 17:17         ` Richard Henderson
  2022-12-07 10:09         ` Claudio Fontana
  1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2022-12-06 17:17 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Claudio Fontana, Philippe Mathieu-Daudé,
	qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini

On 12/6/22 11:09, Philippe Mathieu-Daudé wrote:
> On 6/12/22 16:38, Claudio Fontana wrote:
>> On 12/6/22 15:53, Claudio Fontana wrote:
>>> On 5/17/21 13:11, Philippe Mathieu-Daudé wrote:
>>>> Guard declarations within hwaddr.h against inclusion
>>>> from user-mode emulation.
>>>>
>>>> To make it clearer this header is sysemu specific,
>>>> move it to the sysemu/ directory.
>>>
>>> Hi Philippe,
>>>
>>> do we need include/exec/sysemu/... .h
>>>
>>> as opposed to just use the existing
>>>
>>> include/sysemu/
>>>
>>> ?
>>
>> ...and I would if anything go include/sysemu/exec/ not include/exec/sysemu ,
>>
>> to highlight first that it is part of the sysemu build, when trying to reason about what 
>> gets built for sysemu vs anything else.
> 
> While refreshing this series I moved these files directly in include/sysemu/. Do you think 
> the exec/ subdirectory {help|meaning}ful?

I don't think exec/ is particularly meaningful.


r~


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/
  2022-12-06 17:09       ` Philippe Mathieu-Daudé
  2022-12-06 17:17         ` Richard Henderson
@ 2022-12-07 10:09         ` Claudio Fontana
  1 sibling, 0 replies; 23+ messages in thread
From: Claudio Fontana @ 2022-12-07 10:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Philippe Mathieu-Daudé, qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Richard Henderson

On 12/6/22 18:09, Philippe Mathieu-Daudé wrote:
> On 6/12/22 16:38, Claudio Fontana wrote:
>> On 12/6/22 15:53, Claudio Fontana wrote:
>>> On 5/17/21 13:11, Philippe Mathieu-Daudé wrote:
>>>> Guard declarations within hwaddr.h against inclusion
>>>> from user-mode emulation.
>>>>
>>>> To make it clearer this header is sysemu specific,
>>>> move it to the sysemu/ directory.
>>>
>>> Hi Philippe,
>>>
>>> do we need include/exec/sysemu/... .h
>>>
>>> as opposed to just use the existing
>>>
>>> include/sysemu/
>>>
>>> ?
>>
>> ...and I would if anything go include/sysemu/exec/ not include/exec/sysemu ,
>>
>> to highlight first that it is part of the sysemu build, when trying to reason about what gets built for sysemu vs anything else.
> 
> While refreshing this series I moved these files directly in 
> include/sysemu/. Do you think the exec/ subdirectory {help|meaning}ful?
> 

Hi Philippe, not so much, I think include/sysemu/ is enough.

Ciao,

Claudio


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-12-07 10:11 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 11:11 [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 01/11] NOTFORMERGE target/arm: Restrict KVM files to softmmu Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 02/11] exec: Restrict hwaddr.h to sysemu/ Philippe Mathieu-Daudé
2021-05-26 18:15   ` Richard Henderson
2022-12-06 14:32     ` Philippe Mathieu-Daudé
2022-12-06 14:40       ` Philippe Mathieu-Daudé
2022-12-06 14:53   ` Claudio Fontana
2022-12-06 15:38     ` Claudio Fontana
2022-12-06 17:09       ` Philippe Mathieu-Daudé
2022-12-06 17:17         ` Richard Henderson
2022-12-07 10:09         ` Claudio Fontana
2022-12-06 15:01   ` Peter Maydell
2021-05-17 11:11 ` [PATCH 03/11] exec: Restrict cputlb.h " Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 04/11] exec: Restrict memory.h " Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 05/11] exec: Restrict memory-internal.h " Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 06/11] exec: Restrict address-spaces.h " Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 07/11] exec: Extract CPU I/O instructions to "cpu-io.h" Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 08/11] exec: Restrict ioport.h to sysemu/ Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 09/11] exec: Restrict ram_addr.h " Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 10/11] exec: Restrict ramblock.h " Philippe Mathieu-Daudé
2021-05-17 11:11 ` [PATCH 11/11] exec: Restrict confidential-guest-support.h " Philippe Mathieu-Daudé
2021-05-25 14:13 ` [PATCH 00/11] exec: Restrict various system emulation specific headers (to sysemu) Philippe Mathieu-Daudé
2021-11-06 14:58   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.