]> git.proxmox.com Git - qemu.git/log
qemu.git
12 years agoConvert IO_MEM_SUBPAGE_RAM to be a MemoryRegion
Avi Kivity [Mon, 2 Jan 2012 10:41:07 +0000 (12:41 +0200)]
Convert IO_MEM_SUBPAGE_RAM to be a MemoryRegion

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoConvert the subpage wrapper to be a MemoryRegion
Avi Kivity [Mon, 2 Jan 2012 10:32:48 +0000 (12:32 +0200)]
Convert the subpage wrapper to be a MemoryRegion

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoSwitch cpu_register_physical_memory_log() to use MemoryRegions
Avi Kivity [Mon, 2 Jan 2012 10:17:03 +0000 (12:17 +0200)]
Switch cpu_register_physical_memory_log() to use MemoryRegions

Still internally using ram_addr.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoConvert IO_MEM_{RAM,ROM,UNASSIGNED,NOTDIRTY} to MemoryRegions
Avi Kivity [Sun, 1 Jan 2012 22:32:15 +0000 (00:32 +0200)]
Convert IO_MEM_{RAM,ROM,UNASSIGNED,NOTDIRTY} to MemoryRegions

Convert the fixed-address IO_MEM_RAM, IO_MEM_ROM, IO_MEM_UNASSIGNED,
and IO_MEM_NOTDIRTY io handlers to MemoryRegions.  These aren't real
regions, since they are never added to the memory hierarchy, but they
allow reuse of the dispatch functionality.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoUninline get_page_addr_code()
Avi Kivity [Sun, 1 Jan 2012 21:35:10 +0000 (23:35 +0200)]
Uninline get_page_addr_code()

Its use of IO_MEM_ROM and friends will later cause #include loops; and it
is too large to merit inlining.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoAvoid range comparisons on io index types
Avi Kivity [Sun, 1 Jan 2012 19:15:42 +0000 (21:15 +0200)]
Avoid range comparisons on io index types

The code sometimes uses range comparisons on io indexes (e.g.
index =< IO_MEM_ROM).  Avoid these as they make moving to objects harder.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoFix wrong region_offset when overlaying a page with another
Avi Kivity [Sun, 1 Jan 2012 16:24:24 +0000 (18:24 +0200)]
Fix wrong region_offset when overlaying a page with another

cpu_register_physical_memory_log() does not update region_offset
if a page was previously registered for the same address.  This
could cause mmio accesses going to the wrong place, by using the
old region_offset.

Signed-off-by: Avi Kivity <avi@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agomemory: remove MemoryRegion::backend_registered
Avi Kivity [Sun, 1 Jan 2012 16:02:31 +0000 (18:02 +0200)]
memory: remove MemoryRegion::backend_registered

backend_registered was used to lazify the process of registering an
mmio region, since the it is different for the I/O address space and
the memory address space.  However, it also makes registration dependent
on the region being visible in the address space.  This is not the case
for "fake" regions, like watchpoints or IO_MEM_UNASSIGNED.

Remove backend_registered and always initialize the region.  If it turns
out to be part of the I/O address space, we've wasted an I/O slot, but
that's not too bad.  In any case this will be optimized later on.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agomemory: move mmio access to functions
Avi Kivity [Mon, 21 Nov 2011 10:27:03 +0000 (12:27 +0200)]
memory: move mmio access to functions

Currently mmio access goes directly to the io_mem_{read,write} arrays.
In preparation for eliminating them, add indirection via a function.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agoexec: make phys_page_find() return a temporary
Avi Kivity [Sun, 20 Nov 2011 15:52:22 +0000 (17:52 +0200)]
exec: make phys_page_find() return a temporary

Instead of returning a PhysPageDesc pointer, return a temporary.
This lets us move away from actually storing PhysPageDesc's, and
instead sythesising them when needed.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agomemory: move endianness compensation to memory core
Avi Kivity [Sun, 20 Nov 2011 14:22:55 +0000 (16:22 +0200)]
memory: move endianness compensation to memory core

Instead of doing device endianness compensation in cpu_register_io_memory(),
do it in the memory core.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
12 years agomemory: obsolete more dirty memory related functions
Avi Kivity [Wed, 21 Dec 2011 12:16:38 +0000 (14:16 +0200)]
memory: obsolete more dirty memory related functions

No longer used outside memory.c and exec.c.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoxen: convert framebuffer dirty tracking to memory API
Avi Kivity [Wed, 21 Dec 2011 12:21:27 +0000 (14:21 +0200)]
xen: convert framebuffer dirty tracking to memory API

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()
Avi Kivity [Wed, 21 Dec 2011 12:14:07 +0000 (14:14 +0200)]
memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()

The getter is no longer used, so it is completely removed.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoConvert ram_load() to the memory API
Avi Kivity [Wed, 21 Dec 2011 11:54:33 +0000 (13:54 +0200)]
Convert ram_load() to the memory API

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoRemove support for version 3 ram_load
Avi Kivity [Wed, 21 Dec 2011 11:37:56 +0000 (13:37 +0200)]
Remove support for version 3 ram_load

