Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp172063rdg; Tue, 10 Oct 2023 07:17:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGj7dm+z0EVCFSrX2Jfm8gSICvMa8RHQLSYahvotlrg7ZXsjiN5MI2kTk6AOkBai3mMNoyV X-Received: by 2002:a05:6a00:1989:b0:68f:e121:b37c with SMTP id d9-20020a056a00198900b0068fe121b37cmr22073834pfl.4.1696947428564; Tue, 10 Oct 2023 07:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696947428; cv=none; d=google.com; s=arc-20160816; b=REuLrvBslADALAaFTOl91fNs4TexUVt9wtPmtR0VKPCIgGLtOccZ3qH3HGDNduS40d gExaRvFwo7ZT7awf/Zi0WeWdm2AgOpTrRwEd/hE+WtRnk1yNHIhpOlk1zgmZ38JoD5rn SaYKLfaYpAy28UB8e1l5wZql8HcAkR5RTxSfQ2nkfp/JY3CPRmqf0kBIysGXcmMZ7eiM TYJWNFoa9kSwVIIo6IKr/m2Sj8pqL8lFqyvQOdDKpWs2RWVzp9cVEWPj0INIjhFCgdPx RjZuN96wJ8dV7qZWA2gMFEuRypdl6ryZ3JP40U8R/gBAL2KVp7JmS/BC73xOBUHsKhiC ZY0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=THfUk3bZaUSrYws2KMqZtGreRJZgHUNuJcfj39mRyqY=; fh=tsGphby1Av5Hj1NEZgyMxnYo679733EsnXXZYUYoOgY=; b=lQR/V+yig6FldoyYk6/gzfO219cQwzlj2zjKVJ+YT7Wp6NE9iD93fJMWJ5sIEngvIk Op0k4AGBqQtv3Px1eTxGOenYM2nDu8Q+aN3uR6QvsbjNca0V8IikJQC282ITQ10OZHy9 k5qBG16W+zw1yh5fMqvvdGzwWXVc6GZHWsktWmrEXDnjxh3l3mNUpDnIx0VQvlIQcpoW makb10vkq5DM8OhQzOScx+fpdB6krABjBD+UVEgHqc1n0IjZKLFGlNWA2JaRZauigmci Tpxr9rdCoa7A+fm6IrLiT3wTPUsZxYW0oUIEKvbSjlL9tANhXqyj5qWQ2VxTzEMxzUyb hk8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id eb25-20020a056a004c9900b00690fbe083f8si9734275pfb.334.2023.10.10.07.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 468FA80309AA; Tue, 10 Oct 2023 07:16:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232855AbjJJOQZ (ORCPT + 99 others); Tue, 10 Oct 2023 10:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232818AbjJJOQX (ORCPT ); Tue, 10 Oct 2023 10:16:23 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BFEA0A9; Tue, 10 Oct 2023 07:16:19 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 29D20C15; Tue, 10 Oct 2023 07:17:00 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E3C763F762; Tue, 10 Oct 2023 07:16:16 -0700 (PDT) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, suzuki.poulose@arm.com Cc: James Clark , Catalin Marinas , Will Deacon , Jonathan Corbet , Russell King , Marc Zyngier , Oliver Upton , James Morse , Zenghui Yu , Mark Rutland , Zaid Al-Bassam , Reiji Watanabe , Geert Uytterhoeven , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v3 1/3] arm: perf: Include threshold control fields valid in PMEVTYPER mask Date: Tue, 10 Oct 2023 15:15:41 +0100 Message-Id: <20231010141551.2262059-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010141551.2262059-1-james.clark@arm.com> References: <20231010141551.2262059-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:16:39 -0700 (PDT) FEAT_PMUv3_TH (Armv8.8) adds two new fields to PMEVTYPER, so include them in the mask. These aren't writable on 32 bit kernels as they are in the high part of the register, so split the mask definition to the asm files for each platform. Now where the value is used in some parts of KVM, include the asm file. There is no impact on guest PMUs emulated with KVM because the new fields are ignored when constructing the attributes for opening the event. But if threshold support is added to KVM at a later time no change to the mask will be needed. Despite not being used on aarch32, TH and TC macros are added to the shared header file, because they are used in arm_pmuv3.c which is compiled for both platforms. Signed-off-by: James Clark --- arch/arm/include/asm/arm_pmuv3.h | 3 +++ arch/arm64/include/asm/arm_pmuv3.h | 4 ++++ arch/arm64/kvm/pmu-emul.c | 1 + arch/arm64/kvm/sys_regs.c | 1 + include/linux/perf/arm_pmuv3.h | 3 ++- 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/arm_pmuv3.h b/arch/arm/include/asm/arm_pmuv3.h index 72529f5e2bed..491310133d09 100644 --- a/arch/arm/include/asm/arm_pmuv3.h +++ b/arch/arm/include/asm/arm_pmuv3.h @@ -9,6 +9,9 @@ #include #include +/* Mask for writable bits */ +#define ARMV8_PMU_EVTYPE_MASK 0xc800ffff + #define PMCCNTR __ACCESS_CP15_64(0, c9) #define PMCR __ACCESS_CP15(c9, 0, c12, 0) diff --git a/arch/arm64/include/asm/arm_pmuv3.h b/arch/arm64/include/asm/arm_pmuv3.h index 18dc2fb3d7b7..4faf4f7385a5 100644 --- a/arch/arm64/include/asm/arm_pmuv3.h +++ b/arch/arm64/include/asm/arm_pmuv3.h @@ -11,6 +11,10 @@ #include #include +/* Mask for writable bits */ +#define ARMV8_PMU_EVTYPE_MASK (0xc800ffffUL | ARMV8_PMU_EVTYPE_TH | \ + ARMV8_PMU_EVTYPE_TC) + #define RETURN_READ_PMEVCNTRN(n) \ return read_sysreg(pmevcntr##n##_el0) static inline unsigned long read_pmevcntrn(int n) diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c index 6b066e04dc5d..0666212c0c15 100644 --- a/arch/arm64/kvm/pmu-emul.c +++ b/arch/arm64/kvm/pmu-emul.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index e92ec810d449..d0e11e684f07 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h index e3899bd77f5c..ec3a01502e7c 100644 --- a/include/linux/perf/arm_pmuv3.h +++ b/include/linux/perf/arm_pmuv3.h @@ -228,7 +228,8 @@ /* * PMXEVTYPER: Event selection reg */ -#define ARMV8_PMU_EVTYPE_MASK 0xc800ffff /* Mask for writable bits */ +#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32) +#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61) #define ARMV8_PMU_EVTYPE_EVENT 0xffff /* Mask for EVENT bits */ /* -- 2.34.1