All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lai Jiangshan <jiangshanlai@gmail.com>
To: linux-kernel@vger.kernel.org, Borislav Petkov <bp@alien8.de>
Cc: 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>,
	Balbir Singh <sblbir@amazon.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 V4 0/6] x86: Don't abuse tss.sp1
Date: Wed, 10 Feb 2021 21:39:11 +0800	[thread overview]
Message-ID: <20210210133917.2414-1-jiangshanlai@gmail.com> (raw)

From: Lai Jiangshan <laijs@linux.alibaba.com>

In x86_64, tss.sp1 is reused as cpu_current_top_of_stack.  We'd better
directly use percpu since CR3 and gs_base is correct when it is used.

In x86_32, tss.sp1 is resued as thread.sp0 in three places in entry
code.  We have the correct CR3 and %fs at two of the places.  The last
one is sysenter.  This patchset makes %fs available earlier so that
we can also use percpu in sysenter.  And add a percpu cpu_current_thread_sp0
for thread.sp0 instead of tss.sp1

[V3]: https://lore.kernel.org/lkml/20210127163231.12709-1-jiangshanlai@gmail.com/
[V2]: https://lore.kernel.org/lkml/20210125173444.22696-1-jiangshanlai@gmail.com/
[V1]: https://lore.kernel.org/lkml/20210123084900.3118-1-jiangshanlai@gmail.com/

Changed from V3:
	Update subjects as Borislav's imperative request. ^_^
	Update changelog as Borislav suggested.
	Change EXPORT_PER_CPU_SYMBOL to EXPORT_PER_CPU_SYMBOL_GPL.

Changed from V2:
	Add missing "%ss:" reported by Brian Gerst.

Changed from V1:
	Requested from Andy to also fix sp1 for x86_32.
	Update comments in the x86_64 patch as Andy sugguested.

Lai Jiangshan (6):
  x86/entry/64: Move cpu_current_top_of_stack out of TSS
  x86/entry/32: Use percpu instead of offset-calculation to get
    thread.sp0 in SWITCH_TO_KERNEL_STACK
  x86/entry/32: Switch to the task stack without emptying the entry
    stack
  x86/entry/32: Restore %fs before switching stack
  x86/entry/32: Use percpu to get thread.sp0 in SYSENTER
  x86/entry/32: Introduce cpu_current_thread_sp0 to replace
    cpu_tss_rw.x86_tss.sp1

 arch/x86/entry/entry_32.S          | 38 +++++++++++++++++-------------
 arch/x86/include/asm/processor.h   | 12 ++--------
 arch/x86/include/asm/switch_to.h   |  8 +------
 arch/x86/include/asm/thread_info.h |  6 -----
 arch/x86/kernel/asm-offsets.c      |  1 -
 arch/x86/kernel/asm-offsets_32.c   | 10 --------
 arch/x86/kernel/cpu/common.c       | 12 +++++++++-
 arch/x86/kernel/process.c          |  7 ------
 arch/x86/mm/pti.c                  |  7 +++---
 9 files changed, 39 insertions(+), 62 deletions(-)

-- 
2.19.1.6.gb485710b


             reply	other threads:[~2021-02-10 12:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 13:39 Lai Jiangshan [this message]
2021-02-10 13:39 ` [PATCH V4 1/6] x86/entry/64: Move cpu_current_top_of_stack out of TSS Lai Jiangshan
2021-02-10 13:39 ` [PATCH V4 2/6] x86/entry/32: Use percpu instead of offset-calculation to get thread.sp0 in SWITCH_TO_KERNEL_STACK Lai Jiangshan
2021-02-10 13:39 ` [PATCH V4 3/6] x86/entry/32: Switch to the task stack without emptying the entry stack Lai Jiangshan
2021-02-10 13:39 ` [PATCH V4 4/6] x86/entry/32: Restore %fs before switching stack Lai Jiangshan
2021-02-10 13:39 ` [PATCH V4 5/6] x86/entry/32: Use percpu to get thread.sp0 in SYSENTER Lai Jiangshan
2021-02-10 13:39 ` [PATCH V4 6/6] x86/entry/32: Introduce cpu_current_thread_sp0 to replace cpu_tss_rw.x86_tss.sp1 Lai Jiangshan
2021-02-10 23:42 ` [PATCH V4 0/6] x86: Don't abuse tss.sp1 mark gross
2021-02-11  1:51   ` 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=20210210133917.2414-1-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=sblbir@amazon.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.