Skip to contentSkip to conversation

virtio for endian curious guests Take #2

PATCH In review Rusty Russell 5 participants 19 messages Aug 12, 2013 – Sep 10, 2013

lore
Share & tools
lore
#0 lore raw

cover virtio for endian curious guests Take #2

The driver parts (patches 3-8) are unchanged, so didn't repost.

1) Rebased onto more recent git tree.
2) New stub is virtio_get_byteswap()
3) PPC64 uses endianness of first CPU interrupt vectors, not CPU endiannes.

Hope this one is closer...
Rusty.

Rusty Russell (8):
virtio_get_byteswap: function for endian-ambivalent targets using
virtio.
target-ppc: ppc64 target's virtio can be either endian.
virtio: allow byte swapping for vring and config access hw/net/virtio-net: use virtio wrappers to access headers. hw/net/virtio-balloon: use virtio wrappers to access page frame
numbers.
hw/block/virtio-blk: use virtio wrappers to access headers. hw/scsi/virtio-scsi: use virtio wrappers to access headers. hw/char/virtio-serial-bus: use virtio wrappers to access headers.

 hw/block/virtio-blk.c             |  35 +++++-----
 hw/char/virtio-serial-bus.c       |  34 +++++-----
 hw/net/virtio-net.c               |  15 +++--
 hw/scsi/virtio-scsi.c             |  33 +++++-----
 hw/virtio/virtio-balloon.c        |   3 +-
 hw/virtio/virtio.c                |  29 +++++----
 include/hw/virtio/virtio-access.h | 130 ++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio.h        |   2 +
 stubs/Makefile.objs               |   1 +
 stubs/virtio_get_byteswap.c       |   6 ++
 target-ppc/misc_helper.c          |   9 +++
 11 files changed, 226 insertions(+), 71 deletions(-)
 create mode 100644 include/hw/virtio/virtio-access.h
 create mode 100644 stubs/virtio_get_byteswap.c
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/8 virtio_get_byteswap: function for endian-ambivalent targets using virtio.

virtio data structures are defined as "target endian", which assumes that's a fixed value. In fact, that actually means it's platform-specific.

Hopefully the OASIS virtio 1.0 spec will fix this. Meanwhile, create a hook for little endian ppc.

---
 include/hw/virtio/virtio-access.h | 130 ++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio.h        |   2 +
 stubs/Makefile.objs               |   1 +
 stubs/virtio_get_byteswap.c       |   6 ++
 4 files changed, 139 insertions(+)
 create mode 100644 include/hw/virtio/virtio-access.h
 create mode 100644 stubs/virtio_get_byteswap.c
