From patchwork Fri Mar 28 11:22:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 334664 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 33E6B14008D for ; Fri, 28 Mar 2014 22:23:50 +1100 (EST) Received: from localhost ([::1]:60568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTUt2-0006PI-6Z for incoming@patchwork.ozlabs.org; Fri, 28 Mar 2014 07:23:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTUsX-00064U-At for qemu-devel@nongnu.org; Fri, 28 Mar 2014 07:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTUsI-00048O-Cg for qemu-devel@nongnu.org; Fri, 28 Mar 2014 07:23:17 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:46275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTUsI-00047e-4u for qemu-devel@nongnu.org; Fri, 28 Mar 2014 07:23:02 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Mar 2014 11:23:01 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Mar 2014 11:22:58 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 27C89219005E; Fri, 28 Mar 2014 11:22:52 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2SBMkWL63963146; Fri, 28 Mar 2014 11:22:46 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2SBMuiq030200; Fri, 28 Mar 2014 05:22:57 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s2SBMt2i030192; Fri, 28 Mar 2014 05:22:55 -0600 Received: from bahia.local (icon-9-164-183-221.megacenter.de.ibm.com [9.164.183.221]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 9957A49DB5; Fri, 28 Mar 2014 12:22:53 +0100 (CET) To: afaerber@suse.de, agraf@suse.de From: Greg Kurz Date: Fri, 28 Mar 2014 12:22:52 +0100 Message-ID: <20140328111548.23869.16689.stgit@bahia.local> In-Reply-To: <20140328105709.21018.88000.stgit@bahia.local> References: <20140328105709.21018.88000.stgit@bahia.local> User-Agent: StGit/0.16 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14032811-5024-0000-0000-0000094DE7FE X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.107 Cc: kwolf@redhat.com, peter.maydell@linaro.org, thuth@linux.vnet.ibm.com, mst@redhat.com, marc.zyngier@arm.com, rusty@rustcorp.com.au, qemu-devel@nongnu.org, amit.shah@redhat.com, qemu-ppc@nongnu.org, aneesh.kumar@linux.vnet.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH v4] target-ppc: ppc64 target's virtio can be either endian 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 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). Using first_cpu to fetch the registers from KVM may look arbitrary and awkward, but it is okay because KVM sets/unsets the ILE bit on all CPUs. Suggested-by: Benjamin Herrenschmidt Signed-off-by: Rusty Russell [ rename virtio_get_byteswap to virtio_legacy_get_byteswap, support both LE and BE host, Greg Kurz ] Signed-off-by: Greg Kurz Reviewed-by: Alexander Graf --- Alex, Welcome back ! :) Changes since v3: - rename the helper according to v6 of the main LE virtio patchset - prepare to support LE ppc64 host - tentatively fixed the list of changes embeded in SoB lines Cheers. -- Greg target-ppc/misc_helper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target-ppc/misc_helper.c b/target-ppc/misc_helper.c index 2eb2fa6..4dbb274 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 */ @@ -120,3 +122,15 @@ void ppc_store_msr(CPUPPCState *env, target_ulong value) { hreg_store_msr(env, value, 0); } + +bool virtio_legacy_get_byteswap(void) +{ + PowerPCCPU *cp = POWERPC_CPU(first_cpu); + CPUPPCState *env = &cp->env; + bool ile = env->spr[SPR_LPCR] & LPCR_ILE; +#ifdef HOST_WORDS_BIGENDIAN + return ile; +#else + return !ile; +#endif +}