Version 3 ram_load depends on ram_addrs, which are not stable.  Version 4
was introduced in 0.13 (and RHEL 6), so this means live migration from 0.12
and earlier to 1.1 or later will not work.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoSort RAMBlocks by ID for migration, not by ram_addr
Avi Kivity [Wed, 21 Dec 2011 11:22:16 +0000 (13:22 +0200)]
Sort RAMBlocks by ID for migration, not by ram_addr

ram_addr is (a) unstable (b) going away.  Sort by idstr instead.

Commit b2e0a138e initially introduced the sorting for the purpose
of improving debuggability.  After this patch, the order is still
stable, but perhaps less usable by a human.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoSwitch ram_save to the memory API
Avi Kivity [Wed, 21 Dec 2011 11:11:22 +0000 (13:11 +0200)]
Switch ram_save to the memory API

Avoid using ram_addr_t, instead use (MemoryRegion *, offset) pairs.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoStore MemoryRegion in RAMBlock
Avi Kivity [Wed, 21 Dec 2011 11:09:49 +0000 (13:09 +0200)]
Store MemoryRegion in RAMBlock

As a step in moving live migration from RAMBlocks to MemoryRegions,
store the MemoryRegion in a RAMBlock.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agovmstate, memory: decouple vmstate from memory API
Avi Kivity [Tue, 20 Dec 2011 13:59:12 +0000 (15:59 +0200)]
vmstate, memory: decouple vmstate from memory API

Currently creating a memory region automatically registers it for
live migration.  This differs from other state (which is enumerated
in a VMStateDescription structure) and ties the live migration code
into the memory core.

Decouple the two by introducing a separate API, vmstate_register_ram(),
for registering a RAM block for migration.  Currently the same
implementation is reused, but later it can be moved into a separate list,
and registrations can be moved to VMStateDescription blocks.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: introduce memory_region_name()
Avi Kivity [Tue, 20 Dec 2011 13:53:11 +0000 (15:53 +0200)]
memory: introduce memory_region_name()

Trivial accessor for the name attribute.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoFix parse of usb device description with multiple configurations
Cao,Bing Bu [Tue, 13 Dec 2011 01:22:20 +0000 (09:22 +0800)]
Fix parse of usb device description with multiple configurations

Changed From V1:
Use DPRINTF instead of fprintf,because it is not an error.

When testing ipod on QEMU by He Jie Xu<xuhj@linux.vnet.ibm.com>,qemu made a assertion.
We found that the ipod with 2 configurations,and the usb-linux did not parse the descriptor correctly.
The descr_len returned is the total length of the all configurations,not one configuration.
The older version will through the other configurations instead of skip,continue parsing the descriptor of interfaces/endpoints in other configurations,then went wrong.

This patch will put the configuration descriptor parse in loop outside and dispel the other configurations not requested.

Signed-off-by: Cao,Bing Bu <mars@linux.vnet.ibm.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agohw/omap1.c: Separate PWL from omap_mpu_state
Juha Riihimäki [Tue, 20 Dec 2011 08:11:32 +0000 (08:11 +0000)]
hw/omap1.c: Separate PWL from omap_mpu_state

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
[Riku Voipio: Fixes and restructuring patchset]
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
[Peter Maydell: More fixes and cleanups for upstream submission]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agohw/omap1.c: omap_mpuio_init() need not be public
Peter Maydell [Tue, 20 Dec 2011 08:11:31 +0000 (08:11 +0000)]
hw/omap1.c: omap_mpuio_init() need not be public

omap_mpuio_init() is only used and defined in omap1.c, so make it static.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agohw/pl110.c: Add post-load hook to invalidate display
Peter Maydell [Mon, 19 Dec 2011 12:01:58 +0000 (12:01 +0000)]
hw/pl110.c: Add post-load hook to invalidate display

Add a post-load hook which invalidates the display. In particular, if we
don't do this and the display size we've just reloaded is larger than
the default then we will segfault trying to read off the end of the buffer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agohw/pl181.c: Add save/load support
Peter Maydell [Mon, 19 Dec 2011 12:01:44 +0000 (12:01 +0000)]
hw/pl181.c: Add save/load support

Add save/load support to the PL181.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12 years agos390: fix cpu hotplug / cpu activity on interrupts
Christian Borntraeger [Sun, 20 Nov 2011 23:12:03 +0000 (23:12 +0000)]
s390: fix cpu hotplug / cpu activity on interrupts

The add_del/running_cpu code and env->halted are tracking stopped cpus.
Sleeping cpus (idle and enabled for interrupts) are waiting inside the
kernel.
No interrupt besides the restart can move a cpu from stopped to
operational. This is already handled over there. So lets just remove
the bogus wakup from the common interrupt delivery, otherwise any
interrupt will wake up a cpu, even if this cpu is stopped (Thus leading
to strange hangs on sigp restart)

This fixes
echo 0 > /sys/devices/system/cpu/cpu0/online
echo 1 > /sys/devices/system/cpu/cpu0/online
in the guest

Signed-off-by: Christian Borntraeger<borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agos390x: add TR function for EXECUTE
Alexander Graf [Fri, 18 Nov 2011 15:45:54 +0000 (16:45 +0100)]
s390x: add TR function for EXECUTE

Newer gcc versions (or glibc?) also generate code that tries to EXECUTE
the TR opcode. Implement it so that we don't break valid guests.

