sdk/emulator/qemu.git
12 years agotarget-mips: Add ASE DSP resources access check
Jia Liu [Wed, 24 Oct 2012 14:17:02 +0000 (22:17 +0800)]
target-mips: Add ASE DSP resources access check

Add MIPS ASE DSP resources access check.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-mips: Add ASE DSP internal functions
Jia Liu [Wed, 24 Oct 2012 14:17:01 +0000 (22:17 +0800)]
target-mips: Add ASE DSP internal functions

Add internal functions using by MIPS ASE DSP instructions.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotap-win32: stubs to fix win32 build
Michael S. Tsirkin [Tue, 30 Oct 2012 14:04:50 +0000 (16:04 +0200)]
tap-win32: stubs to fix win32 build

Add missing stubs to win32 to fix link failure.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotests/tcg: fix unused result warnings
Catalin Patulea [Mon, 29 Oct 2012 18:01:07 +0000 (14:01 -0400)]
tests/tcg: fix unused result warnings

With i386-linux-user target on x86_64 host, this does not introduce any new test
failures.

Signed-off-by: Catalin Patulea <catalinp@google.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoconfigure: use -Wwombat to test whether gcc recognizes -Wno-wombat
Peter Maydell [Sat, 27 Oct 2012 21:19:07 +0000 (22:19 +0100)]
configure: use -Wwombat to test whether gcc recognizes -Wno-wombat

gcc will silently accept unrecognized -Wno-wombat warning suppression
options (it only mentions them if it has to print a compiler warning
for some other reason). Since we already run a check for whether gcc
recognizes the warning options we use, we can easily make this use
the positive sense of the option when checking for support for the
suppression option. This doesn't have any effect except that it avoids
gcc emitting extra messages about unrecognized command line options
when it is printing other warning messages.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-sparc: Revert setting cpu_dst to gen_dest_gpr
Richard Henderson [Mon, 29 Oct 2012 04:50:20 +0000 (15:50 +1100)]
target-sparc: Revert setting cpu_dst to gen_dest_gpr

There is some read-after-write error within the OP=2 insns which
prevents setting cpu_dst to the real output register.  Until this
is found and fixed, always write to a temporary first.

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMerge branch 'qspi.2' of git://developer.petalogix.com/public/qemu
Blue Swirl [Tue, 30 Oct 2012 18:35:18 +0000 (18:35 +0000)]
Merge branch 'qspi.2' of git://developer.petalogix.com/public/qemu

* 'qspi.2' of git://developer.petalogix.com/public/qemu:
  xilinx_zynq: added QSPI controller
  xilinx_spips: Generalised to model QSPI
  m25p80: Support for Quad SPI

12 years agoMerge branch 's390-for-upstream' of git://repo.or.cz/qemu/agraf
Aurelien Jarno [Mon, 29 Oct 2012 23:35:43 +0000 (00:35 +0100)]
Merge branch 's390-for-upstream' of git://repo.or.cz/qemu/agraf

* 's390-for-upstream' of git://repo.or.cz/qemu/agraf:
  s390: sclp ascii console support
  s390: sclp signal quiesce support
  s390: sclp event support
  s390: sclp base support
  s390: use sync regs for register transfer
  s390/kvm_stat: correct sys_perf_event_open syscall number
  s390x: fix -initrd in virtio machine

12 years agotcg/mips: use MUL instead of MULT on MIPS32 and above
Aurelien Jarno [Fri, 19 Oct 2012 21:48:13 +0000 (23:48 +0200)]
tcg/mips: use MUL instead of MULT on MIPS32 and above

MIPS32 and later instruction sets have a multiplication instruction
directly operating on GPRs. It only produces a 32-bit result but
it is exactly what is needed by QEMU.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agomemory: fix rendering of a region obscured by another
Avi Kivity [Mon, 29 Oct 2012 16:22:36 +0000 (18:22 +0200)]
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 the
existing range is below the lower address of the new range.

Example (qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta
         -append "console=ttyS0"  -nographic -vga cirrus):

Existing range: 10000000-107fffff
New range:      100a0000-100bffff

Correct behaviour: drop new range
Incorrect behaviour: add new range

Fix by taking this case into account (previously we only considered
equal lower boundaries).

Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'mst/tags/for_anthony' into staging
Anthony Liguori [Mon, 29 Oct 2012 19:31:47 +0000 (14:31 -0500)]
Merge remote-tracking branch 'mst/tags/for_anthony' into staging

virtio,pci infrastructure

