From patchwork Tue May 13 16:14:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 30108 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1D91E20446 for ; Tue, 13 May 2014 16:19:31 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf1780495yha.7 for ; Tue, 13 May 2014 09:19:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=E0Cgz3fIcMQHGB1fqJqI9W7Ee7m4r+LnjbqqEHprIBo=; b=iylv8b5j52/oFVjy+hxf5nCBeR3nHdCZSN0igAK6fkaE1vGYm9OQlZiXttayeMwzYX LgZBFxGxJztQPY+W/SJVX5Ibfnuj8wdEaUTbJ+0+n1RULpfCzpz0FkTb2hZwfAoXRGn9 Qic04XP7a2sXJ3fdY1DC+T5sUuC7UMZWJEADdwqUYGWe7KLBNL6/AUKdQwzlOGoKEV63 8bcGbdGgRbHO+JLftARz25hFXfgO6Zw1OXvMy2eN1kdPG/76C2iQpMjOrVRNkZhF+aNM H5SQaokxBb0LKYqRTY6jyzh1VcsZunvGfftrSq+1GC4UpyzNOa/4ma4/61hUzdHjxzcX RvnQ== X-Gm-Message-State: ALoCoQmI3TH1+dWV8O6tCgNr9gtCPI1randa6f91HpbGXMjNSURktkoXUppK3ZEjPXvZ8tzgz+Bp X-Received: by 10.58.198.130 with SMTP id jc2mr950484vec.9.1399997970870; Tue, 13 May 2014 09:19:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.112 with SMTP id n103ls1972562qga.86.gmail; Tue, 13 May 2014 09:19:30 -0700 (PDT) X-Received: by 10.220.95.2 with SMTP id b2mr1025696vcn.61.1399997970716; Tue, 13 May 2014 09:19:30 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id jb7si2724161vec.197.2014.05.13.09.19.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 09:19:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ij19so782733vcb.0 for ; Tue, 13 May 2014 09:19:30 -0700 (PDT) X-Received: by 10.220.89.4 with SMTP id c4mr1027215vcm.53.1399997970645; Tue, 13 May 2014 09:19:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp164286vcb; Tue, 13 May 2014 09:19:30 -0700 (PDT) X-Received: by 10.180.78.225 with SMTP id e1mr21710993wix.17.1399997969804; Tue, 13 May 2014 09:19:29 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gy8si4023674wib.80.2014.05.13.09.19.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 09:19:29 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkFOx-0004ZW-Fc; Tue, 13 May 2014 16:17:59 +0000 Received: from mail-pa0-f45.google.com ([209.85.220.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkFMd-0002cR-HI for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2014 16:15:36 +0000 Received: by mail-pa0-f45.google.com with SMTP id ey11so459359pad.18 for ; Tue, 13 May 2014 09:15:14 -0700 (PDT) X-Received: by 10.68.166.36 with SMTP id zd4mr6376903pbb.54.1399997714573; Tue, 13 May 2014 09:15:14 -0700 (PDT) Received: from kamensky-w530.hsd1.ca.comcast.net (c-24-6-79-41.hsd1.ca.comcast.net. [24.6.79.41]) by mx.google.com with ESMTPSA id dd5sm28958360pbc.85.2014.05.13.09.15.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 09:15:13 -0700 (PDT) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, agraf@suse.de Subject: [PATCH v3 14/14] ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest Date: Tue, 13 May 2014 09:14:06 -0700 Message-Id: <1399997646-4716-15-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1399997646-4716-1-git-send-email-victor.kamensky@linaro.org> References: <1399997646-4716-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140513_091535_636924_75332377 X-CRM114-Status: GOOD ( 11.87 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.45 listed in list.dnswl.org] Cc: taras.kondratiuk@linaro.org, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Victor Kamensky X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Fix isssue with 32bit guests running on top of BE KVM host. Guest state is retored with double word read operations. Within the high and low word data is already byteswap. This code effectively swaps two words within 64bit value. Signed-off-by: Victor Kamensky --- arch/arm64/kvm/sys_regs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 060c3a9..4438b47 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -51,6 +51,16 @@ static u32 cache_levels; /* CSSELR values; used to index KVM_REG_ARM_DEMUX_ID_CCSIDR */ #define CSSELR_MAX 12 +/* Word access indexes for 64bit vm accessor */ +#ifdef CONFIG_CPU_BIG_ENDIAN +#define CP15_REG_MSW_INDEX 0 +#define CP15_REG_LSW_INDEX 1 +#else +#define CP15_REG_MSW_INDEX 1 +#define CP15_REG_LSW_INDEX 0 +#endif + + /* Which cache CCSIDR represents depends on CSSELR value. */ static u32 get_ccsidr(u32 csselr) { @@ -137,9 +147,9 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, if (!p->is_aarch32) { vcpu_sys_reg(vcpu, r->reg) = val; } else { - vcpu_cp15(vcpu, r->reg) = val & 0xffffffffUL; + vcpu_cp15(vcpu, r->reg + CP15_REG_LSW_INDEX) = val & 0xffffffffUL; if (!p->is_32bit) - vcpu_cp15(vcpu, r->reg + 1) = val >> 32; + vcpu_cp15(vcpu, r->reg + CP15_REG_MSW_INDEX) = val >> 32; } return true; }