From patchwork Mon Aug 4 08:46:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 34807 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 591AE20F2E for ; Mon, 4 Aug 2014 08:58:58 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf25482881yha.3 for ; Mon, 04 Aug 2014 01:58:58 -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=l/po5XiiGFMRmI9zlxnod8x4oBlB77K5wvzJ+1jF4h8=; b=F9LM82+eg15SM8Bqq78iXvN7W4KeZCx8ribE12fpu+15BPXVbHJzvf0E90xDWhoxL8 w62e7+JnpDCoQ9eWbAC5+YOGmQSZ7nteNPxW1fNMnSdoxsshkqXYWIzpHpFv5P5YsqYX 9DnRcRSFM1o9J5g6QJe3JKRkXUHIGDng/8ZP3a4x9AZMeTOR7ibpq61BS/H9cKi/KuZa ozWq3RIDySDC96b34vnfRktvemIxS7gnd4BXz0b7aRf3G/I40hPA3pkxVn8KO5aSjbeu 6EXaSBQDG6CUYTNOSxOhmzvEpNiWc/YqNNg4ndKKb5moOIrD9fFDKQG8e5GPOm1pKLvk Z3Bw== X-Gm-Message-State: ALoCoQkkR0Rdr9WP6GTl3Fn3+4cMgtJMUnOLJkMPbf6rUQ/u4KGTXlcESKsUeyq5thkZhUDr4tDu X-Received: by 10.52.182.66 with SMTP id ec2mr7324647vdc.0.1407142738160; Mon, 04 Aug 2014 01:58:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.35 with SMTP id g32ls2066220qgd.53.gmail; Mon, 04 Aug 2014 01:58:58 -0700 (PDT) X-Received: by 10.52.165.162 with SMTP id yz2mr929169vdb.10.1407142738086; Mon, 04 Aug 2014 01:58:58 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id ak16si11521127vdc.93.2014.08.04.01.58.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 01:58:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so10589690vcb.19 for ; Mon, 04 Aug 2014 01:58:58 -0700 (PDT) X-Received: by 10.221.21.201 with SMTP id qt9mr21788665vcb.39.1407142738010; Mon, 04 Aug 2014 01:58:58 -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.37.5 with SMTP id tc5csp288661vcb; Mon, 4 Aug 2014 01:58:57 -0700 (PDT) X-Received: by 10.70.95.233 with SMTP id dn9mr778250pdb.160.1407142737122; Mon, 04 Aug 2014 01:58:57 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qo1si8453979pdb.353.2014.08.04.01.58.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Aug 2014 01:58:57 -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 1XEE5E-0003l8-KA; Mon, 04 Aug 2014 08:57:32 +0000 Received: from mail-la0-f48.google.com ([209.85.215.48]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEDwl-0002Ik-VF for linux-arm-kernel@lists.infradead.org; Mon, 04 Aug 2014 08:48:48 +0000 Received: by mail-la0-f48.google.com with SMTP id gl10so5154376lab.35 for ; Mon, 04 Aug 2014 01:48:25 -0700 (PDT) X-Received: by 10.152.163.33 with SMTP id yf1mr21957758lab.6.1407142105540; Mon, 04 Aug 2014 01:48:25 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id px1sm26731207lbb.46.2014.08.04.01.48.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Aug 2014 01:48:24 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , Gleb Natapov Subject: [GIT PULL 39/51] ARM64: KVM: fix big endian issue in access_vm_reg for 32bit guest Date: Mon, 4 Aug 2014 10:46:56 +0200 Message-Id: <1407142028-31105-40-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1407142028-31105-1-git-send-email-christoffer.dall@linaro.org> References: <1407142028-31105-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140804_014848_192185_963339CA X-CRM114-Status: GOOD ( 12.92 ) 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.215.48 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.48 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Marc Zyngier , Victor Kamensky , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org 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: christoffer.dall@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.174 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 From: Victor Kamensky 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 macro to access low words of 64bit cp15 register. Signed-off-by: Victor Kamensky Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 6 ++++++ arch/arm64/kvm/sys_regs.c | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 4ae9213..503c706 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -140,6 +140,12 @@ 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_low(v,r) ((v)->arch.ctxt.cp15[((r) + 1)]) +#else +#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 f0cecef..56288f3 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -134,13 +134,11 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, BUG_ON(!p->is_write); val = *vcpu_reg(vcpu, p->Rt); - if (!p->is_aarch32) { + if (!p->is_aarch32 || !p->is_32bit) vcpu_sys_reg(vcpu, r->reg) = val; - } else { - vcpu_cp15(vcpu, r->reg) = val & 0xffffffffUL; - if (!p->is_32bit) - vcpu_cp15(vcpu, r->reg + 1) = val >> 32; - } + else + vcpu_cp15_64_low(vcpu, r->reg) = val & 0xffffffffUL; + return true; }