Re: [PATCH 2/8] perf evsel: Do not request ptrauth sample field if not supported

From: Vince Weaver
Date: Wed Jul 06 2022 - 12:01:23 EST


On Mon, 4 Jul 2022, Andrew Kilroy wrote:

> A subsequent patch alters perf to perf_event_open with the
> PERF_SAMPLE_ARCH_1 bit on.
>
> This patch deals with the case where the kernel does not know about the
> PERF_SAMPLE_ARCH_1 bit, and does not know to send the pointer
> authentication masks. In this case the perf_event_open system call
> returns -EINVAL (-22) and perf exits with an error.
>
> This patch causes userspace process to re-attempt the perf_event_open
> system call but without asking for the PERF_SAMPLE_ARCH_1 sample
> field, allowing the perf_event_open system call to succeed.

So in this case you are leaking ARM64-specific info into the generic
perf_event_open() call? Is there any way the kernel could implement this
without userspace having to deal with the issue?

There are a few recent ARM64 perf_event related patches that are pushing
ARM specific interfaces into the generic code, with the apparent
assumption that it will just be implemented in the userspace perf tool.
However there are a number of outside-the-kernel codebases that also use
perf_event_open() and it seems a bit onerous if all of them have to start
adding a lot of extra ARM64-specific code, especially because as far as I
can tell there haven't been any documentation patches included for the
Makefile.

The other recent change that's annoying for userspace is the addition of
the ARM-specific /proc/sys/kernel/perf_user_access that duplicates
functionality found in /sys/devices/cpu/rdpmc

Vince Weaver
vincent.weaver@xxxxxxxxx