Reported-by: Andreas Faerber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoExpose drive_add on all architectures
Alexander Graf [Wed, 13 Jul 2011 12:08:32 +0000 (14:08 +0200)]
Expose drive_add on all architectures

All architectures can now use drive_add on the monitor. This of course
does not mean that there is hotplug support for the specific platform,
so in order to actually make use of the new drives you still need to
have a hotplug capable device.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoAdd generic drive hotplugging
Alexander Graf [Mon, 23 Aug 2010 21:43:10 +0000 (23:43 +0200)]
Add generic drive hotplugging

The monitor command for hotplugging is in i386 specific code. This is just
plain wrong, as S390 just learned how to do hotplugging too and needs to
get drives for that.

So let's add a generic copy to generic code that handles drive_add in a
way that doesn't have pci dependencies. All pci specific code can then
be handled in a pci specific function.

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

v1 -> v2:

  - align generic drive_add to pci specific one
  - rework to split between generic and pci code

v2 -> v3:

  - remove comment

12 years agoCompile device-hotplug on all targets
Alexander Graf [Mon, 23 Aug 2010 21:40:28 +0000 (23:40 +0200)]
Compile device-hotplug on all targets

All guest targets could potentially implement hotplugging. With the next
patches in this set I will also reflect this in the monitor interface.

So let's always compile it in. It shouldn't hurt.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years ago[S390] Add hotplug support
Alexander Graf [Mon, 23 Aug 2010 16:58:34 +0000 (18:58 +0200)]
[S390] Add hotplug support

I just submitted a few patches that enable the s390 virtio bus to receive
a hotplug add event. This patch implements the qemu side of it, so that new
hotplug events can be submitted to the guest.

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

v1 -> v2:

  - make s390 virtio hoplug code emulate-capable

12 years agoMerge remote-tracking branch 'qemu-kvm/memory/page_desc' into staging
Anthony Liguori [Tue, 3 Jan 2012 20:39:05 +0000 (14:39 -0600)]
Merge remote-tracking branch 'qemu-kvm/memory/page_desc' into staging

* qemu-kvm/memory/page_desc: (22 commits)
  Remove cpu_get_physical_page_desc()
  sparc: avoid cpu_get_physical_page_desc()
  virtio-balloon: avoid cpu_get_physical_page_desc()
  vhost: avoid cpu_get_physical_page_desc()
  kvm: avoid cpu_get_physical_page_desc()
  memory: remove CPUPhysMemoryClient
  xen: convert to MemoryListener API
  memory: temporarily add memory_region_get_ram_addr()
  xen, vga: add API for registering the framebuffer
  vhost: convert to MemoryListener API
  kvm: convert to MemoryListener API
  kvm: switch kvm slots to use host virtual address instead of ram_addr_t
  memory: add API for observing updates to the physical memory map
  memory: replace cpu_physical_sync_dirty_bitmap() with a memory API
  framebuffer: drop use of cpu_physical_sync_dirty_bitmap()
  loader: remove calls to cpu_get_physical_page_desc()
  framebuffer: drop use of cpu_get_physical_page_desc()
  memory: introduce memory_region_find()
  memory: add memory_region_is_logging()
  memory: add memory_region_is_rom()
  ...

12 years agoRemove cpu_get_physical_page_desc()
Avi Kivity [Mon, 19 Dec 2011 14:01:08 +0000 (16:01 +0200)]
Remove cpu_get_physical_page_desc()

No longer used.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agosparc: avoid cpu_get_physical_page_desc()
Avi Kivity [Mon, 19 Dec 2011 11:18:13 +0000 (13:18 +0200)]
sparc: avoid cpu_get_physical_page_desc()

This reaches into the innards of the memory core, which are being
changed.  Switch to a memory API version.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agovirtio-balloon: avoid cpu_get_physical_page_desc()
Avi Kivity [Mon, 19 Dec 2011 11:18:13 +0000 (13:18 +0200)]
virtio-balloon: avoid cpu_get_physical_page_desc()

This reaches into the innards of the memory core, which are being
changed.  Switch to a memory API version.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agovhost: avoid cpu_get_physical_page_desc()
Avi Kivity [Mon, 19 Dec 2011 11:18:13 +0000 (13:18 +0200)]
vhost: avoid cpu_get_physical_page_desc()

This reaches into the innards of the memory core, which are being
changed.  Switch to a memory API version.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agokvm: avoid cpu_get_physical_page_desc()
Avi Kivity [Mon, 19 Dec 2011 11:18:13 +0000 (13:18 +0200)]
kvm: avoid cpu_get_physical_page_desc()

This reaches into the innards of the memory core, which are being
changed.  Switch to a memory API version.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agomemory: remove CPUPhysMemoryClient
Avi Kivity [Mon, 19 Dec 2011 10:53:48 +0000 (12:53 +0200)]
memory: remove CPUPhysMemoryClient

No longer used.

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoxen: convert to MemoryListener API
Avi Kivity [Mon, 19 Dec 2011 10:07:50 +0000 (12:07 +0200)]
xen: convert to MemoryListener API

