x86/asm changes for v4.1
Subsystems (16)
Linus,
Please pull the latest x86-asm-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-asm-for-linus
# HEAD: 3b75232d55680ca166dffa274d0587d5faf0a016 perf/x86/64: Report regs_user->ax too in get_regs_user()
There were lots of changes in this development cycle:
- over 100 separate cleanups, restructuring changes, speedups and fixes in the x86 system call, irq, trap and other entry code, part of a heroic effort to deobfuscate a decade old spaghetti asm code and its C code dependencies. (Denys Vlasenko, Andy Lutomirski)
- alternatives code fixes and enhancements (Borislav Petkov)
- simplifications and cleanups to the compat code. (Brian Gerst)
- signal handling fixes and new x86 testcases. (Andy Lutomirski)
- various other fixes and cleanups
By their nature many of these changes are risky - we tried to test them well on many different x86 systems (there are no known regressions), and they are split up finely to help bisection - but there's still a fair bit of residual risk left so caveat emptor.
out-of-topic modifications in x86-asm-for-linus:
--------------------------------------------------
drivers/misc/sgi-xp/xpc_main.c # f39b6f0ef855: x86/asm/entry: Change all 'u
include/linux/stddef.h # 3876488444e7: include/stddef.h: Move offse
include/linux/vfio.h # 3876488444e7: include/stddef.h: Move offse
tools/perf/bench/mem-memcpy-x86-64-asm-def.h# 0cf55934ecac: perf/bench: Fix mem* routine
tools/perf/bench/mem-memcpy-x86-64-asm.S# 0cf55934ecac: perf/bench: Fix mem* routine
tools/perf/bench/mem-memcpy.c # dfecb95cdfea: perf/bench: Add -r all so th
# 515e23f0193f: perf/bench: Carve out mem ro tools/perf/bench/mem-memset-x86-64-asm-def.h# 0cf55934ecac: perf/bench: Fix mem* routine tools/perf/bench/mem-memset-x86-64-asm.S# 0cf55934ecac: perf/bench: Fix mem* routine tools/perf/util/include/asm/alternative-asm.h# 0cf55934ecac: perf/bench: Fix mem* routine
tools/testing/selftests/Makefile # 3f705dfdf85a: x86, selftests: Add sigretur
tools/testing/selftests/x86/.gitignore# 3f705dfdf85a: x86, selftests: Add sigretur tools/testing/selftests/x86/Makefile# 3f705dfdf85a: x86, selftests: Add sigretur tools/testing/selftests/x86/run_x86_tests.sh# 3f705dfdf85a: x86, selftests: Add sigretur tools/testing/selftests/x86/sigreturn.c# 3f705dfdf85a: x86, selftests: Add sigretur tools/testing/selftests/x86/trivial_32bit_program.c# 3f705dfdf85a: x86, selftests: Add sigretur
Thanks,
Ingo
------------------>
Alexander Kuleshov (2):
x86/asm/boot: Fix path in comments
x86/asm/boot: Use already defined KEEP_SEGMENTS macro in head_{32,64}.S
Andy Lutomirski (31):
x86/asm/decoder: Fix and enforce max instruction size in the insn decoder x86/ptrace: Remove checks for TIF_IA32 when changing CS and SS x86/ia32-compat: Fix CLONE_SETTLS bitness of copy_thread() x86/asm/entry/64: Remove 'int_check_syscall_exit_work' x86/asm/entry/64: Remove a bogus 'ret_from_fork' optimization x86/asm/entry: Add this_cpu_sp0() to read sp0 for the current cpu x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0() x86/asm/entry/64/compat: Change the 32-bit sysenter code to use sp0 x86/asm/entry: Rename 'init_tss' to 'cpu_tss'
x86/asm/entry: Remove INIT_TSS and fold the definitions into 'cpu_tss' x86/asm/entry: Rename 'INIT_TSS_IST' to 'CPU_TSS_IST'
x86/asm/entry: Delay loading sp0 slightly on task switch
x86/asm/entry: Replace this_cpu_sp0() with current_top_of_stack() and fix it on x86_32 x86/signal/64: Fix SS handling for signals delivered to 64-bit programs x86/signal/64: Remove 'fs' and 'gs' from sigcontext
x86/asm/entry: Create and use a 'TOP_OF_KERNEL_STACK_PADDING' macro x86/asm/entry: Unify and fix initial thread_struct::sp0 values x86/asm/entry/32: Document our abuse of x86_hw_tss::ss1 and x86_hw_tss::sp1 x86/mm/fault: Use TASK_SIZE_MAX in is_prefetch()
x86/asm/entry, perf: Fix incorrect TIF_IA32 check in code_segment_base() x86/asm/entry: Add user_mode_ignore_vm86()
x86/asm/entry, perf: Explicitly optimize vm86 handling in code_segment_base() x86/asm/entry: Use user_mode_ignore_vm86() where appropriate x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode x86/asm/entry: Change all 'user_mode_vm()' calls to 'user_mode()' x86/asm/entry: Remove user_mode_vm()
x86/asm/entry: Replace some open-coded VM86 checks with v8086_mode() checks x86/asm/entry/32: Improve a TOP_OF_KERNEL_STACK_PADDING comment x86/asm/entry/32: Stop caching MSR_IA32_SYSENTER_ESP in tss.sp1 x86/asm/entry/64/compat: Use SYSRETL to return from compat mode SYSENTER x86, selftests: Add sigreturn selftest
Boris Ostrovsky (1):
x86/cpu: Factor out common CPU initialization code, fix 32-bit Xen PV guests
Borislav Petkov (24):
x86/lib/copy_user_64.S: Remove FIX_ALIGNMENT define x86/alternatives: Cleanup DPRINTK macro x86/alternatives: Add instruction padding x86/alternatives: Make JMPs more robust x86/alternatives: Use optimized NOPs for padding x86/lib/copy_page_64.S: Use generic ALTERNATIVE macro x86/lib/copy_user_64.S: Convert to ALTERNATIVE_2 x86/smap: Use ALTERNATIVE macro
x86/entry_32: Convert X86_INVD_BUG to ALTERNATIVE macro x86/lib/clear_page_64.S: Convert to ALTERNATIVE_2 macro x86/asm: Use alternative_2() in rdtsc_barrier() x86/asm: Cleanup prefetch primitives x86/lib/memset_64.S: Convert to ALTERNATIVE_2 macro x86/lib/memmove_64.S: Convert memmove() to ALTERNATIVE macro x86/lib/memcpy_64.S: Convert memcpy to ALTERNATIVE_2 macro perf/bench: Fix mem* routines usage after alternatives change perf/bench: Carve out mem routine benchmarking perf/bench: Add -r all so that you can run all mem* routines x86/asm/entry: Drop now unused ENABLE_INTERRUPTS_SYSEXIT32 x86/mm/KASLR: Propagate KASLR status to kernel proper x86/asm/entry/64: Fix MSR_IA32_SYSENTER_CS MSR value x86/asm/entry/64: Use a define for an invalid segment selector x86/alternatives: Fix ALTERNATIVE_2 padding generation properly x86/alternatives: Guard NOPs optimization
Brian Gerst (5):
x86/compat: Remove compat_ni_syscall()
x86/compat: Merge native and compat 32-bit syscall tables x86/compat: Remove sys32_vm86_warning
x86/asm/entry: Fix execve() and sigreturn() syscalls to always return via IRET x86/signal: Remove pax argument from restore_sigcontext
Denys Vlasenko (69):
x86/asm/decoder: Create artificial 3rd byte for 2-byte VEX
x86/asm/decoder: Explain CALLW discrepancy between Intel and AMD x86/asm/64: Open-code register save/restore in trace_hardirqs*() thunks x86/asm: Introduce push/pop macros which generate CFI_REL_OFFSET and CFI_RESTORE x86/asm/entry/64: Fix incorrect symbolic constant usage: R11->ARGOFFSET x86/asm/entry/64: Always allocate a complete "struct pt_regs" on the kernel stack x86/asm/entry/64: Fix comments
x86/asm/entry/64: Shrink code in 'paranoid_exit'
x86/asm/entry: Do mass removal of 'ARGOFFSET'
x86/asm/entry: Add comments about various syscall instructions x86/asm/entry/64: Move 'save_paranoid' and 'ret_from_fork' closer to their users x86/asm/entry/64: Clean up and document various entry code details x86/asm/entry/64/compat: Fold the IA32_ARG_FIXUP macro into its callers x86/asm/entry/64: Use more readable constants
x86/asm/entry/64/compat: Use more readable constant
x86/asm/entry/64: Simplify optimistic SYSRET
x86/asm: Optimize unnecessarily wide TEST instructions
x86/asm/entry/64: Save R11 into pt_regs->flags on SYSCALL64 fastpath x86/asm/entry/64: Remove stub_iopl
x86/asm/entry/64: Save user RSP in pt_regs->sp on SYSCALL64 fastpath x86/asm/entry: Simplify task_pt_regs() macro definition
include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header x86/asm/entry/32: Document the 32-bit SYSENTER "emergency stack" better x86/asm/entry/64: Enable interrupts *after* we fetch PER_CPU_VAR(old_rsp) x86/asm/entry/64: Fix incorrect comment
x86/asm/entry/64: Fold syscall32_cpu_init() into its sole user x86/asm/entry/64: Change the THREAD_INFO() definition to not depend on KERNEL_STACK_OFFSET x86/asm/entry: Get rid of KERNEL_STACK_OFFSET
x86/asm/entry/64: Use PUSH instructions to build pt_regs on stack x86/asm/entry/64: Get rid of the FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK macros x86/asm/entry/64: Get rid of int_ret_from_sys_call_fixup
x86/asm: Deobfuscate segment.h
x86/asm/entry/64: Use better label name, fix comments
x86/asm/entry/64: Use smaller instructions
x86/irq/tracing: Move ARCH_LOCKDEP_SYS_EXIT defines closer to their users x86/irq/tracing: Fold ARCH_LOCKDEP_SYS_EXIT defines into their users x86/irq/tracing: Do not save callee-preserved registers around lockdep_sys_exit_thunk x86/asm/entry/64: Fix comment about SYSENTER MSRs
x86/asm/entry/64: Add missing CFI annotation
x86/asm/entry/32: Update "interrupt off" comments
x86/asm/entry/32: Make register zero-extension more prominent x86/asm/entry/64: Move retint_kernel code block closer to its user x86/asm/entry/64: Do not GET_THREAD_INFO() too early
x86/asm/entry/64: Do not TRACE_IRQS fast SYSRET64 path
x86/asm/entry/32: Use smaller PUSH instructions instead of MOV, to build 'pt_regs' on stack x86/asm/entry/64: Simplify retint_kernel label usage, make retint_restore_args label local x86/asm/entry/64: Remove redundant DISABLE_INTERRUPTS()
x86/asm/entry/64: Simplify looping around preempt_schedule_irq()
x86/asm: Replace "MOVQ $imm, %reg" with MOVL
x86/asm/entry/64: Use local label to skip around sycall dispatch x86/asm/entry/64: Fold the 'test_in_nmi' macro into its only user x86/asm/boot/64: Use __BOOT_TSS instead of literal $0x20
x86/asm/entry: Clear EXTRA_REGS for all executable formats x86/asm/entry/64: Move opportunistic sysret code to syscall code path x86/asm/entry/irq: Simplify interrupt dispatch table (IDT) layout x86/asm/entry/64: Add forgotten CFI annotation
x86/asm/entry/64: Use common code for rt_sigreturn() epilogue x86/asm/entry/64: Move stub_x32_execvecloser() to stub_execveat() x86/asm/entry: Zero EXTRA_REGS for stub32_execve() too
x86/asm/entry/64: Optimize [v]fork/clone stubs
x86/asm/entry/64: Remove a redundant jump
x86/asm/entry/64: Simplify jumps in ret_from_fork
x86/asm/entry/64: Remove GET_THREAD_INFO() in ret_from_fork x86/asm/entry/64: Reduce padding in execve stubs
x86/asm/entry/32: Tidy up JNZ instructions after TESTs
perf/x86/64: Do not guess user_regs->cs, ss, sp in get_regs_user() perf/x86/64: Do report user_regs->cx while we are in syscall, in get_regs_user() perf/x86/64: Simplify regs_user->abi setting code in get_regs_user() perf/x86/64: Report regs_user->ax too in get_regs_user()
Ingo Molnar (11):
x86/asm/entry: Document and clean up the enable_sep_cpu() and syscall32_cpu_init() functions x86/asm/entry/64: Simplify 'old_rsp' usage
x86/asm/entry/64: Remove thread_struct::usersp
x86/asm/entry/64: Update comments about stack frames
x86/asm/entry/64: Rename 'old_rsp' to 'rsp_scratch'
x86/asm/entry/64: Always set up SYSENTER MSRs
x86/asm/entry/64: Improve the THREAD_INFO() macro explanation x86/asm/entry/64: Merge the field offset into the THREAD_INFO() macro x86/asm/entry/64: Rename THREAD_INFO() to ASM_THREAD_INFO()
x86/asm: Further improve segment.h readability
x86/asm/entry: Remove user_mode_ignore_vm86()
Jan Beulich (1):
x86-64: Also clear _PAGE_GLOBAL from __supported_pte_mask if !cpu_has_pge
Ross Zwisler (2):
x86/asm: Add support for the pcommit instruction x86/asm: Add support for the CLWB instruction
Wang Nan (2):
x86/traps: Enable DEBUG_STACK after cpu_init() for TRAP_DB/BP x86/traps: Separate set_intr_gate() and clean up early_trap_init()
Documentation/x86/boot.txt | 6 + arch/x86/boot/compressed/aslr.c | 5 +- arch/x86/boot/compressed/head_32.S | 3 +- arch/x86/boot/compressed/head_64.S | 5 +- arch/x86/boot/compressed/misc.c | 5 +- arch/x86/boot/compressed/misc.h | 6 +- arch/x86/crypto/crc32c-pcl-intel-asm_64.S | 2 +- arch/x86/crypto/twofish-x86_64-asm_64.S | 4 +- arch/x86/ia32/Makefile | 1 - arch/x86/ia32/ia32_signal.c | 19 +- arch/x86/ia32/ia32entry.S | 485 +++++----- arch/x86/ia32/nosyscall.c | 7 - arch/x86/ia32/sys_ia32.c | 14 - arch/x86/ia32/syscall_ia32.c | 25 - arch/x86/include/asm/alternative-asm.h | 53 +- arch/x86/include/asm/alternative.h | 73 +- arch/x86/include/asm/apic.h | 2 +- arch/x86/include/asm/barrier.h | 6 +- arch/x86/include/asm/calling.h | 284 +++--- arch/x86/include/asm/compat.h | 2 +- arch/x86/include/asm/cpufeature.h | 32 +- arch/x86/include/asm/desc.h | 7 +- arch/x86/include/asm/dwarf2.h | 24 + arch/x86/include/asm/elf.h | 7 +- arch/x86/include/asm/hw_irq.h | 5 +- arch/x86/include/asm/insn.h | 2 +- arch/x86/include/asm/irqflags.h | 49 +- arch/x86/include/asm/paravirt.h | 5 - arch/x86/include/asm/processor.h | 107 ++- arch/x86/include/asm/ptrace.h | 45 +- arch/x86/include/asm/segment.h | 289 +++--- arch/x86/include/asm/setup.h | 5 + arch/x86/include/asm/sigcontext.h | 6 +- arch/x86/include/asm/sighandling.h | 4 +- arch/x86/include/asm/smap.h | 30 +- arch/x86/include/asm/smp.h | 1 + arch/x86/include/asm/special_insns.h | 24 + arch/x86/include/asm/thread_info.h | 74 +- arch/x86/include/uapi/asm/bootparam.h | 1 + arch/x86/include/uapi/asm/ptrace-abi.h | 16 +- arch/x86/include/uapi/asm/ptrace.h | 13 +- arch/x86/include/uapi/asm/sigcontext.h | 21 +- arch/x86/kernel/Makefile | 1 + arch/x86/kernel/alternative.c | 163 +++- arch/x86/kernel/asm-offsets_32.c | 2 +- arch/x86/kernel/asm-offsets_64.c | 1 + arch/x86/kernel/cpu/amd.c | 5 + arch/x86/kernel/cpu/common.c | 87 +- arch/x86/kernel/cpu/perf_event.c | 18 +- arch/x86/kernel/crash.c | 2 +- arch/x86/kernel/dumpstack.c | 4 +- arch/x86/kernel/dumpstack_32.c | 4 +- arch/x86/kernel/entry_32.S | 93 +- arch/x86/kernel/entry_64.S | 978 ++++++++++----------- arch/x86/kernel/head_32.S | 3 +- arch/x86/kernel/head_64.S | 6 +- arch/x86/kernel/i387.c | 2 +- arch/x86/kernel/ioport.c | 2 +- arch/x86/kernel/irq_32.c | 2 +- arch/x86/kernel/irq_64.c | 2 +- arch/x86/kernel/irqinit.c | 3 +- arch/x86/kernel/kgdb.c | 4 +- arch/x86/kernel/kprobes/core.c | 4 +- arch/x86/kernel/module.c | 11 +- arch/x86/kernel/perf_regs.c | 40 +- arch/x86/kernel/process.c | 23 +- arch/x86/kernel/process_32.c | 27 +- arch/x86/kernel/process_64.c | 24 +- arch/x86/kernel/ptrace.c | 12 +- arch/x86/kernel/relocate_kernel_32.S | 8 +- arch/x86/kernel/relocate_kernel_64.S | 16 +- arch/x86/kernel/setup.c | 13 +- arch/x86/kernel/signal.c | 50 +- arch/x86/kernel/smpboot.c | 36 +- arch/x86/kernel/syscall_32.c | 16 +- arch/x86/kernel/time.c | 2 +- arch/x86/kernel/traps.c | 56 +- arch/x86/kernel/uprobes.c | 2 +- arch/x86/kernel/vm86_32.c | 4 +- arch/x86/lguest/boot.c | 4 +- arch/x86/lib/atomic64_cx8_32.S | 50 +- arch/x86/lib/checksum_32.S | 64 +- arch/x86/lib/clear_page_64.S | 66 +- arch/x86/lib/copy_page_64.S | 37 +- arch/x86/lib/copy_user_64.S | 46 +- arch/x86/lib/csum-copy_64.S | 2 +- arch/x86/lib/insn.c | 13 + arch/x86/lib/memcpy_64.S | 68 +- arch/x86/lib/memmove_64.S | 19 +- arch/x86/lib/memset_64.S | 61 +- arch/x86/lib/msr-reg.S | 24 +- arch/x86/lib/rwsem.S | 44 +- arch/x86/lib/thunk_32.S | 18 +- arch/x86/lib/thunk_64.S | 28 +- arch/x86/lib/x86-opcode-map.txt | 9 + arch/x86/mm/fault.c | 8 +- arch/x86/mm/init.c | 3 +- arch/x86/oprofile/backtrace.c | 2 +- arch/x86/power/cpu.c | 2 +- arch/x86/syscalls/syscall_32.tbl | 4 +- arch/x86/syscalls/syscall_64.tbl | 2 +- arch/x86/um/asm/barrier.h | 4 +- arch/x86/um/sys_call_table_64.c | 2 +- arch/x86/xen/enlighten.c | 1 + arch/x86/xen/smp.c | 14 +- arch/x86/xen/xen-asm_64.S | 8 +- drivers/misc/sgi-xp/xpc_main.c | 2 +- include/linux/stddef.h | 9 + include/linux/vfio.h | 13 - tools/perf/bench/mem-memcpy-x86-64-asm-def.h | 6 +- tools/perf/bench/mem-memcpy-x86-64-asm.S | 2 - tools/perf/bench/mem-memcpy.c | 128 +-- tools/perf/bench/mem-memset-x86-64-asm-def.h | 6 +- tools/perf/bench/mem-memset-x86-64-asm.S | 2 - tools/perf/util/include/asm/alternative-asm.h | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/x86/.gitignore | 2 + tools/testing/selftests/x86/Makefile | 48 + tools/testing/selftests/x86/run_x86_tests.sh | 11 + tools/testing/selftests/x86/sigreturn.c | 684 ++++++++++++++ .../testing/selftests/x86/trivial_32bit_program.c | 14 + 121 files changed, 3006 insertions(+), 2026 deletions(-) delete mode 100644 arch/x86/ia32/nosyscall.c delete mode 100644 arch/x86/ia32/syscall_ia32.c create mode 100644 tools/testing/selftests/x86/.gitignore create mode 100644 tools/testing/selftests/x86/Makefile create mode 100644 tools/testing/selftests/x86/run_x86_tests.sh create mode 100644 tools/testing/selftests/x86/sigreturn.c create mode 100644 tools/testing/selftests/x86/trivial_32bit_program.c
Documentation/x86/boot.txt +6 -0
@@ -406,6 +406,12 @@ Protocol: 2.00+ - If 0, the protected-mode code is loaded at 0x10000. - If 1, the protected-mode code is loaded at 0x100000. + Bit 1 (kernel internal): ALSR_FLAG + - Used internally by the compressed kernel to communicate + KASLR status to kernel proper. + If 1, KASLR enabled. + If 0, KASLR disabled. + Bit 5 (write): QUIET_FLAG - If 0, print early messages. - If 1, suppress early messages.
arch/x86/boot/compressed/aslr.c +4 -1
@@ -295,7 +295,8 @@ static unsigned long find_random_addr(unsigned long minimum,return slots_fetch_random (); } -unsigned char *choose_kernel_location (unsigned char *input, +unsigned char *choose_kernel_location (struct boot_params *boot_params, +unsigned char *input,unsigned long input_size,unsigned char *output,unsigned long output_size)
@@ -315,6 +316,8 @@ unsigned char *choose_kernel_location(unsigned char *input, }#endif + boot_params->hdr.loadflags |=KASLR_FLAG ; +/* Record the various known unsafe memory ranges. */ mem_avoid_init ((unsigned long )input, input_size, (unsigned long )output, output_size);
arch/x86/boot/compressed/head_32.S +2 -1
@@ -29,6 +29,7 @@ #include <asm/page_types.h> #include <asm/boot.h> #include <asm/asm-offsets.h> +#include <asm/bootparam.h> __HEAD ENTRY(startup_32)
@@ -102,7 +103,7 @@ ENTRY(efi32_stub_entry) * Test KEEP_SEGMENTS flag to see if the bootloader is asking * us to not reload segments */ - testb $(1<<6), BP_loadflags(%esi) + testb $KEEP_SEGMENTS, BP_loadflags(%esi) jnz 1f cli
arch/x86/boot/compressed/head_64.S +3 -2
@@ -31,6 +31,7 @@ #include <asm/msr.h> #include <asm/processor-flags.h> #include <asm/asm-offsets.h> +#include <asm/bootparam.h> __HEAD .code32
@@ -46,7 +47,7 @@ ENTRY(startup_32) * Test KEEP_SEGMENTS flag to see if the bootloader is asking * us to not reload segments */ - testb $(1<<6), BP_loadflags(%esi) + testb $KEEP_SEGMENTS, BP_loadflags(%esi) jnz 1f cli
@@ -164,7 +165,7 @@ ENTRY(startup_32) /* After gdt is loaded */ xorl %eax, %eax lldt %ax - movl $0x20, %eax + movl $__BOOT_TSS, %eax ltr %ax /*
arch/x86/boot/compressed/misc.c +4 -1
@@ -377,6 +377,9 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, real_mode = rmode; +/* Clear it for solely in-kernel use */ + real_mode->hdr.loadflags &= ~KASLR_FLAG ; +sanitize_boot_params (real_mode);if (real_mode->screen_info.orig_video_mode ==7 ) {
@@ -401,7 +404,7 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,* the entire decompressed kernel plus relocation table, or the * entire decompressed kernel plus .bss and .brk sections. */ - output =choose_kernel_location (input_data, input_len, output, + output =choose_kernel_location (real_mode, input_data, input_len, output, output_len > run_size ? output_len : run_size);
arch/x86/boot/compressed/misc.h +4 -2
@@ -57,7 +57,8 @@ int cmdline_find_option_bool(const char *option);#if CONFIG_RANDOMIZE_BASE /* aslr.c */ -unsigned char *choose_kernel_location (unsigned char *input, +unsigned char *choose_kernel_location (struct boot_params *boot_params, +unsigned char *input,unsigned long input_size,unsigned char *output,unsigned long output_size);
@@ -65,7 +66,8 @@ unsigned char *choose_kernel_location(unsigned char *input,bool has_cpuflag (int flag);#else static inline -unsigned char *choose_kernel_location (unsigned char *input, +unsigned char *choose_kernel_location (struct boot_params *boot_params, +unsigned char *input,unsigned long input_size,unsigned char *output,unsigned long output_size)
arch/x86/crypto/crc32c-pcl-intel-asm_64.S +1 -1
@@ -178,7 +178,7 @@ ENTRY(crc_pcl) ## 2a) PROCESS FULL BLOCKS: ################################################################ full_block: - movq $128,%rax + movl $128,%eax lea 128*8*2(block_0), block_1 lea 128*8*3(block_0), block_2 add $128*8*1, block_0
arch/x86/crypto/twofish-x86_64-asm_64.S +2 -2
@@ -264,7 +264,7 @@ ENTRY(twofish_enc_blk) movq R1, 8(%rsi) popq R1 - movq $1,%rax + movl $1,%eax ret ENDPROC(twofish_enc_blk)
@@ -316,6 +316,6 @@ ENTRY(twofish_dec_blk) movq R1, 8(%rsi) popq R1 - movq $1,%rax + movl $1,%eax ret ENDPROC(twofish_dec_blk)
arch/x86/ia32/Makefile +0 -1
@@ -3,7 +3,6 @@ # obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o -obj-$(CONFIG_IA32_EMULATION) += nosyscall.o syscall_ia32.o obj-$(CONFIG_IA32_AOUT) += ia32_aout.o
arch/x86/ia32/ia32_signal.c +8 -11
@@ -161,8 +161,7 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) }static int ia32_restore_sigcontext (struct pt_regs *regs, -struct sigcontext_ia32 __user *sc, -unsigned int *pax) +struct sigcontext_ia32 __user *sc) {unsigned int tmpflags, err =0 ;void __user *buf;
@@ -184,7 +183,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,RELOAD_SEG (es);COPY (di);COPY (si);COPY (bp);COPY (sp);COPY (bx); -COPY (dx);COPY (cx);COPY (ip); +COPY (dx);COPY (cx);COPY (ip);COPY (ax);/* Don't touch extended registers */ COPY_SEG_CPL3 (cs);
@@ -197,12 +196,12 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,get_user_ex (tmp, &sc->fpstate); buf =compat_ptr (tmp); - -get_user_ex (*pax, &sc->ax); }get_user_catch (err); err |=restore_xstate_sig (buf,1 ); +force_iret (); +return err; }
@@ -211,7 +210,6 @@ asmlinkage long sys32_sigreturn(void)struct pt_regs *regs =current_pt_regs ();struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8 );sigset_t set; -unsigned int ax;if (!access_ok (VERIFY_READ , frame,sizeof (*frame))) goto badframe;
@@ -224,9 +222,9 @@ asmlinkage long sys32_sigreturn(void)set_current_blocked (&set); -if (ia32_restore_sigcontext (regs, &frame->sc, &ax)) +if (ia32_restore_sigcontext (regs, &frame->sc)) goto badframe; -return ax; +return regs->ax; badframe:signal_fault (regs, frame,"32bit sigreturn" );
@@ -238,7 +236,6 @@ asmlinkage long sys32_rt_sigreturn(void)struct pt_regs *regs =current_pt_regs ();struct rt_sigframe_ia32 __user *frame;sigset_t set; -unsigned int ax; frame = (struct rt_sigframe_ia32 __user *)(regs->sp -4 );
@@ -249,13 +246,13 @@ asmlinkage long sys32_rt_sigreturn(void)set_current_blocked (&set); -if (ia32_restore_sigcontext (regs, &frame->uc.uc_mcontext, &ax)) +if (ia32_restore_sigcontext (regs, &frame->uc.uc_mcontext)) goto badframe;if (compat_restore_altstack (&frame->uc.uc_stack)) goto badframe; -return ax; +return regs->ax; badframe:signal_fault (regs, frame,"32bit rt sigreturn" );
arch/x86/ia32/ia32entry.S +287 -198
689 lines not on this page · raw message
arch/x86/ia32/nosyscall.c deleted +0 -7
@@ -1,7 +0,0 @@ -#include <linux/kernel.h> -#include <linux/errno.h> - -long compat_ni_syscall (void ) -{ -return -ENOSYS ; -}
arch/x86/ia32/sys_ia32.c +0 -14
@@ -201,20 +201,6 @@ long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, advice); } -long sys32_vm86_warning (void ) -{ -struct task_struct *me = current; -static char lastcomm[sizeof (me->comm)]; - -if (strncmp (lastcomm, me->comm,sizeof (lastcomm))) { -compat_printk (KERN_INFO -"%s: vm86 mode not supported on 64 bit kernel\n" , - me->comm); -strncpy (lastcomm, me->comm,sizeof (lastcomm)); - } -return -ENOSYS ; -} - asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,size_t count) {
arch/x86/ia32/syscall_ia32.c deleted +0 -25
@@ -1,25 +0,0 @@ -/* System call table for ia32 emulation. */ - -#include <linux/linkage.h> -#include <linux/sys.h> -#include <linux/cache.h> -#include <asm/asm-offsets.h> - -#define __SYSCALL_I386 (nr, sym, compat) extern asmlinkage void compat(void) ; -#include <asm/syscalls_32.h> -#undef __SYSCALL_I386 - -#define __SYSCALL_I386 (nr, sym, compat) [nr] = compat, - -typedef void (*sys_call_ptr_t )(void ); - -extern void compat_ni_syscall (void ); - -const sys_call_ptr_t ia32_sys_call_table[__NR_ia32_syscall_max+1 ] = { -/* -* Smells like a compiler bug -- it doesn't work -* when the & below is removed. -*/ - [0 ... __NR_ia32_syscall_max] = &compat_ni_syscall, -#include <asm/syscalls_32.h> -};
arch/x86/include/asm/alternative-asm.h +52 -1
64 lines not on this page · raw message
arch/x86/include/asm/alternative.h +48 -25
112 lines not on this page · raw message
arch/x86/include/asm/apic.h +1 -1
@@ -91,7 +91,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v) {volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg); -alternative_io ("movl %0, %1" ,"xchgl %0, %1" ,X86_BUG_11AP , +alternative_io ("movl %0, %P1" ,"xchgl %0, %P1" ,X86_BUG_11AP ,ASM_OUTPUT2 ("=r" (v),"=m" (*addr)),ASM_OUTPUT2 ("0" (v),"m" (*addr))); }
arch/x86/include/asm/barrier.h +2 -4
@@ -95,13 +95,11 @@ do { \* Stop RDTSC speculation. This is needed when you need to use RDTSC * (or get_cycles or vread that possibly accesses the TSC) in a defined * code region. -* -* (Could use an alternative three way for this if there was one.) */ static __always_inline void rdtsc_barrier(void) { -alternative (ASM_NOP3 ,"mfence" ,X86_FEATURE_MFENCE_RDTSC ); -alternative (ASM_NOP3 ,"lfence" ,X86_FEATURE_LFENCE_RDTSC ); +alternative_2 ("" ,"mfence" ,X86_FEATURE_MFENCE_RDTSC , +"lfence" ,X86_FEATURE_LFENCE_RDTSC ); }#endif /* _ASM_X86_BARRIER_H */
arch/x86/include/asm/calling.h +142 -142
322 lines not on this page · raw message
arch/x86/include/asm/compat.h +1 -1
@@ -301,7 +301,7 @@ static inline void __user *arch_compat_alloc_user_space(long len) sp =task_pt_regs (current)->sp; }else {/* -128 for the x32 ABI redzone */ - sp =this_cpu_read (old_rsp) -128 ; + sp =task_pt_regs (current)->sp -128 ; }return (void __user *)round_down (sp - len,16 );
arch/x86/include/asm/cpufeature.h +19 -13
@@ -231,7 +231,9 @@#define X86_FEATURE_RDSEED ( 9*32+18)/* The RDSEED instruction */ #define X86_FEATURE_ADX ( 9*32+19)/* The ADCX and ADOX instructions */ #define X86_FEATURE_SMAP ( 9*32+20)/* Supervisor Mode Access Prevention */ +#define X86_FEATURE_PCOMMIT ( 9*32+22)/* PCOMMIT instruction */ #define X86_FEATURE_CLFLUSHOPT ( 9*32+23)/* CLFLUSHOPT instruction */ +#define X86_FEATURE_CLWB ( 9*32+24)/* CLWB instruction */ #define X86_FEATURE_AVX512PF ( 9*32+26)/* AVX-512 Prefetch */ #define X86_FEATURE_AVX512ER ( 9*32+27)/* AVX-512 Exponential and Reciprocal */ #define X86_FEATURE_AVX512CD ( 9*32+28)/* AVX-512 Conflict Detection */
@@ -418,6 +420,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) " .word %P0\n" /* 1: do replace */ " .byte 2b - 1b\n" /* source len */ " .byte 0\n" /* replacement len */ + " .byte 0\n" /* pad len */ ".previous\n" /* skipping size check since replacement size = 0 */ : : "i" (X86_FEATURE_ALWAYS) : : t_warn);
@@ -432,6 +435,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) " .word %P0\n" /* feature bit */ " .byte 2b - 1b\n" /* source len */ " .byte 0\n" /* replacement len */ + " .byte 0\n" /* pad len */ ".previous\n" /* skipping size check since replacement size = 0 */ : : "i" (bit) : : t_no);
@@ -457,6 +461,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)" .word %P1\n" /* feature bit */ " .byte 2b - 1b\n" /* source len */ " .byte 4f - 3f\n" /* replacement len */ +" .byte 0\n" /* pad len */ ".previous\n" ".section .discard,\"aw\",@progbits\n" " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
@@ -483,31 +488,30 @@ static __always_inline __pure bool __static_cpu_has(u16 bit) static __always_inline __pure bool _static_cpu_has_safe(u16 bit) {#ifdef CC_HAVE_ASM_GOTO -/* -* We need to spell the jumps to the compiler because, depending on the offset, -* the replacement jump can be bigger than the original jump, and this we cannot -* have. Thus, we force the jump to the widest, 4-byte, signed relative -* offset even though the last would often fit in less bytes. -*/ -asm_volatile_goto ("1: .byte 0xe9\n .long %l[t_dynamic] - 2f\n" +asm_volatile_goto ("1: jmp %l[t_dynamic]\n" "2:\n" +".skip -(((5f-4f) - (2b-1b)) > 0) * " +"((5f-4f) - (2b-1b)),0x90\n" +"3:\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n" /* src offset */ -" .long 3f - .\n" /* repl offset */ +" .long 4f - .\n" /* repl offset */ " .word %P1\n" /* always replace */ -" .byte 2b - 1b\n" /* src len */ -" .byte 4f - 3f\n" /* repl len */ +" .byte 3b - 1b\n" /* src len */ +" .byte 5f - 4f\n" /* repl len */ +" .byte 3b - 2b\n" /* pad len */ ".previous\n" ".section .altinstr_replacement,\"ax\"\n" -"3: .byte 0xe9\n .long %l[t_no] - 2b\n" -"4:\n" +"4: jmp %l[t_no]\n" +"5:\n" ".previous\n" ".section .altinstructions,\"a\"\n" " .long 1b - .\n" /* src offset */ " .long 0\n" /* no replacement */ " .word %P0\n" /* feature bit */ -" .byte 2b - 1b\n" /* src len */ +" .byte 3b - 1b\n" /* src len */ " .byte 0\n" /* repl len */ +" .byte 0\n" /* pad len */ ".previous\n" : : "i" (bit), "i" (X86_FEATURE_ALWAYS) : : t_dynamic, t_no);
@@ -527,6 +531,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)" .word %P2\n" /* always replace */ " .byte 2b - 1b\n" /* source len */ " .byte 4f - 3f\n" /* replacement len */ +" .byte 0\n" /* pad len */ ".previous\n" ".section .discard,\"aw\",@progbits\n" " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
@@ -541,6 +546,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)" .word %P1\n" /* feature bit */ " .byte 4b - 3b\n" /* src len */ " .byte 6f - 5f\n" /* repl len */ +" .byte 0\n" /* pad len */ ".previous\n" ".section .discard,\"aw\",@progbits\n" " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
arch/x86/include/asm/desc.h +6 -1
@@ -376,11 +376,16 @@ static inline void _set_gate(int gate, unsigned type, void *addr,* Pentium F0 0F bugfix can have resulted in the mapped * IDT being write-protected. */ -#define set_intr_gate (n, addr) \ +#define set_intr_gate_notrace (n, addr) \ do { \ BUG_ON((unsigned)n > 0xFF); \ _set_gate(n, GATE_INTERRUPT, (void *)addr, 0, 0, \ __KERNEL_CS); \ + } while (0) + +#define set_intr_gate (n, addr) \ + do { \ + set_intr_gate_notrace(n, addr); \ _trace_set_gate(n, GATE_INTERRUPT, (void *)trace_##addr,\ 0, 0, __KERNEL_CS); \ } while (0)
arch/x86/include/asm/dwarf2.h +24 -0
@@ -86,11 +86,23 @@ CFI_ADJUST_CFA_OFFSET 8 .endm + .macro pushq_cfi_reg reg + pushq %\reg + CFI_ADJUST_CFA_OFFSET 8 + CFI_REL_OFFSET \reg, 0 + .endm + .macro popq_cfi reg popq \reg CFI_ADJUST_CFA_OFFSET -8 .endm + .macro popq_cfi_reg reg + popq %\reg + CFI_ADJUST_CFA_OFFSET -8 + CFI_RESTORE \reg + .endm + .macro pushfq_cfi pushfq CFI_ADJUST_CFA_OFFSET 8
@@ -116,11 +128,23 @@ CFI_ADJUST_CFA_OFFSET 4 .endm + .macro pushl_cfi_reg reg + pushl %\reg + CFI_ADJUST_CFA_OFFSET 4 + CFI_REL_OFFSET \reg, 0 + .endm + .macro popl_cfi reg popl \reg CFI_ADJUST_CFA_OFFSET -4 .endm + .macro popl_cfi_reg reg + popl %\reg + CFI_ADJUST_CFA_OFFSET -4 + CFI_RESTORE \reg + .endm + .macro pushfl_cfi pushfl CFI_ADJUST_CFA_OFFSET 4
arch/x86/include/asm/elf.h +4 -3
@@ -171,10 +171,11 @@ do { \static inline void elf_common_init (struct thread_struct *t,struct pt_regs *regs,const u16 ds) { - regs->ax = regs->bx = regs->cx = regs->dx =0 ; - regs->si = regs->di = regs->bp =0 ; +/* Commented-out registers are cleared in stub_execve */ +/*regs->ax = regs->bx =*/ regs->cx = regs->dx =0 ; + regs->si = regs->di/*= regs->bp*/ =0 ; regs->r8 = regs->r9 = regs->r10 = regs->r11 =0 ; - regs->r12 = regs->r13 = regs->r14 = regs->r15 =0 ; +/*regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;*/ t->fs = t->gs =0 ; t->fsindex = t->gsindex =0 ; t->ds = t->es = ds;
arch/x86/include/asm/hw_irq.h +2 -3
@@ -181,10 +181,9 @@ extern __visible void smp_call_function_single_interrupt(struct pt_regs *); extern __visible void smp_invalidate_interrupt(struct pt_regs *);#endif -extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR - -FIRST_EXTERNAL_VECTOR ])(void ); +extern char irq_entries_start[];#ifdef CONFIG_TRACING -#define trace_interrupt interrupt +#define trace_irq_entries_start irq_entries_start#endif #define VECTOR_UNDEFINED (-1)
arch/x86/include/asm/insn.h +1 -1
@@ -69,7 +69,7 @@ struct insn {const insn_byte_t *next_byte; }; -#define MAX_INSN_SIZE 16 +#define MAX_INSN_SIZE 15#define X86_MODRM_MOD (modrm) (((modrm) & 0xc0) >> 6)#define X86_MODRM_REG (modrm) (((modrm) & 0x38) >> 3)
arch/x86/include/asm/irqflags.h +19 -30
75 lines not on this page · raw message
arch/x86/include/asm/paravirt.h +0 -5
@@ -976,11 +976,6 @@ extern void default_banner(void);PARA_SITE (PARA_PATCH (pv_cpu_ops, PV_CPU_usergs_sysret64), \CLBR_NONE , \ jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_usergs_sysret64)) - -#define ENABLE_INTERRUPTS_SYSEXIT32 \ - PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \ - CLBR_NONE, \ - jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))#endif /* CONFIG_X86_32 */ #endif /* __ASSEMBLY__ */
arch/x86/include/asm/processor.h +52 -55
194 lines not on this page · raw message
arch/x86/include/asm/ptrace.h +20 -25
88 lines not on this page · raw message
arch/x86/include/asm/segment.h +157 -132
400 lines not on this page · raw message
arch/x86/include/asm/setup.h +5 -0
@@ -66,6 +66,11 @@ static inline void x86_ce4100_early_setup(void) { }*/ extern struct boot_params boot_params; +static inline bool kaslr_enabled (void ) +{ +return !!(boot_params.hdr.loadflags &KASLR_FLAG ); +} +/* * Do NOT EVER look at the BIOS memory size location. * It does not work on many machines.
arch/x86/include/asm/sigcontext.h +3 -3
@@ -57,9 +57,9 @@ struct sigcontext {unsigned long ip;unsigned long flags;unsigned short cs; -unsigned short gs; -unsigned short fs; -unsigned short __pad0; +unsigned short __pad2;/* Was called gs, but was always zero. */ +unsigned short __pad1;/* Was called fs, but was always zero. */ +unsigned short ss;unsigned long err;unsigned long trapno;unsigned long oldmask;
arch/x86/include/asm/sighandling.h +1 -3
@@ -13,9 +13,7 @@ X86_EFLAGS_CF | X86_EFLAGS_RF)void signal_fault (struct pt_regs *regs,void __user *frame,char *where); - -int restore_sigcontext (struct pt_regs *regs,struct sigcontext __user *sc, -unsigned long *pax); +int restore_sigcontext (struct pt_regs *regs,struct sigcontext __user *sc);int setup_sigcontext (struct sigcontext __user *sc,void __user *fpstate,struct pt_regs *regs,unsigned long mask);
arch/x86/include/asm/smap.h +9 -21
@@ -27,23 +27,11 @@#ifdef CONFIG_X86_SMAP -#define ASM_CLAC \ - 661: ASM_NOP3 ; \ - .pushsection .altinstr_replacement, "ax" ; \ - 662: __ASM_CLAC ; \ - .popsection ; \ - .pushsection .altinstructions, "a" ; \ - altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3 ; \ - .popsection - -#define ASM_STAC \ - 661: ASM_NOP3 ; \ - .pushsection .altinstr_replacement, "ax" ; \ - 662: __ASM_STAC ; \ - .popsection ; \ - .pushsection .altinstructions, "a" ; \ - altinstruction_entry 661b, 662b, X86_FEATURE_SMAP, 3, 3 ; \ - .popsection +#define ASM_CLAC \ + ALTERNATIVE "", __stringify(__ASM_CLAC), X86_FEATURE_SMAP + +#define ASM_STAC \ + ALTERNATIVE "", __stringify(__ASM_STAC), X86_FEATURE_SMAP#else /* CONFIG_X86_SMAP */
@@ -61,20 +49,20 @@ static __always_inline void clac(void) {/* Note: a barrier is implicit in alternative() */ -alternative (ASM_NOP3 ,__stringify (__ASM_CLAC),X86_FEATURE_SMAP ); +alternative ("" ,__stringify (__ASM_CLAC),X86_FEATURE_SMAP ); } static __always_inline void stac(void) {/* Note: a barrier is implicit in alternative() */ -alternative (ASM_NOP3 ,__stringify (__ASM_STAC),X86_FEATURE_SMAP ); +alternative ("" ,__stringify (__ASM_STAC),X86_FEATURE_SMAP ); }/* These macros can be used in asm() statements */ #define ASM_CLAC \ - ALTERNATIVE(ASM_NOP3, __stringify(__ASM_CLAC), X86_FEATURE_SMAP) + ALTERNATIVE("", __stringify(__ASM_CLAC), X86_FEATURE_SMAP)#define ASM_STAC \ - ALTERNATIVE(ASM_NOP3, __stringify(__ASM_STAC), X86_FEATURE_SMAP) + ALTERNATIVE("", __stringify(__ASM_STAC), X86_FEATURE_SMAP)#else /* CONFIG_X86_SMAP */
arch/x86/include/asm/smp.h +1 -0
@@ -154,6 +154,7 @@ void cpu_die_common(unsigned int cpu);void native_smp_prepare_boot_cpu (void );void native_smp_prepare_cpus (unsigned int max_cpus);void native_smp_cpus_done (unsigned int max_cpus); +void common_cpu_up (unsigned int cpunum,struct task_struct *tidle);int native_cpu_up (unsigned int cpunum,struct task_struct *tidle);int native_cpu_disable (void );void native_cpu_die (unsigned int cpu);
arch/x86/include/asm/special_insns.h +24 -0
@@ -4,6 +4,8 @@#ifdef __KERNEL__ +#include <asm/nops.h> +static inline void native_clts (void ) { asmvolatile ("clts" );
@@ -199,6 +201,28 @@ static inline void clflushopt(volatile void *__p) "+m" (*(volatile char __force *)__p)); } +static inline void clwb (volatile void *__p) +{ +volatile struct {char x[64 ]; } *p = __p; + + asm volatile(ALTERNATIVE_2( + ".byte " __stringify(NOP_DS_PREFIX) "; clflush (%[pax])", + ".byte 0x66; clflush (%[pax])", /* clflushopt (%%rax) */ + X86_FEATURE_CLFLUSHOPT, + ".byte 0x66, 0x0f, 0xae, 0x30", /* clwb (%%rax) */ + X86_FEATURE_CLWB) + : [p] "+m" (*p) + : [pax] "a" (p)); +} + +static inline void pcommit_sfence (void ) +{ +alternative (ASM_NOP7 , +".byte 0x66, 0x0f, 0xae, 0xf8\n\t" /* pcommit */ +"sfence" , +X86_FEATURE_PCOMMIT ); +} +#define nop () asm volatile ("nop")
arch/x86/include/asm/thread_info.h +64 -10
109 lines not on this page · raw message
arch/x86/include/uapi/asm/bootparam.h +1 -0
@@ -15,6 +15,7 @@/* loadflags */ #define LOADED_HIGH (1<<0) +#define KASLR_FLAG (1<<1)#define QUIET_FLAG (1<<5)#define KEEP_SEGMENTS (1<<6)#define CAN_USE_HEAP (1<<7)
arch/x86/include/uapi/asm/ptrace-abi.h +11 -5
@@ -25,13 +25,17 @@#else /* __i386__ */ #if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS) +/* +* C ABI says these regs are callee-preserved. They aren't saved on kernel entry +* unless syscall needs a complete, fully filled "struct pt_regs". +*/ #define R15 0#define R14 8#define R13 16#define R12 24#define RBP 32#define RBX 40 -/* arguments: interrupts/non tracing syscalls only save up to here*/ +/* These regs are callee-clobbered. Always saved on kernel entry. */ #define R11 48#define R10 56#define R9 64
@@ -41,15 +45,17 @@#define RDX 96#define RSI 104#define RDI 112 -#define ORIG_RAX 120/* = ERROR */ -/* end of arguments */ -/* cpu exception frame or undefined in case of fast syscall. */ +/* +* On syscall entry, this is syscall#. On CPU exception, this is error code. +* On hw interrupt, it's IRQ number: +*/ +#define ORIG_RAX 120 +/* Return frame for iretq */ #define RIP 128#define CS 136#define EFLAGS 144#define RSP 152#define SS 160 -#define ARGOFFSET R11#endif /* __ASSEMBLY__ */ /* top of stack page */
arch/x86/include/uapi/asm/ptrace.h +10 -3
@@ -41,13 +41,17 @@ struct pt_regs { #ifndef __KERNEL__ struct pt_regs { +/* + * C ABI says these regs are callee-preserved. They aren't saved on kernel entry + * unless syscall needs a complete, fully filled "struct pt_regs". + */ unsigned long r15; unsigned long r14; unsigned long r13; unsigned long r12; unsigned long rbp; unsigned long rbx; -/* arguments: non interrupts/non tracing syscalls only save up to here*/ +/* These regs are callee-clobbered. Always saved on kernel entry. */ unsigned long r11; unsigned long r10; unsigned long r9;
@@ -57,9 +61,12 @@ struct pt_regs {unsigned long rdx;unsigned long rsi;unsigned long rdi; +/* +* On syscall entry, this is syscall#. On CPU exception, this is error code. +* On hw interrupt, it's IRQ number: +*/ unsigned long orig_rax; -/* end of arguments */ -/* cpu exception frame or undefined */ +/* Return frame for iretq */ unsigned long rip;unsigned long cs;unsigned long eflags;
arch/x86/include/uapi/asm/sigcontext.h +18 -3
@@ -177,9 +177,24 @@ struct sigcontext {__u64 rip;__u64 eflags;/* RFLAGS */ __u16 cs; -__u16 gs; -__u16 fs; -__u16 __pad0; + +/* +* Prior to 2.5.64 ("[PATCH] x86-64 updates for 2.5.64-bk3"), +* Linux saved and restored fs and gs in these slots. This +* was counterproductive, as fsbase and gsbase were never +* saved, so arch_prctl was presumably unreliable. +* +* If these slots are ever needed for any other purpose, there +* is some risk that very old 64-bit binaries could get +* confused. I doubt that many such binaries still work, +* though, since the same patch in 2.5.64 also removed the +* 64-bit set_thread_area syscall, so it appears that there is +* no TLS API that works in both pre- and post-2.5.64 kernels. +*/ +__u16 __pad2;/* Was gs. */ +__u16 __pad1;/* Was fs. */ + +__u16 ss;__u64 err;__u64 trapno;__u64 oldmask;
arch/x86/kernel/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_X86_32) += i386_ksyms_32.o obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o obj-$(CONFIG_X86_64) += mcount_64.o obj-y += syscall_$(BITS).o vsyscall_gtod.o +obj-$(CONFIG_IA32_EMULATION) += syscall_32.o obj-$(CONFIG_X86_VSYSCALL_EMULATION) += vsyscall_64.o vsyscall_emu_64.o obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o obj-$(CONFIG_SYSFS) += ksysfs.o
arch/x86/kernel/alternative.c +140 -23
223 lines not on this page · raw message
arch/x86/kernel/asm-offsets_32.c +1 -1
@@ -68,7 +68,7 @@ void foo(void)/* Offset from the sysenter stack to tss.sp0 */ DEFINE(TSS_sysenter_sp0, offsetof(struct tss_struct, x86_tss.sp0) -
Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/common.c +54 -33
87 lines not on this page · raw message
arch/x86/kernel/entry_32.S +31 -62
93 lines not on this page · raw message
arch/x86/kernel/entry_64.S +458 -520
978 lines not on this page · raw message
arch/x86/kernel/signal.c +25 -25
50 lines not on this page · raw message
arch/x86/kernel/traps.c +37 -19
56 lines not on this page · raw message
arch/x86/lib/atomic64_cx8_32.S +20 -30
50 lines not on this page · raw message
arch/x86/lib/checksum_32.S +22 -42
64 lines not on this page · raw message
arch/x86/lib/clear_page_64.S +27 -39
66 lines not on this page · raw message
arch/x86/lib/copy_user_64.S +10 -36
46 lines not on this page · raw message
arch/x86/lib/memcpy_64.S +21 -47
68 lines not on this page · raw message
arch/x86/lib/memset_64.S +24 -37
61 lines not on this page · raw message
arch/x86/lib/rwsem.S +20 -24
44 lines not on this page · raw message
tools/perf/bench/mem-memcpy-x86-64-asm-def.h +3 -3
Lines of this file are not shown. View the raw message.
tools/perf/bench/mem-memcpy-x86-64-asm.S +0 -2
Lines of this file are not shown. View the raw message.
tools/perf/bench/mem-memcpy.c +66 -62
128 lines not on this page · raw message
tools/perf/bench/mem-memset-x86-64-asm-def.h +3 -3
Lines of this file are not shown. View the raw message.
tools/perf/bench/mem-memset-x86-64-asm.S +0 -2
Lines of this file are not shown. View the raw message.
tools/perf/util/include/asm/alternative-asm.h +1 -0
Lines of this file are not shown. View the raw message.
tools/testing/selftests/x86/.gitignore new file +2 -0
Lines of this file are not shown. View the raw message.
tools/testing/selftests/x86/Makefile new file +48 -0
48 lines not on this page · raw message
tools/testing/selftests/x86/run_x86_tests.sh new file +11 -0
Lines of this file are not shown. View the raw message.
tools/testing/selftests/x86/sigreturn.c new file +684 -0
684 lines not on this page · raw message
tools/testing/selftests/x86/trivial_32bit_program.c new file +14 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.