All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: Joey Gouly <joey.gouly@arm.com>, kvm@vger.kernel.org
Cc: alexandru.elisei@arm.com, andrew.jones@linux.dev,
	kvmarm@lists.linux.dev, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>
Subject: Re: [kvm-unit-tests PATCH v3 08/10] arm64: pmu: count EL2 cycles
Date: Tue, 2 Dec 2025 11:31:36 +0100	[thread overview]
Message-ID: <a8951572-2d70-413e-90c7-9eb45a5d18a2@redhat.com> (raw)
In-Reply-To: <20250925141958.468311-9-joey.gouly@arm.com>



On 9/25/25 4:19 PM, Joey Gouly wrote:
> Count EL2 cycles if that's the EL kvm-unit-tests is running at!
>
> Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric
> ---
>  arm/pmu.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/arm/pmu.c b/arm/pmu.c
> index 2dc0822b..e6c0f05b 100644
> --- a/arm/pmu.c
> +++ b/arm/pmu.c
> @@ -121,6 +121,8 @@ static struct pmu pmu;
>  #define PMINTENCLR   __ACCESS_CP15(c9, 0, c14, 2)
>  #define PMCCNTR64    __ACCESS_CP15_64(0, c9)
>  
> +#define PMCCFILTR_EL0_DEFAULT	0
> +
>  static inline uint32_t get_id_dfr0(void) { return read_sysreg(ID_DFR0); }
>  static inline uint32_t get_pmcr(void) { return read_sysreg(PMCR); }
>  static inline void set_pmcr(uint32_t v) { write_sysreg(v, PMCR); }
> @@ -206,6 +208,9 @@ static void test_overflow_interrupt(bool overflow_at_64bits) {}
>  #define ID_DFR0_PMU_V3_8_5	0b0110
>  #define ID_DFR0_PMU_IMPDEF	0b1111
>  
> +#define PMCCFILTR_EL0_NSH	BIT(27)
> +#define PMCCFILTR_EL0_DEFAULT	(current_level() == CurrentEL_EL2 ? PMCCFILTR_EL0_NSH : 0)
> +
>  static inline uint32_t get_id_aa64dfr0(void) { return read_sysreg(id_aa64dfr0_el1); }
>  static inline uint32_t get_pmcr(void) { return read_sysreg(pmcr_el0); }
>  static inline void set_pmcr(uint32_t v) { write_sysreg(v, pmcr_el0); }
> @@ -246,8 +251,7 @@ static inline void precise_instrs_loop(int loop, uint32_t pmcr)
>  #define PMCNTENSET_EL0 sys_reg(3, 3, 9, 12, 1)
>  #define PMCNTENCLR_EL0 sys_reg(3, 3, 9, 12, 2)
>  
> -#define PMEVTYPER_EXCLUDE_EL1 BIT(31)
> -#define PMEVTYPER_EXCLUDE_EL0 BIT(30)
> +#define PMEVTYPER_EXCLUDE_EL0 BIT(30) | (current_level() == CurrentEL_EL2 ? BIT(27) : 0)
>  
>  static bool is_event_supported(uint32_t n, bool warn)
>  {
> @@ -1063,7 +1067,8 @@ static bool check_cycles_increase(void)
>  	/* init before event access, this test only cares about cycle count */
>  	pmu_reset();
>  	set_pmcntenset(1 << PMU_CYCLE_IDX);
> -	set_pmccfiltr(0); /* count cycles in EL0, EL1, but not EL2 */
> +
> +	set_pmccfiltr(PMCCFILTR_EL0_DEFAULT);
>  
>  	set_pmcr(get_pmcr() | PMU_PMCR_LC | PMU_PMCR_C | PMU_PMCR_E);
>  	isb();
> @@ -1118,7 +1123,7 @@ static bool check_cpi(int cpi)
>  	/* init before event access, this test only cares about cycle count */
>  	pmu_reset();
>  	set_pmcntenset(1 << PMU_CYCLE_IDX);
> -	set_pmccfiltr(0); /* count cycles in EL0, EL1, but not EL2 */
> +	set_pmccfiltr(PMCCFILTR_EL0_DEFAULT);
>  
>  	if (cpi > 0)
>  		printf("Checking for CPI=%d.\n", cpi);


  reply	other threads:[~2025-12-02 10:31 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 14:19 [kvm-unit-tests PATCH v3 00/10] arm64: EL2 support Joey Gouly
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 01/10] arm64: drop to EL1 if booted at EL2 Joey Gouly
2025-11-27 17:07   ` Eric Auger
2025-11-28 15:11     ` Joey Gouly
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 02/10] arm64: efi: initialise SCTLR_ELx fully Joey Gouly
2025-11-27 16:49   ` Eric Auger
2025-11-28 15:18     ` Joey Gouly
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 03/10] arm64: efi: initialise the EL Joey Gouly
2025-11-27 17:08   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 04/10] arm64: timer: use hypervisor timers when at EL2 Joey Gouly
2025-12-02  8:36   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 05/10] arm64: micro-bench: fix timer IRQ Joey Gouly
2025-12-02  8:36   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 06/10] arm64: micro-bench: use smc when at EL2 Joey Gouly
2025-12-02  9:11   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 07/10] arm64: selftest: update test for running " Joey Gouly
2025-12-02  9:16   ` Eric Auger
2025-12-02 12:21     ` Joey Gouly
2025-12-02 12:30       ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 08/10] arm64: pmu: count EL2 cycles Joey Gouly
2025-12-02 10:31   ` Eric Auger [this message]
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 09/10] arm64: run at EL2 if supported Joey Gouly
2025-12-02 10:35   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 10/10] arm64: add EL2 environment variable Joey Gouly
2025-11-27 10:34   ` Eric Auger
2025-11-27 10:40     ` Joey Gouly
2025-12-01 23:34   ` Andrew Jones
2025-11-19 13:18 ` [kvm-unit-tests PATCH v3 00/10] arm64: EL2 support Joey Gouly
2025-11-19 13:48   ` Nadav Amit
2025-11-19 14:02     ` Joey Gouly
2025-11-19 15:34       ` Andrew Jones
2025-11-19 15:34 ` Marc Zyngier
2025-11-27 10:04 ` Eric Auger
2025-11-27 11:08   ` Joey Gouly
2025-11-27 12:04     ` Eric Auger
2025-11-27 14:52       ` Joey Gouly
2025-12-01 23:16         ` Andrew Jones
2025-12-02 14:22           ` Joey Gouly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8951572-2d70-413e-90c7-9eb45a5d18a2@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.