sdk/emulator/qemu.git
13 years agoMerge branch 'master' of git://git.qemu.org/qemu
malc [Tue, 1 Nov 2011 22:16:34 +0000 (02:16 +0400)]
Merge branch 'master' of git://git.qemu.org/qemu

13 years agoMerge branch 'master' of git://git.qemu.org/qemu
malc [Tue, 1 Nov 2011 22:14:19 +0000 (02:14 +0400)]
Merge branch 'master' of git://git.qemu.org/qemu

13 years agotcg: Fix whitespace in tcg-op.h.
Richard Henderson [Tue, 1 Nov 2011 22:06:43 +0000 (15:06 -0700)]
tcg: Fix whitespace in tcg-op.h.

Removing the only tabs in the file.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: malc <av1474@comtv.ru>
13 years agotcg: Fix regression in tcg_gen_deposit_i64.
Richard Henderson [Tue, 1 Nov 2011 22:06:42 +0000 (15:06 -0700)]
tcg: Fix regression in tcg_gen_deposit_i64.

The error being caused by the failure to copy the other half of
the input to the output after having narrowed the deposit operation.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: malc <av1474@comtv.ru>
13 years agopcnet: Add link state support
Jan Kiszka [Fri, 7 Oct 2011 10:27:25 +0000 (12:27 +0200)]
pcnet: Add link state support

Update lnkst on link state changes so that guests can obtain this
information via reading back the LED output pin. Works for Linux but
not for guests that depend on the missing PHY.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agopcnet-pci: Fix PIO word access to PROM
Jan Kiszka [Mon, 26 Sep 2011 17:01:45 +0000 (19:01 +0200)]
pcnet-pci: Fix PIO word access to PROM

Implement the various IO access widths according to the spec. This
specifically unbreaks word and dword access to the PROM area that is
mapped into IO space. It also drops redundant upper limit checks and
spurious "return void".

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agopcnet: Move BCR defines to header
Jan Kiszka [Mon, 26 Sep 2011 17:01:44 +0000 (19:01 +0200)]
pcnet: Move BCR defines to header

This moves BCR defines to the common header and immediately makes use of
them to add BCR_APROMWE, replacing the open-coded write check in
pcnet_aprom_writeb.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoSort the help info shown in monitor at runtime
Wayne Xia [Wed, 12 Oct 2011 03:32:41 +0000 (11:32 +0800)]
Sort the help info shown in monitor at runtime

This patch would try sort the command list in monitor at runtime. As a result,
command help and help info would show a more friendly sorted command list.
For eg:
(qemu)help
acl_add
acl_policy
acl_remove
acl_reset
acl_show
balloon
block_passwd
...
the command list is sorted.

v3: using qsort function to sort the command list.

Tested-by: Wenyi Gao <wenyi@linux.vnet.ibm.com>
Signed-off-by: Wayne Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoevent_notifier: move to top-level directory
Avi Kivity [Tue, 27 Sep 2011 14:26:23 +0000 (17:26 +0300)]
event_notifier: move to top-level directory

Has no business in hw/.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMove filedescriptor parsing code from net.c into qemu_parse_fd()
Stefan Berger [Wed, 28 Sep 2011 10:41:32 +0000 (06:41 -0400)]
Move filedescriptor parsing code from net.c into qemu_parse_fd()

Move the parsing of a filedescriptor into a common function
qemu_parse_fd() so others can use it as well. Have net.c call this
function.

v2:
 - moving qemu_parse_fd into cutils.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoconfigure: Suppress messages from pkg_config probe for check
Peter Maydell [Tue, 1 Nov 2011 18:32:55 +0000 (18:32 +0000)]
configure: Suppress messages from pkg_config probe for check

Suppress confusing messages from pkg_config when probing for
'check' by sending them to /dev/null as we do with other
similar probes.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agovirtio: Add PCI memory BAR in addition to PIO BAR
David Gibson [Fri, 30 Sep 2011 05:26:16 +0000 (15:26 +1000)]
virtio: Add PCI memory BAR in addition to PIO BAR

Currently, virtio devices are usually presented to the guest as an
emulated PCI device, virtio_pci.  Although the actual IO operations
are done through system memory, the configuration of the virtio device
is done through the one PCI IO space BAR that virtio_pci presents.

But PCI IO space (aka PIO) is deprecated for modern PCI devices, and
on some systems with many PCI domains accessing PIO space can be
problematic.  For example on the existing PowerVM implementation of
the PAPR spec, PCI PIO access is not supported at all.  We're hoping
that our KVM implementation will support PCI PIO (once we support PCI
at all), but it will probably have some irritating limitations.

This patch, therefore, extends the virtio_pci device to have a PCI
memory space (MMIO) BAR as well as the IO BAR.  The MMIO BAR contains
exactly the same registers, in exactly the same layout as the existing
PIO BAR.

Because the PIO BAR is still present, existing guest drivers should
still work fine.  With this change in place, future guest drivers can
check for an MMIO BAR and use that if present (falling back to PIO
when possible to support older qemu versions).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agousb-uhci: Use PCI DMA stub functions
David Gibson [Mon, 31 Oct 2011 06:06:58 +0000 (17:06 +1100)]
usb-uhci: Use PCI DMA stub functions

This updates the usb-uhci device emulation to use the explicit PCI DMA
wrapper to initialize its scatter/gathjer structure.  This means this
driver should not need further changes when the sglist interface is
extended to support IOMMUs.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agousb-ehci: Use PCI DMA stub functions
David Gibson [Mon, 31 Oct 2011 06:06:57 +0000 (17:06 +1100)]
usb-ehci: Use PCI DMA stub functions