This includes infrastructure patches that don't do much by themselves
but should help vfio and q35 make progress.
Also included is rework of virtio-net to use iovec APIs
for vector access - helpful to make it more secure
and in preparation for a new feature that will allow
arbitrary s/g layout for guests.
Also included is a pci bridge bugfix by Avi.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* mst/tags/for_anthony: (25 commits)
  pci: avoid destroying bridge address space windows in a transaction
  virtio-net: enable mrg buf header in tap on linux
  virtio-net: test peer header support at init time
  virtio-net: minor code simplification
  virtio-net: simplify rx code
  virtio-net: switch tx to safe iov functions
  virtio-net: first s/g is always at start of buf
  virtio-net: refactor receive_hdr
  virtio-net: use safe iov operations for rx
  virtio-net: avoid sg copy
  iov: add iov_cpy
  virtio-net: track host/guest header length
  pcie: Convert PCIExpressHost to use the QOM.
  pcie: pass pcie window size to pcie_host_mmcfg_update()
  pci: Add class 0xc05 as 'SMBus'
  pci: introduce pci_swizzle_map_irq_fn() for standardized interrupt pin swizzle
  pci_ids: add intel 82801BA pci-to-pci bridge id
  pci: pci capability must be in PCI space
  pci: make each capability DWORD aligned
  qemu: enable PV EOI for qemu 1.3
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agos390: sclp ascii console support
Heinz Graalfs [Mon, 29 Oct 2012 02:13:25 +0000 (02:13 +0000)]
s390: sclp ascii console support

This code adds console support  by implementing SCLP's ASCII Console
Data event. This is the same console as LPARs ASCII console or z/VMs
sysascii.

The console can be specified manually with something like
-chardev stdio,id=charconsole0 -device sclpconsole,chardev=charconsole0,id=console0

Newer kernels will autodetect that console and prefer that over virtio
console.

When data is received from the character layer it creates a service
interrupt to trigger a Read Event Data command from the guest that will
pick up the received character byte-stream.
When characters are echo'ed by the linux guest a Write Event Data occurs
which is forwarded by the Event Facility to the console that supports
a corresponding mask value.
Console resizing is not supported.
The character layer byte-stream is buffered using a fixed size iov
buffer.

Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390: sclp signal quiesce support
Heinz Graalfs [Mon, 29 Oct 2012 02:13:24 +0000 (02:13 +0000)]
s390: sclp signal quiesce support

This implements the sclp signal quiesce event via the SCLP Event
Facility.
This allows to gracefully shutdown a guest by using system_powerdown
notifiers. It creates a service interrupt that will trigger a
Read Event Data command from the guest. This code will then add an
event that is interpreted by linux guests as ctrl-alt-del.

Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390: sclp event support
Heinz Graalfs [Mon, 29 Oct 2012 02:13:23 +0000 (02:13 +0000)]
s390: sclp event support

Several SCLP features are considered to be events. Those events don't
provide SCLP commands on their own, instead they are all based on
Read Event Data, Write Event Data, Write Event Mask and the service
interrupt. Follow-on patches will provide SCLP's Signal Quiesce (via
system_powerdown) and the ASCII console.
Further down the road the sclp line mode console and configuration
change events (e.g. cpu hotplug) can be implemented.

Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390: sclp base support
Heinz Graalfs [Mon, 29 Oct 2012 02:13:22 +0000 (02:13 +0000)]
s390: sclp base support

This adds a more generic infrastructure for handling Service-Call
requests on s390. Currently we only support a small subset of Read
SCP Info directly in target-s390x. This patch provides the base
infrastructure for supporting more commands and moves Read SCP
Info.
In the future we could add additional commands for hotplug, call
home and event handling.

Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390: use sync regs for register transfer
Christian Borntraeger [Mon, 29 Oct 2012 02:13:21 +0000 (02:13 +0000)]
s390: use sync regs for register transfer

Newer kernels provide the guest registers in kvm_run. Lets use
those if available (i.e. the capability is set). This avoids
ioctls on cpu_synchronize_state making intercepts faster.

In addition, we have now the prefix register, the access registers
the control registers up to date. This helps in certain cases,
e.g. for resolving kernel module addresses with gdb on a guest.

On return, we update the registers according to the level statement,
i.e. we put all registers for KVM_PUT_FULL_STATE and _RESET_STATE.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390/kvm_stat: correct sys_perf_event_open syscall number
Heinz Graalfs [Mon, 29 Oct 2012 02:13:20 +0000 (02:13 +0000)]
s390/kvm_stat: correct sys_perf_event_open syscall number

Correct sys_perf_event_open syscall number for s390 architecture
   - the hardcoded syscall number 298 is for x86 but should
     be different for other architectures.
     In case we figure out via /proc/cpuinfo that we are running
     on s390 the appropriate syscall number is used from map
     syscall_numbers; other architectures can extend this.

Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390x: fix -initrd in virtio machine
Alexander Graf [Wed, 19 Sep 2012 15:24:46 +0000 (17:24 +0200)]
s390x: fix -initrd in virtio machine

