On Mon, Jan 25, 2021 at 11:35 AM Lai Jiangshan <jiangshan...@gmail.com> wrote: > > From: Lai Jiangshan <la...@linux.alibaba.com> > > Like the way x86_64 uses the "old" stack, we can save the entry stack > pointer to a register and switch to the task stack. So that we have > space on the "old" stack to save more things or scratch registers. > > Signed-off-by: Lai Jiangshan <la...@linux.alibaba.com> > --- > arch/x86/entry/entry_32.S | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S > index 3b4d1a63d1f0..4513702ba45d 100644 > --- a/arch/x86/entry/entry_32.S > +++ b/arch/x86/entry/entry_32.S > @@ -905,19 +905,18 @@ SYM_FUNC_START(entry_SYSENTER_32) > pushl %eax > BUG_IF_WRONG_CR3 no_user_check=1 > SWITCH_TO_KERNEL_CR3 scratch_reg=%eax > - popl %eax > - popfl > > - /* Stack empty again, switch to task stack */ > - movl TSS_entry2task_stack(%esp), %esp > + /* Switch to task stack */ > + movl %esp, %eax > + movl (2*4+TSS_entry2task_stack)(%esp), %esp > > .Lsysenter_past_esp: > pushl $__USER_DS /* pt_regs->ss */ > pushl $0 /* pt_regs->sp (placeholder) */ > - pushfl /* pt_regs->flags (except IF = 0) */ > + pushl 4(%eax) /* pt_regs->flags (except IF = 0) */
__KERNEL_DS isn't loaded at this point, so this needs an explicit %ss: override. You probably didn't catch this because the default __USER_DS was still loaded. > pushl $__USER_CS /* pt_regs->cs */ > pushl $0 /* pt_regs->ip = 0 (placeholder) */ > - pushl %eax /* pt_regs->orig_ax */ > + pushl (%eax) /* pt_regs->orig_ax */ Add an %ss: override here too. > SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest, stack already switched > */ > > /* > -- > 2.19.1.6.gb485710b > -- Brian Gerst