From patchwork Fri Jan 17 13:52:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 312069 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 EAAEA2C007A for ; Sat, 18 Jan 2014 00:52:55 +1100 (EST) Received: from localhost ([::1]:38296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W49qu-0007ry-5w for incoming@patchwork.ozlabs.org; Fri, 17 Jan 2014 08:52:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W49qW-0007YO-Rg for qemu-devel@nongnu.org; Fri, 17 Jan 2014 08:52:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W49qP-0006mz-6f for qemu-devel@nongnu.org; Fri, 17 Jan 2014 08:52:28 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:54984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W49qO-0006mL-SZ for qemu-devel@nongnu.org; Fri, 17 Jan 2014 08:52:21 -0500 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2014 13:52:18 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 17 Jan 2014 13:52:15 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id DA61C1B08066; Fri, 17 Jan 2014 13:51:37 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s0HDq2H647841426; Fri, 17 Jan 2014 13:52:02 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s0HDqEwk031107; Fri, 17 Jan 2014 06:52:14 -0700 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s0HDqDE2031099; Fri, 17 Jan 2014 06:52:13 -0700 Received: from bahia.local (icon-9-167-199-102.megacenter.de.ibm.com [9.167.199.102]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 08FA1210FFD; Fri, 17 Jan 2014 14:52:12 +0100 (CET) To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org From: Greg Kurz Date: Fri, 17 Jan 2014 14:52:12 +0100 Message-ID: <20140117135211.27377.91848.stgit@bahia.local> In-Reply-To: <20131211155716.8373.27979.stgit@bahia.local> References: <20131211155716.8373.27979.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: 14011713-2966-0000-0000-000009F7E5FD X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.109 Cc: rusty@rustcorp.com.au, agraf@suse.de Subject: [Qemu-devel] [PATCH] target-ppc: ppc64 target's virtio can be either endian. (v3) 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). This patch implements virtio_get_byteswap() over LPCR. 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. Changes in v3: - dropped the explicit calls to kvm_[get|put]_one_reg as LPCR is now properly handled by the generic SPR code. Changes in v2: - call cpu_synchronize_state() instead of kvm_arch_get_registers(). Suggested-by: Benjamin Herrenschmidt Signed-off-by: Rusty Russell Signed-off-by: Greg Kurz Reviewed-by: Alexander Graf --- target-ppc/misc_helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target-ppc/misc_helper.c b/target-ppc/misc_helper.c index 616aab6..e8fc8a3 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,13 @@ 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; + + cpu_synchronize_state(first_cpu); + + return env->spr[SPR_LPCR] & LPCR_ILE; +}