Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp280491lqp; Mon, 10 Jun 2024 04:10:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOxC1ySHsnyk+aB0y5J0MrZcWVDtCUWgwbFlsztC6lHYQmFK062o4AwqsvcyHN0gaIwsKpU9guN8xA5HtL1B/qu6A2FilSogXrHtNHHQ== X-Google-Smtp-Source: AGHT+IE7po5W4XrSrQo1SXzklF27qGOodOck7zpTKAHo4r0dzJxatbcybr17RPdyhXvMYuEFOWRN X-Received: by 2002:a05:6122:9aa:b0:4dc:d7b4:5f7d with SMTP id 71dfb90a1353d-4eb56254431mr8910031e0c.8.1718017830718; Mon, 10 Jun 2024 04:10:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718017830; cv=pass; d=google.com; s=arc-20160816; b=QEfjJCXbb8B5drsm8iSfPzgWIRM4l5WUVrfwy4fTRSWvH1cPpYn2jAngnPlzOQa63+ cMbTg7svDeJrabFc5wGuMFPdF/okzF5i5+6Kol16vEjSNLQcMWBPz7R7TCTSoZnTPETk pkNM3/Q6ncW280BHPnQ/5CgG4ANY1NJphvxuqasolMty1qEx/2MfQVeXAXREy+xndZ35 QEntWtt/1JWww+ilwYatj5bX4Dzhdzxxifp/c24SJdNp3sv6isXk3tqgPc9PdiSPIzzW I8D1ywoPDfQuko+c7POxTAGsXoBzQsSSJuoDF7vZV1K1Uq9NNSjxzOYKuA45yH2HokT+ H8hA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=wJDQ319eF7bWUD7ZwBliyE9zNXmH1f0N9SEKvoDNXeo=; fh=qgMfJgvzXFQidiVGYujudC5/sUCtdt6StJkY7gN6rRQ=; b=cRxSx0OsVn+0G9YSIscvTCB7u3RTGahpm7+yQ6CX3JxhRBkFlpQx3lEPTTa627g/TG 7HnnXdRaW0ggOmNZhIdVDzJHBXzHGQNIkiXHQvBImj10/kmZMtSyuWZw2phgGy61snC3 +FCahkZdd9IJspFXvk1MjCalmkcovz+INP6ji06pcMMjyppOFqOPT8zy7WhPc2IPnWkQ xF/UYOae0Y79uvRkWNYGvF+/hI7d+iSzU0Wx03uyK4pp+m4D8l6xfpDxkg/PHmA4k7+L ZwNuu2XGN762N+WOrj4ur5S7F/aBA4sqGzdPOMGxwQHpjgpn9MrStWoTiCzMY0I2USLd 4iAw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208064-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 71dfb90a1353d-4eb4ac961efsi1602129e0c.113.2024.06.10.04.10.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208064-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 207371C219BE for ; Mon, 10 Jun 2024 11:10:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02F517CF25; Mon, 10 Jun 2024 11:10:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF14D79DD4; Mon, 10 Jun 2024 11:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718017820; cv=none; b=q+PT2wGRpV0XrbfXGJxtWpFti7k3taRbAsnTrQRyED5UGWjVhuXTaPFyqc+MXmWzwitNhZ2nBFfCvFLOCRfM9aozXTnr6cZqp0Bf2fUREfyD3+jXdku6BjmezVwgDdu5YgSwXCL1xF41xv1NzcPsEoy/3nzuOpMda84hYHNYd5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718017820; c=relaxed/simple; bh=t8YAAYThVnVgT7x/11d4Zu4WwbrMMvSN6ZQtxSBGXPY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KmaDLUQYqqpIzBjf5x9v9+pfu5OtE/oFNa3xQt9ErmjoLWKzgurw7w2C48vHT5z/DoNtPKwzgJrHsQCkH49m4w2Lqfl1yB7iDKniNBF0XrQth7Po16JYkuktgX2XK+RkwIfiQWoUmzwWJMcnit27wfaLIGXwl8eKXlxawdNISfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 C59B312FC; Mon, 10 Jun 2024 04:10:41 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E56843F73B; Mon, 10 Jun 2024 04:10:13 -0700 (PDT) Date: Mon, 10 Jun 2024 12:10:11 +0100 From: Mark Rutland To: "Rob Herring (Arm)" Cc: Russell King , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvmarm@lists.linux.dev Subject: Re: [PATCH 6/9] KVM: arm64: pmu: Use generated define for PMSELR_EL0.SEL access Message-ID: References: <20240607-arm-pmu-3-9-icntr-v1-0-c7bd2dceff3b@kernel.org> <20240607-arm-pmu-3-9-icntr-v1-6-c7bd2dceff3b@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240607-arm-pmu-3-9-icntr-v1-6-c7bd2dceff3b@kernel.org> On Fri, Jun 07, 2024 at 02:31:31PM -0600, Rob Herring (Arm) wrote: > 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(-) This looks good to me; I checked the reg values match those in the latest ARM ARM (ARM DDI 0487K.a pages 9016 to 9018), and they also match the eixsting values in the kernel. The changes to use the new mask name and to use SYS_FIELD_GET() all look good to me. Reviewed-by: Mark Rutland Acked-by: Mark Rutland Mark. > > 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 >