This series, split out of the previous attempt to set owners for memory regions, adds reference counting operations to memory regions and uses them. As requested by Peter, I'm adding an argument for the owner to all memory region creation functions.
The big patches to actually add the owners will come soon, since I found a decent way to split it. Paolo v1->v2: patches 7/11 redone and placed at the end of the series; refcount changes for address_space_translate left for a later series, they are not yet necessary; rebased on top of Jan's patches. Paolo Bonzini (11): memory: add owner argument to initialization functions memory: destroy phys_sections one by one exec: simplify destruction of the phys map memory: add getter for owner memory: add ref/unref memory: add ref/unref calls exec: check MRU in qemu_ram_addr_from_host exec: move qemu_ram_addr_from_host_nofail to cputlb.c memory: return MemoryRegion from qemu_ram_addr_from_host exec: reorganize address_space_map memory: ref/unref memory across address_space_map/unmap cputlb.c | 11 ++ exec.c | 218 +++++++++++++++---------------- hw/acpi/core.c | 6 +- hw/acpi/ich9.c | 6 +- hw/acpi/piix4.c | 8 +- hw/alpha/typhoon.c | 16 +-- hw/arm/armv7m.c | 8 +- hw/arm/exynos4210.c | 12 +- hw/arm/highbank.c | 6 +- hw/arm/integratorcp.c | 12 +- hw/arm/kzm.c | 6 +- hw/arm/mainstone.c | 2 +- hw/arm/musicpal.c | 22 ++-- hw/arm/omap1.c | 52 ++++---- hw/arm/omap2.c | 16 +-- hw/arm/omap_sx1.c | 14 +- hw/arm/palm.c | 10 +- hw/arm/pxa2xx.c | 30 ++--- hw/arm/pxa2xx_gpio.c | 2 +- hw/arm/pxa2xx_pic.c | 2 +- hw/arm/realview.c | 8 +- hw/arm/spitz.c | 4 +- hw/arm/stellaris.c | 8 +- hw/arm/strongarm.c | 14 +- hw/arm/tosa.c | 2 +- hw/arm/versatilepb.c | 4 +- hw/arm/vexpress.c | 12 +- hw/arm/xilinx_zynq.c | 4 +- hw/audio/ac97.c | 4 +- hw/audio/cs4231.c | 2 +- hw/audio/cs4231a.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/audio/marvell_88w8618.c | 2 +- hw/audio/milkymist-ac97.c | 2 +- hw/audio/pcspk.c | 2 +- hw/audio/pl041.c | 2 +- hw/block/fdc.c | 4 +- hw/block/nvme.c | 2 +- hw/block/onenand.c | 8 +- hw/block/pc_sysfw.c | 6 +- hw/block/pflash_cfi01.c | 3 +- hw/block/pflash_cfi02.c | 6 +- hw/char/cadence_uart.c | 2 +- hw/char/debugcon.c | 2 +- hw/char/escc.c | 2 +- hw/char/etraxfs_ser.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/char/imx_serial.c | 2 +- hw/char/lm32_uart.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/milkymist-uart.c | 2 +- hw/char/omap_uart.c | 2 +- hw/char/parallel.c | 2 +- hw/char/pl011.c | 2 +- hw/char/serial-isa.c | 2 +- hw/char/serial-pci.c | 6 +- hw/char/serial.c | 4 +- hw/char/sh_serial.c | 6 +- hw/char/tpci200.c | 12 +- hw/char/xilinx_uartlite.c | 2 +- hw/core/empty_slot.c | 2 +- hw/core/loader.c | 1 + hw/cpu/a15mpcore.c | 2 +- hw/cpu/a9mpcore.c | 2 +- hw/cpu/arm11mpcore.c | 4 +- hw/cpu/icc_bus.c | 2 +- hw/cris/axis_dev88.c | 8 +- hw/display/cirrus_vga.c | 16 +-- hw/display/exynos4210_fimd.c | 8 +- hw/display/framebuffer.c | 12 +- hw/display/g364fb.c | 4 +- hw/display/jazz_led.c | 2 +- hw/display/milkymist-tmu2.c | 2 +- hw/display/milkymist-vgafb.c | 2 +- hw/display/omap_dss.c | 10 +- hw/display/omap_lcdc.c | 2 +- hw/display/pl110.c | 2 +- hw/display/pxa2xx_lcd.c | 2 +- hw/display/qxl.c | 10 +- hw/display/sm501.c | 8 +- hw/display/tc6393xb.c | 4 +- hw/display/tcx.c | 16 +-- hw/display/vga-isa-mm.c | 4 +- hw/display/vga-pci.c | 6 +- hw/display/vga.c | 8 +- hw/display/vmware_vga.c | 4 +- hw/dma/etraxfs_dma.c | 2 +- hw/dma/i8257.c | 4 +- hw/dma/omap_dma.c | 4 +- hw/dma/pl080.c | 2 +- hw/dma/pl330.c | 2 +- hw/dma/puv3_dma.c | 2 +- hw/dma/pxa2xx_dma.c | 2 +- hw/dma/rc4030.c | 4 +- hw/dma/sparc32_dma.c | 2 +- hw/dma/sun4m_iommu.c | 2 +- hw/dma/xilinx_axidma.c | 2 +- hw/gpio/omap_gpio.c | 6 +- hw/gpio/pl061.c | 2 +- hw/gpio/puv3_gpio.c | 2 +- hw/gpio/zaurus.c | 2 +- hw/i2c/bitbang_i2c.c | 2 +- hw/i2c/exynos4210_i2c.c | 2 +- hw/i2c/omap_i2c.c | 2 +- hw/i2c/pm_smbus.c | 2 +- hw/i2c/versatile_i2c.c | 2 +- hw/i386/kvm/apic.c | 2 +- hw/i386/kvm/i8254.c | 2 +- hw/i386/kvm/i8259.c | 4 +- hw/i386/kvm/ioapic.c | 2 +- hw/i386/kvm/pci-assign.c | 14 +- hw/i386/kvmvapic.c | 5 +- hw/i386/pc.c | 14 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ide/ahci.c | 4 +- hw/ide/cmd646.c | 10 +- hw/ide/macio.c | 2 +- hw/ide/mmio.c | 4 +- hw/ide/piix.c | 6 +- hw/ide/via.c | 6 +- hw/input/milkymist-softusb.c | 6 +- hw/input/pckbd.c | 6 +- hw/input/pl050.c | 2 +- hw/input/pxa2xx_keypad.c | 2 +- hw/intc/apic.c | 2 +- hw/intc/arm_gic.c | 6 +- hw/intc/arm_gic_kvm.c | 4 +- hw/intc/armv7m_nvic.c | 6 +- hw/intc/etraxfs_pic.c | 2 +- hw/intc/exynos4210_combiner.c | 2 +- hw/intc/exynos4210_gic.c | 8 +- hw/intc/grlib_irqmp.c | 2 +- hw/intc/heathrow_pic.c | 2 +- hw/intc/i8259.c | 4 +- hw/intc/imx_avic.c | 2 +- hw/intc/ioapic.c | 2 +- hw/intc/omap_intc.c | 4 +- hw/intc/openpic.c | 4 +- hw/intc/pl190.c | 2 +- hw/intc/puv3_intc.c | 2 +- hw/intc/realview_gic.c | 2 +- hw/intc/sh_intc.c | 6 +- hw/intc/slavio_intctl.c | 4 +- hw/intc/xilinx_intc.c | 2 +- hw/isa/apm.c | 2 +- hw/isa/i82378.c | 4 +- hw/isa/isa_mmio.c | 2 +- hw/isa/lpc_ich9.c | 4 +- hw/isa/pc87312.c | 2 +- hw/isa/vt82c686.c | 6 +- hw/lm32/lm32_boards.c | 4 +- hw/lm32/milkymist.c | 2 +- hw/m68k/an5206.c | 4 +- hw/m68k/dummy_m68k.c | 2 +- hw/m68k/mcf5206.c | 2 +- hw/m68k/mcf5208.c | 8 +- hw/m68k/mcf_intc.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 4 +- hw/microblaze/petalogix_s3adsp1800_mmu.c | 4 +- hw/mips/gt64xxx_pci.c | 2 +- hw/mips/mips_fulong2e.c | 4 +- hw/mips/mips_jazz.c | 12 +- hw/mips/mips_malta.c | 10 +- hw/mips/mips_mipssim.c | 4 +- hw/mips/mips_r4k.c | 6 +- hw/misc/a9scu.c | 2 +- hw/misc/applesmc.c | 4 +- hw/misc/arm_l2x0.c | 2 +- hw/misc/arm_sysctl.c | 2 +- hw/misc/debugexit.c | 2 +- hw/misc/eccmemctl.c | 4 +- hw/misc/exynos4210_pmu.c | 2 +- hw/misc/imx_ccm.c | 2 +- hw/misc/ivshmem.c | 8 +- hw/misc/lm32_sys.c | 2 +- hw/misc/macio/cuda.c | 2 +- hw/misc/macio/mac_dbdma.c | 2 +- hw/misc/macio/macio.c | 2 +- hw/misc/milkymist-hpdmc.c | 2 +- hw/misc/milkymist-pfpu.c | 2 +- hw/misc/mst_fpga.c | 2 +- hw/misc/omap_gpmc.c | 8 +- hw/misc/omap_l4.c | 2 +- hw/misc/omap_sdrc.c | 2 +- hw/misc/omap_tap.c | 2 +- hw/misc/pc-testdev.c | 8 +- hw/misc/pci-testdev.c | 4 +- hw/misc/puv3_pm.c | 2 +- hw/misc/pvpanic.c | 2 +- hw/misc/pxa2xx_pcmcia.c | 6 +- hw/misc/slavio_misc.c | 16 +-- hw/misc/vfio.c | 30 +++-- hw/misc/vmport.c | 2 +- hw/misc/zynq_slcr.c | 2 +- hw/moxie/moxiesim.c | 4 +- hw/net/cadence_gem.c | 2 +- hw/net/dp8393x.c | 2 +- hw/net/e1000.c | 4 +- hw/net/eepro100.c | 6 +- hw/net/etraxfs_eth.c | 2 +- hw/net/lan9118.c | 2 +- hw/net/lance.c | 2 +- hw/net/mcf_fec.c | 2 +- hw/net/milkymist-minimac2.c | 4 +- hw/net/mipsnet.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/opencores_eth.c | 4 +- hw/net/pcnet-pci.c | 4 +- hw/net/rtl8139.c | 4 +- hw/net/smc91c111.c | 2 +- hw/net/stellaris_enet.c | 2 +- hw/net/vmxnet3.c | 6 +- hw/net/xgmac.c | 2 +- hw/net/xilinx_axienet.c | 2 +- hw/net/xilinx_ethlite.c | 2 +- hw/nvram/ds1225y.c | 2 +- hw/nvram/fw_cfg.c | 6 +- hw/nvram/mac_nvram.c | 2 +- hw/openrisc/openrisc_sim.c | 2 +- hw/pci-bridge/dec.c | 4 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-host/apb.c | 8 +- hw/pci-host/bonito.c | 10 +- hw/pci-host/grackle.c | 8 +- hw/pci-host/pam.c | 8 +- hw/pci-host/piix.c | 12 +- hw/pci-host/ppce500.c | 12 +- hw/pci-host/prep.c | 8 +- hw/pci-host/q35.c | 10 +- hw/pci-host/uninorth.c | 24 ++-- hw/pci-host/versatile.c | 14 +- hw/pci/msix.c | 6 +- hw/pci/pci.c | 4 +- hw/pci/pci_bridge.c | 12 +- hw/pci/pcie_host.c | 2 +- hw/pci/shpc.c | 2 +- hw/ppc/e500.c | 4 +- hw/ppc/mac_newworld.c | 8 +- hw/ppc/mac_oldworld.c | 6 +- hw/ppc/mpc8544_guts.c | 2 +- hw/ppc/ppc405_boards.c | 18 +-- hw/ppc/ppc405_uc.c | 12 +- hw/ppc/ppc4xx_devs.c | 4 +- hw/ppc/ppc4xx_pci.c | 8 +- hw/ppc/ppce500_spin.c | 2 +- hw/ppc/prep.c | 8 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/ppc/spapr_pci.c | 10 +- hw/ppc/virtex_ml507.c | 2 +- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio.c | 2 +- hw/scsi/esp-pci.c | 2 +- hw/scsi/esp.c | 2 +- hw/scsi/lsi53c895a.c | 6 +- hw/scsi/megasas.c | 6 +- hw/scsi/vmw_pvscsi.c | 2 +- hw/sd/milkymist-memcard.c | 2 +- hw/sd/omap_mmc.c | 4 +- hw/sd/pl181.c | 2 +- hw/sd/pxa2xx_mmci.c | 2 +- hw/sd/sdhci.c | 2 +- hw/sh4/r2d.c | 4 +- hw/sh4/sh7750.c | 16 +-- hw/sh4/sh_pci.c | 4 +- hw/sh4/shix.c | 6 +- hw/sparc/leon3.c | 4 +- hw/sparc/sun4m.c | 8 +- hw/sparc64/sun4u.c | 4 +- hw/ssi/omap_spi.c | 2 +- hw/ssi/pl022.c | 2 +- hw/ssi/xilinx_spi.c | 2 +- hw/ssi/xilinx_spips.c | 4 +- hw/timer/arm_mptimer.c | 4 +- hw/timer/arm_timer.c | 4 +- hw/timer/cadence_ttc.c | 2 +- hw/timer/etraxfs_timer.c | 2 +- hw/timer/exynos4210_mct.c | 2 +- hw/timer/exynos4210_pwm.c | 2 +- hw/timer/exynos4210_rtc.c | 2 +- hw/timer/grlib_gptimer.c | 2 +- hw/timer/hpet.c | 2 +- hw/timer/i8254.c | 2 +- hw/timer/imx_epit.c | 2 +- hw/timer/imx_gpt.c | 2 +- hw/timer/lm32_timer.c | 2 +- hw/timer/m48t59.c | 6 +- hw/timer/mc146818rtc.c | 2 +- hw/timer/milkymist-sysctl.c | 2 +- hw/timer/omap_gptimer.c | 2 +- hw/timer/omap_synctimer.c | 2 +- hw/timer/pl031.c | 2 +- hw/timer/puv3_ost.c | 2 +- hw/timer/pxa2xx_timer.c | 2 +- hw/timer/sh_timer.c | 6 +- hw/timer/slavio_timer.c | 2 +- hw/timer/tusb6010.c | 2 +- hw/timer/xilinx_timer.c | 2 +- hw/tpm/tpm_tis.c | 2 +- hw/unicore32/puv3.c | 2 +- hw/usb/hcd-ehci-sysbus.c | 2 +- hw/usb/hcd-ehci.c | 8 +- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 12 +- hw/virtio/dataplane/hostmem.c | 7 + hw/virtio/vhost.c | 2 + hw/virtio/virtio-balloon.c | 1 + hw/virtio/virtio-pci.c | 2 +- hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_apic.c | 2 +- hw/xen/xen_platform.c | 6 +- hw/xen/xen_pt.c | 8 +- hw/xen/xen_pt_msi.c | 2 +- hw/xtensa/xtensa_lx60.c | 12 +- hw/xtensa/xtensa_sim.c | 4 +- include/exec/cpu-common.h | 3 +- include/exec/memory.h | 54 ++++++++ include/hw/virtio/dataplane/hostmem.h | 1 + ioport.c | 2 +- kvm-all.c | 2 + memory.c | 64 ++++++++- target-arm/kvm.c | 2 + target-i386/kvm.c | 4 +- target-ppc/kvm.c | 2 +- target-sparc/mmu_helper.c | 1 + xen-all.c | 10 +- 330 files changed, 1009 insertions(+), 870 deletions(-) -- 1.8.1.4