From patchwork Wed Jun 11 10:23:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 358595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DD3791400B2 for ; Wed, 11 Jun 2014 20:23:47 +1000 (EST) Received: from localhost ([::1]:44696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wufh2-0007aV-TW for incoming@patchwork.ozlabs.org; Wed, 11 Jun 2014 06:23:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WufgY-0006wR-WC for qemu-devel@nongnu.org; Wed, 11 Jun 2014 06:23:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WufgS-0004Ta-7y for qemu-devel@nongnu.org; Wed, 11 Jun 2014 06:23:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35520 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WufgR-0004TP-Vr; Wed, 11 Jun 2014 06:23:08 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4FE4CAC8D; Wed, 11 Jun 2014 10:23:07 +0000 (UTC) From: Alexander Graf To: qemu-ppc@nongnu.org Date: Wed, 11 Jun 2014 12:23:07 +0200 Message-Id: <1402482187-7518-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.8.1.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] PPC: KVM: Make pv hcall endian agnostic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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; }