Amit Shah [Wed, 20 Jul 2011 08:00:56 +0000 (13:30 +0530)]
balloon: Separate out stat and balloon handling
Passing on '0' as ballooning target to indicate retrieval of stats is
bad API. It also makes 'balloon 0' in the monitor cause a segfault.
Have two different functions handle the different functionality instead.
Detailed explanation from Markus's review:
1. do_info_balloon() is an info_async() method. It receives a callback
with argument, to be called exactly once (callback frees the
argument). It passes the callback via qemu_balloon_status() and
indirectly through qemu_balloon_event to virtio_balloon_to_target().
virtio_balloon_to_target() executes its balloon stats half. It
stores the callback in the device state.
If it can't send a stats request, it resets stats and calls the
callback right away.
Else, it sends a stats request. The device model runs the callback
when it receives the answer.
Works.
2. do_balloon() is a cmd_async() method. It receives a callback with
argument, to be called when the command completes. do_balloon()
calls it right before it succeeds. Odd, but should work.
Nevertheless, it passes the callback on via qemu_ballon() and
indirectly through qemu_balloon_event to virtio_balloon_to_target().
a. If the argument is non-zero, virtio_balloon_to_target() executes
its balloon half, which doesn't use the callback in any way.
Odd, but works.
b. If the argument is zero, virtio_balloon_to_target() executes its
balloon stats half, just like in 1. It either calls the callback
right away, or arranges for it to be called later.
Thus, the callback runs twice: use after free and double free.
Test case: start with -S -device virtio-balloon, execute "balloon 0" in
human monitor. Runs the callback first from virtio_balloon_to_target(),
then again from do_balloon().
Amit Shah [Wed, 20 Jul 2011 07:49:07 +0000 (13:19 +0530)]
virtio-balloon: Separate status handling into separate function
Separate out the code to retrieve balloon info from the code that sets
balloon values.
This will be used to separate the two callbacks from balloon.c and help
cope with 'balloon 0' on the monitor. Currently, 'balloon 0' causes a
segfault in monitor_resume().
Michael Walle [Thu, 21 Jul 2011 18:52:24 +0000 (20:52 +0200)]
lm32: softusb: claim to support full speed
The QEMU keyboard and mouse reports themselves as full speed devices,
though they are actually low speed devices. Until this is fixed, claim that
we are supporting full speed devices.
Commit b14ef7c9ab41ea824c3ccadb070ad95567cca84e
introduced cpu_unassigned_access() function. On Sparc,
the function does not restore AREG0 used for global CPUState
on function exit, causing bugs with non-faulting unassigned
memory accesses. Alpha, Microblaze and MIPS are not affected.
Fix by restoring AREG0 on exit. Remove excess saving by
do_unassigned_access() functions.
Also ignore unassigned accesses outside of CPU context.
Added file tcg/optimize.c to hold TCG optimizations. Function tcg_optimize
is called from tcg_gen_code_common. It calls other functions performing
specific optimizations. Stub for constant folding was added.
Blue Swirl [Wed, 13 Jul 2011 12:44:15 +0000 (12:44 +0000)]
exec.h cleanup
Move softmmu_exec.h include directives from target-*/exec.h to
target-*/op_helper.c. Move also various other stuff only used in
op_helper.c there.
Define global env in dyngen-exec.h.
For i386, move wrappers for segment and FPU helpers from user-exec.c
to op_helper.c. Implement raise_exception_err_env() to handle dynamic
CPUState. Move the function declarations to cpu.h since they can be
used outside of op_helper.c context.
LM32, s390x, UniCore32: remove unused cpu_halted(), regs_to_env() and
env_to_regs().
ARM: make raise_exception() static.
Convert
#include "exec.h"
to
#include "cpu.h"
#include "dyngen-exec.h"
and remove now unused target-*/exec.h.
Michael Tokarev [Thu, 12 May 2011 14:44:17 +0000 (18:44 +0400)]
revamp acpitable parsing and allow to specify complete (headerful) table
This patch almost rewrites acpi_table_add() function
(but still leaves it using old get_param_value() interface).
The result is that it's now possible to specify whole table
(together with a header) in an external file, instead of just
data portion, with a new file= parameter, but at the same time
it's still possible to specify header fields as before.
Now with the checkpatch.pl formatting fixes, thanks to
Stefan Hajnoczi for suggestions, with changes from
Isaku Yamahata, and with my further refinements.
Peter Maydell [Mon, 18 Jul 2011 10:44:09 +0000 (11:44 +0100)]
user: Restore debug usage message for '-d ?' in user mode emulation
The code which prints the debug usage message on '-d ?' for *-user
has to come before the check for "not enough arguments", so that
"qemu-foo -d ?" prints the list of possible debug log items rather than
the generic usage message. (This was inadvertently broken in commit c235d73.)
Juha Riihimäki [Fri, 29 Jul 2011 15:35:28 +0000 (16:35 +0100)]
hw/onenand: program actions can only clear bits
The program actions onenand_prog_main() and onenand_prog_spare()
can only set bits.
This implies a rewrite of onenand_erase() to not use the program
functions, since erase does need to set bits.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Juha Riihimäki [Fri, 29 Jul 2011 15:35:26 +0000 (16:35 +0100)]
onenand: Handle various ID fields separately
Handle the manufacturer, device and version IDs separately rather than
smooshing them all together into a single uint32_t. Note that the ID
registers are actually 16 bit, even though typically the top bits are 0
and the Read Identification Data command only returns the bottom 8 bits.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Juha Riihimäki [Fri, 29 Jul 2011 15:35:24 +0000 (16:35 +0100)]
hw/nand: qdevify
Qdevify the NAND device.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Juha Riihimäki [Fri, 29 Jul 2011 15:35:22 +0000 (16:35 +0100)]
hw/nand: Support multiple reads following READ STATUS
After receiving READ STATUS command all subsequent IO reads should return
the status register value until another command is issued.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Juha Riihimäki [Fri, 29 Jul 2011 15:35:21 +0000 (16:35 +0100)]
hw/nand: Support devices wider than 8 bits
Support NAND devices which are wider than 8 bits.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Juha Riihimäki [Fri, 29 Jul 2011 15:35:20 +0000 (16:35 +0100)]
hw/nand: Support large NAND devices
Add support for NAND devices of over 1Gb.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Peter Maydell [Fri, 29 Jul 2011 15:35:18 +0000 (16:35 +0100)]
lm832x: Take DeviceState pointer in lm832x_key_event()
Since lm832x has been qdev'ified, its users will generally
have a DeviceState pointer rather than an i2c_slave pointer,
so adjust lm832x_key_event's prototype to suit.
This allows the n810 (its only user) to actually pass a correct
pointer to it rather than NULL. The effect is that we no longer
segfault when a key is pressed.
Juha Riihimäki [Fri, 29 Jul 2011 15:35:17 +0000 (16:35 +0100)]
hw/omap_gpio.c: Convert to qdev
Convert the OMAP GPIO module to qdev.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Juha Riihimäki [Fri, 29 Jul 2011 15:35:14 +0000 (16:35 +0100)]
hw/omap_l4.c: Add helper function omap_l4_region_base
Add helper function omap_l4_region_base() to return the base address
of a particular region of an L4 target agent.
Signed-off-by: Juha Riihimäki <[email protected]>
[Riku Voipio: Fixes and restructuring patchset] Signed-off-by: Riku Voipio <[email protected]>
[Peter Maydell: More fixes and cleanups for upstream submission] Signed-off-by: Peter Maydell <[email protected]> Signed-off-by: Andrzej Zaborowski <[email protected]>
Jan Kiszka [Mon, 25 Jul 2011 16:11:20 +0000 (18:11 +0200)]
Allow to leave type on default in -machine
This allows to specify -machine options without setting an explicit
machine type. We will pick the default machine in this case. Requesting
the list of available machines is still possible via '-machine ?' e.g.
Stefan Berger [Tue, 26 Jul 2011 14:33:11 +0000 (10:33 -0400)]
Fix a compilation error in xen-mapcache.c
This patch fixes a compilation error in xen-mapcache.c .
/home/stefanb/qemu/qemu-git/xen-mapcache.c: In function ‘xen_ram_addr_from_mapcache’:
/home/stefanb/qemu/qemu-git/xen-mapcache.c:240:42: error: variable ‘pentry’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
Multiboot images can specify a bss segment. The boot loader must clear
the memory of the bss and ensure that no modules or structures are
allocated inside it. Several fields are provided in the Multiboot
header that were previously not used properly. The header is now used
to determine how much data should be read from the image and how much
memory should be reserved to the bss segment.
When writing the last sector of an SD card using WRITE_MULTIPLE_BLOCK
QEmu throws an error saying that we've run off the end, and leaves
itself in the wrong state.
Paolo Bonzini [Thu, 28 Jul 2011 10:10:29 +0000 (12:10 +0200)]
softfloat: change default nan definitions to variables
Most definitions in softfloat.h are really target-independent, but the
file is not because it includes definitions of the default NaN values.
Change those to variables to allow including softfloat.h from files that
are not compiled per-target. By making them const, the compiler is
allowed to optimize them into softfloat functions that use them.
wayne [Wed, 27 Jul 2011 10:04:55 +0000 (18:04 +0800)]
showing a splash picture when start
Added options to let qemu transfer two configuration files to bios:
"bootsplash.bmp" and "etc/boot-menu-wait", which could be specified by command
-boot splash=P,splash-time=T
P is jpg/bmp file name or an absolute path, T have a max value of 0xffff, unit
is ms. With these two options, if user invoke qemu with menu=on option, then
a splash picture would be showed in a given time. For example:
qemu -boot menu=on,splash=/root/boot.bmp,splash-time=5000
would make boot.bmp shown as a brand with 5 seconds in the booting up process.
This feature need the new seabios's support, which could be got from git.
Avi Kivity [Tue, 26 Jul 2011 11:26:21 +0000 (14:26 +0300)]
sysbus: add MemoryRegion based memory management API
Allow registering sysbus device memory using a MemoryRegion. Once all users
are converted, sysbus_init_mmio() and sysbus_init_mmio_cb() will be removed.
Avi Kivity [Tue, 26 Jul 2011 11:26:13 +0000 (14:26 +0300)]
memory: transaction API
Allow changes to the memory hierarchy to be accumulated and
made visible all at once. This reduces computational effort,
especially when an accelerator (e.g. kvm) is involved.
Useful when a single register update causes multiple changes
to an address space.
The single pass algorithm removed a1, added b2, then removed a2 and a3,
which caused the wrong memory map to be built. The two pass algorithm
removes a1, a2, and a3, then adds b1.
Avi Kivity [Tue, 26 Jul 2011 11:26:11 +0000 (14:26 +0300)]
memory: add ioeventfd support
As with the rest of the memory API, the caller associates an eventfd
with an address, and the memory API takes care of registering or
unregistering when the address is made visible or invisible to the
guest.
Avi Kivity [Tue, 26 Jul 2011 11:26:07 +0000 (14:26 +0300)]
memory: late initialization of ram_addr
For non-RAM memory regions, we cannot tell whether this is an I/O region
or an MMIO region. Since the qemu backing registration is different for
the two, we have to defer initialization until we know which address
space we are in.
These shenanigans will be removed once the backing registration is unified
with the memory API.
Avi Kivity [Tue, 26 Jul 2011 11:26:05 +0000 (14:26 +0300)]
memory: abstract address space operations
Prepare for multiple address space support by abstracting away the details
of registering a memory range with qemu's flat representation into an
AddressSpace object.
Note operations which are memory specific are not abstracted, since they will
never be called on I/O address spaces anyway.
Avi Kivity [Tue, 26 Jul 2011 11:26:04 +0000 (14:26 +0300)]
Internal interfaces for memory API
get_system_memory() provides the root of the memory hierarchy.
This interface is intended to be private between memory.c and exec.c.
If this file is included elsewhere, it should be regarded as a bug (or
TODO item). However, it will be temporarily needed for the conversion
to hierarchical memory routing.
Avi Kivity [Tue, 26 Jul 2011 11:26:03 +0000 (14:26 +0300)]
memory: merge adjacent segments of a single memory region
Simple implementations of memory routers, for example the Cirrus VGA memory banks
or the 440FX PAM registers can generate adjacent memory regions which are contiguous.
Detect these and merge them; this saves kvm memory slots and shortens lookup times.
Avi Kivity [Tue, 26 Jul 2011 11:26:01 +0000 (14:26 +0300)]
Hierarchical memory region API
The memory API separates the attributes of a memory region (its size, how
reads or writes are handled, dirty logging, and coalescing) from where it
is mapped and whether it is enabled. This allows a device to configure
a memory region once, then hand it off to its parent bus to map it according
to the bus configuration.
Hierarchical registration also allows a device to compose a region out of
a number of sub-regions with different properties; for example some may be
RAM while others may be MMIO.
Jan Kiszka [Sun, 24 Jul 2011 17:38:36 +0000 (19:38 +0200)]
qdev: Reset hot-plugged devices
Device models rely on the core invoking their reset handlers after init.
We do this in the cold-plug case, but so far we miss this step after
hot-plug.
Create cscope symbols for assembly files in addition to .c/.h files.
Create cscope database with full path instead of relative path so cscope
can be used with CSCOPE_DB in any directory.
The unplug protocol is necessary to support PV drivers in the guest: the
drivers expect to be able to "unplug" emulated disks and nics before
initializing the Xen PV interfaces.
It is responsibility of the guest to make sure that the unplug is done
before the emulated devices or the PV interface start to be used.
We use pci_for_each_device to walk the PCI bus, identify the devices and
disks that we want to disable and dynamically unplug them.
Changes in v2:
- use PCI_CLASS constants;
- replace pci_unplug_device with qdev_unplug;
- do not import hw/ide/internal.h in xen_platform.c;
Changes in v3:
- introduce piix3-ide-xen, that support hot-unplug;
- move the unplug code to hw/ide/piix.c;
- just call qdev_unplug from xen_platform.c to unplug the IDE disks;
Anthony PERARD [Wed, 20 Jul 2011 08:17:43 +0000 (08:17 +0000)]
xen: Fix the memory registration to reflect of what is done by Xen.
A Xen guest memory is allocated by libxc. But this memory is not
allocated continuously, instead, it leaves the VGA IO memory space not
allocated, same for the MMIO space (at HVM_BELOW_4G_MMIO_START of size
HVM_BELOW_4G_MMIO_LENGTH).
So to reflect that, we do not register the physical memory for this two
holes. But we still keep only one RAMBlock for the all RAM as it is more
easier than have two separate blocks (1 above 4G). Also this prevent QEMU
from use the MMIO space for a ROM.
Alexander Graf [Sun, 17 Jul 2011 05:30:29 +0000 (07:30 +0200)]
xen: make xen_enabled even more clever
When using xen_enabled() we're currently only checking if xen is enabled
at all during the build. But what if you want to build multiple targets
out of which only one can potentially run xen code?
That means that for generic code we'll still have to fall back to the
variable and potentially slow the code down, but it's not as important as
that is mostly xen device emulation which is not touched for non-xen targets.
The target specific code however can with this patch see that it's unable to
ever execute xen code. We can thus always return 0 on xen_enabled(), giving
gcc enough hints to evict the mapcache code from the target memory management
code.
Anthony PERARD [Fri, 15 Jul 2011 04:32:53 +0000 (04:32 +0000)]
exec.c: Use ram_addr_t in cpu_physical_memory_rw(...).
As the variable pd and addr1 inside the function cpu_physical_memory_rw
are mean to handle a RAM address, they should be of the ram_addr_t type
instead of unsigned long.
Anthony PERARD [Fri, 15 Jul 2011 00:33:42 +0000 (00:33 +0000)]
xen: introduce xen_change_state_handler
Remove the call to xenstore_record_dm_state from xen_main_loop_prepare
that is HVM specific.
Add a new vm_change_state_handler shared between xen_pv and xen_hvm
machines to record the VM state to xenstore.
Blue Swirl [Sat, 23 Jul 2011 21:21:14 +0000 (21:21 +0000)]
simpletrace: suppress a warning from unused variable
Avoid this warning:
CC simpletrace.o
/src/qemu/simpletrace.c: In function 'writeout_thread':
/src/qemu/simpletrace.c:122:12: error: variable 'unused' set but not used [-Werror=unused-but-set-variable]
by adding GCC attribute unused to the variable.
Blue Swirl [Sat, 23 Jul 2011 20:04:29 +0000 (20:04 +0000)]
Wrap recv to avoid warnings
Avoid warnings like these by wrapping recv():
CC slirp/ip_icmp.o
/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':
/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]
/usr/local/lib/gcc/i686-mingw32msvc/4.6.0/../../../../i686-mingw32msvc/include/winsock2.h:547:32: note: expected 'char *' but argument is of type 'struct icmp *'