Re: [Qemu-devel] [PATCH 2/2] virtio: refresh registers at reset time

2013-10-15 Thread Rusty Russell
Greg Kurz gk...@linux.vnet.ibm.com writes:
 We need to support the guest endianness as soon as a virtio device shows
 up. Alex suggested this can achieved by calling cpu_synchronize_state().

 To have it working on PowerPC, we need to add LPCR in the sync register
 functions.

 Signed-off-by: Greg Kurz gk...@linux.vnet.ibm.com

Excellent!  Alex, if you take this, I'll be happy to rebase and re-test
the virtio endianness patches on top.

Cheers,
Rusty.



[Qemu-devel] [PATCH 2/2] virtio: refresh registers at reset time

2013-10-07 Thread Greg Kurz
We need to support the guest endianness as soon as a virtio device shows
up. Alex suggested this can achieved by calling cpu_synchronize_state().

To have it working on PowerPC, we need to add LPCR in the sync register
functions.

Signed-off-by: Greg Kurz gk...@linux.vnet.ibm.com
---
 hw/virtio/virtio.c |5 +
 target-ppc/kvm.c   |4 
 2 files changed, 9 insertions(+)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index bc728d8..4a294e1 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -19,6 +19,7 @@
 #include qemu/atomic.h
 #include hw/virtio/virtio-bus.h
 #include hw/virtio/virtio-access.h
+#include sysemu/kvm.h
 
 /*
  * The alignment to use between consumer and producer parts of vring.
@@ -566,6 +567,10 @@ void virtio_reset(void *opaque)
 vdev-vq[i].signalled_used_valid = false;
 vdev-vq[i].notification = true;
 }
+
+if (current_cpu) {
+cpu_synchronize_state(current_cpu);
+}
 }
 
 uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index b77ce5e..69ebe2a 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -869,6 +869,8 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 DPRINTF(Warning: Unable to set VPA information to KVM\n);
 }
 }
+
+kvm_put_one_spr(cs, KVM_REG_PPC_LPCR, SPR_LPCR);
 #endif /* TARGET_PPC64 */
 }
 
@@ -1091,6 +1093,8 @@ int kvm_arch_get_registers(CPUState *cs)
 DPRINTF(Warning: Unable to get VPA information from KVM\n);
 }
 }
+
+kvm_get_one_spr(cs, KVM_REG_PPC_LPCR, SPR_LPCR);
 #endif
 }