summaryrefslogtreecommitdiffstats
path: root/memory.c
Commit message (Collapse)AuthorAgeFilesLines
* memory: check address space when a listener is registeredJulien Grall2012-04-051-0/+5
| | | | | | | | | | This patch resolves a bug in memory listener registration. "range_add" callback was called on each section of the both address space (IO and memory space) even if it doesn't match the address space filter. Signed-off-by: Julien Grall <julien.grall@citrix.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: print aliased IO ranges in info mtreeBlue Swirl2012-03-191-7/+7
| | | | | | | Print also I/O ports behind bridges and other aliases. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: get rid of cpu_register_io_memory()Avi Kivity2012-03-081-4/+1
| | | | | | | The return value of cpu_register_io_memory() is no longer used anywhere, so we can remove it and all associated data and code. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: dispatch directly via MemoryRegionAvi Kivity2012-03-081-4/+4
| | | | | | | Instead of indirecting via io_mem_region, dispatch directly through the MemoryRegion obtained from the iotlb or phys_page_find(). Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: fix I/O port aliasesAvi Kivity2012-03-051-6/+20
| | | | | | | | | | | | | | | | | | | Commit e58ac72b6a0 ("ioport: change portio_list not to use memory_region_set_offset()") started using aliases of I/O memory regions. Since the IORange used for the I/O was contained in the target region, the alias information (specifically, the offset into the region) was lost. This broke -vga std. Fix by allocating an independent object to hold the IORange and also the new offset. Note that I/O memory regions were conceptually broken wrt aliases in a different way: an alias can cause the same region to appear twice in an address space, but we had just one IORange to service it. This patch fixes that problem as well, since we can now have multiple IORange/MemoryRegion associations. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: support stateless memory listenersAvi Kivity2012-02-291-0/+5
| | | | | | | | | | | | | Current memory listeners are incremental; that is, they are expected to maintain their own state, and receive callbacks for changes to that state. This patch adds support for stateless listeners; these work by receiving a ->begin() callback (which tells them that new state is coming), a sequence of ->region_add() and ->region_nop() callbacks, and then a ->commit() callback which signifies the end of the new state. They should ignore ->region_del() callbacks. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: allow MemoryListeners to observe a specific address spaceAvi Kivity2012-02-291-6/+39
| | | | | | Ignore any regions not belonging to a specified address space. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: drop AddressSpaceOpsAvi Kivity2012-02-291-54/+2
| | | | | | | All functionality has been moved to various MemoryListeners. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: use a MemoryListener for core memory map updates tooAvi Kivity2012-02-291-26/+1
| | | | | | | | This transforms memory.c into a library which can then be unit tested easily, by feeding it inputs and listening to its outputs. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: don't pass ->readable attribute to cpu_register_physical_memory_logAvi Kivity2012-02-291-2/+2
| | | | | | | | It can be derived from the MemoryRegion itself (which is why it is not used there). Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: add a readonly attribute to MemoryRegionSectionAvi Kivity2012-02-291-0/+5
| | | | | | | | | | .readonly cannot be obtained from the MemoryRegion, since it is inherited from aliases (so you can have a MemoryRegion mapped RW at one address and RO at another). Record it in a MemoryRegionSection for listeners. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: move ioeventfd ops to MemoryListenerAvi Kivity2012-02-291-56/+18
| | | | | | | This way the accelerator (kvm) can handle them directly. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: code motion: move MEMORY_LISTENER_CALL()Avi Kivity2012-02-291-32/+32
| | | | | | | So it can be used in earlier code. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: switch memory listeners to a QTAILQAvi Kivity2012-02-291-21/+49
| | | | | | | | | | | | | This allows reverse iteration, which in turns allows consistent ordering among multiple listeners: l1->add l2->add l2->del l1->del Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: add shorthand for invoking a callback on all listenersAvi Kivity2012-02-291-35/+19
| | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: remove memory_region_set_offset()Avi Kivity2012-02-291-16/+10
| | | | | | | | memory_region_set_offset() complicates the API, and has been deprecated since its introduction. Now that it is no longer used, remove it. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory-region: Report if region is read-only or write-only on info mtreeJan Kiszka2012-02-111-3/+11
| | | | | | | | Helpful to understand guest configurations of things like the i440FX's PAM or the state of ROM devices. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* memory: change dirty getting API to take a sizeBlue Swirl2012-02-041-2/+3
| | | | | | | Instead of each device knowing or guessing the guest page size, just pass the desired size of dirtied memory area. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* memory: change dirty setting APIs to take a sizeBlue Swirl2012-01-251-2/+3
| | | | | | | Instead of each target knowing or guessing the guest page size, just pass the desired size of dirtied memory area. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* memory: Introduce memory_region_init_reservationJan Kiszka2012-01-191-0/+36
| | | | | | | | | | | | Introduce a memory region type that can reserve I/O space. Such regions are useful for modeling I/O that is only handled outside of QEMU, i.e. in the context of an accelerator like KVM. Any access to such a region from QEMU is a bug, but could theoretically be triggered by guest code (DMA to reserved region). So only warning about such events once, then ignore them. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
* prepare for future GPLv2+ relicensingPaolo Bonzini2012-01-131-0/+2
| | | | | | | | | All files under GPLv2 will get GPLv2+ changes starting tomorrow. event_notifier.c and exec-obsolete.h were only ever touched by Red Hat employees and can be relicensed now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* memory: Fix adjust_endianness()Andreas Färber2012-01-081-0/+1
| | | | | | | | | | | Commit a621f38de85598a13d8d8524d1a94fc6a1818215 (Direct dispatch through MemoryRegion) moved byte swaps to a central function. Add a missing break, so that long-sized byte swaps don't abort. Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: Fix memory_region_wrong_endianness()Andreas Färber2012-01-081-1/+1
| | | | | | | | | | | Since commit be675c972088eba210e18dc125613e9f205a6bfb (memory: move endianness compensation to memory core) it was checking for TARGET_BIG_ENDIAN instead of TARGET_WORDS_BIGENDIAN, thereby not swapping correctly for Big Endian targets. Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Avi Kivity <avi@redhat.com>
* Drop IO_MEM_ROMDAvi Kivity2012-01-041-2/+3
| | | | | | | | Unlike ->readonly, ->readable is not inherited from aliase, so we can simply query the memory region. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* Remove IO_MEM_SUBPAGEAvi Kivity2012-01-041-0/+1
| | | | | | | Replace with a MemoryRegion flag. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* Direct dispatch through MemoryRegionAvi Kivity2012-01-041-82/+40
| | | | | | | | | Now that all mmio goes through MemoryRegions, we can convert io_mem_opaque to be a MemoryRegion pointer, and remove the thunks that convert from old-style CPU{Read,Write}MemoryFunc to MemoryRegionOps. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* Switch cpu_register_physical_memory_log() to use MemoryRegionsAvi Kivity2012-01-041-27/+15
| | | | | | | Still internally using ram_addr. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* Convert IO_MEM_{RAM,ROM,UNASSIGNED,NOTDIRTY} to MemoryRegionsAvi Kivity2012-01-041-4/+3
| | | | | | | | | | Convert the fixed-address IO_MEM_RAM, IO_MEM_ROM, IO_MEM_UNASSIGNED, and IO_MEM_NOTDIRTY io handlers to MemoryRegions. These aren't real regions, since they are never added to the memory hierarchy, but they allow reuse of the dispatch functionality. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* Avoid range comparisons on io index typesAvi Kivity2012-01-041-1/+2
| | | | | | | | The code sometimes uses range comparisons on io indexes (e.g. index =< IO_MEM_ROM). Avoid these as they make moving to objects harder. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: remove MemoryRegion::backend_registeredAvi Kivity2012-01-041-22/+4
| | | | | | | | | | | | | | | backend_registered was used to lazify the process of registering an mmio region, since the it is different for the I/O address space and the memory address space. However, it also makes registration dependent on the region being visible in the address space. This is not the case for "fake" regions, like watchpoints or IO_MEM_UNASSIGNED. Remove backend_registered and always initialize the region. If it turns out to be part of the I/O address space, we've wasted an I/O slot, but that's not too bad. In any case this will be optimized later on. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: move mmio access to functionsAvi Kivity2012-01-041-0/+13
| | | | | | | | Currently mmio access goes directly to the io_mem_{read,write} arrays. In preparation for eliminating them, add indirection via a function. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: move endianness compensation to memory coreAvi Kivity2012-01-041-6/+31
| | | | | | | | Instead of doing device endianness compensation in cpu_register_io_memory(), do it in the memory core. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()Avi Kivity2012-01-041-0/+2
| | | | | | | The getter is no longer used, so it is completely removed. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* vmstate, memory: decouple vmstate from memory APIAvi Kivity2012-01-041-6/+3
| | | | | | | | | | | | | | Currently creating a memory region automatically registers it for live migration. This differs from other state (which is enumerated in a VMStateDescription structure) and ties the live migration code into the memory core. Decouple the two by introducing a separate API, vmstate_register_ram(), for registering a RAM block for migration. Currently the same implementation is reused, but later it can be moved into a separate list, and registrations can be moved to VMStateDescription blocks. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: introduce memory_region_name()Avi Kivity2012-01-041-0/+5
| | | | | | Trivial accessor for the name attribute. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: remove CPUPhysMemoryClientAvi Kivity2012-01-031-12/+0
| | | | | | No longer used. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: temporarily add memory_region_get_ram_addr()Avi Kivity2011-12-201-0/+6
| | | | | | | This is a layering violation, but needed while the code contains naked calls to qemu_get_ram_ptr() and the like. Signed-off-by: Avi Kivity <avi@redhat.com>
* kvm: switch kvm slots to use host virtual address instead of ram_addr_tAvi Kivity2011-12-201-3/+3
| | | | | | This simplifies a later switch to the memory API in slot management. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: add API for observing updates to the physical memory mapAvi Kivity2011-12-201-0/+93
| | | | | | | | | | | | | | | Add an API that allows a client to observe changes in the global memory map: - region added (possibly with logging enabled) - region removed (possibly with logging enabled) - logging started on a region - logging stopped on a region - global logging started - global logging removed This API will eventually replace cpu_register_physical_memory_client(). Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: replace cpu_physical_sync_dirty_bitmap() with a memory APIAvi Kivity2011-12-201-0/+4
| | | | | | The function is still used as the implementation. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: introduce memory_region_find()Avi Kivity2011-12-201-0/+62
| | | | | | | | | | | Given an address space (represented by the top-level memory region), returns the memory region that maps a given range. Useful for implementing DMA. The implementation is a simplistic binary search. Once we have a tree representation this can be optimized. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: add memory_region_is_logging()Avi Kivity2011-12-201-0/+5
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: add memory_region_is_rom()Avi Kivity2011-12-201-0/+5
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: add memory_region_is_ram()Avi Kivity2011-12-201-0/+8
| | | | Signed-off-by: Avi Kivity <avi@redhat.com>
* Merge remote-tracking branch 'qemu-kvm/memory/exec-obsolete' into stagingAnthony Liguori2011-12-191-0/+3
|\
| * memory: move obsolete exec.c functions to a private headerAvi Kivity2011-12-191-0/+3
| | | | | | | | | | | | This will help avoid accidental usage. Signed-off-by: Avi Kivity <avi@redhat.com>
* | Merge remote-tracking branch 'qemu-kvm/memory/xen' into stagingAnthony Liguori2011-12-191-3/+3
|\ \ | |/
| * memory, xen: pass MemoryRegion to xen_ram_alloc()Avi Kivity2011-12-191-3/+3
| | | | | | | | | | | | | | Currently xen_ram_alloc() relies on ram_addr, which is going away. Give it something else to use as a cookie. Signed-off-by: Avi Kivity <avi@redhat.com>
* | memory: optimize empty transactions due to mutatorsAvi Kivity2011-12-051-1/+7
| | | | | | | | | | | | | | | | | | The mutating memory APIs can easily cause empty transactions, where the mutators don't actually change anything, or perhaps only modify disabled regions. Detect these conditions and avoid regenerating the memory topology. Signed-off-by: Avi Kivity <avi@redhat.com>
* | memory: introduce memory_region_set_alias_offset()Avi Kivity2011-12-051-0/+14
| | | | | | | | | | | | | | Add an API to update an alias offset of an active alias. This can be used to simplify implementation of dynamic memory banks. Signed-off-by: Avi Kivity <avi@redhat.com>
OpenPOWER on IntegriCloud