Skip to content

x86: A round of x86 segmentation improvements

Andy Lutomirski lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8x86/asm: Stop depending on ptrace.h in alternative.harch/x86/include/asm/alternative.h arch/x86/include/asm/kgdb.h arch/x86/include/asm/setup.h +8 more+50 -330 replies
2/8x86/asm: Make asm/alternative.h safe from assemblyarch/x86/include/asm/alternative.h+4 -00 replies
3/8x86/segments/64: When loadsegment(fs, ...) fails, clear the basearch/x86/include/asm/segment.h arch/x86/kernel/cpu/common.c arch/x86/mm/extable.c+50 -40 replies
4/8x86/segments/64: When load_gs_index fails, clear the basearch/x86/entry/entry_64.S+6 -00 replies
5/8x86/arch_prctl/64: Remove FSBASE/GSBASE < 4G optimizationarch/x86/include/asm/segment.h arch/x86/kernel/process_64.c arch/x86/kernel/ptrace.c+17 -1052 replies
6/8x86/asm/64: Rename thread_struct's fs and gs to fsbase and gsbasearch/x86/include/asm/elf.h arch/x86/include/asm/processor.h arch/x86/kernel/process_64.c +2 more+32 -250 replies
7/8x86/tls: Synchronize segment registers in set_thread_areaarch/x86/kernel/tls.c+42 -00 replies
8/8selftests/x86/ldt_gdt: Test set_thread_area deletion of an active segmenttools/testing/selftests/x86/ldt_gdt.c+250 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/8] x86: A round of x86 segmentation improvements

Hi all-

This is preparation for enabling FSGSBASE and fixing FS/GS switching better than my last attempt.

It cleans up the code, fixes two more holes in X86_BUG_NULL_SEG handling (loadsegment(fs, val) and load_gs_index(val) failure handling), and makes set_thread_area behave in a well-defined manner.

With these patches applied, modify_ldt should be the last remaining way for a user thread to get its cached descriptors out of sync with memory, except in the 64-bit FS/GS < 3 case. I'll fix modify_ldt as well, but those patches will come later.

I'm sending these now because they seem to be good improvements on their own and it'll help avoid a monster patch series down the road.

Tested on x86_32 with and without lazy GS and on x86_64.

Andy Lutomirski (8):
x86/asm: Stop depending on ptrace.h in alternative.h x86/asm: Make asm/alternative.h safe from assembly x86/segments/64: When loadsegment(fs, ...) fails, clear the base x86/segments/64: When load_gs_index fails, clear the base x86/arch_prctl/64: Remove FSBASE/GSBASE < 4G optimization x86/asm/64: Rename thread_struct's fs and gs to fsbase and gsbase x86/tls: Synchronize segment registers in set_thread_area selftests/x86/ldt_gdt: Test set_thread_area deletion of an active
segment

 arch/x86/entry/entry_64.S             |   6 +
 arch/x86/include/asm/alternative.h    |  35 +----
 arch/x86/include/asm/elf.h            |   6 +-
 arch/x86/include/asm/kgdb.h           |   2 +
 arch/x86/include/asm/processor.h      |  11 +-
 arch/x86/include/asm/segment.h        |  49 +++++--
 arch/x86/include/asm/setup.h          |   1 +
 arch/x86/include/asm/text-patching.h  |  40 ++++++
 arch/x86/kernel/alternative.c         |   1 +
 arch/x86/kernel/cpu/common.c          |   2 +-
 arch/x86/kernel/jump_label.c          |   1 +
 arch/x86/kernel/kgdb.c                |   1 +
 arch/x86/kernel/kprobes/core.c        |   1 +
 arch/x86/kernel/kprobes/opt.c         |   1 +
 arch/x86/kernel/module.c              |   1 +
 arch/x86/kernel/process_64.c          |  97 ++++---------
 arch/x86/kernel/ptrace.c              |  48 ++-----
 arch/x86/kernel/tls.c                 |  42 ++++++
 arch/x86/kernel/traps.c               |   1 +
 arch/x86/kvm/svm.c                    |   2 +-
 arch/x86/mm/extable.c                 |  10 ++
 tools/testing/selftests/x86/ldt_gdt.c | 250 ++++++++++++++++++++++++++++++++++
 22 files changed, 446 insertions(+), 162 deletions(-)
 create mode 100644 arch/x86/include/asm/text-patching.h
Signature · 1 line
2.5.5