History | View | Annotate | Download (57.5 kB)
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
pci, pc, acpi fixes, enhancements
This includes some pretty big changes:- pci master abort support by Marcel- pci IRQ API rework by Marcel- acpi generation support by myself
Everything has gone through several revisions, latest versions have been on...
memory: fix 128 arithmetic in info mtree
mtree_print_mr() calls int128_get64() in 3 places but only 2 placeshandle 2^64 correctly.
This fixes the third call of int128_get64().
Cc: qemu-stable@nongnu.orgSigned-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>...
memory: Change MemoryRegion priorities from unsigned to signed
When memory regions overlap, priority can be used to specifywhich of them takes priority. By making the priority values signedrather than unsigned, we make it more convenient to implementa situation where one "background" region should appear only...
Revert "memory: Return -1 again on reads from unsigned regions"
This reverts commit 9b8c69243585a32d14b9bb9fcd52c37b0b5a1b71.
The commit was wrong: We only return -1 on invalid accesses, not onvalid but unbacked ones. This broke various corner cases.
Cc: qemu-stable@nongnu.org...
memory.c: drop kvm.h dependency
memory.c does not use any kvm specific interfaces,don't include kvm.h
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
memory: add tracepoints for MMIO reads/writes
This is quite handy to debug softmmu targets.
Reviewed-by: Andreas Faerber <afaerber@suse.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Message-id: 1375016242-32651-1-git-send-email-pbonzini@redhat.com...
memory: move functions around
Prepare for next patch, no semantic change.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Message-id: 1374501278-31549-26-git-send-email-pbonzini@redhat.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
memory: pass MemoryRegion to access_with_adjusted_size
The accessors all use a MemoryRegion opaque value. Avoid goinguselessly through void*.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Message-id: 1374501278-31549-27-git-send-email-pbonzini@redhat.com...
memory: check memory region endianness, not target's
When combining multiple accesses into a single value, we need to do soin the device's desired endianness. The target endianness does not haveany influence.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
memory: Fix zero-sized memory region print
if mr->size == 0, then
int128_get64(int128_sub(mr->size, int128_make64(1))) => assert(!a.hi)
Also, use int128_one().
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>...
memory: actually set the owner
Brown paper bag for me. Originally commit 803c0816 came before commit2c9b15c. When the order was inverted, I left in the NULL initializationof mr->owner.
Reviewed-by: Hu Tao <hutao@cn.fujitsu.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: Return -1 again on reads from unsigned regions
This restore the behavior prior to b018ddf633 which accidentally changedthe return code to 0. Specifically guests probing for register existencewere affected by this.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
cpu: Replace cpu_single_env with CPUState current_cpu
Move it to qom/cpu.h.
Signed-off-by: Andreas Färber <afaerber@suse.de>
memory: access FlatView from a local variable
We will soon require accesses to as->current_map to be placed undera lock (with reference counting so as to keep the critical sectionsmall). To simplify this change, always fetch as->current_map intoa local variable and access it through that variable....
memory: use a new FlatView pointer on every topology update
This is the first step towards converting as->current_map toRCU-style updates, where the FlatView updates run concurrentlywith uses of an old FlatView.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>...
memory: add reference counting to FlatView
With this change, a FlatView can be used even after a concurrentupdate has replaced it. Because we do not yet have RCU, we use amutex to protect the small critical sections that read/write theas->current_map pointer. Accesses to the FlatView can be done...
memory: add getter for owner
Whenever memory regions are accessed outside the BQL, they need to bepreserved against hot-unplug. MemoryRegions actually do not have theirown reference count; they piggyback on a QOM object, their "owner".The owner is set at creation time, and there is a function to retrieve...
memory: add ref/unref
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: introduce memory_region_present
This new API will avoid having too many memory_region_ref/unrefin paths that currently use memory_region_find.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: add ref/unref calls
Add ref/unref calls at the following places:
- places where memory regions are stashed by a listener and used outside the BQL (including in Xen or KVM).
- memory_region_find callsites
- creation of aliases and containers (only the aliased/contained...
ioport: Switch dispatching to memory core layer
The current ioport dispatcher is a complex beast, mostly due to theneed to deal with old portio interface users. But we can overcome itwithout converting all portio users by embedding the required baseaddress of a MemoryRegionPortio access into that data structure. That...
memory: add owner argument to initialization functions
cpu: Turn cpu_unassigned_access() into a CPUState hook
Use it for all targets, but be careful not to pass invalid CPUState.cpu_single_env can be NULL, e.g. on Xen.
memory: give name to every AddressSpace
The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpacestructs created by PCI and VIO devices. Those devices do not normallyhave names and therefore not present in "info mtree" output....
memory: Fix comment typo
s/ajacent/adjacent
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: as_update_topology_pass: Improve comments
These comments were a little difficult to read. First one hadincorrect parenthesis. The part about attributes changing isreally applicable to the region being 'in both' rather than 'innew'
Second comment has an obscure parenthetic about 'Logging may have...
memory: render_memory_region: factor out fr constant setters
These 4 replicated lines set properties of fr that are constant overthe course of the function. Factor out their repeated setting (and alsoguards against them being set multiple times in the loop below)....
memory: make section size a 128-bit integer
So far, the size of all regions passed to listeners could fit in 64 bits,because artificial regions (containers and aliases) are eliminated bythe memory core, leaving only device regions which have reasonable sizes...
memory: iommu support
Add a new memory region type that translates addresses it is given,then forwards them to a target address space. This is similar toan alias, except that the mapping is more flexible than a lineartranslation and trucation, and also less efficient since the...
memory: Add iommu map/unmap notifiers
This patch adds a NotifierList to MemoryRegions which represent IOMMUsallowing other parts of the code to register interest in mappings orunmappings from the IOMMU. All IOMMU implementations will need to callmemory_region_notify_iommu() to inform those waiting on the notifier list,...
memory: propagate errors on I/O dispatch
Reviewed-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: correctly handle endian-swapped 64-bit accesses
memory: split accesses even when the old MMIO callbacks are used
This is useful for 64-bit memory accesses.
memory: add big endian support to access_with_adjusted_size
This will be used to split 8-byte access down to two four-byte accesses.
memory: accept mismatching sizes in memory_region_access_valid
The memory API is able to use smaller/wider accesses than requested,match that in memory_region_access_valid. Of course, the acceptscallback is still free to reject those accesses.
Reviewed-by: Richard Henderson <rth@twiddle.net>...
memory: export memory_region_access_valid to exec.c
We'll use it to implement address_space_access_valid.
memory: assign MemoryRegionOps to all regions
This allows to remove the checks on section->readonly. Simply,write accesses to ROM will not be considered "direct" and willgo through mr->ops without any special intervention.
memory: move unassigned_mem_ops to memory.c
reservation_ops is already doing the same thing.
memory: dispatch unassigned accesses based on .valid.accepts
This provides the basics for detecting accesses to unassigned memoryas soon as they happen, and also for a simple implementation ofaddress_space_access_valid.
memory: populate FlatView for new address spaces
Even a new address space might have a non-empty FlatView. In orderto initialize it properly, address_space_init should (a) callmemory_region_transaction_commit after the address space is insertedinto the list; (b) force memory_region_transaction_commit to do something....
memory: fix address space initialization/destruction
A couple of fields were left uninitialized. This was not observed earlierbecause all address spaces were statically allocated. Also free allocationfor those fields.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
memory: make memory_global_sync_dirty_bitmap take an AddressSpace
Since this is a MemoryListener operation, it only makes senseon an AddressSpace granularity.
Suggested-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: do not duplicate memory_region_destructor_none
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
memory: Rename readable flag to romd_mode
"Readable" is a very unfortunate name for this flag because even arom_device region will always be readable from the guest POV. Whatdiffers is the mapping, just like the comments had to explain already.Also, readable could currently be understood as being a generic region...
memory: allow memory_region_find() to run on non-root memory regions
memory_region_find() is similar to registering a MemoryListener andchecking for the MemoryRegionSections that come from a particularregion. There is no reason for this to be limited to a root memory...
memory: fix a bug of detection of memory region collision
The collision reports before and after this patch are:
before:
warning: subregion collision cfc/4 (pci-conf-data) vs cf8/4 (pci-conf-idx)warning: subregion collision 8000000/f8000000 (pci-hole) vs 0/8000000 (ram-below-4g)...
memory: Use non-bitops ctzl
A memory size of zero is invalid, and so that edge conditiondoes not occur.
Signed-off-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl
We had two copies of a ffs function for longs with subtly differentsemantics and, for the one in bitops.h, a confusing name: the resultwas off-by-one compared to the library function ffsl....
memory: introduce memory_region_test_and_clear_dirty
This function avoids having to do two calls, one to test the dirty bit, andother to reset it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
softmmu: move include files to include/sysemu/
misc: move include files to include/qemu/
exec: move include files to include/exec/
memory: Don't dump disabled regions
This makes "info mtree" output readable again.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
memory: Reintroduce dirty flag to optimize changes on disabled regions
Cirrus is triggering this, e.g. during Win2k boot: Changes only ondisabled regions require no topology update when transaction depth dropsto 0 again.
memory: fix rendering of a region obscured by another
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 theexisting range is below the lower address of the new range....
Rename target_phys_addr_t to hwaddr
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes arereserved) and its purpose doesn't match the name (most target_phys_addr_taddresses are not target specific). Replace it with a finger-friendly,...
Merge remote-tracking branch 'qemu-kvm/memory/urgent' into staging
memory: per-AddressSpace dispatch
Currently we use a global radix tree to dispatch memory access. This onlyworks with a single address space; to support multiple address spaces wemake the radix tree a member of AddressSpace (via an intermediate structure...
memory: add address_space_destroy()
Since address spaces can be created dynamically by device hotplug, theycan also be destroyed dynamically.
Signed-off-by: Avi Kivity <avi@redhat.com>
memory: move address_space_memory and address_space_io out of memory core
With this change, memory.c no longer knows anything about special addressspaces, so it is prepared for AddressSpace based DMA.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Avi Kivity <avi@redhat.com>
memory: use AddressSpace for MemoryListener filtering
Using the AddressSpace type reduces confusion, as you can't accidentallysupply the MemoryRegion you're interested in.
memory: manage coalesced mmio via a MemoryListener
Instead of calling a global function on coalesced mmio changes, whichroutes the call to kvm if enabled, add coalesced mmio hooks toMemoryListener and make kvm use that instead.
The motivation is support for multiple address spaces (which means we...
memory: abort if a memory region is destroyed during a transaction
Destroying a memory region is illegal within a transaction, as untilthe transaction is committed, the memory core may hold references tothe region. Add an assert to check for violations of this rule....
memory: Make eventfd adhere to device endianness
Our memory API MMIO regions know the concept of device endianness. Thisis used to automatically swap endianness between devices and host CPU,depending on whether buses in between would swizzle the bits....
memory: prepare AddressSpace for exporting
AddressSpace contains a member, current_map, of type FlatView. Since wewant to limit the leakage of internal types to public headers, switch toa pointer to a FlatView. There is no performance impact as this isn't used...
memory: export AddressSpace
The DMA API will use an AddressSpace to differentiate among differentinitiators.
memory: maintain a list of address spaces
Instead of embedding knowledge of the memory and I/O address spaces in thememory core, maintain a list of all address spaces. This list will laterbe extended dynamically for other bus masters.
memory: provide defaults for MemoryListener operations
Many listeners don't need to respond to all MemoryListener callbacks;provide suitable no-op defaults instead.
memory: rename 'exec-obsolete.h'
exec-obsolete.h used to hold pre-memory-API functions that were used fromdevice code prior to the transition to the memory API. Now that thetransition is complete, the name no longer describes the file. Thefunctions still need to be merged better into the memory core, but there's...
memory: Flush coalesced MMIO on mapping and state changes
Flush pending coalesced MMIO before performing mapping or state changesthat could affect the event orderings or route the buffered requests toa wrong region.
memory: Fold memory_region_update_topology into memory_region_transaction_commit
Simplify the code as we are using now only a subset of the originalfeatures of memory_region_update_topology.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
memory: Use transaction_begin/commit also for single-step operations
Wrap also simple operations consisting only of a single step withmemory_region_transaction_begin/commit. This allows to performadditional steps like coalesced MMIO flushing from a single place....
memory: Flush coalesced MMIO on selected region access
Instead of flushing pending coalesced MMIO requests on every vmexit,this provides a mechanism to selectively flush when memory regionsrelated to the coalesced one are accessed. This first of all includes...
memory: Fix copy&paste mistake in memory_region_iorange_write
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>
memory: pass EventNotifier, not eventfd
Under Win32, EventNotifiers will not have event_notifier_get_fd, so wecannot call it in common code such as hw/virtio-pci.c. Pass a pointer tothe notifier, and only retrieve the file descriptor in kvm-specific code....
memory: check address space when a listener is registered
This patch resolves a bug in memory listener registration."range_add" callback was called on each section of the bothaddress space (IO and memory space) even if it doesn't matchthe address space filter....
memory: print aliased IO ranges in info mtree
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()
The return value of cpu_register_io_memory() is no longer used anywhere, sowe can remove it and all associated data and code.
memory: dispatch directly via MemoryRegion
Instead of indirecting via io_mem_region, dispatch directlythrough the MemoryRegion obtained from the iotlb or phys_page_find().
memory: fix I/O port aliases
Commit e58ac72b6a0 ("ioport: change portio_list not to usememory_region_set_offset()") started using aliases of I/O memoryregions. Since the IORange used for the I/O was contained in thetarget region, the alias information (specifically, the offset...
memory: don't pass ->readable attribute to cpu_register_physical_memory_log
It can be derived from the MemoryRegion itself (which is why it is notused there).
Signed-off-by: Avi Kivity <avi@redhat.com>Reviewed-by: Richard Henderson <rth@twiddle.net>
memory: use a MemoryListener for core memory map updates too
This transforms memory.c into a library which can then be unit testedeasily, by feeding it inputs and listening to its outputs.
memory: drop AddressSpaceOps
All functionality has been moved to various MemoryListeners.
memory: allow MemoryListeners to observe a specific address space
Ignore any regions not belonging to a specified address space.
memory: support stateless memory listeners
Current memory listeners are incremental; that is, they are expected tomaintain their own state, and receive callbacks for changes to that state.
This patch adds support for stateless listeners; these work by receiving...
memory: remove memory_region_set_offset()
memory_region_set_offset() complicates the API, and has been deprecatedsince its introduction. Now that it is no longer used, remove it.
memory: add shorthand for invoking a callback on all listeners
memory: switch memory listeners to a QTAILQ
This allows reverse iteration, which in turns allows consistent orderingamong multiple listeners:
l1->add l2->add l2->del l1->del
memory: code motion: move MEMORY_LISTENER_CALL()
So it can be used in earlier code.
memory: move ioeventfd ops to MemoryListener
This way the accelerator (kvm) can handle them directly.
memory: add a readonly attribute to MemoryRegionSection
.readonly cannot be obtained from the MemoryRegion, since it isinherited from aliases (so you can have a MemoryRegion mapped RWat one address and RO at another). Record it in a MemoryRegionSection...
memory-region: Report if region is read-only or write-only on info mtree
Helpful to understand guest configurations of things like the i440FX'sPAM or the state of ROM devices.
memory: change dirty getting API to take a size
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 size
Instead of each target knowing or guessing the guest page size,just pass the desired size of dirtied memory area.
memory: Introduce memory_region_init_reservation
Introduce a memory region type that can reserve I/O space. Such regionsare 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...
prepare for future GPLv2+ relicensing
All files under GPLv2 will get GPLv2+ changes starting tomorrow.event_notifier.c and exec-obsolete.h were only ever touched by Red Hatemployees and can be relicensed now.
memory: Fix adjust_endianness()
Commit a621f38de85598a13d8d8524d1a94fc6a1818215 (Direct dispatchthrough 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>...
memory: Fix memory_region_wrong_endianness()
Since commit be675c972088eba210e18dc125613e9f205a6bfb (memory: moveendianness compensation to memory core) it was checking forTARGET_BIG_ENDIAN instead of TARGET_WORDS_BIGENDIAN, thereby notswapping correctly for Big Endian targets....
Remove IO_MEM_SUBPAGE
Replace with a MemoryRegion flag.
Drop IO_MEM_ROMD
Unlike ->readonly, ->readable is not inherited from aliase, so we can simplyquery the memory region.