linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Madhavan Srinivasan <maddy@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v3 1/2] powerpc/perf: Infrastructure to support checking of attr.config*
Date: Thu, 8 Apr 2021 08:08:22 +0530	[thread overview]
Message-ID: <01370595-7135-1cb1-5998-76e169617b1b@linux.ibm.com> (raw)
In-Reply-To: <87sg42e34x.fsf@mpe.ellerman.id.au>


On 4/7/21 5:08 PM, Michael Ellerman wrote:
> Madhavan Srinivasan <maddy@linux.ibm.com> writes:
>> diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
>> index 6817331e22ff..c6eeb4fdc5fd 100644
>> --- a/arch/powerpc/perf/core-book3s.c
>> +++ b/arch/powerpc/perf/core-book3s.c
>> @@ -1958,6 +1958,20 @@ static int power_pmu_event_init(struct perf_event *event)
>>   
>>   		if (ppmu->blacklist_ev && is_event_blacklisted(ev))
>>   			return -EINVAL;
>> +		/*
>> +		 * PMU config registers have fields that are
>> +		 * reserved and specific value to bit field as reserved.
>> +		 * For ex., MMCRA[61:62] is Randome Sampling Mode (SM)
>> +		 * and value of 0b11 to this field is reserved.
>> +		 *
>> +		 * This check is needed only for raw event type,
>> +		 * since tools like fuzzer use raw event type to
>> +		 * provide randomized event code values for test.
>> +		 *
>> +		 */
>> +		if (ppmu->check_attr_config &&
>> +		    ppmu->check_attr_config(event))
>> +			return -EINVAL;
>>   		break;
> It's not obvious from the diff, but you're only doing the check for RAW
> events.
>
> But I think that's wrong, we should always check, even if the event code
> comes from the kernel we should still apply the same checks. Otherwise
> we might inadvertently use an invalid event code for a HARDWARE or CACHE
Reason for not including HARDWARE and CACHE events are thats,
they are straight forward, meaning they dont use sampling or thresholding
features. Currently, checks are mostly in that spaces to check for any 
invalid
values. We could include the check for all types the events.

I will respin the patch with that change

Thanks for review
Maddy


> event.
>
> cheers

      reply	other threads:[~2021-04-08  2:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 11:53 [PATCH v3 1/2] powerpc/perf: Infrastructure to support checking of attr.config* Madhavan Srinivasan
2021-03-25 11:53 ` [PATCH v3 2/2] powerpc/perf: Add platform specific check_attr_config Madhavan Srinivasan
2021-04-01 16:00 ` [PATCH v3 1/2] powerpc/perf: Infrastructure to support checking of attr.config* Athira Rajeev
2021-04-07 11:38 ` Michael Ellerman
2021-04-08  2:38   ` Madhavan Srinivasan [this message]

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=01370595-7135-1cb1-5998-76e169617b1b@linux.ibm.com \
    --to=maddy@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).