From patchwork Fri Apr 24 05:27:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47508 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D467520553 for ; Fri, 24 Apr 2015 05:31:44 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf9451512lab.1 for ; Thu, 23 Apr 2015 22:31:43 -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=rDQHCF4ksp0SGUDNKPIEj+ZU+03wyGkFgAghUI2bgk8=; b=iBZPqq2tnCXr5/DnlZu9JkBJ1xdcb+DVCXF/t9C36ByFzQCpORDIVZfu1ZWUdyeGmD PsrLbQgvzkvPC2A6mDDbs5XuTerxzwqnao2LZ6OIejB9p/SiKIaN0SLzdeRP81L9c2Z4 KADtnZgIEk0Z5KCd5RVneMOHfwTLBQWFIE4BNO4fAZVweidthWq+APfHDdZWFT9C7hCO LSYkb1MFtBfFkPt/6bu+7tBFBT6FYOr5tx7nW9m2Wq3724OT5vEPb8TDjUs1uehat7Y9 ZQrsQ2J+DVHzsuwdgVLvoMRIBqdKGC365IVLpqmsycpmUC79z/LoNXlJy73zhUrLnp79 knFg== X-Gm-Message-State: ALoCoQlI7Hoven5F0MzS5GQNihRGP7V5PWZ97cvhtpQe2TQPxYJy0SDouoDVTzuMk/ftu5yukJG6 X-Received: by 10.112.122.39 with SMTP id lp7mr3187482lbb.5.1429853503813; Thu, 23 Apr 2015 22:31:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.65 with SMTP id lu1ls405394lac.104.gmail; Thu, 23 Apr 2015 22:31:43 -0700 (PDT) X-Received: by 10.152.23.3 with SMTP id i3mr5399662laf.23.1429853503461; Thu, 23 Apr 2015 22:31:43 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id w8si7464468law.99.2015.04.23.22.31.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbzk7 with SMTP id zk7so28605319lbb.0 for ; Thu, 23 Apr 2015 22:31:43 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr5344972lbc.41.1429853503299; Thu, 23 Apr 2015 22:31:43 -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 l1csp977732lbt; Thu, 23 Apr 2015 22:31:42 -0700 (PDT) X-Received: by 10.68.57.201 with SMTP id k9mr11649810pbq.135.1429853501503; Thu, 23 Apr 2015 22:31:41 -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.40; Thu, 23 Apr 2015 22:31:41 -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 S1754530AbbDXFbj (ORCPT + 2 others); Fri, 24 Apr 2015 01:31:39 -0400 Received: from mail-oi0-f49.google.com ([209.85.218.49]:34248 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754523AbbDXFbj (ORCPT ); Fri, 24 Apr 2015 01:31:39 -0400 Received: by oiko83 with SMTP id o83so32475102oik.1 for ; Thu, 23 Apr 2015 22:31:38 -0700 (PDT) X-Received: by 10.60.50.69 with SMTP id a5mr5615528oeo.23.1429853498904; Thu, 23 Apr 2015 22:31:38 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id e74sm6085956oib.16.2015.04.23.22.31.36 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:31:38 -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 23/63] ARM: KVM: fix handling of trapped 64bit coprocessor accesses Date: Fri, 24 Apr 2015 13:27:21 +0800 Message-Id: <1429853281-6136-24-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.217.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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marc Zyngier commit 46c214dd595381c880794413facadfa07fba5c95 upstream. Commit 240e99cbd00a (ARM: KVM: Fix 64-bit coprocessor handling) changed the way we match the 64bit coprocessor access from user space, but didn't update the trap handler for the same set of registers. The effect is that a trapped 64bit access is never matched, leading to a fault being injected into the guest. This went unnoticed as we didn't really trap any 64bit register so far. Placing the CRm field of the access into the CRn field of the matching structure fixes the problem. Also update the debug feature to emit the expected string in case of failing match. Signed-off-by: Marc Zyngier Reviewed-by: Christoffer Dall Acked-by: Catalin Marinas Signed-off-by: Shannon Zhao --- arch/arm/kvm/coproc.c | 4 ++-- arch/arm/kvm/coproc.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index db9cf69..f79b8e1 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -323,7 +323,7 @@ int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run) { struct coproc_params params; - params.CRm = (kvm_vcpu_get_hsr(vcpu) >> 1) & 0xf; + params.CRn = (kvm_vcpu_get_hsr(vcpu) >> 1) & 0xf; params.Rt1 = (kvm_vcpu_get_hsr(vcpu) >> 5) & 0xf; params.is_write = ((kvm_vcpu_get_hsr(vcpu) & 1) == 0); params.is_64bit = true; @@ -331,7 +331,7 @@ int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run) params.Op1 = (kvm_vcpu_get_hsr(vcpu) >> 16) & 0xf; params.Op2 = 0; params.Rt2 = (kvm_vcpu_get_hsr(vcpu) >> 10) & 0xf; - params.CRn = 0; + params.CRm = 0; return emulate_cp15(vcpu, ¶ms); } diff --git a/arch/arm/kvm/coproc.h b/arch/arm/kvm/coproc.h index 0461d5c..c5ad7ff 100644 --- a/arch/arm/kvm/coproc.h +++ b/arch/arm/kvm/coproc.h @@ -58,8 +58,8 @@ static inline void print_cp_instr(const struct coproc_params *p) { /* Look, we even formatted it for you to paste into the table! */ if (p->is_64bit) { - kvm_pr_unimpl(" { CRm(%2lu), Op1(%2lu), is64, func_%s },\n", - p->CRm, p->Op1, p->is_write ? "write" : "read"); + kvm_pr_unimpl(" { CRm64(%2lu), Op1(%2lu), is64, func_%s },\n", + p->CRn, p->Op1, p->is_write ? "write" : "read"); } else { kvm_pr_unimpl(" { CRn(%2lu), CRm(%2lu), Op1(%2lu), Op2(%2lu), is32," " func_%s },\n",