Signed-off-by: Avi Kivity <avi@redhat.com>
12 years agoPPC: Add description for the Freescale e500mc core.
Varun Sethi [Thu, 22 Dec 2011 12:26:17 +0000 (12:26 +0000)]
PPC: Add description for the Freescale e500mc core.

This core is found on chips such as p4080, p3041, p2040, and p5020.

More needs to be done to make this viable for TCG (such as missing SPRs
and instructions), but this suffices to get KVM running with appropriate
kernel support.

Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
[scottwood@freescale.com: tweak some flags]
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Check for duplicate addresses on the spapr-vio bus
Michael Ellerman [Mon, 12 Dec 2011 18:24:35 +0000 (18:24 +0000)]
pseries: Check for duplicate addresses on the spapr-vio bus

Check that devices on the spapr vio bus aren't given duplicate
addresses. Currently we will not run with duplicate devices, the
fdt code will spot it, but the error reporting is not great. With
this patch we can report the error nicely in terms of the device
names given by the user.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Populate "/chosen/linux,stdout-path" in the FDT
David Gibson [Tue, 13 Dec 2011 04:24:34 +0000 (15:24 +1100)]
pseries: Populate "/chosen/linux,stdout-path" in the FDT

There is a device tree property "/chosen/linux,stdout-path" which indicates
which device should be used as stdout - ie. "the console".

Currently we don't specify anything, which means both firmware and Linux
choose something arbitrarily. Use the routine we added in the last patch
to pick a default vty and specify it as stdout.

Currently SLOF doesn't use the property, but we are hoping to update it
to do so.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Add a routine to find a stable "default" vty and use it
David Gibson [Mon, 12 Dec 2011 18:24:33 +0000 (18:24 +0000)]
pseries: Add a routine to find a stable "default" vty and use it

In vty_lookup() we have a special case for supporting early debug in
the kernel. This accepts reg == 0 as a special case to mean "any vty".

We implement this by searching the vtys on the bus and returning the
first we find. This means that the vty we chose depends on the order
the vtys are specified on the QEMU command line - because that determines
the order of the vtys on the bus.

We'd rather the command line order was irrelevant, so instead return
the vty with the lowest reg value. This is still a guess as to what the
user really means, but it is at least stable WRT command line ordering.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
[agraf] fix braces

12 years agopseries: Emit device tree nodes in reg order
David Gibson [Mon, 12 Dec 2011 18:24:32 +0000 (18:24 +0000)]
pseries: Emit device tree nodes in reg order

Although in theory the device tree has no inherent ordering, in practice
the order of nodes in the device tree does effect the order that devices
are detected by software.

Currently the ordering is determined by the order the devices appear on
the QEMU command line. Although that does give the user control over the
ordering, it is fragile, especially when the user does not generate the
command line manually - eg. when using libvirt etc.

So order the device tree based on the reg value, ie. the address of on
the VIO bus of the devices. This gives us a sane and stable ordering.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
[agraf] add braces

12 years agopseries: FDT NUMA extensions to support multi-node guests
Bharata B Rao [Mon, 12 Dec 2011 18:24:30 +0000 (18:24 +0000)]
pseries: FDT NUMA extensions to support multi-node guests

Add NUMA specific properties to guest's device tree to boot a multi-node
guests. This patch adds the following properties:

ibm,associativity
ibm,architecture-vec-5
ibm,associativity-reference-points

With this, it becomes possible to use -numa option on pseries targets.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agopseries: Remove hcalls callback
David Gibson [Mon, 12 Dec 2011 18:24:28 +0000 (18:24 +0000)]
pseries: Remove hcalls callback

For forgotten historical reasons, PAPR hypercalls for specific virtual IO
devices (oh which there are quite a number) are registered via a callback
in the VIOsPAPRDeviceInfo structure.

This is kind of ugly, so this patch instead registers hypercalls from
device_init() functions for each device type.  This works just as well,
and is cleaner.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agokvm-ppc: halt secondary cpus when guest reset
Liu Yu-B13201 [Mon, 28 Nov 2011 20:41:18 +0000 (20:41 +0000)]
kvm-ppc: halt secondary cpus when guest reset

When guest reset, we need to halt secondary cpus until guest kick them.
This already works for tcg. The patch add the support for kvm.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
[agraf: remove in-kernel irqchip code]

12 years agoconsole: Fix segfault on screendump without VGA adapter
Alexander Graf [Fri, 18 Nov 2011 15:41:59 +0000 (16:41 +0100)]
console: Fix segfault on screendump without VGA adapter

When trying to create a screen dump without having any VGA adapter
inside the guest, QEMU segfaults.

This is because it's trying to switch back to the "previous" screen
it was on before dumping the VGA screen. Unfortunately, in my case
there simply is no previous screen so it accesses a NULL pointer.

Fix it by checking if previous_active_console is actually available.

This is 1.0 material.

Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agoPPC: monitor: add ability to dump SLB entries
Nishanth Aravamudan [Tue, 1 Nov 2011 09:57:52 +0000 (09:57 +0000)]
PPC: monitor: add ability to dump SLB entries