When using -initrd in the virtio machine, we need to indicate the initrd
start and size inside the kernel image. These parameters need to be stored
in native endianness.

Signed-off-by: Alexander Graf <agraf@suse.de>
Acked-by: Richard Henderson <rth@twiddle.net>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
12 years agopci: avoid destroying bridge address space windows in a transaction
Avi Kivity [Thu, 25 Oct 2012 10:37:57 +0000 (12:37 +0200)]
pci: avoid destroying bridge address space windows in a transaction

Calling memory_region_destroy() in a transaction is illegal (and aborts),
as until the transaction is committed, the region remains live.

Fix by moving destruction until after the transaction commits.  This requires
having an extra set of regions, so the new and old regions can coexist.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: enable mrg buf header in tap on linux
Michael S. Tsirkin [Mon, 24 Sep 2012 19:05:03 +0000 (21:05 +0200)]
virtio-net: enable mrg buf header in tap on linux

Modern linux supports arbitrary header size,
which makes it possible to pass mrg buf header
to tap directly without iovec mangling.
Use this capability when it is there.

This removes the need to deal with it in
vhost-net as we do now.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: test peer header support at init time
Michael S. Tsirkin [Mon, 24 Sep 2012 15:04:21 +0000 (17:04 +0200)]
virtio-net: test peer header support at init time

There's no reason to query header support at random
times: at load or feature query.
Driver also might not query functions.
Cleaner to do it at device init.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: minor code simplification
Michael S. Tsirkin [Mon, 24 Sep 2012 14:27:27 +0000 (16:27 +0200)]
virtio-net: minor code simplification

During packet filtering, we can now use host hdr len
to offset incoming buffer unconditionally.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: simplify rx code
Michael S. Tsirkin [Mon, 24 Sep 2012 12:54:44 +0000 (14:54 +0200)]
virtio-net: simplify rx code

Remove code duplication using guest header length that we track.
Drop specific layout requirement for rx buffers: things work
using generic iovec functions in any case.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: switch tx to safe iov functions
Michael S. Tsirkin [Mon, 24 Sep 2012 12:52:28 +0000 (14:52 +0200)]
virtio-net: switch tx to safe iov functions

Avoid mangling iovec manually: use safe iov_*
functions.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: first s/g is always at start of buf
Michael S. Tsirkin [Mon, 24 Sep 2012 11:26:55 +0000 (13:26 +0200)]
virtio-net: first s/g is always at start of buf

We know offset is 0, assert that.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: refactor receive_hdr
Michael S. Tsirkin [Mon, 24 Sep 2012 11:24:17 +0000 (13:24 +0200)]
virtio-net: refactor receive_hdr

Now that we know host hdr length, we don't need to
duplicate the logic in receive_hdr: caller can
figure out the offset itself.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: use safe iov operations for rx
Michael S. Tsirkin [Mon, 24 Sep 2012 11:17:13 +0000 (13:17 +0200)]
virtio-net: use safe iov operations for rx

Avoid magling iov manually: use safe iov operations
for processing packets incoming to guest.
This also removes the requirement for virtio header to
fit the first s/g entry exactly.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: avoid sg copy
Michael S. Tsirkin [Mon, 24 Sep 2012 11:14:16 +0000 (13:14 +0200)]
virtio-net: avoid sg copy

Avoid tweaking iovec during receive. This removes
the need to copy the vector.
Note: we currently have an evil cast in work_around_broken_dhclient
and unfortunately this patch does not fix it - just
pushes the evil cast to another place.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoiov: add iov_cpy
Michael S. Tsirkin [Mon, 24 Sep 2012 11:02:52 +0000 (13:02 +0200)]
iov: add iov_cpy

Add API to copy part of iovec safely.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agovirtio-net: track host/guest header length
Michael S. Tsirkin [Mon, 24 Sep 2012 10:12:25 +0000 (12:12 +0200)]
virtio-net: track host/guest header length

Tracking these in device state instead of
re-calculating on each packet. No functional
changes.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: avoid destroying bridge address space windows in a transaction
Avi Kivity [Thu, 25 Oct 2012 10:37:57 +0000 (12:37 +0200)]
pci: avoid destroying bridge address space windows in a transaction

Calling memory_region_destroy() in a transaction is illegal (and aborts),
as until the transaction is committed, the region remains live.

Fix by moving destruction until after the transaction commits.  This requires
having an extra set of regions, so the new and old regions can coexist.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agopcie: Convert PCIExpressHost to use the QOM.
Jason Baron [Fri, 19 Oct 2012 20:43:33 +0000 (16:43 -0400)]
pcie: Convert PCIExpressHost to use the QOM.

