All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	paulmck <paulmck@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Paul Turner <pjt@google.com>,
	linux-api <linux-api@vger.kernel.org>,
	Florian Weimer <fw@deneb.enyo.de>,
	David Laight <David.Laight@ACULAB.COM>,
	carlos <carlos@redhat.com>
Subject: Re: [RFC PATCH v2 1/2] rseq: x86: implement abort-at-ip extension
Date: Wed, 12 Jan 2022 09:47:29 -0500 (EST)	[thread overview]
Message-ID: <1475639366.24565.1641998849957.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20220112084617.32bjjo774n7vvyct@wittgenstein>

----- On Jan 12, 2022, at 3:46 AM, Christian Brauner christian.brauner@ubuntu.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

  reply	other threads:[~2022-01-12 14:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 17:16 [RFC PATCH v2 1/2] rseq: x86: implement abort-at-ip extension Mathieu Desnoyers
2022-01-10 17:16 ` [RFC PATCH v2 2/2] selftests: rseq: test abort-at-ip extension on x86 Mathieu Desnoyers
2022-01-11  5:31 ` [RFC PATCH v2 1/2] rseq: x86: implement abort-at-ip extension kernel test robot
2022-01-11 11:05 ` Christian Brauner
2022-01-11 17:43   ` Mathieu Desnoyers
2022-01-12  8:46     ` Christian Brauner
2022-01-12 14:47       ` Mathieu Desnoyers [this message]
2022-01-12 14:55         ` Christian Brauner
2022-01-12 14:58         ` David Laight
2022-01-12 15:05           ` Mathieu Desnoyers
2022-01-12 15:15             ` David Laight
2022-01-12 15:24               ` Mathieu Desnoyers
2022-01-12 15:34               ` Peter Zijlstra
2022-01-12 15:53                 ` David Laight
2022-01-12 19:03 ` kernel test robot
2022-01-12 19:03   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475639366.24565.1641998849957.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=boqun.feng@gmail.com \
    --cc=brauner@kernel.org \
    --cc=carlos@redhat.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=fw@deneb.enyo.de \
    --cc=hpa@zytor.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.