When run with a PPC Book3S (server) CPU Currently 'info tlb' in the
qemu monitor reports "dump_mmu: unimplemented".  However, during
bringup work, it can be quite handy to have the SLB entries, which are
available in the CPUPPCState.  This patch adds an implementation of
info tlb for book3s, which dumps the SLB.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
12 years agovirtio-console: Fix failure on unconnected pty
Christian Borntraeger [Thu, 29 Dec 2011 12:47:43 +0000 (13:47 +0100)]
virtio-console: Fix failure on unconnected pty

when I tried qemu with -virtio-console pty the guest hangs and attaching
on /dev/pts/<x> does not return anything if the attachment is too late.

This results in pty_chr_write() returning 0, which causes the port to
get throttled. This results in the guest getting frozen as the
guest->host virtio_console writes don't return until the host releases
the vq element back to the guest.

For the virtio-serial use case we don't want to lose data but for the
console case we better drop data instead of "killing" the guest
console. If we get chardev->frontend notification and a better behaving
virtio-console we can revert this fix.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
12 years agoFix qapi code generation wrt parallel build
Avi Kivity [Tue, 27 Dec 2011 14:02:16 +0000 (16:02 +0200)]
Fix qapi code generation wrt parallel build

Make's multiple output syntax

  x.c x.h: x.template
       gen < x.template

actually invokes the command once for x.c and once for x.h (with differing $@
in each invocation).  During a parallel build, the two commands may be invoked
in parallel; this opens up a race, where the second invocation trashes a file
supposedly produced during the first, and now in use by a dependent command.

The various qapi code generators are susceptible to this; fix by making them
generate just one file per invocation.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoMerge remote-tracking branch 'aneesh/for-upstream' into staging
Anthony Liguori [Tue, 27 Dec 2011 14:53:35 +0000 (08:53 -0600)]
Merge remote-tracking branch 'aneesh/for-upstream' into staging

* aneesh/for-upstream:
  scripts/analyse-9p-simpletrace.py: Add symbolic names for 9p operations.
  hw/9pfs: iattr_valid flags are kernel internal flags map them to 9p values.
  hw/9pfs: Use the correct signed type for different variables
  hw/9pfs: replace iovec manipulation with QEMUIOVector

12 years agoMerge remote-tracking branch 'bonzini/nbd-for-anthony' into staging
Anthony Liguori [Tue, 27 Dec 2011 14:52:42 +0000 (08:52 -0600)]
Merge remote-tracking branch 'bonzini/nbd-for-anthony' into staging

* bonzini/nbd-for-anthony: (26 commits)
  nbd: add myself as maintainer
  qemu-nbd: throttle requests
  qemu-nbd: asynchronous operation
  qemu-nbd: add client pointer to NBDRequest
  qemu-nbd: move client handling to nbd.c
  qemu-nbd: use common main loop
  link the main loop and its dependencies into the tools
  qemu-nbd: introduce NBDRequest
  qemu-nbd: introduce NBDExport
  qemu-nbd: introduce nbd_do_receive_request
  qemu-nbd: more robust handling of invalid requests
  qemu-nbd: introduce nbd_do_send_reply
  qemu-nbd: simplify nbd_trip
  move corking functions to osdep.c
  qemu-nbd: remove data_size argument to nbd_trip
  qemu-nbd: remove offset argument to nbd_trip
  Update ioctl order in nbd_init() to detect EBUSY
  nbd: add support for NBD_CMD_TRIM
  nbd: add support for NBD_CMD_FLUSH
  nbd: add support for NBD_CMD_FLAG_FUA
  ...

12 years agoenable architectural PMU cpuid leaf for kvm
Gleb Natapov [Thu, 15 Dec 2011 10:44:05 +0000 (12:44 +0200)]
enable architectural PMU cpuid leaf for kvm

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agoSet numa topology for max_cpus
Vasilis Liaskovitis [Wed, 26 Oct 2011 12:19:00 +0000 (14:19 +0200)]
Set numa topology for max_cpus

qemu-kvm passes numa/SRAT topology information for smp_cpus to SeaBIOS. However
SeaBIOS always expects to setup max_cpus number of SRAT cpu entries
(MaxCountCPUs variable in build_srat function of Seabios). When qemu-kvm runs
with smp_cpus != max_cpus (e.g. -smp 2,maxcpus=4), Seabios will mistakenly use
memory SRAT info for setting up CPU SRAT entries for the offline CPUs. Wrong
SRAT memory entries are also created. This breaks NUMA in a guest.
Fix by setting up SRAT info for max_cpus in qemu-kvm.

Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agokvm: x86: Drop redundant apic base and tpr update from kvm_get_sregs
Jan Kiszka [Wed, 26 Oct 2011 11:09:45 +0000 (13:09 +0200)]
kvm: x86: Drop redundant apic base and tpr update from kvm_get_sregs

The latter was already commented out, the former is redundant as well.
We always get the latest changes after return from the guest via
kvm_arch_post_run.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agokvm: x86: Avoid runtime allocation of xsave buffer
Jan Kiszka [Thu, 27 Oct 2011 17:25:58 +0000 (19:25 +0200)]
kvm: x86: Avoid runtime allocation of xsave buffer

Keep a per-VCPU xsave buffer for kvm_put/get_xsave instead of
continuously allocating and freeing it on state sync.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agokvm: x86: Use symbols for all xsave field
Jan Kiszka [Thu, 27 Oct 2011 17:26:02 +0000 (19:26 +0200)]
kvm: x86: Use symbols for all xsave field

