Patchwork [2/2] virtio: refresh registers at reset time

login
register
mail settings
Submitter Greg Kurz
Date Oct. 7, 2013, 3:23 p.m.
Message ID <20131007152344.26996.16447.stgit@bahia.local>
Download mbox | patch
Permalink /patch/281131/
State New
Headers show

Comments

Greg Kurz - Oct. 7, 2013, 3:23 p.m.
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 <gkurz@linux.vnet.ibm.com>
---
 hw/virtio/virtio.c |    5 +++++
 target-ppc/kvm.c   |    4 ++++
 2 files changed, 9 insertions(+)
Rusty Russell - Oct. 15, 2013, 1:49 a.m.
Greg Kurz <gkurz@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 <gkurz@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.

Patch

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
     }