Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966924AbcKXP3L (ORCPT ); Thu, 24 Nov 2016 10:29:11 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58012 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965988AbcKXP3I (ORCPT ); Thu, 24 Nov 2016 10:29:08 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei Huang , Marc Zyngier Subject: [PATCH 4.8 04/67] arm64: KVM: pmu: Fix AArch32 cycle counter access Date: Thu, 24 Nov 2016 16:26:58 +0100 Message-Id: <20161124145457.410167114@linuxfoundation.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161124145457.061710350@linuxfoundation.org> References: <20161124145457.061710350@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1248 Lines: 47 4.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wei Huang commit 9e3f7a29694049edd728e2400ab57ad7553e5aa9 upstream. We're missing the handling code for the cycle counter accessed from a 32bit guest, leading to unexpected results. Signed-off-by: Wei Huang Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/sys_regs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -602,8 +602,14 @@ static bool access_pmu_evcntr(struct kvm idx = ARMV8_PMU_CYCLE_IDX; } else { - BUG(); + return false; } + } else if (r->CRn == 0 && r->CRm == 9) { + /* PMCCNTR */ + if (pmu_access_event_counter_el0_disabled(vcpu)) + return false; + + idx = ARMV8_PMU_CYCLE_IDX; } else if (r->CRn == 14 && (r->CRm & 12) == 8) { /* PMEVCNTRn_EL0 */ if (pmu_access_event_counter_el0_disabled(vcpu)) @@ -611,7 +617,7 @@ static bool access_pmu_evcntr(struct kvm idx = ((r->CRm & 3) << 3) | (r->Op2 & 7); } else { - BUG(); + return false; } if (!pmu_counter_idx_valid(vcpu, idx))