mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-24 05:04:00 +08:00
a84d2d2906
This round of csky subsystem gives two features (ASID algorithm update, Perf pmu record support) and some fixups. Feature: - csky: Revert mmu ASID mechanism - csky: Add new asid lib code from arm - csky: Use generic asid algorithm to implement switch_mm - csky: Improve tlb operation with help of asid - csky: Init pmu as a device - csky: Add count-width property for csky pmu - csky: Add pmu interrupt support - csky: Fix perf record in kernel/user space - dt-bindings: csky: Add csky PMU bindings Fixup: - csky: Fixup no panic in kernel for some traps - csky: Fixup some error count in 810 & 860. - csky: Fixup abiv1 memset error CI-Tested: https://gitlab.com/c-sky/buildroot/pipelines/68656845 -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE2KAv+isbWR/viAKHAXH1GYaIxXsFAl0xaiwSHHJlbl9ndW9A Yy1za3kuY29tAAoJEAFx9RmGiMV7+PgP/3mbYMf42AicPZHF/m4QkK9+wProS3TF ctu8Qzncue8SDMELKXWegnU6svB7wntL69wFbr53zQr4Kxyo0PS6QM1HrbIUHMZ/ rnwGKAMHTP1yjwN89TZ7F0IIb2WPlbEyrJnYSJ4FvtUM/YWI310POibtFOpGztUw Wx/ioTharhtOipkkVMITYZRFnIQMm4j4I2YDROsSHbEGPy0QdrQ7nZvYiRAa7X50 tDjXPNeV8+r5wlhMybCjykcdypPtFXv/na+9uwboO2RRapkUQx6J8Q9NG2SqTs4e EWrOAOnpniA3lahBuivhHfQrd9nxHAKfy0C/7Rhs9PTiU5dwETPILh2bF2TqnBZt XHohUyIxec6KmuY1o3/IOAhaAg8WCouVG3EtVv19qHxReWrlzc7RnQZ/j276BhcS BCB3b7WgrNES5i73gRPEQGFOxbML53uzoWShUZkAhQC5hepNqQNcvBmz/ecshbMM qL4p1uz3ol9yCylVcw1U5hzGjzChRGLj95MDeYuCMgDXybCzL8XevBuoOYB30r56 tJJ2cSF3qkkB4a95OOAnxO+NgT88VXaXxA7/lzjFJjce5jH1ZN1e+GlYLDDyfVfT 073j3GlhHUbzR5InQEJhHQW/1zKUOTV9H28dW3yJdlbrwAEroYPIJE+k+GSpS3Dq oNp4p5jePTZu =PbF1 -----END PGP SIGNATURE----- Merge tag 'csky-for-linus-5.3-rc1' of git://github.com/c-sky/csky-linux Pull arch/csky pupdates from Guo Ren: "This round of csky subsystem gives two features (ASID algorithm update, Perf pmu record support) and some fixups. ASID updates: - Revert mmu ASID mechanism - Add new asid lib code from arm - Use generic asid algorithm to implement switch_mm - Improve tlb operation with help of asid Perf pmu record support: - Init pmu as a device - Add count-width property for csky pmu - Add pmu interrupt support - Fix perf record in kernel/user space - dt-bindings: Add csky PMU bindings Fixes: - Fixup no panic in kernel for some traps - Fixup some error count in 810 & 860. - Fixup abiv1 memset error" * tag 'csky-for-linus-5.3-rc1' of git://github.com/c-sky/csky-linux: csky: Fixup abiv1 memset error csky: Improve tlb operation with help of asid csky: Use generic asid algorithm to implement switch_mm csky: Add new asid lib code from arm csky: Revert mmu ASID mechanism dt-bindings: csky: Add csky PMU bindings dt-bindings: interrupt-controller: Update csky mpintc csky: Fixup some error count in 810 & 860. csky: Fix perf record in kernel/user space csky: Add pmu interrupt support csky: Add count-width property for csky pmu csky: Init pmu as a device csky: Fixup no panic in kernel for some traps csky: Select intc & timer drivers
169 lines
3.4 KiB
C
169 lines
3.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
|
|
|
|
#include <linux/sched.h>
|
|
#include <linux/signal.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/module.h>
|
|
#include <linux/user.h>
|
|
#include <linux/string.h>
|
|
#include <linux/linkage.h>
|
|
#include <linux/init.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/rtc.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <asm/setup.h>
|
|
#include <asm/traps.h>
|
|
#include <asm/pgalloc.h>
|
|
#include <asm/siginfo.h>
|
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
#ifdef CONFIG_CPU_HAS_FPU
|
|
#include <abi/fpu.h>
|
|
#endif
|
|
|
|
/* Defined in entry.S */
|
|
asmlinkage void csky_trap(void);
|
|
|
|
asmlinkage void csky_systemcall(void);
|
|
asmlinkage void csky_cmpxchg(void);
|
|
asmlinkage void csky_get_tls(void);
|
|
asmlinkage void csky_irq(void);
|
|
|
|
asmlinkage void csky_tlbinvalidl(void);
|
|
asmlinkage void csky_tlbinvalids(void);
|
|
asmlinkage void csky_tlbmodified(void);
|
|
|
|
/* Defined in head.S */
|
|
asmlinkage void _start_smp_secondary(void);
|
|
|
|
void __init pre_trap_init(void)
|
|
{
|
|
int i;
|
|
|
|
mtcr("vbr", vec_base);
|
|
|
|
for (i = 1; i < 128; i++)
|
|
VEC_INIT(i, csky_trap);
|
|
}
|
|
|
|
void __init trap_init(void)
|
|
{
|
|
VEC_INIT(VEC_AUTOVEC, csky_irq);
|
|
|
|
/* setup trap0 trap2 trap3 */
|
|
VEC_INIT(VEC_TRAP0, csky_systemcall);
|
|
VEC_INIT(VEC_TRAP2, csky_cmpxchg);
|
|
VEC_INIT(VEC_TRAP3, csky_get_tls);
|
|
|
|
/* setup MMU TLB exception */
|
|
VEC_INIT(VEC_TLBINVALIDL, csky_tlbinvalidl);
|
|
VEC_INIT(VEC_TLBINVALIDS, csky_tlbinvalids);
|
|
VEC_INIT(VEC_TLBMODIFIED, csky_tlbmodified);
|
|
|
|
#ifdef CONFIG_CPU_HAS_FPU
|
|
init_fpu();
|
|
#endif
|
|
|
|
#ifdef CONFIG_SMP
|
|
mtcr("cr<28, 0>", virt_to_phys(vec_base));
|
|
|
|
VEC_INIT(VEC_RESET, (void *)virt_to_phys(_start_smp_secondary));
|
|
#endif
|
|
}
|
|
|
|
void die_if_kernel(char *str, struct pt_regs *regs, int nr)
|
|
{
|
|
if (user_mode(regs))
|
|
return;
|
|
|
|
console_verbose();
|
|
pr_err("%s: %08x\n", str, nr);
|
|
show_regs(regs);
|
|
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
|
|
do_exit(SIGSEGV);
|
|
}
|
|
|
|
void buserr(struct pt_regs *regs)
|
|
{
|
|
#ifdef CONFIG_CPU_CK810
|
|
static unsigned long prev_pc;
|
|
|
|
if ((regs->pc == prev_pc) && prev_pc != 0) {
|
|
prev_pc = 0;
|
|
} else {
|
|
prev_pc = regs->pc;
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
die_if_kernel("Kernel mode BUS error", regs, 0);
|
|
|
|
pr_err("User mode Bus Error\n");
|
|
show_regs(regs);
|
|
|
|
force_sig_fault(SIGSEGV, 0, (void __user *)regs->pc);
|
|
}
|
|
|
|
#define USR_BKPT 0x1464
|
|
asmlinkage void trap_c(struct pt_regs *regs)
|
|
{
|
|
int sig;
|
|
unsigned long vector;
|
|
siginfo_t info;
|
|
|
|
vector = (mfcr("psr") >> 16) & 0xff;
|
|
|
|
switch (vector) {
|
|
case VEC_ZERODIV:
|
|
die_if_kernel("Kernel mode ZERO DIV", regs, vector);
|
|
sig = SIGFPE;
|
|
break;
|
|
/* ptrace */
|
|
case VEC_TRACE:
|
|
info.si_code = TRAP_TRACE;
|
|
sig = SIGTRAP;
|
|
break;
|
|
case VEC_ILLEGAL:
|
|
die_if_kernel("Kernel mode ILLEGAL", regs, vector);
|
|
#ifndef CONFIG_CPU_NO_USER_BKPT
|
|
if (*(uint16_t *)instruction_pointer(regs) != USR_BKPT)
|
|
#endif
|
|
{
|
|
sig = SIGILL;
|
|
break;
|
|
}
|
|
/* gdbserver breakpoint */
|
|
case VEC_TRAP1:
|
|
/* jtagserver breakpoint */
|
|
case VEC_BREAKPOINT:
|
|
die_if_kernel("Kernel mode BKPT", regs, vector);
|
|
info.si_code = TRAP_BRKPT;
|
|
sig = SIGTRAP;
|
|
break;
|
|
case VEC_ACCESS:
|
|
return buserr(regs);
|
|
#ifdef CONFIG_CPU_NEED_SOFTALIGN
|
|
case VEC_ALIGN:
|
|
return csky_alignment(regs);
|
|
#endif
|
|
#ifdef CONFIG_CPU_HAS_FPU
|
|
case VEC_FPE:
|
|
die_if_kernel("Kernel mode FPE", regs, vector);
|
|
return fpu_fpe(regs);
|
|
case VEC_PRIV:
|
|
die_if_kernel("Kernel mode PRIV", regs, vector);
|
|
if (fpu_libc_helper(regs))
|
|
return;
|
|
#endif
|
|
default:
|
|
sig = SIGSEGV;
|
|
break;
|
|
}
|
|
send_sig(sig, current, 0);
|
|
}
|