[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1475639366.24565.1641998849957.JavaMail.zimbra@efficios.com>
Date: Wed, 12 Jan 2022 09:47:29 -0500 (EST)
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Christian Brauner <christian.brauner@...ntu.com>
Cc: Christian Brauner <brauner@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
paulmck <paulmck@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
"H. Peter Anvin" <hpa@...or.com>, Paul Turner <pjt@...gle.com>,
linux-api <linux-api@...r.kernel.org>,
Florian Weimer <fw@...eb.enyo.de>,
David Laight <David.Laight@...LAB.COM>,
carlos <carlos@...hat.com>
Subject: Re: [RFC PATCH v2 1/2] rseq: x86: implement abort-at-ip extension
----- On Jan 12, 2022, at 3:46 AM, Christian Brauner christian.brauner@...ntu.com wrote:
> On Tue, Jan 11, 2022 at 12:43:05PM -0500, Mathieu Desnoyers wrote:
[...]
>> >> + *
>> >> + * rseq critical sections defined with the RSEQ_CS_FLAG_ABORT_AT_IP flag
>> >> + * have the following behavior on abort: when the stack grows down: the
>> >> + * stack pointer is decremented to skip the redzone, and decremented of
>> >> + * the pointer size. The aborted address (abort-at-ip) is stored at
>> >> + * this stack pointer location. The user-space abort handler needs to
>> >> + * pop the abort-at-ip address from the stack, and add the redzone size
>> >> + * to the stack pointer.
>> >> + *
>> >> + * TODO: describe stack grows up.
>> >
>> > Is this intentional or did you forget? :)
>>
>> Since I did not implement abort-at-ip on stack-grows-up architectures, I felt
>> it would be too early to describe the algorithm. I can simply remove the TODO
>> altogether and we'll take care of it when we get there ? If I had to try to
>> wordsmith it, it would look like e.g.:
>>
>> * [...] When the stack grows up: the
>> * stack pointer is incremented to skip the redzone, and incremented of
>> * the pointer size. The aborted address (abort-at-ip) is stored immediately
>> * under this stack pointer location. The user-space abort handler needs to
>> * pop the abort-at-ip address from the stack, and subtract the redzone size
>> * from the stack pointer.
>>
>> [ Please let me know if I got somehow confused in my understanding of stack
>> grows
>> up architectures. ]
>>
>> I'm also unsure whether any of the stack grows up architecture have redzones ?
>
> I don't think so? From when I last touched that piece of arch code when
> massaging copy_thread() I only remember parisc as having an upwards
> growing stack.
>
>> From a quick grep for redzone in Linux arch/, only openrisc, powerpc64 and
> > x86-64 appear to have redzones.
I figured it was kind of silly to special-case arch-agnostic comments for stack
grows up/down, how about the following instead ?
* rseq critical sections defined with the RSEQ_CS_FLAG_ABORT_AT_IP flag
* have the following behavior on abort: the stack pointer is adjusted to
* skip over the redzone [*], and the aborted address (abort-at-ip) is pushed
* at this stack pointer location. The user-space abort handler needs to pop
* the abort-at-ip address from the stack, and adjust the stack pointer to skip
* back over the redzone.
*
* [*] The openrisc, powerpc64 and x86-64 architectures define a "redzone" as a
* stack area beyond the stack pointer which can be used by the compiler
* to store local variables in leaf functions.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
Powered by blists - more mailing lists