From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com ([66.111.4.28]:55879 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729587AbeKTBkj (ORCPT ); Mon, 19 Nov 2018 20:40:39 -0500 Date: Mon, 19 Nov 2018 16:16:42 +0100 From: Greg KH To: Marc Zyngier Cc: stable@vger.kernel.org, Mark Rutland , christoffer.dall@arm.com, james.morse@arm.com, robin.murphy@arm.com, will.deacon@arm.com Subject: Re: [PATCH stable-4.9] KVM: arm64: Fix caching of host MDCR_EL2 value Message-ID: <20181119151642.GD5340@kroah.com> References: <20181112082707.26785-1-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181112082707.26785-1-marc.zyngier@arm.com> Sender: stable-owner@vger.kernel.org List-ID: On Mon, Nov 12, 2018 at 08:27:07AM +0000, Marc Zyngier wrote: > From: Mark Rutland > > commit da5a3ce66b8bb51b0ea8a89f42aac153903f90fb upstream. > > At boot time, KVM stashes the host MDCR_EL2 value, but only does this > when the kernel is not running in hyp mode (i.e. is non-VHE). In these > cases, the stashed value of MDCR_EL2.HPMN happens to be zero, which can > lead to CONSTRAINED UNPREDICTABLE behaviour. > > Since we use this value to derive the MDCR_EL2 value when switching > to/from a guest, after a guest have been run, the performance counters > do not behave as expected. This has been observed to result in accesses > via PMXEVTYPER_EL0 and PMXEVCNTR_EL0 not affecting the relevant > counters, resulting in events not being counted. In these cases, only > the fixed-purpose cycle counter appears to work as expected. > > Fix this by always stashing the host MDCR_EL2 value, regardless of VHE. > > Cc: Christopher Dall > Cc: James Morse > Cc: Will Deacon > Cc: stable@vger.kernel.org > Fixes: 1e947bad0b63b351 ("arm64: KVM: Skip HYP setup when already running in HYP") > Tested-by: Robin Murphy > Signed-off-by: Mark Rutland > Signed-off-by: Marc Zyngier > --- > arch/arm/kvm/arm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Now queued up, thanks. greg k-h