This updates the usb-ehci device emulation to use the explicit PCI DMA
wrapper to initialize its scatter/gathjer structure.  This means this
driver should not need further changes when the sglist interface is
extended to support IOMMUs.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoPCI IDE: Use PCI DMA stub functions
David Gibson [Mon, 31 Oct 2011 06:06:56 +0000 (17:06 +1100)]
PCI IDE: Use PCI DMA stub functions

This updates the PCI IDE device emulation to use the explicit PCI DMA
wrapper to initialize its scatter/gathjer structure.  This means this
driver should not need further changes when the sglist interface is
extended to support IOMMUs.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agointel-hda: Use PCI DMA stub functions
David Gibson [Mon, 31 Oct 2011 06:06:55 +0000 (17:06 +1100)]
intel-hda: Use PCI DMA stub functions

This updates the intel-hda device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agopcnet-pci: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:54 +0000 (17:06 +1100)]
pcnet-pci: Use PCI DMA stub functions

This updates the pcnet-pci device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agolsi53c895a: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:53 +0000 (17:06 +1100)]
lsi53c895a: Use PCI DMA stub functions

This updates the lsi53c895a device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoe1000: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:52 +0000 (17:06 +1100)]
e1000: Use PCI DMA stub functions

This updates the e1000 device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoes1370: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:51 +0000 (17:06 +1100)]
es1370: Use PCI DMA stub functions

This updates the es1370 device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoac97: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:50 +0000 (17:06 +1100)]
ac97: Use PCI DMA stub functions

This updates the ac97 device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoeepro100: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:49 +0000 (17:06 +1100)]
eepro100: Use PCI DMA stub functions

This updates the eepro100 device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agortl8139: Use PCI DMA stub functions
Eduard - Gabriel Munteanu [Mon, 31 Oct 2011 06:06:48 +0000 (17:06 +1100)]
rtl8139: Use PCI DMA stub functions

This updates the rtl8139 device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoAdd stub functions for PCI device models to do PCI DMA
David Gibson [Mon, 31 Oct 2011 06:06:47 +0000 (17:06 +1100)]
Add stub functions for PCI device models to do PCI DMA

This patch adds functions to pci.[ch] to perform PCI DMA operations.
At present, these are just stubs which perform directly cpu physical
memory accesses.  Stubs are included which are analogous to
cpu_physical_memory_{read,write}(), the stX_phys() and ldX_phys()
functions and cpu_physical_memory_{map,unmap}().

In addition, a wrapper around qemu_sglist_init() is provided, which
also takes a PCIDevice *.  It's assumed that _init() is the only
sglist function which will need wrapping, the idea being that once we
have IOMMU support whatever IOMMU context handle the wrapper derives
from the PCI device will be stored within the sglist structure for
later use.

Using these stubs, however, distinguishes PCI device DMA transactions from
other accesses to physical memory, which will allow PCI IOMMU support to
be added in one place, rather than updating every PCI driver at that time.

That is, it allows us to update individual PCI drivers to support an IOMMU
without having yet determined the details of how the IOMMU emulation will
operate.  This will let us remove the most bitrot-sensitive part of an
IOMMU patch in advance.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoUse dma_addr_t type for scatter/gather code
David Gibson [Mon, 31 Oct 2011 06:06:46 +0000 (17:06 +1100)]
Use dma_addr_t type for scatter/gather code

This patch uses the newly created dma_addr_t type throughout the
scatter/gather handling code in dma-helpers.c whenever we need to
represent a dma bus address.  This makes a better distinction as to
what is a bus address and what is a cpu physical address.  Since we
don't support IOMMUs yet, they can't be very different for now, but
that will change in future, and this preliminary helps clarify what's
going on.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoDefine DMA address and direction types
David Gibson [Mon, 31 Oct 2011 06:06:45 +0000 (17:06 +1100)]
Define DMA address and direction types

As a preliminary to adding more extensive DMA and IOMMU infrastructure
support into qemu, this patch defines a dma_addr_t for storing DMA bus
addresses and a DMADirection enum which describes whether a DMA is
from an external device to main memory or from main memory to an
external device.

For now dma_addr_t is just defined to be target_phys_addr_t, but in
future, we can change this to support machines where we have bus
addresses which don't necessarily have the same format as CPU physical
addresses.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agops2: migrate ledstate
Christophe Fergeau [Mon, 17 Oct 2011 11:37:34 +0000 (13:37 +0200)]
ps2: migrate ledstate

Make the ps2 device track its ledstate so that we can migrate it.
Otherwise it gets lost across migration, and spice-server gets
confused about the actual keyboard state and sends bogus
caps/scroll/num key events. This fixes RH bug #729294

We only need to migrate the state when it is different of the default
one (0).

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoui/vnc: Fix use of free() instead of g_free()
Stefan Weil [Fri, 7 Oct 2011 19:15:20 +0000 (21:15 +0200)]
ui/vnc: Fix use of free() instead of g_free()

Please note that mechlist still uses malloc / strdup / free.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agocheckpatch: remove rule on non-indented labels
Paolo Bonzini [Fri, 7 Oct 2011 13:59:01 +0000 (15:59 +0200)]
checkpatch: remove rule on non-indented labels