Let's use PCIExpressHost with QOM.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopcie: pass pcie window size to pcie_host_mmcfg_update()
Jason Baron [Fri, 19 Oct 2012 20:43:32 +0000 (16:43 -0400)]
pcie: pass pcie window size to pcie_host_mmcfg_update()

This allows q35 to pass/set the size of the pcie window in its update routine.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: Add class 0xc05 as 'SMBus'
Jan Kiszka [Fri, 19 Oct 2012 20:43:31 +0000 (16:43 -0400)]
pci: Add class 0xc05 as 'SMBus'

[jbaron@redhat.com: add PCI_CLASS_SERIAL_SMBUS definition]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: introduce pci_swizzle_map_irq_fn() for standardized interrupt pin swizzle
Isaku Yamahata [Fri, 19 Oct 2012 20:43:28 +0000 (16:43 -0400)]
pci: introduce pci_swizzle_map_irq_fn() for standardized interrupt pin swizzle

Introduce pci_swizzle_map_irq_fn() for interrupt pin swizzle which is
standardized. PCI bridge swizzle is common logic, by introducing
this function duplicated swizzle logic will be avoided later.

[jbaron@redhat.com: drop opaque argument]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci_ids: add intel 82801BA pci-to-pci bridge id
Isaku Yamahata [Fri, 19 Oct 2012 20:43:31 +0000 (16:43 -0400)]
pci_ids: add intel 82801BA pci-to-pci bridge id

Adds pci id constants which will be used by q35.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: pci capability must be in PCI space
Isaku Yamahata [Fri, 19 Oct 2012 20:43:28 +0000 (16:43 -0400)]
pci: pci capability must be in PCI space

pci capability must be in PCI space.
It can't lay in PCIe extended config space.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: make each capability DWORD aligned
Michael S. Tsirkin [Mon, 22 Oct 2012 10:35:00 +0000 (12:35 +0200)]
pci: make each capability DWORD aligned

PCI spec (see e.g. 6.7 Capabilities List in spec rev 3.0)
requires that each capability is DWORD aligned.
Ensure this when allocating space by rounding size up to 4.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoqemu: enable PV EOI for qemu 1.3
Michael S. Tsirkin [Wed, 17 Oct 2012 22:15:48 +0000 (00:15 +0200)]
qemu: enable PV EOI for qemu 1.3

Enable KVM PV EOI by default. You can still disable it with
-kvm_pv_eoi cpu flag. To avoid breaking cross-version migration,
enable only for qemu 1.3 (or in the future, newer) machine type.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: Return PCI_INTX_DISABLED when no bus INTx routing support
Alex Williamson [Wed, 17 Oct 2012 22:13:12 +0000 (16:13 -0600)]
pci: Return PCI_INTX_DISABLED when no bus INTx routing support

Rather than assert, simply return PCI_INTX_DISABLED when we don't
have a pci_route_irq_fn.  PIIX already returns DISABLED for an
invalid pin, so users already deal with this state.  Users of this
interface should only be acting on an ENABLED or INVERTED return
value (though we really have no support for INVERTED).  Also
complain loudly when we hit this so we don't forget it's missing.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
12 years agopci-assign: Use msi_get_message()
Alex Williamson [Tue, 2 Oct 2012 19:22:14 +0000 (13:22 -0600)]
pci-assign: Use msi_get_message()

pci-assign only uses a subset of the flexibility msi_get_message()
provides, but it's still worthwhile to use it.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agomsi: Add msi_get_message()
Alex Williamson [Tue, 2 Oct 2012 19:22:07 +0000 (13:22 -0600)]
msi: Add msi_get_message()

vfio-pci and pci-assign both do this on their own for setting up
direct MSI injection through KVM.  Provide a helper function for
this in MSI code.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci-assign: Use pci_intx_route_changed()
Alex Williamson [Tue, 2 Oct 2012 19:22:01 +0000 (13:22 -0600)]
pci-assign: Use pci_intx_route_changed()

Replace open coded version

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agopci: Helper function for testing if an INTx route changed
Alex Williamson [Tue, 2 Oct 2012 19:21:54 +0000 (13:21 -0600)]
pci: Helper function for testing if an INTx route changed

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 years agoMerge remote-tracking branch 'kraxel/usb.68' into staging
Anthony Liguori [Mon, 29 Oct 2012 15:34:29 +0000 (10:34 -0500)]
Merge remote-tracking branch 'kraxel/usb.68' into staging

