All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Florian Weimer <fw@deneb.enyo.de>,
	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>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	carlos <carlos@redhat.com>
Subject: Re: [RFC PATCH] rseq: x86: implement abort-at-ip extension
Date: Fri, 7 Jan 2022 20:08:10 -0500 (EST)	[thread overview]
Message-ID: <333385690.14559.1641604090435.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <701ff3888b3f42f4a6a1dded84b79078@AcuMS.aculab.com>

----- On Jan 7, 2022, at 5:27 PM, David Laight David.Laight@ACULAB.COM wrote:

>> That being said, there might be an architecture agnostic alternative available.
>> On abort of a RSEQ_CS_FLAG_ABORT_AT_IP critical section, we could let the kernel
>> decrement/increment the stack pointer to make room for a pointer (depending if
>> the
>> stack grows down or up). It would then store the abort-at-ip value at the top of
>> stack.
> 
> Stack redzone in a leaf function?

Good point!

For x86-64 for instance, which has a redzone of 128 bytes, there are a few alternatives.
On abort:

Approach A) Move the stack pointer as little as possible

   1. On abort in kernel:
   1.1 Subtract 8 bytes from the stack pointer
   1.2 Store the abort-at-ip value at stack pointer - 128
   2. In abort handler (userspace)
   2.1 user-space knows that it can find the abort-at-ip value at stack pointer - 128
   2.2 after using that value, the abort handler needs to add 8 bytes to the stack pointer

Approach B) Move the stack pointer to skip the entire redzone

   1. On abort in kernel:
   1.1 Subtract 128 bytes from the stack pointer
   1.2 Store the abort-at-ip value at stack pointer - 8 (basically within a new red zone)
   2. In abort handler (userspace)
   2.1 user-space knows that it can find the abort-at-ip value at stack pointer - 8
   2.2 after using that value, the abort handler needs to add 128 bytes to the stack pointer

I suspect both approaches should work.

Any preference or other ideas ?

Thanks,

Mathieu

> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT,
> UK
> Registration No: 1397386 (Wales)

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2022-01-08  1:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07 17:03 [RFC PATCH] rseq: x86: implement abort-at-ip extension Mathieu Desnoyers
2022-01-07 19:31 ` Florian Weimer
2022-01-07 19:48   ` Mathieu Desnoyers
2022-01-07 21:27     ` Mathieu Desnoyers
2022-01-07 22:27       ` David Laight
2022-01-08  1:08         ` Mathieu Desnoyers [this message]
2022-01-08  1:33           ` Mathieu Desnoyers
2022-01-08  1:33           ` Mathieu Desnoyers
2022-01-12 15:16     ` Florian Weimer
2022-01-12 15:26       ` Mathieu Desnoyers
2022-01-12 15:38       ` Peter Zijlstra
2022-01-12 16:00         ` Florian Weimer
2022-01-12 16:38           ` Mathieu Desnoyers
2022-01-12 21:00             ` Florian Weimer
2022-01-12 21:24               ` Mathieu Desnoyers

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=333385690.14559.1641604090435.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=boqun.feng@gmail.com \
    --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.