lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 22 Feb 2024 12:24:38 +0000
From: Will Deacon <will@...nel.org>
To: Xu Yang <xu.yang_2@....com>
Cc: Frank.li@....com, mark.rutland@....com, robh+dt@...nel.org,
	krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
	shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
	festevam@...il.com, john.g.garry@...cle.com, jolsa@...nel.org,
	namhyung@...nel.org, irogers@...gle.com, linux-imx@....com,
	mike.leach@...aro.org, leo.yan@...aro.org, peterz@...radead.org,
	mingo@...hat.com, acme@...nel.org,
	alexander.shishkin@...ux.intel.com, adrian.hunter@...el.com,
	linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
	imx@...ts.linux.dev
Subject: Re: [PATCH v4 5/6] perf: imx_perf: limit counter ID from user space
 and optimize counter usage

On Wed, Jan 31, 2024 at 01:58:10PM +0800, Xu Yang wrote:
> The user can pass any counter ID to perf app. However, current pmu driver
> doesn't judge the validity of the counter ID. This will add necessary
> check for counter ID from user space. Besides, this pmu has 10 counters
> except cycle counter which can be used to count reference events and
> counter specific evnets. This will also add supports to auto allocate
> counter if the user doesn't pass it the perf. Then, the usage of counter
> will be optimized.
> 
> Signed-off-by: Xu Yang <xu.yang_2@....com>
> 
> ---
> Changes in v2:
>  - limit counter ID from user to 0-10
>  - combine dynamic and static allocation of counter
> Changes in v3:
>  - no changes
> Changes in v4:
>  - rename ddr_perf_is_specific_event()
>  - use macro definitions to parse config attr
> ---
>  drivers/perf/fsl_imx9_ddr_perf.c | 72 +++++++++++++++++++++++++++++++-
>  1 file changed, 71 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c
> index 94041f06c152..e71496809c52 100644
> --- a/drivers/perf/fsl_imx9_ddr_perf.c
> +++ b/drivers/perf/fsl_imx9_ddr_perf.c
> @@ -51,6 +51,7 @@
>  
>  #define NUM_COUNTERS		11
>  #define CYCLES_COUNTER		0
> +#define CYCLES_EVENT_ID		0
>  
>  #define CONFIG_EVENT_MASK	0x00FF
>  #define CONFIG_EVENT_OFFSET	0
> @@ -240,6 +241,19 @@ static struct attribute *ddr_perf_events_attrs[] = {
>  	NULL,
>  };
>  
> +/*
> + * An event is either reference evnet or counter specific event.
> + * For counter specific event, the event count will only be incremented
> + * on the corresponding counter.
> + */
> +static bool ddr_perf_is_counter_specific_event(int event)
> +{
> +	if (event >= 64 && event <= 73)
> +		return true;
> +	else
> +		return false;

Just collapse this to 'return event >= 64 && event <= 73;'

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