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
#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"
#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"
*/
#include "qemu/osdep.h"
+#include "exec/cpu-common.h"
#include "system/tcg.h"
#include "system/replay.h"
#include "exec/icount.h"
#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"
#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"
#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"
#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"
#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
#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)
#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"
#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"
#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
*/
#include "qemu/osdep.h"
+#include "exec/cpu-common.h"
#include "qapi/error.h"
#include "hw/core/cpu.h"
#include "system/hw_accel.h"
#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"
#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"
#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"
#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;
#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;
#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"
#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"
#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 */
#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"
#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"
#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"
#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"
#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"
#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>
#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"
#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"
#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,
#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"
#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"
#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
#include "qemu/log.h"
#include "etsec.h"
#include "registers.h"
+#include "exec/cpu-common.h"
/* #define ETSEC_RING_DEBUG */
/* #define HEX_DUMP */
#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
#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"
#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"
#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 {
#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"
#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
#include "qemu/datadir.h"
#include "system/device_tree.h"
#include "hw/ppc/vof.h"
+#include "exec/cpu-common.h"
#include <libfdt.h>
#include "hw/isa/isa.h"
#include "hw/char/serial-isa.h"
#include "hw/rtc/mc146818rtc.h"
+#include "exec/cpu-common.h"
#include <libfdt.h>
#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"
#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"
#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"
#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"
#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)
{
#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"
#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
#include "hw/ppc/ppc.h"
#include "hw/ppc/ppc4xx.h"
#include "hw/core/qdev-properties.h"
+#include "exec/cpu-common.h"
#include <libfdt.h>
#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"
#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;
#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"
#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"
#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"
#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
#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"
#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"
#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"
/*
#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"
#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"
#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"
#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 */
#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"
#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;
#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 {
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
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);
#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);
#ifdef CONFIG_USER_ONLY
#include "qemu/interval-tree.h"
#include "exec/target_page.h"
+#else
+#include "system/ram_addr.h"
#endif
/*
#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);
#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);
#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;
#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);
#ifndef BLOCK_RAM_REGISTRAR_H
#define BLOCK_RAM_REGISTRAR_H
-#include "exec/ramlist.h"
+#include "system/ramlist.h"
/**
* struct BlockRAMRegistrar:
#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"
#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
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
#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 */
#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))
/*
- * 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
#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"
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
#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:
*
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);
#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,
#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
#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"
#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"
#include "qapi/qapi-types-migration.h"
#include "exec/cpu-common.h"
+#include "system/ram_addr.h"
#include "io/channel.h"
/*
//! `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)]
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;
)]
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");
#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)
#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)
#include "system/ioport.h"
#include "system/memory.h"
#include "system/address-spaces.h"
+#include "hw/core/qdev.h"
#include "trace.h"
struct MemoryRegionPortioList {
#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"
#include "qemu/main-loop.h"
#include "system/replay.h"
-#include "system/ram_addr.h"
+#include "system/ramblock.h"
#include "qemu/pmem.h"
#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"
#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"
#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"
#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"
#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"
#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"
#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"