include/hw/virtio/virtio-access.h new file +130 -0
new file mode 100644
index 0000000..01d7dd6
@@ -0,0 +1,130 @@
+/*
+ * Virtio Accessor Support: In case your target can change endian.
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Rusty Russell   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+#ifndef _QEMU_VIRTIO_ACCESS_H
+#define _QEMU_VIRTIO_ACCESS_H
+#include "hw/virtio/virtio.h"
+
+static inline uint16_t virtio_lduw_phys(hwaddr pa)
+{
+    if (virtio_get_byteswap()) {
+        return bswap16(lduw_phys(pa));
+    }
+    return lduw_phys(pa);
+    
+}
+
+static inline uint32_t virtio_ldl_phys(hwaddr pa)
+{
+    if (virtio_get_byteswap()) {
+        return bswap32(ldl_phys(pa));
+    }
+    return ldl_phys(pa);
+}
+
+static inline uint64_t virtio_ldq_phys(hwaddr pa)
+{
+    if (virtio_get_byteswap()) {
+        return bswap64(ldq_phys(pa));
+    }
+    return ldq_phys(pa);
+}
+
+static inline void virtio_stw_phys(hwaddr pa, uint16_t value)
+{
+    if (virtio_get_byteswap()) {
+        stw_phys(pa, bswap16(value));
+    } else {
+        stw_phys(pa, value);
+    }
+}
+
+static inline void virtio_stl_phys(hwaddr pa, uint32_t value)
+{
+    if (virtio_get_byteswap()) {
+        stl_phys(pa, bswap32(value));
+    } else {
+        stl_phys(pa, value);
+    }
+}
+
+static inline void virtio_stw_p(void *ptr, uint16_t v)
+{
+    if (virtio_get_byteswap()) {
+        stw_p(ptr, bswap16(v));
+    } else {
+        stw_p(ptr, v);
+    }
+}
+
+static inline void virtio_stl_p(void *ptr, uint32_t v)
+{
+    if (virtio_get_byteswap()) {
+        stl_p(ptr, bswap32(v));
+    } else {
+        stl_p(ptr, v);
+    }
+}
+
+static inline void virtio_stq_p(void *ptr, uint64_t v)
+{
+    if (virtio_get_byteswap()) {
+        stq_p(ptr, bswap64(v));
+    } else {
+        stq_p(ptr, v);
+    }
+}
+
+static inline int virtio_lduw_p(const void *ptr)
+{
+    if (virtio_get_byteswap()) {
+        return bswap16(lduw_p(ptr));
+    } else {
+        return lduw_p(ptr);
+    }
+}
+
+static inline int virtio_ldl_p(const void *ptr)
+{
+    if (virtio_get_byteswap()) {
+        return bswap32(ldl_p(ptr));
+    } else {
+        return ldl_p(ptr);
+    }
+}
+
+static inline uint64_t virtio_ldq_p(const void *ptr)
+{
+    if (virtio_get_byteswap()) {
+        return bswap64(ldq_p(ptr));
+    } else {
+        return ldq_p(ptr);
+    }
+}
+
+static inline uint32_t virtio_tswap32(uint32_t s)
+{
+    if (virtio_get_byteswap()) {
+        return bswap32(tswap32(s));
+    } else {
+        return tswap32(s);
+    }
+}
+
+static inline void virtio_tswap32s(uint32_t *s)
+{
+    tswap32s(s);
+    if (virtio_get_byteswap()) {
+        *s = bswap32(*s);
+    }
+}
+#endif /* _QEMU_VIRTIO_ACCESS_H */
include/hw/virtio/virtio.h +2 -0
index d7e9e0f..18ca725 100644
@@ -248,4 +248,6 @@ void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
                                                bool set_handler);
 void virtio_queue_notify_vq(VirtQueue *vq);
 void virtio_irq(VirtQueue *vq);
+
+extern bool virtio_get_byteswap(void);
 #endif
stubs/Makefile.objs +1 -0
index f306cba..05f7bab 100644
@@ -26,3 +26,4 @@ stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
+stub-obj-y += virtio_get_byteswap.o
stubs/virtio_get_byteswap.c new file +6 -0
new file mode 100644
index 0000000..7cf764d
@@ -0,0 +1,6 @@
+#include "hw/virtio/virtio.h"
+
+bool virtio_get_byteswap(void)
+{
+    return false;
+}
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 6 lines · Rusty Russell

virtio data structures are defined as "target endian", which assumes that's a fixed value. In fact, that actually means it's platform-specific.

Hopefully the OASIS virtio 1.0 spec will fix this. Meanwhile, create a hook for little endian ppc.

Ok, sorry if I missed a previous debate on that one but why do you do a call-out to architecture specific stuff (that is not even inline) on every access ?

If we consider that virtio byte order is global, can't you make it a global that is *set* by the architecture rather than *polled* by virtio ?

We have explicit knowledge of when our endianness change (we get the hcall or a write to some SPR), we can call virtio *then* to adjust the endianness rather than having a call-out to the platform on every access.

Ben.

#3 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 4 lines · Benjamin Herrenschmidt

We have explicit knowledge of when our endianness change (we get the hcall or a write to some SPR), we can call virtio *then* to adjust the endianness rather than having a call-out to the platform on every access.

