From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F12C5606A31A for ; Wed, 2 Dec 2026 00:50:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=syy6d/pc; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UYhzrE7a DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=J2UxnGzsHon4L9GLboxJ478UlQu1UXmVkp8ai6i6PVM=; b=syy6d/pcahXPxll5dto3F69wdR CaVmJyh5yG7IO6CnUAGF0ft0XNyzioSMSf3vgpRto93j4o5WllNdYz84/EWEuEblsXJZe/gAA8IuE DnCsFIsKJACxoZMbBAs/yRMCspefa0U0RIqbp1FIp1ZVuGL6K9A7JOfejHYtYipIOxBiLl+y3y1vM U81rwZxCYxtmV6SVousy1XIa7ik/UJFO3WmPbQEMvQV/NYjIJVCpxzg5VGVVh4L2gnYWNiRNiYP9O qcGtxjS48SIrh9ju5mNUlHz7hzr5ZXQW9Y1cD+iQaltBFmeKdbV2YrjGT2Z9WKbVnJ3W5qblKVXGu 3M0qEMcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYYY2-00000009pQ8-3PMm; Wed, 02 Dec 2026 00:50:14 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYYXz-00000009pQ1-3T69 for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 00:50:13 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 81AE841188; Wed, 2 Dec 2026 00:50:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1380B1F00893; Wed, 2 Dec 2026 00:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796172611; bh=J2UxnGzsHon4L9GLboxJ478UlQu1UXmVkp8ai6i6PVM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=UYhzrE7abL0mVLbhVx1lfh8Lk2+UACKJGI6cly9y7bvYcf6R31IW75g14padRrqgs QFJrss6/3pBTvBXlCE19fgeRmuRvQsXxftzAF/Y8AAOiIygPsguRiw8lDDXtnc6Vor zBNU1WkpprB8SfxjvSXyUAZQaovj2E+gTu0MdxIdLOrcqmvKYFm0SM0fE0AfAd5ezj RtX563hd3iFK5J/GDC/JBAtSR2ji1BaU3Syg8Ihalo8D6y67iFYnBPc4DI4+hCxuYM p/tVFq5lnOhe3uqY6LNSGBuAERDqZNAMf3SQAr6GiApkRmZnAFputXAllJPryQ70K/ izx9aiK5VmhrA== Date: Tue, 1 Dec 2026 16:50:09 -0800 From: Oliver Upton To: Colton Lewis Cc: Marc Zyngier , Catalin Marinas , Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , Paolo Bonzini , Russell King , Jonathan Corbet , Fuad Tabba , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Shuah Khan , James Clark , Alexandru Elisei , Mingwei Zhang , Ganapatrao Kulkarni , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 12/33] KVM: arm64: Set up FGT for Partitioned PMU Message-ID: References: <20261119185215.632334-1-coltonlewis@google.com> <20261119185215.632334-13-coltonlewis@google.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261119185215.632334-13-coltonlewis@google.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Nov 19, 2026 at 06:51:54PM +0000, Colton Lewis wrote: > +static void __compute_hdfgrtr(struct kvm_vcpu *vcpu) > +{ > + __compute_fgt(vcpu, HDFGRTR_EL2); > + > + if (kvm_pmu_is_partitioned(vcpu->kvm)) { > + u64 set = HDFGRTR_EL2_PMOVS | > + HDFGRTR_EL2_PMCCFILTR_EL0 | > + HDFGRTR_EL2_PMEVTYPERn_EL0 | > + HDFGRTR_EL2_PMCEIDn_EL0 | > + HDFGRTR_EL2_PMMIR_EL1; > + > + if (is_hyp_ctxt(vcpu) && > + (__vcpu_sys_reg(vcpu, MDCR_EL2) & MDCR_EL2_TPM)) > + set |= HDFGRTR_EL2_PMUSERENR_EL0; > + > + *vcpu_fgt(vcpu, HDFGRTR_EL2) |= set & ~hdfgrtr_masks.res0; There's no reason to use the RES0 mask. If one of the FGT bits you set depends on a feature that's not present in hardware then it's up to *hardware* to ignore the value. Thanks, Oliver > + } > +} > + > static void __compute_hdfgwtr(struct kvm_vcpu *vcpu) > { > __compute_fgt(vcpu, HDFGWTR_EL2); > > if (is_hyp_ctxt(vcpu)) > *vcpu_fgt(vcpu, HDFGWTR_EL2) |= HDFGWTR_EL2_MDSCR_EL1; > + > + if (kvm_pmu_is_partitioned(vcpu->kvm)) { > + u64 set = HDFGWTR_EL2_PMOVS | > + HDFGWTR_EL2_PMCCFILTR_EL0 | > + HDFGWTR_EL2_PMEVTYPERn_EL0; > + > + if (is_hyp_ctxt(vcpu)) > + set |= HDFGWTR_EL2_PMUSERENR_EL0; > + > + *vcpu_fgt(vcpu, HDFGWTR_EL2) |= set & ~hdfgwtr_masks.res0; > + } > +} > + > +static void __compute_hdfgrtr2(struct kvm_vcpu *vcpu) > +{ > + __compute_fgt(vcpu, HDFGRTR2_EL2); > + > + if (kvm_pmu_is_partitioned(vcpu->kvm)) { > + *vcpu_fgt(vcpu, HDFGRTR2_EL2) &= > + ~(HDFGRTR2_EL2_nPMICFILTR_EL0 | > + HDFGRTR2_EL2_nPMICNTR_EL0) | hdfgrtr2_masks.res1; > + } > +} > + > +static void __compute_hdfgwtr2(struct kvm_vcpu *vcpu) > +{ > + __compute_fgt(vcpu, HDFGWTR2_EL2); > + > + if (kvm_pmu_is_partitioned(vcpu->kvm)) { > + *vcpu_fgt(vcpu, HDFGWTR2_EL2) &= > + ~(HDFGWTR2_EL2_nPMICFILTR_EL0 | > + HDFGWTR2_EL2_nPMICNTR_EL0) | hdfgwtr2_masks.res1; > + } > } > > static void __compute_ich_hfgrtr(struct kvm_vcpu *vcpu) > @@ -1828,7 +1880,7 @@ void kvm_vcpu_load_fgt(struct kvm_vcpu *vcpu) > __compute_fgt(vcpu, HFGRTR_EL2); > __compute_hfgwtr(vcpu); > __compute_fgt(vcpu, HFGITR_EL2); > - __compute_fgt(vcpu, HDFGRTR_EL2); > + __compute_hdfgrtr(vcpu); > __compute_hdfgwtr(vcpu); > __compute_fgt(vcpu, HAFGRTR_EL2); > > @@ -1836,8 +1888,8 @@ void kvm_vcpu_load_fgt(struct kvm_vcpu *vcpu) > __compute_fgt(vcpu, HFGRTR2_EL2); > __compute_fgt(vcpu, HFGWTR2_EL2); > __compute_fgt(vcpu, HFGITR2_EL2); > - __compute_fgt(vcpu, HDFGRTR2_EL2); > - __compute_fgt(vcpu, HDFGWTR2_EL2); > + __compute_hdfgrtr2(vcpu); > + __compute_hdfgwtr2(vcpu); > } > > if (cpus_have_final_cap(ARM64_HAS_GICV5_CPUIF)) { > -- > 2.56.1.708.g77570a6a1d-goog >