qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-ppc: ppc64 target's virtio can be either endian.
@ 2013-11-25 15:35 Greg Kurz
  2013-12-09 15:33 ` Alexander Graf
  0 siblings, 1 reply; 15+ messages in thread
From: Greg Kurz @ 2013-11-25 15:35 UTC (permalink / raw)
  To: rusty; +Cc: qemu-ppc, agraf, qemu-devel

We base it on the OS endian, as reflected by the endianness of the
interrupt vectors (handled through the ILE bit in the LPCR register).

This patch does two things:
- make LPCR a KVM register
- implement virtio_get_byteswap() over LPCR

This patch requires to have the following defined in the linux headers:

$ grep LPCR linux-headers/asm-powerpc/kvm.h
#define KVM_REG_PPC_LPCR        (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)

Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 target-ppc/kvm.c         |    4 ++++
 target-ppc/misc_helper.c |   14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 10d0cd9..b450a22 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
     }
 
diff --git a/target-ppc/misc_helper.c b/target-ppc/misc_helper.c
index 616aab6..0e0743a 100644
--- a/target-ppc/misc_helper.c
+++ b/target-ppc/misc_helper.c
@@ -20,6 +20,8 @@
 #include "helper.h"
 
 #include "helper_regs.h"
+#include "hw/virtio/virtio.h"
+#include "sysemu/kvm.h"
 
 /*****************************************************************************/
 /* SPR accesses */
@@ -116,3 +118,15 @@ 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;
+
+    if (kvm_enabled()) { 
+        kvm_arch_get_registers(first_cpu);
+    }
+
+    return env->spr[SPR_LPCR] & LPCR_ILE;
+}

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-01-20 14:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 15:35 [Qemu-devel] [PATCH] target-ppc: ppc64 target's virtio can be either endian Greg Kurz
2013-12-09 15:33 ` Alexander Graf
2013-12-09 17:11   ` Greg Kurz
2013-12-09 17:18     ` Alexander Graf
2013-12-10 17:37       ` Greg Kurz
2013-12-10 17:48         ` Alexander Graf
2013-12-10 19:44           ` Greg Kurz
2013-12-10 22:25             ` Alexander Graf
2013-12-11 15:59               ` [Qemu-devel] [PATCH V2] " Greg Kurz
2013-12-11 16:11                 ` Alexander Graf
2013-12-11 17:18                   ` Greg Kurz
2014-01-17 13:52                 ` [Qemu-devel] [PATCH] target-ppc: ppc64 target's virtio can be either endian. (v3) Greg Kurz
2014-01-20 14:36                   ` Alexander Graf
2013-12-09 19:44   ` [Qemu-devel] [Qemu-ppc] [PATCH] target-ppc: ppc64 target's virtio can be either endian Benjamin Herrenschmidt
2013-12-10  1:18     ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).