Field 0 (FCW+FSW) and 1 (FTW+FOP) were hard-coded so far.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
12 years agonbd: add myself as maintainer
Paolo Bonzini [Thu, 22 Dec 2011 10:39:19 +0000 (11:39 +0100)]
nbd: add myself as maintainer

Not planning to do much else, hence listing it as "Odd Fixes".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: throttle requests
Paolo Bonzini [Mon, 19 Sep 2011 13:25:40 +0000 (15:25 +0200)]
qemu-nbd: throttle requests

Limiting the number of in-flight requests is implemented very simply
with a can_read callback.  It does not require a semaphore, unlike the
client side in block/nbd.c, because we can throttle directly the creation
of coroutines.  The client side can have a coroutine created at any time
when an I/O request is made.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: asynchronous operation
Paolo Bonzini [Mon, 19 Sep 2011 13:19:27 +0000 (15:19 +0200)]
qemu-nbd: asynchronous operation

Using coroutines enable asynchronous operation on both the network and
the block side.  Network can be owned by two coroutines at the same time,
one writing and one reading.  On the send side, mutual exclusion is
guaranteed by a CoMutex.  On the receive side, mutual exclusion is
guaranteed because new coroutines immediately start receiving data,
and no new coroutines are created as long as the previous one is receiving.

Between receive and send, qemu-nbd can have an arbitrary number of
in-flight block transfers.  Throttling is implemented by the next
patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: add client pointer to NBDRequest
Paolo Bonzini [Fri, 7 Oct 2011 14:47:56 +0000 (16:47 +0200)]
qemu-nbd: add client pointer to NBDRequest

By attaching a client to an NBDRequest, we can avoid passing around the
socket descriptor and data buffer.

Also, we can now manage the reference count for the client in
nbd_request_get/put request instead of having to do it ourselved in
nbd_read.  This simplifies things when coroutines are used.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: move client handling to nbd.c
Paolo Bonzini [Mon, 19 Sep 2011 12:33:23 +0000 (14:33 +0200)]
qemu-nbd: move client handling to nbd.c

This patch sets up the fd handler in nbd.c instead of qemu-nbd.c.  It
introduces NBDClient, which wraps the arguments to nbd_trip in a single
structure, so that we can add a notifier to it.  This way, qemu-nbd can
know about disconnections.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: use common main loop
Paolo Bonzini [Mon, 12 Sep 2011 15:28:11 +0000 (17:28 +0200)]
qemu-nbd: use common main loop

Using a single main loop for sockets will help yielding from the socket
coroutine back to the main loop, and later reentering it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agolink the main loop and its dependencies into the tools
Paolo Bonzini [Mon, 12 Sep 2011 14:20:11 +0000 (16:20 +0200)]
link the main loop and its dependencies into the tools

Using the main loop code from QEMU enables tools to operate fully
asynchronously.  Advantages include better Windows portability (for some
definition of portability) over glib's.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: introduce NBDRequest
Paolo Bonzini [Mon, 19 Sep 2011 12:18:33 +0000 (14:18 +0200)]
qemu-nbd: introduce NBDRequest

Move the buffer from NBDExport to a new structure, so that it will be
possible to have multiple in-flight requests for the same export
(and for the same client too---we get that for free).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: introduce NBDExport
Paolo Bonzini [Mon, 19 Sep 2011 12:03:37 +0000 (14:03 +0200)]
qemu-nbd: introduce NBDExport

Wrap the common parameters of nbd_trip and nbd_negotiate in a
single opaque struct.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: introduce nbd_do_receive_request
Paolo Bonzini [Mon, 19 Sep 2011 13:07:54 +0000 (15:07 +0200)]
qemu-nbd: introduce nbd_do_receive_request

Group the receiving of a response and the associated data into a new function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: more robust handling of invalid requests
Paolo Bonzini [Mon, 19 Sep 2011 14:04:36 +0000 (16:04 +0200)]
qemu-nbd: more robust handling of invalid requests

Fail invalid requests with EINVAL instead of dropping them into
the void.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: introduce nbd_do_send_reply
Paolo Bonzini [Mon, 19 Sep 2011 12:25:30 +0000 (14:25 +0200)]
qemu-nbd: introduce nbd_do_send_reply

Group the sending of a reply and the associated data into a new function.
Without corking, the caller would be forced to leave 12 free bytes at the
beginning of the data pointer.  Not too ugly, but still ugly. :)

Using nbd_do_send_reply everywhere will help when the routine will set up
the write handler that re-enters the send coroutine.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: simplify nbd_trip
Paolo Bonzini [Mon, 19 Sep 2011 11:48:43 +0000 (13:48 +0200)]
qemu-nbd: simplify nbd_trip

Use TCP_CORK to remove a violation of encapsulation, that would later
require nbd_trip to know too much about an NBD reply.

We could also switch to sendmsg (qemu_co_sendv) later, it is even
easier once coroutines are in.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agomove corking functions to osdep.c
Paolo Bonzini [Wed, 21 Sep 2011 10:36:48 +0000 (12:36 +0200)]
move corking functions to osdep.c

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: remove data_size argument to nbd_trip
Paolo Bonzini [Fri, 7 Oct 2011 12:35:58 +0000 (14:35 +0200)]
qemu-nbd: remove data_size argument to nbd_trip

