aboutsummaryrefslogtreecommitdiff
path: root/memory.c
AgeCommit message (Collapse)AuthorFilesLines
2012-12-20memory: introduce memory_region_test_and_clear_dirtyJuan Quintela1-0/+16
This function avoids having to do two calls, one to test the dirty bit, and other to reset it. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19exec: move include files to include/exec/Paolo Bonzini1-4/+4
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-10memory: Don't dump disabled regionsJan Kiszka1-1/+1
This makes "info mtree" output readable again. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-11-10memory: Reintroduce dirty flag to optimize changes on disabled regionsJan Kiszka1-2/+13
Cirrus is triggering this, e.g. during Win2k boot: Changes only on disabled regions require no topology update when transaction depth drops to 0 again. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-10-29memory: fix rendering of a region obscured by anotherAvi Kivity1-6/+6
The memory core drops regions that are hidden by another region (for example, during BAR sizing), but it doesn't do so correctly if the lower address of the existing range is below the lower address of the new range. Example (qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -vga cirrus): Existing range: 10000000-107fffff New range: 100a0000-100bffff Correct behaviour: drop new range Incorrect behaviour: add new range Fix by taking this case into account (previously we only considered equal lower boundaries). Tested-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-23Rename target_phys_addr_t to hwaddrAvi Kivity1-34/+34
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-22Merge remote-tracking branch 'qemu-kvm/memory/urgent' into stagingAnthony Liguori1-0/+3
* qemu-kvm/memory/urgent: memory: abort if a memory region is destroyed during a transaction i440fx: avoid destroying memory regions within a transaction memory: Make eventfd adhere to device endianness
2012-10-22memory: add address_space_destroy()Avi Kivity1-2/+16
Since address spaces can be created dynamically by device hotplug, they can also be destroyed dynamically. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-22memory: per-AddressSpace dispatchAvi Kivity1-0/+1
Currently we use a global radix tree to dispatch memory access. This only works with a single address space; to support multiple address spaces we make the radix tree a member of AddressSpace (via an intermediate structure AddressSpaceDispatch to avoid exposing too many internals). A side effect is that address_space_io also gains a dispatch table. When we remove all the pre-memory-API I/O registrations, we can use that for dispatching I/O and get rid of the original I/O dispatch. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-22memory: use AddressSpace for MemoryListener filteringAvi Kivity1-7/+7
Using the AddressSpace type reduces confusion, as you can't accidentally supply the MemoryRegion you're interested in. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-22memory: move address_space_memory and address_space_io out of memory coreAvi Kivity1-16/+0
With this change, memory.c no longer knows anything about special address spaces, so it is prepared for AddressSpace based DMA. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-22memory: manage coalesced mmio via a MemoryListenerAvi Kivity1-4/+13
Instead of calling a global function on coalesced mmio changes, which routes the call to kvm if enabled, add coalesced mmio hooks to MemoryListener and make kvm use that instead. The motivation is support for multiple address spaces (which means we we need to filter the call on the right address space) but the result is cleaner as well. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-17memory: abort if a memory region is destroyed during a transactionAvi Kivity1-0/+1
Destroying a memory region is illegal within a transaction, as until the transaction is committed, the memory core may hold references to the region. Add an assert to check for violations of this rule. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-17memory: Make eventfd adhere to device endiannessAlexander Graf1-0/+2
Our memory API MMIO regions know the concept of device endianness. This is used to automatically swap endianness between devices and host CPU, depending on whether buses in between would swizzle the bits. The ioeventfd value comparison does not adhere to that semantic though. Probably because nobody has been running ioeventfd on a BE platform and the only device implementing ioeventfd right now is LE (PCI) based. So add swizzling to ioeventfd registration / deletion to make the rest of the code as consistent as possible. Thanks a lot to Michael Tsirkin to point me towards the right direction. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15memory: provide defaults for MemoryListener operationsAvi Kivity1-6/+17
Many listeners don't need to respond to all MemoryListener callbacks; provide suitable no-op defaults instead. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15memory: maintain a list of address spacesAvi Kivity1-29/+46
Instead of embedding knowledge of the memory and I/O address spaces in the memory core, maintain a list of all address spaces. This list will later be extended dynamically for other bus masters. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15memory: export AddressSpaceAvi Kivity1-10/+1
The DMA API will use an AddressSpace to differentiate among different initiators. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15memory: prepare AddressSpace for exportingAvi Kivity1-15/+24
AddressSpace contains a member, current_map, of type FlatView. Since we want to limit the leakage of internal types to public headers, switch to a pointer to a FlatView. There is no performance impact as this isn't used during lookups, only address space reconfigurations. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-10-15memory: rename 'exec-obsolete.h'Avi Kivity1-2/+1
exec-obsolete.h used to hold pre-memory-API functions that were used from device code prior to the transition to the memory API. Now that the transition is complete, the name no longer describes the file. The functions still need to be merged better into the memory core, but there's no danger of anyone using them. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-09-11memory: Flush coalesced MMIO on mapping and state changesJan Kiszka1-0/+1
Flush pending coalesced MMIO before performing mapping or state changes that could affect the event orderings or route the buffered requests to a wrong region. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-09-11memory: Fold memory_region_update_topology into memory_region_transaction_commitJan Kiszka1-28/+11
Simplify the code as we are using now only a subset of the original features of memory_region_update_topology. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-09-11memory: Use transaction_begin/commit also for single-step operationsJan Kiszka1-15/+25
Wrap also simple operations consisting only of a single step with memory_region_transaction_begin/commit. This allows to perform additional steps like coalesced MMIO flushing from a single place. This requires dropping some micro-optimizations: The skipping of topology updates after updating disabled or unregistered regions. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-09-11memory: Flush coalesced MMIO on selected region accessJan Kiszka1-0/+24
Instead of flushing pending coalesced MMIO requests on every vmexit, this provides a mechanism to selectively flush when memory regions related to the coalesced one are accessed. This first of all includes the coalesced region itself but can also applied to other regions, e.g. of the same device, by calling memory_region_set_flush_coalesced. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2012-08-29memory: Fix copy&paste mistake in memory_region_iorange_writeJan Kiszka1-1/+1
The last argument of find_portio is "write", so this must be true here. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-07-12memory: pass EventNotifier, not eventfdPaolo Bonzini1-9/+9
Under Win32, EventNotifiers will not have event_notifier_get_fd, so we cannot call it in common code such as hw/virtio-pci.c. Pass a pointer to the notifier, and only retrieve the file descriptor in kvm-specific code. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-04-05memory: check address space when a listener is registeredJulien Grall1-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>
2012-03-19memory: print aliased IO ranges in info mtreeBlue Swirl1-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>
2012-03-08memory: get rid of cpu_register_io_memory()Avi Kivity1-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>
2012-03-08memory: dispatch directly via MemoryRegionAvi Kivity1-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>
2012-03-05memory: fix I/O port aliasesAvi Kivity1-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>
2012-02-29memory: support stateless memory listenersAvi Kivity1-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>
2012-02-29memory: allow MemoryListeners to observe a specific address spaceAvi Kivity1-6/+39
Ignore any regions not belonging to a specified address space. Signed-off-by: Avi Kivity <avi@redhat.com>
2012-02-29memory: drop AddressSpaceOpsAvi Kivity1-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>
2012-02-29memory: use a MemoryListener for core memory map updates tooAvi Kivity1-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>
2012-02-29memory: don't pass ->readable attribute to cpu_register_physical_memory_logAvi Kivity1-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>
2012-02-29memory: add a readonly attribute to MemoryRegionSectionAvi Kivity1-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>
2012-02-29memory: move ioeventfd ops to MemoryListenerAvi Kivity1-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>
2012-02-29memory: code motion: move MEMORY_LISTENER_CALL()Avi Kivity1-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>
2012-02-29memory: switch memory listeners to a QTAILQAvi Kivity1-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>
2012-02-29memory: add shorthand for invoking a callback on all listenersAvi Kivity1-35/+19
Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
2012-02-29memory: remove memory_region_set_offset()Avi Kivity1-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>
2012-02-11memory-region: Report if region is read-only or write-only on info mtreeJan Kiszka1-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>
2012-02-04memory: change dirty getting API to take a sizeBlue Swirl1-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>
2012-01-25memory: change dirty setting APIs to take a sizeBlue Swirl1-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>
2012-01-19memory: Introduce memory_region_init_reservationJan Kiszka1-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>
2012-01-13prepare for future GPLv2+ relicensingPaolo Bonzini1-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>
2012-01-08memory: Fix adjust_endianness()Andreas Färber1-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>
2012-01-08memory: Fix memory_region_wrong_endianness()Andreas Färber1-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>