Skip to content

x86: Don't abuse tss.sp1

Lai Jiangshan lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest6 patches 2 repliesIn review
  2. v36 patches 4 repliesSuperseded
  3. v26 patches 1 replyApplied
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch1 replySuperseded

Changes in v4 from the cover letter

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

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6x86/entry/64: Move cpu_current_top_of_stack out of TSSarch/x86/include/asm/processor.h arch/x86/include/asm/switch_to.h arch/x86/include/asm/thread_info.h +3 more+7 -320 replies
2/6x86/entry/32: Use percpu instead of offset-calculation to get thread.sp0 in SWITCH_TO_KERNEL_STACKarch/x86/entry/entry_32.S+2 -70 replies
3/6x86/entry/32: Switch to the task stack without emptying the entry stackarch/x86/entry/entry_32.S+5 -60 replies
4/6x86/entry/32: Restore %fs before switching stackarch/x86/entry/entry_32.S+17 -50 replies
5/6x86/entry/32: Use percpu to get thread.sp0 in SYSENTERarch/x86/entry/entry_32.S arch/x86/kernel/asm-offsets_32.c+1 -110 replies
6/6x86/entry/32: Introduce cpu_current_thread_sp0 to replace cpu_tss_rw.x86_tss.sp1arch/x86/entry/entry_32.S arch/x86/include/asm/processor.h arch/x86/include/asm/switch_to.h +3 more+14 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH V4 0/6] x86: Don't abuse tss.sp1

From: Lai Jiangshan <[email protected]>

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/[email protected]/
[V2]: https://lore.kernel.org/lkml/[email protected]/
[V1]: https://lore.kernel.org/lkml/[email protected]/

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(-)
Signature · 1 line
2.19.1.6.gb485710b