* kraxel/usb.68: (36 commits)
  xhci: fix usb name in caps
  xhci: make number of interrupters and slots configurable
  xhci: allow disabling interrupters
  xhci: flush endpoint context unconditinally
  xhci: fix function name in error message
  uhci: Use only one queue for ctrl endpoints
  uhci: Retry to fill the queue while waiting for td completion
  uhci: Always mark a queue valid when we encounter it
  uhci: When the guest marks a pending td non-active, cancel the queue
  uhci: Detect guest td re-use
  uhci: Verify queue has not been changed by guest
  uhci: Immediately free queues on device disconnect
  uhci: Store ep in UHCIQueue
  uhci: Make uhci_fill_queue() actually operate on an UHCIQueue
  uhci: Add uhci_read_td() helper function
  uhci: Rename UHCIAsync->td to UHCIAsync->td_addr
  uhci: Move emptying of the queue's asyncs' queue to uhci_queue_free
  uhci: Drop unnecessary forward declaration of some static functions
  uhci: Don't retry on error
  uhci: cleanup: Add an unlink call to uhci_async_cancel()
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 29 Oct 2012 15:34:05 +0000 (10:34 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony: (32 commits)
  osdep: Less restrictive F_SEFL in qemu_dup_flags()
  qemu-iotests: add testcases for mirroring on-source-error/on-target-error
  qmp: add pull_event function
  mirror: add support for on-source-error/on-target-error
  iostatus: forward block_job_iostatus_reset to block job
  qemu-iotests: add mirroring test case
  mirror: implement completion
  qmp: add drive-mirror command
  mirror: introduce mirror job
  block: introduce BLOCK_JOB_READY event
  block: add block-job-complete
  block: rename block_job_complete to block_job_completed
  block: export dirty bitmap information in query-block
  block: introduce new dirty bitmap functionality
  block: add bdrv_open_backing_file
  block: add bdrv_query_stats
  block: add bdrv_query_info
  qemu-config: Add new -add-fd command line option
  monitor: Prevent removing fd from set during init
  monitor: Enable adding an inherited fd to an fd set
  ...

Conflicts:
vl.c

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf
Aurelien Jarno [Mon, 29 Oct 2012 13:56:17 +0000 (14:56 +0100)]
Merge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf

* 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf: (22 commits)
  PPC: pseries: Remove hack for PIO window
  PPC: e500: Map PIO space into core memory region
  xen_platform: convert PIO to new memory api read/write
  vmport: convert PIO to new memory api read/write
  serial: convert PIO to new memory api read/write
  rtl8139: convert PIO to new memory api read/write
  pckbd: convert PIO to new memory api read/write
  pc port92: convert PIO to new memory api read/write
  mc146818rtc: convert PIO to new memory api read/write
  m48t59: convert PIO to new memory api read/write
  i8254: convert PIO to new memory api read/write
  es1370: convert PIO to new memory api read/write
  virtio-pci: convert PIO to new memory api read/write
  ac97: convert PIO to new memory api read/write
  pseries: Implement qemu initiated shutdowns using EPOW events
  target-ppc: Rework storage of VPA registration state
  pseries: Don't allow duplicate registration of hcalls or RTAS calls
  Add USB option in machine options
  e500: Fix serial initialization
  PPC: 440: Emulate DCBR0
  ...

12 years agoMerge branch 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable
Aurelien Jarno [Mon, 29 Oct 2012 13:55:51 +0000 (14:55 +0100)]
Merge branch 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable

* 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable:
  migration: go to paused state after finishing incoming migration with -S
  qmp: handle stop/cont in INMIGRATE state
  hmp: fix info cpus for sparc targets

12 years agoPPC: pseries: Remove hack for PIO window
Alexander Graf [Mon, 8 Oct 2012 11:54:18 +0000 (13:54 +0200)]
PPC: pseries: Remove hack for PIO window

Now that all users of old_portio are gone, we can remove the hack
that enabled us to support them.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: e500: Map PIO space into core memory region
Alexander Graf [Mon, 8 Oct 2012 10:21:30 +0000 (12:21 +0200)]
PPC: e500: Map PIO space into core memory region

On PPC, we don't have PIO. So usually PIO space behind a PCI bridge is
accessible via MMIO. Do this mapping explicitly by mapping the PIO space
of our PCI bus into a memory region that lives in memory space.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoxen_platform: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:47:30 +0000 (13:47 +0200)]
xen_platform: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agovmport: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:44:24 +0000 (13:44 +0200)]
vmport: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoserial: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:40:29 +0000 (13:40 +0200)]
serial: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agortl8139: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:35:24 +0000 (13:35 +0200)]
rtl8139: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopckbd: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:30:08 +0000 (13:30 +0200)]
pckbd: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopc port92: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:24:52 +0000 (13:24 +0200)]
pc port92: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agomc146818rtc: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:22:28 +0000 (13:22 +0200)]
mc146818rtc: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agom48t59: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:19:48 +0000 (13:19 +0200)]
m48t59: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoi8254: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:12:31 +0000 (13:12 +0200)]
i8254: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoes1370: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:09:44 +0000 (13:09 +0200)]
es1370: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agovirtio-pci: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:02:30 +0000 (13:02 +0200)]
virtio-pci: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoac97: convert PIO to new memory api read/write
Alexander Graf [Mon, 8 Oct 2012 11:02:20 +0000 (13:02 +0200)]
ac97: convert PIO to new memory api read/write

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Implement qemu initiated shutdowns using EPOW events
David Gibson [Mon, 8 Oct 2012 18:17:39 +0000 (18:17 +0000)]
pseries: Implement qemu initiated shutdowns using EPOW events

