linux/arch/csky/kernel/process.c
Linus Torvalds 2044513ffe arch/csky patches for 5.9-rc1
Features:
  - seccomp-filter
  - err-injection
  - top-down&random mmap-layout
  - irq_work
  - show_ipi
  - context-tracking)
 
 Fixup & Optimize:
  - kprobe_on_ftrace
  - optimize panic print
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE2KAv+isbWR/viAKHAXH1GYaIxXsFAl8rSUESHHJlbl9ndW9A
 Yy1za3kuY29tAAoJEAFx9RmGiMV7REoP/jABI6Xa3YH5Xfh4Xmr/CSM7vYMMMjsc
 2+t1tJ9EHrOR4wEhG6bX8C2uGwtnwb9u5B9JY1fQ9nbrLtKPNlhpq9ukOmztOqEp
 EuAZZ3NildOKdRwyK4SaV3Mf1TbPg75EX7u/MuwQuTy3dKqvSu3VigJ3XN2VvpOz
 orbRID0FMYAG76QCqCm3ddrUD/Jm6IIeMpCxEF5VT05+OBdmmuYS6uOF8Cmm432F
 OX2WZhoo8vjNe+orVPxNxTojuBXve/ygHGLq7CSMZuoJdoArQKKD7+fpAupDR9qq
 LWZMqfYRmIPXsWT/MlZVb/w2AHDKvZXPWvDT7Imw3Y7A/jMNd4zbULXt0S3Pq3Y/
 LMC8SvC9Ag5GZLKPKj3f+1G4rr3h/WT4Ey6QURiHoxEVO91tdRyRY5JMjDf0W18K
 XMl4pDEbFHNGl8Ph+fBeTwTNCsH2PkHP8ESUHLIw+2wbNSk+9XvjGJ7dC3wffVp4
 oZcGB/8EPLGxTgM+pXfiP1M39B58ku+Duf1iNXXx3RDA7znSpVRCAmCk2jXygXmH
 NsRBg/lNxD7ZeHLbH1qIbROzIRV1scvnt5iUM8J15SnW21xK3VisrcHUWiB7xHrr
 u0lLAW0mG1wpK78TXIO7jlHYMgy5er5pMIGJ9e2UJHYJ13h8p1s6PKXSXERprSjc
 0HqOLF0bxcse
 =l7rw
 -----END PGP SIGNATURE-----

Merge tag 'csky-for-linus-5.9-rc1' of https://github.com/c-sky/csky-linux

Pull arch/csky updates from Guo Ren:
 "New features:
   - seccomp-filter
   - err-injection
   - top-down&random mmap-layout
   - irq_work
   - show_ipi
   - context-tracking

  Fixes & Optimizations:
   - kprobe_on_ftrace
   - optimize panic print"

* tag 'csky-for-linus-5.9-rc1' of https://github.com/c-sky/csky-linux:
  csky: Add context tracking support
  csky: Add arch_show_interrupts for IPI interrupts
  csky: Add irq_work support
  csky: Fixup warning by EXPORT_SYMBOL(kmap)
  csky: Set CONFIG_NR_CPU 4 as default
  csky: Use top-down mmap layout
  csky: Optimize the trap processing flow
  csky: Add support for function error injection
  csky: Fixup kprobes handler couldn't change pc
  csky: Fixup duplicated restore sp in RESTORE_REGS_FTRACE
  csky: Add cpu feature register hint for smp
  csky: Add SECCOMP_FILTER supported
  csky: remove unusued thread_saved_pc and *_segments functions/macros
2020-08-06 10:15:28 -07:00

108 lines
2.4 KiB
C

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
#include <linux/module.h>
#include <linux/version.h>
#include <linux/sched.h>
#include <linux/sched/task_stack.h>
#include <linux/sched/debug.h>
#include <linux/delay.h>
#include <linux/kallsyms.h>
#include <linux/uaccess.h>
#include <linux/ptrace.h>
#include <asm/elf.h>
#include <abi/reg_ops.h>
struct cpuinfo_csky cpu_data[NR_CPUS];
#ifdef CONFIG_STACKPROTECTOR
#include <linux/stackprotector.h>
unsigned long __stack_chk_guard __read_mostly;
EXPORT_SYMBOL(__stack_chk_guard);
#endif
asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);
/*
* Some archs flush debug and FPU info here
*/
void flush_thread(void){}
int copy_thread(unsigned long clone_flags,
unsigned long usp,
unsigned long kthread_arg,
struct task_struct *p,
unsigned long tls)
{
struct switch_stack *childstack;
struct pt_regs *childregs = task_pt_regs(p);
#ifdef CONFIG_CPU_HAS_FPU
save_to_user_fp(&p->thread.user_fp);
#endif
childstack = ((struct switch_stack *) childregs) - 1;
memset(childstack, 0, sizeof(struct switch_stack));
/* setup thread.sp for switch_to !!! */
p->thread.sp = (unsigned long)childstack;
if (unlikely(p->flags & PF_KTHREAD)) {
memset(childregs, 0, sizeof(struct pt_regs));
childstack->r15 = (unsigned long) ret_from_kernel_thread;
childstack->r10 = kthread_arg;
childstack->r9 = usp;
childregs->sr = mfcr("psr");
} else {
*childregs = *(current_pt_regs());
if (usp)
childregs->usp = usp;
if (clone_flags & CLONE_SETTLS)
task_thread_info(p)->tp_value = childregs->tls
= tls;
childregs->a0 = 0;
childstack->r15 = (unsigned long) ret_from_fork;
}
return 0;
}
/* Fill in the fpu structure for a core dump. */
int dump_fpu(struct pt_regs *regs, struct user_fp *fpu)
{
memcpy(fpu, &current->thread.user_fp, sizeof(*fpu));
return 1;
}
EXPORT_SYMBOL(dump_fpu);
int dump_task_regs(struct task_struct *tsk, elf_gregset_t *pr_regs)
{
struct pt_regs *regs = task_pt_regs(tsk);
/* NOTE: usp is error value. */
ELF_CORE_COPY_REGS((*pr_regs), regs)
return 1;
}
#ifndef CONFIG_CPU_PM_NONE
void arch_cpu_idle(void)
{
#ifdef CONFIG_CPU_PM_WAIT
asm volatile("wait\n");
#endif
#ifdef CONFIG_CPU_PM_DOZE
asm volatile("doze\n");
#endif
#ifdef CONFIG_CPU_PM_STOP
asm volatile("stop\n");
#endif
local_irq_enable();
}
#endif