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 1C86CC7619A for ; Sat, 8 Apr 2023 09:05:29 +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=LcBctusP6yiv07WOFXnGQuid/y2QBWvagLhJnPqj9hc=; b=RZ/Nxh7c06eu2s f9THya7XPE2oGdW3TD/EajZiVAO+agNsWSzlb8evEv5y298Yi5OuP2oBNijrvslHSxN6HynLGsDYv sNpF/TRChBF+PKR0dEzh5IUJwxxf1c/YzFUyxj3GCXlMOgfkGbKOil/4RtlIfYPc0KMJet1cVLXh5 MlKRkVOrqIpjWHn5yzPB/V0Bbt5IwgESwW4GRS+GTpXsT3nRrNeCcDlI9jg6hJtdH/dFBwncUk1gp G2y1U7PCVHTXyxqry5nxpTD1HXK+3l0w59TjdAq0AGbG9LWU1CUG7OvATxyYW8Icw5swR6aJNmVKi mi7zEoQQ81sHluHBEm3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pl4Uq-00ByuL-0N; Sat, 08 Apr 2023 09:04:32 +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 1pl4Um-00Bytu-1B for linux-arm-kernel@lists.infradead.org; Sat, 08 Apr 2023 09:04:29 +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 46F5160EA8; Sat, 8 Apr 2023 09:04:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3BA7C433D2; Sat, 8 Apr 2023 09:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680944665; bh=9KSYc/aRzYiGq0Et9z8S3TtK1vtPJYEJOL1TbX+w8Cc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=epS8tW5Nzv9fOkclOry6xBnGFaAghO2/86lz2k72HS4MAuoK6o+KLa0fYUC99xrul erPTpiKD0HweyrP/9AkyXGkywX9sGc8xSM1VOr/nWrhxJunJtvHWsIYZo1wpTPGvN6 5NQltmVpMJXadZRnVMX+yx/rWBS30rmx+KfLAK9JT8guKVJYZNwynaxMOr6UUfIgiJ el4ERoV4zMVXu8Q6TY7Z2lqHThOZZlGuMlP3/m6jbLN43iT0QDGN4nwxR2Yh3mCY+9 7T+krDi7p7AzcMU0e4FiEpBb8QgcNsWDqLRusg6KR+1Q0X4MeqTjO6Xz8mihaEvRgI cqQceWWIBuN7g== 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 1pl4Uh-006tVO-6G; Sat, 08 Apr 2023 10:04:23 +0100 Date: Sat, 08 Apr 2023 10:04:19 +0100 Message-ID: <86r0subv8s.wl-maz@kernel.org> From: Marc Zyngier To: Reiji Watanabe , Mark Rutland , Will Deacon Cc: 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: <20230408034759.2369068-1-reijiw@google.com> References: <20230408034759.2369068-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: reijiw@google.com, mark.rutland@arm.com, will@kernel.org, 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-20230408_020428_506897_40ABFA96 X-CRM114-Status: GOOD ( 25.77 ) 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 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? 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