There are 508 non-indented (non-default) labels, and 511 that are
indented.  So the rule is debatable at least.  Actually, in the
common case of labels at the outermost scope, there is really just
one place where to put the label, so the rule is just wrong IMHO.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agosavevm: qemu_fille_buffer() used to return one error for reads of size 0.
Juan Quintela [Tue, 25 Oct 2011 17:18:58 +0000 (19:18 +0200)]
savevm: qemu_fille_buffer() used to return one error for reads of size 0.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agokvm_init didn't set return value after create vm failed
Xu He Jie [Thu, 27 Oct 2011 02:15:13 +0000 (10:15 +0800)]
kvm_init didn't set return value after create vm failed

And kvm_ioctl(s, KVM_CREATE_VM, 0)'s return value can be < -1,
so change the check of vmfd at label 'err'.

Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agospapr: fix build
Anthony Liguori [Tue, 1 Nov 2011 21:49:17 +0000 (16:49 -0500)]
spapr: fix build

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoRevert "PPC: Fail configure when libfdt is not available"
Blue Swirl [Tue, 1 Nov 2011 20:59:32 +0000 (20:59 +0000)]
Revert "PPC: Fail configure when libfdt is not available"

This reverts commit f90a9d02401eeeec18a122b61ccccb91244f321c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoMerge branch 'ppc-next' of git://repo.or.cz/qemu/agraf
Blue Swirl [Tue, 1 Nov 2011 20:57:01 +0000 (20:57 +0000)]
Merge branch 'ppc-next' of git://repo.or.cz/qemu/agraf

* 'ppc-next' of git://repo.or.cz/qemu/agraf: (24 commits)
  pseries: Add partial support for PCI
  ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate
  pseries: Allow writes to KVM accelerated TCE table
  KVM: PPC: Override host vmx/vsx/dfp only when information known
  ppc: Fix up usermode only builds
  pseries: Correct vmx/dfp handling in both KVM and TCG cases
  PPC: Fail configure when libfdt is not available
  ppc: Avoid decrementer related kvm exits
  PPC: Disable non-440 CPUs for ppcemb target
  PPC: Bump qemu-system-ppc to 64-bit physical address space
  pseries: Under kvm use guest cpu = host cpu by default
  ppc: Add cpu defs for POWER7 revisions 2.1 and 2.3
  ppc: First cut implementation of -cpu host
  ppc: Remove broken partial PVR matching
  pseries: Update SLOF firmware image
  pseries: Add device tree properties for VMX/VSX and DFP under kvm
  ppc: Generalize the kvmppc_get_clockfreq() function
  Set an invalid-bits mask for each SPE instructions
  pseries: Update SLOF firmware image
  pseries: Use Book3S-HV TCE acceleration capabilities
  ...

13 years agoMerge remote-tracking branch 'kraxel/usb.29' into staging
Anthony Liguori [Tue, 1 Nov 2011 18:09:31 +0000 (13:09 -0500)]
Merge remote-tracking branch 'kraxel/usb.29' into staging

13 years agoMerge remote-tracking branch 'stefanha/tracing' into staging
Anthony Liguori [Tue, 1 Nov 2011 18:08:33 +0000 (13:08 -0500)]
Merge remote-tracking branch 'stefanha/tracing' into staging

13 years agoMerge remote-tracking branch 'spice/spice.v46' into staging
Anthony Liguori [Tue, 1 Nov 2011 18:06:46 +0000 (13:06 -0500)]
Merge remote-tracking branch 'spice/spice.v46' into staging