The size of the buffer is in practice part of the protocol.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu-nbd: remove offset argument to nbd_trip
Paolo Bonzini [Mon, 19 Sep 2011 11:50:54 +0000 (13:50 +0200)]
qemu-nbd: remove offset argument to nbd_trip

The argument is write-only.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoUpdate ioctl order in nbd_init() to detect EBUSY
Chunyan Liu [Fri, 2 Dec 2011 15:27:54 +0000 (23:27 +0800)]
Update ioctl order in nbd_init() to detect EBUSY

Update ioctl(s) in nbd_init() to detect device busy early.

Current nbd_init() issues NBD_CLEAR_SOCKET before NBD_SET_SOCKET, if issuing
"qemu-nbd -c /dev/nbd0 disk.img" twice, the second time won't detect EBUSY in
nbd_init(), but in nbd_client will report EBUSY and do clear socket (the 1st
time command will be affacted too because of no socket any more.)

No change to previous version.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: add support for NBD_CMD_TRIM
Paolo Bonzini [Fri, 21 Oct 2011 11:17:14 +0000 (13:17 +0200)]
nbd: add support for NBD_CMD_TRIM

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: add support for NBD_CMD_FLUSH
Paolo Bonzini [Fri, 21 Oct 2011 11:17:14 +0000 (13:17 +0200)]
nbd: add support for NBD_CMD_FLUSH

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: add support for NBD_CMD_FLAG_FUA
Paolo Bonzini [Fri, 21 Oct 2011 11:16:28 +0000 (13:16 +0200)]
nbd: add support for NBD_CMD_FLAG_FUA

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: fix error handling in the server
Paolo Bonzini [Tue, 13 Sep 2011 15:27:45 +0000 (17:27 +0200)]
nbd: fix error handling in the server

bdrv_read and bdrv_write return negative errno values, not -1.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: allow multiple in-flight requests
Paolo Bonzini [Sat, 10 Sep 2011 13:06:52 +0000 (15:06 +0200)]
nbd: allow multiple in-flight requests

Allow sending up to 16 requests, and drive the replies to the coroutine
that did the request.  The code is written to be exactly the same as
before this patch when MAX_NBD_REQUESTS == 1 (modulo the extra mutex
and state).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: split requests
Paolo Bonzini [Sat, 10 Sep 2011 13:06:52 +0000 (15:06 +0200)]
nbd: split requests

qemu-nbd has a limit of slightly less than 1M per request.  Work
around this in the nbd block driver.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agonbd: switch to asynchronous operation
Paolo Bonzini [Thu, 8 Sep 2011 12:28:59 +0000 (14:28 +0200)]
nbd: switch to asynchronous operation

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agosheepdog: move coroutine send/recv function to generic code
Paolo Bonzini [Thu, 8 Sep 2011 11:46:25 +0000 (13:46 +0200)]
sheepdog: move coroutine send/recv function to generic code

Outside coroutines, avoid busy waiting on EAGAIN by temporarily
making the socket blocking.

The API of qemu_recvv/qemu_sendv is slightly different from
do_readv/do_writev because they do not handle coroutines.  It
returns the number of bytes written before encountering an
EAGAIN.  The specificity of yielding on EAGAIN is entirely in
qemu-coroutine.c.

Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-serial-bus: Ports are expected to implement 'have_data' callback
Amit Shah [Wed, 21 Dec 2011 06:58:29 +0000 (12:28 +0530)]
virtio-serial-bus: Ports are expected to implement 'have_data' callback

There's no need to check if ports can accept any incoming data from the
guest each time the guest sends data.  Check if the port implements such
functionality during port initialisation.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agovirtio-console: Properly initialise class methods
Amit Shah [Wed, 21 Dec 2011 06:58:28 +0000 (12:28 +0530)]
virtio-console: Properly initialise class methods

The earlier code really was a hack: initialising class methods in an
object init function as noted by Anthony.

The motivation for that was to not have the virtio-serial-bus call into
the callback functions if there was no chardev backend registered.
However, that really wasn't a worthwhile optimisation, and definitely
not one that was well-implemented.  Get rid of it.

Reported-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agovirtio-console: Check if chardev backends available before calling into them
Amit Shah [Wed, 21 Dec 2011 06:58:27 +0000 (12:28 +0530)]
virtio-console: Check if chardev backends available before calling into them

For the callback functions invoked by the virtio-serial-bus code, check
if we have chardev backends registered before we call into the chardev
functions.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reported-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
12 years agoadd qemu_send_full and qemu_recv_full
Paolo Bonzini [Sat, 17 Sep 2011 14:27:59 +0000 (16:27 +0200)]
add qemu_send_full and qemu_recv_full

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscripts/analyse-9p-simpletrace.py: Add symbolic names for 9p operations.
Harsh Prateek Bora [Wed, 21 Dec 2011 07:07:23 +0000 (12:37 +0530)]
scripts/analyse-9p-simpletrace.py: Add symbolic names for 9p operations.