At present, using 'system_powerdown' from the monitor or otherwise
instructing qemu to (cleanly) shut down a pseries guest will not work,
because we did not have a method of signalling the shutdown request to the
guest.

PAPR does include a usable mechanism for this, though it is rather more
involved than the equivalent on x86.  This involves sending an EPOW
(Environmental and POwer Warning) event through the PAPR event and error
logging mechanism, which also has a number of other functions.

This patch implements just enough of the event/error logging functionality
to be able to send a shutdown event to the guest.  At least with modern
guest kernels and a userspace that is up and running, this means that
system_powerdown from the qemu monitor should now work correctly on pseries
guests.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agotarget-ppc: Rework storage of VPA registration state
David Gibson [Mon, 8 Oct 2012 18:17:38 +0000 (18:17 +0000)]
target-ppc: Rework storage of VPA registration state

With PAPR guests, hypercalls allow registration of the Virtual Processor
Area (VPA), SLB shadow and dispatch trace log (DTL), each of which allow
for certain communication between the guest and hypervisor.  Currently, we
store the addresses of the three areas and the size of the dtl in
CPUPPCState.

The SLB shadow and DTL are variable sized, with the size being retrieved
from within the registered memory area at the hypercall time.  This size
can later be overwritten with other information, however, so we need to
save the size as of registration time.  We already do this for the DTL,
but not for the SLB shadow, so this patch fixes that.

In addition, we change the storage of the VPA information to use fixed
size integer types which will make life easier for syncing this data with
KVM, which we will need in future.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Don't allow duplicate registration of hcalls or RTAS calls
David Gibson [Mon, 8 Oct 2012 18:17:36 +0000 (18:17 +0000)]
pseries: Don't allow duplicate registration of hcalls or RTAS calls

Currently the pseries machine code allows a callback to be registered
for a hypercall number twice, as long as it's the same callback the second
time.  We don't test for duplicate registrations of RTAS callbacks at all
so it will effectively be last registratiojn wins.

This was originally done because it was awkward to ensure that the
registration happened exactly once, but the code has since been
restructured so that's no longer the case.

Duplicate registration of a hypercall or RTAS call could well suggest
a duplicate initialization which could cause other problems, so this patch
makes duplicate registrations a bug, to prevent the old behaviour from
hiding other bugs.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoAdd USB option in machine options
zhlcindy@gmail.com [Sun, 2 Sep 2012 19:25:28 +0000 (19:25 +0000)]
Add USB option in machine options

When -usb option is used, global varible usb_enabled is set.
And all the plaform will create one USB controller according
to this variable. In fact, global varibles make code hard
to read.

So this patch is to remove global variable usb_enabled and
add USB option in machine options. All the plaforms will get
USB option value from machine options.

USB option of machine options will be set either by:
  * -usb
  * -machine type=pseries,usb=on

Both these ways can work now. They both set USB option in
machine options. In the future, the first way will be removed.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoe500: Fix serial initialization
Bharat Bhushan [Mon, 8 Oct 2012 06:46:54 +0000 (06:46 +0000)]
e500: Fix serial initialization

it was wrongly using serial_hds[0] instead of serial_hds[1]

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: 440: Emulate DCBR0
Alexander Graf [Sat, 6 Oct 2012 20:54:25 +0000 (22:54 +0200)]
PPC: 440: Emulate DCBR0

The DCBR0 register on 440 is used to implement system reset. The same
register is used on 405 as well, so just reuse the code.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: Bamboo: Fix memory size DT property
Alexander Graf [Sat, 6 Oct 2012 00:02:05 +0000 (02:02 +0200)]
PPC: Bamboo: Fix memory size DT property

Device tree properties need to be specified in big endian. Fix the
bamboo memory size property accordingly.

Signed-off-by: Alexander Graf <agraf@suse.de>
CC: qemu-stable@nongnu.org
12 years agoDrop unnecessary check of TARGET_PHYS_ADDR_SPACE_BITS
Peter Maydell [Fri, 5 Oct 2012 07:09:02 +0000 (07:09 +0000)]
Drop unnecessary check of TARGET_PHYS_ADDR_SPACE_BITS

For all our PPC targets the physical address space is at least
36 bits, so drop an unnecessary preprocessor conditional check
on TARGET_PHYS_ADDR_SPACE_BITS (erroneously introduced as part
of the change from target_phys_addr_t to hwaddr). This brings
this bit of code into line with the way we handle the other
cases which were originally checking TARGET_PHYS_ADDR_BITS in
order to avoid compiler complaints about overflowing a 32 bit type.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoxilinx_zynq: added QSPI controller
Peter Crosthwaite [Mon, 15 Oct 2012 04:40:21 +0000 (14:40 +1000)]
xilinx_zynq: added QSPI controller

Added the QSPI controller to the Zynq. 4 SPI devices are attached to allow
modelling of the different geometries. E.G. Dual parallel and dual stacked
mode can both be tested with this one arrangement.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
12 years agoxilinx_spips: Generalised to model QSPI
Peter Crosthwaite [Mon, 15 Oct 2012 04:37:04 +0000 (14:37 +1000)]
xilinx_spips: Generalised to model QSPI

Extended the xilinx spips controller to model QSPI as well. Paremeterised the
operational difference with the normal spi controller (num_ss_bits, width of the
tx/rx fifo heads etc.). Multiple bus functionality is modelled (needed for QSPI
dual parallel mode. LQSPI is modelled.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
12 years agom25p80: Support for Quad SPI
Peter Crosthwaite [Mon, 15 Oct 2012 04:34:37 +0000 (14:34 +1000)]
m25p80: Support for Quad SPI

Added the Quad mode read and write commands. Data remains serialized on a
single wire, i.e. the quad mode instructions just behave the same as single
mode, with the expection of modelling the varying number of dummy/mode bytes
between the address bytes and the first data word.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
12 years agotarget-i386: cpu: recover items 28-31 of ext2_feature_name
Eduardo Habkost [Wed, 24 Oct 2012 14:10:33 +0000 (12:10 -0200)]
target-i386: cpu: recover items 28-31 of ext2_feature_name

I removed a line by mistake on commit
3b671a40cab2404bc63e57db8cd3afa4ec70bfab, containing the flags lm/i64,
3dnow, and 3dnowext. This patch restores the removed line.

Reviewed-by: Don Slutz <Don@cloudswitch.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agoqemu-timer: Check for usable fields for SIGEV_THREAD_ID
Richard Henderson [Mon, 22 Oct 2012 21:33:00 +0000 (07:33 +1000)]
qemu-timer: Check for usable fields for SIGEV_THREAD_ID

Older glibc (RHEL 5.x, Debian 5.x) does not have the _sigev_un._tid
member in its structure definition, while the accompanying kernel
headers do define SIGEV_THREAD_ID.  We need configure to check for
both before using it.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg-i386: Use %gs prefixes for x86_64 GUEST_BASE
Richard Henderson [Mon, 22 Oct 2012 02:11:07 +0000 (12:11 +1000)]
tcg-i386: Use %gs prefixes for x86_64 GUEST_BASE

When we allocate a reserved_va for the guest, the kernel will likely
choose an address well above 4G.  At which point we must use a pair
of movabsq+addq to form the host address.  If we have OS support,
set up a segment register to point to guest_base instead.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-mips: Use TCG registers for the FPU.
Richard Henderson [Tue, 9 Oct 2012 19:53:19 +0000 (21:53 +0200)]
target-mips: Use TCG registers for the FPU.

With normal FP, this doesn't have much affect on the generated code,
because most of the FP operations are not CONST/PURE, and so we spill
registers in about the same frequency as the explicit load/stores.

But with Loongson multimedia instructions, which are all integral and
whose helpers are in fact CONST+PURE, this greatly improves the code.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: remove compatiblity call flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
tcg: remove compatiblity call flags

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-xtensa: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-xtensa: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-sparc: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-sparc: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Blue Swirl <blauwirbel@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-sh4: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-sh4: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-s390x: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-s390x: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Alexander Graf <agraf@suse.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-ppc: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-ppc: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Alexander Graf <agraf@suse.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-mips: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-mips: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-microblaze: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:09 +0000 (21:53 +0200)]
target-microblaze: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-i386: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-i386: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-cris: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-cris: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-arm: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-arm: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Cc: Paul Brook <paul@codesourcery.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotarget-alpha: rename helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
target-alpha: rename helper flags

Rename helper flags to the new ones. This is purely a mechanical change,
it's possible to use better flags by looking at the helpers.

Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: rework TCG helper flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: rework TCG helper flags

