Lines Matching +full:protect +full:- +full:exec

1 // SPDX-License-Identifier: GPL-2.0-only
8 * X86-64 port
11 * CPU hotplug support - ashok.raj@intel.com
15 * This file handles the architecture-dependent parts of process handling..
75 if (regs->orig_ax != -1) in __show_regs()
76 pr_cont(" ORIG_RAX: %016lx\n", regs->orig_ax); in __show_regs()
81 log_lvl, regs->ax, regs->bx, regs->cx); in __show_regs()
83 log_lvl, regs->dx, regs->si, regs->di); in __show_regs()
85 log_lvl, regs->bp, regs->r8, regs->r9); in __show_regs()
87 log_lvl, regs->r10, regs->r11, regs->r12); in __show_regs()
89 log_lvl, regs->r13, regs->r14, regs->r15); in __show_regs()
119 log_lvl, regs->cs, ds, es, cr0); in __show_regs()
130 /* Only print out debug registers if they are in their non-default state. */ in __show_regs()
145 WARN_ON(dead_task->mm); in release_thread()
205 * not available. The goal is to be reasonably fast on non-FSGSBASE systems.
216 * be the pre-existing saved base or it could be zero. On AMD in save_base_legacy()
221 * context switch between 64-bit programs), and avoiding in save_base_legacy()
226 * To avoid leaking state, on non-X86_BUG_NULL_SEG CPUs, if we in save_base_legacy()
242 prev_p->thread.fsbase = 0; in save_base_legacy()
244 prev_p->thread.gsbase = 0; in save_base_legacy()
250 savesegment(fs, task->thread.fsindex); in save_fsgs()
251 savesegment(gs, task->thread.gsindex); in save_fsgs()
258 task->thread.fsbase = rdfsbase(); in save_fsgs()
259 task->thread.gsbase = __rdgsbase_inactive(); in save_fsgs()
261 save_base_legacy(task, task->thread.fsindex, FS); in save_fsgs()
262 save_base_legacy(task, task->thread.gsindex, GS); in save_fsgs()
267 * While a process is running,current->thread.fsbase and current->thread.gsbase
300 * The next task is using 64-bit TLS, is not using this in load_seg_legacy()
322 * Intel-style CPUs.) in load_seg_legacy()
347 if (unlikely(prev->fsindex || next->fsindex)) in x86_fsgsbase_load()
348 loadseg(FS, next->fsindex); in x86_fsgsbase_load()
349 if (unlikely(prev->gsindex || next->gsindex)) in x86_fsgsbase_load()
350 loadseg(GS, next->gsindex); in x86_fsgsbase_load()
353 wrfsbase(next->fsbase); in x86_fsgsbase_load()
354 __wrgsbase_inactive(next->gsbase); in x86_fsgsbase_load()
356 load_seg_legacy(prev->fsindex, prev->fsbase, in x86_fsgsbase_load()
357 next->fsindex, next->fsbase, FS); in x86_fsgsbase_load()
358 load_seg_legacy(prev->gsindex, prev->gsbase, in x86_fsgsbase_load()
359 next->gsindex, next->gsbase, GS); in x86_fsgsbase_load()
380 idx -= GDT_ENTRY_TLS_MIN; in x86_fsgsbase_read_task()
381 base = get_desc_base(&task->thread.tls_array[idx]); in x86_fsgsbase_read_task()
387 * If performance here mattered, we could protect the LDT in x86_fsgsbase_read_task()
391 mutex_lock(&task->mm->context.lock); in x86_fsgsbase_read_task()
392 ldt = task->mm->context.ldt; in x86_fsgsbase_read_task()
393 if (unlikely(!ldt || idx >= ldt->nr_entries)) in x86_fsgsbase_read_task()
396 base = get_desc_base(ldt->entries + idx); in x86_fsgsbase_read_task()
397 mutex_unlock(&task->mm->context.lock); in x86_fsgsbase_read_task()
443 (task->thread.fsindex == 0)) in x86_fsbase_read_task()
444 fsbase = task->thread.fsbase; in x86_fsbase_read_task()
446 fsbase = x86_fsgsbase_read_task(task, task->thread.fsindex); in x86_fsbase_read_task()
458 (task->thread.gsindex == 0)) in x86_gsbase_read_task()
459 gsbase = task->thread.gsbase; in x86_gsbase_read_task()
461 gsbase = x86_fsgsbase_read_task(task, task->thread.gsindex); in x86_gsbase_read_task()
470 task->thread.fsbase = fsbase; in x86_fsbase_write_task()
477 task->thread.gsbase = gsbase; in x86_gsbase_write_task()
498 regs->ip = new_ip; in start_thread_common()
499 regs->sp = new_sp; in start_thread_common()
500 regs->cs = _cs; in start_thread_common()
501 regs->ss = _ss; in start_thread_common()
502 regs->flags = X86_EFLAGS_IF; in start_thread_common()
527 * - fold all the options into a flag word and test it with a single test.
528 * - could test fs/gs bitsliced
536 struct thread_struct *prev = &prev_p->thread; in __switch_to()
537 struct thread_struct *next = &next_p->thread; in __switch_to()
538 struct fpu *prev_fpu = &prev->fpu; in __switch_to()
539 struct fpu *next_fpu = &next->fpu; in __switch_to()
543 this_cpu_read(irq_count) != -1); in __switch_to()
582 savesegment(es, prev->es); in __switch_to()
583 if (unlikely(next->es | prev->es)) in __switch_to()
584 loadsegment(es, next->es); in __switch_to()
586 savesegment(ds, prev->ds); in __switch_to()
587 if (unlikely(next->ds | prev->ds)) in __switch_to()
588 loadsegment(ds, next->ds); in __switch_to()
617 * SS, so the only way to get NULL is to re-enter the kernel in __switch_to()
625 * it previously had a different non-NULL value. in __switch_to()
648 task_pt_regs(current)->orig_ax = __NR_execve; in set_personality_64bit()
649 current_thread_info()->status &= ~TS_COMPAT; in set_personality_64bit()
652 if (current->mm) in set_personality_64bit()
653 current->mm->context.ia32_compat = 0; in set_personality_64bit()
659 current->personality &= ~READ_IMPLIES_EXEC; in set_personality_64bit()
667 if (current->mm) in __set_personality_x32()
668 current->mm->context.ia32_compat = TIF_X32; in __set_personality_x32()
669 current->personality &= ~READ_IMPLIES_EXEC; in __set_personality_x32()
674 * in_32bit_syscall() work during exec(). in __set_personality_x32()
678 task_pt_regs(current)->orig_ax = __NR_x32_execve | __X32_SYSCALL_BIT; in __set_personality_x32()
679 current_thread_info()->status &= ~TS_COMPAT; in __set_personality_x32()
688 if (current->mm) in __set_personality_ia32()
689 current->mm->context.ia32_compat = TIF_IA32; in __set_personality_ia32()
690 current->personality |= force_personality32; in __set_personality_ia32()
692 task_pt_regs(current)->orig_ax = __NR_ia32_execve; in __set_personality_ia32()
693 current_thread_info()->status |= TS_COMPAT; in __set_personality_ia32()
718 return (long)image->size; in prctl_map_vdso()
729 return -EPERM; in do_arch_prctl_64()
743 * On non-FSGSBASE systems, save_base_legacy() expects in do_arch_prctl_64()
746 task->thread.gsbase = arg2; in do_arch_prctl_64()
749 task->thread.gsindex = 0; in do_arch_prctl_64()
761 return -EPERM; in do_arch_prctl_64()
773 * On non-FSGSBASE systems, save_base_legacy() expects in do_arch_prctl_64()
776 task->thread.fsbase = arg2; in do_arch_prctl_64()
778 task->thread.fsindex = 0; in do_arch_prctl_64()
811 ret = -EINVAL; in do_arch_prctl_64()
823 if (ret == -EINVAL) in SYSCALL_DEFINE2()
838 return task_pt_regs(task)->sp; in KSTK_ESP()