From patchwork Thu Jun 12 16:30:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 31849 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 52AFE20AE6 for ; Thu, 12 Jun 2014 16:36:33 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf4336190qac.4 for ; Thu, 12 Jun 2014 09:36:33 -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=fVzyydFNSqZHxxIBRr573T6XgUBJpqU2aGp0A21e2kE=; b=D1wrvAmRs1F0wO15q0VikOrh5EoAu75+jrpoY+XG1gpGOcW07UsdgjtB38HM9dmFnw OuhbPMV93Fp5iRkfoJR4q5DrK7/F3ILY2DKLzkczNZctrTf3RPydjxh+swfFOwRYXovG 8n6mFMlIBVfqgRBDbYZh0WreQm8yQFHuiXyemzD5fibjU5sT/O9GBbX99G/AGcLFrLsn GDCOcsG+yAd12v+Kea88sR67JO74mtk82cUnx8hBVnO3x03Oyqgq1iROb5gWmHccX9BV 2435XZsUcS/72ZlgePq9Eu+mdRgvTw3ignGk7eeoBiKaZ1NxO6Sqs6F9Q1ImhS+4+7oK 22jg== X-Gm-Message-State: ALoCoQmMfNI3BIfbO002g0/Cq4mIk/u3sk7ij6me0gD9uQeCOwJXqSRVicvf7LfG7ZthyzTxDGPP X-Received: by 10.236.183.164 with SMTP id q24mr5200016yhm.53.1402590993191; Thu, 12 Jun 2014 09:36:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.135 with SMTP id e7ls3173361qga.70.gmail; Thu, 12 Jun 2014 09:36:33 -0700 (PDT) X-Received: by 10.58.195.130 with SMTP id ie2mr46431829vec.3.1402590992997; Thu, 12 Jun 2014 09:36:32 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id 5si473511vdy.104.2014.06.12.09.36.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Jun 2014 09:36:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id il7so1097814vcb.27 for ; Thu, 12 Jun 2014 09:36:32 -0700 (PDT) X-Received: by 10.58.216.163 with SMTP id or3mr14556vec.80.1402590992654; Thu, 12 Jun 2014 09:36:32 -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.221.54.6 with SMTP id vs6csp417198vcb; Thu, 12 Jun 2014 09:36:32 -0700 (PDT) X-Received: by 10.140.84.83 with SMTP id k77mr58679110qgd.70.1402590992105; Thu, 12 Jun 2014 09:36:32 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 94si34790384qgl.41.2014.06.12.09.36.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:36:32 -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 1Wv7xd-00024r-6x; Thu, 12 Jun 2014 16:34:45 +0000 Received: from mail-pa0-f53.google.com ([209.85.220.53]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv7uE-0007tk-FN for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 16:31:18 +0000 Received: by mail-pa0-f53.google.com with SMTP id kx10so1174221pab.40 for ; Thu, 12 Jun 2014 09:30:53 -0700 (PDT) X-Received: by 10.68.94.225 with SMTP id df1mr13812833pbb.86.1402590653665; Thu, 12 Jun 2014 09:30:53 -0700 (PDT) Received: from kamensky-w530.cisco.com (128-107-239-235.cisco.com. [128.107.239.235]) by mx.google.com with ESMTPSA id nh8sm81278030pbc.25.2014.06.12.09.30.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:30:53 -0700 (PDT) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, agraf@suse.de Subject: [PATCH v4 14/14] ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest Date: Thu, 12 Jun 2014 09:30:13 -0700 Message-Id: <1402590613-3341-15-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1402590613-3341-1-git-send-email-victor.kamensky@linaro.org> References: <1402590613-3341-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140612_093114_549279_ABBA5761 X-CRM114-Status: GOOD ( 11.94 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.53 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.53 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 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.18-1 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.182 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 issue with 32bit guests running on top of BE KVM host. Indexes of high and low words of 64bit cp15 register are swapped in case of big endian code, since 64bit cp15 state is restored or saved with double word write or read instruction. Define helper macros to access high low words of 64bit cp15 register. Signed-off-by: Victor Kamensky --- arch/arm64/include/asm/kvm_host.h | 8 ++++++++ arch/arm64/kvm/sys_regs.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 0a1d697..e9d2e11 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -140,6 +140,14 @@ struct kvm_vcpu_arch { #define vcpu_sys_reg(v,r) ((v)->arch.ctxt.sys_regs[(r)]) #define vcpu_cp15(v,r) ((v)->arch.ctxt.cp15[(r)]) +#ifdef CONFIG_CPU_BIG_ENDIAN +#define vcpu_cp15_64_high(v,r) ((v)->arch.ctxt.cp15[((r) + 0)]) +#define vcpu_cp15_64_low(v,r) ((v)->arch.ctxt.cp15[((r) + 1)]) +#else +#define vcpu_cp15_64_high(v,r) ((v)->arch.ctxt.cp15[((r) + 1)]) +#define vcpu_cp15_64_low(v,r) ((v)->arch.ctxt.cp15[((r) + 0)]) +#endif + struct kvm_vm_stat { u32 remote_tlb_flush; }; diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 8e65e31..71aa9b0 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -137,9 +137,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_64_low(vcpu, r->reg) = val & 0xffffffffUL; if (!p->is_32bit) - vcpu_cp15(vcpu, r->reg + 1) = val >> 32; + vcpu_cp15_64_high(vcpu, r->reg) = val >> 32; } return true; }