summaryrefslogtreecommitdiff
path: root/include/exec/memory.h
AgeCommit message (Collapse)AuthorFilesLines
2014-03-09memory_region_present: return false if address is not found in child ↵Igor Mammedov1-3/+3
MemoryRegion Windows XP shows COM2 port as non functional in "Device Manager" although no COM2 port backing device is present in QEMU. This regression is really due to 3bb28b7208b349e7a1b326e3c6ef9efac1d462bf? memory: Provide separate handling of unassigned io ports accesses That is caused by the fact that QEMU reports to OSPM that device is present by setting 5th bit in PII4XPM.pci_conf[0x67] register when COM2 doesn't exist. It happens due to memory_region_present(io_as, 0x2f8) returning false positive since 0x2f8 address eventually translates into catchall io_as address space. Fix memory_region_present(parent, addr) by returning true only if addr maps into a MemoryRegion within parent (excluding parent itself), to match its doc comment. While at it fix copy/paste error in memory_region_present() doc comment. Note: this is a temporary hack: we really need better handling for unassigned regions, we should avoid fallback regions since they are bad for performance (breaking radix tree assumption that the data structure is sparsely populated); for memory we need to fix this to implement PCI master abort properly, anyway. Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-02-11memory: Add MemoryListener to typedefs.hEdgar E. Iglesias1-2/+0
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
2014-01-13memory: split dirty bitmap into threeJuan Quintela1-5/+5
After all the previous patches, spliting the bitmap gets direct. Note: For some reason, I have to move DIRTY_MEMORY_* definitions to the beginning of memory.h to make compilation work. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2014-01-13memory: use bit 2 for migrationJuan Quintela1-1/+2
For historical reasons it was bit 3. Once there, create a constant to know the number of clients. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2014-01-13memory: cpu_physical_memory_mask_dirty_range() always clears a single flagJuan Quintela1-3/+0
Document it Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2013-10-14memory: Change MemoryRegion priorities from unsigned to signedMarcel Apfelbaum1-2/+2
When memory regions overlap, priority can be used to specify which of them takes priority. By making the priority values signed rather than unsigned, we make it more convenient to implement a situation where one "background" region should appear only where no other region exists: rather than having to explicitly specify a high priority for all the other regions, we can let them take the default (zero) priority and specify a negative priority for the background region. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-07-04exec: separate current radix tree from the one being builtPaolo Bonzini1-0/+1
This same treatment previously done to phys_node_map and phys_sections is now applied to the dispatch field of AddressSpace. Topology updates use as->next_dispatch while accesses use as->dispatch. Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04exec: move listener from AddressSpaceDispatch to AddressSpacePaolo Bonzini1-0/+2
This will help having two copies of AddressSpaceDispatch during the recreation of the radix tree (one being built, and one that is complete and will be protected by RCU). We do not want to have to unregister and re-register the listener. Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04memory: move MemoryListener declaration earlierPaolo Bonzini1-33/+33
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04memory: introduce memory_region_presentPaolo Bonzini1-0/+12
This new API will avoid having too many memory_region_ref/unref in paths that currently use memory_region_find. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04memory: add ref/unrefPaolo Bonzini1-0/+30
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04memory: add getter for ownerPaolo Bonzini1-0/+7
Whenever memory regions are accessed outside the BQL, they need to be preserved against hot-unplug. MemoryRegions actually do not have their own reference count; they piggyback on a QOM object, their "owner". The owner is set at creation time, and there is a function to retrieve the owner. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04memory: add owner argument to initialization functionsPaolo Bonzini1-0/+17
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04ioport: Move portio types to ioport.hJan Kiszka1-13/+0
This decouples memory.h from ioport.h, concentrating all portio related types in a single header. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04ioport: Remove unused old dispatching servicesJan Kiszka1-9/+0
Remove unused ioport_register and isa_unassign_ioport along with everything that only those services used. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-07-04ioport: Switch dispatching to memory core layerJan Kiszka1-4/+1
The current ioport dispatcher is a complex beast, mostly due to the need to deal with old portio interface users. But we can overcome it without converting all portio users by embedding the required base address of a MemoryRegionPortio access into that data structure. That removes the need to have the additional MemoryRegionIORange structure in the loop on every access. To handle old portio memory ops, we simply install dispatching handlers for portio memory regions when registering them with the memory core. This removes the need for the old_portio field. We can drop the additional aliasing of ioport regions and also the special address space listener. cpu_in and cpu_out now simply call address_space_read/write. And we can concentrate portio handling in a single source file. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-28hwaddr: Make hwaddr type usable beyond softmmuAndreas Färber1-0/+2
While not normally needed for *-user, it can safely be used there since always based on uint64_t, to avoid ifdeffery. To avoid accidental uses, move the guards from exec/hwaddr.h to its inclusion sites. No need for them in include/hw/. Prepares for hwaddr use in qom/cpu.h. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-06-20memory: give name to every AddressSpaceAlexey Kardashevskiy1-2/+4
The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpace structs created by PCI and VIO devices. Those devices do not normally have names and therefore not present in "info mtree" output. The patch fixes this. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-20memory: Add iommu map/unmap notifiersDavid Gibson1-0/+32
This patch adds a NotifierList to MemoryRegions which represent IOMMUs allowing other parts of the code to register interest in mappings or unmappings from the IOMMU. All IOMMU implementations will need to call memory_region_notify_iommu() to inform those waiting on the notifier list, whenever an IOMMU mapping is made or removed. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-20memory: iommu supportAvi Kivity1-4/+62
Add a new memory region type that translates addresses it is given, then forwards them to a target address space. This is similar to an alias, except that the mapping is more flexible than a linear translation and trucation, and also less efficient since the translation happens at runtime. The implementation uses an AddressSpace mapping the target region to avoid hierarchical dispatch all the way to the resolved region; only iommu regions are looked up dynamically. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Avi Kivity <avi.kivity@gmail.com> [Modified to put translation in address_space_translate; assume IOMMUs are not reachable from TCG. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-20memory: make section size a 128-bit integerPaolo Bonzini1-1/+4
So far, the size of all regions passed to listeners could fit in 64 bits, because artificial regions (containers and aliases) are eliminated by the memory core, leaving only device regions which have reasonable sizes An IOMMU however cannot be eliminated by the memory core, and may have an artificial size, hence we may need 65 bits to represent its size. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-20Revert "memory: limit sections in the radix tree to the actual address space ↵Paolo Bonzini1-3/+0
size" This reverts commit 86a8623692b1b559a419a92eb8b6897c221bca74. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-06-20exec: return MemoryRegion from address_space_translatePaolo Bonzini1-4/+4
Only address_space_translate_for_iotlb needs to return the section. Every caller of address_space_translate now uses only section->mr, return it directly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-29memory: add return value to address_space_rw/read/writePaolo Bonzini1-3/+9
Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-29memory: add address_space_access_validPaolo Bonzini1-0/+15
The old-style IOMMU lets you check whether an access is valid in a given DMAContext. There is no equivalent for AddressSpace in the memory API, implement it with a lookup of the dispatch tree. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-29memory: add address_space_translatePaolo Bonzini1-17/+14
Using phys_page_find to translate an AddressSpace to a MemoryRegionSection is unwieldy. It requires to pass the page index rather than the address, and later memory_region_section_addr has to be called. Replace memory_region_section_addr with a function that does all of it: call phys_page_find, compute the offset within the region, and check how big the current mapping is. This way, a large flat region can be written with a single lookup rather than a page at a time. address_space_translate will also provide a single point where IOMMU forwarding is implemented. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-24memory: limit sections in the radix tree to the actual address space sizeAvi Kivity1-0/+3
The radix tree is statically sized to fit TARGET_PHYS_ADDR_SPACE_BITS. If a larger memory region is registered, it will overflow. Fix by limiting any section in the radix tree to the supported size. This problem was not observed earlier since artificial regions (containers and aliases) are eliminated by the memory core, leaving only device regions which have reasonable sizes. An IOMMU however cannot be eliminated by the memory core, and may have an artificial size. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Avi Kivity <avi.kivity@gmail.com> [ Fail the build if TARGET_PHYS_ADDR_SPACE_BITS is too large - Paolo ] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-24memory: make memory_global_sync_dirty_bitmap take an AddressSpacePaolo Bonzini1-4/+3
Since this is a MemoryListener operation, it only makes sense on an AddressSpace granularity. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-24memory: Rename readable flag to romd_modeJan Kiszka1-11/+11
"Readable" is a very unfortunate name for this flag because even a rom_device region will always be readable from the guest POV. What differs is the mapping, just like the comments had to explain already. Also, readable could currently be understood as being a generic region flag, but it only applies to rom_device regions. So rename the flag and the function to modify it after the original term "ROMD" which could also be interpreted as "ROM direct", i.e. ROM mode with direct access. In any case, the scope of the flag is clearer now. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-24memory: allow memory_region_find() to run on non-root memory regionsPaolo Bonzini1-9/+19
memory_region_find() is similar to registering a MemoryListener and checking for the MemoryRegionSections that come from a particular region. There is no reason for this to be limited to a root memory region. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-15memory: move core typedefs to qemu/typedefs.hPaolo Bonzini1-5/+0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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-19misc: move include files to include/qemu/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19exec: move include files to include/exec/Paolo Bonzini1-0/+882
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>