Re: [PATCH v2] riscv: VMAP_STACK overflow detection thread-safe

From: Sami Tolvanen
Date: Mon Jul 24 2023 - 13:03:55 EST


On Thu, Jul 20, 2023 at 8:10 AM Guo Ren <guoren@xxxxxxxxxx> wrote:
>
> On Thu, Nov 24, 2022 at 5:48 PM Deepak Gupta <debug@xxxxxxxxxxxx> wrote:
> > +.macro asm_per_cpu dst sym tmp
> > + REG_L \tmp, TASK_TI_CPU_NUM(tp)
> > + slli \tmp, \tmp, PER_CPU_OFFSET_SHIFT
> > + la \dst, __per_cpu_offset
> > + add \dst, \dst, \tmp
> > + REG_L \tmp, 0(\dst)
> > + la \dst, \sym
> > + add \dst, \dst, \tmp
> > +.endm
> It's a tricky implementation, and we can't maintain it here because it
> depends on percpu design.

I can certainly understand this concern, but AFAICT this part of the
percpu code hasn't changed in ~14 years, so adding an assembly macro
for the computation shouldn't be a huge maintenance burden. arm64 also
performs a similar computation in assembly (starting with commit
3d8c1a013d78) and I don't see their implementation needing constant
maintenance since then.

Sami