[Qemu-devel] buildbot failure in qemu on ppc-next_x86_64_debian_6_0

2012-05-04 Thread qemu
The Buildbot has detected a new failure on builder ppc-next_x86_64_debian_6_0 
while building qemu.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu/builders/ppc-next_x86_64_debian_6_0/builds/263

Buildbot URL: http://buildbot.b1-systems.de/qemu/

Buildslave for this Build: yuzuki

Build Reason: The Nightly scheduler named 'nightly_ppc-next' triggered this 
build
Build Source Stamp: [branch ppc-next] HEAD
Blamelist: 

BUILD FAILED: failed git

sincerely,
 -The Buildbot



Re: [Qemu-devel] [PATCH 1.1] scsi: Add assertion for use-after-free errors

2012-05-04 Thread Paolo Bonzini
Il 03/05/2012 22:58, Stefan Weil ha scritto:
 Am 03.05.2012 19:36, schrieb Stefan Weil:
 The QEMU emulation which is currently used with Raspberry PI images
 (qemu-system-arm -M versatilepb ...) accesses memory which was freed.

 Valgrind output (extract):

 ==17857== Invalid write of size 4
 ==17857== at 0x24EB06: scsi_req_unref (scsi-bus.c:1273)
 ==17857== by 0x24FFAE: scsi_read_complete (scsi-disk.c:277)
 ==17857== by 0x152ACC: bdrv_co_em_bh (block.c:3363)
 ==17857== by 0x13D49C: qemu_bh_poll (async.c:71)
 ==17857== by 0x211A8C: main_loop_wait (main-loop.c:503)
 ==17857== by 0x207954: main_loop (vl.c:1555)
 ==17857== by 0x20E9C9: main (vl.c:3653)
 ==17857== Address 0x1c54383c is 12 bytes inside a block of size 260
 free'd
 ==17857== at 0x4824B3A: free (vg_replace_malloc.c:366)
 ==17857== by 0x20ADFA: free_and_trace (vl.c:2250)
 ==17857== by 0x4899FC5: g_free (in /lib/libglib-2.0.so.0.2400.1)
 ==17857== by 0x24EB3B: scsi_req_unref (scsi-bus.c:1277)
 ==17857== by 0x24F003: scsi_req_complete (scsi-bus.c:1383)
 ==17857== by 0x25022A: scsi_read_data (scsi-disk.c:334)
 ==17857== by 0x24EB9F: scsi_req_continue (scsi-bus.c:1289)
 ==17857== by 0x1C7787: lsi_do_dma (lsi53c895a.c:575)
 ==17857== by 0x1C8CDA: lsi_execute_script (lsi53c895a.c:1147)
 ==17857== by 0x1C74EA: lsi_resume_script (lsi53c895a.c:510)
 ==17857== by 0x1C7ECD: lsi_transfer_data (lsi53c895a.c:746)
 ==17857== by 0x24EC90: scsi_req_data (scsi-bus.c:1307)

Yes, this was reported by David Gibson too.  Interesting that
virtio-scsi doesn't show it, probably it's the sglist support that hides
it.  I queued the fix and I'm sending the pull request in a matter of
minutes.  The patch is a good addition so I queued it too, thanks.

Paolo



Re: [Qemu-devel] [Bug 990364] Re: virtio_ioport_write: unexpected address 0x13 value 0x1

2012-05-04 Thread Alon Levy
On Thu, May 03, 2012 at 12:16:57PM -, vrozenfe wrote:
 On Monday, April 30, 2012 07:17:09 PM Vadim Rozenfeld wrote:
  On Monday, April 30, 2012 03:31:03 PM Stefan Hajnoczi wrote:
   Hi Vadim,
   Here is a recent bug report with virtio-win-0.1-22.iso.  Wanted to
   bring it to your attention, please let me know if you already monitor
   these bug emails.
  
  Hi Stefan,
  Yes, it's on my radar.
  Cheers,
  Vadim.
  
 seems to be ndis related 
 (https://bugzilla.redhat.com/show_bug.cgi?id=808654#c10)
 cc'ing Yan.

I get the same error with a vm that is virtio-net free:
qemu-system-x86_64 -chardev stdio,id=muxstdio,mux=on -mon 
chardev=muxstdio,mode=readline -vga qxl -drive 
file=/images/win7_squashed_earth.img,cache=unsafe,if=virtio,readonly=off 
-enable-kvm -L /home/alon/spice/upstream/share/qemu -m 2048 -cpu host -spice 
disable-ticketing,port=10001 -snapshot -no-shutdown -smp 2 -global 
qxl-vga.debug=1 -usb -device virtio-serial,multifunction=on -chardev 
spicevmc,name=vdagent,id=vdagent -device 
virtserialport,chardev=vdagent,name=com.redhat.spice.0 -net none

I get it during bootup sometimes:
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 13 for device 
virtio-serial-bus.0

or
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 2324003424 for device 
virtio-serial-bus.0
(0x8a857a60)

And also using a batch script to repeatedly disable and enable the
device, either with restarting the vdagent service or without.

With: endless-toggle-vdservice.bat
:loop
net stop vdservice
devcon disable PCI\VEN_1AF4DEV_1003
devcon enable PCI\VEN_1AF4DEV_1003
net start vdservice
goto :loop

I get some different error message as well:

qemu-system-x86_64: virtio-serial-bus: Guest failure in adding device 
virtio-serial-bus.0

But also the Unexpected port one:

qemu-system-x86_64: virtio-serial-bus: Unexpected port id 2351381636 for device 
virtio-serial-bus.0
(0x8c273c84)

The numbers are random:
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 295259532 for device 
virtio-serial-bus.0
(0x11994d8c)
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 2671983748 for device 
virtio-serial-bus.0
(0x9f433c84)

And a lot of time it does work.

Without: endless-toggle-virtio.bat
:loop
devcon disable PCI\VEN_1AF4DEV_1003
devcon enable PCI\VEN_1AF4DEV_1003
goto :loop
(this takes a *lot* of iterations to reproduce - ~20 success for 1
failure. Probably worth looking at the exact number)

qemu-system-x86_64: virtio-serial-bus: Guest failure in adding device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 4 for device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Guest failure in adding device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 13 for device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Guest failure in adding device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Unexpected port id 13 for device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Guest failure in adding device 
virtio-serial-bus.0
qemu-system-x86_64: virtio-serial-bus: Guest failure in adding device 
virtio-serial-bus.0


 
   Stefan
   
   On Sat, Apr 28, 2012 at 9:49 AM, Vitalis wor...@gmail.com wrote:
Public bug reported:

Hello! I have:

virtio_ioport_write: unexpected address 0x13 value 0x1

on config:

LC_ALL=C
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.12 -cpu qemu32 -enable-kvm
-m 3072 -smp 1 -name nata_xp -uuid da607499-1d8f-e7ef-d1d2-38
1c1839e4ba -chardev
socket,id=monitor,path=/var/lib/libvirt/qemu/nata_xp.monitor,server,now
a it -monitor chardev:monitor -localtime -boot c -drive
file=/root/nata_xp.qcow2,if=virtio,index=0,boot=on,format=raw
,cache=none -drive
file=/home/admino/virtio-win-0.1-22.iso,if=ide,media=cdrom,index=2,form
a t=raw -net
nic,macaddr=00:16:36:06:02:69,vlan=0,model=virtio,name=virtio.0 -net
tap,fd=43,vlan=0,name=tap.0 -serial none -parallel none -usb -usbdevice
tablet -vnc 127.0.0.1:3 -k en-us -vga cirrus pci_add_option_rom: failed
to find romfile pxe-virtio.bin

with kernel 2.6.32-40-generic #87-Ubuntu SMP Tue Mar 6 00:56:56 UTC
2012 x86_64 GNU/Linux qemu drivers are virtio-win-0.1-22.iso
kvm version 1:84+dfsg-0ubuntu16+0.12.3+noroms+0ubuntu9.18
qemu 0.12.3+noroms-0ubuntu9.18

** Affects: qemu

Importance: Undecided

Status: New

** Tags: bug kvm virtio

--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/990364

Title:
 virtio_ioport_write: unexpected address 0x13 value 0x1

Status in QEMU:
 New

Bug description:
 Hello! I have:
 
 virtio_ioport_write: unexpected address 0x13 value 0x1
 
 on 

Re: [Qemu-devel] [PATCH] ISCSI: Add support for thin-provisioning via discard/UNMAP and bigger LUNs

2012-05-04 Thread Paolo Bonzini
Il 24/04/2012 08:29, Ronnie Sahlberg ha scritto:
 +itask-bs-total_sectors= rc16-returned_lba *
 +   rc16-block_length / BDRV_SECTOR_SIZE ;

Ronnie, does this need to be (rc16-returned_lba + 1) * ...?

READ CAPACITY returns the highest valid LBA, not the size.

Please send a patch to fix this up if that's the case.

Paolo



Re: [Qemu-devel] [PATCH] ISCSI: Add support for thin-provisioning via discard/UNMAP and bigger LUNs

2012-05-04 Thread ronnie sahlberg
On Fri, May 4, 2012 at 6:06 PM, Paolo Bonzini pbonz...@redhat.com wrote:
 Il 24/04/2012 08:29, Ronnie Sahlberg ha scritto:
 +    itask-bs-total_sectors    = rc16-returned_lba *
 +                               rc16-block_length / BDRV_SECTOR_SIZE ;

 Ronnie, does this need to be (rc16-returned_lba + 1) * ...?

 READ CAPACITY returns the highest valid LBA, not the size.

 Please send a patch to fix this up if that's the case.


Absolutely. A patch is on its way.
This is probably the third time I have made the same mistake of
RC10/16 returns the lba of last block, not the number of blocks.
I think READCAPACITY is just not compatible with my brain here.


regards
ronnie sahlberg



[Qemu-devel] [PATCH] Fix incorrect calculation of iscsi number of blocks

2012-05-04 Thread Ronnie Sahlberg

List,

READCAPACITY16 returns the LBA of the last accessible block.
Number of blocks is one greater than this.

This patch fixes the incorrect calculation of total sectors that Paolo spotted 
and reported. Sorry,


regards
ronnie sahlberg




[Qemu-devel] [PATCH] ISCSI: Readcapacity retruned the lba of the last sector. Total number of sectors is one more.

2012-05-04 Thread Ronnie Sahlberg
Thanks to Paolo for spotting.

Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
---
 block/iscsi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index eb49093..7c1970d 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -482,7 +482,7 @@ iscsi_readcapacity16_cb(struct iscsi_context *iscsi, int 
status,
 
 itask-iscsilun-block_size = rc16-block_length;
 itask-iscsilun-num_blocks = rc16-returned_lba;
-itask-bs-total_sectors= rc16-returned_lba *
+itask-bs-total_sectors= (rc16-returned_lba + 1) *
rc16-block_length / BDRV_SECTOR_SIZE ;
 
 itask-status   = 0;
-- 
1.7.3.1




[Qemu-devel] [seabios patch 2/5] acpi: add qemu fwcfg driver

2012-05-04 Thread Gerd Hoffmann
Add a acpi driver for the qemu firmware config interface.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 src/acpi-dsdt.dsl |   43 +++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl
index 4a18617..d71b783 100644
--- a/src/acpi-dsdt.dsl
+++ b/src/acpi-dsdt.dsl
@@ -445,6 +445,49 @@ DefinitionBlock (
Return (BUF0)
}
}
+
+   /* qemu firmware config interface */
+   Device (FWC)
+   {
+   Name (_HID, EisaId (FWC0510))
+   OperationRegion (FWCD, SystemIO, 0x0510, 0x02)
+   Field (FWCD, WordAcc, NoLock, Preserve)
+   {
+   FWCS, 16,  /* select */
+   }
+   Field (FWCD, ByteAcc, NoLock, Preserve)
+   {
+   FWCW, 8,   /* write */
+   FWCR, 8,   /* read */
+   }
+Name (_CRS, ResourceTemplate ()
+   {
+   IO (Decode16, 0x0510, 0x0510, 0x01, 0x02)
+   })
+
+   /* fetch fw_cfg entry, args: entry nr, length */
+   Method (FWCB, 2) {
+   Name (RETB, Buffer(Arg1) { })
+   Store (Arg0, FWCS)
+   Store (Zero, Local0)
+   While (LLess(Local0, Arg1)) {
+   Store (FWCR, Index(RETB, Local0))
+   Increment(Local0)
+   }
+   Return (RETB)
+   }
+
+   /* fetch signature  verify */
+   Method (_STA, 0, NotSerialized)
+   {
+   Store(ToString(FWCB(0, 4)), Local0)
+   If (LEqual (Local0, QEMU)) {
+   Return (0x0f)
+   } Else {
+   Return (0x00)
+   }
+}
+   }
 }
 
 
-- 
1.7.1




[Qemu-devel] [seabios patch 3/5] acpi: update pci io windows according to fw_cfg info

2012-05-04 Thread Gerd Hoffmann
This patch makes the pci ressources runtime configurable.  The patch
fetches the pci window information from the qemu firmware config
interface and in case valid data is found there the ressource entries
are updated accordingly.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 src/acpi-dsdt.dsl |   38 +++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl
index d71b783..4e6c2ad 100644
--- a/src/acpi-dsdt.dsl
+++ b/src/acpi-dsdt.dsl
@@ -132,7 +132,7 @@ DefinitionBlock (
 B0EJ, 32,
 }
 
-Name (_CRS, ResourceTemplate ()
+Name (CRES, ResourceTemplate ()
 {
 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
 0x, // Address Space Granularity
@@ -174,15 +174,47 @@ DefinitionBlock (
 0xFEBF, // Address Range Maximum
 0x, // Address Translation Offset
 0x1EC0, // Address Length
-,, , AddressRangeMemory, TypeStatic)
+,, PW32, AddressRangeMemory, TypeStatic)
 QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, 
Cacheable, ReadWrite,
 0x,  // Address Space Granularity
 0x80,// Address Range Minimum
 0xFF,// Address Range Maximum
 0x,  // Address Translation Offset
 0x80,// Address Length
-,, , AddressRangeMemory, TypeStatic)
+,, PW64, AddressRangeMemory, TypeStatic)
 })
+Method (_INI, 0)
+{
+   Store (\_SB.PCI0.ISA.FWC.FWCB(0x1a, 64), Local0)
+   CreateQWordField (Local0,  0, QW0)
+   CreateQWordField (Local0,  8, QW1)
+   CreateQWordField (Local0, 16, QW2)
+   CreateQWordField (Local0, 24, QW3)
+
+   /* 32bit pci io window */
+   If (LAnd (LNotEqual(QW0, 0), LNotEqual(QW1, 0))) {
+   CreateDWordField (CRES,\_SB.PCI0.PW32._MIN, PS32)
+   CreateDWordField (CRES,\_SB.PCI0.PW32._MAX, PE32)
+   CreateDWordField (CRES,\_SB.PCI0.PW32._LEN, PL32)
+   Store (QW0, PS32)
+   Store (QW1, PE32)
+   Subtract (QW1, QW0, PL32)
+   }
+
+   /* 64bit pci io window */
+   If (LAnd (LNotEqual(QW2, 0), LNotEqual(QW3, 0))) {
+   CreateQWordField (CRES,\_SB.PCI0.PW64._MIN, PS64)
+   CreateQWordField (CRES,\_SB.PCI0.PW64._MAX, PE64)
+   CreateQWordField (CRES,\_SB.PCI0.PW64._LEN, PL64)
+   Store (QW2, PS64)
+   Store (QW3, PE64)
+   Subtract (QW3, QW2, PL64)
+   }
+   }
+Method (_CRS, 0)
+{
+   Return (CRES)
+   }
 }
 }
 
-- 
1.7.1




[Qemu-devel] [seabios patch 5/5] update src/acpi-dsdt.hex

2012-05-04 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 src/acpi-dsdt.hex |  420 +++--
 1 files changed, 410 insertions(+), 10 deletions(-)

