Re: [PATCH 4/4] x86: save user %rsp in pt_regs->sp

From: Andy Lutomirski
Date: Tue Feb 24 2015 - 17:56:00 EST


On Tue, Feb 24, 2015 at 10:51 AM, Denys Vlasenko <dvlasenk@xxxxxxxxxx> wrote:
> PER_CPU(old_rsp) usage is simplified - now it is used only
> as temp storage, and userspace stack pointer is immediately stored
> in pt_regs->sp on syscall entry, instead of being used later,
> on syscall exit. This allows to get rid of thread_struct::usersp.

I'm not seeing any performance loss here, which is good. This is a
nice cleanup.

> @@ -253,11 +247,13 @@ GLOBAL(system_call_after_swapgs)
> */
> ENABLE_INTERRUPTS(CLBR_NONE)
> ALLOC_PT_GPREGS_ON_STACK 6*8 /* 6*8: space for orig_ax and iret frame */
> + movq %rcx,RIP(%rsp)
> + movq %r11,EFLAGS(%rsp)

> + movq PER_CPU_VAR(old_rsp),%rcx
> + movq %rcx,RSP(%rsp)

It's a bit unfortunate that this adds two instructions instead of just
one. I guess this gets fix when we start using push instead of mov
here. (And, if we use push, then we can fix up the RCX slot for free,
too.)

Acked-by me, but I won't apply it until v2 to avoid messy rebases.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/