From patchwork Tue Nov 5 17:22:08 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: 3142891 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 262749F466 for ; Tue, 5 Nov 2013 17:22:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E11A020266 for ; Tue, 5 Nov 2013 17:22:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C226120395 for ; Tue, 5 Nov 2013 17:22:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755007Ab3KERWt (ORCPT ); Tue, 5 Nov 2013 12:22:49 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:56554 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754886Ab3KERWq (ORCPT ); Tue, 5 Nov 2013 12:22:46 -0500 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Nov 2013 17:22:45 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Nov 2013 17:22:42 -0000 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 4683E17D8063; Tue, 5 Nov 2013 17:22:18 +0000 (GMT) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rA5HMS1s64422034; Tue, 5 Nov 2013 17:22:28 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rA5HMdch002237; Tue, 5 Nov 2013 10:22:40 -0700 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id rA5HMdGs002231; Tue, 5 Nov 2013 10:22:39 -0700 Received: from hermes.lab.toulouse-stg.fr.ibm.com (hermes.lab.toulouse-stg.fr.ibm.com [9.101.4.42]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 59660210FFE; Tue, 5 Nov 2013 18:22:39 +0100 (CET) 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 v5 6/6] KVM: PPC: Book3S: modify byte loading when guest uses Split Little Endian Date: Tue, 5 Nov 2013 18:22:08 +0100 Message-Id: <1383672128-26795-7-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1383672128-26795-1-git-send-email-clg@fr.ibm.com> References: <1383672128-26795-1-git-send-email-clg@fr.ibm.com> In-Reply-To: <84018BDE-858B-4F59-8AA0-9135CCFF4720@suse.de> References: <84018BDE-858B-4F59-8AA0-9135CCFF4720@suse.de> MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13110517-0542-0000-0000-000006F7616B Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instruction and data storage accesses are done in opposite order when the Split Little Endian mode is used. This patch modifies the kvmppc_ld32() routine to reverse the byteswap when the guest is in SLE mode. Signed-off-by: Cédric Le Goater --- arch/powerpc/include/asm/kvm_book3s.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 6974aa0..eac8808 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -288,10 +288,22 @@ static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, ulong *eaddr, u32 *ptr, bool data) { int ret; + bool byteswap; ret = kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data); - if (kvmppc_need_byteswap(vcpu)) + byteswap = kvmppc_need_byteswap(vcpu); + + /* When in Split Little Endian (SLE) mode, instruction and + * data storage accesses are done in opposite order. If the + * guest is using this mode, we need to reverse the byteswap + * for data accesses only. Instructions accesses are left + * unchanged. + */ + if (data && (vcpu->arch.shared->msr & MSR_SLE)) + byteswap = !byteswap; + + if (byteswap) *ptr = swab32(*ptr); return ret;