Re: [PATCH v2 1/2] kcov, objtool: Make runtime functions noinstr-compatible

From: Marco Elver
Date: Thu Aug 12 2021 - 10:04:41 EST


[-Cc most]
[+Cc Mark]

On Thu, 4 Jun 2020 at 17:25, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
[...]
> I would feel very much better with those actually in noinstr, because
> without it, there is nothing stopping us from adding a kprobe/hw-
> breakpoint or other funny to the function.
>
> Even if they almost instra-return, having a kprobe on the function entry
> or condition check is enough to utterly wreck things.
>
> So something like:
>
> void noinstr __sanitizer_cov_trace_*(...)
> {
> if (within_noinstr_section(ip))
> return;
>
> instrumentation_begin();
> write_comp_data(...);
> instrumentation_end();
> }

Apologies for resurrecting this. :-)

It seems I'll need to use this approach soon for upcoming KCSAN
instrumentation for memory barriers. I'm able to use the same objtool
feature that erases __sanitizer_cov* calls on x86 to erase memory
barrier instrumentation, but arm64 will still be a problem because of
lack of objtool support.

Mark, on arm64, is the approach above that Peter proposed ~1y ago
acceptable in general to make instrumentation noinstr-safe?

Thanks,
-- Marco