From patchwork Mon May 4 01:51:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47940 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 02C212121F for ; Mon, 4 May 2015 01:53:40 +0000 (UTC) Received: by laat2 with SMTP id t2sf42171316laa.2 for ; Sun, 03 May 2015 18:53:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=wHFhjoeLH8Olr0I8pZxZlLjxLPlCCoCSpKGehe9FWRM=; b=fxwk2xNXr1Ut0lKaHZjVqWifquA6Ew1w+RTTcE3gddjbFP+gfrO3oFAcW08FlJVqZi SOzqRyPYSPfvRnlJTbyeTakvAP71wboBfOJP6naDFZSkh3uQ59B7aOUvusLJWkyq7ADO W9SzqqZuzLEKMs059FPVEW5PSWIF+DJDLftSGRHazBjlfV1liazy/ZC6Flml/1fpUo8p 3b8u5j5mxLayUuC9mSAR5vrbuIExGdvGpTCjKZUNoY7Jbysqp9PpO9vWeI4abOMsyTLu xN8B9QSDBfxOxAx9PGN3EsO/HM9RiEhUd3ESGWidUAu15HiMyo6yPNnV472D0L3jUuLE bSfA== X-Gm-Message-State: ALoCoQm91NLV/1dtaOTec7OD+z6liMBcEXc3Fb/lbr5icok3F5MNDEVU58dCQ8W+ERhIFOYZuyFr X-Received: by 10.180.85.129 with SMTP id h1mr6902041wiz.6.1430704418965; Sun, 03 May 2015 18:53:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.200 with SMTP id yk8ls693905lab.95.gmail; Sun, 03 May 2015 18:53:38 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr18035964lbh.56.1430704418798; Sun, 03 May 2015 18:53:38 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id s7si9085155las.80.2015.05.03.18.53.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbzk7 with SMTP id zk7so95750477lbb.0 for ; Sun, 03 May 2015 18:53:38 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr17579976lbb.36.1430704418378; Sun, 03 May 2015 18:53:38 -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.112.67.65 with SMTP id l1csp1412432lbt; Sun, 3 May 2015 18:53:37 -0700 (PDT) X-Received: by 10.70.130.168 with SMTP id of8mr38207741pdb.131.1430704416562; Sun, 03 May 2015 18:53:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.53.35; Sun, 03 May 2015 18:53:36 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbbEDBxf (ORCPT + 2 others); Sun, 3 May 2015 21:53:35 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:35492 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483AbbEDBxe (ORCPT ); Sun, 3 May 2015 21:53:34 -0400 Received: by pabtp1 with SMTP id tp1so147785055pab.2 for ; Sun, 03 May 2015 18:53:34 -0700 (PDT) X-Received: by 10.70.124.233 with SMTP id ml9mr38558723pdb.9.1430704414587; Sun, 03 May 2015 18:53:34 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id j10sm11035200pdk.48.2015.05.03.18.53.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:53:33 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Marc Zyngier Subject: [PATCH for 3.14.y stable 02/47] arm64: KVM: allows discrimination of AArch32 sysreg access Date: Mon, 4 May 2015 09:51:57 +0800 Message-Id: <1430704362-6292-3-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@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.217.171 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marc Zyngier commit 2072d29c46b73e39b3c6c56c6027af77086f45fd upstream. The current handling of AArch32 trapping is slightly less than perfect, as it is not possible (from a handler point of view) to distinguish it from an AArch64 access, nor to tell a 32bit from a 64bit access either. Fix this by introducing two additional flags: - is_aarch32: true if the access was made in AArch32 mode - is_32bit: true if is_aarch32 == true and a MCR/MRC instruction was used to perform the access (as opposed to MCRR/MRRC). This allows a handler to cover all the possible conditions in which a system register gets trapped. Signed-off-by: Marc Zyngier Acked-by: Christoffer Dall Signed-off-by: Shannon Zhao --- arch/arm64/kvm/sys_regs.c | 6 ++++++ arch/arm64/kvm/sys_regs.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 02e9d09..bf03e0f 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -437,6 +437,8 @@ int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run) u32 hsr = kvm_vcpu_get_hsr(vcpu); int Rt2 = (hsr >> 10) & 0xf; + params.is_aarch32 = true; + params.is_32bit = false; params.CRm = (hsr >> 1) & 0xf; params.Rt = (hsr >> 5) & 0xf; params.is_write = ((hsr & 1) == 0); @@ -480,6 +482,8 @@ int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run) struct sys_reg_params params; u32 hsr = kvm_vcpu_get_hsr(vcpu); + params.is_aarch32 = true; + params.is_32bit = true; params.CRm = (hsr >> 1) & 0xf; params.Rt = (hsr >> 5) & 0xf; params.is_write = ((hsr & 1) == 0); @@ -549,6 +553,8 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu, struct kvm_run *run) struct sys_reg_params params; unsigned long esr = kvm_vcpu_get_hsr(vcpu); + params.is_aarch32 = false; + params.is_32bit = false; params.Op0 = (esr >> 20) & 3; params.Op1 = (esr >> 14) & 0x7; params.CRn = (esr >> 10) & 0xf; diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h index d50d372..d411e25 100644 --- a/arch/arm64/kvm/sys_regs.h +++ b/arch/arm64/kvm/sys_regs.h @@ -30,6 +30,8 @@ struct sys_reg_params { u8 Op2; u8 Rt; bool is_write; + bool is_aarch32; + bool is_32bit; /* Only valid if is_aarch32 is true */ }; struct sys_reg_desc {