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 5FD2AC7619A for ; Wed, 12 Apr 2023 10:30:54 +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=wvlhHYb2Dbhs22qaZZmmE9HEjhK0rEdzY1PL9h5BW3U=; b=25RVtAgQKng/8L cR2uuZUrOdNf7mh6ixUepsiFmDm7qwhhKYtvXWBm4QFVGMEp9Ys84vASldWiqNEWtQKDBJftHkWga mmSkm3hkUfbT1YiAf4dAic7xNqbNwKw1rc0+/AzNQrAwHCznGJg4yUVxmWDcroybfh9x7WV4KsOzC bKBtlPRPiOCRKHjvl8VGmbjhcTwfXkDWp2TzQ05+MeC1xcq1Gb+S0VAR0AdcH26jq7ci83Zr5My3K gLHUtfpiLd1M0lqOVBgartYNoYyzVZUIWkqODbQtPUPIidSxXcvUGYALfNEGzWjaRlqsEAFWYwI8I /b+riJxw/hjadg3rNzAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmXjh-002fJy-1z; Wed, 12 Apr 2023 10:29:57 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmXje-002fIY-07 for linux-arm-kernel@lists.infradead.org; Wed, 12 Apr 2023 10:29:55 +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 6313D62A7E; Wed, 12 Apr 2023 10:29:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B60CCC433EF; Wed, 12 Apr 2023 10:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681295392; bh=KxETWSFM6PX9F1aCzoKEky8AIF4EgyPmopldmq4pXys=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cvwzylPVkLVdU0xJjS7gk539HjYqPqSLvzjAVOB/7p9kphwPzfGAfkdG6ZjrZEjRI VCD343EhyUnjAijx9Ts73/gfHOFcmzPNqHjylV+CNopkXQSbXrxWFXX8tbTAngYTSt 7s9RFec5H6EDe6ZzMIBUIYXmY2GSh74DrGAgM9MA1PwBmWXhbHHa7Meq7CbOIE1klf HR9Ch8teJLXIBCEl07430oJp1neNgD5HGPT/yqCMQeGgKZu1bvZO4N4KlQBN2G7Zdr mss90l1wjT1aFp9RjvuPvPXUgiWAZLU3h9nukZv+3OfzHU4NFbbemeK2lk0Y2CTYHu ZqjR0iqoP/Dhg== 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 1pmXja-007nKb-BO; Wed, 12 Apr 2023 11:29:50 +0100 Date: Wed, 12 Apr 2023 11:29:50 +0100 Message-ID: <86ttxll7fl.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Reiji Watanabe , Mark Rutland , Oliver Upton , Catalin Marinas , 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 , Shaoqin Huang , Rob Herring Subject: Re: [PATCH v2 0/2] KVM: arm64: PMU: Correct the handling of PMUSERENR_EL0 In-Reply-To: <20230411112458.GA22090@willie-the-truck> References: <20230408034759.2369068-1-reijiw@google.com> <86r0subv8s.wl-maz@kernel.org> <20230411112458.GA22090@willie-the-truck> 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: will@kernel.org, reijiw@google.com, mark.rutland@arm.com, oliver.upton@linux.dev, catalin.marinas@arm.com, 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, shahuang@redhat.com, robh@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-20230412_032954_145740_02A5D019 X-CRM114-Status: GOOD ( 36.52 ) 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 On Tue, 11 Apr 2023 12:24:59 +0100, Will Deacon wrote: > > On Sat, Apr 08, 2023 at 10:04:19AM +0100, Marc Zyngier wrote: > > On Sat, 08 Apr 2023 04:47:57 +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-rc5. > > > > > > v2: > > > - Save the PMUSERENR_EL0 for the host in the sysreg array of > > > kvm_host_data. [Marc] > > > - Don't let armv8pmu_start() overwrite PMUSERENR if the vCPU > > > is loaded, instead have KVM update the saved shadow register > > > value for the host. [Marc, Mark] > > > > This looks much better to me. If Mark is OK with it, I'm happy to take > > it in 6.4. > > > > Speaking of which, this will clash with the queued move of the PMUv3 > > code into drivers/perf, and probably break on 32bit. I can either take > > a branch shared with arm64 (009d6dc87a56 ("ARM: perf: Allow the use of > > the PMUv3 driver on 32bit ARM")), or wait until -rc1. > > > > Will, what do you prefer? > > I'd be inclined to wait until -rc1, but for-next/perf is stable if you > decide to take it anyway. Given that Mark and Reiji are still working out some of the corner cases, -rc1 feels like the right target. Thanks, M. -- 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