Currently, we just print the numerical value of 9p operation identifier in
case of RERROR which is less meaningful for readability. Mapping 9p
operation ids to symbolic names provides a better tracelog:

RERROR (tag = 1 , id = TWALK , err = " No such file or directory ")
RERROR (tag = 1 , id = TUNLINKAT , err = " Directory not empty ")

This patch provides a dictionary of all possible 9p operation symbols mapped
to their numerical identifiers which are likely to be used in future at
various places in this script.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: iattr_valid flags are kernel internal flags map them to 9p values.
Aneesh Kumar K.V [Wed, 21 Dec 2011 07:07:23 +0000 (12:37 +0530)]
hw/9pfs: iattr_valid flags are kernel internal flags map them to 9p values.

Kernel internal values can change, add protocol values for these constant and
use them.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: Use the correct signed type for different variables
Aneesh Kumar K.V [Wed, 21 Dec 2011 07:07:23 +0000 (12:37 +0530)]
hw/9pfs: Use the correct signed type for different variables

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agohw/9pfs: replace iovec manipulation with QEMUIOVector
Stefan Hajnoczi [Wed, 21 Dec 2011 07:07:22 +0000 (12:37 +0530)]
hw/9pfs: replace iovec manipulation with QEMUIOVector

The v9fs_read() and v9fs_write() functions rely on iovec[] manipulation
code should be replaced with QEMUIOVector to avoid duplicating code.
In the future it may be possible to make the code even more concise by
using QEMUIOVector consistently across virtio and 9pfs.

The "v" format specifier for pdu_marshal() and pdu_unmarshal() is
dropped since it does not actually pack/unpack anything.  The specifier
was also not implemented to update the offset variable and could only be
used at the end of a format string, another sign that this shouldn't
really be a format specifier.  Instead, see the new
v9fs_init_qiov_from_pdu() function.

This change avoids a possible iovec[] buffer overflow when indirect
vrings are used since the number of vectors is now limited by the
underlying VirtQueueElement and cannot be out-of-bounds.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
12 years agosd: Remember to reset .expecting_acmd on reset.
Andrzej Zaborowski [Wed, 21 Dec 2011 04:04:21 +0000 (05:04 +0100)]
sd: Remember to reset .expecting_acmd on reset.

Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: Clear status bits when read via response r6
Peter Maydell [Sun, 18 Dec 2011 20:38:00 +0000 (21:38 +0100)]
hw/sd.c: Clear status bits when read via response r6

Response format r6 includes a subset of the status bits;
clear the clear-on-read bits which are read by an r6 response.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: Correct handling of APP_CMD status bit
Peter Maydell [Sun, 18 Dec 2011 20:37:59 +0000 (21:37 +0100)]
hw/sd.c: Correct handling of APP_CMD status bit

Fix some bugs in our implementation of the APP_CMD status bit:
 * the response to an ACMD should have APP_CMD set, not cleared
 * if an illegal ACMD is sent then the next command should be
   handled as a normal command

This requires that we split "card is expecting an ACMD" from
the state of the APP_CMD status bit (the latter indicates
both "expecting ACMD" and "that was an ACMD").

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: Correct handling of type B SD status bits
Peter Maydell [Sun, 18 Dec 2011 20:37:58 +0000 (21:37 +0100)]
hw/sd.c: Correct handling of type B SD status bits

Correct how we handle the type B ("cleared on valid command")
status bits. In particular, the CURRENT_STATE bits in a response
should be the state of the card when it received that command,
not the state when it received the preceding command. (This is
one of the issues noted in LP:597641.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: Set ILLEGAL_COMMAND for ACMDs in invalid state
Peter Maydell [Sun, 18 Dec 2011 20:37:57 +0000 (21:37 +0100)]
hw/sd.c: Set ILLEGAL_COMMAND for ACMDs in invalid state

App commands in an invalid state should set ILLEGAL_COMMAND, not
merely return a zero response.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: Handle CRC and locked-card errors in normal code path
Peter Maydell [Sun, 18 Dec 2011 20:37:56 +0000 (21:37 +0100)]
hw/sd.c: Handle CRC and locked-card errors in normal code path

Handle returning CRC and locked-card errors in the same code path
we use for other responses. This makes no difference in behaviour
but means that these error responses will be printed by the debug
logging code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: Handle illegal commands in sd_do_command
Peter Maydell [Sun, 18 Dec 2011 20:37:55 +0000 (21:37 +0100)]
hw/sd.c: Handle illegal commands in sd_do_command

Add an extra sd_illegal value to the sd_rsp_type_t enum so that
sd_app_command() and sd_normal_command() can tell sd_do_command()
that the command was illegal. This is needed so we can do things
like reset certain status bits only on receipt of a valid command.
For the moment, just use it to pull out the setting of the
ILLEGAL_COMMAND status bit into sd_do_command().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
12 years agohw/sd.c: When setting ADDRESS_ERROR bit, don't clear everything else
Peter Maydell [Sun, 18 Dec 2011 20:37:54 +0000 (21:37 +0100)]
hw/sd.c: When setting ADDRESS_ERROR bit, don't clear everything else

Fix a typo that meant that ADDRESS_ERRORs setting or clearing write
protection would clear every other bit in the status register.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>