ARM doesn't -- I wouldn't expect changing the endianness of exceptions via writing to the SCTLR to trap to the hypervisor (and in any case it certainly won't result in a return to userspace).

-- PMM

#4 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 11 lines · Peter Maydell
Quoted 4 lines · Benjamin Herrenschmidt

We have explicit knowledge of when our endianness change (we get the hcall or a write to some SPR), we can call virtio *then* to adjust the endianness rather than having a call-out to the platform on every access.

ARM doesn't -- I wouldn't expect changing the endianness of exceptions via writing to the SCTLR to trap to the hypervisor (and in any case it certainly won't result in a return to userspace).

But don't you need to reconfigure the bridge (as per our previous discussion) ? In that case you do need to call out to qemu ...

Cheers,
Ben.

#5 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 8 lines · Benjamin Herrenschmidt
Quoted 4 lines · Peter Maydell

ARM doesn't -- I wouldn't expect changing the endianness of exceptions via writing to the SCTLR to trap to the hypervisor (and in any case it certainly won't result in a return to userspace).

But don't you need to reconfigure the bridge (as per our previous discussion) ? In that case you do need to call out to qemu ...

Bridge? You've lost me, I'm afraid.

-- PMM

#6 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 8 lines · Peter Maydell
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 4 lines · Peter Maydell

ARM doesn't -- I wouldn't expect changing the endianness of exceptions via writing to the SCTLR to trap to the hypervisor (and in any case it certainly won't result in a return to userspace).

Quoted 4 lines
Quoted 2 lines

But don't you need to reconfigure the bridge (as per our previous discussion) ? In that case you do need to call out to qemu ...

Bridge? You've lost me, I'm afraid.

I must be confused ... you mentioned in a previous discussion around endianness that on some ARM cores at least, when changing the OS endianness, you had to configure a different lane swapping in the bridge to the the IO devices (AXI ?)

But I might be confusing with something else.

Ben.

#7 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 4 lines · Benjamin Herrenschmidt

I must be confused ... you mentioned in a previous discussion around endianness that on some ARM cores at least, when changing the OS endianness, you had to configure a different lane swapping in the bridge to the the IO devices (AXI ?)

No, that's just the implementation -- the bit in the control register is effectively controlling whether there is byte lane swapping in the part of the CPU which is the data path between it and its bus to the outside world.

-- PMM

#8 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 11 lines · Peter Maydell
Quoted 4 lines · Benjamin Herrenschmidt

I must be confused ... you mentioned in a previous discussion around endianness that on some ARM cores at least, when changing the OS endianness, you had to configure a different lane swapping in the bridge to the the IO devices (AXI ?)

No, that's just the implementation -- the bit in the control register is effectively controlling whether there is byte lane swapping in the part of the CPU which is the data path between it and its bus to the outside world.

I find it amazing that an OS can touch that without hitting the hypervisor :-) Anyway, ok, we do need to poll from virtio then, but we probably need to cache as well, no ?

When do you sample it in qemu ?

Cheers,
Ben.

#9 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 8 lines · Benjamin Herrenschmidt
Quoted 7 lines · Peter Maydell
Quoted 4 lines · Benjamin Herrenschmidt

I must be confused ... you mentioned in a previous discussion around endianness that on some ARM cores at least, when changing the OS endianness, you had to configure a different lane swapping in the bridge to the the IO devices (AXI ?)

Quoted 7 lines
Quoted 4 lines

No, that's just the implementation -- the bit in the control register is effectively controlling whether there is byte lane swapping in the part of the CPU which is the data path between it and its bus to the outside world.

I find it amazing that an OS can touch that without hitting the hypervisor :-)

It's no different to having a userspace process able to have a different setting from the OS, really. (There is an equivalent bit in another register that controls what endianness we use if we trap to hyp mode.)

Quoted 4 lines

Anyway, ok, we do need to poll from virtio then, but we probably need to cache as well, no ?

When do you sample it in qemu ?

It's a bit theoretical at the moment since QEMU's ARM code kind of assumes little endian. I would expect that at the point when virtio was in an MMIO callback the CPUState struct would have been updated via the usual sync process in kvm_arch_get_registers().

-- PMM

#10 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

In reply to Benjamin Herrenschmidt
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 6 lines · Rusty Russell

virtio data structures are defined as "target endian", which assumes that's a fixed value. In fact, that actually means it's platform-specific.

Hopefully the OASIS virtio 1.0 spec will fix this. Meanwhile, create a hook for little endian ppc.

Ok, sorry if I missed a previous debate on that one but why do you do a call-out to architecture specific stuff (that is not even inline) on every access ?

Let's focus on getting something merged. Then we can muck around with it down the road.

Having target-ppc call into virtio is a layering violation. This approach keeps the dependencies cleaner.

Regards,

Anthony Liguori

Quoted 11 lines

If we consider that virtio byte order is global, can't you make it a global that is *set* by the architecture rather than *polled* by virtio ?

We have explicit knowledge of when our endianness change (we get the hcall or a write to some SPR), we can call virtio *then* to adjust the endianness rather than having a call-out to the platform on every access.

Ben.

#11 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 4 lines · Rusty Russell

virtio data structures are defined as "target endian", which assumes that's a fixed value. In fact, that actually means it's platform-specific.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Hopefully the OASIS virtio 1.0 spec will fix this. Meanwhile, create a hook for little endian ppc.

Ok, sorry if I missed a previous debate on that one but why do you do a call-out to architecture specific stuff (that is not even inline) on every access ?

Anthony said he wanted it that way: my initial patch was more optimized.

Quoted 5 lines

Let's focus on getting something merged. Then we can muck around with it down the road.

Having target-ppc call into virtio is a layering violation. This approach keeps the dependencies cleaner.

We can have it call once (eg. when the first and storing the status word) and store the result.

Cheers,
Rusty.

#12 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 2 lines · Rusty Russell

We can have it call once (eg. when the first and storing the status word) and store the result.

And fail with kexec of a different endian kernel :-) Let's not bother yet. Merge it and then we see if we can optimize.

Cheers,
Ben.

#13 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

Quoted 6 lines · Benjamin Herrenschmidt
Quoted 2 lines · Rusty Russell

We can have it call once (eg. when the first and storing the status word) and store the result.

And fail with kexec of a different endian kernel :-) Let's not bother yet. Merge it and then we see if we can optimize.

