]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
include: reorganize memory API headers
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 27 Nov 2025 08:41:14 +0000 (09:41 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 27 Dec 2025 09:11:09 +0000 (10:11 +0100)
Move RAMBlock functions out of ram_addr.h and cpu-common.h;
move memory API headers out of include/exec and into include/system.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
102 files changed:
MAINTAINERS
accel/mshv/mshv-all.c
accel/tcg/cputlb.c
accel/tcg/tcg-accel-ops-mttcg.c
backends/hostmem.c
block/blkio.c
dump/dump.c
hw/acpi/ghes.c
hw/acpi/nvdimm.c
hw/acpi/vmgenid.c
hw/arm/omap1.c
hw/audio/marvell_88w8618.c
hw/char/riscv_htif.c
hw/core/cpu-common.c
hw/core/machine-qmp-cmds.c
hw/core/numa.c
hw/display/exynos4210_fimd.c
hw/display/omap_lcdc.c
hw/display/ramfb.c
hw/display/vga.c
hw/dma/i8257.c
hw/dma/omap_dma.c
hw/dma/rc4030.c
hw/dma/sifive_pdma.c
hw/hyperv/hyperv.c
hw/hyperv/syndbg.c
hw/hyperv/vmbus.c
hw/i386/kvm/clock.c
hw/i386/vapic.c
hw/intc/apic.c
hw/intc/xive2.c
hw/m68k/next-cube.c
hw/microblaze/boot.c
hw/misc/pc-testdev.c
hw/net/fsl_etsec/rings.c
hw/net/mcf_fec.c
hw/net/opencores_eth.c
hw/net/xgmac.c
hw/nvram/spapr_nvram.c
hw/ppc/amigaone.c
hw/ppc/e500.c
hw/ppc/pegasos.c
hw/ppc/pnv.c
hw/ppc/ppc440_uc.c
hw/ppc/spapr.c
hw/ppc/spapr_drc.c
hw/ppc/spapr_events.c
hw/ppc/spapr_hcall.c
hw/ppc/spapr_rtas.c
hw/ppc/spapr_tpm_proxy.c
hw/ppc/virtex_ml507.c
hw/remote/proxy-memory-listener.c
hw/s390x/css.c
hw/s390x/ipl.c
hw/s390x/s390-pci-bus.c
hw/s390x/s390-stattrib.c
hw/s390x/virtio-ccw.c
hw/scsi/vmw_pvscsi.c
hw/sparc/leon3.c
hw/vfio-user/container.c
hw/vfio/container.c
hw/vfio/helpers.c
hw/vfio/migration.c
hw/virtio/vhost.c
hw/xen/xen-mapcache.c
hw/xen/xen_pt_graphics.c
hw/xtensa/xtfpga.c
include/exec/cpu-common.h
include/exec/cputlb.h
include/exec/translation-block.h
include/hw/core/qdev-properties-system.h
include/hw/i2c/smbus_eeprom.h
include/hw/xen/xen-hvm-common.h
include/system/balloon.h
include/system/block-ram-registrar.h
include/system/iommufd.h
include/system/memory.h
include/system/memory_mapping.h
include/system/physmem.h
include/system/ram_addr.h
include/system/ramblock.h
include/system/ramlist.h [moved from include/exec/ramlist.h with 94% similarity]
include/system/xen-mapcache.h
include/system/xen.h
migration/migration.h
migration/ram.c
migration/ram.h
rust/hw/char/pl011/src/bindings.rs
rust/hw/core/src/bindings.rs
rust/system/src/bindings.rs
stubs/physmem.c
stubs/ram-block.c
system/ioport.c
system/memory.c
system/physmem.c
target/arm/kvm.c
target/i386/kvm/kvm.c
target/i386/sev.c
target/ppc/kvm.c
target/s390x/kvm/kvm.c
tests/qtest/fuzz/generic_fuzz.c
util/vfio-helpers.c

index 5d33892c34754a8ec71f4a669a17c3e6cc5e4dec..a03898ccb63e8831442e239cb0dc09f61987a912 100644 (file)
@@ -3254,9 +3254,9 @@ R: Philippe Mathieu-Daudé <philmd@linaro.org>
 S: Supported
 F: include/system/ioport.h
 F: include/exec/memop.h
+F: include/system/ram_addr.h
 F: include/system/memory.h
 F: include/system/physmem.h
-F: include/system/ram_addr.h
 F: include/system/ramblock.h
 F: include/system/memory_mapping.h
 F: system/dma-helpers.c
index 47c67ef8cc9494e32c9d716743794aa4d864e1c0..4675cb886fedef8d57eb065d8f38d233252ff1bf 100644 (file)
@@ -31,6 +31,7 @@
 #include "qemu/guest-random.h"
 #include "accel/accel-ops.h"
 #include "accel/accel-cpu-ops.h"
+#include "exec/cpu-common.h"
 #include "system/cpus.h"
 #include "system/runstate.h"
 #include "system/accel-blocker.h"
index fd1606c85656eb602f22f46d0f94412de33496d6..655d1e113f9ce5c28f905b1870ef020d28afa94e 100644 (file)
@@ -30,7 +30,7 @@
 #include "accel/tcg/cpu-mmu-index.h"
 #include "exec/cputlb.h"
 #include "exec/tb-flush.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "exec/mmu-access-type.h"
 #include "exec/tlb-common.h"
 #include "exec/vaddr.h"
index 89299829c3a66cc4900323a6a7282e6086428376..4160e2ba9470ef517430314cd54f39f0208628c4 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "exec/cpu-common.h"
 #include "system/tcg.h"
 #include "system/replay.h"
 #include "exec/icount.h"
index 67827c42b87bb415f79262734cb26b483ebb9b37..15d4365b697e6f6191dbe8fd1b0ea6fc096600a8 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "system/hostmem.h"
+#include "system/ramblock.h"
 #include "hw/core/boards.h"
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
index 4142673984706dd2aa67bb4dc1e75a6a88eeff37..20f138a38c55fa6c75930d21b3ed2c34e20e0adc 100644 (file)
@@ -12,7 +12,7 @@
 #include <blkio.h>
 #include "block/block_int.h"
 #include "system/memory.h"
-#include "exec/cpu-common.h" /* for qemu_ram_get_fd() */
+#include "system/ramblock.h"
 #include "qemu/defer-call.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
index 15bbcc0c6192822cf920fcb7d60eb7d2cfad0952..f7a99a7af2eb0f2df340e24637a8d1eac128c8b6 100644 (file)
@@ -15,6 +15,7 @@
 #include "qemu/cutils.h"
 #include "elf.h"
 #include "qemu/bswap.h"
+#include "exec/cpu-common.h"
 #include "exec/target_page.h"
 #include "monitor/monitor.h"
 #include "system/dump.h"
index 06555905cebbf9a54af365f379eab7de13938652..365156dff903224371745caec17be2279b43ad1e 100644 (file)
@@ -27,6 +27,7 @@
 #include "hw/acpi/generic_event_device.h"
 #include "hw/nvram/fw_cfg.h"
 #include "qemu/uuid.h"
+#include "exec/cpu-common.h"
 
 #define ACPI_HW_ERROR_FW_CFG_FILE           "etc/hardware_errors"
 #define ACPI_HW_ERROR_ADDR_FW_CFG_FILE      "etc/hardware_errors_addr"
index 732d613ac09201213992e9229d1794f34a5b7141..eb4b47707655072182312c3daa82ba888db04533 100644 (file)
@@ -36,6 +36,7 @@
 #include "hw/mem/nvdimm.h"
 #include "qemu/nvdimm-utils.h"
 #include "trace.h"
+#include "exec/cpu-common.h"
 
 /*
  * define Byte Addressable Persistent Memory (PM) Region according to
index e87c02569647ecc89ea6070c63dca658c3c1393e..70ad029057ba64d0ff7f833a85a8b094d3f8fbd1 100644 (file)
@@ -21,6 +21,7 @@
 #include "hw/core/qdev-properties-system.h"
 #include "migration/vmstate.h"
 #include "system/reset.h"
+#include "exec/cpu-common.h"
 
 void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,
                         BIOSLinker *linker, const char *oem_id)
index f5ff4b107ae123853d5bfd6dcd725d5a399cd8cd..9ca8eecfa09e8678675a665dbd00433a3ac7760b 100644 (file)
@@ -24,6 +24,7 @@
 #include "qapi/error.h"
 #include "cpu.h"
 #include "system/address-spaces.h"
+#include "exec/cpu-common.h"
 #include "hw/core/hw-error.h"
 #include "hw/core/irq.h"
 #include "hw/core/qdev-properties.h"
index 6d5e99123d6e35740fbbb8bbfa99c5db8fb9b23d..4ad4a220a9880295845eb6c8405a46616f9a38dd 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 #include "hw/core/irq.h"
 #include "hw/core/qdev-properties.h"
index a78ea9b01c054ab3da76fe066a64886a9c92a6e8..e9efab16e99981998df93cd27e3253370fec722c 100644 (file)
@@ -31,6 +31,7 @@
 #include "system/address-spaces.h"
 #include "system/dma.h"
 #include "system/runstate.h"
+#include "exec/cpu-common.h"
 #include "trace.h"
 
 #define HTIF_DEV_SHIFT          56
index 2e925880afa901381dbee9782bb97999a3fcb079..6d54c12a778fc2a65f0b48c14633f46781733f89 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "exec/cpu-common.h"
 #include "qapi/error.h"
 #include "hw/core/cpu.h"
 #include "system/hw_accel.h"
index d23466177d846d0ddddbb7cb9b185d31f107a518..79cbcdd63e8c1bdc63a02201f13add370f586d44 100644 (file)
@@ -26,6 +26,7 @@
 #include "system/hostmem.h"
 #include "system/hw_accel.h"
 #include "system/numa.h"
+#include "system/ramlist.h"
 #include "system/runstate.h"
 #include "system/system.h"
 #include "hw/s390x/storage-keys.h"
index fa78dacb6beec4fab4d81dc68412cb8daaf4fc0b..f462883c87cf7784f9df2ebea8bc88e8f7fb9fc8 100644 (file)
@@ -27,7 +27,8 @@
 #include "system/hostmem.h"
 #include "system/numa.h"
 #include "exec/cpu-common.h"
-#include "exec/ramlist.h"
+#include "system/ramlist.h"
+#include "system/ramblock.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qapi/opts-visitor.h"
index a97054132fb8ac9b84e9ff39463876044a92bb52..2d8fa7ee94466ff4eceb12b0395041f88689ca3a 100644 (file)
@@ -27,6 +27,7 @@
 #include "hw/core/hw-error.h"
 #include "hw/core/irq.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 #include "ui/console.h"
 #include "ui/pixel_ops.h"
index 90a9731454165d2c7f3d0204f71623018d37fd5e..c41c65bb2e045cf301459073322fdb324a6ccaeb 100644 (file)
@@ -23,6 +23,7 @@
 #include "hw/arm/omap.h"
 #include "framebuffer.h"
 #include "ui/pixel_ops.h"
+#include "exec/cpu-common.h"
 
 struct omap_lcd_panel_s {
     MemoryRegion *sysmem;
index ad12fb1782e37da96311c9a1f42ae74eabc1af98..50c25706a522411ac24906bca1583c0ca1717573 100644 (file)
@@ -18,6 +18,7 @@
 #include "hw/display/bochs-vbe.h" /* for limits */
 #include "ui/console.h"
 #include "system/reset.h"
+#include "exec/cpu-common.h"
 
 struct QEMU_PACKED RAMFBCfg {
     uint64_t addr;
index 90b89cf40447c7c4f47b058b1f307662ad6ebaf8..59a65cbbff5647d11e3dd8ebe294ede3fcf77bcf 100644 (file)
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "system/reset.h"
+#include "system/ramblock.h"
 #include "qapi/error.h"
 #include "qemu/target-info.h"
 #include "hw/display/vga.h"
index d909d6c8fc23d877fc0d867c6fbbd326e31a814b..3637d8f82d7e039ad8197e5b53054dab19b15e65 100644 (file)
@@ -27,6 +27,7 @@
 #include "hw/core/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "hw/dma/i8257.h"
+#include "exec/cpu-common.h"
 #include "qapi/error.h"
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
index 2bf9ebad565a8f474e6c568971c839bdefb0526e..963ce6fd1027da02f3efa41a977ecf39800ca19f 100644 (file)
@@ -23,6 +23,7 @@
 #include "hw/arm/omap.h"
 #include "hw/core/irq.h"
 #include "hw/arm/soc_dma.h"
+#include "exec/cpu-common.h"
 
 struct omap_dma_channel_s {
     /* transfer data */
index 93db286e690c8f44f1e5645692d1143c030ca47d..159d0173913be41758e986388f71130fe2cc2698 100644 (file)
@@ -27,6 +27,7 @@
 #include "hw/core/irq.h"
 #include "hw/mips/mips.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
 #include "qemu/timer.h"
index 2844515b2d76ce245212dd0f5bb6540545ee8578..6d06ec0375f3a07093d6625ff497e1c42241222e 100644 (file)
@@ -27,6 +27,7 @@
 #include "hw/core/irq.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 #include "system/dma.h"
 #include "hw/dma/sifive_pdma.h"
index e4d0688dbfab94f16240e79d811408191a9fd824..27e323a81962650013173b0c67e0f9fc1601073d 100644 (file)
@@ -14,6 +14,7 @@
 #include "system/address-spaces.h"
 #include "system/memory.h"
 #include "exec/target_page.h"
+#include "exec/cpu-common.h"
 #include "linux/kvm.h"
 #include "system/kvm.h"
 #include "qemu/bitops.h"
index dc6cc84b503c809dd7dcd4d85f779297405d3254..1e177f9dd826dd2b75a8af791f9341a2ca4f7758 100644 (file)
@@ -19,6 +19,7 @@
 #include "hw/hyperv/hyperv.h"
 #include "hw/hyperv/vmbus-bridge.h"
 #include "hw/hyperv/hyperv-proto.h"
+#include "exec/cpu-common.h"
 #include "net/net.h"
 #include "net/eth.h"
 #include "net/checksum.h"
index c01f33923603191e538c9430217a01e40ae55823..c5bab5d245206859d9962a905616c51603032145 100644 (file)
@@ -19,6 +19,7 @@
 #include "hw/hyperv/vmbus.h"
 #include "hw/hyperv/vmbus-bridge.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "exec/target_page.h"
 #include "trace.h"
 
index 8ca88afae24bc04b8b891f9909c687054c1023ca..aba6842a22c38eb6deb52f59b1d54f6e9db2caca 100644 (file)
@@ -24,6 +24,7 @@
 #include "hw/core/sysbus.h"
 #include "hw/i386/kvm/clock.h"
 #include "hw/core/qdev-properties.h"
+#include "exec/cpu-common.h"
 #include "qapi/error.h"
 
 #include <linux/kvm.h>
index 32f92a28b8815901980828040c016515e92d4687..670a50524d660648b34aef7e76f069dad1b66d8b 100644 (file)
@@ -21,6 +21,7 @@
 #include "hw/i386/apic_internal.h"
 #include "hw/core/sysbus.h"
 #include "hw/core/boards.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
 
index aad253af15822e6ef67ddc4e17826057bb8bbce4..dd8c77f81807f67be6528b2a21b6f4b300e70ea6 100644 (file)
@@ -30,6 +30,7 @@
 #include "system/mshv.h"
 #include "trace.h"
 #include "hw/i386/apic-msidef.h"
+#include "exec/cpu-common.h"
 #include "qapi/error.h"
 #include "qom/object.h"
 
index 495925196a8811ed5129c3cf22e3ac5e9d6af10f..d353391208eabb194c933b5f862d443a09a5664f 100644 (file)
@@ -17,6 +17,7 @@
 #include "hw/ppc/xive.h"
 #include "hw/ppc/xive2.h"
 #include "hw/ppc/xive2_regs.h"
+#include "exec/cpu-common.h"
 #include "trace.h"
 
 static void xive2_router_end_notify(Xive2Router *xrtr, uint8_t end_blk,
index ca3df7b887b5e7a68435ce5f852d4342c426ecc8..26177c7b8679d434fabd82d119e579be0585c511 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "exec/hwaddr.h"
+#include "exec/cpu-common.h"
 #include "exec/cpu-interrupt.h"
 #include "system/system.h"
 #include "system/qtest.h"
index 8ff99b3339d2e1b0dc1f407acb3e7e456b959162..a6f9ebab90c1417b78d67248ff49498bb439ebaa 100644 (file)
@@ -33,6 +33,7 @@
 #include "qemu/guest-random.h"
 #include "system/device_tree.h"
 #include "system/reset.h"
+#include "exec/cpu-common.h"
 #include "hw/core/boards.h"
 #include "hw/core/loader.h"
 #include "elf.h"
index 4093cb3c99c62b35d378057ad342314c63aa7af1..228012e772f81c5d4ce15c9f0c8af9ce4d36831b 100644 (file)
@@ -39,6 +39,7 @@
 #include "qemu/module.h"
 #include "hw/core/irq.h"
 #include "hw/isa/isa.h"
+#include "exec/cpu-common.h"
 #include "qom/object.h"
 
 #define IOMEM_LEN    0x10000
index 42216de6c9ac13af6c39f1b1af7a268179e05e69..22660c32b840ccdda9b4ec44d409b1dce72a3796 100644 (file)
@@ -26,6 +26,7 @@
 #include "qemu/log.h"
 #include "etsec.h"
 #include "registers.h"
+#include "exec/cpu-common.h"
 
 /* #define ETSEC_RING_DEBUG */
 /* #define HEX_DUMP */
index 5f267e5ea389a65132957251dc4f76dcdb6e9610..79a5c4385c6a733c59b8dbeb91df3e86397d04d9 100644 (file)
@@ -16,6 +16,7 @@
 #include "hw/net/mii.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include <zlib.h> /* for crc32 */
 
 //#define DEBUG_FEC 1
index ec3301414cc0a741ed05b2f10446740a2cd5acb2..6abeffcc9c7494aa204b210e6ad8f10a7cb695e0 100644 (file)
@@ -36,6 +36,7 @@
 #include "hw/net/mii.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "net/net.h"
 #include "qemu/module.h"
 #include "net/eth.h"
index 8d316e94c178dff9cd49e3a32caca7673888d9ac..204c78aba379d1717887da6c70ebe23507c40f3c 100644 (file)
@@ -28,6 +28,7 @@
 #include "hw/core/irq.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/core/sysbus.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "net/net.h"
index 58d81f77c88194749f9b1f3565612fda07d44d95..3af7e6ecbec9bc355dc98b3d24a2c7076d6bfe0b 100644 (file)
@@ -38,6 +38,7 @@
 #include "hw/ppc/spapr_vio.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/core/qdev-properties-system.h"
+#include "exec/cpu-common.h"
 #include "qom/object.h"
 
 struct SpaprNvram {
index 4b858443806a68afc5718804c16e1c2714147287..8074713fbe9a52783efc66a173049473d6fa5285 100644 (file)
@@ -21,6 +21,7 @@
 #include "hw/ide/pci.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/ppc/ppc.h"
+#include "exec/cpu-common.h"
 #include "system/block-backend.h"
 #include "system/qtest.h"
 #include "system/reset.h"
index 113a2daca1d79aa0ef30621356d29df14dba96b6..eb0d3a418e2ce6a4f2e63067c640598339a20c4e 100644 (file)
@@ -52,6 +52,7 @@
 #include "hw/core/irq.h"
 #include "hw/sd/sdhci.h"
 #include "hw/misc/unimp.h"
+#include "exec/cpu-common.h"
 
 #define EPAPR_MAGIC                (0x45504150)
 #define DTC_LOAD_PAD               0x1800000
index 3e4d19fbe844c6a169c3b4c06496912a645b3567..ac9fc5a654224932d28fb1718880c58ed99d4d88 100644 (file)
@@ -39,6 +39,7 @@
 #include "qemu/datadir.h"
 #include "system/device_tree.h"
 #include "hw/ppc/vof.h"
+#include "exec/cpu-common.h"
 
 #include <libfdt.h>
 
index f891c3a797c07c918144baa1c93f815a1659b1dc..1513575b8f373f815538dc46ac5551bad291d813 100644 (file)
@@ -58,6 +58,7 @@
 #include "hw/isa/isa.h"
 #include "hw/char/serial-isa.h"
 #include "hw/rtc/mc146818rtc.h"
+#include "exec/cpu-common.h"
 
 #include <libfdt.h>
 
index fc6dd332e881ae986903a8e284139f7f316d17c7..0f28a7937fb1a595a481d895ebe7cbeacf77266f 100644 (file)
@@ -17,6 +17,7 @@
 #include "hw/pci-host/ppc4xx.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/pci/pci.h"
+#include "exec/cpu-common.h"
 #include "system/reset.h"
 #include "cpu.h"
 #include "ppc440.h"
index eb626547ebdc66ef201a96df792b3018c5b2a33f..bcf6aa560f3edf8a90484007eefa17e740f8aa23 100644 (file)
@@ -43,6 +43,7 @@
 #include "system/reset.h"
 #include "system/runstate.h"
 #include "qemu/log.h"
+#include "exec/cpu-common.h"
 #include "hw/core/fw-path-provider.h"
 #include "elf.h"
 #include "net/net.h"
index d2044b4fb52275436627cf01312298fd690e80fe..9bc65c760ea6075be6b24830c3f85b91a0dd1a2e 100644 (file)
@@ -23,6 +23,7 @@
 #include "hw/ppc/spapr.h" /* for RTAS return codes */
 #include "hw/pci-host/spapr.h" /* spapr_phb_remove_pci_device_cb callback */
 #include "hw/ppc/spapr_nvdimm.h"
+#include "exec/cpu-common.h"
 #include "system/device_tree.h"
 #include "system/reset.h"
 #include "trace.h"
index b1774e88f2bc8f2be6f522daf1d30a757f48d20e..1a21ac7bbf8b9055184574dbd9a6bb0b00d39e1b 100644 (file)
@@ -41,6 +41,7 @@
 #include "qemu/bcd.h"
 #include "qemu/main-loop.h"
 #include "hw/ppc/spapr_ovec.h"
+#include "exec/cpu-common.h"
 #include <libfdt.h>
 #include "migration/blocker.h"
 
index 8f03b3e77648d27d89cbe89e53ca0e9aefb592f6..032805a8d0db8238c40eea967e2f743c714235e9 100644 (file)
@@ -24,6 +24,7 @@
 #include "hw/ppc/spapr_numa.h"
 #include "mmu-book3s-v3.h"
 #include "hw/mem/memory-device.h"
+#include "exec/cpu-common.h"
 
 bool is_ram_address(SpaprMachineState *spapr, hwaddr addr)
 {
index a6715b4026d5bf344dac535e0aa2e696a728b3a6..cb79ad340530c5263a6d2ff38d652b7a27dc7fa3 100644 (file)
@@ -46,6 +46,7 @@
 #include "qemu/cutils.h"
 #include "trace.h"
 #include "hw/ppc/fdt.h"
+#include "exec/cpu-common.h"
 #include "target/ppc/mmu-hash64.h"
 #include "target/ppc/mmu-book3s-v3.h"
 #include "migration/blocker.h"
index a48dab7e7a679abe6b43518f0e85f97c14db5c5a..361a3dc817d4af17bf9203e5543ca24184b0fa90 100644 (file)
@@ -16,6 +16,7 @@
 #include "system/reset.h"
 #include "hw/ppc/spapr.h"
 #include "hw/core/qdev-properties.h"
+#include "exec/cpu-common.h"
 #include "trace.h"
 
 #define TPM_SPAPR_BUFSIZE 4096
index 8b3e67b627c0c0a35c7da862081f7738e38bd375..51b3d7d7121f575a4a8daefc36f5b2871a1c4515 100644 (file)
@@ -44,6 +44,7 @@
 #include "hw/ppc/ppc.h"
 #include "hw/ppc/ppc4xx.h"
 #include "hw/core/qdev-properties.h"
+#include "exec/cpu-common.h"
 
 #include <libfdt.h>
 
index e1a52d24f0bfe48e0f480ab7843ed98260465d63..d0c856b0939375d533ec7de3bf65c8907ae834d0 100644 (file)
@@ -11,6 +11,7 @@
 #include "qemu/int128.h"
 #include "qemu/range.h"
 #include "system/memory.h"
+#include "system/ramblock.h"
 #include "exec/cpu-common.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
index d2c0af6a9bf5bcde411cbc4c5222ea424776938e..ccc9c1c243b9b855c2b0ee8fbf2db2bfaa63d01e 100644 (file)
@@ -22,6 +22,7 @@
 #include "hw/s390x/s390_flic.h"
 #include "hw/s390x/s390-virtio-ccw.h"
 #include "hw/s390x/s390-ccw.h"
+#include "exec/cpu-common.h"
 
 typedef struct CrwContainer {
     CRW crw;
index b119a87a864624441c331b11c86f1b984c76cd7f..d34adb55220c079c98da626ffc2c8e15ccd37a6d 100644 (file)
@@ -28,6 +28,7 @@
 #include "hw/s390x/ebcdic.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-net.h"
+#include "exec/cpu-common.h"
 #include "ipl.h"
 #include "qemu/error-report.h"
 #include "qemu/config-file.h"
index ff415b6312d193608183c4588a3bc1e089b5e4f5..30fdca1e8a68dacdaf61f72f7a07b8fb97698efc 100644 (file)
@@ -25,6 +25,7 @@
 #include "hw/core/qdev-properties.h"
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/msi.h"
+#include "exec/cpu-common.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
 #include "system/reset.h"
index f149af16ac13af059a639b5cbb161f0255787587..d808ece3b9206e77463f0f43a689a92edf638f99 100644 (file)
@@ -12,6 +12,7 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "exec/target_page.h"
+#include "system/ram_addr.h"
 #include "migration/qemu-file.h"
 #include "migration/register.h"
 #include "hw/core/qdev-properties.h"
index 4a3ffb84f8fd6deaf3366d1da5d505eec0fb8194..b4011c4049df979ce3f1329b90fab4c6419ef10e 100644 (file)
@@ -32,6 +32,7 @@
 #include "trace.h"
 #include "hw/s390x/css-bridge.h"
 #include "hw/s390x/s390-virtio-ccw.h"
+#include "exec/cpu-common.h"
 #include "system/replay.h"
 
 #define NR_CLASSIC_INDICATOR_BITS 64
index b3cdc255b4687a748935e5a5e4eede8261c05d0b..11ae6b9b7474b9bc87621137eb7911361b5fd721 100644 (file)
@@ -34,6 +34,7 @@
 #include "scsi/constants.h"
 #include "hw/pci/msi.h"
 #include "hw/core/qdev-properties.h"
+#include "exec/cpu-common.h"
 #include "vmw_pvscsi.h"
 #include "trace.h"
 #include "qom/object.h"
index ec9a386b48d9da2eef5ae2f7ed94a25c124e10a5..d4e25f761a62eb8da51011e6438cec0b8a4ed190 100644 (file)
@@ -29,6 +29,7 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qemu/datadir.h"
+#include "exec/cpu-common.h"
 #include "cpu.h"
 #include "hw/core/irq.h"
 #include "qemu/timer.h"
index dab7a23224cb65d516fa5da22efc6ff73b699a8a..d5275a463b8d99eae967114e4e0ade70b2076570 100644 (file)
@@ -15,6 +15,7 @@
 #include "hw/vfio-user/trace.h"
 #include "hw/vfio/vfio-device.h"
 #include "hw/vfio/vfio-listener.h"
+#include "system/ramblock.h"
 #include "qapi/error.h"
 
 /*
index 013a691bc5a8a698f6cab71156f4a3595bcce797..5993d9054579077683720959cfc8e0d76eef519d 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/vfio.h>
 
 #include "system/tcg.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/vfio/vfio-container.h"
index 2cbc7b4964f98ad2136697707912069ff998a4c3..c595f860cea91398bffce515e8d25bd462c1a20b 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/ioctl.h>
 
 #include "system/kvm.h"
+#include "exec/cpu-common.h"
 #include "hw/vfio/vfio-device.h"
 #include "hw/core/hw-error.h"
 #include "qapi/error.h"
index fde343f06e3bb086098e6a216de0d7c2321655fd..58a4940b00eb0a070a5a48dc773fe56c42f377cd 100644 (file)
@@ -27,7 +27,7 @@
 #include "migration-multifd.h"
 #include "qapi/error.h"
 #include "qapi/qapi-events-vfio.h"
-#include "exec/ramlist.h"
+#include "system/ramlist.h"
 #include "pci.h"
 #include "trace.h"
 #include "hw/core/hw-error.h"
index e654ea468a022c20b0976b1ea65973410636df4f..31e9704cdc6271becb073065ec38de6f893c85bd 100644 (file)
@@ -28,6 +28,7 @@
 #include "migration/qemu-file-types.h"
 #include "system/dma.h"
 #include "system/memory.h"
+#include "system/ramblock.h"
 #include "trace.h"
 
 /* enabled until disconnected backend stabilizes */
index e31d3797025f0f0e6eee18c3f56afe8be2abdb79..11115f6084518592e5192d0060feb360305a994e 100644 (file)
@@ -18,6 +18,7 @@
 #include "hw/xen/xen_native.h"
 #include "qemu/bitmap.h"
 
+#include "system/ramlist.h"
 #include "system/runstate.h"
 #include "system/xen-mapcache.h"
 #include "trace.h"
index 2c0cec97234eb0de2a34179ad3e9f4be439aef14..445f33e1726699b73e51c8c4a19be2a038878699 100644 (file)
@@ -5,6 +5,7 @@
 #include "qapi/error.h"
 #include "hw/xen/xen_pt.h"
 #include "hw/xen/xen_igd.h"
+#include "exec/cpu-common.h"
 #include "xen-host-pci-device.h"
 
 static unsigned long igd_guest_opregion;
index 5e6f897429d286785eb1f9b5b70e5b081c523410..d427d68e50585680f2c23057ebb85b3e77ea1d21 100644 (file)
@@ -49,6 +49,7 @@
 #include "bootparam.h"
 #include "xtensa_memory.h"
 #include "hw/xtensa/mx_pic.h"
+#include "exec/cpu-common.h"
 #include "migration/vmstate.h"
 
 typedef struct XtfpgaFlashDesc {
index e0be4ee2b8fdb32558ddcb10fbf59437dd0d7e0c..b2e02c60d4a94d59b725818a12c3f32f4f76bf21 100644 (file)
@@ -38,69 +38,6 @@ int cpu_get_free_index(void);
 void tcg_iommu_init_notifier_list(CPUState *cpu);
 void tcg_iommu_free_notifier_list(CPUState *cpu);
 
-enum device_endian {
-    DEVICE_NATIVE_ENDIAN,
-    DEVICE_BIG_ENDIAN,
-    DEVICE_LITTLE_ENDIAN,
-};
-
-/* address in the RAM (different from a physical address) */
-#if defined(CONFIG_XEN_BACKEND)
-typedef uint64_t ram_addr_t;
-#  define RAM_ADDR_MAX UINT64_MAX
-#  define RAM_ADDR_FMT "%" PRIx64
-#else
-typedef uintptr_t ram_addr_t;
-#  define RAM_ADDR_MAX UINTPTR_MAX
-#  define RAM_ADDR_FMT "%" PRIxPTR
-#endif
-
-/* memory API */
-
-void qemu_ram_remap(ram_addr_t addr);
-/* This should not be used by devices.  */
-ram_addr_t qemu_ram_addr_from_host(void *ptr);
-ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
-RAMBlock *qemu_ram_block_by_name(const char *name);
-
-/*
- * Translates a host ptr back to a RAMBlock and an offset in that RAMBlock.
- *
- * @ptr: The host pointer to translate.
- * @round_offset: Whether to round the result offset down to a target page
- * @offset: Will be set to the offset within the returned RAMBlock.
- *
- * Returns: RAMBlock (or NULL if not found)
- *
- * By the time this function returns, the returned pointer is not protected
- * by RCU anymore.  If the caller is not within an RCU critical section and
- * does not hold the BQL, it must have other means of protecting the
- * pointer, such as a reference to the memory region that owns the RAMBlock.
- */
-RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
-                                   ram_addr_t *offset);
-ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
-void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
-void qemu_ram_unset_idstr(RAMBlock *block);
-const char *qemu_ram_get_idstr(RAMBlock *rb);
-void *qemu_ram_get_host_addr(RAMBlock *rb);
-ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
-ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb);
-ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
-ram_addr_t qemu_ram_get_max_length(RAMBlock *rb);
-bool qemu_ram_is_shared(RAMBlock *rb);
-bool qemu_ram_is_noreserve(RAMBlock *rb);
-bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
-void qemu_ram_set_uf_zeroable(RAMBlock *rb);
-bool qemu_ram_is_migratable(RAMBlock *rb);
-void qemu_ram_set_migratable(RAMBlock *rb);
-void qemu_ram_unset_migratable(RAMBlock *rb);
-bool qemu_ram_is_named_file(RAMBlock *rb);
-int qemu_ram_get_fd(RAMBlock *rb);
-
-size_t qemu_ram_pagesize(RAMBlock *block);
-size_t qemu_ram_pagesize_largest(void);
-
 /**
  * cpu_address_space_init:
  * @cpu: CPU to add this address space to
@@ -139,17 +76,6 @@ void *cpu_physical_memory_map(hwaddr addr,
 void cpu_physical_memory_unmap(void *buffer, hwaddr len,
                                bool is_write, hwaddr access_len);
 
-/* Coalesced MMIO regions are areas where write operations can be reordered.
- * This usually implies that write operations are side-effect free.  This allows
- * batching which can make a major impact on performance when using
- * virtualization.
- */
-void qemu_flush_coalesced_mmio_buffer(void);
-
-typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);
-
-int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
-
 /* vl.c */
 void list_cpus(void);
 
index 9bec0e78909aaba93d14957b38a4124a4f939e0d..0d1d46429c93e1f7e913b2608250497d1c022bcb 100644 (file)
@@ -24,6 +24,7 @@
 #include "exec/hwaddr.h"
 #include "exec/memattrs.h"
 #include "exec/vaddr.h"
+#include "system/ram_addr.h"
 
 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
 void tlb_protect_code(ram_addr_t ram_addr);
index cdce399ebab55fc5df0b14b179461f4dc4adc103..4f83d5bec9805e01d6a2aac5ec07c6c6942849ab 100644 (file)
@@ -14,6 +14,8 @@
 #ifdef CONFIG_USER_ONLY
 #include "qemu/interval-tree.h"
 #include "exec/target_page.h"
+#else
+#include "system/ram_addr.h"
 #endif
 
 /*
index ec39ef3bd6e16f305ffa9226b8b8e3860e7c067a..ec21732ce5268baa52509a3440d6822690ecbb41 100644 (file)
@@ -2,6 +2,7 @@
 #define HW_QDEV_PROPERTIES_SYSTEM_H
 
 #include "hw/core/qdev-properties.h"
+#include "qapi/qapi-types-common.h"
 
 bool qdev_prop_sanitize_s390x_loadparm(uint8_t *loadparm, const char *str,
                                        Error **errp);
index 68b0063ab6f9e8ede990c183b642f7a7d8b750b7..61a54cda7613d8687543eeff55368626e8da3725 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef HW_SMBUS_EEPROM_H
 #define HW_SMBUS_EEPROM_H
 
-#include "exec/cpu-common.h"
+#include "system/ram_addr.h"
 #include "hw/i2c/i2c.h"
 
 void smbus_eeprom_init_one(I2CBus *bus, uint8_t address, uint8_t *eeprom_buf);
index 19df5600a3975abb09aa982a43f1c03c8d95b641..e1beca062ff16483c4d2999d46fbe2171c08024e 100644 (file)
@@ -5,6 +5,7 @@
 #include "exec/hwaddr.h"
 #include "hw/xen/xen_native.h"
 #include "hw/xen/xen_backend_ops.h"
+#include "system/runstate.h"
 #include <xen/hvm/ioreq.h>
 
 extern MemoryRegion xen_memory;
index 867687b73ac27e7aeddacf1ce59b31bc393b28bc..066c7e1ddf49b064bf5ba487acb940aa5f1a6d4a 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef QEMU_BALLOON_H
 #define QEMU_BALLOON_H
 
-#include "exec/cpu-common.h"
+#include "system/ram_addr.h"
 #include "qapi/qapi-types-machine.h"
 
 typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target);
index d8b2f7942ba1650bdf5b4244a05667a496ce089e..61b0dff3400084c6d8f4ba22b406e5bdf15b1396 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef BLOCK_RAM_REGISTRAR_H
 #define BLOCK_RAM_REGISTRAR_H
 
-#include "exec/ramlist.h"
+#include "system/ramlist.h"
 
 /**
  * struct BlockRAMRegistrar:
index a659f36a20fdcf2f4855ebca43fc801a1b0e6634..9f5eb872454a8d09d1b9e8c6d5dd50fa2a832068 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "qom/object.h"
 #include "exec/hwaddr.h"
-#include "exec/cpu-common.h"
+#include "system/ram_addr.h"
 #include "system/host_iommu_device.h"
 
 #define TYPE_IOMMUFD_BACKEND "iommufd"
index 1cacc117cc63d37aafa885a11478925c1a6616f9..b3597fb2d043144d93c87dc2d7d74f9e72c06d45 100644 (file)
 #ifndef SYSTEM_MEMORY_H
 #define SYSTEM_MEMORY_H
 
-#include "exec/cpu-common.h"
 #include "exec/hwaddr.h"
+#include "system/ram_addr.h"
 #include "exec/memattrs.h"
 #include "exec/memop.h"
-#include "exec/ramlist.h"
 #include "qemu/bswap.h"
 #include "qemu/queue.h"
 #include "qemu/int128.h"
 #include "qom/object.h"
 #include "qemu/rcu.h"
 
+enum device_endian {
+    DEVICE_NATIVE_ENDIAN,
+    DEVICE_BIG_ENDIAN,
+    DEVICE_LITTLE_ENDIAN,
+};
+
 #define RAM_ADDR_INVALID (~(ram_addr_t)0)
 
 #define MAX_PHYS_ADDR_SPACE_BITS 62
@@ -3266,6 +3271,13 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
 MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
                               uint8_t c, hwaddr len, MemTxAttrs attrs);
 
+/* Coalesced MMIO regions are areas where write operations can be reordered.
+ * This usually implies that write operations are side-effect free.  This allows
+ * batching which can make a major impact on performance when using
+ * virtualization.
+ */
+void qemu_flush_coalesced_mmio_buffer(void);
+
 /*
  * Inhibit technologies that require discarding of pages in RAM blocks, e.g.,
  * to manage the actual amount of memory consumed by the VM (then, the memory
index 021e0a623091b08a42fe5a0941cf2289f0fdad32..4c770bf0b836b2b781ac162f66bee647997a1d6a 100644 (file)
@@ -15,7 +15,9 @@
 #define MEMORY_MAPPING_H
 
 #include "qemu/queue.h"
-#include "exec/cpu-common.h"
+#include "exec/hwaddr.h"
+#include "exec/vaddr.h"
+#include "system/ram_addr.h"
 
 typedef struct GuestPhysBlock {
     /* visible to guest, reflects PCI hole, etc */
index 879f6eae38b07dc5c679dc35a9c74b323f730335..ed3371302283b2d6c867ffd4b04f68b2013b0e16 100644 (file)
@@ -9,7 +9,7 @@
 #define QEMU_SYSTEM_PHYSMEM_H
 
 #include "exec/hwaddr.h"
-#include "exec/ramlist.h"
+#include "system/ramlist.h"
 
 #define DIRTY_CLIENTS_ALL     ((1 << DIRTY_MEMORY_NUM) - 1)
 #define DIRTY_CLIENTS_NOCODE  (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE))
index 683485980cea6352433299226482086af78cfd94..129f6b8757dd9ee4d10aec2265e9e4e3e869bd7b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Declarations for cpu physical memory functions
+ * Declarations of basic RAMBlock-related types and macros
  *
  * Copyright 2011 Red Hat, Inc. and/or its affiliates
  *
  *
  */
 
-/*
- * This header is for use by exec.c and memory.c ONLY.  Do not include it.
- * The functions declared here will be removed soon.
- */
-
-#ifndef SYSTEM_RAM_ADDR_H
-#define SYSTEM_RAM_ADDR_H
-
-#include "system/ramblock.h"
-#include "exec/target_page.h"
-#include "exec/hwaddr.h"
-
-extern uint64_t total_dirty_pages;
-
-/**
- * clear_bmap_size: calculate clear bitmap size
- *
- * @pages: number of guest pages
- * @shift: guest page number shift
- *
- * Returns: number of bits for the clear bitmap
- */
-static inline long clear_bmap_size(uint64_t pages, uint8_t shift)
-{
-    return DIV_ROUND_UP(pages, 1UL << shift);
-}
-
-/**
- * clear_bmap_set: set clear bitmap for the page range.  Must be with
- * bitmap_mutex held.
- *
- * @rb: the ramblock to operate on
- * @start: the start page number
- * @size: number of pages to set in the bitmap
- *
- * Returns: None
- */
-static inline void clear_bmap_set(RAMBlock *rb, uint64_t start,
-                                  uint64_t npages)
-{
-    uint8_t shift = rb->clear_bmap_shift;
-
-    bitmap_set(rb->clear_bmap, start >> shift, clear_bmap_size(npages, shift));
-}
-
-/**
- * clear_bmap_test_and_clear: test clear bitmap for the page, clear if set.
- * Must be with bitmap_mutex held.
- *
- * @rb: the ramblock to operate on
- * @page: the page number to check
- *
- * Returns: true if the bit was set, false otherwise
- */
-static inline bool clear_bmap_test_and_clear(RAMBlock *rb, uint64_t page)
-{
-    uint8_t shift = rb->clear_bmap_shift;
-
-    return bitmap_test_and_clear(rb->clear_bmap, page >> shift, 1);
-}
-
-static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
-                                                            RAMBlock *rb)
-{
-    uint64_t host_addr_offset =
-            (uint64_t)(uintptr_t)(host_addr - (void *)rb->host);
-    return host_addr_offset >> TARGET_PAGE_BITS;
-}
-
-/**
- * qemu_ram_alloc_from_file,
- * qemu_ram_alloc_from_fd:  Allocate a ram block from the specified backing
- *                          file or device
- *
- * Parameters:
- *  @size: the size in bytes of the ram block
- *  @max_size: the maximum size of the block after resizing
- *  @mr: the memory region where the ram block is
- *  @resized: callback after calls to qemu_ram_resize
- *  @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM,
- *              RAM_NORESERVE, RAM_PROTECTED, RAM_NAMED_FILE, RAM_READONLY,
- *              RAM_READONLY_FD, RAM_GUEST_MEMFD
- *  @mem_path or @fd: specify the backing file or device
- *  @offset: Offset into target file
- *  @grow: extend file if necessary (but an empty file is always extended).
- *  @errp: pointer to Error*, to store an error if it happens
- *
- * Return:
- *  On success, return a pointer to the ram block.
- *  On failure, return NULL.
- */
-typedef void (*qemu_ram_resize_cb)(const char *, uint64_t length, void *host);
-
-RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
-                                   uint32_t ram_flags, const char *mem_path,
-                                   off_t offset, Error **errp);
-RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,
-                                 qemu_ram_resize_cb resized, MemoryRegion *mr,
-                                 uint32_t ram_flags, int fd, off_t offset,
-                                 bool grow,
-                                 Error **errp);
-
-RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
-                                  MemoryRegion *mr, Error **errp);
-RAMBlock *qemu_ram_alloc(ram_addr_t size, uint32_t ram_flags, MemoryRegion *mr,
-                         Error **errp);
-RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t max_size,
-                                    qemu_ram_resize_cb resized,
-                                    MemoryRegion *mr, Error **errp);
-void qemu_ram_free(RAMBlock *block);
-
-int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
-
-void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length);
+#ifndef RAM_ADDR_H
+#define RAM_ADDR_H
+
+/* address in the RAM (different from a physical address) */
+#if defined(CONFIG_XEN_BACKEND)
+typedef uint64_t ram_addr_t;
+#  define RAM_ADDR_MAX UINT64_MAX
+#  define RAM_ADDR_FMT "%" PRIx64
+#else
+typedef uintptr_t ram_addr_t;
+#  define RAM_ADDR_MAX UINTPTR_MAX
+#  define RAM_ADDR_FMT "%" PRIxPTR
+#endif
 
