Re: [PATCH v2 2/4] arm64, scs: save scs_sp values per-cpu when switching stacks

From: Andrey Konovalov
Date: Tue Apr 05 2022 - 21:53:13 EST

On Thu, Mar 31, 2022 at 11:24 AM Mark Rutland <mark.rutland@xxxxxxx> wrote:
> On Wed, Mar 23, 2022 at 04:32:53PM +0100, andrey.konovalov@xxxxxxxxx wrote:
> > From: Andrey Konovalov <andreyknvl@xxxxxxxxxx>
> >
> > Instead of trying to retrieve the SCS pointers from the stack, change
> > interrupt handlers (for hard IRQ, Normal and Critical SDEI) to save the
> > previous SCS pointer in a per-CPU variable.
> I'm *really* not keen on *always* poking this in the entry code for the
> uncommon case of unwind. It complicates the entry code and means we're always
> paying a cost for potentially no benefit. At a high-level, I don't think this
> is the right approach.

This also gives a 5% slowdown, which is not acceptable.

What we can do instead, is to not collect frames from the higher
exception levels at all. This would leave SCS-based stack collection
method impaired, but this is probably fine for KASAN's use case:
currently, stack depot filters out higher-level frames anyway, so
KASAN never saves them. And the lower-level part of the stack trace is
enough to identify the allocation.


> For the regular unwinder, I want to rework things such that we can identify
> exception boundaries and look into the regs (e.g. so that we can recover the
> PC+LR+FP and avoid duplicating part of this in a frame record), and I'd much
> prefer that we did the same here.