qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] PPC: KVM: Make pv hcall endian agnostic
@ 2014-06-11 10:23 Alexander Graf
  0 siblings, 0 replies; only message in thread
From: Alexander Graf @ 2014-06-11 10:23 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel

There were a few revisions of the Linux kernel that incorrectly swapped
the hcall instructions when they saw ePAPR compliant hypercalls.

We already have fixups for those in place when running with PR KVM, but
HV KVM and systems that don't implement hypercalls at all are still broken
because they fall back to the QEMU implementation of fallback hypercalls.

So let's make the fallback hypercall instruction path endian agnostic. This
only really works well for 64bit guests, but I don't think there are any 32bit
systems left that don't implement real pv hcall support, so we'll never get
into this code path.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/kvm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index dfa5a26..561f8cc 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1525,18 +1525,18 @@ int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)
     }
 
     /*
-     * Fallback to always fail hypercalls:
+     * Fallback to always fail hypercalls regardless of endianness:
      *
+     *     tdi 0,r0,72 (becomes b .+8 in wrong endian, nop in good endian)
      *     li r3, -1
-     *     nop
-     *     nop
-     *     nop
+     *     b .+8       (becomes nop in wrong endian)
+     *     bswap32(li r3, -1)
      */
 
-    hc[0] = 0x3860ffff;
-    hc[1] = 0x60000000;
-    hc[2] = 0x60000000;
-    hc[3] = 0x60000000;
+    hc[0] = cpu_to_be32(0x08000048);
+    hc[1] = cpu_to_be32(0x3860ffff);
+    hc[2] = cpu_to_be32(0x48000008);
+    hc[3] = cpu_to_be32(bswap32(0x3860ffff));
 
     return 0;
 }
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-11 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-11 10:23 [Qemu-devel] [PATCH] PPC: KVM: Make pv hcall endian agnostic 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).