Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3430331imu; Sun, 11 Nov 2018 14:56:37 -0800 (PST) X-Google-Smtp-Source: AJdET5ebHiVCfu+5yDnJwSO3ISN1MsXtEl1MPaAsLpWUywL09hdrEQIHdH/z4wH5W9VKh9ncxM89 X-Received: by 2002:a62:6e47:: with SMTP id j68-v6mr17769481pfc.197.1541976997691; Sun, 11 Nov 2018 14:56:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976997; cv=none; d=google.com; s=arc-20160816; b=hrL15QCDnOja3eZwM/EfcUcSXBtldiGxzb4geM4OHj3BMmL9xh6B2i+Ip0B+CznuaB YU8YyiBwYFnTfqWSOpaBoU1/7RG8Sp9s/oqyPDR3ZPVh4YvBVZSvy6TYC8ba0G7nhufp Uxrj78wD+bYLw39IVqe1RwKSyHrhhUqsibxBXrvkaLN6yKhaVkXraBA3aaEJSkyJx0IB kTb3eVjLIwPv+HQ6ySpiEPKjtJx44hSm5rZJbbObbMsZE4hUQemmNsGpN3KncIRgyYU0 dcfGfQ3AEen/oye99EKmopuh5xpzT3yACs84zSE8rw44Ohmb/JYlhIC/V+W7JbrK1I4N gUgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yXy7LixhrjobchwzY5SQAJ1qlkYdmGh8RYo3NUHdsWs=; b=OkV/sguJLCTo4J9/lCWCZ7IUFKnKCvNwFQ3dJdvpEU0XAE18YG8PT2LWI80NwUqipr U+VU3hUnYcwlPW/qfR/K49zqwngEkvB+nipR+hnU1H2ZAW/nI+vn/YgVlKlxKSupQsSZ FDZazHdT/NOkBzXV8I4zJ+2j1pTEPc0csyX2MyMZZtVG9Jp2qukCSNyt5mBagpvyUEUE vLUuvIRL5uNdQue95v5tmRcWqlyv1IejOcXPvCaJ3iYYQGQYU6SkJtMEsVE665v39TYn XcWttS80BcOwFLJpUEpfX6OUdcO7WIWcn/H1p3W3Ny2W6LGChMH8XdMsy0350Y2tirVt hpig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i4PYkpSd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17si8390263pgl.6.2018.11.11.14.56.22; Sun, 11 Nov 2018 14:56:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i4PYkpSd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403982AbeKLIqH (ORCPT + 99 others); Mon, 12 Nov 2018 03:46:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:54620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403874AbeKLIWx (ORCPT ); Mon, 12 Nov 2018 03:22:53 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB1052243E; Sun, 11 Nov 2018 22:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975576; bh=7Yr2wb0NIdTkYOitdsKrY4fA6di1vmuy9wtp3CXTeCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4PYkpSdAMtsPVLfz86bcloTS+7gsQDkoh1PtbimHthPa0j68jc+7SsSuPlkMyMZn 4N3p0uZBIbNqq1bEWrb0WqqMayA/JgbataqE1MBOMIkyFV59h4/ZVeOCgKQgCvXDY0 orXGZU4bHB1UKJOrbSUgO8+/8omVrExk/vJEvlZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christopher Dall , James Morse , Will Deacon , Robin Murphy , Mark Rutland , Marc Zyngier Subject: [PATCH 4.14 157/222] KVM: arm64: Fix caching of host MDCR_EL2 value Date: Sun, 11 Nov 2018 14:24:14 -0800 Message-Id: <20181111221701.367448114@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -1148,8 +1148,6 @@ static void cpu_init_hyp_mode(void *dumm __cpu_init_hyp_mode(pgd_ptr, hyp_stack_ptr, vector_ptr); __cpu_init_stage2(); - - kvm_arm_init_debug(); } static void cpu_hyp_reset(void) @@ -1173,6 +1171,8 @@ static void cpu_hyp_reinit(void) cpu_init_hyp_mode(NULL); } + kvm_arm_init_debug(); + if (vgic_present) kvm_vgic_init_cpu_hardware(); }