-/* Clear whole block of mem */
-static inline void qemu_ram_block_writeback(RAMBlock *block)
-{
-    qemu_ram_msync(block, 0, block->used_length);
-}
+#define DIRTY_MEMORY_VGA       0
+#define DIRTY_MEMORY_CODE      1
+#define DIRTY_MEMORY_MIGRATION 2
+#define DIRTY_MEMORY_NUM       3        /* num of dirty bits */
 
 #endif
index 76694fe1b5bb98ccf8b63262b70a70778bd25804..e9f58ac045715739327e6d1e4b193678e2a26781 100644 (file)
@@ -14,9 +14,9 @@
 #ifndef SYSTEM_RAMBLOCK_H
 #define SYSTEM_RAMBLOCK_H
 
-#include "exec/cpu-common.h"
 #include "qemu/rcu.h"
-#include "exec/ramlist.h"
+#include "system/ram_addr.h"
+#include "system/ramlist.h"
 #include "system/hostmem.h"
 
 #define TYPE_RAM_BLOCK_ATTRIBUTES "ram-block-attributes"
@@ -130,4 +130,160 @@ static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset)
     return (char *)block->host + offset;
 }
 
+/* memory API */
+
+void qemu_ram_remap(ram_addr_t addr);
+/* This should not be used by devices.  */
+ram_addr_t qemu_ram_addr_from_host(void *ptr);
+ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr);
+RAMBlock *qemu_ram_block_by_name(const char *name);
+
+/*
+ * Translates a host ptr back to a RAMBlock and an offset in that RAMBlock.
+ *
+ * @ptr: The host pointer to translate.
+ * @round_offset: Whether to round the result offset down to a target page
+ * @offset: Will be set to the offset within the returned RAMBlock.
+ *
+ * Returns: RAMBlock (or NULL if not found)
+ *
+ * By the time this function returns, the returned pointer is not protected
+ * by RCU anymore.  If the caller is not within an RCU critical section and
+ * does not hold the BQL, it must have other means of protecting the
+ * pointer, such as a reference to the memory region that owns the RAMBlock.
+ */
+RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
+                                   ram_addr_t *offset);
+ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
+void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
+void qemu_ram_unset_idstr(RAMBlock *block);
+const char *qemu_ram_get_idstr(RAMBlock *rb);
+void *qemu_ram_get_host_addr(RAMBlock *rb);
+ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
+ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb);
+ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
+ram_addr_t qemu_ram_get_max_length(RAMBlock *rb);
+bool qemu_ram_is_shared(RAMBlock *rb);
+bool qemu_ram_is_noreserve(RAMBlock *rb);
+bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
+void qemu_ram_set_uf_zeroable(RAMBlock *rb);
+bool qemu_ram_is_migratable(RAMBlock *rb);
+void qemu_ram_set_migratable(RAMBlock *rb);
+void qemu_ram_unset_migratable(RAMBlock *rb);
+bool qemu_ram_is_named_file(RAMBlock *rb);
+int qemu_ram_get_fd(RAMBlock *rb);
+
+size_t qemu_ram_pagesize(RAMBlock *block);
+size_t qemu_ram_pagesize_largest(void);
+#include "exec/target_page.h"
+#include "exec/hwaddr.h"
+
+extern uint64_t total_dirty_pages;
+
+/**
+ * clear_bmap_size: calculate clear bitmap size
+ *
+ * @pages: number of guest pages
+ * @shift: guest page number shift
+ *
+ * Returns: number of bits for the clear bitmap
+ */
+static inline long clear_bmap_size(uint64_t pages, uint8_t shift)
+{
+    return DIV_ROUND_UP(pages, 1UL << shift);
+}
+
+/**
+ * clear_bmap_set: set clear bitmap for the page range.  Must be with
+ * bitmap_mutex held.
+ *
+ * @rb: the ramblock to operate on
+ * @start: the start page number
+ * @size: number of pages to set in the bitmap
+ *
+ * Returns: None
+ */
+static inline void clear_bmap_set(RAMBlock *rb, uint64_t start,
+                                  uint64_t npages)
+{
+    uint8_t shift = rb->clear_bmap_shift;
+
+    bitmap_set(rb->clear_bmap, start >> shift, clear_bmap_size(npages, shift));
+}
+
+/**
+ * clear_bmap_test_and_clear: test clear bitmap for the page, clear if set.
+ * Must be with bitmap_mutex held.
+ *
+ * @rb: the ramblock to operate on
+ * @page: the page number to check
+ *
+ * Returns: true if the bit was set, false otherwise
+ */
+static inline bool clear_bmap_test_and_clear(RAMBlock *rb, uint64_t page)
+{
+    uint8_t shift = rb->clear_bmap_shift;
+
+    return bitmap_test_and_clear(rb->clear_bmap, page >> shift, 1);
+}
+
+static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
+                                                            RAMBlock *rb)
+{
+    uint64_t host_addr_offset =
+            (uint64_t)(uintptr_t)(host_addr - (void *)rb->host);
+    return host_addr_offset >> TARGET_PAGE_BITS;
+}
+
+/**
+ * qemu_ram_alloc_from_file,
+ * qemu_ram_alloc_from_fd:  Allocate a ram block from the specified backing
+ *                          file or device
+ *
+ * Parameters:
+ *  @size: the size in bytes of the ram block
+ *  @max_size: the maximum size of the block after resizing
+ *  @mr: the memory region where the ram block is
+ *  @resized: callback after calls to qemu_ram_resize
+ *  @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM,
+ *              RAM_NORESERVE, RAM_PROTECTED, RAM_NAMED_FILE, RAM_READONLY,
+ *              RAM_READONLY_FD, RAM_GUEST_MEMFD
+ *  @mem_path or @fd: specify the backing file or device
+ *  @offset: Offset into target file
+ *  @grow: extend file if necessary (but an empty file is always extended).
+ *  @errp: pointer to Error*, to store an error if it happens
+ *
+ * Return:
+ *  On success, return a pointer to the ram block.
+ *  On failure, return NULL.
+ */
+typedef void (*qemu_ram_resize_cb)(const char *, uint64_t length, void *host);
+
+RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
+                                   uint32_t ram_flags, const char *mem_path,
+                                   off_t offset, Error **errp);
+RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,
+                                 qemu_ram_resize_cb resized, MemoryRegion *mr,
+                                 uint32_t ram_flags, int fd, off_t offset,
+                                 bool grow,
+                                 Error **errp);
+
+RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
+                                  MemoryRegion *mr, Error **errp);
+RAMBlock *qemu_ram_alloc(ram_addr_t size, uint32_t ram_flags, MemoryRegion *mr,
+                         Error **errp);
+RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t max_size,
+                                    qemu_ram_resize_cb resized,
+                                    MemoryRegion *mr, Error **errp);
+void qemu_ram_free(RAMBlock *block);
+
+int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
+
+void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length);
+
+/* Clear whole block of mem */
+static inline void qemu_ram_block_writeback(RAMBlock *block)
+{
+    qemu_ram_msync(block, 0, block->used_length);
+}
 #endif
