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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 26 Feb 2024 18:57:17 +0000
From: Robin Murphy <robin.murphy@....com>
To: Yang Jialong 杨佳龙 <jialong.yang@...ngroup.cn>,
 Will Deacon <will@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>, shenghui.qu@...ngroup.cn,
 ke.zhao@...ngroup.cn, zhijie.ren@...ngroup.cn,
 linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf/arm_smmuv3: Omit the two judgements which done in
 framework

On 19/02/2024 6:37 am, Yang Jialong 杨佳龙 wrote:
> 
> 
> 在 2024/2/10 0:32, Robin Murphy 写道:
>> On 2024-02-09 4:09 pm, Will Deacon wrote:
>>> On Thu, Dec 21, 2023 at 05:38:01PM +0800, JiaLong.Yang wrote:
>>>> 'event->attr.type != event->pmu->type' has been done in
>>>> core.c::perf_init_event() ,core.c::perf_event_modify_attr(), etc.
>>>>
>>>> This PMU is an uncore one. The core framework has disallowed
>>>> uncore-task events. So the judgement to event->cpu < 0 is no mean.
>>>
>>> It would be great to refer to the changes which added those checks to
>>> the perf core code. From reading the code myself, I can't convince 
>>> myself
>>> that perf_try_init_event() won't call into the driver.
>>>
>>>>
>>>> The two judgements have been done in kernel/events/core.c
>>>>
>>>> Signed-off-by: JiaLong.Yang <jialong.yang@...ngroup.cn>
>>>> ---
>>>>   drivers/perf/arm_smmuv3_pmu.c | 8 --------
>>>>   1 file changed, 8 deletions(-)
>>>
>>> It looks like _many_ perf drivers have these checks, so if they really
>>> aren't needed, we can clean this up bveyond SMMU. However, as I said
>>> above, I'm not quite convinced we can drop them.
>>
>> Right, I think the logic prevents events with a specific PMU type 
>> being offered to other PMUs, but as far as I'm aware doesn't apply the 
>> other way round to stop generic events (PERF_TYPE_HARDWARE etc.) being 
>> offered to all PMUs, so it's those that system PMUs need to reject. >
>> It's been on my wishlist for a long time to have a capability flag to 
>> say "I don't handle generic events, please only ever give me events of 
>> my exact type" so we *can* truly factor this into the core.
> 
> 
> It's core framework's responsible to differ generic events and others, 
> or uncore pmu and core pmu.
> Here we have flag PERF_TYPE_HARDWARE, PERF_TYPE_HW_CACHE, 
> PERF_PMU_CAP_EXTENDED_HW_TYPE doing this.
> 
> again:
>          rcu_read_lock();
>          pmu = idr_find(&pmu_idr, type);
>          rcu_read_unlock();
>          if (pmu) {
>                  if (event->attr.type != type && type != PERF_TYPE_RAW &&
>                      !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE))
>                          goto fail; /* generic event with no ability pmu */
> This can avoid driver code (event->attr.type != event->pmu->type).

Now consider the other case below that, where "type" has not matched 
anything registered, so "pmu" is NULL, and the event is then offered to 
*every* registered PMU to see if anyone accepts it. Note that even CPU 
PMUs don't always register as PERF_TYPE_RAW, and in particular arm_pmu 
doesn't.

Thanks,
Robin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