From patchwork Fri Apr 24 05:27:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47503 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 48CC820553 for ; Fri, 24 Apr 2015 05:31:11 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf8846654lbc.1 for ; Thu, 23 Apr 2015 22:31:10 -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=IZF/anwxALUTQY9g/93jST68xjksCsil6mRlaK+jj/l4lkmFhbe4KQJ1v1p5ZQJB9K LBfgCjeC8+6N7lo9TTAWRGaKbgr5RoScxNGxN9NZCXyubgAoMPEtCf6Wstc1dXoC96T5 a8NdIUHhHxrFrLgDGRDqPI5IJZbzLyAVW+UnA78odFXeUUQIHvr7YwH+o/dZPdc0FWJC Jpr4tk7q7yzKtLDpvcydAS9X7thDmMSuc1PLICor/C3bWEXJwLLhBdK7Rkx78dplV6w7 nEXawzs1L1mqAgnFak5opmnoIYEZYYWh4fZrecNwYjzLRvaEdLZfp6Xy18D1A8+BR+GC WO2Q== X-Gm-Message-State: ALoCoQnJOurA6AEt4KheZ9FHoDbwXf+9Jb96fpP5WeRcuwXCA9u0jqKxg4acrcUiiosSTTtqNfgx X-Received: by 10.112.189.131 with SMTP id gi3mr3207139lbc.6.1429853470256; Thu, 23 Apr 2015 22:31:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.36 with SMTP id yf4ls441175lab.43.gmail; Thu, 23 Apr 2015 22:31:10 -0700 (PDT) X-Received: by 10.152.36.40 with SMTP id n8mr5456821laj.121.1429853470111; Thu, 23 Apr 2015 22:31:10 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id h2si7455498lag.151.2015.04.23.22.31.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lagv1 with SMTP id v1so27521815lag.3 for ; Thu, 23 Apr 2015 22:31:10 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr3662181lbc.19.1429853470022; Thu, 23 Apr 2015 22:31:10 -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 l1csp977509lbt; Thu, 23 Apr 2015 22:31:09 -0700 (PDT) X-Received: by 10.68.112.195 with SMTP id is3mr11801544pbb.92.1429853468240; Thu, 23 Apr 2015 22:31:08 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.31.07; Thu, 23 Apr 2015 22:31:08 -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 S1754505AbbDXFbG (ORCPT + 2 others); Fri, 24 Apr 2015 01:31:06 -0400 Received: from mail-oi0-f47.google.com ([209.85.218.47]:33962 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754520AbbDXFbF (ORCPT ); Fri, 24 Apr 2015 01:31:05 -0400 Received: by oiko83 with SMTP id o83so32468158oik.1 for ; Thu, 23 Apr 2015 22:31:05 -0700 (PDT) X-Received: by 10.60.57.230 with SMTP id l6mr5797230oeq.18.1429853465162; Thu, 23 Apr 2015 22:31:05 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id gh8sm6061966obb.27.2015.04.23.22.31.02 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:31:04 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Marc Zyngier Subject: [PATCH for 3.12.y stable 18/63] arm64: KVM: allows discrimination of AArch32 sysreg access Date: Fri, 24 Apr 2015 13:27:16 +0800 Message-Id: <1429853281-6136-19-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-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.215.41 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 {