The current helper flags, TCG_CALL_CONST and TCG_CALL_PURE might be
confusing and doesn't provide enough granularity for some helpers (FP
helpers for example).

This patch changes them into the following helpers flags:
- TCG_CALL_NO_READ_GLOBALS means that the helper does not read globals,
  either directly or via an exception. They will not be saved to their
  canonical location before calling the helper.
- TCG_CALL_NO_WRITE_GLOBALS means that the helper does not modify any
  globals. They will only be saved to their canonical locations before
  calling helpers, but they won't be reloaded afterwise.
- TCG_CALL_NO_SIDE_EFFECTS means that the call to the function is
  removed if the return value is not used.

It provides convenience flags, to avoid helper definitions longer than
80 characters. It also provides compatibility flags, and updates the
documentation.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: synchronize globals for ops with side effects
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: synchronize globals for ops with side effects

Operations with side effects (in practice qemu_ld/st ops), only need to
synchronize globals to make sure the CPU state is consistent in case of
exception.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: forbid ld/st function to modify globals
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: forbid ld/st function to modify globals

Mapping a memory address using a global and accessing it through
ld/st operations is currently broken. As it doesn't make any sense
to do that performance wise, let's forbid that.

Update the TCG documentation, and remove partial support for that.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: fix some op flags
Aurelien Jarno [Tue, 9 Oct 2012 19:53:08 +0000 (21:53 +0200)]
tcg: fix some op flags

Some branch related ops are marked with TCG_OPF_SIDE_EFFECTS, some other
not. In practice they don't need to, as they are all marked with
TCG_OPF_BB_END, which is handled specifically in all the code.

The call op is marked as TCG_OPF_SIDE_EFFECTS, which might be not true
as there is are specific flags (TCG_CALL_CONST and TCG_CALL_PURE) for
specifying that. On the other hand it always clobber arguments, so mark
it as such even if the call op is handled in a different code path.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: don't explicitly save globals and temps
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: don't explicitly save globals and temps

The liveness analysis ensures that globals and temps are at the correct
state at a basic block end or with an op with side effects. Avoid
looping on all temps, this can be time consuming on targets with a lot
of globals. Keep an assert in debug mode.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: start with local temps in TEMP_VAL_MEM state
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: start with local temps in TEMP_VAL_MEM state

Start with local temps in TEMP_VAL_MEM state, to make possible a later
check that all the temps are correctly saved back to memory.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: always mark dead input arguments as dead
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: always mark dead input arguments as dead

Always mark dead input arguments as dead, even if the op is at the basic
block end. This will allow to check that all temps are correctly saved.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: rewrite tcg_reg_alloc_mov()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: rewrite tcg_reg_alloc_mov()

Now that the liveness analysis provides more information, rewrite
tcg_reg_alloc_mov(). This changes the behaviour about propagating
constants and memory accesses. We now take the assumption that once
a value is loaded into a register (from memory or from a constant),
it's better to keep it there than to reload it later. This assumption
is now always almost correct given that we are now sure the
corresponding temp is going to be used later (otherwise it would have
been synchronized and marked as dead already). The assumption is wrong
if one of the op after clobbers some registers including the one
of the holding the temp (this can be avoided by allocating clobbered
registers last, which is what most TCG target do), or in case of lack
of available register.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: improve tcg_reg_alloc_movi()
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: improve tcg_reg_alloc_movi()

Now that the liveness analysis might mark some output temps as dead, call
temp_dead() if needed.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: rework liveness analysis
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: rework liveness analysis

Rework the liveness analysis by tracking temps that need to go back to
memory in addition to dead temps tracking. This allows to mark output
arguments as "need sync", and to synchronize them back to memory as soon
as they are not written anymore. This way even arguments mapping to
globals can be marked as "dead", avoiding moves to a new register when
input and outputs are aliased.

In addition it means that registers are freed as soon as temps are not
used anymore, instead of waiting for a basic block end or an op with side
effects. This reduces register spilling especially on CPUs with few
registers, and spread the mov over all the TB, increasing the
performances on in-order CPUs.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
12 years agotcg: sync output arguments on liveness request
Aurelien Jarno [Tue, 9 Oct 2012 19:53:07 +0000 (21:53 +0200)]
tcg: sync output arguments on liveness request

Synchronize an output argument when requested by the liveness analysis.
This is needed so that the temp can be declared dead later.

For that, add a new op_sync_args table in which each bit tells if the
corresponding output argument needs to be synchronized with the memory.
Pass it to the tcg_reg_alloc_* functions, and honor this bit. We need to
synchronize the argument before marking it as dead, and we have to make
sure all the infos about the temp are correctly filled.

At the same time change some types from unsigned int to uint16_t when
passing op_dead_args.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>