RE: [RFC PATCH v2 1/2] rseq: x86: implement abort-at-ip extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Zijlstra 
> Sent: 12 January 2022 15:34
> 
> On Wed, Jan 12, 2022 at 03:15:27PM +0000, David Laight wrote:
> > From: Mathieu Desnoyers
> > > Sent: 12 January 2022 15:06
> > >
> > > ----- On Jan 12, 2022, at 9:58 AM, David Laight David.Laight@xxxxxxxxxx wrote:
> > >
> > > >>  * [*] 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.
> > > >
> > > > I wonder if that is really worth the trouble it causes!
> > > > By the time a function is spilling values to stack the cost
> > > > of a %sp update is almost certainly noise.
> > > >
> > > > Someone clearly thought it was a 'good idea (tm)'.
> > >
> > > I must admit that I've been surprised to learn about these redzones. Thanks for
> > > pointing them out to me, it was clearly a blind spot. I suspect it would be useful
> > > to introduce per-architecture KERNEL_REDZONE, USER_REDZONE and COMPAT_USER_REDZONE
> > > with a asm-generic version defining them to 0, with proper documentation. It would
> > > make it clearer to kernel developers working on stuff similar to signal handler
> > > delivery that they need to consider these carefully.
> >
> > They can never be used in kernel - any ISR would overwrite them.
> 
> That depends on how the architecture does exceptions;

True, many newer ones don't actually write anything to the stack.
Makes the cpu simpler.

> also consider:
> 
>   https://www.intel.com/content/www/us/en/develop/download/flexible-return-and-event-delivery-
> specification.html

That contains the snippet:
	The SWAPGS instruction supports efficient updates of the GS base address.

Which is just so horribly not true...
Even FRED is always doing a GS swap - so you can easily lose the kernel GS value.

I remember fixing all the 'in kernel' faults in the netbsd x86-64 return to user path.
Entirely horrid...

	David

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




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux