^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/sched/task.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/current.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <as-layout.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <mem_user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <skas.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <os.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void flush_thread(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) void *data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) arch_flush_thread(¤t->thread.arch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ret = unmap(¤t->mm->context.id, 0, STUB_START, 0, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ret = ret || unmap(¤t->mm->context.id, STUB_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) host_task_size - STUB_END, 1, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) printk(KERN_ERR "flush_thread - clearing address space failed, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) "err = %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) force_sig(SIGKILL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) get_safe_registers(current_pt_regs()->regs.gp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) current_pt_regs()->regs.fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __switch_mm(¤t->mm->context.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) PT_REGS_IP(regs) = eip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) PT_REGS_SP(regs) = esp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) current->ptrace &= ~PT_DTRACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #ifdef SUBARCH_EXECVE1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) SUBARCH_EXECVE1(regs->regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) EXPORT_SYMBOL(start_thread);