similarity index 94%
rename from include/exec/ramlist.h
rename to include/system/ramlist.h
index d9cfe530beaf386087d65730cdacf0bd43986edb..c7f388f487d7057665c5fd03e723ea4c62c0daed 100644 (file)
@@ -5,14 +5,10 @@
 #include "qemu/thread.h"
 #include "qemu/rcu.h"
 #include "qemu/rcu_queue.h"
+#include "system/ram_addr.h"
 
 typedef struct RAMBlockNotifier RAMBlockNotifier;
 
-#define DIRTY_MEMORY_VGA       0
-#define DIRTY_MEMORY_CODE      1
-#define DIRTY_MEMORY_MIGRATION 2
-#define DIRTY_MEMORY_NUM       3        /* num of dirty bits */
-
 /* The dirty memory bitmap is split into fixed-size blocks to allow growth
  * under RCU.  The bitmap for a block can be accessed as follows:
  *
@@ -75,6 +71,10 @@ struct RAMBlockNotifier {
     QLIST_ENTRY(RAMBlockNotifier) next;
 };
 
+typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);
+
+int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
+
 void ram_block_notifier_add(RAMBlockNotifier *n);
 void ram_block_notifier_remove(RAMBlockNotifier *n);
 void ram_block_notify_add(void *host, size_t size, size_t max_size);
index bb454a7c96caf3b656dacd53e88477f3f9c9f2e8..fa2cff38d1a3eac4f578e25058c7569b14c21232 100644 (file)
@@ -9,7 +9,6 @@
 #ifndef XEN_MAPCACHE_H
 #define XEN_MAPCACHE_H
 
-#include "exec/cpu-common.h"
 #include "system/xen.h"
 
 typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr phys_offset,
index c2f283d1c269126bc81d5eb6c3ae20836c32eec6..9a7c53f283812d357da8f456a7ddc0885ca30d19 100644 (file)
@@ -10,7 +10,8 @@
 #ifndef SYSTEM_XEN_H
 #define SYSTEM_XEN_H
 
-#include "exec/cpu-common.h"
+#include "exec/hwaddr.h"
+#include "system/ram_addr.h"
 
 #ifdef COMPILING_PER_TARGET
 # ifdef CONFIG_XEN
index fbe02d5bb1a92074f04d1c6f130a8de3ef722322..43fbe5488caa7ed4da57ba5c09d453581f1d8739 100644 (file)
@@ -14,7 +14,8 @@
 #ifndef QEMU_MIGRATION_H
 #define QEMU_MIGRATION_H
 
-#include "exec/cpu-common.h"
+#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "hw/core/qdev.h"
 #include "qapi/qapi-types-migration.h"
 #include "qobject/json-writer.h"
index 6b469238ad2a40369cd47bb852e3dea39310b817..a57f4f49b3420e9686246065cbdb9774dbf618ab 100644 (file)
@@ -48,7 +48,7 @@
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qmp/qerror.h"
 #include "trace.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "exec/target_page.h"
 #include "qemu/rcu_queue.h"
 #include "migration/colo.h"
index 24cd0bf585762cfa1e86834dc03c6baeea2f0627..41697a75993f5b19323677dc36d114c2a6a3c9dc 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "qapi/qapi-types-migration.h"
 #include "exec/cpu-common.h"
+#include "system/ram_addr.h"
 #include "io/channel.h"
 
 /*
index 654be9185b14080094103f0dec1eecdad0a6501c..68b9b22bbc3776507011763b59217acad4939ec7 100644 (file)
@@ -21,8 +21,8 @@
 //! `bindgen`-generated declarations.
 
 use glib_sys::{
-    gboolean, guint, GArray, GByteArray, GHashTable, GHashTableIter, GIOCondition, GList,
-    GMainContext, GPollFD, GPtrArray, GSList, GSource, GSourceFunc, GString,
+    gboolean, guint, GArray, GHashTable, GHashTableIter, GIOCondition, GList, GMainContext,
+    GPollFD, GPtrArray, GSList, GSource, GSourceFunc,
 };
 
 #[cfg(MESON)]
index 730d5b28a3c11fdb641da7ae04e50ee45730972a..db872d38bc7ccd9e50a8beeebc4afe75151f6ec9 100644 (file)
@@ -20,7 +20,7 @@
 
 use chardev::bindings::Chardev;
 use common::Zeroable;
-use glib_sys::{GArray, GByteArray, GHashTable, GHashTableIter, GList, GPtrArray, GSList, GString};
+use glib_sys::{GHashTable, GHashTableIter, GList, GPtrArray, GSList};
 use migration::bindings::VMStateDescription;
 use qom::bindings::ObjectClass;
 use system::bindings::MemoryRegion;
index ddccfe0436f37313f2cf68361f9a3aea00be8b20..7164c5219a5a602b54ddbc1706eb5095c2918340 100644 (file)
 )]
 
 use common::Zeroable;
-use glib_sys::{
-    guint, GArray, GByteArray, GHashTable, GHashTableIter, GList, GPollFD, GPtrArray, GSList,
-    GString,
-};
+use glib_sys::{guint, GHashTable, GHashTableIter, GList, GPollFD, GPtrArray, GSList};
 
 #[cfg(MESON)]
 include!("bindings.inc.rs");
index 1fc5f2df29fa2b0329f78dd5fb9dd9fd7eba7cbe..14667f2bd8f908bab8648c34e45bfc8c84a0dc7d 100644 (file)
@@ -1,5 +1,5 @@
 #include "qemu/osdep.h"
-#include "exec/cpu-common.h"
+#include "system/ramblock.h"
 
 RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
                                    ram_addr_t *offset)
index e88fab31a5d728c86d82b23b06a26b0a001eab50..8790a59593e570ef6b51d49fff95fab18aadfbdc 100644 (file)
@@ -1,6 +1,6 @@
 #include "qemu/osdep.h"
-#include "exec/ramlist.h"
-#include "exec/cpu-common.h"
+#include "system/ramlist.h"
+#include "system/ramblock.h"
 #include "system/memory.h"
 
 void *qemu_ram_get_host_addr(RAMBlock *rb)
index 4f96e9119fc119ae32dbe041454637bf6917bbe7..801e2490c367fee80f0f6abb2888adbcc31d43e2 100644 (file)
@@ -29,6 +29,7 @@
 #include "system/ioport.h"
 #include "system/memory.h"
 #include "system/address-spaces.h"
+#include "hw/core/qdev.h"
 #include "trace.h"
 
 struct MemoryRegionPortioList {
index b65219c2e4922fbc9895db51bc5008a9d7f57bf0..259507566041f4cc4ac0458cdafa53972e6c443d 100644 (file)
@@ -26,7 +26,7 @@
 #include "qom/object.h"
 #include "trace.h"
 #include "system/physmem.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "system/kvm.h"
 #include "system/runstate.h"
 #include "system/tcg.h"
index e3221ce00de4985b45575bc270a879f7837d95d1..2547687d137fe5571656438890bb416ed758ca89 100644 (file)
@@ -68,7 +68,7 @@
 #include "qemu/main-loop.h"
 #include "system/replay.h"
 
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 
 #include "qemu/pmem.h"
 
index 12a63602b114a7adb4d65ef9452d2a57574d0f06..48f853fff80e5be9ebac2ba23dd9127da0721a3a 100644 (file)
@@ -22,6 +22,7 @@
 #include "qapi/error.h"
 #include "system/system.h"
 #include "system/runstate.h"
+#include "system/ramblock.h"
 #include "system/kvm.h"
 #include "system/kvm_int.h"
 #include "kvm_arm.h"
index 60c798113823dabea1c76f8655da229a9a41809d..e98da47a451435e4b6a6e421c3a7e2f741fba9a0 100644 (file)
@@ -35,6 +35,7 @@
 #include "system/hw_accel.h"
 #include "system/kvm_int.h"
 #include "system/runstate.h"
+#include "system/ramblock.h"
 #include "kvm_i386.h"
 #include "../confidential-guest.h"
 #include "sev.h"
index fd2dada013b7cce4247ca729b31867019898c99d..fb5a3b5d778f746750c7228477fa100006ebdbd7 100644 (file)
@@ -41,6 +41,7 @@
 #include "confidential-guest.h"
 #include "hw/i386/pc.h"
 #include "system/address-spaces.h"
+#include "system/ramlist.h"
 #include "hw/i386/e820_memory_layout.h"
 #include "qemu/queue.h"
 #include "qemu/cutils.h"
index 2c96eca584edee18bdaa1b1e381ddc2fc8266504..3b2f1077da6bf2d18f91c3381b72b86f4cff2690 100644 (file)
@@ -41,7 +41,7 @@
 #include "trace.h"
 #include "gdbstub/enums.h"
 #include "exec/memattrs.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "system/hostmem.h"
 #include "qemu/cutils.h"
 #include "qemu/main-loop.h"
index 916dac1f14ec9d69d1c36adc7504b9d972350b73..fe3bf408dda113659078103851e0031721bb5da8 100644 (file)
@@ -41,7 +41,7 @@
 #include "system/runstate.h"
 #include "system/device_tree.h"
 #include "gdbstub/enums.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
 #include "trace.h"
 #include "hw/s390x/s390-pci-inst.h"
 #include "hw/s390x/s390-pci-bus.h"
index e8bb7bb0d5644ab68e6322e33f48b8e14f18a8a7..440de250345a5ed965e7f782402b77c1a97b66df 100644 (file)
@@ -21,7 +21,7 @@
 #include "fuzz.h"
 #include "string.h"
 #include "system/memory.h"
-#include "system/ramblock.h"
+#include "system/ram_addr.h"
 #include "hw/core/qdev.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_device.h"
index fdff042ab46968d2021d179863ab2bc334aa4ede..44b457c442f157afecbc09156fea56989b29c1bc 100644 (file)
@@ -14,7 +14,7 @@
 #include <sys/ioctl.h>
 #include <linux/vfio.h>
 #include "qapi/error.h"
-#include "exec/ramlist.h"
+#include "system/ramlist.h"
 #include "exec/cpu-common.h"
 #include "system/memory.h"
 #include "trace.h"