| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * OpenRISC process.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 8 | 9 | * Modifications for the OpenRISC architecture: |
|---|
| 9 | 10 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> |
|---|
| 10 | 11 | * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or |
|---|
| 13 | | - * modify it under the terms of the GNU General Public License |
|---|
| 14 | | - * as published by the Free Software Foundation; either version |
|---|
| 15 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 16 | 12 | * |
|---|
| 17 | 13 | * This file handles the architecture-dependent parts of process handling... |
|---|
| 18 | 14 | */ |
|---|
| .. | .. |
|---|
| 40 | 36 | #include <linux/fs.h> |
|---|
| 41 | 37 | |
|---|
| 42 | 38 | #include <linux/uaccess.h> |
|---|
| 43 | | -#include <asm/pgtable.h> |
|---|
| 44 | 39 | #include <asm/io.h> |
|---|
| 45 | 40 | #include <asm/processor.h> |
|---|
| 46 | 41 | #include <asm/spr_defs.h> |
|---|
| .. | .. |
|---|
| 84 | 79 | */ |
|---|
| 85 | 80 | void arch_cpu_idle(void) |
|---|
| 86 | 81 | { |
|---|
| 87 | | - local_irq_enable(); |
|---|
| 82 | + raw_local_irq_enable(); |
|---|
| 88 | 83 | if (mfspr(SPR_UPR) & SPR_UPR_PMP) |
|---|
| 89 | 84 | mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME); |
|---|
| 90 | 85 | } |
|---|
| .. | .. |
|---|
| 126 | 121 | * @usp: user stack pointer or fn for kernel thread |
|---|
| 127 | 122 | * @arg: arg to fn for kernel thread; always NULL for userspace thread |
|---|
| 128 | 123 | * @p: the newly created task |
|---|
| 129 | | - * @regs: CPU context to copy for userspace thread; always NULL for kthread |
|---|
| 124 | + * @tls: the Thread Local Storage pointer for the new process |
|---|
| 130 | 125 | * |
|---|
| 131 | 126 | * At the top of a newly initialized kernel stack are two stacked pt_reg |
|---|
| 132 | 127 | * structures. The first (topmost) is the userspace context of the thread. |
|---|
| .. | .. |
|---|
| 152 | 147 | */ |
|---|
| 153 | 148 | |
|---|
| 154 | 149 | int |
|---|
| 155 | | -copy_thread(unsigned long clone_flags, unsigned long usp, |
|---|
| 156 | | - unsigned long arg, struct task_struct *p) |
|---|
| 150 | +copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg, |
|---|
| 151 | + struct task_struct *p, unsigned long tls) |
|---|
| 157 | 152 | { |
|---|
| 158 | 153 | struct pt_regs *userregs; |
|---|
| 159 | 154 | struct pt_regs *kregs; |
|---|
| .. | .. |
|---|
| 172 | 167 | sp -= sizeof(struct pt_regs); |
|---|
| 173 | 168 | kregs = (struct pt_regs *)sp; |
|---|
| 174 | 169 | |
|---|
| 175 | | - if (unlikely(p->flags & PF_KTHREAD)) { |
|---|
| 170 | + if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) { |
|---|
| 176 | 171 | memset(kregs, 0, sizeof(struct pt_regs)); |
|---|
| 177 | 172 | kregs->gpr[20] = usp; /* fn, kernel thread */ |
|---|
| 178 | 173 | kregs->gpr[22] = arg; |
|---|
| .. | .. |
|---|
| 183 | 178 | userregs->sp = usp; |
|---|
| 184 | 179 | |
|---|
| 185 | 180 | /* |
|---|
| 186 | | - * For CLONE_SETTLS set "tp" (r10) to the TLS pointer passed to sys_clone. |
|---|
| 187 | | - * |
|---|
| 188 | | - * The kernel entry is: |
|---|
| 189 | | - * int clone (long flags, void *child_stack, int *parent_tid, |
|---|
| 190 | | - * int *child_tid, struct void *tls) |
|---|
| 191 | | - * |
|---|
| 192 | | - * This makes the source r7 in the kernel registers. |
|---|
| 181 | + * For CLONE_SETTLS set "tp" (r10) to the TLS pointer. |
|---|
| 193 | 182 | */ |
|---|
| 194 | 183 | if (clone_flags & CLONE_SETTLS) |
|---|
| 195 | | - userregs->gpr[10] = userregs->gpr[7]; |
|---|
| 184 | + userregs->gpr[10] = tls; |
|---|
| 196 | 185 | |
|---|
| 197 | 186 | userregs->gpr[11] = 0; /* Result from fork() */ |
|---|
| 198 | 187 | |
|---|
| .. | .. |
|---|
| 223 | 212 | regs->pc = pc; |
|---|
| 224 | 213 | regs->sr = sr; |
|---|
| 225 | 214 | regs->sp = sp; |
|---|
| 226 | | -} |
|---|
| 227 | | - |
|---|
| 228 | | -/* Fill in the fpu structure for a core dump. */ |
|---|
| 229 | | -int dump_fpu(struct pt_regs *regs, elf_fpregset_t * fpu) |
|---|
| 230 | | -{ |
|---|
| 231 | | - /* TODO */ |
|---|
| 232 | | - return 0; |
|---|
| 233 | 215 | } |
|---|
| 234 | 216 | |
|---|
| 235 | 217 | extern struct thread_info *_switch(struct thread_info *old_ti, |
|---|