From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lai Jiangshan <laijs@linux.alibaba.com>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Joerg Roedel <jroedel@suse.de>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Gabriel Krisman Bertazi <krisman@collabora.com>,
Kees Cook <keescook@chromium.org>,
Frederic Weisbecker <frederic@kernel.org>,
Jens Axboe <axboe@kernel.dk>,
Arvind Sankar <nivedita@alum.mit.edu>,
Brian Gerst <brgerst@gmail.com>, Ard Biesheuvel <ardb@kernel.org>,
Andi Kleen <ak@linux.intel.com>, Mike Rapoport <rppt@kernel.org>,
Mike Hommey <mh@glandium.org>,
Mark Gross <mgross@linux.intel.com>,
Fenghua Yu <fenghua.yu@intel.com>,
Tony Luck <tony.luck@intel.com>,
Anthony Steinhauser <asteinhauser@google.com>,
Jay Lang <jaytlang@mit.edu>,
"Chang S. Bae" <chang.seok.bae@intel.com>
Subject: [PATCH V2 4/6] x86_32/sysenter: restore %fs before switching stack
Date: Tue, 26 Jan 2021 01:34:32 +0800 [thread overview]
Message-ID: <20210125173444.22696-5-jiangshanlai@gmail.com> (raw)
In-Reply-To: <20210125173444.22696-1-jiangshanlai@gmail.com>
From: Lai Jiangshan <laijs@linux.alibaba.com>
Prepare for using percpu and removing TSS_entry2task_stack
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
---
arch/x86/entry/entry_32.S | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 4513702ba45d..a8d2640394f9 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -279,11 +279,13 @@
.Lfinished_frame_\@:
.endm
-.macro SAVE_ALL pt_regs_ax=%eax switch_stacks=0 skip_gs=0 unwind_espfix=0
+.macro SAVE_ALL pt_regs_ax=%eax switch_stacks=0 skip_gs=0 skip_fs=0 unwind_espfix=0
cld
.if \skip_gs == 0
PUSH_GS
.endif
+
+.if \skip_fs == 0
pushl %fs
pushl %eax
@@ -293,6 +295,7 @@
UNWIND_ESPFIX_STACK
.endif
popl %eax
+.endif
FIXUP_FRAME
pushl %es
@@ -906,18 +909,27 @@ SYM_FUNC_START(entry_SYSENTER_32)
BUG_IF_WRONG_CR3 no_user_check=1
SWITCH_TO_KERNEL_CR3 scratch_reg=%eax
+ /* Restore kernel %fs, so that we can use PERCPU */
+ pushl %fs
+ movl $(__KERNEL_PERCPU), %eax
+ movl %eax, %fs
+
/* Switch to task stack */
movl %esp, %eax
- movl (2*4+TSS_entry2task_stack)(%esp), %esp
+ movl (3*4+TSS_entry2task_stack)(%esp), %esp
.Lsysenter_past_esp:
pushl $__USER_DS /* pt_regs->ss */
pushl $0 /* pt_regs->sp (placeholder) */
- pushl 4(%eax) /* pt_regs->flags (except IF = 0) */
+ pushl 8(%eax) /* pt_regs->flags (except IF = 0) */
pushl $__USER_CS /* pt_regs->cs */
pushl $0 /* pt_regs->ip = 0 (placeholder) */
- pushl (%eax) /* pt_regs->orig_ax */
- SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest, stack already switched */
+ pushl 4(%eax) /* pt_regs->orig_ax */
+ PUSH_GS /* pt_regs->gs */
+ pushl (%eax) /* pt_regs->fs */
+ /* save rest, stack and %fs already switched */
+ SAVE_ALL pt_regs_ax=$-ENOSYS skip_gs=1 skip_fs=1
+ SET_KERNEL_GS %edx
/*
* SYSENTER doesn't filter flags, so we need to clear NT, AC
--
2.19.1.6.gb485710b
next prev parent reply other threads:[~2021-01-25 16:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-23 8:48 [PATCH] x86_64: move cpu_current_top_of_stack out of TSS Lai Jiangshan
2021-01-25 2:24 ` Andy Lutomirski
2021-01-25 17:34 ` [PATCH V2 0/6] x86: don't abuse tss.sp1 Lai Jiangshan
2021-01-25 17:34 ` [PATCH V2 1/6] x86_64: move cpu_current_top_of_stack out of TSS Lai Jiangshan
2021-03-28 20:46 ` [tip: x86/cleanups] x86/process/64: Move " tip-bot2 for Lai Jiangshan
2021-01-25 17:34 ` [PATCH V2 2/6] x86_32: use percpu instead of offset-calculation to get thread.sp0 when SWITCH_TO_KERNEL_STACK Lai Jiangshan
2021-01-25 17:34 ` [PATCH V2 3/6] x86_32/sysenter: switch to the task stack without emptying the entry stack Lai Jiangshan
2021-01-26 6:04 ` Brian Gerst
2021-01-25 17:34 ` Lai Jiangshan [this message]
2021-01-25 17:34 ` [PATCH V2 5/6] x86_32/sysenter: use percpu to get thread.sp0 when sysenter Lai Jiangshan
2021-01-25 17:34 ` [PATCH V2 6/6] x86_32: use cpu_current_thread_sp0 instead of cpu_tss_rw.x86_tss.sp1 Lai Jiangshan
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=20210125173444.22696-5-jiangshanlai@gmail.com \
--to=jiangshanlai@gmail.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=asteinhauser@google.com \
--cc=axboe@kernel.dk \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=frederic@kernel.org \
--cc=hpa@zytor.com \
--cc=jaytlang@mit.edu \
--cc=jroedel@suse.de \
--cc=keescook@chromium.org \
--cc=krisman@collabora.com \
--cc=laijs@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mgross@linux.intel.com \
--cc=mh@glandium.org \
--cc=mingo@redhat.com \
--cc=nivedita@alum.mit.edu \
--cc=peterz@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=rppt@kernel.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vincenzo.frascino@arm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).