Commit Graph

77 Commits

Author SHA1 Message Date
Avi Kivity 72e22d2fe1 memory: switch memory listeners to a QTAILQ
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-29 13:44:41 +02:00
Avi Kivity 946996e9c1 memory: add shorthand for invoking a callback on all listeners
Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2012-02-29 13:44:41 +02:00
Avi Kivity 2b50aa1f14 memory: remove memory_region_set_offset()
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-29 13:44:41 +02:00
Jan Kiszka 4896d74b84 memory-region: Report if region is read-only or write-only on info mtree
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-11 10:49:07 +00:00
Blue Swirl cd7a45c95e 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>
2012-02-04 12:45:10 +00:00
Blue Swirl fd4aa97903 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.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-01-25 18:32:47 +00:00
Jan Kiszka 1660e72d4f memory: Introduce memory_region_init_reservation
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-19 12:14:41 +01:00
Paolo Bonzini 6b620ca3b0 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 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-13 10:55:56 -06:00
Andreas Färber 1470a0cdca memory: Fix adjust_endianness()
Commit a621f38de8 (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-08 13:10:16 +02:00
Andreas Färber 2c3579ab07 memory: Fix memory_region_wrong_endianness()
Since commit be675c9720 (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>
2012-01-08 13:10:09 +02:00
Avi Kivity 75c578dcaa Drop IO_MEM_ROMD
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>
2012-01-04 13:34:50 +02:00
Avi Kivity b3b00c78d8 Remove IO_MEM_SUBPAGE
Replace with a MemoryRegion flag.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2012-01-04 13:34:50 +02:00
Avi Kivity a621f38de8 Direct dispatch through MemoryRegion
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>
2012-01-04 13:34:50 +02:00
Avi Kivity dd81124bf6 Switch cpu_register_physical_memory_log() to use MemoryRegions
Still internally using ram_addr.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
2012-01-04 13:34:50 +02:00
Avi Kivity 0e0df1e24d Convert IO_MEM_{RAM,ROM,UNASSIGNED,NOTDIRTY} to MemoryRegions
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>
2012-01-04 13:34:50 +02:00
Avi Kivity 1d393fa2d1 Avoid range comparisons on io index types
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>
2012-01-04 13:34:49 +02:00
Avi Kivity 26a83ad0e7 memory: remove MemoryRegion::backend_registered
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>
2012-01-04 13:34:49 +02:00
Avi Kivity acbbec5d43 memory: move mmio access to functions
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>
2012-01-04 13:34:49 +02:00
Avi Kivity be675c9720 memory: move endianness compensation to memory core
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>
2012-01-04 13:34:49 +02:00
Avi Kivity 8f77558f22 memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()
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>
2012-01-04 13:34:49 +02:00
Avi Kivity c5705a7728 vmstate, memory: decouple vmstate from memory API
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>
2012-01-04 13:34:48 +02:00
Avi Kivity 8991c79b57 memory: introduce memory_region_name()
Trivial accessor for the name attribute.

Signed-off-by: Avi Kivity <avi@redhat.com>
2012-01-04 13:34:47 +02:00
Avi Kivity dcd97e33af memory: remove CPUPhysMemoryClient
No longer used.

Signed-off-by: Avi Kivity <avi@redhat.com>
2012-01-03 19:19:27 +02:00
Avi Kivity e34911c420 memory: temporarily add memory_region_get_ram_addr()
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>
2011-12-20 14:14:08 +02:00
Avi Kivity 9f213ed92c kvm: switch kvm slots to use host virtual address instead of ram_addr_t
This simplifies a later switch to the memory API in slot management.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-20 14:14:07 +02:00
Avi Kivity 7664e80c84 memory: add API for observing updates to the physical memory map
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>
2011-12-20 14:14:07 +02:00
Avi Kivity 86e775c654 memory: replace cpu_physical_sync_dirty_bitmap() with a memory API
The function is still used as the implementation.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-20 14:14:07 +02:00
Avi Kivity e2177955a8 memory: introduce memory_region_find()
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>
2011-12-20 14:14:07 +02:00
Avi Kivity 55043ba37e memory: add memory_region_is_logging()
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-20 14:14:06 +02:00
Avi Kivity ce7923da4d memory: add memory_region_is_rom()
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-20 14:14:06 +02:00
Avi Kivity 8ea9252abe memory: add memory_region_is_ram()
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-20 14:14:06 +02:00
Anthony Liguori f76d27b67c Merge remote-tracking branch 'qemu-kvm/memory/exec-obsolete' into staging 2011-12-19 09:45:17 -06:00
Anthony Liguori 4a1cc6800a Merge remote-tracking branch 'qemu-kvm/memory/xen' into staging 2011-12-19 09:45:12 -06:00
Avi Kivity 67d95c153b memory: move obsolete exec.c functions to a private header
This will help avoid accidental usage.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-19 17:28:54 +02:00
Avi Kivity fce537d4a7 memory, xen: pass MemoryRegion to xen_ram_alloc()
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>
2011-12-19 17:23:24 +02:00
Avi Kivity e87c099f1c memory: optimize empty transactions due to mutators
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>
2011-12-05 12:04:09 +02:00
Avi Kivity 4703359e0e memory: introduce memory_region_set_alias_offset()
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>
2011-12-05 12:04:05 +02:00
Avi Kivity 2282e1af40 memory: introduce memory_region_set_address()
Allow changing the address of a memory region while it is
in the memory hierarchy.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-04 19:19:39 +02:00
Avi Kivity 6bba19ba4e memory: introduce memory_region_set_enabled()
This allows users to disable a memory region without removing
it from the hierarchy, simplifying the implementation of
memory routers.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-04 19:00:33 +02:00
Avi Kivity 897fa7cff2 memory: add MemoryRegionOps::valid.accepts
MemoryRegionOps::valid tries to declaratively specify which transactions
are accepted by the device/bus, however it is not completely generic.  Add
a callback for special cases.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-24 18:32:00 +02:00
Avi Kivity 88365e47dd memory: fix 'info mtree' segfaults
'info mtree' accesses invalid memory in two cases, both due to incorrect
(and unsafe) usage of QTAILQ_FOREACH_SAFE().

Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-11-13 12:00:55 +02:00
Avi Kivity 08dafab4bd memory: use 128-bit integers for sizes and intermediates
Since the memory API supports 64-bit buses, it needs a larger type to represent
intermediate results.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-16 13:19:17 +02:00
Jan Kiszka 03808f58e4 memory: Fix old portio word accesses
As we register old portio regions via ioport_register, we are also
responsible for providing the word access wrapper.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-11 15:57:09 +02:00
Avi Kivity 6bf9fd43cf Introduce PortioList
Add a type and methods for manipulating a list of disjoint I/O ports,
used in some older hardware devices.

Based on original patch by Richard Henderson.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-11 15:57:07 +02:00
Jan Kiszka 9479c57a8c memory: Print regions in ascending order
Makes reading the output more user friendly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-02 16:27:14 +02:00
Jan Kiszka 066318109f memory: Do not print empty PIO root
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-02 16:27:14 +02:00
Jan Kiszka 4b474ba7a1 memory: Print region priority
Useful to discover eclipses.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-02 16:27:14 +02:00
Blue Swirl 314e298735 memory: simple memory tree printer
Add a monitor command 'info mtree' to show the memory hierarchy
much like /proc/iomem in Linux.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-02 16:27:13 +02:00
Avi Kivity fb1cd6f998 memory: implement memory_region_set_readonly()
The property is inheritable, but only if set to true.  This is so
that memory routers can mark sections of RAM as read-only via aliases.

Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-25 14:48:47 +03:00
Michael Walle 860329b251 memory: fix subregion collision warning
Instead of the offset property use the proper addr property to calculate
the offsets.

Additionally, be a little more verbose on the warning and print the
subregion name.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Avi Kivity <avi@redhat.com>
2011-09-18 14:55:16 +03:00