diff --git a/src/acpi-dsdt.hex b/src/acpi-dsdt.hex
index 07f0e18..16b3e37 100644
--- a/src/acpi-dsdt.hex
+++ b/src/acpi-dsdt.hex
@@ -3,12 +3,12 @@ static unsigned char AmlCode[] = {
 0x53,
 0x44,
 0x54,
-0x4f,
-0x11,
+0xdf,
+0x12,
 0x0,
 0x0,
 0x1,
-0xca,
+0x9,
 0x42,
 0x58,
 0x50,
@@ -110,16 +110,16 @@ static unsigned char AmlCode[] = {
 0x47,
 0x42,
 0x10,
-0x42,
-0x84,
+0x4e,
+0x92,
 0x5f,
 0x53,
 0x42,
 0x5f,
 0x5b,
 0x82,
-0x4a,
-0x83,
+0x46,
+0x92,
 0x50,
 0x43,
 0x49,
@@ -2059,9 +2059,9 @@ static unsigned char AmlCode[] = {
 0x4a,
 0x20,
 0x8,
-0x5f,
 0x43,
 0x52,
+0x45,
 0x53,
 0x11,
 0x40,
@@ -2224,6 +2224,242 @@ static unsigned char AmlCode[] = {
 0x0,
 0x79,
 0x0,
+0x14,
+0x4f,
+0xd,
+0x5f,
+0x49,
+0x4e,
+0x49,
+0x0,
+0x70,
+0x5e,
+0x2f,
+0x3,
+0x49,
+0x53,
+0x41,
+0x5f,
+0x46,
+0x57,
+0x43,
+0x5f,
+0x46,
+0x57,
+0x43,
+0x42,
+0xa,
+0x1a,
+0xa,
+0x40,
+0x60,
+0x8f,
+0x60,
+0x0,
+0x51,
+0x57,
+0x30,
+0x5f,
+0x8f,
+0x60,
+0xa,
+0x8,
+0x51,
+0x57,
+0x31,
+0x5f,
+0x8f,
+0x60,
+0xa,
+0x10,
+0x51,
+0x57,
+0x32,
+0x5f,
+0x8f,
+0x60,
+0xa,
+0x18,
+0x51,
+0x57,
+0x33,
+0x5f,
+0xa0,
+0x41,
+0x5,
+0x90,
+0x92,
+0x93,
+0x51,
+0x57,
+0x30,
+0x5f,
+0x0,
+0x92,
+0x93,
+0x51,
+0x57,
+0x31,
+0x5f,
+0x0,
+0x8a,
+0x43,
+0x52,
+0x45,
+0x53,
+0xa,
+0x5c,
+0x50,
+0x53,
+0x33,
+0x32,
+0x8a,
+0x43,
+0x52,
+0x45,
+0x53,
+0xa,
+0x60,
+0x50,
+0x45,
+0x33,
+0x32,
+0x8a,
+0x43,
+0x52,
+0x45,
+0x53,
+0xa,
+0x68,
+0x50,
+0x4c,
+0x33,
+0x32,
+0x70,
+0x51,
+0x57,
+0x30,
+0x5f,
+0x50,
+0x53,
+0x33,
+0x32,
+0x70,
+0x51,
+0x57,
+0x31,
+0x5f,
+0x50,
+0x45,
+0x33,
+0x32,
+0x74,
+0x51,
+0x57,
+0x31,
+0x5f,
+0x51,
+0x57,
+0x30,
+0x5f,
+0x50,
+0x4c,
+0x33,
+0x32,
+0xa0,
+0x41,
+0x5,
+0x90,
+0x92,
+0x93,
+0x51,
+0x57,
+0x32,
+0x5f,
+0x0,
+0x92,
+0x93,
+0x51,
+0x57,
+0x33,
+0x5f,
+0x0,
+0x8f,
+0x43,
+0x52,
+0x45,
+0x53,
+0xa,
+0x7a,
+0x50,
+0x53,
+0x36,
+0x34,
+0x8f,
+0x43,
+0x52,
+0x45,
+0x53,
+0xa,
+0x82,
+0x50,
+0x45,
+0x36,
+0x34,
+0x8f,
+0x43,
+0x52,
+0x45,
+0x53,
+0xa,
+0x92,
+0x50,
+0x4c,
+0x36,
+0x34,
+0x70,
+0x51,
+0x57,
+0x32,
+0x5f,
+0x50,
+0x53,
+0x36,
+0x34,
+0x70,
+0x51,
+0x57,
+0x33,
+0x5f,
+0x50,
+0x45,
+0x36,
+0x34,
+0x74,
+0x51,
+0x57,
+0x33,
+0x5f,
+0x51,
+0x57,
+0x32,
+0x5f,
+0x50,
+0x4c,
+0x36,
+0x34,
+0x14,
+0xb,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x0,
+0xa4,
+0x43,
+0x52,
+0x45,
+0x53,
 0x10,
 0x4b,
 0x9,
@@ -2517,8 +2753,8 @@ static unsigned char AmlCode[] = {
 0xa,
 0x4,
 0x10,
-0x47,
-0x22,
+0x4b,
+0x2c,
 0x2f,
 0x3,
 0x5f,
@@ -3068,6 +3304,170 @@ static unsigned char AmlCode[] = {
 0x55,
 0x46,
 0x30,
+0x5b,
+0x82,
+0x42,
+0xa,
+0x46,
+0x57,
+0x43,
+0x5f,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xc,
+0x1a,
+0xe3,
+0x5,
+0x10,
+0x5b,
+0x80,
+0x46,
+0x57,
+0x43,
+0x44,
+0x1,
+0xb,
+0x10,
+0x5,
+0xa,
+0x2,
+0x5b,
+0x81,
+0xb,
+0x46,
+0x57,
+0x43,
+0x44,
+0x2,
+0x46,
+0x57,
+0x43,
+0x53,
+0x10,
+0x5b,
+0x81,
+0x10,
+0x46,
+0x57,
+0x43,
+0x44,
+0x1,
+0x46,
+0x57,
+0x43,
+0x57,
+0x8,
+0x46,
+0x57,
+0x43,
+0x52,
+0x8,
+0x8,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x11,
+0xd,
+0xa,
+0xa,
+0x47,
+0x1,
+0x10,
+0x5,
+0x10,
+0x5,
+0x1,
+0x2,
+0x79,
+0x0,
+0x14,
+0x2f,
+0x46,
+0x57,
+0x43,
+0x42,
+0x2,
+0x8,
+0x52,
+0x45,
+0x54,
+0x42,
+0x11,
+0x2,
+0x69,
+0x70,
+0x68,
+0x46,
+0x57,
+0x43,
+0x53,
+0x70,
+0x0,
+0x60,
+0xa2,
+0x12,
+0x95,
+0x60,
+0x69,
+0x70,
+0x46,
+0x57,
+0x43,
+0x52,
+0x88,
+0x52,
+0x45,
+0x54,
+0x42,
+0x60,
+0x0,
+0x75,
+0x60,
+0xa4,
+0x52,
+0x45,
+0x54,
+0x42,
+0x14,
+0x23,
+0x5f,
+0x53,
+0x54,
+0x41,
+0x0,
+0x70,
+0x9c,
+0x46,
+0x57,
+0x43,
+0x42,
+0x0,
+0xa,
+0x4,
+0xff,
+0x0,
+0x60,
+0xa0,
+0xc,
+0x93,
+0x60,
+0xd,
+0x51,
+0x45,
+0x4d,
+0x55,
+0x0,
+0xa4,
+0xa,
+0xf,
+0xa1,
+0x3,
+0xa4,
+0x0,
 0x10,
 0x4d,
 0x5,
-- 
1.7.1




[Qemu-devel] [seabios patch 4/5] pciinit: make pci ressources configurable

2012-05-04 Thread Gerd Hoffmann
Try to get the pci window information from the qemu firmware config
interface and use them if available, otherwise fall back to the compile
time defaults.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 src/paravirt.c |8 
 src/paravirt.h |2 ++
 src/pciinit.c  |   29 -
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/paravirt.c b/src/paravirt.c
index 9cf77de..61ed086 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -305,6 +305,14 @@ u16 qemu_cfg_get_max_cpus(void)
 return cnt;
 }
 
+void qemu_cfg_get_pci_windows(u64 *pcimem)
+{
+if (!qemu_cfg_present)
+return;
+
+qemu_cfg_read_entry(pcimem, QEMU_CFG_PCI_WINDOWS, 64);
+}
+
 static QemuCfgFile LastFile;
 
 static u32
diff --git a/src/paravirt.h b/src/paravirt.h
index f39e226..6dc8ede 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -35,6 +35,7 @@ static inline int kvm_para_available(void)
 #define QEMU_CFG_BOOT_MENU  0x0e
 #define QEMU_CFG_MAX_CPUS   0x0f
 #define QEMU_CFG_FILE_DIR   0x19
+#define QEMU_CFG_PCI_WINDOWS0x1a
 #define QEMU_CFG_ARCH_LOCAL 0x8000
 #define QEMU_CFG_ACPI_TABLES(QEMU_CFG_ARCH_LOCAL + 0)
 #define QEMU_CFG_SMBIOS_ENTRIES (QEMU_CFG_ARCH_LOCAL + 1)
@@ -57,6 +58,7 @@ int qemu_cfg_smbios_load_external(int type, char **p, 
unsigned *nr_structs,
 int qemu_cfg_get_numa_nodes(void);
 void qemu_cfg_get_numa_data(u64 *data, int n);
 u16 qemu_cfg_get_max_cpus(void);
+void qemu_cfg_get_pci_windows(u64 *pcimem);
 
 typedef struct QemuCfgFile {
 u32  size;/* file size */
diff --git a/src/pciinit.c b/src/pciinit.c
index 6a7a0d2..52c5b69 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -11,6 +11,7 @@
 #include pci_ids.h // PCI_VENDOR_ID_INTEL
 #include pci_regs.h // PCI_COMMAND
 #include xen.h // usingXen
+#include paravirt.h // qemu_cfg_get_pci_windows
 
 #define PCI_DEVICE_MEM_MIN 0x1000
 #define PCI_BRIDGE_IO_MIN  0x1000
@@ -29,6 +30,12 @@ static const char *region_type_name[] = {
 [ PCI_REGION_TYPE_PREFMEM ] = prefmem,
 };
 
+static u64 pcimem[4];
+static u64 pcimem_start   = BUILD_PCIMEM_START;
+static u64 pcimem_end = BUILD_PCIMEM_END;
+static u64 pcimem64_start = BUILD_PCIMEM64_START;
+static u64 pcimem64_end   = BUILD_PCIMEM64_END;
+
 struct pci_region_entry {
 struct pci_device *dev;
 int bar;
@@ -511,13 +518,13 @@ static int pci_bios_init_root_regions(struct pci_bus *bus)
 }
 u64 sum = pci_region_sum(r_end);
 u64 align = pci_region_align(r_end);
-r_end-base = ALIGN_DOWN((BUILD_PCIMEM_END - sum), align);
+r_end-base = ALIGN_DOWN((pcimem_end - sum), align);
 sum = pci_region_sum(r_start);
 align = pci_region_align(r_start);
 r_start-base = ALIGN_DOWN((r_end-base - sum), align);
 
-if ((r_start-base  BUILD_PCIMEM_START) ||
- (r_start-base  BUILD_PCIMEM_END))
+if ((r_start-base  pcimem_start) ||
+ (r_start-base  pcimem_end))
 // Memory range requested is larger than available.
 return -1;
 return 0;
@@ -595,11 +602,11 @@ static void pci_bios_map_devices(struct pci_bus *busses)
 if (pci_bios_init_root_regions(busses))
 panic(PCI: out of 32bit address space\n);
 
-r64_mem.base = BUILD_PCIMEM64_START;
+r64_mem.base = pcimem64_start;
 u64 sum = pci_region_sum(r64_mem);
 u64 align = pci_region_align(r64_pref);
 r64_pref.base = ALIGN(r64_mem.base + sum, align);
-if (r64_pref.base + pci_region_sum(r64_pref)  BUILD_PCIMEM64_END)
+if (r64_pref.base + pci_region_sum(r64_pref)  pcimem64_end)
 panic(PCI: out of 64bit address space\n);
 pci_region_map_entries(busses, r64_mem);
 pci_region_map_entries(busses, r64_pref);
@@ -629,6 +636,18 @@ pci_setup(void)
 
 dprintf(3, pci setup\n);
 
+qemu_cfg_get_pci_windows(pcimem);
+if (pcimem[0]  pcimem[1]) {
+pcimem_start = pcimem[0];
+pcimem_end = pcimem[1] + 1;
+dprintf(1, 32bit pci window: %llx - %llx\n, pcimem_start, 
pcimem_end);
+}
+if (pcimem[2]  pcimem[3]) {
+pcimem64_start = pcimem[2];
+pcimem64_end = pcimem[3] + 1;
+dprintf(1, 64bit pci window: %llx - %llx\n, pcimem64_start, 
pcimem64_end);
+}
+
 dprintf(1, === PCI bus  bridge init ===\n);
 if (pci_probe_host() != 0) {
 return;
-- 
1.7.1




[Qemu-devel] [seabios patch 0/5] dynamic pci i/o windows

2012-05-04 Thread Gerd Hoffmann
  Hi,

This patch series makes the PCI I/O windows runtime-configurable via
qemu firmware config interface.  Main advantage is that we can size and
shuffle around the PCI i/O windows according to the amount of memory the
virtual machine has.  We don't need a hole for 64bit PCI bars, we can
just map them above the main memory.  The hole for 32bit PCI bars can be
enlarged for guests with less than 3.5 GB of memory.

Oh, and the pci device initialization fix is there too ;)

cheers,
  Gerd

Gerd Hoffmann (5):
  pci: init all devices
  acpi: add qemu fwcfg driver
  acpi: update pci io windows according to fw_cfg info
  pciinit: make pci ressources configurable
  update src/acpi-dsdt.hex

 src/acpi-dsdt.dsl |   81 ++-
 src/acpi-dsdt.hex |  420 +++--
 src/paravirt.c|8 +
 src/paravirt.h|2 +
 src/pciinit.c |   32 +++-
 5 files changed, 522 insertions(+), 21 deletions(-)




Re: [Qemu-devel] [PATCH] ISCSI: Readcapacity retruned the lba of the last sector. Total number of sectors is one more.

2012-05-04 Thread Paolo Bonzini
Il 04/05/2012 10:15, Ronnie Sahlberg ha scritto:
  itask-iscsilun-num_blocks = rc16-returned_lba;
 -itask-bs-total_sectors= rc16-returned_lba *
 +itask-bs-total_sectors= (rc16-returned_lba + 1) *

What about itask-iscsilun-num_blocks? :)  No need to resend, I fixed
this locally.



[Qemu-devel] [PULL 00/14] SCSI changes for 1.1

2012-05-04 Thread Paolo Bonzini
Anthony,

the following changes since commit f05ae5379e40f81a6c8526d891693af8bf6e62da:

  Bail out if CONFIG_TCG_PASS_AREG0 is defined (2012-05-03 15:48:49 +0400)

are available in the git repository at:

  git://github.com/bonzini/qemu.git scsi-next

for you to fetch changes up to 537b10a444015fb6b01150f2ec7425a61472c621:

  scsi: Add assertion for use-after-free errors (2012-05-04 10:29:31 +0200)

With the patches, scsi-testsuite passes.


Paolo Bonzini (11):
  scsi: prevent data transfer overflow
  scsi: fix refcounting for reads
  scsi: fix WRITE SAME transfer length and direction
  scsi: change removable field to host many features
  scsi-disk: add dpofua property
  scsi: do not report bogus overruns for commands in the 0x00-0x1F range
  scsi: parse 16-byte tape CDBs
  scsi: do not require a minimum allocation length for INQUIRY
  scsi: do not require a minimum allocation length for REQUEST SENSE
  scsi: set VALID bit to 0 in fixed format sense data
  scsi: remove useless debug messages

Ronnie Sahlberg (2):
  ISCSI: Add support for thin-provisioning via discard/UNMAP and bigger LUNs
  scsi: Specify the xfer direction for UNMAP and ATA_PASSTHROUGH commands

Stefan Weil (1):
  scsi: Add assertion for use-after-free errors

 block/iscsi.c  |   86 
 configure  |5 ++-
 hw/scsi-bus.c  |  100 ++--
 hw/scsi-defs.h |1 +
 hw/scsi-disk.c |   66 ++---
 5 files changed, 171 insertions(+), 87 deletions(-)
-- 
1.7.9.3




Re: [Qemu-devel] [PATCH 2/3] runstate: introduce suspended state

2012-05-04 Thread Gerd Hoffmann
  Hi,

 However, I've ran into a different issue today: migrating while suspended
 doesn't work. The target VM seems to be locked into S3, it just doesn't 
 resume.
 
 Haven't investigated yet, but this is expected to work, right?

Well, that one is still on the todo list.  There is the temporary
stopgap to just resume the machine before migration so we don't have to
migrate the is_suspended bit (not merged).

I plan to fix that properly, it needs some discussion to figure a sane
way as we don't have a vmstate section for global state like this where
we could attach a subsection to.  That didn't happen yet though ...

cheers,
  Gerd



Re: [Qemu-devel] [PATCH v3] vnc: disable VNC password authentication (security type 2) when in FIPS mode

2012-05-04 Thread Daniel P. Berrange
On Thu, May 03, 2012 at 05:00:45PM -0400, Paul Moore wrote:
 FIPS 140-2 requires disabling certain ciphers, including DES, which is used
 by VNC to obscure passwords when they are sent over the network.  The
 solution for FIPS users is to disable the use of VNC password auth when the
 host system is operating in FIPS mode.
 
 This patch causes qemu to emit a syslog entry and a message to stderr when
 the host system is running in FIPS mode and a VNC password was specified on
 the commend line.  If the system is not running in FIPS mode, or is running
 in FIPS mode but VNC password authentication was not requested, qemu
 operates normally.
 
 Signed-off-by: Paul Moore pmo...@redhat.com

Reviewed-by: Dainel P. Berrange berra...@redhat.com

Looks good to me now.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



[Qemu-devel] [PATCH 04/14] scsi: fix WRITE SAME transfer length and direction

2012-05-04 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c  |   14 --
 hw/scsi-disk.c |5 -
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index c29a4ae..5640aae 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -791,7 +791,8 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice 
*dev, uint8_t *buf)
 case MODE_SENSE:
 break;
 case WRITE_SAME_10:
-cmd-xfer = 1;
+case WRITE_SAME_16:
+cmd-xfer = dev-blocksize;
 break;
 case READ_CAPACITY_10:
 cmd-xfer = 8;
@@ -909,6 +910,10 @@ static int scsi_req_stream_length(SCSICommand *cmd, 
SCSIDevice *dev, uint8_t *bu
 
 static void scsi_cmd_xfer_mode(SCSICommand *cmd)
 {
+if (!cmd-xfer) {
+cmd-mode = SCSI_XFER_NONE;
+return;
+}
 switch (cmd-buf[0]) {
 case WRITE_6:
 case WRITE_10:
@@ -934,6 +939,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
 case UPDATE_BLOCK:
 case WRITE_LONG_10:
 case WRITE_SAME_10:
+case WRITE_SAME_16:
 case SEARCH_HIGH_12:
 case SEARCH_EQUAL_12:
 case SEARCH_LOW_12:
@@ -946,11 +952,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
 cmd-mode = SCSI_XFER_TO_DEV;
 break;
 default:
-if (cmd-xfer)
-cmd-mode = SCSI_XFER_FROM_DEV;
-else {
-cmd-mode = SCSI_XFER_NONE;
-}
+cmd-mode = SCSI_XFER_FROM_DEV;
 break;
 }
 }
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index eca00a6..fbb1041 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1566,8 +1566,11 @@ static int32_t scsi_send_command(SCSIRequest *req, 
uint8_t *buf)
 }
 break;
 case WRITE_SAME_10:
+len = lduw_be_p(buf[7]);
+goto write_same;
 case WRITE_SAME_16:
-len = r-req.cmd.xfer / s-qdev.blocksize;
+len = ldl_be_p(buf[10])  0xULL;
+write_same:
 
 DPRINTF(WRITE SAME() (sector % PRId64 , count %d)\n,
 r-req.cmd.lba, len);
-- 
1.7.9.3





Re: [Qemu-devel] [SeaBIOS] [seabios patch 5/5] update src/acpi-dsdt.hex

2012-05-04 Thread Gerd Hoffmann
On 05/04/12 10:21, Gerd Hoffmann wrote:
 Signed-off-by: Gerd Hoffmann kra...@redhat.com

Topic just came up on irc (#qemu):  Any reason to keep the iasl
generated files in the git repository?  I think pretty much every linux
distro has iasl packaged these days, so it shouldn't be a major hassle
to depend on it for seabios builds ...

cheers,
  Gerd




[Qemu-devel] [PATCH 10/14] scsi: do not require a minimum allocation length for INQUIRY

2012-05-04 Thread Paolo Bonzini
The requirements on the INQUIRY buffer size are not in my copy of SPC
(SPC-4 r27) and not observed by LIO.  Rip them out.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c  |8 
 hw/scsi-disk.c |   11 ---
 2 files changed, 19 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 46cd1f9..4090b9f 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -367,10 +367,6 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
 if (r-req.cmd.buf[1]  0x1) {
 /* Vital product data */
 uint8_t page_code = r-req.cmd.buf[2];
-if (r-req.cmd.xfer  4) {
-return false;
-}
-
 r-buf[r-len++] = page_code ; /* this page */
 r-buf[r-len++] = 0x00;
 
@@ -398,10 +394,6 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
 }
 
 /* PAGE CODE == 0 */
-if (r-req.cmd.xfer  5) {
-return false;
-}
-
 r-len = MIN(r-req.cmd.xfer, 36);
 memset(r-buf, 0, r-len);
 if (r-req.lun != 0) {
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index e0f1821..298b4ef 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -524,11 +524,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 if (req-cmd.buf[1]  0x1) {
 /* Vital product data */
 uint8_t page_code = req-cmd.buf[2];
-if (req-cmd.xfer  4) {
-BADF(Error: Inquiry (EVPD[%02X]) buffer size %zd is 
- less than 4\n, page_code, req-cmd.xfer);
-return -1;
-}
 
 outbuf[buflen++] = s-qdev.type  0x1f;
 outbuf[buflen++] = page_code ; // this page
@@ -659,12 +654,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 }
 
 /* PAGE CODE == 0 */
-if (req-cmd.xfer  5) {
-BADF(Error: Inquiry (STANDARD) buffer size %zd 
- is less than 5\n, req-cmd.xfer);
-return -1;
-}
-
 buflen = req-cmd.xfer;
 if (buflen  SCSI_MAX_INQUIRY_LEN) {
 buflen = SCSI_MAX_INQUIRY_LEN;
-- 
1.7.9.3





[Qemu-devel] [PATCH 14/14] scsi: Add assertion for use-after-free errors

2012-05-04 Thread Paolo Bonzini
From: Stefan Weil s...@weilnetz.de

The QEMU emulation which is currently used with Raspberry PI images
(qemu-system-arm -M versatilepb ...) accesses memory which was freed.

Valgrind output (extract):

==17857== Invalid write of size 4
==17857==at 0x24EB06: scsi_req_unref (scsi-bus.c:1273)
==17857==by 0x24FFAE: scsi_read_complete (scsi-disk.c:277)
==17857==by 0x152ACC: bdrv_co_em_bh (block.c:3363)
==17857==by 0x13D49C: qemu_bh_poll (async.c:71)
==17857==by 0x211A8C: main_loop_wait (main-loop.c:503)
==17857==by 0x207954: main_loop (vl.c:1555)
==17857==by 0x20E9C9: main (vl.c:3653)
==17857==  Address 0x1c54383c is 12 bytes inside a block of size 260 free'd
==17857==at 0x4824B3A: free (vg_replace_malloc.c:366)
==17857==by 0x20ADFA: free_and_trace (vl.c:2250)
==17857==by 0x4899FC5: g_free (in /lib/libglib-2.0.so.0.2400.1)
==17857==by 0x24EB3B: scsi_req_unref (scsi-bus.c:1277)
==17857==by 0x24F003: scsi_req_complete (scsi-bus.c:1383)
==17857==by 0x25022A: scsi_read_data (scsi-disk.c:334)
==17857==by 0x24EB9F: scsi_req_continue (scsi-bus.c:1289)
==17857==by 0x1C7787: lsi_do_dma (lsi53c895a.c:575)
==17857==by 0x1C8CDA: lsi_execute_script (lsi53c895a.c:1147)
==17857==by 0x1C74EA: lsi_resume_script (lsi53c895a.c:510)
==17857==by 0x1C7ECD: lsi_transfer_data (lsi53c895a.c:746)
==17857==by 0x24EC90: scsi_req_data (scsi-bus.c:1307)

(There are some more similar messages.)

This patch adds an assertion which also detects those errors:

Calling scsi_req_unref is not allowed when the previous call
of that function has decremented refcount to 0, because in this
case req was freed.

Signed-off-by: Stefan Weil s...@weilnetz.de
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index add1d4f..8ab9bcd 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -1291,6 +1291,7 @@ SCSIRequest *scsi_req_ref(SCSIRequest *req)
 
 void scsi_req_unref(SCSIRequest *req)
 {
+assert(req-refcount  0);
 if (--req-refcount == 0) {
 if (req-ops-free_req) {
 req-ops-free_req(req);
-- 
1.7.9.3




[Qemu-devel] [PATCH 13/14] scsi: remove useless debug messages

2012-05-04 Thread Paolo Bonzini
Optional inquiry information is declared obsolete in the latest versions
of the standard; invalid CDBs or unsupported VPD pages are supported
can be diagnosed with trace_scsi_inquiry.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-disk.c |   13 -
 1 file changed, 13 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 298b4ef..08a8226 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -28,9 +28,6 @@ do { printf(scsi-disk:  fmt , ## __VA_ARGS__); } while (0)
 #define DPRINTF(fmt, ...) do {} while(0)
 #endif
 
-#define BADF(fmt, ...) \
-do { fprintf(stderr, scsi-disk:  fmt , ## __VA_ARGS__); } while (0)
-
 #include qemu-common.h
 #include qemu-error.h
 #include scsi.h
@@ -515,12 +512,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req-dev);
 int buflen = 0;
 
-if (req-cmd.buf[1]  0x2) {
-/* Command support data - optional, not implemented */
-BADF(optional INQUIRY command support request not implemented\n);
-return -1;
-}
-
 if (req-cmd.buf[1]  0x1) {
 /* Vital product data */
 uint8_t page_code = req-cmd.buf[2];
@@ -638,8 +629,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 break;
 }
 default:
-BADF(Error: unsupported Inquiry (EVPD[%02X]) 
- buffer size %zd\n, page_code, req-cmd.xfer);
 return -1;
 }
 /* done with EVPD */
@@ -648,8 +637,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 
 /* Standard INQUIRY data */
 if (req-cmd.buf[2] != 0) {
-BADF(Error: Inquiry (STANDARD) page or code 
- is non-zero [%02X]\n, req-cmd.buf[2]);
 return -1;
 }
 
-- 
1.7.9.3





[Qemu-devel] [PATCH 05/14] scsi: Specify the xfer direction for UNMAP and ATA_PASSTHROUGH commands

2012-05-04 Thread Paolo Bonzini
From: Ronnie Sahlberg ronniesahlb...@gmail.com

scsi_cmd_xfer_mode() is used to specify the xfer direction for SCSI
commands that come in from the guest.  If the direction is set incorrectly
this will eventually cause QEMU to kernel-panic the guest.

Add UNMAP and ATAPASSTHROUGH as commands that send data to the device.

Without this change, recent kernels will send both UNMAP as well
as ATAPASSTHROUGH commands to any /dev/sg* device, which due to the
incorrect xfer direction very quickly causes the guest kernel to crash.

Example causing a crash without the patch applied:

./x86_64-softmmu/qemu-system-x86_64 -m 1024 -enable-kvm -cdrom 
linuxmint-12-gnome-dvd-64bit.iso -drive file=/dev/sg4,if=scsi,bus=0,unit=6

Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 5640aae..08d5088 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -940,6 +940,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
 case WRITE_LONG_10:
 case WRITE_SAME_10:
 case WRITE_SAME_16:
+case UNMAP:
 case SEARCH_HIGH_12:
 case SEARCH_EQUAL_12:
 case SEARCH_LOW_12:
@@ -949,6 +950,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
 case SEND_DVD_STRUCTURE:
 case PERSISTENT_RESERVE_OUT:
 case MAINTENANCE_OUT:
+case ATA_PASSTHROUGH:
 cmd-mode = SCSI_XFER_TO_DEV;
 break;
 default:
-- 
1.7.9.3





Re: [Qemu-devel] [SeaBIOS] [seabios patch 5/5] update src/acpi-dsdt.hex

2012-05-04 Thread Michael Tokarev
On 04.05.2012 13:04, Gerd Hoffmann wrote:
 On 05/04/12 10:21, Gerd Hoffmann wrote:
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 
 Topic just came up on irc (#qemu):  Any reason to keep the iasl
 generated files in the git repository?  I think pretty much every linux
 distro has iasl packaged these days, so it shouldn't be a major hassle
 to depend on it for seabios builds ...

There's no need to _depend_ on iasl for building from a tarball.
Just add generation of acpi-dsdt.hex in the `make dist' target,
or in autogen.sh, or even both - and ship the resulting file in
the tarball.  This way, the only place where iasl will be needed
is when building from git, or when you changed acpi sources
(I assume dependencies for acpi-dsdt.hex are specified correctly).

Thanks,

/mjt



[Qemu-devel] [PATCH 08/14] scsi: do not report bogus overruns for commands in the 0x00-0x1F range

2012-05-04 Thread Paolo Bonzini
Interpreting cdb[4] == 0 as a request to transfer 256 blocks is only
needed for READ_6 and WRITE_6.  No other command in that range needs
that special-casing, and the resulting overrun breaks scsi-testsuite's
attempt to use command 2 as a known-invalid command.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 08d5088..5fbf8db 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -735,10 +735,6 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice 
*dev, uint8_t *buf)
 case 0:
 cmd-xfer = buf[4];
 cmd-len = 6;
-/* length 0 means 256 blocks */
-if (cmd-xfer == 0) {
-cmd-xfer = 256;
-}
 break;
 case 1:
 case 2:
@@ -808,18 +804,26 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice 
*dev, uint8_t *buf)
 cmd-xfer = buf[9] | (buf[8]  8);
 }
 break;
+case WRITE_6:
+/* length 0 means 256 blocks */
+if (cmd-xfer == 0) {
+cmd-xfer = 256;
+}
 case WRITE_10:
 case WRITE_VERIFY_10:
-case WRITE_6:
 case WRITE_12:
 case WRITE_VERIFY_12:
 case WRITE_16:
 case WRITE_VERIFY_16:
 cmd-xfer *= dev-blocksize;
 break;
-case READ_10:
 case READ_6:
 case READ_REVERSE:
+/* length 0 means 256 blocks */
+if (cmd-xfer == 0) {
+cmd-xfer = 256;
+}
+case READ_10:
 case RECOVER_BUFFERED_DATA:
 case READ_12:
 case READ_16:
-- 
1.7.9.3





[Qemu-devel] [PATCH 02/14] scsi: prevent data transfer overflow

2012-05-04 Thread Paolo Bonzini
Avoid sending more than 2GB of data, as that can cause overflows
in int32_t variables.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c |   38 ++
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index dbdb99c..c29a4ae 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -239,6 +239,18 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
 return res;
 }
 
+static int32_t scsi_invalid_field(SCSIRequest *req, uint8_t *buf)
+{
+scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));
+scsi_req_complete(req, CHECK_CONDITION);
+return 0;
+}
+
+static const struct SCSIReqOps reqops_invalid_field = {
+.size = sizeof(SCSIRequest),
+.send_command = scsi_invalid_field
+};
+
 /* SCSIReqOps implementation for invalid commands.  */
 
 static int32_t scsi_invalid_command(SCSIRequest *req, uint8_t *buf)
@@ -517,18 +529,20 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, 
uint32_t lun,
   cmd.lba);
 }
 
-if ((d-unit_attention.key == UNIT_ATTENTION ||
- bus-unit_attention.key == UNIT_ATTENTION) 
-(buf[0] != INQUIRY 
- buf[0] != REPORT_LUNS 
- buf[0] != GET_CONFIGURATION 
- buf[0] != GET_EVENT_STATUS_NOTIFICATION 
-
- /*
-  * If we already have a pending unit attention condition,
-  * report this one before triggering another one.
-  */
- !(buf[0] == REQUEST_SENSE  d-sense_is_ua))) {
+if (cmd.xfer  INT32_MAX) {
+req = scsi_req_alloc(reqops_invalid_field, d, tag, lun, 
hba_private);
+} else if ((d-unit_attention.key == UNIT_ATTENTION ||
+   bus-unit_attention.key == UNIT_ATTENTION) 
+  (buf[0] != INQUIRY 
+   buf[0] != REPORT_LUNS 
+   buf[0] != GET_CONFIGURATION 
+   buf[0] != GET_EVENT_STATUS_NOTIFICATION 
+
+   /*
+* If we already have a pending unit attention condition,
+* report this one before triggering another one.
+*/
+   !(buf[0] == REQUEST_SENSE  d-sense_is_ua))) {
 req = scsi_req_alloc(reqops_unit_attention, d, tag, lun,
  hba_private);
 } else if (lun != d-lun ||
-- 
1.7.9.3





[Qemu-devel] [qemu patch] pci: pass i/o windows via fwcfg

2012-05-04 Thread Gerd Hoffmann
This patch adds a fw_cfg entry for the PCI I/O windows.  It holds four
values, 64bit each.  The first two specify the 32bit PCI I/O window
below 4G, the second two the 64bit PCI I/O window above 4G.

The 32bit PCI I/O window used to start at the fixed address 0xe000.
Now it starts at the end of low ram, i.e. machines with less than 3.5 GB
of memory get a larger PCI I/O window.

The 64bit PCI I/O window is located above all memory, is 64G in size and
is aligned according to its size, i.e. usually it starts at 64GB and
ends at 128GB.  When guests have lots of memory it gets moved up
accordingly.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 hw/fw_cfg.h |1 +
 hw/pc.c |   15 ++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
index 856bf91..3042954 100644
--- a/hw/fw_cfg.h
+++ b/hw/fw_cfg.h
@@ -27,6 +27,7 @@
 #define FW_CFG_SETUP_SIZE   0x17
 #define FW_CFG_SETUP_DATA   0x18
 #define FW_CFG_FILE_DIR 0x19
+#define FW_CFG_PCI_WINDOWS  0x1a
 
 #define FW_CFG_FILE_FIRST   0x20
 #define FW_CFG_FILE_SLOTS   0x10
diff --git a/hw/pc.c b/hw/pc.c
index 4d34a33..a823b27 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -72,7 +72,8 @@
 
 #define MSI_ADDR_BASE 0xfee0
 
-#define E820_NR_ENTRIES16
+#define E820_NR_ENTRIES   16
+#define PCI64_SIZE0x10LL /* 64 GB */
 
 struct e820_entry {
 uint64_t address;
@@ -987,6 +988,7 @@ void pc_memory_init(MemoryRegion *system_memory,
 int linux_boot, i;
 MemoryRegion *ram, *option_rom_mr;
 MemoryRegion *ram_below_4g, *ram_above_4g;
+uint64_t *pcimem, pci64_base;
 void *fw_cfg;
 
 linux_boot = (kernel_filename != NULL);
@@ -1027,6 +1029,17 @@ void pc_memory_init(MemoryRegion *system_memory,
 fw_cfg = bochs_bios_init();
 rom_set_fw(fw_cfg);
 
+pcimem = g_malloc0(sizeof(uint64_t) * 4);
+/* 32bit pci io window */
+pcimem[0] = cpu_to_le64(below_4g_mem_size);
+pcimem[1] = cpu_to_le64(0xFEC0 - 1);
+/* 64bit pci io window */
+pci64_base = (0x1ULL + above_4g_mem_size + PCI64_SIZE)  
~(PCI64_SIZE-1);
+pcimem[2] = cpu_to_le64(pci64_base);
+pcimem[3] = cpu_to_le64(pci64_base + PCI64_SIZE - 1);
+fw_cfg_add_bytes(fw_cfg, FW_CFG_PCI_WINDOWS,
+ (uint8_t *)pcimem, sizeof(uint64_t) * 4);
+
 if (linux_boot) {
 load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, 
below_4g_mem_size);
 }
-- 
1.7.1




[Qemu-devel] [PATCH 06/14] scsi: change removable field to host many features

2012-05-04 Thread Paolo Bonzini
It is pointless to add a uint32_t field for every new feature.
Since we will need a new feature soon, convert accesses to removable
to look at bit 0 only.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-disk.c |   23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index fbb1041..e04b469 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -61,10 +61,12 @@ typedef struct SCSIDiskReq {
 BlockAcctCookie acct;
 } SCSIDiskReq;
 
+#define SCSI_DISK_F_REMOVABLE  0
+
 struct SCSIDiskState
 {
 SCSIDevice qdev;
-uint32_t removable;
+uint32_t features;
 bool media_changed;
 bool media_event;
 bool eject_request;
@@ -669,7 +671,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, 
uint8_t *outbuf)
 memset(outbuf, 0, buflen);
 
 outbuf[0] = s-qdev.type  0x1f;
-outbuf[1] = s-removable ? 0x80 : 0;
+outbuf[1] = (s-features  (1  SCSI_DISK_F_REMOVABLE)) ? 0x80 : 0;
 if (s-qdev.type == TYPE_ROM) {
 memcpy(outbuf[16], QEMU CD-ROM , 16);
 } else {
@@ -1710,7 +1712,8 @@ static int scsi_initfn(SCSIDevice *dev)
 return -1;
 }
 
-if (!s-removable  !bdrv_is_inserted(s-qdev.conf.bs)) {
+if (!(s-features  (1  SCSI_DISK_F_REMOVABLE)) 
+!bdrv_is_inserted(s-qdev.conf.bs)) {
 error_report(Device needs media, but drive is empty);
 return -1;
 }
@@ -1732,7 +1735,7 @@ static int scsi_initfn(SCSIDevice *dev)
 return -1;
 }
 
-if (s-removable) {
+if (s-features  (1  SCSI_DISK_F_REMOVABLE)) {
 bdrv_set_dev_ops(s-qdev.conf.bs, scsi_cd_block_ops, s);
 }
 bdrv_set_buffer_alignment(s-qdev.conf.bs, s-qdev.blocksize);
@@ -1755,7 +1758,7 @@ static int scsi_cd_initfn(SCSIDevice *dev)
 SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
 s-qdev.blocksize = 2048;
 s-qdev.type = TYPE_ROM;
-s-removable = true;
+s-features |= 1  SCSI_DISK_F_REMOVABLE;
 return scsi_initfn(s-qdev);
 }
 
@@ -1828,7 +1831,9 @@ static int get_device_type(SCSIDiskState *s)
 return -1;
 }
 s-qdev.type = buf[0];
-s-removable = (buf[1]  0x80) != 0;
+if (buf[1]  0x80) {
+s-features |= 1  SCSI_DISK_F_REMOVABLE;
+}
 return 0;
 }
 
@@ -1928,7 +1933,8 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, 
uint32_t tag,
 
 static Property scsi_hd_properties[] = {
 DEFINE_SCSI_DISK_PROPERTIES(),
-DEFINE_PROP_BIT(removable, SCSIDiskState, removable, 0, false),
+DEFINE_PROP_BIT(removable, SCSIDiskState, features,
+SCSI_DISK_F_REMOVABLE, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2030,7 +2036,8 @@ static TypeInfo scsi_block_info = {
 
 static Property scsi_disk_properties[] = {
 DEFINE_SCSI_DISK_PROPERTIES(),
-DEFINE_PROP_BIT(removable, SCSIDiskState, removable, 0, false),
+DEFINE_PROP_BIT(removable, SCSIDiskState, features,
+SCSI_DISK_F_REMOVABLE, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
1.7.9.3





[Qemu-devel] [PATCH 11/14] scsi: do not require a minimum allocation length for REQUEST SENSE

2012-05-04 Thread Paolo Bonzini
The requirements on the REQUEST SENSE buffer size are not in my copy of SPC
(SPC-4 r27) and not observed by LIO.  Rip them out.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 4090b9f..925c3ae 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -427,9 +427,6 @@ static int32_t scsi_target_send_command(SCSIRequest *req, 
uint8_t *buf)
 }
 break;
 case REQUEST_SENSE:
-if (req-cmd.xfer  4) {
-goto illegal_request;
-}
 r-len = scsi_device_get_sense(r-req.dev, r-buf,
MIN(req-cmd.xfer, sizeof r-buf),
(req-cmd.buf[1]  1) == 0);
@@ -538,8 +535,8 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, 
uint32_t lun,
 req = scsi_req_alloc(reqops_unit_attention, d, tag, lun,
  hba_private);
 } else if (lun != d-lun ||
-buf[0] == REPORT_LUNS ||
-(buf[0] == REQUEST_SENSE  (d-sense_len || cmd.xfer  4))) {
+   buf[0] == REPORT_LUNS ||
+   (buf[0] == REQUEST_SENSE  d-sense_len)) {
 req = scsi_req_alloc(reqops_target_command, d, tag, lun,
  hba_private);
 } else {
-- 
1.7.9.3





[Qemu-devel] [PATCH 01/14] ISCSI: Add support for thin-provisioning via discard/UNMAP and bigger LUNs

2012-05-04 Thread Paolo Bonzini
From: Ronnie Sahlberg ronniesahlb...@gmail.com

Update the configure test for libiscsi support to detect version 1.3
or later.  Version 1.3 of libiscsi provides both READCAPACITY16 as well
as UNMAP commands.

Update the iscsi block layer to use READCAPACITY16 to detect the size of
the LUN instead of READCAPACITY10. This allows support for LUNs larger
than 2TB.

Update to implement bdrv_aio_discard() using the UNMAP command.
This allows us to use thin-provisioned LUNs from TGTD and other iSCSI
targets that support thin-provisioning.

Signed-off-by: Ronnie Sahlberg ronniesahlb...@gmail.com
[squashed in and fixed subsequent patch from Ronnie to fix off-by-one in
 LBA count]
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 block/iscsi.c |   86 -
 configure |5 +++-
 2 files changed, 77 insertions(+), 14 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 5222726..d37c4ee 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -383,6 +383,65 @@ iscsi_aio_flush(BlockDriverState *bs,
 return acb-common;
 }
 
+static void
+iscsi_unmap_cb(struct iscsi_context *iscsi, int status,
+ void *command_data, void *opaque)
+{
+IscsiAIOCB *acb = opaque;
+
+if (acb-canceled != 0) {
+qemu_aio_release(acb);
+scsi_free_scsi_task(acb-task);
+acb-task = NULL;
+return;
+}
+
+acb-status = 0;
+if (status  0) {
+error_report(Failed to unmap data on iSCSI lun. %s,
+ iscsi_get_error(iscsi));
+acb-status = -EIO;
+}
+
+iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+scsi_free_scsi_task(acb-task);
+acb-task = NULL;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_discard(BlockDriverState *bs,
+  int64_t sector_num, int nb_sectors,
+  BlockDriverCompletionFunc *cb, void *opaque)
+{
+IscsiLun *iscsilun = bs-opaque;
+struct iscsi_context *iscsi = iscsilun-iscsi;
+IscsiAIOCB *acb;
+struct unmap_list list[1];
+
+acb = qemu_aio_get(iscsi_aio_pool, bs, cb, opaque);
+
+acb-iscsilun = iscsilun;
+acb-canceled   = 0;
+
+list[0].lba = sector_qemu2lun(sector_num, iscsilun);
+list[0].num = nb_sectors * BDRV_SECTOR_SIZE / iscsilun-block_size;
+
+acb-task = iscsi_unmap_task(iscsi, iscsilun-lun,
+ 0, 0, list[0], 1,
+ iscsi_unmap_cb,
+ acb);
+if (acb-task == NULL) {
+error_report(iSCSI: Failed to send unmap command. %s,
+ iscsi_get_error(iscsi));
+qemu_aio_release(acb);
+return NULL;
+}
+
+iscsi_set_events(iscsilun);
+
+return acb-common;
+}
+
 static int64_t
 iscsi_getlength(BlockDriverState *bs)
 {
@@ -396,11 +455,11 @@ iscsi_getlength(BlockDriverState *bs)
 }
 
 static void
-iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int status,
+iscsi_readcapacity16_cb(struct iscsi_context *iscsi, int status,
 void *command_data, void *opaque)
 {
 struct IscsiTask *itask = opaque;
-struct scsi_readcapacity10 *rc10;
+struct scsi_readcapacity16 *rc16;
 struct scsi_task *task = command_data;
 
 if (status != 0) {
@@ -412,26 +471,25 @@ iscsi_readcapacity10_cb(struct iscsi_context *iscsi, int 
status,
 return;
 }
 
-rc10 = scsi_datain_unmarshall(task);
-if (rc10 == NULL) {
-error_report(iSCSI: Failed to unmarshall readcapacity10 data.);
+rc16 = scsi_datain_unmarshall(task);
+if (rc16 == NULL) {
+error_report(iSCSI: Failed to unmarshall readcapacity16 data.);
 itask-status   = 1;
 itask-complete = 1;
 scsi_free_scsi_task(task);
 return;
 }
 
-itask-iscsilun-block_size = rc10-block_size;
-itask-iscsilun-num_blocks = rc10-lba;
-itask-bs-total_sectors = (uint64_t)rc10-lba *
-   rc10-block_size / BDRV_SECTOR_SIZE ;
+itask-iscsilun-block_size = rc16-block_length;
+itask-iscsilun-num_blocks = rc16-returned_lba + 1;
+itask-bs-total_sectors= itask-iscsilun-num_blocks *
+   itask-iscsilun-block_size / BDRV_SECTOR_SIZE ;
 
 itask-status   = 0;
 itask-complete = 1;
 scsi_free_scsi_task(task);
 }
 
-
 static void
 iscsi_connect_cb(struct iscsi_context *iscsi, int status, void *command_data,
  void *opaque)
@@ -445,10 +503,10 @@ iscsi_connect_cb(struct iscsi_context *iscsi, int status, 
void *command_data,
 return;
 }
 
-task = iscsi_readcapacity10_task(iscsi, itask-iscsilun-lun, 0, 0,
-   iscsi_readcapacity10_cb, opaque);
+task = iscsi_readcapacity16_task(iscsi, itask-iscsilun-lun,
+   iscsi_readcapacity16_cb, opaque);
 if (task == NULL) {
-error_report(iSCSI: failed to send readcapacity command.);
+error_report(iSCSI: failed 

[Qemu-devel] [PATCH 09/14] scsi: parse 16-byte tape CDBs

2012-05-04 Thread Paolo Bonzini
The transfer length for these commands is different from the transfer
length of the corresponding disk commands, so parse it specially.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
READ REVERSE(16) seems to be for people who stream manga from tape.

 hw/scsi-bus.c  |   10 ++
 hw/scsi-defs.h |1 +
 2 files changed, 11 insertions(+)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 5fbf8db..46cd1f9 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -891,6 +891,16 @@ static int scsi_req_stream_length(SCSICommand *cmd, 
SCSIDevice *dev, uint8_t *bu
 cmd-xfer *= dev-blocksize;
 }
 break;
+case READ_16:
+case READ_REVERSE_16:
+case VERIFY_16:
+case WRITE_16:
+cmd-len = 16;
+cmd-xfer = buf[14] | (buf[13]  8) | (buf[12]  16);
+if (buf[1]  0x01) { /* fixed */
+cmd-xfer *= dev-blocksize;
+}
+break;
 case REWIND:
 case START_STOP:
 cmd-len = 6;
diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index ca24192..219c84d 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -92,6 +92,7 @@
 #define PERSISTENT_RESERVE_OUT 0x5f
 #define VARLENGTH_CDB 0x7f
 #define WRITE_FILEMARKS_160x80
+#define READ_REVERSE_16   0x81
 #define ALLOW_OVERWRITE   0x82
 #define EXTENDED_COPY 0x83
 #define ATA_PASSTHROUGH   0x85
-- 
1.7.9.3





[Qemu-devel] [PATCH 07/14] scsi-disk: add dpofua property

2012-05-04 Thread Paolo Bonzini
Linux expects REQ_FUA to be advertised only if WRITE+FUA is faster than
WRITE+SYNCHRONIZE CACHE, so we should not set the DPOFUA bit.  However,
it is useful to have it for testing purposes, so add a qdev property to
set it.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-disk.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index e04b469..e0f1821 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -62,6 +62,7 @@ typedef struct SCSIDiskReq {
 } SCSIDiskReq;
 
 #define SCSI_DISK_F_REMOVABLE  0
+#define SCSI_DISK_F_DPOFUA 1
 
 struct SCSIDiskState
 {
@@ -1103,7 +1104,7 @@ static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, 
uint8_t *outbuf)
 p = outbuf;
 
 if (s-qdev.type == TYPE_DISK) {
-dev_specific_param = 0x10; /* DPOFUA */
+dev_specific_param = s-features  (1  SCSI_DISK_F_DPOFUA) ? 0x10 : 
0;
 if (bdrv_is_read_only(s-qdev.conf.bs)) {
 dev_specific_param |= 0x80; /* Readonly.  */
 }
@@ -1935,6 +1936,8 @@ static Property scsi_hd_properties[] = {
 DEFINE_SCSI_DISK_PROPERTIES(),
 DEFINE_PROP_BIT(removable, SCSIDiskState, features,
 SCSI_DISK_F_REMOVABLE, false),
+DEFINE_PROP_BIT(dpofua, SCSIDiskState, features,
+SCSI_DISK_F_DPOFUA, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -2038,6 +2041,8 @@ static Property scsi_disk_properties[] = {
 DEFINE_SCSI_DISK_PROPERTIES(),
 DEFINE_PROP_BIT(removable, SCSIDiskState, features,
 SCSI_DISK_F_REMOVABLE, false),
+DEFINE_PROP_BIT(dpofua, SCSIDiskState, features,
+SCSI_DISK_F_DPOFUA, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
1.7.9.3





[Qemu-devel] [PATCH 03/14] scsi: fix refcounting for reads

2012-05-04 Thread Paolo Bonzini
Recently introduced FUA support also gave us a use-after-free
of the BlockAcctCookie within a SCSIDiskReq, due to unbalanced
reference counting.

The patch fixes this by making scsi_do_read look like a combination
of scsi_*_complete + scsi_*_data.  It does both a ref (like
scsi_read_data) and an unref (like scsi_flush_complete).

Reported-by: David Gibson da...@gibson.dropbear.id.au
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-disk.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index a029ab6..eca00a6 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -296,6 +296,13 @@ static void scsi_do_read(void *opaque, int ret)
 }
 }
 
+if (r-req.io_canceled) {
+return;
+}
+
+/* The request is used as the AIO opaque value, so add a ref.  */
+scsi_req_ref(r-req);
+
 if (r-req.sg) {
 dma_acct_start(s-qdev.conf.bs, r-acct, r-req.sg, BDRV_ACCT_READ);
 r-req.resid -= r-req.sg-size;
-- 
1.7.9.3





[Qemu-devel] [PATCH 12/14] scsi: set VALID bit to 0 in fixed format sense data

2012-05-04 Thread Paolo Bonzini
The INFORMATION field (bytes 3..6) is never set by QEMU, so the VALID
bit must be 0.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 hw/scsi-bus.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 925c3ae..add1d4f 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -649,7 +649,7 @@ void scsi_req_build_sense(SCSIRequest *req, SCSISense sense)
 trace_scsi_req_build_sense(req-dev-id, req-lun, req-tag,
sense.key, sense.asc, sense.ascq);
 memset(req-sense, 0, 18);
-req-sense[0] = 0xf0;
+req-sense[0] = 0x70;
 req-sense[2] = sense.key;
 req-sense[7] = 10;
 req-sense[12] = sense.asc;
@@ -1148,7 +1148,7 @@ int scsi_build_sense(uint8_t *in_buf, int in_len,
 memset(buf, 0, len);
 if (fixed) {
 /* Return fixed format sense buffer */
-buf[0] = 0xf0;
+buf[0] = 0x70;
 buf[2] = sense.key;
 buf[7] = 10;
 buf[12] = sense.asc;
-- 
1.7.9.3





[Qemu-devel] [seabios patch 1/5] pci: init all devices

2012-05-04 Thread Gerd Hoffmann
seabios used to initialize root bus devices only, with this patch
devices behind pci bridges are initialized too.  This allows to boot
from virtio devices behind pci bridges.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 src/pciinit.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/pciinit.c b/src/pciinit.c
index 25b04ac..6a7a0d2 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -213,9 +213,6 @@ static void pci_bios_init_devices(void)
 {
 struct pci_device *pci;
 foreachpci(pci) {
-if (pci_bdf_to_bus(pci-bdf) != 0)
-// Only init devices on host bus.
-break;
 pci_bios_init_device(pci);
 }
 
-- 
1.7.1




Re: [Qemu-devel] unreviewed commits (was: Re: Restore consistent formatting)

2012-05-04 Thread Peter Maydell
On 4 May 2012 01:41, Anthony Liguori anth...@codemonkey.ws wrote:
 On 05/03/2012 02:58 PM, Peter Maydell wrote:
 No unreviewed patches should go double when we're in hardfreeze!

 These patches are admittedly trivial but it is important to stress the point
 that all patches need to go on the mailing list before being committed.

 It's an important part of keeping the development process inclusive.  I
 don't think it's reasonable to ask for an Acked-by on something as simple as
 indentation changes but at the same time, there's no reason not to just post
 patches.

Yes, it is specifically the failure to follow the standard process
of posting patches and allowing the opportunity for review before commit
that I'm complaining about. Obviously if nobody cares to actually do
the review that's their lookout.

-- PMM



Re: [Qemu-devel] unreviewed commits (was: Re: Restore consistent formatting)

2012-05-04 Thread Alexander Graf

On 04.05.2012, at 04:37, malc wrote:

 On Fri, 4 May 2012, Andreas F?rber wrote:
 
 Am 04.05.2012 02:41, schrieb Anthony Liguori:
 On 05/03/2012 02:58 PM, Peter Maydell wrote:
 On 9 February 2012 13:46, Anthony Liguorianth...@codemonkey.ws  wrote:
 On 02/09/2012 03:48 AM, Markus Armbruster wrote:
 You buried the one truly important sentence, let me dig it out for you:
 
 *** Patches should always go to the mailing list ***
 
 Exceptions need justification.  Responsible handling embargoed security
 issues may qualify.  Style fixes certainly not.
 
 100% agreed.
 
 I don't see anything in the mailing list archives corresponding
 to commits f05ae537, f6af014e.
 
 No unreviewed patches should go double when we're in hardfreeze!
 
 These patches are admittedly trivial but it is important to stress the
 point that all patches need to go on the mailing list before being
 committed.
 
 It's an important part of keeping the development process inclusive.  I
 don't think it's reasonable to ask for an Acked-by on something as
 simple as indentation changes but at the same time, there's no reason
 not to just post patches.
 
 The second patch is far from trivial!
 
 It unneededly breaks the build on ppc hosts (during the Hard Freeze!),
 so that I can no longer compile-test my patch series against PowerKVM.
 
 As discussed on IRC, the feature does not work on PPC32, hence it's
 violently disabled, what's needed is a black/white list of AREG0 ready
 targets.

While I agree that it's broken, a runtime error would be a lot better than a 
compile time one. The way it's now, it only makes our automated compile tests 
fail. And since nobody realized until now that sparc and alpha don't work on 
ppc hosts, I don't think having a compile time failure is warranted.


Alex




[Qemu-devel] [PATCH 03/35] vmstate: unicore32 don't support cpu migration

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-unicore32/cpu.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h
index 81c14ff..65f389c 100644
--- a/target-unicore32/cpu.h
+++ b/target-unicore32/cpu.h
@@ -135,8 +135,6 @@ int uc32_cpu_signal_handler(int host_signum, void *pinfo, 
void *puc);
 int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address, 
int rw,
   int mmu_idx);

-#define CPU_SAVE_VERSION 2
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
-- 
1.7.7.6




[Qemu-devel] [PATCH 34/35] vmstate: Add copyright info for ppc processor

2012-05-04 Thread Juan Quintela
v2: Move license to BSD-like as in vl.c
v3: change copyright dates
v4: add Fabrice  QEMU contributors

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-ppc/vmstate-cpu.c |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/target-ppc/vmstate-cpu.c b/target-ppc/vmstate-cpu.c
index c4547df..3fa6750 100644
--- a/target-ppc/vmstate-cpu.c
+++ b/target-ppc/vmstate-cpu.c
@@ -1,3 +1,33 @@
+/*
+ * Migration support for ppc cpu
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2004-2009 Blue Swirl blauwir...@gmail.com
+ * Copyright (c) 2003-2012 QEMU contributors
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
 #include hw/hw.h

 static const VMStateDescription vmstate_tlb = {
-- 
1.7.7.6




Re: [Qemu-devel] [PATCH v5 00/35] VMState port of all cpus

2012-05-04 Thread Andreas Färber
Am 04.05.2012 12:54, schrieb Juan Quintela:
 This repository contains all the changes:
 
   git://repo.or.cz/qemu/quintela.git vmstate-cpus-v4
 
 [v5]
 - rebase on top
 - sparc psr change behaviour: old behaviour was unintended, thanks Blu
 - alexander agreed with ppc changes
 - patch missing already included for ppc
 
 Anthony, please pull.

You forgot to update the subjects. And if it's labeled [PATCH] it's
supposed to be reviewed, not directly pulled.

The branch is off by one; positive that -v4 branch matches v5 series?

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 29/35] vmstate: Add copyright info for lm32 processor

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
Acked-By: Michael Walle mich...@walle.cc
---
 target-lm32/vmstate-cpu.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/target-lm32/vmstate-cpu.c b/target-lm32/vmstate-cpu.c
index 132259d..3867189 100644
--- a/target-lm32/vmstate-cpu.c
+++ b/target-lm32/vmstate-cpu.c
@@ -1,3 +1,18 @@
+/*
+ * Migration support for lm32 cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Based on savevm serialization code by:
+ *  Michael Walle mich...@walle.cc
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
 #include hw/hw.h

 const VMStateDescription vmstate_cpu = {
-- 
1.7.7.6




[Qemu-devel] [PATCH 15/35] vmstate: port sparc cpu

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/sun4u.c |   20 --
 target-sparc/cpu.h |9 +-
 target-sparc/machine.c |  474 
 3 files changed, 283 insertions(+), 220 deletions(-)

diff --git a/hw/sun4u.c b/hw/sun4u.c
index fe33138..3008513 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -338,26 +338,6 @@ typedef struct ResetData {
 uint64_t prom_addr;
 } ResetData;

-void cpu_put_timer(QEMUFile *f, CPUTimer *s)
-{
-qemu_put_be32s(f, s-frequency);
-qemu_put_be32s(f, s-disabled);
-qemu_put_be64s(f, s-disabled_mask);
-qemu_put_sbe64s(f, s-clock_offset);
-
-qemu_put_timer(f, s-qtimer);
-}
-
-void cpu_get_timer(QEMUFile *f, CPUTimer *s)
-{
-qemu_get_be32s(f, s-frequency);
-qemu_get_be32s(f, s-disabled);
-qemu_get_be64s(f, s-disabled_mask);
-qemu_get_sbe64s(f, s-clock_offset);
-
-qemu_get_timer(f, s-qtimer);
-}
-
 static CPUTimer* cpu_timer_create(const char* name, CPUSPARCState *env,
   QEMUBHFunc *cb, uint32_t frequency,
   uint64_t disabled_mask)
diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h
index 29c63c7..98db96a 100644
--- a/target-sparc/cpu.h
+++ b/target-sparc/cpu.h
@@ -374,10 +374,6 @@ struct CPUTimer

 typedef struct CPUTimer CPUTimer;

-struct QEMUFile;
-void cpu_put_timer(struct QEMUFile *f, CPUTimer *s);
-void cpu_get_timer(struct QEMUFile *f, CPUTimer *s);
-
 typedef struct CPUSPARCState CPUSPARCState;

 struct CPUSPARCState {
@@ -509,6 +505,9 @@ struct CPUSPARCState {

 /* Leon3 cache control */
 uint32_t cache_control;
+
+/* Fields needed as intermediate for vmstate */
+uint32_t psr_vmstate;
 };

 #ifndef NO_CPU_IO_DEFS
@@ -596,8 +595,6 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, 
void *puc);
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list

-#define CPU_SAVE_VERSION 7
-
 /* MMU modes definitions */
 #if defined (TARGET_SPARC64)
 #define MMU_USER_IDX   0
diff --git a/target-sparc/machine.c b/target-sparc/machine.c
index eb4d87f..801ec55 100644
--- a/target-sparc/machine.c
+++ b/target-sparc/machine.c
@@ -4,214 +4,300 @@

 #include cpu.h

-void cpu_save(QEMUFile *f, void *opaque)
-{
-CPUSPARCState *env = opaque;
-int i;
-uint32_t tmp;
-
-// if env-cwp == env-nwindows - 1, this will set the ins of the last
-// window as the outs of the first window
-cpu_set_cwp(env, env-cwp);
+static const VMStateDescription vmstate_cpu_timer = {
+.name = cpu_timer,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINT32(frequency, CPUTimer),
+VMSTATE_UINT32(disabled, CPUTimer),
+VMSTATE_UINT64(disabled_mask, CPUTimer),
+VMSTATE_INT64(clock_offset, CPUTimer),
+VMSTATE_TIMER(qtimer, CPUTimer),
+VMSTATE_END_OF_LIST()
+}
+};

-for(i = 0; i  8; i++)
-qemu_put_betls(f, env-gregs[i]);
-qemu_put_be32s(f, env-nwindows);
-for(i = 0; i  env-nwindows * 16; i++)
-qemu_put_betls(f, env-regbase[i]);
+#define VMSTATE_CPU_TIMER(_f, _s) \
+VMSTATE_STRUCT_POINTER(_f, _s, vmstate_cpu_timer, CPUTimer *)

-/* FPU */
-for (i = 0; i  TARGET_DPREGS; i++) {
-qemu_put_be32(f, env-fpr[i].l.upper);
-qemu_put_be32(f, env-fpr[i].l.lower);
+#if defined(TARGET_SPARC64)
+static const VMStateDescription vmstate_trap_state = {
+.name = trap_state,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINT64(tpc, trap_state),
+VMSTATE_UINT64(tnpc, trap_state),
+VMSTATE_UINT64(tstate, trap_state),
+VMSTATE_UINT32(tt, trap_state),
+VMSTATE_END_OF_LIST()
 }
+};

-qemu_put_betls(f, env-pc);
-qemu_put_betls(f, env-npc);
-qemu_put_betls(f, env-y);
-tmp = cpu_get_psr(env);
-qemu_put_be32(f, tmp);
-qemu_put_betls(f, env-fsr);
-qemu_put_betls(f, env-tbr);
-tmp = env-interrupt_index;
-qemu_put_be32(f, tmp);
-qemu_put_be32s(f, env-pil_in);
-#ifndef TARGET_SPARC64
-qemu_put_be32s(f, env-wim);
-/* MMU */
-for (i = 0; i  32; i++)
-qemu_put_be32s(f, env-mmuregs[i]);
-for (i = 0; i  4; i++) {
-qemu_put_be64s(f, env-mxccdata[i]);
-}
-for (i = 0; i  8; i++) {
-qemu_put_be64s(f, env-mxccregs[i]);
-}
-qemu_put_be32s(f, env-mmubpctrv);
-qemu_put_be32s(f, env-mmubpctrc);
-qemu_put_be32s(f, env-mmubpctrs);
-qemu_put_be64s(f, env-mmubpaction);
-for (i = 0; i  4; i++) {
-qemu_put_be64s(f, env-mmubpregs[i]);
+static const VMStateDescription vmstate_tlb_entry = {
+.name = tlb_entry,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINT64(tag, 

Re: [Qemu-devel] [PATCH v5 00/35] VMState port of all cpus

2012-05-04 Thread Juan Quintela
Andreas Färber afaer...@suse.de wrote:
 Am 04.05.2012 12:54, schrieb Juan Quintela:
 This repository contains all the changes:
 
   git://repo.or.cz/qemu/quintela.git vmstate-cpus-v4
 
 [v5]
 - rebase on top
 - sparc psr change behaviour: old behaviour was unintended, thanks Blu
 - alexander agreed with ppc changes
 - patch missing already included for ppc
 
 Anthony, please pull.

 You forgot to update the subjects. And if it's labeled [PATCH] it's
 supposed to be reviewed, not directly pulled.

Oops.  I think that I answered all the review comments on previous
threads, Should be ready for pull.


 The branch is off by one; positive that -v4 branch matches v5 series?

Shuould be updated by now  (I sent the patches and forget to do the
push).



[Qemu-devel] [PATCH 25/35] vmstate: fix vmstate formating for i386

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-i386/machine.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/target-i386/machine.c b/target-i386/machine.c
index 127c44f..c2a8872 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -11,7 +11,7 @@ static const VMStateDescription vmstate_segment = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField []) {
+.fields = (VMStateField[]) {
 VMSTATE_UINT32(selector, SegmentCache),
 VMSTATE_UINTTL(base, SegmentCache),
 VMSTATE_UINT32(limit, SegmentCache),
@@ -37,7 +37,7 @@ static const VMStateDescription vmstate_xmm_reg = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField []) {
+.fields = (VMStateField[]) {
 VMSTATE_UINT64(XMM_Q(0), XMMReg),
 VMSTATE_UINT64(XMM_Q(1), XMMReg),
 VMSTATE_END_OF_LIST()
@@ -53,7 +53,7 @@ static const VMStateDescription vmstate_ymmh_reg = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField []) {
+.fields = (VMStateField[]) {
 VMSTATE_UINT64(XMM_Q(0), XMMReg),
 VMSTATE_UINT64(XMM_Q(1), XMMReg),
 VMSTATE_END_OF_LIST()
@@ -68,7 +68,7 @@ static const VMStateDescription vmstate_mtrr_var = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField []) {
+.fields = (VMStateField[]) {
 VMSTATE_UINT64(base, MTRRVar),
 VMSTATE_UINT64(mask, MTRRVar),
 VMSTATE_END_OF_LIST()
@@ -284,7 +284,7 @@ static const VMStateDescription vmstate_async_pf_msr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField []) {
+.fields = (VMStateField []) {
 VMSTATE_UINT64(async_pf_en_msr, CPUX86State),
 VMSTATE_END_OF_LIST()
 }
@@ -302,7 +302,7 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField []) {
+.fields = (VMStateField []) {
 VMSTATE_UINT16(fpop, CPUX86State),
 VMSTATE_UINT64(fpip, CPUX86State),
 VMSTATE_UINT64(fpdp, CPUX86State),
@@ -353,7 +353,7 @@ const VMStateDescription vmstate_cpu = {
 .minimum_version_id_old = 3,
 .pre_save = cpu_pre_save,
 .post_load = cpu_post_load,
-.fields  = (VMStateField []) {
+.fields = (VMStateField []) {
 VMSTATE_UINTTL_ARRAY(regs, CPUX86State, CPU_NB_REGS),
 VMSTATE_UINTTL(eip, CPUX86State),
 VMSTATE_UINTTL(eflags, CPUX86State),
@@ -449,7 +449,7 @@ const VMStateDescription vmstate_cpu = {
 VMSTATE_END_OF_LIST()
 /* The above list is not sorted /wrt version numbers, watch out! */
 },
-.subsections = (VMStateSubsection []) {
+.subsections = (VMStateSubsection[]) {
 {
 .vmsd = vmstate_async_pf_msr,
 .needed = async_pf_msr_needed,
-- 
1.7.7.6




Re: [Qemu-devel] [PATCH 16/35] vmstate: make incompatible change for sparc

2012-05-04 Thread Andreas Färber
Am 04.05.2012 12:54, schrieb Juan Quintela:
 With this change, we sent arrays as arrays, making state description

send?

 much simpler.  The change is incompatible, but as far as I know, sparc
 don't care about migration compatibility beteween versions.

the SPARC targets don't (or sparc doesn't)

between

 
 Signed-off-by: Juan Quintela quint...@redhat.com

It appears once again none of these patches are actually cc'ing the
proper maintainers. Not even Acked-by (or is git-send-email
case-sensitive? it's spelled Acked-By in lm32 patch).

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH v5 00/35] VMState port of all cpus

2012-05-04 Thread Juan Quintela
Juan Quintela quint...@redhat.com wrote:
 Andreas Färber afaer...@suse.de wrote:
 Am 04.05.2012 12:54, schrieb Juan Quintela:
 This repository contains all the changes:
 
   git://repo.or.cz/qemu/quintela.git vmstate-cpus-v4
 

Oops, you meaned here.  s/v4/v5/  :-(

I have to put in one script how to ask for a pull and don't rely on my
weak memory.


 [v5]
 - rebase on top
 - sparc psr change behaviour: old behaviour was unintended, thanks Blu
 - alexander agreed with ppc changes
 - patch missing already included for ppc
 
 Anthony, please pull.

 You forgot to update the subjects. And if it's labeled [PATCH] it's
 supposed to be reviewed, not directly pulled.

 Oops.  I think that I answered all the review comments on previous
 threads, Should be ready for pull.


 The branch is off by one; positive that -v4 branch matches v5 series?

 Shuould be updated by now  (I sent the patches and forget to do the
 push).



[Qemu-devel] [PATCH 01/35] vmstate: Simplify test for CPU_SAVE_VERSION

2012-05-04 Thread Juan Quintela
Some cpu's definitions define CPU_SAVE_VERSION, others not, but they have
defined cpu_save/load.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 exec.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index 0607c9b..cba333f 100644
--- a/exec.c
+++ b/exec.c
@@ -650,7 +650,7 @@ void cpu_exec_init_all(void)
 #endif
 }

-#if defined(CPU_SAVE_VERSION)  !defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)

 static int cpu_common_post_load(void *opaque, int version_id)
 {
@@ -717,11 +717,13 @@ void cpu_exec_init(CPUArchState *env)
 #if defined(CONFIG_USER_ONLY)
 cpu_list_unlock();
 #endif
-#if defined(CPU_SAVE_VERSION)  !defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
 vmstate_register(NULL, cpu_index, vmstate_cpu_common, env);
+#if defined(CPU_SAVE_VERSION)
 register_savevm(NULL, cpu, cpu_index, CPU_SAVE_VERSION,
 cpu_save, cpu_load, env);
 #endif
+#endif
 }

 /* Allocate a new translation block. Flush the translation buffer if
-- 
1.7.7.6




Re: [Qemu-devel] [PATCH 01/35] vmstate: Simplify test for CPU_SAVE_VERSION

2012-05-04 Thread Andreas Färber
Am 04.05.2012 12:54, schrieb Juan Quintela:
 Some cpu's definitions define CPU_SAVE_VERSION, others not, but they have

CPUs' definitions?

 defined cpu_save/load.

This commit message sounds wrong. Use of cpu_save/load is still coupled
to CPU_SAVE_VERSION AFAICS.

What really changes is that vmstate_cpu_common is now registered whether
or not the target supports loading/saving the target-specific parts,
isn't it? Is that really useful? Either way, the commit message should
be updated.

Andreas

 
 Signed-off-by: Juan Quintela quint...@redhat.com
 ---
  exec.c |6 --
  1 files changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/exec.c b/exec.c
 index 0607c9b..cba333f 100644
 --- a/exec.c
 +++ b/exec.c
 @@ -650,7 +650,7 @@ void cpu_exec_init_all(void)
  #endif
  }
 
 -#if defined(CPU_SAVE_VERSION)  !defined(CONFIG_USER_ONLY)
 +#if !defined(CONFIG_USER_ONLY)
 
  static int cpu_common_post_load(void *opaque, int version_id)
  {
 @@ -717,11 +717,13 @@ void cpu_exec_init(CPUArchState *env)
  #if defined(CONFIG_USER_ONLY)
  cpu_list_unlock();
  #endif
 -#if defined(CPU_SAVE_VERSION)  !defined(CONFIG_USER_ONLY)
 +#if !defined(CONFIG_USER_ONLY)
  vmstate_register(NULL, cpu_index, vmstate_cpu_common, env);
 +#if defined(CPU_SAVE_VERSION)
  register_savevm(NULL, cpu, cpu_index, CPU_SAVE_VERSION,
  cpu_save, cpu_load, env);
  #endif
 +#endif
  }
 
  /* Allocate a new translation block. Flush the translation buffer if

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH v5 00/35] VMState port of all cpus

2012-05-04 Thread Juan Quintela
This repository contains all the changes:

  git://repo.or.cz/qemu/quintela.git vmstate-cpus-v4

[v5]
- rebase on top
- sparc psr change behaviour: old behaviour was unintended, thanks Blu
- alexander agreed with ppc changes
- patch missing already included for ppc

Anthony, please pull.

[v4]
- rebase to top
- adapt to vmstate.h change
- adapt to CPUState - CPU$archState rename
- integrate arm changes in the meantime
- add QEMU contributors to the copyright notice of ppc  sparc

[v3]
- rebase to top
- fix sparc/arm/i386 changes in upstream
- all reviews were positive, Anthony, please pull

[v2] Changes since v1

- preserve arm comment that was missing (pbrook)
- add copyright notice to the files that were empty
- new patches:
  * fix formating for i386
  * remove unneeded includes
  * rename machine.c to vmstate.c


[v1]

This series port all cpus to use vmstate.
- 1st patch is a fix of vmstate.
- I discussed the arm changes over irc with Peter, he agreed that some
  simplification could be good, but he didn't saw the patches O:-)
- mips: no pci chipset has been ported, so migration don't work there.
  I have embedded a couple of structs to improve vmstate checking.  Notice
  that they were always allocated, so there shouldn't be any problem.
- sparc: I changed the format a little bit to be able to use normal arrays.
- sparc: If we always send the whole register windows, we don't need
  VMSTATE_VARRAY_MULTIPLY.  As that array is quite big (520 elements), I am not
  sure what is best.
- cpsr_vmstate on arm: I am not sure if I could abuse uncached_cpsr for that
  purpose?

I have only tested on x86, for the rest, I double checked, but it is
possible that I missed something.  I expect all patches to be
integrated by Anthony in one go.  Architecture maintainers are CC'd
for an ACK/NACK/comments.



Juan Quintela (35):
  vmstate: Simplify test for CPU_SAVE_VERSION
  vmstate: make all architectures export a way to migrate cpu's
  vmstate: unicore32 don't support cpu migration
  vmstate: use new cpu style for x86
  vmstate: use new style for lm32 cpus
  vmstate: make microblaze cpus not migrateable
  vmstate: port cris cpu to vmstate
  vmstate: introduce float32 arrays
  vmstate: introduce float64 arrays
  vmstate: introduce CPU_DoubleU arrays
  vmstate: Introduce VMSTATE_STRUCT_VARRAY_INT32_TEST
  vmstate: port ppc cpu
  vmstate: introduce VMSTATE_VARRAY_MULTIPLY
  vmstate: define vmstate_info_uinttls
  vmstate: port sparc cpu
  vmstate: make incompatible change for sparc
  mips_fulong2e: cpu vmstate already registered in cpu_exec_init
  mips: make mvp an embedded struct instead of a pointer
  mips: make tlb an embedded struct instead of a pointer
  mips: bump migration version to 4
  vmstate: port mips cpu
  arm: save always 32 fpu registers
  vmstate: port arm cpu
  vmstate: all cpus converted
  vmstate: fix vmstate formating for i386
  vmstate: remove unneeded includes from target-*/machine.c
  vmstate: rename machine.c to vmstate-cpu.c
  vmstate: Add copyright info for alpha processor
  vmstate: Add copyright info for lm32 processor
  vmstate: Add copyright info for cris processor
  vmstate: Add copyright info for arm processor
  vmstate: Add copyright info for i386 processor
  vmstate: Add copyright info for mips processor
  vmstate: Add copyright info for ppc processor
  vmstate: Add copyright info for sparc processor

 Makefile.target|3 +-
 exec.c |7 +-
 hw/hw.h|2 +
 hw/mips_fulong2e.c |1 -
 hw/mips_malta.c|4 +-
 hw/mips_timer.c|2 +-
 hw/sun4u.c |   20 --
 qemu-common.h  |4 -
 savevm.c   |   80 +++
 target-alpha/{machine.c = vmstate-cpu.c}  |   28 ++-
 target-arm/cpu.h   |5 +-
 target-arm/machine.c   |  233 -
 target-arm/vmstate-cpu.c   |  191 +
 target-cris/cpu.h  |   13 +-
 target-cris/machine.c  |   90 
 target-cris/vmstate-cpu.c  |   74 +++
 target-i386/cpu.h  |2 -
 target-i386/{machine.c = vmstate-cpu.c}   |   64 ---
 target-lm32/cpu.h  |2 -
 target-lm32/{machine.c = vmstate-cpu.c}   |   32 ++--
 target-m68k/vmstate-cpu.c  |   21 ++
 target-microblaze/cpu.h|2 -
 target-microblaze/machine.c|   11 -
 target-microblaze/vmstate-cpu.c|   21 ++
 target-mips/cpu.h  |   11 +-
 target-mips/helper.c   |   30 ++-
 target-mips/machine.c  |  308 
 target-mips/op_helper.c|   70 ---
 target-mips/translate.c 

[Qemu-devel] [PATCH 20/35] mips: bump migration version to 4

2012-05-04 Thread Juan Quintela
bcond state was stored as int32, but it is target_ulong.  Change migration state
to reflect that.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-mips/cpu.h |2 +-
 target-mips/machine.c |   10 --
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index aea2c5b..c77d270 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -502,7 +502,7 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 #define cpu_signal_handler cpu_mips_signal_handler
 #define cpu_list mips_cpu_list

-#define CPU_SAVE_VERSION 3
+#define CPU_SAVE_VERSION 4

 /* MMU modes definitions. We carefully match the indices with our
hflags layout. */
diff --git a/target-mips/machine.c b/target-mips/machine.c
index 4a1d2d8..8b9c0fb 100644
--- a/target-mips/machine.c
+++ b/target-mips/machine.c
@@ -84,8 +84,7 @@ void cpu_save(QEMUFile *f, void *opaque)
 qemu_put_sbe32s(f, env-error_code);
 qemu_put_be32s(f, env-hflags);
 qemu_put_betls(f, env-btarget);
-i = env-bcond;
-qemu_put_sbe32s(f, i);
+qemu_put_betls(f, env-bcond);

 /* Save remaining CP1 registers */
 qemu_put_sbe32s(f, env-CP0_Index);
@@ -193,9 +192,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
 CPUMIPSState *env = opaque;
 int i;

-if (version_id != 3)
+if (version_id != 4) {
 return -EINVAL;
-
+}
 /* Load active TC */
 load_tc(f, env-active_tc);

@@ -236,8 +235,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
 qemu_get_sbe32s(f, env-error_code);
 qemu_get_be32s(f, env-hflags);
 qemu_get_betls(f, env-btarget);
-qemu_get_sbe32s(f, i);
-env-bcond = i;
+qemu_get_betls(f, env-bcond);

 /* Load remaining CP1 registers */
 qemu_get_sbe32s(f, env-CP0_Index);
-- 
1.7.7.6




[Qemu-devel] [PATCH 12/35] vmstate: port ppc cpu

2012-05-04 Thread Juan Quintela
Added sdr1_vmstate because storing the value requires calling ppc_store_sdr1().
The position when the function is called also changes (I think it is save).

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-ppc/cpu.h |5 +-
 target-ppc/machine.c |  245 ++
 2 files changed, 90 insertions(+), 160 deletions(-)

diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 84c9674..473e1a6 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1064,6 +1064,9 @@ struct CPUPPCState {
  */
 uint8_t fit_period[4];
 uint8_t wdt_period[4];
+
+/* Fields needed as intermediate for vmstate */
+target_ulong sdr1_vmstate;
 };

 #define SET_FIT_PERIOD(a_, b_, c_, d_)  \
@@ -1220,8 +1223,6 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t 
val);
 #define cpu_signal_handler cpu_ppc_signal_handler
 #define cpu_list ppc_cpu_list

-#define CPU_SAVE_VERSION 4
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _user
 #define MMU_MODE1_SUFFIX _kernel
diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index d6c2ee4..ca60bc0 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -2,172 +2,101 @@
 #include hw/boards.h
 #include kvm.h

-void cpu_save(QEMUFile *f, void *opaque)
+static const VMStateDescription vmstate_tlb = {
+.name = tlb,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINTTL(pte0, ppc6xx_tlb_t),
+VMSTATE_UINTTL(pte1, ppc6xx_tlb_t),
+VMSTATE_UINTTL(EPN, ppc6xx_tlb_t),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static bool is_tlb6(void *opaque, int version_id)
 {
-CPUPPCState *env = (CPUPPCState *)opaque;
-unsigned int i, j;
+CPUPPCState *env = opaque;

-for (i = 0; i  32; i++)
-qemu_put_betls(f, env-gpr[i]);
-#if !defined(TARGET_PPC64)
-for (i = 0; i  32; i++)
-qemu_put_betls(f, env-gprh[i]);
-#endif
-qemu_put_betls(f, env-lr);
-qemu_put_betls(f, env-ctr);
-for (i = 0; i  8; i++)
-qemu_put_be32s(f, env-crf[i]);
-qemu_put_betls(f, env-xer);
-qemu_put_betls(f, env-reserve_addr);
-qemu_put_betls(f, env-msr);
-for (i = 0; i  4; i++)
-qemu_put_betls(f, env-tgpr[i]);
-for (i = 0; i  32; i++) {
-union {
-float64 d;
-uint64_t l;
-} u;
-u.d = env-fpr[i];
-qemu_put_be64(f, u.l);
-}
-qemu_put_be32s(f, env-fpscr);
-qemu_put_sbe32s(f, env-access_type);
-#if defined(TARGET_PPC64)
-qemu_put_betls(f, env-asr);
-qemu_put_sbe32s(f, env-slb_nr);
-#endif
-qemu_put_betls(f, env-spr[SPR_SDR1]);
-for (i = 0; i  32; i++)
-qemu_put_betls(f, env-sr[i]);
-for (i = 0; i  2; i++)
-for (j = 0; j  8; j++)
-qemu_put_betls(f, env-DBAT[i][j]);
-for (i = 0; i  2; i++)
-for (j = 0; j  8; j++)
-qemu_put_betls(f, env-IBAT[i][j]);
-qemu_put_sbe32s(f, env-nb_tlb);
-qemu_put_sbe32s(f, env-tlb_per_way);
-qemu_put_sbe32s(f, env-nb_ways);
-qemu_put_sbe32s(f, env-last_way);
-qemu_put_sbe32s(f, env-id_tlbs);
-qemu_put_sbe32s(f, env-nb_pids);
-if (env-tlb.tlb6) {
-// XXX assumes 6xx
-for (i = 0; i  env-nb_tlb; i++) {
-qemu_put_betls(f, env-tlb.tlb6[i].pte0);
-qemu_put_betls(f, env-tlb.tlb6[i].pte1);
-qemu_put_betls(f, env-tlb.tlb6[i].EPN);
-}
-}
-for (i = 0; i  4; i++)
-qemu_put_betls(f, env-pb[i]);
-for (i = 0; i  1024; i++)
-qemu_put_betls(f, env-spr[i]);
-qemu_put_be32s(f, env-vscr);
-qemu_put_be64s(f, env-spe_acc);
-qemu_put_be32s(f, env-spe_fscr);
-qemu_put_betls(f, env-msr_mask);
-qemu_put_be32s(f, env-flags);
-qemu_put_sbe32s(f, env-error_code);
-qemu_put_be32s(f, env-pending_interrupts);
-qemu_put_be32s(f, env-irq_input_state);
-for (i = 0; i  POWERPC_EXCP_NB; i++)
-qemu_put_betls(f, env-excp_vectors[i]);
-qemu_put_betls(f, env-excp_prefix);
-qemu_put_betls(f, env-hreset_excp_prefix);
-qemu_put_betls(f, env-ivor_mask);
-qemu_put_betls(f, env-ivpr_mask);
-qemu_put_betls(f, env-hreset_vector);
-qemu_put_betls(f, env-nip);
-qemu_put_betls(f, env-hflags);
-qemu_put_betls(f, env-hflags_nmsr);
-qemu_put_sbe32s(f, env-mmu_idx);
-qemu_put_sbe32s(f, env-power_mode);
+return (env-tlb.tlb6 != NULL);
 }

-int cpu_load(QEMUFile *f, void *opaque, int version_id)
+static void cpu_pre_save(void *opaque)
 {
-CPUPPCState *env = (CPUPPCState *)opaque;
-unsigned int i, j;
-target_ulong sdr1;
+CPUPPCState *env = opaque;
+env-sdr1_vmstate = env-spr[SPR_SDR1];
+}

-for (i = 0; i  32; i++)
-qemu_get_betls(f, env-gpr[i]);
+static int cpu_post_load(void *opaque, int version_id)
+{
+CPUPPCState *env = opaque;
+ppc_store_sdr1(env, env-sdr1_vmstate);
+return 0;
+}
+
+const VMStateDescription 

Re: [Qemu-devel] [RFC 0/9] Virtio-mmio refactoring.

2012-05-04 Thread Evgeny Voevodin

On 04.05.2012 07:41, Evgeny Voevodin wrote:

On 03.05.2012 16:14, Peter Maydell wrote:

On 25 April 2012 06:54, Evgeny Voevodine.voevo...@samsung.com wrote:

In this patchset refactoring of virtio-mmio layer is made.
Instead of creating virtio-blk-mmio, virtio-net-mmio, etc on the
system bus
we create virtio-blk, virtio-net, etc devices on the virtio-transport
bus.
To create virtio-transport bus virtio-mmio-transport device provided.
Transport device plugs into virtio-mmio bus.
To create virtio-mmio bus virtio-mmio-bridge device provided.

This seems to me to have one more layer than it needs. Why not just:
create virtio-blk, virtio-net, etc on the virtio-transport bus
To create virtio-transport bus, we create a virtio-mmio-transport
device, and this device is a sysbus device.

ie why do you have separate virtio-mmio-transport and
virtio-mmio-bridge devices, and two different new buses (virtio-mmio
and virtio-transport) rather than just virtio-transport?

-- PMM



Actually, the only necessity to have a bridge device is to count amount
of transport devices. Amount of transport devices we need to know because
we want to specify names to transport buses (virtio-mmio.0,
virtio-mmio.1, ...).
If there is a way to find out amount of transport devices on sysbus (and
on pci bus)
we don't need bridge device.
Maybe, there is also another way to specify bus names instead of just
get parent bus name
and add transport device's index as a tail.



Ok, seems that we don't need that bridge device. Each transport device
can run through all childs of parent bus and look if they have created 
virtio bus and then specify appropriate name to its virtio bus.


--
Kind regards,
Evgeny Voevodin,
Leading Software Engineer,
ASWG, Moscow RD center, Samsung Electronics
e-mail: e.voevo...@samsung.com



Re: [Qemu-devel] [PATCH 01/35] vmstate: Simplify test for CPU_SAVE_VERSION

2012-05-04 Thread Juan Quintela
Andreas Färber afaer...@suse.de wrote:
 Am 04.05.2012 12:54, schrieb Juan Quintela:
 Some cpu's definitions define CPU_SAVE_VERSION, others not, but they have

 CPUs' definitions?

 defined cpu_save/load.

 This commit message sounds wrong. Use of cpu_save/load is still coupled
 to CPU_SAVE_VERSION AFAICS.

 What really changes is that vmstate_cpu_common is now registered whether
 or not the target supports loading/saving the target-specific parts,
 isn't it? Is that really useful? Either way, the commit message should
 be updated.

For the cpus that weren't using CPU_SAVE_VERSION, we now register the
system as unmigratable, so this don't matter.  For the cpus that support
migration, it was always sent.  Code now is trivial to understand:

#if !defined(CONFIG_USER_ONLY)
vmstate_register(NULL, cpu_index, vmstate_cpu_common, env);
vmstate_register(NULL, cpu_index, vmstate_cpu, env);
#endif

Befor it was a maze of ifdefs.  No change of behaviour with what we had
before.  For either cpus that had[not]  support for migration or not.



Re: [Qemu-devel] [PATCH 08/35] vmstate: introduce float32 arrays

2012-05-04 Thread Andreas Färber
Am 04.05.2012 12:54, schrieb Juan Quintela:
 Signed-off-by: Juan Quintela quint...@redhat.com
 ---
  savevm.c  |   25 +
  vmstate.h |5 +
  2 files changed, 30 insertions(+), 0 deletions(-)
 
 diff --git a/savevm.c b/savevm.c
 index 2d18bab..a22278e 100644
 --- a/savevm.c
 +++ b/savevm.c
 @@ -1082,6 +1082,31 @@ const VMStateInfo vmstate_info_uint16_equal = {
  .put  = put_uint16,
  };
 
 +/* 32 bit float */
 +
 +static int get_float32(QEMUFile *f, void *pv, size_t size)
 +{
 +float32 *v = pv;
 +uint32_t u;
 +qemu_get_be32s(f, u);
 +*v = make_float32(u);
 +return 0;
 +}
 +
 +static void put_float32(QEMUFile *f, void *pv, size_t size)
 +{
 +float32 *v = pv;
 +uint32_t u;
 +u = float32_val(*v);
 +qemu_put_be32s(f, u);
 +}
 +
 +const VMStateInfo vmstate_info_float32 = {
 +.name = float32,
 +.get  = get_float32,
 +.put  = put_float32,
 +};
 +
  /* timers  */
 
  static int get_timer(QEMUFile *f, void *pv, size_t size)
 diff --git a/vmstate.h b/vmstate.h
 index 1a4a60b..135c5aa 100644
 --- a/vmstate.h
 +++ b/vmstate.h
 @@ -130,6 +130,8 @@ extern const VMStateInfo vmstate_info_uint16;
  extern const VMStateInfo vmstate_info_uint32;
  extern const VMStateInfo vmstate_info_uint64;
 
 +extern const VMStateInfo vmstate_info_float32;
 +
  extern const VMStateInfo vmstate_info_timer;
  extern const VMStateInfo vmstate_info_buffer;
  extern const VMStateInfo vmstate_info_unused_buffer;
 @@ -559,6 +561,9 @@ extern const VMStateDescription vmstate_cpu;
  #define VMSTATE_INT64_ARRAY(_f, _s, _n)   \
  VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
 
 +#define VMSTATE_FLOAT32_ARRAY(_f, _s, _n) \
 +VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)

Why isn't there a VMSTATE_FLOAT32_ARRAY_V for symmetry? Otherwise looks
fine.

/-F

 +
  #define VMSTATE_BUFFER_V(_f, _s, _v)  \
  VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
 

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 30/35] vmstate: Add copyright info for cris processor

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
Acked-by: Edgar E. Iglesias edgar.igles...@gmail.com
---
 target-cris/vmstate-cpu.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/target-cris/vmstate-cpu.c b/target-cris/vmstate-cpu.c
index 1dbf8b5..47ac170 100644
--- a/target-cris/vmstate-cpu.c
+++ b/target-cris/vmstate-cpu.c
@@ -1,3 +1,18 @@
+/*
+ * Migration support for cris cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Based on savevm serialization code by:
+ *  Edgar E. Iglesias edgar.igles...@gmail.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
 #include hw/hw.h

 static const VMStateDescription vmstate_tlbset = {
-- 
1.7.7.6




Re: [Qemu-devel] [PATCH 01/35] vmstate: Simplify test for CPU_SAVE_VERSION

2012-05-04 Thread Andreas Färber
Am 04.05.2012 13:59, schrieb Juan Quintela:
 Andreas Färber afaer...@suse.de wrote:
 Am 04.05.2012 12:54, schrieb Juan Quintela:
 Some cpu's definitions define CPU_SAVE_VERSION, others not, but they have

 CPUs' definitions?

 defined cpu_save/load.

 This commit message sounds wrong. Use of cpu_save/load is still coupled
 to CPU_SAVE_VERSION AFAICS.

 What really changes is that vmstate_cpu_common is now registered whether
 or not the target supports loading/saving the target-specific parts,
 isn't it? Is that really useful? Either way, the commit message should
 be updated.
 
 For the cpus that weren't using CPU_SAVE_VERSION, we now register the
 system as unmigratable, so this don't matter.  For the cpus that support
 migration, it was always sent.  Code now is trivial to understand:
 
 #if !defined(CONFIG_USER_ONLY)
 vmstate_register(NULL, cpu_index, vmstate_cpu_common, env);
 vmstate_register(NULL, cpu_index, vmstate_cpu, env);
 #endif

No, that's not what's in the patch.

 Befor it was a maze of ifdefs.  No change of behaviour with what we had
 before.  For either cpus that had[not]  support for migration or not.

Please look at the patch again - it turns the one-ifdef block into two
nested ifdefs. So therefore it is my understanding that - in lack of
unmigratable VMSDs this patch - possibly temporarily, not all patches
have arrived yet - changes the migration format in an odd way. In that
case we should consider reordering the patch within the series.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 32/35] vmstate: Add copyright info for i386 processor

2012-05-04 Thread Juan Quintela
v2: Move license to BSD-like as in vl.c
Add Fabrice copyright from vl.c

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-i386/vmstate-cpu.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/target-i386/vmstate-cpu.c b/target-i386/vmstate-cpu.c
index 0ef12ac..3a321e4 100644
--- a/target-i386/vmstate-cpu.c
+++ b/target-i386/vmstate-cpu.c
@@ -1,3 +1,31 @@
+/*
+ * Migration support for x86 cpu
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
 #include hw/hw.h

 static const VMStateDescription vmstate_segment = {
-- 
1.7.7.6




[Qemu-devel] [PATCH 31/35] vmstate: Add copyright info for arm processor

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
Acked-by: Andrzej Zaborowski andrew.zaborow...@intel.com
---
 target-arm/vmstate-cpu.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/target-arm/vmstate-cpu.c b/target-arm/vmstate-cpu.c
index f8ccdd7..65ed6eb 100644
--- a/target-arm/vmstate-cpu.c
+++ b/target-arm/vmstate-cpu.c
@@ -1,3 +1,18 @@
+/*
+ * Migration support for arm cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Based on savevm serialization code by:
+ *  Andrzej Zaborowski andrew.zaborow...@intel.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
 #include hw/hw.h

 static bool feature_vfp_needed(void *opaque)
-- 
1.7.7.6




[Qemu-devel] [PATCH 07/35] vmstate: port cris cpu to vmstate

2012-05-04 Thread Juan Quintela
Have to define TLBSet struct.
Multidimensional arrays in C are a mess, just unroll them.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-cris/cpu.h |   13 ++---
 target-cris/machine.c |  138 +++--
 2 files changed, 60 insertions(+), 91 deletions(-)

diff --git a/target-cris/cpu.h b/target-cris/cpu.h
index 5449cc4..6d14147 100644
--- a/target-cris/cpu.h
+++ b/target-cris/cpu.h
@@ -104,6 +104,11 @@

 #define NB_MMU_MODES 2

+typedef struct {
+uint32_t hi;
+uint32_t lo;
+} TLBSet;
+
 typedef struct CPUCRISState {
uint32_t regs[16];
/* P0 - P15 are referred to as special registers in the docs.  */
@@ -157,11 +162,7 @@ typedef struct CPUCRISState {
 *
 * One for I and another for D.
 */
-   struct
-   {
-   uint32_t hi;
-   uint32_t lo;
-   } tlbsets[2][4][16];
+   TLBSet tlbsets[2][4][16];

CPU_COMMON

@@ -221,8 +222,6 @@ enum {
 #define cpu_gen_code cpu_cris_gen_code
 #define cpu_signal_handler cpu_cris_signal_handler

-#define CPU_SAVE_VERSION 1
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
diff --git a/target-cris/machine.c b/target-cris/machine.c
index 8f9c0dd..1b96265 100644
--- a/target-cris/machine.c
+++ b/target-cris/machine.c
@@ -1,90 +1,60 @@
 #include hw/hw.h
 #include hw/boards.h

-void cpu_save(QEMUFile *f, void *opaque)
-{
-CPUCRISState *env = opaque;
-int i;
-int s;
-int mmu;
-
-for (i = 0; i  16; i++)
-qemu_put_be32(f, env-regs[i]);
-for (i = 0; i  16; i++)
-qemu_put_be32(f, env-pregs[i]);
-
-qemu_put_be32(f, env-pc);
-qemu_put_be32(f, env-ksp);
-
-qemu_put_be32(f, env-dslot);
-qemu_put_be32(f, env-btaken);
-qemu_put_be32(f, env-btarget);
-
-qemu_put_be32(f, env-cc_op);
-qemu_put_be32(f, env-cc_mask);
-qemu_put_be32(f, env-cc_dest);
-qemu_put_be32(f, env-cc_src);
-qemu_put_be32(f, env-cc_result);
-qemu_put_be32(f, env-cc_size);
-qemu_put_be32(f, env-cc_x);
-
-for (s = 0; s  4; s++) {
-for (i = 0; i  16; i++)
-qemu_put_be32(f, env-sregs[s][i]);
-}
-
-qemu_put_be32(f, env-mmu_rand_lfsr);
-for (mmu = 0; mmu  2; mmu++) {
-for (s = 0; s  4; s++) {
-for (i = 0; i  16; i++) {
-qemu_put_be32(f, env-tlbsets[mmu][s][i].lo);
-qemu_put_be32(f, env-tlbsets[mmu][s][i].hi);
-}
-}
+static const VMStateDescription vmstate_tlbset = {
+.name = cpu/tlbset,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINT32(lo, TLBSet),
+VMSTATE_UINT32(hi, TLBSet),
+VMSTATE_END_OF_LIST()
 }
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-   CPUCRISState *env = opaque;
-int i;
-int s;
-int mmu;
-
-for (i = 0; i  16; i++)
-env-regs[i] = qemu_get_be32(f);
-for (i = 0; i  16; i++)
-env-pregs[i] = qemu_get_be32(f);
-
-env-pc = qemu_get_be32(f);
-env-ksp = qemu_get_be32(f);
-
-env-dslot = qemu_get_be32(f);
-env-btaken = qemu_get_be32(f);
-env-btarget = qemu_get_be32(f);
-
-env-cc_op = qemu_get_be32(f);
-env-cc_mask = qemu_get_be32(f);
-env-cc_dest = qemu_get_be32(f);
-env-cc_src = qemu_get_be32(f);
-env-cc_result = qemu_get_be32(f);
-env-cc_size = qemu_get_be32(f);
-env-cc_x = qemu_get_be32(f);
-
-for (s = 0; s  4; s++) {
-for (i = 0; i  16; i++)
-env-sregs[s][i] = qemu_get_be32(f);
-}
-
-env-mmu_rand_lfsr = qemu_get_be32(f);
-for (mmu = 0; mmu  2; mmu++) {
-for (s = 0; s  4; s++) {
-for (i = 0; i  16; i++) {
-env-tlbsets[mmu][s][i].lo = qemu_get_be32(f);
-env-tlbsets[mmu][s][i].hi = qemu_get_be32(f);
-}
-}
+};
+
+const VMStateDescription vmstate_cpu = {
+.name = cpu,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINT32_ARRAY(regs, CPUCRISState, 16),
+VMSTATE_UINT32_ARRAY(pregs, CPUCRISState, 16),
+VMSTATE_UINT32(pc, CPUCRISState),
+VMSTATE_UINT32(ksp, CPUCRISState),
+VMSTATE_INT32(dslot, CPUCRISState),
+VMSTATE_INT32(btaken, CPUCRISState),
+VMSTATE_UINT32(btarget, CPUCRISState),
+VMSTATE_UINT32(cc_op, CPUCRISState),
+VMSTATE_UINT32(cc_mask, CPUCRISState),
+VMSTATE_UINT32(cc_dest, CPUCRISState),
+VMSTATE_UINT32(cc_src, CPUCRISState),
+VMSTATE_UINT32(cc_result, CPUCRISState),
+VMSTATE_INT32(cc_size, CPUCRISState),
+VMSTATE_INT32(cc_x, CPUCRISState),
+VMSTATE_UINT32_ARRAY(sregs[0], CPUCRISState, 16),
+VMSTATE_UINT32_ARRAY(sregs[1], CPUCRISState, 16),
+VMSTATE_UINT32_ARRAY(sregs[2], CPUCRISState, 

[Qemu-devel] [PATCH 05/35] vmstate: use new style for lm32 cpus

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-lm32/cpu.h |2 --
 target-lm32/machine.c |   14 ++
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h
index 422a55b..049936a 100644
--- a/target-lm32/cpu.h
+++ b/target-lm32/cpu.h
@@ -205,8 +205,6 @@ void cpu_lm32_set_phys_msb_ignore(CPULM32State *env, int 
value);
 #define cpu_gen_code cpu_lm32_gen_code
 #define cpu_signal_handler cpu_lm32_signal_handler

-#define CPU_SAVE_VERSION 1
-
 int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw,
   int mmu_idx);
 #define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index ed71bc4..24db6c0 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -3,10 +3,10 @@

 const VMStateDescription vmstate_cpu = {
 .name = cpu,
-.version_id = CPU_SAVE_VERSION,
+.version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.fields  = (VMStateField[]) {
+.fields = (VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, CPULM32State, 32),
 VMSTATE_UINT32(pc, CPULM32State),
 VMSTATE_UINT32(ie, CPULM32State),
@@ -21,13 +21,3 @@ const VMStateDescription vmstate_cpu = {
 VMSTATE_END_OF_LIST()
 }
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-vmstate_save_state(f, vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-return vmstate_load_state(f, vmstate_cpu, opaque, version_id);
-}
-- 
1.7.7.6




[Qemu-devel] [PATCH 23/35] vmstate: port arm cpu

2012-05-04 Thread Juan Quintela
Use one subsection for each feature.  This means that we don't need to
bump the version field each time that a new feature gets introduced.

Introduce cpsr_vmstate field, as I am not sure if I can use
uncached_cpsr for saving state.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-arm/cpu.h |5 +-
 target-arm/machine.c |  344 ++
 2 files changed, 156 insertions(+), 193 deletions(-)

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 9434902..37744c6 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -236,6 +236,9 @@ typedef struct CPUARMState {
 } cp[15];
 void *nvic;
 const struct arm_boot_info *boot_info;
+
+/* Fields needed as intermediate for vmstate */
+uint32_t cpsr_vmstate;
 } CPUARMState;

 #include cpu-qom.h
@@ -464,8 +467,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list

-#define CPU_SAVE_VERSION 7
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
diff --git a/target-arm/machine.c b/target-arm/machine.c
index 9c0f773..31e49ac 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -1,215 +1,177 @@
 #include hw/hw.h
 #include hw/boards.h

-void cpu_save(QEMUFile *f, void *opaque)
+static bool feature_vfp_needed(void *opaque)
 {
-int i;
-CPUARMState *env = (CPUARMState *)opaque;
+CPUARMState *env = opaque;

-for (i = 0; i  16; i++) {
-qemu_put_be32(f, env-regs[i]);
-}
-qemu_put_be32(f, cpsr_read(env));
-qemu_put_be32(f, env-spsr);
-for (i = 0; i  6; i++) {
-qemu_put_be32(f, env-banked_spsr[i]);
-qemu_put_be32(f, env-banked_r13[i]);
-qemu_put_be32(f, env-banked_r14[i]);
-}
-for (i = 0; i  5; i++) {
-qemu_put_be32(f, env-usr_regs[i]);
-qemu_put_be32(f, env-fiq_regs[i]);
-}
-qemu_put_be32(f, env-cp15.c0_cpuid);
-qemu_put_be32(f, env-cp15.c0_cachetype);
-qemu_put_be32(f, env-cp15.c0_cssel);
-qemu_put_be32(f, env-cp15.c1_sys);
-qemu_put_be32(f, env-cp15.c1_coproc);
-qemu_put_be32(f, env-cp15.c1_xscaleauxcr);
-qemu_put_be32(f, env-cp15.c1_scr);
-qemu_put_be32(f, env-cp15.c2_base0);
-qemu_put_be32(f, env-cp15.c2_base1);
-qemu_put_be32(f, env-cp15.c2_control);
-qemu_put_be32(f, env-cp15.c2_mask);
-qemu_put_be32(f, env-cp15.c2_base_mask);
-qemu_put_be32(f, env-cp15.c2_data);
-qemu_put_be32(f, env-cp15.c2_insn);
-qemu_put_be32(f, env-cp15.c3);
-qemu_put_be32(f, env-cp15.c5_insn);
-qemu_put_be32(f, env-cp15.c5_data);
-for (i = 0; i  8; i++) {
-qemu_put_be32(f, env-cp15.c6_region[i]);
-}
-qemu_put_be32(f, env-cp15.c6_insn);
-qemu_put_be32(f, env-cp15.c6_data);
-qemu_put_be32(f, env-cp15.c7_par);
-qemu_put_be32(f, env-cp15.c9_insn);
-qemu_put_be32(f, env-cp15.c9_data);
-qemu_put_be32(f, env-cp15.c9_pmcr);
-qemu_put_be32(f, env-cp15.c9_pmcnten);
-qemu_put_be32(f, env-cp15.c9_pmovsr);
-qemu_put_be32(f, env-cp15.c9_pmxevtyper);
-qemu_put_be32(f, env-cp15.c9_pmuserenr);
-qemu_put_be32(f, env-cp15.c9_pminten);
-qemu_put_be32(f, env-cp15.c13_fcse);
-qemu_put_be32(f, env-cp15.c13_context);
-qemu_put_be32(f, env-cp15.c13_tls1);
-qemu_put_be32(f, env-cp15.c13_tls2);
-qemu_put_be32(f, env-cp15.c13_tls3);
-qemu_put_be32(f, env-cp15.c15_cpar);
-qemu_put_be32(f, env-cp15.c15_power_control);
-qemu_put_be32(f, env-cp15.c15_diagnostic);
-qemu_put_be32(f, env-cp15.c15_power_diagnostic);
-
-qemu_put_be32(f, env-features);
-
-if (arm_feature(env, ARM_FEATURE_VFP)) {
-for (i = 0;  i  32; i++) {
-CPU_DoubleU u;
-u.d = env-vfp.regs[i];
-qemu_put_be32(f, u.l.upper);
-qemu_put_be32(f, u.l.lower);
-}
-for (i = 0; i  16; i++) {
-qemu_put_be32(f, env-vfp.xregs[i]);
-}
+return arm_feature(env, ARM_FEATURE_VFP);
+}

+static const VMStateDescription vmstate_feature_vfp = {
+.name = feature_vfp,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_FLOAT64_ARRAY(vfp.regs, CPUARMState, 32),
+VMSTATE_UINT32_ARRAY(vfp.xregs, CPUARMState, 16),
 /* TODO: Should use proper FPSCR access functions.  */
-qemu_put_be32(f, env-vfp.vec_len);
-qemu_put_be32(f, env-vfp.vec_stride);
+VMSTATE_INT32(vfp.vec_len, CPUARMState),
+VMSTATE_INT32(vfp.vec_stride, CPUARMState),
+VMSTATE_END_OF_LIST()
 }
+};

-if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
-for (i = 0; i  16; i++) {
-qemu_put_be64(f, env-iwmmxt.regs[i]);
-}
-for (i = 0; i  16; i++) {
-qemu_put_be32(f, env-iwmmxt.cregs[i]);
-}
-}
+static bool feature_iwmmxt_needed(void *opaque)
+{
+CPUARMState *env = 

[Qemu-devel] [PATCH 24/35] vmstate: all cpus converted

2012-05-04 Thread Juan Quintela
We don't have any more CPU_SAVEVM_VERSION users, neither
cpu_save/load() ones.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 exec.c|5 -
 qemu-common.h |4 
 2 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/exec.c b/exec.c
index 85f0d61..1deb943 100644
--- a/exec.c
+++ b/exec.c
@@ -719,13 +719,8 @@ void cpu_exec_init(CPUArchState *env)
 #endif
 #if !defined(CONFIG_USER_ONLY)
 vmstate_register(NULL, cpu_index, vmstate_cpu_common, env);
-#if defined(CPU_SAVE_VERSION)
-register_savevm(NULL, cpu, cpu_index, CPU_SAVE_VERSION,
-cpu_save, cpu_load, env);
-#else
 vmstate_register(NULL, cpu_index, vmstate_cpu, env);
 #endif
-#endif
 }

 /* Allocate a new translation block. Flush the translation buffer if
diff --git a/qemu-common.h b/qemu-common.h
index 50f659a..4c2ebbb 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -275,10 +275,6 @@ bool tcg_enabled(void);

 void cpu_exec_init_all(void);

-/* CPU save/load.  */
-void cpu_save(QEMUFile *f, void *opaque);
-int cpu_load(QEMUFile *f, void *opaque, int version_id);
-
 /* Unblock cpu */
 void qemu_cpu_kick(void *env);
 void qemu_cpu_kick_self(void);
-- 
1.7.7.6




[Qemu-devel] [PATCH 18/35] mips: make mvp an embedded struct instead of a pointer

2012-05-04 Thread Juan Quintela
Adjust all callers.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/mips_malta.c  |4 ++--
 target-mips/cpu.h|4 ++--
 target-mips/machine.c|   12 ++--
 target-mips/op_helper.c  |   30 +-
 target-mips/translate.c  |6 +++---
 target-mips/translate_init.c |   14 ++
 6 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 4752bb2..a1cdab5 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -745,8 +745,8 @@ static int64_t load_kernel (void)

 static void malta_mips_config(CPUMIPSState *env)
 {
-env-mvp-CP0_MVPConf0 |= ((smp_cpus - 1)  CP0MVPC0_PVPE) |
- ((smp_cpus * env-nr_threads - 1)  CP0MVPC0_PTC);
+env-mvp.CP0_MVPConf0 |= ((smp_cpus - 1)  CP0MVPC0_PVPE) |
+  ((smp_cpus * env-nr_threads - 1)  CP0MVPC0_PTC);
 }

 static void main_cpu_reset(void *opaque)
diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index c0f8826..659dba9 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -466,7 +466,7 @@ struct CPUMIPSState {

 CPU_COMMON

-CPUMIPSMVPContext *mvp;
+CPUMIPSMVPContext mvp;
 #if !defined(CONFIG_USER_ONLY)
 CPUMIPSTLBContext *tlb;
 #endif
@@ -670,7 +670,7 @@ static inline int mips_vpe_active(CPUMIPSState *env)
 int active = 1;

 /* Check that the VPE is enabled.  */
-if (!(env-mvp-CP0_MVPControl  (1  CP0MVPCo_EVP))) {
+if (!(env-mvp.CP0_MVPControl  (1  CP0MVPCo_EVP))) {
 active = 0;
 }
 /* Check that the VPE is activated.  */
diff --git a/target-mips/machine.c b/target-mips/machine.c
index 23504ba..d5d8865 100644
--- a/target-mips/machine.c
+++ b/target-mips/machine.c
@@ -52,9 +52,9 @@ void cpu_save(QEMUFile *f, void *opaque)
 save_fpu(f, env-active_fpu);

 /* Save MVP */
-qemu_put_sbe32s(f, env-mvp-CP0_MVPControl);
-qemu_put_sbe32s(f, env-mvp-CP0_MVPConf0);
-qemu_put_sbe32s(f, env-mvp-CP0_MVPConf1);
+qemu_put_sbe32s(f, env-mvp.CP0_MVPControl);
+qemu_put_sbe32s(f, env-mvp.CP0_MVPConf0);
+qemu_put_sbe32s(f, env-mvp.CP0_MVPConf1);

 /* Save TLB */
 qemu_put_be32s(f, env-tlb-nb_tlb);
@@ -203,9 +203,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
 load_fpu(f, env-active_fpu);

 /* Load MVP */
-qemu_get_sbe32s(f, env-mvp-CP0_MVPControl);
-qemu_get_sbe32s(f, env-mvp-CP0_MVPConf0);
-qemu_get_sbe32s(f, env-mvp-CP0_MVPConf1);
+qemu_get_sbe32s(f, env-mvp.CP0_MVPControl);
+qemu_get_sbe32s(f, env-mvp.CP0_MVPConf0);
+qemu_get_sbe32s(f, env-mvp.CP0_MVPConf1);

 /* Load TLB */
 qemu_get_be32s(f, env-tlb-nb_tlb);
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 5627447..16d9cb8 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -908,17 +908,17 @@ static void sync_c0_entryhi(CPUMIPSState *cpu, int tc)
 /* CP0 helpers */
 target_ulong helper_mfc0_mvpcontrol (void)
 {
-return env-mvp-CP0_MVPControl;
+return env-mvp.CP0_MVPControl;
 }

 target_ulong helper_mfc0_mvpconf0 (void)
 {
-return env-mvp-CP0_MVPConf0;
+return env-mvp.CP0_MVPConf0;
 }

 target_ulong helper_mfc0_mvpconf1 (void)
 {
-return env-mvp-CP0_MVPConf1;
+return env-mvp.CP0_MVPConf1;
 }

 target_ulong helper_mfc0_random (void)
@@ -1171,13 +1171,14 @@ void helper_mtc0_mvpcontrol (target_ulong arg1)
 if (env-CP0_VPEConf0  (1  CP0VPEC0_MVP))
 mask |= (1  CP0MVPCo_CPA) | (1  CP0MVPCo_VPC) |
 (1  CP0MVPCo_EVP);
-if (env-mvp-CP0_MVPControl  (1  CP0MVPCo_VPC))
+if (env-mvp.CP0_MVPControl  (1  CP0MVPCo_VPC)) {
 mask |= (1  CP0MVPCo_STLB);
-newval = (env-mvp-CP0_MVPControl  ~mask) | (arg1  mask);
+}
+newval = (env-mvp.CP0_MVPControl  ~mask) | (arg1  mask);

 // TODO: Enable/disable shared TLB, enable/disable VPEs.

-env-mvp-CP0_MVPControl = newval;
+env-mvp.CP0_MVPControl = newval;
 }

 void helper_mtc0_vpecontrol (target_ulong arg1)
@@ -1265,9 +1266,10 @@ void helper_mtc0_vpeconf1 (target_ulong arg1)
 uint32_t mask = 0;
 uint32_t newval;

-if (env-mvp-CP0_MVPControl  (1  CP0MVPCo_VPC))
+if (env-mvp.CP0_MVPControl  (1  CP0MVPCo_VPC)) {
 mask |= (0xff  CP0VPEC1_NCX) | (0xff  CP0VPEC1_NCP2) |
 (0xff  CP0VPEC1_NCP1);
+}
 newval = (env-CP0_VPEConf1  ~mask) | (arg1  mask);

 /* UDI not implemented. */
@@ -1324,8 +1326,9 @@ void helper_mtc0_tcbind (target_ulong arg1)
 uint32_t mask = (1  CP0TCBd_TBE);
 uint32_t newval;

-if (env-mvp-CP0_MVPControl  (1  CP0MVPCo_VPC))
+if (env-mvp.CP0_MVPControl  (1  CP0MVPCo_VPC)) {
 mask |= (1  CP0TCBd_CurVPE);
+}
 newval = (env-active_tc.CP0_TCBind  ~mask) | (arg1  mask);
 env-active_tc.CP0_TCBind = newval;
 }
@@ -1337,8 +1340,9 @@ void helper_mttc0_tcbind (target_ulong arg1)
 uint32_t newval;
 CPUMIPSState *other = mips_cpu_map_tc(other_tc);

-if 

[Qemu-devel] [PATCH 21/35] vmstate: port mips cpu

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-mips/cpu.h |5 +-
 target-mips/machine.c |  465 +++--
 2 files changed, 182 insertions(+), 288 deletions(-)

diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index c77d270..8eb6173 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -30,6 +30,9 @@ struct r4k_tlb_t {
 uint_fast16_t D0:1;
 uint_fast16_t D1:1;
 target_ulong PFN[2];
+/* Fields needed as intermediate for vmstate */
+uint8_t asid_vmstate;
+uint16_t flags_vmstate;
 };

 #if !defined(CONFIG_USER_ONLY)
@@ -502,8 +505,6 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 #define cpu_signal_handler cpu_mips_signal_handler
 #define cpu_list mips_cpu_list

-#define CPU_SAVE_VERSION 4
-
 /* MMU modes definitions. We carefully match the indices with our
hflags layout. */
 #define MMU_MODE0_SUFFIX _kernel
diff --git a/target-mips/machine.c b/target-mips/machine.c
index 8b9c0fb..8951748 100644
--- a/target-mips/machine.c
+++ b/target-mips/machine.c
@@ -3,304 +3,197 @@

 #include cpu.h

-static void save_tc(QEMUFile *f, TCState *tc)
-{
-int i;
-
-/* Save active TC */
-for(i = 0; i  32; i++)
-qemu_put_betls(f, tc-gpr[i]);
-qemu_put_betls(f, tc-PC);
-for(i = 0; i  MIPS_DSP_ACC; i++)
-qemu_put_betls(f, tc-HI[i]);
-for(i = 0; i  MIPS_DSP_ACC; i++)
-qemu_put_betls(f, tc-LO[i]);
-for(i = 0; i  MIPS_DSP_ACC; i++)
-qemu_put_betls(f, tc-ACX[i]);
-qemu_put_betls(f, tc-DSPControl);
-qemu_put_sbe32s(f, tc-CP0_TCStatus);
-qemu_put_sbe32s(f, tc-CP0_TCBind);
-qemu_put_betls(f, tc-CP0_TCHalt);
-qemu_put_betls(f, tc-CP0_TCContext);
-qemu_put_betls(f, tc-CP0_TCSchedule);
-qemu_put_betls(f, tc-CP0_TCScheFBack);
-qemu_put_sbe32s(f, tc-CP0_Debug_tcstatus);
-}
-
-static void save_fpu(QEMUFile *f, CPUMIPSFPUContext *fpu)
-{
-int i;
-
-for(i = 0; i  32; i++)
-qemu_put_be64s(f, fpu-fpr[i].d);
-qemu_put_s8s(f, fpu-fp_status.float_detect_tininess);
-qemu_put_s8s(f, fpu-fp_status.float_rounding_mode);
-qemu_put_s8s(f, fpu-fp_status.float_exception_flags);
-qemu_put_be32s(f, fpu-fcr0);
-qemu_put_be32s(f, fpu-fcr31);
-}
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-CPUMIPSState *env = opaque;
-int i;
-
-/* Save active TC */
-save_tc(f, env-active_tc);
-
-/* Save active FPU */
-save_fpu(f, env-active_fpu);
-
-/* Save MVP */
-qemu_put_sbe32s(f, env-mvp.CP0_MVPControl);
-qemu_put_sbe32s(f, env-mvp.CP0_MVPConf0);
-qemu_put_sbe32s(f, env-mvp.CP0_MVPConf1);
-
-/* Save TLB */
-qemu_put_be32s(f, env-tlb.nb_tlb);
-qemu_put_be32s(f, env-tlb.tlb_in_use);
-for(i = 0; i  MIPS_TLB_MAX; i++) {
-uint16_t flags = ((env-tlb.mmu.r4k.tlb[i].G  10) |
-  (env-tlb.mmu.r4k.tlb[i].C0  7) |
-  (env-tlb.mmu.r4k.tlb[i].C1  4) |
-  (env-tlb.mmu.r4k.tlb[i].V0  3) |
-  (env-tlb.mmu.r4k.tlb[i].V1  2) |
-  (env-tlb.mmu.r4k.tlb[i].D0  1) |
-  (env-tlb.mmu.r4k.tlb[i].D1  0));
-uint8_t asid;
-
-qemu_put_betls(f, env-tlb.mmu.r4k.tlb[i].VPN);
-qemu_put_be32s(f, env-tlb.mmu.r4k.tlb[i].PageMask);
-asid = env-tlb.mmu.r4k.tlb[i].ASID;
-qemu_put_8s(f, asid);
-qemu_put_be16s(f, flags);
-qemu_put_betls(f, env-tlb.mmu.r4k.tlb[i].PFN[0]);
-qemu_put_betls(f, env-tlb.mmu.r4k.tlb[i].PFN[1]);
+static const VMStateDescription vmstate_tc = {
+.name = tc,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINTTL_ARRAY(gpr, TCState, 32),
+VMSTATE_UINTTL(PC, TCState),
+VMSTATE_UINTTL_ARRAY(HI, TCState, MIPS_DSP_ACC),
+VMSTATE_UINTTL_ARRAY(LO, TCState, MIPS_DSP_ACC),
+VMSTATE_UINTTL_ARRAY(ACX, TCState, MIPS_DSP_ACC),
+VMSTATE_UINTTL(DSPControl, TCState),
+VMSTATE_INT32(CP0_TCStatus, TCState),
+VMSTATE_INT32(CP0_TCBind, TCState),
+VMSTATE_UINTTL(CP0_TCHalt, TCState),
+VMSTATE_UINTTL(CP0_TCContext, TCState),
+VMSTATE_UINTTL(CP0_TCSchedule, TCState),
+VMSTATE_UINTTL(CP0_TCScheFBack, TCState),
+VMSTATE_INT32(CP0_Debug_tcstatus, TCState),
+VMSTATE_END_OF_LIST()
 }
+};
+
+static const VMStateDescription vmstate_fpu_reg = {
+.name = fpu_reg,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_UINT64(d, fpr_t),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const VMStateDescription vmstate_fpu_context = {
+.name = fpu_context,
+.version_id = 1,
+.minimum_version_id = 1,
+.minimum_version_id_old = 1,
+.fields = (VMStateField[]) {
+VMSTATE_STRUCT_ARRAY(fpr, CPUMIPSFPUContext, 32, 0,
+   

[Qemu-devel] [PATCH 09/35] vmstate: introduce float64 arrays

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 savevm.c  |   25 +
 vmstate.h |4 
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/savevm.c b/savevm.c
index a22278e..da8f234 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1107,6 +1107,31 @@ const VMStateInfo vmstate_info_float32 = {
 .put  = put_float32,
 };

+/* 64 bit float */
+
+static int get_float64(QEMUFile *f, void *pv, size_t size)
+{
+float64 *v = pv;
+uint64_t u;
+qemu_get_be64s(f, u);
+*v = make_float64(u);
+return 0;
+}
+
+static void put_float64(QEMUFile *f, void *pv, size_t size)
+{
+float64 *v = pv;
+uint64_t u;
+u = float64_val(*v);
+qemu_put_be64s(f, u);
+}
+
+const VMStateInfo vmstate_info_float64 = {
+.name = float64,
+.get  = get_float64,
+.put  = put_float64,
+};
+
 /* timers  */

 static int get_timer(QEMUFile *f, void *pv, size_t size)
diff --git a/vmstate.h b/vmstate.h
index 135c5aa..d3fb88c 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -131,6 +131,7 @@ extern const VMStateInfo vmstate_info_uint32;
 extern const VMStateInfo vmstate_info_uint64;

 extern const VMStateInfo vmstate_info_float32;
+extern const VMStateInfo vmstate_info_float64;

 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_buffer;
@@ -564,6 +565,9 @@ extern const VMStateDescription vmstate_cpu;
 #define VMSTATE_FLOAT32_ARRAY(_f, _s, _n) \
 VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)

+#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
+VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float64, float64)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)  \
 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))

-- 
1.7.7.6




[Qemu-devel] [PATCH 17/35] mips_fulong2e: cpu vmstate already registered in cpu_exec_init

2012-05-04 Thread Juan Quintela
This is the second place that register cpu migration code, it is done
in general in cpu_exec_init(), just remove this call.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/mips_fulong2e.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index 37dc711..1a8df10 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -284,7 +284,6 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const 
char *boot_device,
 exit(1);
 }

-register_savevm(NULL, cpu, 0, 3, cpu_save, cpu_load, env);
 qemu_register_reset(main_cpu_reset, env);

 /* fulong 2e has 256M ram. */
-- 
1.7.7.6




[Qemu-devel] [PATCH 13/35] vmstate: introduce VMSTATE_VARRAY_MULTIPLY

2012-05-04 Thread Juan Quintela
This allows to sent a partial array where the size is another
structure field multiplied by a constant.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 savevm.c  |6 ++
 vmstate.h |   35 +++
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/savevm.c b/savevm.c
index 0a00dec..211be7b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1509,6 +1509,9 @@ int vmstate_load_state(QEMUFile *f, const 
VMStateDescription *vmsd,
 } else if (field-flags  VMS_VARRAY_UINT8) {
 n_elems = *(uint8_t *)(opaque+field-num_offset);
 }
+if (field-flags  VMS_MULTIPLY_ELEMENTS) {
+n_elems *= field-num;
+}
 if (field-flags  VMS_POINTER) {
 base_addr = *(void **)base_addr + field-start;
 }
@@ -1573,6 +1576,9 @@ void vmstate_save_state(QEMUFile *f, const 
VMStateDescription *vmsd,
 } else if (field-flags  VMS_VARRAY_UINT8) {
 n_elems = *(uint8_t *)(opaque+field-num_offset);
 }
+if (field-flags  VMS_MULTIPLY_ELEMENTS) {
+n_elems *= field-num;
+}
 if (field-flags  VMS_POINTER) {
 base_addr = *(void **)base_addr + field-start;
 }
diff --git a/vmstate.h b/vmstate.h
index b8ac2d0..b0225e9 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -64,18 +64,19 @@ struct VMStateInfo {
 };

 enum VMStateFlags {
-VMS_SINGLE   = 0x001,
-VMS_POINTER  = 0x002,
-VMS_ARRAY= 0x004,
-VMS_STRUCT   = 0x008,
-VMS_VARRAY_INT32 = 0x010,  /* Array with size in int32_t field*/
-VMS_BUFFER   = 0x020,  /* static sized buffer */
-VMS_ARRAY_OF_POINTER = 0x040,
-VMS_VARRAY_UINT16= 0x080,  /* Array with size in uint16_t field */
-VMS_VBUFFER  = 0x100,  /* Buffer with size in int32_t field */
-VMS_MULTIPLY = 0x200,  /* multiply size field by field_size */
-VMS_VARRAY_UINT8 = 0x400,  /* Array with size in uint8_t field*/
-VMS_VARRAY_UINT32= 0x800,  /* Array with size in uint32_t field*/
+VMS_SINGLE= 0x001,
+VMS_POINTER   = 0x002,
+VMS_ARRAY = 0x004,
+VMS_STRUCT= 0x008,
+VMS_VARRAY_INT32  = 0x010,  /* Array with size in int32_t field*/
+VMS_BUFFER= 0x020,  /* static sized buffer */
+VMS_ARRAY_OF_POINTER  = 0x040,
+VMS_VARRAY_UINT16 = 0x080,  /* Array with size in uint16_t field */
+VMS_VBUFFER   = 0x100,  /* Buffer with size in int32_t field */
+VMS_MULTIPLY  = 0x200,  /* multiply size field by field_size */
+VMS_VARRAY_UINT8  = 0x400,  /* Array with size in uint8_t field*/
+VMS_VARRAY_UINT32 = 0x800,  /* Array with size in uint32_t field*/
+VMS_MULTIPLY_ELEMENTS = 0x1000,  /* multiply size field by field_size */
 };

 typedef struct {
@@ -200,6 +201,16 @@ extern const VMStateDescription vmstate_cpu;
 .offset = vmstate_offset_array(_state, _field, _type, _num), \
 }

+#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, 
_type) { \
+.name   = (stringify(_field)),   \
+.num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+.num= (_multiply),   \
+.info   = (_info),  \
+.size   = sizeof(_type), \
+.flags  = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS,   \
+.offset = offsetof(_state, _field),  \
+}
+
 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
 .name = (stringify(_field)),  \
 .field_exists = (_test),  \
-- 
1.7.7.6




[Qemu-devel] [PATCH 35/35] vmstate: Add copyright info for sparc processor

2012-05-04 Thread Juan Quintela
v2: Move license to BSD-like as in vl.c
v3: Change copyright dates
v4: add QEMU contributors

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-sparc/vmstate-cpu.c |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/target-sparc/vmstate-cpu.c b/target-sparc/vmstate-cpu.c
index b599ac7..0d19e6a 100644
--- a/target-sparc/vmstate-cpu.c
+++ b/target-sparc/vmstate-cpu.c
@@ -1,3 +1,33 @@
+/*
+ * Migration support for sparc cpu
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2004-2011 Blue Swirl blauwir...@gmail.com
+ * Copyright (c) 2003-2012 QEMU contributors
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
 #include hw/hw.h

 static const VMStateDescription vmstate_cpu_timer = {
-- 
1.7.7.6




[Qemu-devel] [PATCH 11/35] vmstate: Introduce VMSTATE_STRUCT_VARRAY_INT32_TEST

2012-05-04 Thread Juan Quintela
We have an array of structs whose size is an int32 in the same struct that
depends on a test value to know if it is there or not.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 vmstate.h |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/vmstate.h b/vmstate.h
index 5c56f25..b8ac2d0 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -309,6 +309,16 @@ extern const VMStateDescription vmstate_cpu;
 .offset = offsetof(_state, _field),  \
 }

+#define VMSTATE_STRUCT_VARRAY_INT32_TEST(_field, _state, _field_num, _test, 
_vmsd, _type) { \
+.name   = (stringify(_field)),   \
+.num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
+.vmsd   = (_vmsd),  \
+.field_exists = (_test), \
+.size   = sizeof(_type), \
+.flags  = VMS_STRUCT|VMS_VARRAY_INT32,   \
+.offset = offsetof(_state, _field),  \
+}
+
 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, 
_type) { \
 .name   = (stringify(_field)),   \
 .version_id = 0, \
-- 
1.7.7.6




[Qemu-devel] [PATCH 08/35] vmstate: introduce float32 arrays

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 savevm.c  |   25 +
 vmstate.h |5 +
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/savevm.c b/savevm.c
index 2d18bab..a22278e 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1082,6 +1082,31 @@ const VMStateInfo vmstate_info_uint16_equal = {
 .put  = put_uint16,
 };

+/* 32 bit float */
+
+static int get_float32(QEMUFile *f, void *pv, size_t size)
+{
+float32 *v = pv;
+uint32_t u;
+qemu_get_be32s(f, u);
+*v = make_float32(u);
+return 0;
+}
+
+static void put_float32(QEMUFile *f, void *pv, size_t size)
+{
+float32 *v = pv;
+uint32_t u;
+u = float32_val(*v);
+qemu_put_be32s(f, u);
+}
+
+const VMStateInfo vmstate_info_float32 = {
+.name = float32,
+.get  = get_float32,
+.put  = put_float32,
+};
+
 /* timers  */

 static int get_timer(QEMUFile *f, void *pv, size_t size)
diff --git a/vmstate.h b/vmstate.h
index 1a4a60b..135c5aa 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -130,6 +130,8 @@ extern const VMStateInfo vmstate_info_uint16;
 extern const VMStateInfo vmstate_info_uint32;
 extern const VMStateInfo vmstate_info_uint64;

+extern const VMStateInfo vmstate_info_float32;
+
 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_buffer;
 extern const VMStateInfo vmstate_info_unused_buffer;
@@ -559,6 +561,9 @@ extern const VMStateDescription vmstate_cpu;
 #define VMSTATE_INT64_ARRAY(_f, _s, _n)   \
 VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)

+#define VMSTATE_FLOAT32_ARRAY(_f, _s, _n) \
+VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)  \
 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))

-- 
1.7.7.6




Re: [Qemu-devel] [PATCH v2] vnc: disable VNC password authentication (security type 2) when in FIPS mode

2012-05-04 Thread Paul Moore
On Friday, May 04, 2012 04:01:09 AM Roman Drahtmueller wrote:
FIPS 140-2 requires disabling certain ciphers, including DES, which is
used
by VNC to obscure passwords when they are sent over the network.  The
solution for FIPS users is to disable the use of VNC password auth
when
the
host system is operating in FIPS mode.

This patch causes qemu to emit a syslog entry indicating that VNC
password
auth is disabled when it detects the host is running in FIPS mode, and
unless a VNC password was specified on the command line it continues
normally.  However, if a VNC password was given on the command line,
qemu
fails with an error message to stderr explaining that VNC password
auth is
not allowed in FIPS mode.
   
   I just talked to Roman about this one and he had some comments :)
  
  I'm sure he did :)
 
 *g* Thanks, Alex! :)
 
 The purpose makes perfect sense, I think.
 
 Some small glitch, though:
 
 fips=1 on the kernel commandline turns on fips mode in the kernel crypto,
 and leaves 1 in /proc/sys/crypto/fips_enabled for userland to consume.
 openssl starts up, reads the file and runs its fips initialization with
 1 in the file. Typically...
 
 Two problems:
 1) openssl may not come with FIPS support. proc file is ignored.
 2) openssl may run in FIPS mode for reasons other than fips=1 on the
kernel cmdline (environment, ...).

 Suggested way to handle this:
 
 1) compile-time check if openssl/fips.h exists.
Ignore fips specifics if not, otherwise:
 2) use int FIPS_mode(void) for what it's there:
 
 #ifdef _QEMU_FIPS /* or whatever */
 #include openssl/fips.h
   vs-fips = FIPS_mode();
 #endif
 
 and skip fips_enabled(void).
 
 Much easier!

If QEMU's VNC implementation used OpenSSL's DES cipher for the password 
encryption I would agree with you, but QEMU uses its own implementation 
(ui/d3des.*) and because of this I think it makes the most sense to check the 
kernel setting directly.

-- 
paul moore
security and virtualization @ redhat




[Qemu-devel] [PATCH 16/35] vmstate: make incompatible change for sparc

2012-05-04 Thread Juan Quintela
With this change, we sent arrays as arrays, making state description
much simpler.  The change is incompatible, but as far as I know, sparc
don't care about migration compatibility beteween versions.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-sparc/machine.c |  172 +++-
 1 files changed, 9 insertions(+), 163 deletions(-)

diff --git a/target-sparc/machine.c b/target-sparc/machine.c
index 801ec55..818b11c 100644
--- a/target-sparc/machine.c
+++ b/target-sparc/machine.c
@@ -74,9 +74,9 @@ static int cpu_post_load(void *opaque, int version_id)

 const VMStateDescription vmstate_cpu = {
 .name = cpu,
-.version_id = 7,
-.minimum_version_id = 7,
-.minimum_version_id_old = 7,
+.version_id = 8,
+.minimum_version_id = 8,
+.minimum_version_id_old = 8,
 .pre_save = cpu_pre_save,
 .post_load = cpu_post_load,
 .fields = (VMStateField[]) {
@@ -106,166 +106,12 @@ const VMStateDescription vmstate_cpu = {
 VMSTATE_UINT64_ARRAY(mmubpregs, CPUSPARCState, 4),
 #else
 VMSTATE_UINT64(lsu, CPUSPARCState),
-VMSTATE_UINT64(immuregs[0], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[0], CPUSPARCState),
-VMSTATE_UINT64(immuregs[1], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[1], CPUSPARCState),
-VMSTATE_UINT64(immuregs[2], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[2], CPUSPARCState),
-VMSTATE_UINT64(immuregs[3], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[3], CPUSPARCState),
-VMSTATE_UINT64(immuregs[4], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[4], CPUSPARCState),
-VMSTATE_UINT64(immuregs[5], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[5], CPUSPARCState),
-VMSTATE_UINT64(immuregs[6], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[6], CPUSPARCState),
-VMSTATE_UINT64(immuregs[7], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[7], CPUSPARCState),
-VMSTATE_UINT64(immuregs[8], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[8], CPUSPARCState),
-VMSTATE_UINT64(immuregs[9], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[9], CPUSPARCState),
-VMSTATE_UINT64(immuregs[10], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[10], CPUSPARCState),
-VMSTATE_UINT64(immuregs[11], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[11], CPUSPARCState),
-VMSTATE_UINT64(immuregs[12], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[12], CPUSPARCState),
-VMSTATE_UINT64(immuregs[13], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[13], CPUSPARCState),
-VMSTATE_UINT64(immuregs[14], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[14], CPUSPARCState),
-VMSTATE_UINT64(immuregs[15], CPUSPARCState),
-VMSTATE_UINT64(dmmuregs[15], CPUSPARCState),
-VMSTATE_STRUCT(itlb[0], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[0], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[1], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[1], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[2], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[2], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[3], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[3], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[4], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[4], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[5], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[5], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[6], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[6], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[7], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[7], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[8], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[8], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[9], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[9], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[10], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[10], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[11], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(dtlb[11], CPUSPARCState, 0, vmstate_tlb_entry, 
SparcTLBEntry),
-VMSTATE_STRUCT(itlb[12], CPUSPARCState, 0, vmstate_tlb_entry, 

Re: [Qemu-devel] [PATCH v3] vnc: disable VNC password authentication (security type 2) when in FIPS mode

2012-05-04 Thread Paul Moore
On Friday, May 04, 2012 09:54:17 AM Daniel P. Berrange wrote:
 On Thu, May 03, 2012 at 05:00:45PM -0400, Paul Moore wrote:
  FIPS 140-2 requires disabling certain ciphers, including DES, which is
  used
  by VNC to obscure passwords when they are sent over the network.  The
  solution for FIPS users is to disable the use of VNC password auth when
  the
  host system is operating in FIPS mode.
  
  This patch causes qemu to emit a syslog entry and a message to stderr when
  the host system is running in FIPS mode and a VNC password was specified
  on
  the commend line.  If the system is not running in FIPS mode, or is
  running
  in FIPS mode but VNC password authentication was not requested, qemu
  operates normally.
  
  Signed-off-by: Paul Moore pmo...@redhat.com
 
 Reviewed-by: Dainel P. Berrange berra...@redhat.com
 
 Looks good to me now.

Thanks.

-- 
paul moore
security and virtualization @ redhat




Re: [Qemu-devel] [PATCH v2] vnc: disable VNC password authentication (security type 2) when in FIPS mode

2012-05-04 Thread Daniel P. Berrange
On Fri, May 04, 2012 at 08:39:04AM -0400, Paul Moore wrote:
 On Friday, May 04, 2012 04:01:09 AM Roman Drahtmueller wrote:

  Two problems:
  1) openssl may not come with FIPS support. proc file is ignored.
  2) openssl may run in FIPS mode for reasons other than fips=1 on the
 kernel cmdline (environment, ...).
 
  Suggested way to handle this:
  
  1) compile-time check if openssl/fips.h exists.
 Ignore fips specifics if not, otherwise:
  2) use int FIPS_mode(void) for what it's there:
  
  #ifdef _QEMU_FIPS   /* or whatever */
  #include openssl/fips.h
vs-fips = FIPS_mode();
  #endif
  
  and skip fips_enabled(void).
  
  Much easier!

QEMU does not use OpenSSL for anything [1], it uses GNUTLS, so I would
not be in favour of using OpenSSL for this. 

Daniel

[1] Yes the libspice-server.so uses OpenSSL which is a shame, but that
can be sorted out one day.
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|



[Qemu-devel] [PATCH 19/35] mips: make tlb an embedded struct instead of a pointer

2012-05-04 Thread Juan Quintela
Adjust all callers.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/mips_timer.c  |2 +-
 target-mips/cpu.h|2 +-
 target-mips/helper.c |   30 +-
 target-mips/machine.c|   56 +-
 target-mips/op_helper.c  |   40 +++---
 target-mips/translate.c  |   16 +++
 target-mips/translate_init.c |   24 -
 7 files changed, 89 insertions(+), 81 deletions(-)

diff --git a/hw/mips_timer.c b/hw/mips_timer.c
index 7aa9004..33e4021 100644
--- a/hw/mips_timer.c
+++ b/hw/mips_timer.c
@@ -35,7 +35,7 @@ uint32_t cpu_mips_get_random (CPUMIPSState *env)
 /* Don't return same value twice, so get another value */
 do {
 lfsr = (lfsr  1) ^ (-(lfsr  1u)  0xd001u);
-idx = lfsr % (env-tlb-nb_tlb - env-CP0_Wired) + env-CP0_Wired;
+idx = lfsr % (env-tlb.nb_tlb - env-CP0_Wired) + env-CP0_Wired;
 } while (idx == prev_idx);
 prev_idx = idx;
 return idx;
diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index 659dba9..aea2c5b 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -468,7 +468,7 @@ struct CPUMIPSState {

 CPUMIPSMVPContext mvp;
 #if !defined(CONFIG_USER_ONLY)
-CPUMIPSTLBContext *tlb;
+CPUMIPSTLBContext tlb;
 #endif

 const mips_def_t *cpu_model;
diff --git a/target-mips/helper.c b/target-mips/helper.c
index ddf9cb7..b2f2658 100644
--- a/target-mips/helper.c
+++ b/target-mips/helper.c
@@ -69,8 +69,8 @@ int r4k_map_address (CPUMIPSState *env, target_phys_addr_t 
*physical, int *prot,
 uint8_t ASID = env-CP0_EntryHi  0xFF;
 int i;

-for (i = 0; i  env-tlb-tlb_in_use; i++) {
-r4k_tlb_t *tlb = env-tlb-mmu.r4k.tlb[i];
+for (i = 0; i  env-tlb.tlb_in_use; i++) {
+r4k_tlb_t *tlb = env-tlb.mmu.r4k.tlb[i];
 /* 1k pages are not supported. */
 target_ulong mask = tlb-PageMask | ~(TARGET_PAGE_MASK  1);
 target_ulong tag = address  ~mask;
@@ -124,13 +124,15 @@ static int get_physical_address (CPUMIPSState *env, 
target_phys_addr_t *physical
 *physical = address  0x;
 *prot = PAGE_READ | PAGE_WRITE;
 } else {
-ret = env-tlb-map_address(env, physical, prot, address, rw, 
access_type);
+ret = env-tlb.map_address(env, physical, prot, address, rw,
+   access_type);
 }
 #if defined(TARGET_MIPS64)
 } else if (address  0x4000ULL) {
 /* xuseg */
 if (UX  address = (0x3FFFULL  env-SEGMask)) {
-ret = env-tlb-map_address(env, physical, prot, address, rw, 
access_type);
+ret = env-tlb.map_address(env, physical, prot, address, rw,
+   access_type);
 } else {
 ret = TLBRET_BADADDR;
 }
@@ -138,7 +140,8 @@ static int get_physical_address (CPUMIPSState *env, 
target_phys_addr_t *physical
 /* xsseg */
 if ((supervisor_mode || kernel_mode) 
 SX  address = (0x7FFFULL  env-SEGMask)) {
-ret = env-tlb-map_address(env, physical, prot, address, rw, 
access_type);
+ret = env-tlb.map_address(env, physical, prot, address, rw,
+   access_type);
 } else {
 ret = TLBRET_BADADDR;
 }
@@ -155,7 +158,8 @@ static int get_physical_address (CPUMIPSState *env, 
target_phys_addr_t *physical
 /* xkseg */
 if (kernel_mode  KX 
 address = (0x7FFFULL  env-SEGMask)) {
-ret = env-tlb-map_address(env, physical, prot, address, rw, 
access_type);
+ret = env-tlb.map_address(env, physical, prot, address, rw,
+   access_type);
 } else {
 ret = TLBRET_BADADDR;
 }
@@ -179,7 +183,8 @@ static int get_physical_address (CPUMIPSState *env, 
target_phys_addr_t *physical
 } else if (address  (int32_t)0xE000UL) {
 /* sseg (kseg2) */
 if (supervisor_mode || kernel_mode) {
-ret = env-tlb-map_address(env, physical, prot, address, rw, 
access_type);
+ret = env-tlb.map_address(env, physical, prot, address, rw,
+   access_type);
 } else {
 ret = TLBRET_BADADDR;
 }
@@ -187,7 +192,8 @@ static int get_physical_address (CPUMIPSState *env, 
target_phys_addr_t *physical
 /* kseg3 */
 /* XXX: debug segment is not emulated */
 if (kernel_mode) {
-ret = env-tlb-map_address(env, physical, prot, address, rw, 
access_type);
+ret = env-tlb.map_address(env, physical, prot, address, rw,
+   access_type);
 } else {
 ret = TLBRET_BADADDR;
 }
@@ -645,19 +651,19 @@ void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int 

Re: [Qemu-devel] [PATCH 22/35] arm: save always 32 fpu registers

2012-05-04 Thread Peter Maydell
On 4 May 2012 11:54, Juan Quintela quint...@redhat.com wrote:
 This way, we fix a bug (we were overwritten the 16 first registers on
 load), and we don't need to check for ARM_FEATURE_VPF3, we always send
 the 32 registers.

As I pointed out last time around, this bug is already fixed in
master and you need to correct this commit message.

-- PMM



[Qemu-devel] [PATCH 04/35] vmstate: use new cpu style for x86

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-i386/cpu.h |2 --
 target-i386/machine.c |   12 +---
 2 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index b5b9a50..73b71ec 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -965,8 +965,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define cpu_list_id x86_cpu_list
 #define cpudef_setup   x86_cpudef_setup

-#define CPU_SAVE_VERSION 12
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
diff --git a/target-i386/machine.c b/target-i386/machine.c
index fc37738..127c44f 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -348,7 +348,7 @@ static const VMStateDescription 
vmstate_msr_ia32_misc_enable = {

 const VMStateDescription vmstate_cpu = {
 .name = cpu,
-.version_id = CPU_SAVE_VERSION,
+.version_id = 12,
 .minimum_version_id = 3,
 .minimum_version_id_old = 3,
 .pre_save = cpu_pre_save,
@@ -467,13 +467,3 @@ const VMStateDescription vmstate_cpu = {
 }
 }
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-vmstate_save_state(f, vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-return vmstate_load_state(f, vmstate_cpu, opaque, version_id);
-}
-- 
1.7.7.6




[Qemu-devel] [PATCH 33/35] vmstate: Add copyright info for mips processor

2012-05-04 Thread Juan Quintela
v2: Move license to BSD-like as in vl.c

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-mips/vmstate-cpu.c |   29 +
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/target-mips/vmstate-cpu.c b/target-mips/vmstate-cpu.c
index bbfa2a9..1e28b3f 100644
--- a/target-mips/vmstate-cpu.c
+++ b/target-mips/vmstate-cpu.c
@@ -1,3 +1,32 @@
+/*
+ * Migration support for mips cpu
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ * Copyright (c) 2003-2008 Thiemo Seufer
+ * Copyright (c) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
 #include hw/hw.h

 static const VMStateDescription vmstate_tc = {
-- 
1.7.7.6




[Qemu-devel] [PATCH 26/35] vmstate: remove unneeded includes from target-*/machine.c

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-alpha/machine.c |1 -
 target-arm/machine.c   |1 -
 target-cris/machine.c  |1 -
 target-i386/machine.c  |6 --
 target-lm32/machine.c  |1 -
 target-mips/machine.c  |3 ---
 target-ppc/machine.c   |2 --
 target-sparc/machine.c |4 
 8 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 8b3b42e..22c70f3 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -1,5 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h

 static int get_fpcr(QEMUFile *f, void *opaque, size_t size)
 {
diff --git a/target-arm/machine.c b/target-arm/machine.c
index 31e49ac..f8ccdd7 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -1,5 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h

 static bool feature_vfp_needed(void *opaque)
 {
diff --git a/target-cris/machine.c b/target-cris/machine.c
index 1b96265..1dbf8b5 100644
--- a/target-cris/machine.c
+++ b/target-cris/machine.c
@@ -1,5 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h

 static const VMStateDescription vmstate_tlbset = {
 .name = cpu/tlbset,
diff --git a/target-i386/machine.c b/target-i386/machine.c
index c2a8872..0ef12ac 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -1,10 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h
-#include hw/pc.h
-#include hw/isa.h
-
-#include cpu.h
-#include kvm.h

 static const VMStateDescription vmstate_segment = {
 .name = segment,
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 24db6c0..132259d 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -1,5 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h

 const VMStateDescription vmstate_cpu = {
 .name = cpu,
diff --git a/target-mips/machine.c b/target-mips/machine.c
index 8951748..bbfa2a9 100644
--- a/target-mips/machine.c
+++ b/target-mips/machine.c
@@ -1,7 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h
-
-#include cpu.h

 static const VMStateDescription vmstate_tc = {
 .name = tc,
diff --git a/target-ppc/machine.c b/target-ppc/machine.c
index ca60bc0..c4547df 100644
--- a/target-ppc/machine.c
+++ b/target-ppc/machine.c
@@ -1,6 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h
-#include kvm.h

 static const VMStateDescription vmstate_tlb = {
 .name = tlb,
diff --git a/target-sparc/machine.c b/target-sparc/machine.c
index 818b11c..b599ac7 100644
--- a/target-sparc/machine.c
+++ b/target-sparc/machine.c
@@ -1,8 +1,4 @@
 #include hw/hw.h
-#include hw/boards.h
-#include qemu-timer.h
-
-#include cpu.h

 static const VMStateDescription vmstate_cpu_timer = {
 .name = cpu_timer,
-- 
1.7.7.6




[Qemu-devel] [PATCH 06/35] vmstate: make microblaze cpus not migrateable

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-microblaze/cpu.h |2 --
 target-microblaze/machine.c |   26 ++
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
index 718d5bb..866623d 100644
--- a/target-microblaze/cpu.h
+++ b/target-microblaze/cpu.h
@@ -296,8 +296,6 @@ enum {
 #define cpu_gen_code cpu_mb_gen_code
 #define cpu_signal_handler cpu_mb_signal_handler

-#define CPU_SAVE_VERSION 1
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _nommu
 #define MMU_MODE1_SUFFIX _kernel
diff --git a/target-microblaze/machine.c b/target-microblaze/machine.c
index 1be1c35..13abf6a 100644
--- a/target-microblaze/machine.c
+++ b/target-microblaze/machine.c
@@ -1,11 +1,21 @@
+/*
+ * Migration support for microblaze cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
 #include hw/hw.h
-#include hw/boards.h

-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */

-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-return 0;
-}
+const VMStateDescription vmstate_cpu = {
+.name = cpu,
+.unmigratable = 1,
+};
-- 
1.7.7.6




[Qemu-devel] [PATCH 28/35] vmstate: Add copyright info for alpha processor

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
Acked-by: Richard Henderson r...@twiddle.net
---
 target-alpha/vmstate-cpu.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/target-alpha/vmstate-cpu.c b/target-alpha/vmstate-cpu.c
index 22c70f3..b94b1e5 100644
--- a/target-alpha/vmstate-cpu.c
+++ b/target-alpha/vmstate-cpu.c
@@ -1,3 +1,18 @@
+/*
+ * Migration support for alpha cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * Based on savevm serialization code by:
+ *   Richard Henderson r...@twiddle.net
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
 #include hw/hw.h

 static int get_fpcr(QEMUFile *f, void *opaque, size_t size)
-- 
1.7.7.6




[Qemu-devel] [PATCH 10/35] vmstate: introduce CPU_DoubleU arrays

2012-05-04 Thread Juan Quintela
Signed-off-by: Juan Quintela quint...@redhat.com
---
 savevm.c  |   24 
 vmstate.h |4 
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/savevm.c b/savevm.c
index da8f234..0a00dec 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1132,6 +1132,30 @@ const VMStateInfo vmstate_info_float64 = {
 .put  = put_float64,
 };

+/* 64 bit CPUDouble */
+
+static int get_cpudouble(QEMUFile *f, void *pv, size_t size)
+{
+CPU_DoubleU *v = pv;
+
+qemu_get_be32s(f, v-l.upper);
+qemu_get_be32s(f, v-l.lower);
+return 0;
+}
+
+static void put_cpudouble(QEMUFile *f, void *pv, size_t size)
+{
+CPU_DoubleU *v = pv;
+qemu_put_be32s(f, v-l.upper);
+qemu_put_be32s(f, v-l.lower);
+}
+
+const VMStateInfo vmstate_info_cpudouble = {
+.name = CPU_Double_U,
+.get  = get_cpudouble,
+.put  = put_cpudouble,
+};
+
 /* timers  */

 static int get_timer(QEMUFile *f, void *pv, size_t size)
diff --git a/vmstate.h b/vmstate.h
index d3fb88c..5c56f25 100644
--- a/vmstate.h
+++ b/vmstate.h
@@ -132,6 +132,7 @@ extern const VMStateInfo vmstate_info_uint64;

 extern const VMStateInfo vmstate_info_float32;
 extern const VMStateInfo vmstate_info_float64;
+extern const VMStateInfo vmstate_info_cpudouble;

 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_buffer;
@@ -568,6 +569,9 @@ extern const VMStateDescription vmstate_cpu;
 #define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
 VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float64, float64)

+#define VMSTATE_CPUDOUBLE_ARRAY(_f, _s, _n) \
+VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_cpudouble, CPU_DoubleU)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)  \
 VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))

-- 
1.7.7.6




Re: [Qemu-devel] [PATCH v5 00/35] VMState port of all cpus

2012-05-04 Thread Anthony Liguori

On 05/04/2012 06:35 AM, Juan Quintela wrote:

Juan Quintelaquint...@redhat.com  wrote:

Andreas Färberafaer...@suse.de  wrote:

Am 04.05.2012 12:54, schrieb Juan Quintela:

This repository contains all the changes:

   git://repo.or.cz/qemu/quintela.git vmstate-cpus-v4



Oops, you meaned here.  s/v4/v5/  :-(

I have to put in one script how to ask for a pull and don't rely on my
weak memory.


We're in freeze so this cannot be pulled until after the 1.1 release.

Regards,

Anthony Liguori



[Qemu-devel] [PATCH 22/35] arm: save always 32 fpu registers

2012-05-04 Thread Juan Quintela
This way, we fix a bug (we were overwritten the 16 first registers on
load), and we don't need to check for ARM_FEATURE_VPF3, we always send
the 32 registers.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 target-arm/cpu.h |2 +-
 target-arm/machine.c |   22 ++
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 5eac070..9434902 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -464,7 +464,7 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list

-#define CPU_SAVE_VERSION 6
+#define CPU_SAVE_VERSION 7

 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
diff --git a/target-arm/machine.c b/target-arm/machine.c
index f66b8df..9c0f773 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -64,7 +64,7 @@ void cpu_save(QEMUFile *f, void *opaque)
 qemu_put_be32(f, env-features);

 if (arm_feature(env, ARM_FEATURE_VFP)) {
-for (i = 0;  i  16; i++) {
+for (i = 0;  i  32; i++) {
 CPU_DoubleU u;
 u.d = env-vfp.regs[i];
 qemu_put_be32(f, u.l.upper);
@@ -77,15 +77,6 @@ void cpu_save(QEMUFile *f, void *opaque)
 /* TODO: Should use proper FPSCR access functions.  */
 qemu_put_be32(f, env-vfp.vec_len);
 qemu_put_be32(f, env-vfp.vec_stride);
-
-if (arm_feature(env, ARM_FEATURE_VFP3)) {
-for (i = 16;  i  32; i++) {
-CPU_DoubleU u;
-u.d = env-vfp.regs[i];
-qemu_put_be32(f, u.l.upper);
-qemu_put_be32(f, u.l.lower);
-}
-}
 }

 if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
@@ -182,7 +173,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
 env-features = qemu_get_be32(f);

 if (arm_feature(env, ARM_FEATURE_VFP)) {
-for (i = 0;  i  16; i++) {
+for (i = 0;  i  32; i++) {
 CPU_DoubleU u;
 u.l.upper = qemu_get_be32(f);
 u.l.lower = qemu_get_be32(f);
@@ -195,15 +186,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
 /* TODO: Should use proper FPSCR access functions.  */
 env-vfp.vec_len = qemu_get_be32(f);
 env-vfp.vec_stride = qemu_get_be32(f);
-
-if (arm_feature(env, ARM_FEATURE_VFP3)) {
-for (i = 16;  i  32; i++) {
-CPU_DoubleU u;
-u.l.upper = qemu_get_be32(f);
-u.l.lower = qemu_get_be32(f);
-env-vfp.regs[i] = u.d;
-}
-}
 }

 if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
-- 
1.7.7.6




[Qemu-devel] [PATCH 14/35] vmstate: define vmstate_info_uinttls

2012-05-04 Thread Juan Quintela
We are going to define arrays of this type, so we need the integer type.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 hw/hw.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/hw.h b/hw/hw.h
index e5cb9bf..9dbac88 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -52,11 +52,13 @@ int qemu_boot_set(const char *boot_devices);
 VMSTATE_UINT64_V(_f, _s, _v)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)\
 VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
+#define vmstate_info_uinttls vmstate_info_uint64
 #else
 #define VMSTATE_UINTTL_V(_f, _s, _v)  \
 VMSTATE_UINT32_V(_f, _s, _v)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)\
 VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
+#define vmstate_info_uinttls vmstate_info_uint32
 #endif
 #define VMSTATE_UINTTL(_f, _s)\
 VMSTATE_UINTTL_V(_f, _s, 0)
-- 
1.7.7.6




Re: [Qemu-devel] [PATCH 16/35] vmstate: make incompatible change for sparc

2012-05-04 Thread Peter Maydell
On 4 May 2012 12:35, Andreas Färber afaer...@suse.de wrote:
 It appears once again none of these patches are actually cc'ing the
 proper maintainers. Not even Acked-by (or is git-send-email
 case-sensitive? it's spelled Acked-By in lm32 patch).

FWIW, git-send-email is not case-sensitive when looking for
things indicating it should CC people. However it will only
add CCs for CC: and Signed-off-by:, not the others like Acked-by:,
Reported-by:, etc.

-- PMM



[Qemu-devel] [PATCH 02/35] vmstate: make all architectures export a way to migrate cpu's

2012-05-04 Thread Juan Quintela
This makes several changes:
- exports VMStateDescription vmstate_cpu non-static.
- makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
- for the architecture that had nothing, it just register the cpu as 
unmigratable.
- Depending on CPU_SAVE_VERSION we register old/new migration style
- Add copyrights to the new files

Signed-off-by: Juan Quintela quint...@redhat.com
---
 exec.c  |2 ++
 target-alpha/machine.c  |   12 +---
 target-i386/machine.c   |2 +-
 target-lm32/machine.c   |2 +-
 target-m68k/machine.c   |   21 +
 target-s390x/machine.c  |   14 ++
 target-sh4/machine.c|   21 +
 target-xtensa/machine.c |   14 ++
 vmstate.h   |2 ++
 9 files changed, 61 insertions(+), 29 deletions(-)

diff --git a/exec.c b/exec.c
index cba333f..85f0d61 100644
--- a/exec.c
+++ b/exec.c
@@ -722,6 +722,8 @@ void cpu_exec_init(CPUArchState *env)
 #if defined(CPU_SAVE_VERSION)
 register_savevm(NULL, cpu, cpu_index, CPU_SAVE_VERSION,
 cpu_save, cpu_load, env);
+#else
+vmstate_register(NULL, cpu_index, vmstate_cpu, env);
 #endif
 #endif
 }
diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 1c9edd1..8b3b42e 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -68,20 +68,10 @@ static VMStateField vmstate_cpu_fields[] = {
 VMSTATE_END_OF_LIST()
 };

-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
 .name = cpu,
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .fields = vmstate_cpu_fields,
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-vmstate_save_state(f, vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-return vmstate_load_state(f, vmstate_cpu, opaque, version_id);
-}
diff --git a/target-i386/machine.c b/target-i386/machine.c
index a8be058..fc37738 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -346,7 +346,7 @@ static const VMStateDescription 
vmstate_msr_ia32_misc_enable = {
 }
 };

-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
 .name = cpu,
 .version_id = CPU_SAVE_VERSION,
 .minimum_version_id = 3,
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 6802e81..ed71bc4 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -1,7 +1,7 @@
 #include hw/hw.h
 #include hw/boards.h

-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
 .name = cpu,
 .version_id = CPU_SAVE_VERSION,
 .minimum_version_id = 1,
diff --git a/target-m68k/machine.c b/target-m68k/machine.c
index e69de29..7c89d4f 100644
--- a/target-m68k/machine.c
+++ b/target-m68k/machine.c
@@ -0,0 +1,21 @@
+/*
+ * Migration support for m68k cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
+#include hw/hw.h
+
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
+
+const VMStateDescription vmstate_cpu = {
+.name = cpu,
+.unmigratable = 1,
+};
diff --git a/target-s390x/machine.c b/target-s390x/machine.c
index 3e79be6..5a7b219 100644
--- a/target-s390x/machine.c
+++ b/target-s390x/machine.c
@@ -18,13 +18,11 @@
  */

 #include hw/hw.h
-#include hw/boards.h

-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */

-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-return 0;
-}
+const VMStateDescription vmstate_cpu = {
+.name = cpu,
+.unmigratable = 1,
+};
diff --git a/target-sh4/machine.c b/target-sh4/machine.c
index e69de29..b97355d 100644
--- a/target-sh4/machine.c
+++ b/target-sh4/machine.c
@@ -0,0 +1,21 @@
+/*
+ * Migration support for sh4 cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela quint...@redhat.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * later.  See the COPYING file in the top-level directory.
+ */
+
+#include hw/hw.h
+
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
+
+const VMStateDescription vmstate_cpu = {
+.name = cpu,
+.unmigratable = 1,
+};
diff --git a/target-xtensa/machine.c b/target-xtensa/machine.c
index ddeffb2..3f98330 100644
--- a/target-xtensa/machine.c
+++ b/target-xtensa/machine.c
@@ -26,13 +26,11 @@
  */

 #include hw/hw.h
-#include hw/boards.h

-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere 

Re: [Qemu-devel] [PATCH 09/35] vmstate: introduce float64 arrays

2012-05-04 Thread Andreas Färber
Am 04.05.2012 12:54, schrieb Juan Quintela:
 Signed-off-by: Juan Quintela quint...@redhat.com
 ---
  savevm.c  |   25 +
  vmstate.h |4 
  2 files changed, 29 insertions(+), 0 deletions(-)
 
 diff --git a/savevm.c b/savevm.c
 index a22278e..da8f234 100644
 --- a/savevm.c
 +++ b/savevm.c
 @@ -1107,6 +1107,31 @@ const VMStateInfo vmstate_info_float32 = {
  .put  = put_float32,
  };
 
 +/* 64 bit float */
 +
 +static int get_float64(QEMUFile *f, void *pv, size_t size)
 +{
 +float64 *v = pv;
 +uint64_t u;
 +qemu_get_be64s(f, u);
 +*v = make_float64(u);
 +return 0;
 +}
 +
 +static void put_float64(QEMUFile *f, void *pv, size_t size)
 +{
 +float64 *v = pv;
 +uint64_t u;
 +u = float64_val(*v);
 +qemu_put_be64s(f, u);
 +}
 +
 +const VMStateInfo vmstate_info_float64 = {
 +.name = float64,
 +.get  = get_float64,
 +.put  = put_float64,
 +};
 +
  /* timers  */
 
  static int get_timer(QEMUFile *f, void *pv, size_t size)
 diff --git a/vmstate.h b/vmstate.h
 index 135c5aa..d3fb88c 100644
 --- a/vmstate.h
 +++ b/vmstate.h
 @@ -131,6 +131,7 @@ extern const VMStateInfo vmstate_info_uint32;
  extern const VMStateInfo vmstate_info_uint64;
 
  extern const VMStateInfo vmstate_info_float32;
 +extern const VMStateInfo vmstate_info_float64;
 
  extern const VMStateInfo vmstate_info_timer;
  extern const VMStateInfo vmstate_info_buffer;
 @@ -564,6 +565,9 @@ extern const VMStateDescription vmstate_cpu;
  #define VMSTATE_FLOAT32_ARRAY(_f, _s, _n) \
  VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)
 
 +#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n) \
 +VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float64, float64)

Same comment as for float32:
Why not _FLOAT64_ARRAY - _FLOAT64_ARRAY_V - _ARRAY?

/-F

 +
  #define VMSTATE_BUFFER_V(_f, _s, _v)  \
  VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
 

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH 23/35] vmstate: port arm cpu

2012-05-04 Thread Peter Maydell
On 4 May 2012 11:54, Juan Quintela quint...@redhat.com wrote:
 Use one subsection for each feature.  This means that we don't need to
 bump the version field each time that a new feature gets introduced.

 Introduce cpsr_vmstate field, as I am not sure if I can use
 uncached_cpsr for saving state.

 Signed-off-by: Juan Quintela quint...@redhat.com
 ---
  target-arm/cpu.h     |    5 +-
  target-arm/machine.c |  344 
 ++
  2 files changed, 156 insertions(+), 193 deletions(-)

 diff --git a/target-arm/cpu.h b/target-arm/cpu.h
 index 9434902..37744c6 100644
 --- a/target-arm/cpu.h
 +++ b/target-arm/cpu.h
 @@ -236,6 +236,9 @@ typedef struct CPUARMState {
     } cp[15];
     void *nvic;
     const struct arm_boot_info *boot_info;
 +
 +    /* Fields needed as intermediate for vmstate */
 +    uint32_t cpsr_vmstate;
  } CPUARMState;

I still think this is the wrong approach. We need to support
this is how you read/write this field functions. See also
target-alpha handling of the fpcr.

-- PMM



[Qemu-devel] [PATCH 27/35] vmstate: rename machine.c to vmstate-cpu.c

2012-05-04 Thread Juan Quintela
They only contain vmstate cpu sections nowadays.  Change name to reflect the 
case.

Signed-off-by: Juan Quintela quint...@redhat.com
---
 Makefile.target|3 ++-
 target-alpha/{machine.c = vmstate-cpu.c}  |0
 target-arm/{machine.c = vmstate-cpu.c}|0
 target-cris/{machine.c = vmstate-cpu.c}   |0
 target-i386/{machine.c = vmstate-cpu.c}   |0
 target-lm32/{machine.c = vmstate-cpu.c}   |0
 target-m68k/{machine.c = vmstate-cpu.c}   |0
 target-microblaze/{machine.c = vmstate-cpu.c} |0
 target-mips/{machine.c = vmstate-cpu.c}   |0
 target-ppc/{machine.c = vmstate-cpu.c}|0
 target-s390x/{machine.c = vmstate-cpu.c}  |0
 target-sh4/{machine.c = vmstate-cpu.c}|0
 target-sparc/{machine.c = vmstate-cpu.c}  |0
 target-xtensa/{machine.c = vmstate-cpu.c} |0
 14 files changed, 2 insertions(+), 1 deletions(-)
 rename target-alpha/{machine.c = vmstate-cpu.c} (100%)
 rename target-arm/{machine.c = vmstate-cpu.c} (100%)
 rename target-cris/{machine.c = vmstate-cpu.c} (100%)
 rename target-i386/{machine.c = vmstate-cpu.c} (100%)
 rename target-lm32/{machine.c = vmstate-cpu.c} (100%)
 rename target-m68k/{machine.c = vmstate-cpu.c} (100%)
 rename target-microblaze/{machine.c = vmstate-cpu.c} (100%)
 rename target-mips/{machine.c = vmstate-cpu.c} (100%)
 rename target-ppc/{machine.c = vmstate-cpu.c} (100%)
 rename target-s390x/{machine.c = vmstate-cpu.c} (100%)
 rename target-sh4/{machine.c = vmstate-cpu.c} (100%)
 rename target-sparc/{machine.c = vmstate-cpu.c} (100%)
 rename target-xtensa/{machine.c = vmstate-cpu.c} (100%)

diff --git a/Makefile.target b/Makefile.target
index 1582904..88ff9c9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -179,7 +179,8 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU

-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y = arch_init.o cpus.o monitor.o vmstate-cpu.o gdbstub.o balloon.o
+obj-y += ioport.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-$(CONFIG_NO_PCI) += pci-stub.o
diff --git a/target-alpha/machine.c b/target-alpha/vmstate-cpu.c
similarity index 100%
rename from target-alpha/machine.c
rename to target-alpha/vmstate-cpu.c
diff --git a/target-arm/machine.c b/target-arm/vmstate-cpu.c
similarity index 100%
rename from target-arm/machine.c
rename to target-arm/vmstate-cpu.c
diff --git a/target-cris/machine.c b/target-cris/vmstate-cpu.c
similarity index 100%
rename from target-cris/machine.c
rename to target-cris/vmstate-cpu.c
diff --git a/target-i386/machine.c b/target-i386/vmstate-cpu.c
similarity index 100%
rename from target-i386/machine.c
rename to target-i386/vmstate-cpu.c
diff --git a/target-lm32/machine.c b/target-lm32/vmstate-cpu.c
similarity index 100%
rename from target-lm32/machine.c
rename to target-lm32/vmstate-cpu.c
diff --git a/target-m68k/machine.c b/target-m68k/vmstate-cpu.c
similarity index 100%
rename from target-m68k/machine.c
rename to target-m68k/vmstate-cpu.c
diff --git a/target-microblaze/machine.c b/target-microblaze/vmstate-cpu.c
similarity index 100%
rename from target-microblaze/machine.c
rename to target-microblaze/vmstate-cpu.c
diff --git a/target-mips/machine.c b/target-mips/vmstate-cpu.c
similarity index 100%
rename from target-mips/machine.c
rename to target-mips/vmstate-cpu.c
diff --git a/target-ppc/machine.c b/target-ppc/vmstate-cpu.c
similarity index 100%
rename from target-ppc/machine.c
rename to target-ppc/vmstate-cpu.c
diff --git a/target-s390x/machine.c b/target-s390x/vmstate-cpu.c
similarity index 100%
rename from target-s390x/machine.c
rename to target-s390x/vmstate-cpu.c
diff --git a/target-sh4/machine.c b/target-sh4/vmstate-cpu.c
similarity index 100%
rename from target-sh4/machine.c
rename to target-sh4/vmstate-cpu.c
diff --git a/target-sparc/machine.c b/target-sparc/vmstate-cpu.c
similarity index 100%
rename from target-sparc/machine.c
rename to target-sparc/vmstate-cpu.c
diff --git a/target-xtensa/machine.c b/target-xtensa/vmstate-cpu.c
similarity index 100%
rename from target-xtensa/machine.c
rename to target-xtensa/vmstate-cpu.c
-- 
1.7.7.6




Re: [Qemu-devel] [SeaBIOS] [seabios patch 1/5] pci: init all devices

2012-05-04 Thread Kevin O'Connor
On Fri, May 04, 2012 at 10:21:23AM +0200, Gerd Hoffmann wrote:
 seabios used to initialize root bus devices only, with this patch
 devices behind pci bridges are initialized too.  This allows to boot
 from virtio devices behind pci bridges.
 
 Signed-off-by: Gerd Hoffmann kra...@redhat.com
 ---
  src/pciinit.c |3 ---
  1 files changed, 0 insertions(+), 3 deletions(-)
 
 diff --git a/src/pciinit.c b/src/pciinit.c
 index 25b04ac..6a7a0d2 100644
 --- a/src/pciinit.c
 +++ b/src/pciinit.c
 @@ -213,9 +213,6 @@ static void pci_bios_init_devices(void)
  {
  struct pci_device *pci;
  foreachpci(pci) {
 -if (pci_bdf_to_bus(pci-bdf) != 0)
 -// Only init devices on host bus.
 -break;

I think this will then assign an incorrect PCI_INTERRUPT_LINE value to
non root bus devices.

-Kevin



Re: [Qemu-devel] [SeaBIOS] [PATCH 11/12] Migrate 64bit entries to 64bit pci regions

2012-05-04 Thread Kevin O'Connor
On Wed, May 02, 2012 at 03:42:51PM +0200, Gerd Hoffmann wrote:
   Hi,
 
  Is this just a matter of removing the if (pci_bdf_to_bus(pci-bdf) !=
  0) break from pci_bios_init_devices()?
 
 Seems to do the trick, at least the disks connected appear in the boot
 menu now and the seabios log file looks sane.
 
 The guest kernel has no virtio-scsi drivers though, need to update it
 for more testing.
 
  The code should probably handle the irq swizzling that pci bridges do
  though.
 
 i.e. add bridge handling to pci_slot_get_irq() ?

Yes.

-Kevin



Re: [Qemu-devel] [SeaBIOS] [seabios patch 0/5] dynamic pci i/o windows

2012-05-04 Thread Kevin O'Connor
On Fri, May 04, 2012 at 10:21:22AM +0200, Gerd Hoffmann wrote:
   Hi,
 
 This patch series makes the PCI I/O windows runtime-configurable via
 qemu firmware config interface.  Main advantage is that we can size and
 shuffle around the PCI i/O windows according to the amount of memory the
 virtual machine has.  We don't need a hole for 64bit PCI bars, we can
 just map them above the main memory.  The hole for 32bit PCI bars can be
 enlarged for guests with less than 3.5 GB of memory.

Why pass in a PCI IO range through fw_cfg if SeaBIOS can figure out an
acceptable range from the amount of memory in the machine?

-Kevin



Re: [Qemu-devel] [RFC 0/9] Virtio-mmio refactoring.

2012-05-04 Thread Anthony Liguori

On 05/03/2012 07:14 AM, Peter Maydell wrote:

On 25 April 2012 06:54, Evgeny Voevodine.voevo...@samsung.com  wrote:

In this patchset refactoring of virtio-mmio layer is made.
Instead of creating virtio-blk-mmio, virtio-net-mmio, etc on the system bus
we create virtio-blk, virtio-net, etc devices on the virtio-transport bus.
To create virtio-transport bus virtio-mmio-transport device provided.
Transport device plugs into virtio-mmio bus.
To create virtio-mmio bus virtio-mmio-bridge device provided.


This seems to me to have one more layer than it needs. Why not just:
  create virtio-blk, virtio-net, etc on the virtio-transport bus
  To create virtio-transport bus, we create a virtio-mmio-transport
  device, and this device is a sysbus device.

ie why do you have separate virtio-mmio-transport and
virtio-mmio-bridge devices, and two different new buses (virtio-mmio
and virtio-transport) rather than just virtio-transport?


I think using a bus won't work.   You need to create a VirtioDevice that has a 
linkVirtioTransport.  I would suggest making VirtioTransport an interface.


Then you can have VirtioPCI inherit from PCIDevice and implement 
VirtioTransport.

Regards,

Anthony Liguori



-- PMM






Re: [Qemu-devel] [PATCH 16/35] vmstate: make incompatible change for sparc

2012-05-04 Thread Andreas Färber
Am 04.05.2012 15:00, schrieb Peter Maydell:
 On 4 May 2012 12:35, Andreas Färber afaer...@suse.de wrote:
 Not even [cc'ing] Acked-by (or is git-send-email
 case-sensitive? it's spelled Acked-By in lm32 patch).
 
 FWIW, git-send-email is not case-sensitive when looking for
 things indicating it should CC people. However it will only
 add CCs for CC: and Signed-off-by:, not the others like Acked-by:,
 Reported-by:, etc.

Ah sorry, I had noticed Acked-by not getting cc'ed myself recently.
Seems like there's no config option to cc beyond Cc, Signed-off-by and
From, so that we'd have to write a custom cc-cmd script to both cc the
maintainers and Reported-by, Suggested-by, Reviewed-by, Acked-by,
Tested-by, etc. if we wanted to. (Obviously the first two are only
sensible on first submission where depending on length of patch series
one could just use --cc.)

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



[Qemu-devel] [PATCH 0/1] RFC: ipl device for s390

2012-05-04 Thread Christian Borntraeger
Alex,

while Einar is reworking the block size/geometry patches,
here is the current state of the external loader. While the real firmware
loader only supports fcp, this patch also allows to ipl dasd disks
(the differences in terms of on-disk format are pretty small).
This has the advantage of being able to zipl on LPAR and ipl in KVM and vice
versa for DASD disks.

This patch also contains code to IPL a new dasd bootmap (which is then 
architectured) that will be created by a future zipl version. This zipl
version will then also allow to zipl a dasd/scsi disk under KVM and
create the same bootmap as under LPAR.

I was able to IPL CDL,LDL and FCP disks.
Can you have a look and give some review feedback?

PS: booting from dasd requires the correct geometry and blocksize

Christian Borntraeger (1):
  s390: IPL device for s390

 Makefile.target  |2 +-
 hw/s390-loader.c |  463 ++
 hw/s390-loader.h |   81 ++
 hw/s390-virtio.c |   36 +
 vl.c |7 +
 5 files changed, 554 insertions(+), 35 deletions(-)
 create mode 100644 hw/s390-loader.c
 create mode 100644 hw/s390-loader.h

-- 
1.7.9.6




[Qemu-devel] [PATCH 1/1] s390: IPL device for s390

2012-05-04 Thread Christian Borntraeger
An IPL (booting) on s390 of SCSI disks is done by a firmware component.
Lets implement this scheme as an qemu device that also allows to
configure the IPL like the HMC. We have a parameter iplid that
refers to a disk device and a load parm that specifies the entry
on the disk to be ipled. We also provide a default device
if no -device s390-ipl statement is given.

Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 Makefile.target  |2 +-
 hw/s390-loader.c |  463 ++
 hw/s390-loader.h |   81 ++
 hw/s390-virtio.c |   36 +
 vl.c |7 +
 5 files changed, 554 insertions(+), 35 deletions(-)
 create mode 100644 hw/s390-loader.c
 create mode 100644 hw/s390-loader.h

diff --git a/Makefile.target b/Makefile.target
index 1582904..7b8cd84 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -374,7 +374,7 @@ obj-sh4-y += ide/mmio.o
 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
 obj-m68k-y += m68k-semi.o dummy_m68k.o
 
-obj-s390x-y = s390-virtio-bus.o s390-virtio.o
+obj-s390x-y = s390-virtio-bus.o s390-virtio.o s390-loader.o
 
 obj-alpha-y = mc146818rtc.o
 obj-alpha-y += alpha_pci.o alpha_dp264.o alpha_typhoon.o
diff --git a/hw/s390-loader.c b/hw/s390-loader.c
new file mode 100644
index 000..2d63ecf
--- /dev/null
+++ b/hw/s390-loader.c
@@ -0,0 +1,463 @@
+/*
+ * bootloader support
+ * Copyright IBM Corp. 2007,2012
+ * Author: Christian Borntraeger borntrae...@de.ibm.com
+ *
+ * This file is licensed under the terms of the GNU General Public License(GPL)
+ */
+
+#include stdio.h
+#include sys/types.h
+#include sys/stat.h
+#include sys/ioctl.h
+#include linux/fs.h
+#include fcntl.h
+#include stdint.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+#include cpu.h
+#include hw/loader.h
+#include hw/s390-loader.h
+#include hw/s390-virtio-bus.h
+#include hw/sysbus.h
+
+#define KERN_IMAGE_START0x01UL
+
+typedef struct {
+BlockDriverState *bs;
+uint64_t (*blockno)(BlockPtr *blockptr);
+uint64_t (*offset)(BlockPtr *blockptr);
+uint64_t (*size)(BlockPtr *blockptr);
+bool (*empty)(BlockPtr *blockptr);
+BlockPtr *(*element)(BlockPtr *blockptr, int num);
+uint32_t (*entries)(void);
+uint32_t  loadparm;
+uint8_t  heads;
+uint8_t  secs;
+uint16_t blk_size;
+} Loader;
+
+/*
+ * We have one structure that is setup with the right callbacks for the
+ * detected type of boot loader
+ */
+static Loader loader;
+
+/* here are the FCP Callbacks */
+static uint64_t getblockno_fcp(BlockPtr *entry)
+{
+return be64_to_cpu(entry-u.fcp.blockno);
+}
+
+static uint64_t getoffset_fcp(BlockPtr *entry)
+{
+return getblockno_fcp(entry) * be16_to_cpu(entry-u.fcp.size);
+}
+
+static uint64_t getsize_fcp(BlockPtr *entry)
+{
+return loader.blk_size * (be16_to_cpu(entry-u.fcp.blockct) + 1);
+}
+
+static bool getempty_fcp(BlockPtr *entry)
+{
+return getblockno_fcp(entry) == 0UL;
+}
+
+static BlockPtr *getelement_fcp(BlockPtr *blockptr, int num)
+{
+ FCPBlockPtr *fcp = (FCPBlockPtr *) blockptr;
+
+ return (BlockPtr *) fcp[num];
+}
+
+static uint32_t entries_fcp(void)
+{
+return loader.blk_size / sizeof(FCPBlockPtr);
+};
+
+/* and here the callbacks for the new and old eckd map */
+static uint64_t getblockno_eckd(BlockPtr *entry)
+{
+return 1UL * loader.secs * loader.heads * entry-u.eckd.cyls +
+   1UL * loader.secs * entry-u.eckd.heads +
+   1UL * entry-u.eckd.secs - 1UL;
+}
+
+static uint64_t getoffset_eckd(BlockPtr *entry)
+{
+return getblockno_eckd(entry) * entry-u.eckd.block_size;
+}
+
+static uint64_t getsize_eckd(BlockPtr *entry)
+{
+return loader.blk_size * (entry-u.eckd.count + 1);
+}
+
+static bool getempty_eckd(BlockPtr *entry)
+{
+return getblockno_eckd(entry) == -1UL;
+}
+
+static BlockPtr *getelement_eckd(BlockPtr *blockptr, int num)
+{
+ ECKDBlockPtr *eckd = (ECKDBlockPtr *) blockptr;
+
+ return (BlockPtr *) eckd[num];
+}
+
+static BlockPtr *getelement_neckd(BlockPtr *blockptr, int num)
+{
+ NECKDBlockPtr *neckd = (NECKDBlockPtr *) blockptr;
+
+ return (BlockPtr *) neckd[num];
+}
+
+
+static uint32_t entries_eckd(void)
+{
+return loader.blk_size / sizeof(ECKDBlockPtr);
+};
+
+static uint32_t entries_neckd(void)
+{
+return loader.blk_size / sizeof(NECKDBlockPtr);
+};
+
+static int magic_ok(void *tmp)
+{
+return memcmp(tmp, zIPL, 4) == 0 ? 1 : 0;
+}
+
+static uint64_t parse_segment_elements(BlockPtr *bprs,
+   uint64_t *address,
+   Loader *loader)
+{
+unsigned d;
+int len;
+
+for (d = 0; d  loader-entries() - 1; d++) {
+if (*address  ram_size) {
+error_report(s390-ipl: bootmap points to illegal address);
+exit(1);
+}
+if (loader-empty(loader-element(bprs, d))) {
+return 0;
+}
+len = 

Re: [Qemu-devel] [PATCH 1/1] s390: IPL device for s390

2012-05-04 Thread Alexander Graf

On 04.05.2012, at 15:44, Christian Borntraeger wrote:

 An IPL (booting) on s390 of SCSI disks is done by a firmware component.
 Lets implement this scheme as an qemu device that also allows to
 configure the IPL like the HMC. We have a parameter iplid that
 refers to a disk device and a load parm that specifies the entry
 on the disk to be ipled. We also provide a default device
 if no -device s390-ipl statement is given.

Any reason we can't do this in guest firmware code?


Alex




Re: [Qemu-devel] [PATCH 2/3] runstate: introduce suspended state

2012-05-04 Thread Gerd Hoffmann
  Hi,

 There's a quite simple and stupid way to do it. When we migrate an stopped
 VM, it's automatically resumed on the target. We could do the same for a
 suspended VM: we could automatically resume it before migrating, as you said
 above.
 
 That's not the behavior I'd expect, I mean I would expect a stopped VM to
 remain stopped after it's migrated. But it has always been this way and I'm
 afraid we can't change this.

Oh, I wasn't aware that a stopped vm behaves the same way.  So resuming
on migration is sort-of bug compatible then.  Patch attached.  Will you
add it to your series or should I submit it separately?

cheers,
  Gerd
From 566ec2adacfa570e9d08067e242a6b7224c46c8e Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann kra...@redhat.com
Date: Wed, 7 Mar 2012 08:00:26 +0100
Subject: [PATCH] wakeup on migration

Wakeup the guest when the live part of the migation is finished.
This avoids being in suspended state on migration, so we don't
have to save the is_suspended bit.

Signed-off-by: Gerd Hoffmann kra...@redhat.com
---
 migration.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/migration.c b/migration.c
index 94f7839..f9e968e 100644
--- a/migration.c
+++ b/migration.c
@@ -252,6 +252,7 @@ static void migrate_fd_put_ready(void *opaque)
 int old_vm_running = runstate_is_running();
 
 DPRINTF(done iterating\n);
+qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
 vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
 
 if (qemu_savevm_state_complete(s-file)  0) {
-- 
1.7.1



Re: [Qemu-devel] [PATCH 2/3] runstate: introduce suspended state

2012-05-04 Thread Luiz Capitulino
On Fri, 04 May 2012 15:54:26 +0200
Gerd Hoffmann kra...@redhat.com wrote:

   Hi,
 
  There's a quite simple and stupid way to do it. When we migrate an stopped
  VM, it's automatically resumed on the target. We could do the same for a
  suspended VM: we could automatically resume it before migrating, as you said
  above.
  
  That's not the behavior I'd expect, I mean I would expect a stopped VM to
  remain stopped after it's migrated. But it has always been this way and I'm
  afraid we can't change this.
 
 Oh, I wasn't aware that a stopped vm behaves the same way.  So resuming
 on migration is sort-of bug compatible then.  Patch attached.  Will you
 add it to your series or should I submit it separately?

I can add it to my series, thanks Gerd!



Re: [Qemu-devel] [PATCH 1/1] s390: IPL device for s390

2012-05-04 Thread Christian Borntraeger
On 04/05/12 15:53, Alexander Graf wrote:
 
 On 04.05.2012, at 15:44, Christian Borntraeger wrote:
 
 An IPL (booting) on s390 of SCSI disks is done by a firmware component.
 Lets implement this scheme as an qemu device that also allows to
 configure the IPL like the HMC. We have a parameter iplid that
 refers to a disk device and a load parm that specifies the entry
 on the disk to be ipled. We also provide a default device
 if no -device s390-ipl statement is given.
 
 Any reason we can't do this in guest firmware code?

Conceptually guest firmware does not exist in the guest address space
on s390. It is separate in a storage area called HSA. 
(you could say the existing hardware is semi-hosted, you cant buy it bare 
metal.
Doing the boot code in guest address space will fail if the guest firmware
address  collides with the addresses specified by a bootmap.

Christian




  1   2   >