On Fri, Jun 23, 2023 at 06:28:12PM +0100, Catalin Marinas wrote:
On Thu, Jun 22, 2023 at 06:11:20PM +0100, Mark Brown wrote:
TPIDR2 is intended to go along with the thread stack, it's intended to be used to allow lazy save of the (rather large) ZA register state when a called function needs it rather than forcing it to be caller saved. TPIDR2 is used to point to memory allocated for managing this process, something that provides a new value should be making a deliberate decision to do so and editing the stack frame.
OK, so if the signal handler invokes a function that touches the ZA state, it may use TPIDR2 for lazy saving in any callee. In this case we need to restore the original TPIDR2 of the interrupted context on sigreturn.
Yeah, or if something tries to sigreturn to a previously saved context which had live TPIDR2 state things might end up unfortunate.
So I convinced myself this is the only option that makes sense ;). I'll queue the patches.
Thanks.