13 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Tue, 1 Nov 2011 18:06:17 +0000 (13:06 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

13 years agoopencores_eth: fix RX path: FCS, padding and TL
Max Filippov [Thu, 27 Oct 2011 22:10:27 +0000 (02:10 +0400)]
opencores_eth: fix RX path: FCS, padding and TL

OpenCores 10/100 Mbps Ethernet MAC specification doesn't clearly state
whether FCS is counted in the RX frame length or not. Looks like it is.
Append zero FCS to the received frames.

Get rid of big static buffer for RX frame padding, optimize it for the
most common MINFL value range.

Set RXD_TL for the long frames only when HUGEN bit is set.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agomigration: flush migration data to disk.
Gerd Hoffmann [Thu, 27 Oct 2011 07:12:04 +0000 (09:12 +0200)]
migration: flush migration data to disk.

This patch increases robustness when migrating to a file with
two little changes:

 (1) Before closing the migration file handle checks if it happens to be
     a regular file and if so it issues a fsync.  This way the data is
     flushed to disk before qemu sends the migration completed event.
 (2) It adds error checking.  In case either fsync or close syscall
     fails pass up the error (and fail migration).

[ v2: return -errno instead of -1 ]

Cc: Juan Quintela <quintela@redhat.com>
Cc: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoadd test-coroutine to checks
Gerd Hoffmann [Thu, 1 Sep 2011 15:42:19 +0000 (17:42 +0200)]
add test-coroutine to checks

There is a "test-coroutine" which isn't in the list.
Add it so "make check" runs it too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoadd "make check" target
Gerd Hoffmann [Thu, 1 Sep 2011 15:42:18 +0000 (17:42 +0200)]
add "make check" target

Add some Makefile glue so we have a simple "make check"
to run the unit tests.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agomove checks to separate variable
Gerd Hoffmann [Thu, 1 Sep 2011 15:42:17 +0000 (17:42 +0200)]
move checks to separate variable

Create a new CHECKS variable.  Put the checks there instead
of adding them to the TOOLS variable.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoProbe for libcheck by default.
Gerd Hoffmann [Thu, 1 Sep 2011 15:42:16 +0000 (17:42 +0200)]
Probe for libcheck by default.

Probe for libcheck and build checks (if found) by default.
Can be explicitly disabled using --disable-check-utests.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoia64-dis.c: Undefine ABS to avoid clash with glib
Peter Maydell [Sat, 29 Oct 2011 11:58:26 +0000 (12:58 +0100)]
ia64-dis.c: Undefine ABS to avoid clash with glib

Undefine ABS to avoid a clash with the macro that glib.h
helpfully defines for us (and a resulting build failure
on ia64 hosts).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoFix segfault on migration completion
Luiz Capitulino [Fri, 28 Oct 2011 16:59:52 +0000 (14:59 -0200)]
Fix segfault on migration completion

A simple migration reproduces it:

1. Start the source VM with:

   # qemu [...] -S

2. Start the destination VM with:

   # qemu <source VM cmd-line> -incoming tcp:0:4444

3. In the source VM:

   (qemu) migrate -d tcp:0:4444

4. The source VM will segfault as soon as migration completes (might not
   happen in the first try)

What is happening here is that qemu_file_put_notify() can end up closing
's->file' (in which case it's also set to NULL). The call stack is rather
complex, but Eduardo helped tracking it to:

select loop -> migrate_fd_put_notify() -> qemu_file_put_notify() ->
buffered_put_buffer() -> migrate_fd_put_ready() ->
migrate_fd_completed() -> migrate_fd_cleanup().

To be honest, it's not completely clear to me in which cases 's->file'
is not closed (on error maybe)? But I doubt this fix will make anything
worse.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoAdd qapi related generated files to .gitignore
David Gibson [Fri, 28 Oct 2011 04:26:18 +0000 (15:26 +1100)]
Add qapi related generated files to .gitignore

.gitignore already lists the qapi-generated subdirectory which includes a
number of files generated during build.  However, there are some additional
files generated by the qapi build which go in the top level directory.

This patch adds them to .gitignore, removing the irritating noise from
diffs and the like.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqemu-barrier: Fix build failure on PowerPC Mac OS X
Eric Sunshine [Tue, 1 Nov 2011 09:39:49 +0000 (05:39 -0400)]
qemu-barrier: Fix build failure on PowerPC Mac OS X

qemu-barrier.h tests if macro __powerpc__ is defined, however, the
preprocessor on PowerPC Mac OS X defines only __POWERPC__, not
__powerpc__.  Resolve by testing instead for qemu-provided _ARCH_PPC.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agofw_cfg: Use g_file_get_contents instead of multiple fread() calls
Pavel Borzenkov [Mon, 24 Oct 2011 11:31:30 +0000 (07:31 -0400)]
fw_cfg: Use g_file_get_contents instead of multiple fread() calls

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoSimplify cpu_exec_all to tcg_exec_all
Jan Kiszka [Mon, 26 Sep 2011 07:40:39 +0000 (09:40 +0200)]
Simplify cpu_exec_all to tcg_exec_all

After the removal of the non-threaded mode cpu_exec_all is now only used
by TCG. Refactor it accordingly, also dropping its unused return value.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMake cpu_single_env thread-local
Paolo Bonzini [Fri, 28 Oct 2011 09:52:42 +0000 (10:52 +0100)]
Make cpu_single_env thread-local

Make cpu_single_env thread-local. This fixes a regression
in handling of multi-threaded programs in linux-user mode
(bug 823902).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[Peter Maydell: rename tls_cpu_single_env to cpu_single_env]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agodarwin-user/main.c: Drop unused cpu_single_env definition
Paolo Bonzini [Fri, 28 Oct 2011 09:52:41 +0000 (10:52 +0100)]
darwin-user/main.c: Drop unused cpu_single_env definition

Drop the cpu_single_env definition as it is unused.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqemu-tls.h: Add abstraction layer for TLS variables
Peter Maydell [Fri, 28 Oct 2011 09:52:40 +0000 (10:52 +0100)]
qemu-tls.h: Add abstraction layer for TLS variables

Add an abstraction layer for defining and using thread-local
variables. For the moment this is implemented only for Linux,
which means they can only be used in restricted circumstances.
The abstraction layer allows us to add POSIX and Win32 support
later.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoError check find_ram_offset
Alex Williamson [Mon, 31 Oct 2011 14:54:09 +0000 (08:54 -0600)]
Error check find_ram_offset

Spotted via code review, we initialize offset to 0 to avoid a
compiler warning, but in the unlikely case that offset is
never set to something else, we should abort instead of return
a value that will almost certainly cause problems.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agousb-host: fix host close
Gerd Hoffmann [Fri, 28 Oct 2011 14:13:50 +0000 (16:13 +0200)]
usb-host: fix host close

The whole usb_host_close() function is skipped in case the device is not
in attached state.  This is wrong though, only then usb_device_detach()
must be skipped, all other cleanup (especially device reset and closing
the file handle) still needs to be done.  There are code paths where
usb_host_close() is called with the device in detached state already.

This fixes usb-host devices not being released and returned to the host
after removing them with device_del.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agousb: change VID/PID for usb-hub and usb-msd to prevent conflict
Roy Tam [Thu, 15 Sep 2011 03:25:47 +0000 (11:25 +0800)]
usb: change VID/PID for usb-hub and usb-msd to prevent conflict

Some USB drivers, for example USBASPI.SYS, will skip different type of
device which has same VID/PID. The following patch helps preventing
usb-msd being skipped by the driver.

Signed-off-by: Roy Tam <roytam@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoSupport running QEMU on Valgrind
Stefan Weil [Mon, 31 Oct 2011 20:29:46 +0000 (21:29 +0100)]
Support running QEMU on Valgrind

Valgrind is a tool which can automatically detect many kinds of bugs.

Running QEMU on Valgrind with x86_64 hosts was not possible because
Valgrind aborts when memalign is called with an alignment larger than
1 MiB. QEMU normally uses 2 MiB on Linux x86_64.

Now the alignment is reduced to the page size when QEMU is running on
Valgrind.

v2:
Instead of using the macro RUNNING_ON_VALGRIND from valgrind.h,
the patch now uses a hack from libvirt which tests for the pre-loaded
vgpreload_*.so shared libraries. This avoids the need for valgrind.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoMAINTAINERS: Add PReP maintainer
Andreas Färber [Mon, 31 Oct 2011 23:03:07 +0000 (00:03 +0100)]
MAINTAINERS: Add PReP maintainer

Officially take on maintainership for PReP and upgrade to Odd Fixes.

Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Cc: Alexander Graf <agraf@suse.de>
Cc: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agotrace: Add wildcard trace event support
Mark Wu [Mon, 31 Oct 2011 03:29:04 +0000 (11:29 +0800)]
trace: Add wildcard trace event support

A basic wildcard matching is supported in both the monitor command
"trace-event" and the events list file. That means you can enable/disable
the events having a common prefix in a batch. For example, virtio-blk trace
events could be enabled using:
    trace-event virtio_blk_* on

Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agousb-hub: wakeup on attach
Gerd Hoffmann [Fri, 14 Oct 2011 09:36:43 +0000 (11:36 +0200)]
usb-hub: wakeup on attach

When attaching a new device we must send a wakeup request to the root
hub, otherwise the guest will not notice the new device in case the
usb hub is suspended.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: create slots on post_load in vga state
Alon Levy [Tue, 25 Oct 2011 13:39:50 +0000 (15:39 +0200)]
qxl: create slots on post_load in vga state

RHBZ 740547

If we migrate when the device is in vga state the guest
still believes the slots are created, and will cause operations
that reference the slots, causing a "panic: virtual address out of range"
on the first of them. Easy to see by migrating in vga mode with
a driver loaded, for instance windows cmd window in full screen mode,
and then exiting vga mode back to native mode will cause said panic.

Fixed by doing the slot recreation in post_load for vga mode as well.
Note that compat does not require any changes because it creates it's
only slot by a side effect of QXL_IO_SET_MODE.

Signed-off-by: Alon Levy <alevy@redhat.com>
13 years agoqxl: make sure we continue to run with a shared buffer
Gerd Hoffmann [Fri, 21 Oct 2011 19:53:54 +0000 (21:53 +0200)]
qxl: make sure we continue to run with a shared buffer

The qxl renderer works only with a shared displaysurface.  So better
make sure we actually have one and restore it when needed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoqxl: stride fixup
Gerd Hoffmann [Fri, 21 Oct 2011 13:59:07 +0000 (15:59 +0200)]
qxl: stride fixup

spice uses negative stride value to signal the bitmap is upside down.
The qxl renderer (used for scl, vnc and screenshots) wants a positive
value because it is easier to work with.  The positive value is then
stored in the very same variable, which has the drawback that the
upside-down test works only once.  Fix by using two variables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
13 years agoacl: Fix use after free in qemu_acl_reset()
Markus Armbruster [Fri, 28 Oct 2011 15:07:02 +0000 (17:07 +0200)]
acl: Fix use after free in qemu_acl_reset()

Reproducer:

    $ MALLOC_PERTURB_=234 qemu-system-x86_64 -vnc :0,acl,sasl [...]
    QEMU 0.15.50 monitor - type 'help' for more information
    (qemu) acl_add vnc.username fred allow
    acl: added rule at position 1
    (qemu) acl_reset vnc.username
    Segmentation fault (core dumped)

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqapi: fix typos in documentation JSON examples
Stefan Hajnoczi [Fri, 28 Oct 2011 14:58:26 +0000 (15:58 +0100)]
qapi: fix typos in documentation JSON examples

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agosysbus: Supply missing va_end()
Markus Armbruster [Fri, 28 Oct 2011 08:52:25 +0000 (10:52 +0200)]
sysbus: Supply missing va_end()

C99 7.15.1: Each invocation of the va_start and va_copy macros shall
be matched by a corresponding invocation of the va_end macro in the
same function.

Spotted by Coverity.  Harmless on the (common) systems where va_end()
does nothing.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agonet: tap-linux: Fix unhelpful error message
Luiz Capitulino [Fri, 14 Oct 2011 18:05:10 +0000 (15:05 -0300)]
net: tap-linux: Fix unhelpful error message

I'm getting:

    could not configure /dev/net/tun (tap%d): Operation not permitted

When the ioctl() fails, ifr.ifr_name will most likely not be overwritten.
So we better only use it when ifname contains a string.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoMerge remote-tracking branch 'riku/linux-user-for-upstream' into staging
Anthony Liguori [Mon, 31 Oct 2011 20:05:40 +0000 (15:05 -0500)]
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging

13 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:09:00 +0000 (11:09 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

Conflicts:
block/vmdk.c

13 years agoMerge remote-tracking branch 'aneesh/for-upstream-7' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:06:02 +0000 (11:06 -0500)]
Merge remote-tracking branch 'aneesh/for-upstream-7' into staging

13 years agoMerge remote-tracking branch 'qmp/queue/qmp' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:02:29 +0000 (11:02 -0500)]
Merge remote-tracking branch 'qmp/queue/qmp' into staging

Conflicts:
ui/spice-core.c

13 years agoMerge remote-tracking branch 'qemu-kvm-tmp/uq/master' into staging
Anthony Liguori [Mon, 31 Oct 2011 16:00:27 +0000 (11:00 -0500)]
Merge remote-tracking branch 'qemu-kvm-tmp/uq/master' into staging

13 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Mon, 31 Oct 2011 15:23:15 +0000 (10:23 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

13 years agoMerge remote-tracking branch 'alon/pull-libcacard-assert' into staging
Anthony Liguori [Mon, 31 Oct 2011 15:14:06 +0000 (10:14 -0500)]
Merge remote-tracking branch 'alon/pull-libcacard-assert' into staging

13 years agoMerge remote-tracking branch 'spice/spice.v45' into staging
Anthony Liguori [Mon, 31 Oct 2011 15:12:14 +0000 (10:12 -0500)]
Merge remote-tracking branch 'spice/spice.v45' into staging

13 years agohw/9pfs: Replace rwlocks with RCU variants of interfaces.
Harsh Prateek Bora [Thu, 13 Oct 2011 20:35:02 +0000 (02:05 +0530)]
hw/9pfs: Replace rwlocks with RCU variants of interfaces.

Use QLIST_INSERT_HEAD_RCU and rcu_read_lock/unlock instead of rwlocks.
Use v9fs_synth_mutex as a write-only mutex to handle concurrent writers.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agoqemu-queue: Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers.
Harsh Prateek Bora [Tue, 25 Oct 2011 06:40:40 +0000 (12:10 +0530)]
qemu-queue: Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers.

SynthFS needs a QLIST_INSERT_HEAD_RCU to make sure list instructions are not
re-ordered and therefore avoiding a crash. There may be parallel readers which
should be allowed for lock-free access and this variant allows us to get rid
of rwlocks used by readers.

SynthFS is a special case where we dont really need full RCU capabilities as
it doesnt allow list entry deletion but concurrent readers/writers and
instruction re-ordering should not result in a crash.

Also, once the real rcu is available, dummy rcu macro definitions will go away
and the code will still work as expected.

This patchwork is based on inputs from Paolo Bonzini.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agohw/9pfs: Add synthetic file system support using 9p
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:40 +0000 (12:10 +0530)]
hw/9pfs: Add synthetic file system support using 9p

This patch create a synthetic file system with mount tag
v_synth when -virtfs_synth command line option is specified
in qemu. The synthetic file system can be mounted in guest
using 9p using the below command line

mount -t 9p -oversion=9p2000.L,trans=virtio v_synth  <mountpint>

Synthetic file system enabled different qemu subsystem to register
callbacks for read and write events from guest. The subsystem
can create directories and files in the synthetic file system as show
in ex below

    qemu_v9fs_synth_mkdir(NULL, 0777, "test2", &node);
    qemu_v9fs_synth_add_file(node, 0777, "testfile",
                             my_test_read, NULL, NULL);

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agohw/9pfs: Abstract open state of fid to V9fsFidOpenState
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:40 +0000 (12:10 +0530)]
hw/9pfs: Abstract open state of fid to V9fsFidOpenState