Yeah, my code actually did it every status bye write, which unintentionally solved this.

But agreed, let's let these patches stand...

Cheers,
Rusty.

#14 lore raw

Re: [Qemu-devel] [PATCH 1/8] virtio_get_byteswap: function for endian-ambivalent targets using virtio.

In reply to Benjamin Herrenschmidt
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 6 lines · Rusty Russell

virtio data structures are defined as "target endian", which assumes that's a fixed value. In fact, that actually means it's platform-specific.

Hopefully the OASIS virtio 1.0 spec will fix this. Meanwhile, create a hook for little endian ppc.

Quoted 7 lines

Ok, sorry if I missed a previous debate on that one but why do you do a call-out to architecture specific stuff (that is not even inline) on every access ?

If we consider that virtio byte order is global, can't you make it a global that is *set* by the architecture rather than *polled* by virtio ?

OK, so after some more offline discussion it turns out these patches won't really work reliably, since powerpc kvm doesn't reflect the register into qemu.

Mikey N has promised me a KVM_GET_ONE_REG to get the register, and I'll rework on top of that: we will query that whenever a device is reset (which Linux does on every device init, so it captures the kexec case too).

Cheers,
Rusty.

#15 lore raw

PATCH 2/8 target-ppc: ppc64 target's virtio can be either endian.

In reply to Rusty Russell

We base it on the OS endian, as reflected by the endianness of the interrupt vectors.

---
 target-ppc/misc_helper.c | 9 +++++++++
 1 file changed, 9 insertions(+)
target-ppc/misc_helper.c +9 -0
index 616aab6..6c97c81 100644
@@ -20,6 +20,7 @@
 #include "helper.h"
 
 #include "helper_regs.h"
+#include "hw/virtio/virtio.h"
 
 /*****************************************************************************/
 /* SPR accesses */
@@ -116,3 +117,11 @@ void ppc_store_msr(CPUPPCState *env, target_ulong value)
 {
     hreg_store_msr(env, value, 0);
 }
