From: Borislav Petkov <bp@alien8.de>
To: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Lai Jiangshan <laijs@linux.alibaba.com>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
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: Re: [PATCH V3 2/6] x86_32: use percpu instead of offset-calculation to get thread.sp0 when SWITCH_TO_KERNEL_STACK
Date: Mon, 8 Feb 2021 20:21:09 +0100 [thread overview]
Message-ID: <20210208192109.GH18227@zn.tnic> (raw)
In-Reply-To: <20210127163231.12709-3-jiangshanlai@gmail.com>
On Thu, Jan 28, 2021 at 12:32:18AM +0800, Lai Jiangshan wrote:
> From: Lai Jiangshan <laijs@linux.alibaba.com>
>
> TSS_entry2task_stack is used to refer to tss.sp1 which is stored the value
> of thread.sp0.
"... which is a copy of thread.sp0."
>
> At the code where TSS_entry2task_stack is used in SWITCH_TO_KERNEL_STACK,
"TSS_entry2task_stack is used in SWITCH_TO_KERNEL_STACK and CR3 is
already... "
> the CR3 is already kernel CR3 and kernel segments is loaded.
>
> So we can directly use the percpu to get tss.sp1(thread.sp0) instead of
Who's "we"?
> the complex offset-calculation.
>
> Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
> ---
> arch/x86/entry/entry_32.S | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
> index df8c017e6161..3b4d1a63d1f0 100644
> --- a/arch/x86/entry/entry_32.S
> +++ b/arch/x86/entry/entry_32.S
> @@ -465,16 +465,11 @@
> cmpl $SIZEOF_entry_stack, %ecx
> jae .Lend_\@
>
> - /* Load stack pointer into %esi and %edi */
> + /* Load stack pointer into %esi */
> movl %esp, %esi
> - movl %esi, %edi
> -
> - /* Move %edi to the top of the entry stack */
> - andl $(MASK_entry_stack), %edi
> - addl $(SIZEOF_entry_stack), %edi
>
> /* Load top of task-stack into %edi */
> - movl TSS_entry2task_stack(%edi), %edi
> + movl PER_CPU_VAR(cpu_tss_rw + TSS_sp1), %edi
>
> /* Special case - entry from kernel mode via entry stack */
> #ifdef CONFIG_VM86
> --
The change itself looks ok.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2021-02-08 20:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 16:32 [PATCH V3 0/6] x86: don't abuse tss.sp1 Lai Jiangshan
2021-01-27 16:32 ` [PATCH V3 1/6] x86_64: move cpu_current_top_of_stack out of TSS Lai Jiangshan
2021-02-04 16:46 ` Borislav Petkov
2021-01-27 16:32 ` [PATCH V3 2/6] x86_32: use percpu instead of offset-calculation to get thread.sp0 when SWITCH_TO_KERNEL_STACK Lai Jiangshan
2021-02-08 19:21 ` Borislav Petkov [this message]
2021-01-27 16:32 ` [PATCH V3 3/6] x86_32/sysenter: switch to the task stack without emptying the entry stack Lai Jiangshan
2021-01-27 16:32 ` [PATCH V3 4/6] x86_32/sysenter: restore %fs before switching stack Lai Jiangshan
2021-01-27 16:32 ` [PATCH V3 5/6] x86_32/sysenter: use percpu to get thread.sp0 when sysenter Lai Jiangshan
2021-01-27 16:32 ` [PATCH V3 6/6] x86_32: use cpu_current_thread_sp0 instead of cpu_tss_rw.x86_tss.sp1 Lai Jiangshan
[not found] ` <CAJhGHyA1U9M2Lv_=Wa2NPzBNevZKOrLaG1FDwbmySMOR_x_GRQ@mail.gmail.com>
2021-01-29 16:43 ` [PATCH V3 0/6] x86: don't abuse tss.sp1 Borislav Petkov
2021-01-30 2:53 ` 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=20210208192109.GH18227@zn.tnic \
--to=bp@alien8.de \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=asteinhauser@google.com \
--cc=axboe@kernel.dk \
--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=jiangshanlai@gmail.com \
--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
all inboxes | Powered by JetHome®