Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1285436lqt; Fri, 7 Jun 2024 13:33:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUF/ov7ACO3iCIEHS6lJKWdGmWucbLR/VbGFg8oJ6gvi7YP8JklW6LG7O/D3bG6Ib9HcW+YB/dlck8qjOFKl+B9nDCtqmDchNhfsfwp6A== X-Google-Smtp-Source: AGHT+IGujJM0ZUfVuTCrFmFUY5vqRubHE+rgop+VAmseAHhdvin6NpXrQFhW7aXzH4hjqGdy7WT8 X-Received: by 2002:a05:622a:288e:b0:440:51f1:288f with SMTP id d75a77b69052e-44051f13801mr12142731cf.48.1717792404806; Fri, 07 Jun 2024 13:33:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717792404; cv=pass; d=google.com; s=arc-20160816; b=vHWJaxnbFBkXhy1VIe9F4YMeqiywzdHHCsEzEKrbnot36e2m/9OkBrV8r0jHKj09eQ y4vwRdFbU9RRv73mj1qPR8WYb7xWGOAgbY7tmTmija3GrcNMwhyjj1JM7zJ4AKvxTtJW PTyJzxw8+GUydjV8yd57kwMbENs3vatI2Xk3ZsQmkTpga3duq8Ns9HxRZC8fg620B4sF 3rrUree6BFoM3ig65DoCFgPojVaJjtHDW/YkdS2jsztkuPkHXSFRFJDA5jfa15hUx9X0 w+osPxqO0B2Nm5VPv0LpYlBAiyHDWRThH8efTjr8dOfqqPtFmOkj/tl+wZ4n2zsFyiQs yirg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=0KjYacNbtEKjwularLI28I+3DULsxKyTJ3ciTXbZHlc=; fh=7MWtQIrhu8/8z5W30BSUbJmbB5Xoil/A+Q0kLnK8lig=; b=ORVQtgan2iWC1kjwXxNg4x9NtdTHgzoQXZDXBXVgiqrDOmjJsoy55xIAIS/eLYo7nr iCqbEZ3mVIQgxPnujfKtjCwThGfcL97lJrOdlZfgbJD6qnQc3MFEEAThzcNDB1Dwm7m0 SoIIqaoroFL17yQEoI0P5znxeK4zt/awP136kC9xMqd07PnGaIAIhzqh5keZpfRK/Mft alL30tR4w9zJ3K/VLMudtyWMyorAXhJNLGW6Dlp+tIOcMMAun6EYYnsHsKVgOEfpGm1S SpN+gAtHg3bbMQhGPt8jDBEAwIFnvwXSf9L1vd110QxlGT3dvLfb0pltHWlit+MrjJ/I tXdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aDPEBnH9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44038a6ebc2si48261881cf.14.2024.06.07.13.33.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 13:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aDPEBnH9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7CCF01C20E8D for ; Fri, 7 Jun 2024 20:33:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D208155748; Fri, 7 Jun 2024 20:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aDPEBnH9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE3561553B3; Fri, 7 Jun 2024 20:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792331; cv=none; b=P4wb5KZLhx5usmsDxmuWd8/ez2MIxQyL4IltTL7KHcAVvlAh4wWuYqyEvk8KNbtQQ2gTMfnmADWRwtOqF3Sfc8OJZ+HbvBoqPJKk0lHONxDjC0O7A/rm+wIk+j1FVrXPaUyBMRr2O3OEQlTL3WBf8abdOHewQo/EeHZnpn+mKnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792331; c=relaxed/simple; bh=17s7vSwqMHxRakvVibGY5mJGrj06gq60Ot/dN3g7oE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a0Ei8k+7+7paeg+6AIByOc9vLO5mXOv4Fd3487B8Cvq8VgnTciyKj/gqrYBEhw8IzE85smMg6cB5Jnhx8Zx0SUupHfV3IQ73G6mYjoERhMys9JfkWNLFnsINRn6jFi9/ICjfUSoCRxzp46Ltj8u9Uc0ONGHnvrxiHJh29wyAMmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aDPEBnH9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35000C4AF11; Fri, 7 Jun 2024 20:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717792331; bh=17s7vSwqMHxRakvVibGY5mJGrj06gq60Ot/dN3g7oE4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aDPEBnH9NLeUYGjfwx3osqF0LmxCqyAbikVBzrj4G6ikVfzPK+sSyKoMUQCdEXk+r 3hsuIgwYr2vUA4mzSmfBh40bLNP87n8Pj0izjjbHa3BAH3uNJfddorZDets554XtSq 6Rh+H2EmApltvf3zKsRV1vWEBLdJM+4r7OUsW7y+OmD7I7MEGYcN8Ejh7ejHmM7fVZ E21xIdqtHrVX5Zp89YhWABjZGzVdfN9hTyg9z2G2DlBvYdMwPeJ4+zm/R/ZLG5gOXx DMBAlOeBAE3XVM+Jbc8CFuVUSUOFsjIo0TndVEVFZ+xvVzKSCqXjA5wPH6A9or43V7 Ji5hhE2OXSuJQ== From: "Rob Herring (Arm)" Date: Fri, 07 Jun 2024 14:31:31 -0600 Subject: [PATCH 6/9] KVM: arm64: pmu: Use generated define for PMSELR_EL0.SEL access Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240607-arm-pmu-3-9-icntr-v1-6-c7bd2dceff3b@kernel.org> References: <20240607-arm-pmu-3-9-icntr-v1-0-c7bd2dceff3b@kernel.org> In-Reply-To: <20240607-arm-pmu-3-9-icntr-v1-0-c7bd2dceff3b@kernel.org> To: Russell King , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvmarm@lists.linux.dev X-Mailer: b4 0.14-dev ARMV8_PMU_COUNTER_MASK is really a mask for the PMSELR_EL0.SEL register field. Make that clear by adding a standard sysreg definition for the register, and using it instead. Signed-off-by: Rob Herring (Arm) --- arch/arm64/include/asm/sysreg.h | 1 - arch/arm64/kvm/sys_regs.c | 10 +++++----- arch/arm64/tools/sysreg | 5 +++++ include/linux/perf/arm_pmuv3.h | 1 - 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index af3b206fa423..b0d6c33f9ecc 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -403,7 +403,6 @@ #define SYS_PMCNTENCLR_EL0 sys_reg(3, 3, 9, 12, 2) #define SYS_PMOVSCLR_EL0 sys_reg(3, 3, 9, 12, 3) #define SYS_PMSWINC_EL0 sys_reg(3, 3, 9, 12, 4) -#define SYS_PMSELR_EL0 sys_reg(3, 3, 9, 12, 5) #define SYS_PMCEID0_EL0 sys_reg(3, 3, 9, 12, 6) #define SYS_PMCEID1_EL0 sys_reg(3, 3, 9, 12, 7) #define SYS_PMCCNTR_EL0 sys_reg(3, 3, 9, 13, 0) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 22b45a15d068..f8b5db48ea8a 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -880,7 +880,7 @@ static u64 reset_pmevtyper(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) static u64 reset_pmselr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) { reset_unknown(vcpu, r); - __vcpu_sys_reg(vcpu, r->reg) &= ARMV8_PMU_COUNTER_MASK; + __vcpu_sys_reg(vcpu, r->reg) &= PMSELR_EL0_SEL_MASK; return __vcpu_sys_reg(vcpu, r->reg); } @@ -972,7 +972,7 @@ static bool access_pmselr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, else /* return PMSELR.SEL field */ p->regval = __vcpu_sys_reg(vcpu, PMSELR_EL0) - & ARMV8_PMU_COUNTER_MASK; + & PMSELR_EL0_SEL_MASK; return true; } @@ -1040,8 +1040,8 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu, if (pmu_access_event_counter_el0_disabled(vcpu)) return false; - idx = __vcpu_sys_reg(vcpu, PMSELR_EL0) - & ARMV8_PMU_COUNTER_MASK; + idx = SYS_FIELD_GET(PMSELR_EL0, SEL, + __vcpu_sys_reg(vcpu, PMSELR_EL0)); } else if (r->Op2 == 0) { /* PMCCNTR_EL0 */ if (pmu_access_cycle_counter_el0_disabled(vcpu)) @@ -1091,7 +1091,7 @@ static bool access_pmu_evtyper(struct kvm_vcpu *vcpu, struct sys_reg_params *p, if (r->CRn == 9 && r->CRm == 13 && r->Op2 == 1) { /* PMXEVTYPER_EL0 */ - idx = __vcpu_sys_reg(vcpu, PMSELR_EL0) & ARMV8_PMU_COUNTER_MASK; + idx = SYS_FIELD_GET(PMSELR_EL0, SEL, __vcpu_sys_reg(vcpu, PMSELR_EL0)); reg = PMEVTYPER0_EL0 + idx; } else if (r->CRn == 14 && (r->CRm & 12) == 12) { idx = ((r->CRm & 3) << 3) | (r->Op2 & 7); diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index a4c1dd4741a4..231817a379b5 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -2153,6 +2153,11 @@ Field 4 P Field 3:0 ALIGN EndSysreg +Sysreg PMSELR_EL0 3 3 9 12 5 +Res0 63:5 +Field 4:0 SEL +EndSysreg + SysregFields CONTEXTIDR_ELx Res0 63:32 Field 31:0 PROCID diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h index 46377e134d67..caa09241ad4f 100644 --- a/include/linux/perf/arm_pmuv3.h +++ b/include/linux/perf/arm_pmuv3.h @@ -7,7 +7,6 @@ #define __PERF_ARM_PMUV3_H #define ARMV8_PMU_MAX_COUNTERS 32 -#define ARMV8_PMU_COUNTER_MASK (ARMV8_PMU_MAX_COUNTERS - 1) /* * Common architectural and microarchitectural event numbers. -- 2.43.0