+
+bool virtio_get_byteswap(void)
+{
+    PowerPCCPU *cp = POWERPC_CPU(first_cpu);
+    CPUPPCState *env = &cp->env;
+
+    return env->spr[SPR_LPCR] & LPCR_ILE;
+}
Signature · 1 line
1.8.1.2
#16 lore raw

PATCH 3/8 virtio: allow byte swapping for vring and config access

In reply to Rusty Russell

This is based on a simpler patch by Anthony Liguouri, which only handled the vring accesses. We also need some drivers to access these helpers, eg. for data which contains headers.

---
 hw/virtio/virtio.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
hw/virtio/virtio.c +15 -14
index 09f62c6..178647b 100644
@@ -18,6 +18,7 @@
 #include "hw/virtio/virtio.h"
 #include "qemu/atomic.h"
 #include "hw/virtio/virtio-bus.h"
+#include "hw/virtio/virtio-access.h"
 
 /*
  * The alignment to use between consumer and producer parts of vring.
@@ -104,49 +105,49 @@ static inline uint64_t vring_desc_addr(hwaddr desc_pa, int i)
 {
     hwaddr pa;
     pa = desc_pa + sizeof(VRingDesc) * i + offsetof(VRingDesc, addr);
-    return ldq_phys(pa);
+    return virtio_ldq_phys(pa);
 }
 
 static inline uint32_t vring_desc_len(hwaddr desc_pa, int i)
 {
     hwaddr pa;
     pa = desc_pa + sizeof(VRingDesc) * i + offsetof(VRingDesc, len);
-    return ldl_phys(pa);
+    return virtio_ldl_phys(pa);
 }
 
 static inline uint16_t vring_desc_flags(hwaddr desc_pa, int i)
 {
     hwaddr pa;
     pa = desc_pa + sizeof(VRingDesc) * i + offsetof(VRingDesc, flags);
-    return lduw_phys(pa);
+    return virtio_lduw_phys(pa);
 }
 
 static inline uint16_t vring_desc_next(hwaddr desc_pa, int i)
 {
     hwaddr pa;
     pa = desc_pa + sizeof(VRingDesc) * i + offsetof(VRingDesc, next);
-    return lduw_phys(pa);
+    return virtio_lduw_phys(pa);
 }
 
 static inline uint16_t vring_avail_flags(VirtQueue *vq)
 {
     hwaddr pa;
     pa = vq->vring.avail + offsetof(VRingAvail, flags);
-    return lduw_phys(pa);
+    return virtio_lduw_phys(pa);
 }
 
 static inline uint16_t vring_avail_idx(VirtQueue *vq)
 {
     hwaddr pa;
     pa = vq->vring.avail + offsetof(VRingAvail, idx);
-    return lduw_phys(pa);
+    return virtio_lduw_phys(pa);
 }
 
 static inline uint16_t vring_avail_ring(VirtQueue *vq, int i)
 {
     hwaddr pa;
     pa = vq->vring.avail + offsetof(VRingAvail, ring[i]);
-    return lduw_phys(pa);
+    return virtio_lduw_phys(pa);
 }
 
 static inline uint16_t vring_used_event(VirtQueue *vq)
@@ -158,42 +159,42 @@ static inline void vring_used_ring_id(VirtQueue *vq, int i, uint32_t val)
 {
     hwaddr pa;
     pa = vq->vring.used + offsetof(VRingUsed, ring[i].id);
-    stl_phys(pa, val);
+    virtio_stl_phys(pa, val);
 }
 
 static inline void vring_used_ring_len(VirtQueue *vq, int i, uint32_t val)
 {
     hwaddr pa;
     pa = vq->vring.used + offsetof(VRingUsed, ring[i].len);
-    stl_phys(pa, val);
+    virtio_stl_phys(pa, val);
 }
 
 static uint16_t vring_used_idx(VirtQueue *vq)
 {
     hwaddr pa;
     pa = vq->vring.used + offsetof(VRingUsed, idx);
-    return lduw_phys(pa);
+    return virtio_lduw_phys(pa);
 }
 
 static inline void vring_used_idx_set(VirtQueue *vq, uint16_t val)
 {
     hwaddr pa;
     pa = vq->vring.used + offsetof(VRingUsed, idx);
-    stw_phys(pa, val);
+    virtio_stw_phys(pa, val);
 }
 
 static inline void vring_used_flags_set_bit(VirtQueue *vq, int mask)
 {
     hwaddr pa;
     pa = vq->vring.used + offsetof(VRingUsed, flags);
-    stw_phys(pa, lduw_phys(pa) | mask);
+    virtio_stw_phys(pa, virtio_lduw_phys(pa) | mask);
 }
 
 static inline void vring_used_flags_unset_bit(VirtQueue *vq, int mask)
 {
     hwaddr pa;
     pa = vq->vring.used + offsetof(VRingUsed, flags);
-    stw_phys(pa, lduw_phys(pa) & ~mask);
+    virtio_stw_phys(pa, virtio_lduw_phys(pa) & ~mask);
 }
 
 static inline void vring_avail_event(VirtQueue *vq, uint16_t val)
@@ -203,7 +204,7 @@ static inline void vring_avail_event(VirtQueue *vq, uint16_t val)
         return;
     }
     pa = vq->vring.used + offsetof(VRingUsed, ring[vq->vring.num]);
-    stw_phys(pa, val);
+    virtio_stw_phys(pa, val);
 }
 
 void virtio_queue_set_notification(VirtQueue *vq, int enable)
Signature · 1 line
1.8.1.2
#17 lore raw

PATCH 1/1 hw/9pfs/virtio_9p_device: use virtio wrappers to access headers.

Follow-up to Rusty's virtio endianness serie: enough to get a working virtfs mount.

Note that st*_raw and ld*_raw are effectively replaced by st*_p and ld*_p.

---
 hw/9pfs/virtio-9p-device.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/9pfs/virtio-9p-device.c +2 -1
index f0ffbe8..bc2d0da 100644
@@ -19,6 +19,7 @@
 #include "fsdev/qemu-fsdev.h"
 #include "virtio-9p-xattr.h"
 #include "virtio-9p-coth.h"
+#include "hw/virtio/virtio-access.h"
 
 static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
 {
@@ -34,7 +35,7 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
 
     len = strlen(s->tag);
     cfg = g_malloc0(sizeof(struct virtio_9p_config) + len);
-    stw_raw(&cfg->tag_len, len);
+    virtio_stl_p(&cfg->tag_len, len);
     /* We don't copy the terminating null to config space */
     memcpy(cfg->tag, s->tag, len);
     memcpy(config, cfg, s->config_size);
