[PATCH] powerpc64: Workaround sigtramp vdso return call.
Paul E Murphy
murphyp@linux.ibm.com
Tue Jan 26 14:45:00 GMT 2021
On 1/26/21 8:12 AM, Florian Weimer via Libc-alpha wrote:
> * Raoni Fassina Firmino:
>
>> A not so recent kernel change[1] changed how the trampoline
>> `__kernel_sigtramp_rt64` is used to call signal handlers.
>>
>> This was exposed on the test misc/tst-sigcontext-get_pc
>>
>> Before kernel 5.9, the kernel set LR to the trampoline address and
>> jumped directly to the signal handler, and at the end the signal
>> handler, as any other function, would `blr` to the address set. In
>> other words, the trampoline was executed just at the end of the signal
>> handler and the only thing it did was call sigreturn. But since
>> kernel 5.9 the kernel set CTRL to the signal handler and calls to the
>> trampoline code, the trampoline then `bctrl` to the address in CTRL,
>> setting the LR to the next instruction in the middle of the
>> trampoline, when the signal handler returns, the rest of the
>> trampoline code executes the same code as before.
>
> Thanks for the patch, byt:
>
> No one has explained so far why the original blr instruction couldn't be
> augmented with the appropriate branch predictor hint. The 2.07 ISA
> manual suggests that it's possible, but maybe I'm reading it wrong.
bctrl is the preferred form of making indirect calls. You can add hint
0b01 to bclr (blr) to get similar behavior on power8/9, but as noted in
the ISA, it is optional.
More information about the Libc-alpha
mailing list