To implement synthetic file system in Qemu we may not really
require file descriptor and Dir *. Make generic code use
V9fsFidOpenState instead.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agohw/9pfs: Read-only support for 9p export
M. Mohan Kumar [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
hw/9pfs: Read-only support for 9p export

A new fsdev parameter "readonly" is introduced to control accessing 9p export.
"readonly" can be used to specify the access type. By default "rw" access
is given to 9p export.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agoqemu: Add opt_set_bool functionality
M. Mohan Kumar [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
qemu: Add opt_set_bool functionality

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agoconfigure: Update configure so that open_by_handle_at check returns correct value
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
configure: Update configure so that open_by_handle_at check returns correct value

According to David Gibson for some compiler/libc combinations, open_by_handle_at
test in configure isn't quite right: because the file_handle pointer is never
dereferenced, gcc doesn't complain even if it is undefined. Change the test
as suggested by him.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agohw/9pfs: Fix error handling in local_mknod
Aneesh Kumar K.V [Tue, 25 Oct 2011 06:40:39 +0000 (12:10 +0530)]
hw/9pfs: Fix error handling in local_mknod

Update local_chown to remove unnecessary if loop

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 years agohw/vexpress.c, hw/realview.c: Add PL041 to VExpress, Realview boards
Peter Maydell [Fri, 28 Oct 2011 09:55:38 +0000 (10:55 +0100)]
hw/vexpress.c, hw/realview.c: Add PL041 to VExpress, Realview boards

Instantiate the PL041 audio on the Versatile Express and
Realview board models.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoAdd AACI audio playback support to the ARM Versatile/PB platform
Mathieu Sonet [Fri, 28 Oct 2011 09:55:37 +0000 (10:55 +0100)]
Add AACI audio playback support to the ARM Versatile/PB platform

This driver emulates the ARM AACI interface (PL041) connected to a LM4549 codec.
It enables audio playback for the Versatile/PB platform.

Limitations:
- Supports only a playback on one channel (Versatile/Vexpress)
- Supports only one TX FIFO in compact-mode or non-compact mode.
- Supports playback of 12, 16, 18 and 20 bits samples.
- Record is not supported.
- The PL041 is hardwired to a LM4549 codec.

Versatile/PB test build:
linux-2.6.38.5
buildroot-2010.11
alsa-lib-1.0.22
alsa-utils-1.0.22
mpg123-0.66

Qemu host: Ubuntu 10.04 in Vmware/OS X

Playback tested successfully with speaker-test/aplay/mpg123.

Signed-off-by: Mathieu Sonet <contact@elasticsheep.com>
[Peter Maydell: fixed typo in code clearing SL1RXBUSY/SL2RXBUSY
 bits, as spotted by Andrzej Zaborowski]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agopseries: Add partial support for PCI
David Gibson [Sun, 30 Oct 2011 17:16:46 +0000 (17:16 +0000)]
pseries: Add partial support for PCI

This patch adds a PCI bus to the pseries machine.  This instantiates
the qemu generic PCI bus code, advertises a PCI host bridge in the
guest's device tree and implements the RTAS methods specified by PAPR
to access PCI config space.  It also sets up the memory regions we
need to provide windows into the PCI memory and IO space, and
advertises those to the guest.

However, because qemu can't yet emulate an IOMMU, which is mandatory on
pseries, PCI devices which use DMA (i.e. most of them) will not work with
this code alone.  Still, this is enough to support the virtio_pci device
(which probably _should_ use emulated PCI DMA, but is specced to use
direct hypervisor access to guest physical memory instead).

[agraf] remove typedef which could cause compile errors

Signed-off-by: Alexey Kardashevskiy <aik@au1.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate
David Gibson [Sun, 30 Oct 2011 15:51:24 +0000 (15:51 +0000)]
ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate

The CPU state contains two bitmaps, initialized from the CPU spec
which describes which instructions are implemented on the CPU.  A
couple of bits are defined which cover instructions (VSX and DFP)
which are not currently implemented in TCG.  So far, these are only
used to handle the case of -cpu host because a KVM guest can use
the instructions when the host CPU supports them.

However, it's a mild layering violation to simply not include those
bits in the CPU descriptions for those CPUs that do support them,
just because we can't handle them in TCG.  This patch corrects the
situation, so that the instruction bits _are_ shown correctly in the
cpu spec table, but are masked out from the cpu state in the non-KVM
case.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agopseries: Allow writes to KVM accelerated TCE table
David Gibson [Thu, 27 Oct 2011 15:56:31 +0000 (15:56 +0000)]
pseries: Allow writes to KVM accelerated TCE table

Sufficiently recent kernels include a KVM call to accelerate use of
PAPR TCE tables (IOMMU), which are used by PAPR virtual IO devices.
This involves qemu mapping the TCE table in from a kernel obtained fd,
which currently we do with PROT_READ only.  This is a hangover from
early (never released) versions of this kernel interface which only
permitted read-only mappings and required us to destroy and recreate
the table when we needed to clear it from qemu.

Now, the kernel permits read-write mappings, and we rely on this to
clear the table in spapr_vio_quiesce_one().  However, due to
insufficient testing, I forgot to update the actual mapping of the
table in kvmppc_create_spapr_tce() to add PROT_WRITE to the mmap().

This patch corrects the oversight.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoKVM: PPC: Override host vmx/vsx/dfp only when information known
Alexander Graf [Mon, 24 Oct 2011 18:43:22 +0000 (20:43 +0200)]
KVM: PPC: Override host vmx/vsx/dfp only when information known

The -cpu host feature tries to find out the host capabilities based
on device tree information. However, we don't always have that available
because it's an optional property in dt.

So instead of force unsetting values depending on an unreliable source
of information, let's just try to be clever about it and not override
capabilities when we don't know the device tree pieces.

This fixes altivec with -cpu host on YDL PowerStations.

Reported-by: Nishanth Aravamudan <nacc@us.ibm.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoppc: Fix up usermode only builds
David Gibson [Sun, 23 Oct 2011 17:25:04 +0000 (17:25 +0000)]
ppc: Fix up usermode only builds

The recent usage of MemoryRegion in kvm_ppc.h breaks builds with
CONFIG_USER_ONLY=y.  This patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agopseries: Correct vmx/dfp handling in both KVM and TCG cases
David Gibson [Mon, 17 Oct 2011 18:15:41 +0000 (18:15 +0000)]
pseries: Correct vmx/dfp handling in both KVM and TCG cases

Currently, when KVM is enabled, the pseries machine checks if the host
CPU supports VMX, VSX and/or DFP instructions and advertises
accordingly in the guest device tree.  It does this regardless of what
CPU is selected on the command line.  On the other hand, when in TCG
mode, it never advertises any of these facilities, even basic VMX
(Altivec) which is supported in TCG.

Now that we have a -cpu host option for ppc, it is fairly
straightforward to fix both problems.  This patch changes the -cpu
host code to override the basic cpu spec derived from the PVR with
information queried from the host avout VMX, VSX and DFP capability.
The pseries code then uses the instruction availability advertised in
the cpu state to set the guest device tree correctly for both the KVM
and TCG cases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoPPC: Fail configure when libfdt is not available
Alexander Graf [Tue, 18 Oct 2011 00:10:36 +0000 (02:10 +0200)]
PPC: Fail configure when libfdt is not available

We have several targets in the PPC tree now that basically require libfdt
to function properly, namely the pseries and the e500 targets. This dependency
will rather increase than decrease in the future, so I want to make sure
that people building shiny new 1.0 actually have libfdt installed to get
rid of a few ifdefs in the code.

Warning: This patch will likely make configure fail for people who don't
select their own --target-list, but don't have libfdt development packages
installed. However, we really need this new dependency to move on.

Signed-off-by: Alexander Graf <agraf@suse.de>
---

v1 -> v2:

  - no paranthesis
  - no fdt check for config_pseries
  - add . in error message

13 years agoppc: Avoid decrementer related kvm exits
David Gibson [Sun, 16 Oct 2011 19:26:17 +0000 (19:26 +0000)]
ppc: Avoid decrementer related kvm exits

In __cpu_ppc_store_decr(), we set up a regular timer used to trigger
decrementer interrupts.  This is necessary to implement the decrementer
properly under TCG, but is unnecessary under KVM (true for both Book3S-PR
and Book3S-HV KVM variants), because the kernel handles generating and
delivering decrementer exceptions.

Under kvm, in fact, the timer causes expensive and unnecessary exits from
kvm to qemu.  This patch, therefore, disables setting the timer when kvm
is in use.

Signed-off-by: Anton Blanchard <anton@au1.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoPPC: Disable non-440 CPUs for ppcemb target
Alexander Graf [Tue, 18 Oct 2011 00:00:51 +0000 (02:00 +0200)]
PPC: Disable non-440 CPUs for ppcemb target

The sole reason we have the ppcemb target is to support MMUs that have
less than the usual 4k possible page size. There are very few of these
chips and I don't want to add additional QA and testing burden to everyone
to ensure that code still works when TARGET_PAGE_SIZE is not 4k.

So this patch disables all CPUs except for MMU_BOOKE capable ones from
the ppcemb target.

Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoPPC: Bump qemu-system-ppc to 64-bit physical address space
Alexander Graf [Mon, 17 Oct 2011 23:46:08 +0000 (01:46 +0200)]
PPC: Bump qemu-system-ppc to 64-bit physical address space

Some 32-bit PPC CPUs can use up to 36 bit of physical address space.
Treat them accordingly in the qemu-system-ppc binary type.

Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agopseries: Under kvm use guest cpu = host cpu by default
David Gibson [Wed, 12 Oct 2011 22:40:34 +0000 (22:40 +0000)]
pseries: Under kvm use guest cpu = host cpu by default

Now that we've implemented -cpu host for ppc, this patch updates the
pseries machine to use the host cpu as the guest cpu by default when
running under KVM.  This is important because under KVM Book3S-HV the guest
cpu _cannot_ be of a different type to the host cpu (at the moment
KVM Book3S-HV will silently virtualize the host cpu instead of whatever was
requested, but in future it is likely to simply refuse to run the VM if
a cpu model other than the host's is requested).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoppc: Add cpu defs for POWER7 revisions 2.1 and 2.3
David Gibson [Wed, 12 Oct 2011 22:40:33 +0000 (22:40 +0000)]
ppc: Add cpu defs for POWER7 revisions 2.1 and 2.3

This patch adds cpu specs to the table for POWER7 revisions 2.1 and 2.3.
This allows -cpu host to be used on these host cpus.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoppc: First cut implementation of -cpu host
David Gibson [Wed, 12 Oct 2011 22:40:32 +0000 (22:40 +0000)]
ppc: First cut implementation of -cpu host

For convenience with kvm, x86 allows the user to specify -cpu host on the
qemu command line, which means make the guest cpu the same as the host
cpu.  This patch implements the same option for ppc targets.

For now, this just read the host PVR (Processor Version Register) and
selects one of our existing CPU specs based on it.  This means that the
option will not work if the host cpu is not supported by TCG, even if that
wouldn't matter for use under kvm.

In future, we can extend this in future to override parts of the cpu spec
based on information obtained from the host (via /proc/cpuinfo, the host
device tree, or explicit KVM calls).  That will let us handle cases where
the real kvm-virtualized CPU doesn't behave exactly like the TCG-emulated
CPU.  With appropriate annotation of the CPU specs we'll also then be able
to use host cpus under kvm even when there isn't a matching full TCG model.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agoppc: Remove broken partial PVR matching
David Gibson [Wed, 12 Oct 2011 22:40:31 +0000 (22:40 +0000)]
ppc: Remove broken partial PVR matching

The ppc target contains a ppc_find_by_pvr() function, which looks up a
CPU spec based on a PVR (that is, based on the value in the target cpu's
Processor Version Register).  PVR values contain information on both the
cpu model (upper 16 bits, usually) and on the precise revision (low 16
bits, usually).

ppc_find_by_pvr, as well as making exact PVR matches, attempts to find
"close" PVR matches, when we don't have a CPU spec for the exact revision
specified.  This sounds like a good idea, execpt that the current logic
is completely nonsensical.

It seems to assume CPU families are subdivided bit by bit in the PVR in a
way they just aren't.  Specifically, it requires a match on all bits of the
specified pvr up to the last non-zero bit.  This has the bizarre effect
that when the low bits are simply a sequential revision number (a common
though not universal pattern), then odd specified revisions must be matched
exactly, whereas even specified revisions will also match the next odd
revision, likewise for powers of 4, 8 and so forth.

To correctly do inexact matching we'd need to re-organize the table of CPU
specs to include a mask showing what PVR range the spec is compatible with
(similar to the cputable code in the Linux kernel).

For now, just remove the bogosity by only permitting exact PVR matches.
That at least makes the matching simple and consistent.  If we need inexact
matching we can add the necessary per-subfamily masks later.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
13 years agopseries: Update SLOF firmware image
David Gibson [Wed, 12 Oct 2011 19:10:30 +0000 (19:10 +0000)]
pseries: Update SLOF firmware image

This patch is a general update to the SLOF firmware image used on the
pseries machine.  This doesn't contain updates for specific features but
contains a number of bugfixes and enhancements in the main SLOF tree from
Thomas Huth.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>