#18 lore raw

Re: [Qemu-devel] [PATCH] hw/9pfs/virtio_9p_device: use virtio wrappers to access headers.

Quoted 6 lines · Greg Kurz

Follow-up to Rusty's virtio endianness serie: enough to get a working virtfs mount.

Note that st*_raw and ld*_raw are effectively replaced by st*_p and ld*_p.

Thanks!

I've reworked my patches in line with the anticipated KVM_GET_ONE_REG from Mikey, and put this into the series.

Mikey, here's the template I assumed (needs CONFIG_KVM implementation of kvmppc_update_spr_lpcr).

Cheers,
Rusty.

FIXME: Implement for KVM using KVM_GET_ONE_REG!

target-ppc/kvm_ppc.h +5 -0
index 771cfbe..30d8af6 100644
@@ -29,6 +29,7 @@ int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
 int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
 int kvmppc_set_tcr(PowerPCCPU *cpu);
 int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
+void kvmppc_update_spr_lpcr(PowerPCCPU *cpu);
 #ifndef CONFIG_USER_ONLY
 off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
 void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd);
@@ -159,6 +160,10 @@ static inline bool kvmppc_has_cap_epr(void)
 {
     return false;
 }
+
+static inline void kvmppc_update_spr_lpcr(PowerPCCPU *cpu)
+{
+}
 #endif
 
 #ifndef CONFIG_KVM