From patchwork Mon Oct 7 14:27:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 281118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2B9E32C00AD for ; Tue, 8 Oct 2013 01:29:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755632Ab3JGO3Y (ORCPT ); Mon, 7 Oct 2013 10:29:24 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:54496 "EHLO e06smtp10.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755582Ab3JGO3X (ORCPT ); Mon, 7 Oct 2013 10:29:23 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Oct 2013 15:29:22 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 Oct 2013 15:29:18 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id BA0AA17D8059; Mon, 7 Oct 2013 15:29:38 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r97ERoTk59244742; Mon, 7 Oct 2013 14:27:50 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r97ES2ik003689; Mon, 7 Oct 2013 08:28:02 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r97ES2Hs003680; Mon, 7 Oct 2013 08:28:02 -0600 Received: from hermes.kaod.org (sig-9-145-55-101.uk.ibm.com [9.145.55.101]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 7D3A5210FF4; Mon, 7 Oct 2013 16:28:01 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: agraf@suse.de, paulus@samba.org Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 2/3] KVM: PPC: Book3S: add helper routines to detect endian order Date: Mon, 7 Oct 2013 16:27:46 +0200 Message-Id: <1381156067-32095-3-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1381156067-32095-1-git-send-email-clg@fr.ibm.com> References: <1381156067-32095-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13100714-4966-0000-0000-0000071C62E0 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org They will be used to decide whether to byte-swap or not. When Little Endian host kernels come, these routines will need to be changed accordingly. Signed-off-by: Cédric Le Goater --- arch/powerpc/include/asm/kvm_book3s.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index dfe8f11..00c2061 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -270,6 +270,16 @@ static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu) return vcpu->arch.pc; } +static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu) +{ + return vcpu->arch.shared->msr & MSR_LE; +} + +static inline bool kvmppc_is_bigendian(struct kvm_vcpu *vcpu) +{ + return !kvmppc_need_byteswap(vcpu); +} + static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, ulong *eaddr, u32 *ptr, bool data) {