From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06705C6FD1D for ; Tue, 4 Apr 2023 10:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+WwkxE1YiCGzA1+wSUfTN7xqbBCpVgrSF0hTZjuBWkg=; b=LXPueJZrqPnYHm DP22KhY6kfoxQMg7L0B1CR0QjJ9zqZSFFnpYlmxLiI6GeAqrmIJajEjSfIQI5P5rZuo7OIav1Kdi2 o3Utjmt+tpyChQGbLQ7tOhzwa0my8fgavWo5c2lX+EMHitKvq5H/y/lIOdPKjp0VW+lfSFyIX8uM1 etZnDITfhGVLSX/vlnrRHxxRC/hiaHUwRQpkjonT8AzaBiU2lipRgN0NPmO76wjw5JxsvubxnB+1z MNRkss3GSaTODKJtfJskZeBECY9XIFvXxnwzJ5MgiSyrQbrH+O2D+b+mxa3mxYTxvigb2uNcDg26A svKSpwsPPI4zb6p+ZyOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjdXU-000owN-2G; Tue, 04 Apr 2023 10:05:20 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjdXQ-000ovX-07 for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 10:05:19 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62DE461E31; Tue, 4 Apr 2023 10:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3321C4339B; Tue, 4 Apr 2023 10:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680602714; bh=vk4tGNl8zx+FJkjVlaxsYjBg7s0TpSl6JR8Z0Yd06kc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=d3jtdP4xbuVnCqgYuEEzVeoezrc/0yMmeXe7vRzRdXaX3fWdsWErCoVMm3eZFM3w+ VfZ7z35ei08ZqJFcZwn21W+D5w5Q7FBhZQ2Zha2xYA0C25mMXGCP1hZdQiY9mHSS1l b6iNy2iNJNy4+RYn2s4vdIHzEKWWi9+GHf5HoLxmFU/X6aOlC5zjbeuzSLlUQuowxr plP38shNHVzjkRC8KbSYKzcE7MQCx7daqNGlwiMb0XRsOBprCLiUGoI7jWiuR6aSfG 0M4lFucyVxhy+HvpM+oUHARLQxtI2LdAoZ49JM1XaLu3qv8u72v5uPPva/lTZfZARm 0WJ4L66QKF92Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pjdXM-005ZtD-7f; Tue, 04 Apr 2023 11:05:12 +0100 Date: Tue, 04 Apr 2023 11:05:11 +0100 Message-ID: <86ttxwufmw.wl-maz@kernel.org> From: Marc Zyngier To: Mark Rutland Cc: Reiji Watanabe , Oliver Upton , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Zenghui Yu , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , Will Deacon Subject: Re: [PATCH v1 0/2] KVM: arm64: PMU: Correct the handling of PMUSERENR_EL0 In-Reply-To: <20230329002136.2463442-1-reijiw@google.com> References: <20230329002136.2463442-1-reijiw@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mark.rutland@arm.com, reijiw@google.com, oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, alexandru.elisei@arm.com, yuzenghui@huawei.com, suzuki.poulose@arm.com, pbonzini@redhat.com, ricarkol@google.com, jingzhangos@google.com, rananta@google.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_030516_175335_0A1A9C33 X-CRM114-Status: GOOD ( 25.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org + Mark, as we just discussed this. On Wed, 29 Mar 2023 01:21:34 +0100, Reiji Watanabe wrote: > > This series will fix bugs in KVM's handling of PMUSERENR_EL0. > > With PMU access support from EL0 [1], the perf subsystem would > set CR and ER bits of PMUSERENR_EL0 as needed to allow EL0 to have > a direct access to PMU counters. However, KVM appears to assume > that the register value is always zero for the host EL0, and has > the following two problems in handling the register. > > [A] The host EL0 might lose the direct access to PMU counters, as > KVM always clears PMUSERENR_EL0 before returning to userspace. > > [B] With VHE, the guest EL0 access to PMU counters might be trapped > to EL1 instead of to EL2 (even when PMUSERENR_EL0 for the guest > indicates that the guest EL0 has an access to the counters). > This is because, with VHE, KVM sets ER, CR, SW and EN bits of > PMUSERENR_EL0 to 1 on vcpu_load() to ensure to trap PMU access > from the guset EL0 to EL2, but those bits might be cleared by > the perf subsystem after vcpu_load() (when PMU counters are > programmed for the vPMU emulation). > > Patch-1 will fix [A], and Patch-2 will fix [B] respectively. > The series is based on v6.3-rc4. > > [1] https://github.com/torvalds/linux/commit/83a7a4d643d33a8b74a42229346b7ed7139fcef9 > > Reiji Watanabe (2): > KVM: arm64: PMU: Restore the host's PMUSERENR_EL0 > KVM: arm64: PMU: Ensure to trap PMU access from EL0 to EL2 > > arch/arm64/include/asm/kvm_host.h | 3 +++ > arch/arm64/kvm/hyp/include/hyp/switch.h | 28 +++++++++++++------------ > 2 files changed, 18 insertions(+), 13 deletions(-) > > > base-commit: 197b6b60ae7bc51dd0814953c562833143b292aa > -- > 2.40.0.348.gf938b09366-goog > > -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel