traps.c (642073c306e66daca108cb630d169129e50a6ba3) traps.c (af0ead42f69389cd4ed68e1a4c6cde45c0adb35c)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6#include <linux/cpu.h>
7#include <linux/kernel.h>
8#include <linux/init.h>

--- 7 unchanged lines hidden (view full) ---

16#include <linux/mm.h>
17#include <linux/module.h>
18#include <linux/irq.h>
19#include <linux/kexec.h>
20#include <linux/entry-common.h>
21
22#include <asm/asm-prototypes.h>
23#include <asm/bug.h>
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6#include <linux/cpu.h>
7#include <linux/kernel.h>
8#include <linux/init.h>

--- 7 unchanged lines hidden (view full) ---

16#include <linux/mm.h>
17#include <linux/module.h>
18#include <linux/irq.h>
19#include <linux/kexec.h>
20#include <linux/entry-common.h>
21
22#include <asm/asm-prototypes.h>
23#include <asm/bug.h>
24#include <asm/cfi.h>
24#include <asm/csr.h>
25#include <asm/processor.h>
26#include <asm/ptrace.h>
27#include <asm/syscall.h>
28#include <asm/thread_info.h>
29#include <asm/vector.h>
30#include <asm/irq_stack.h>
31

--- 234 unchanged lines hidden (view full) ---

266
267 if (user_mode(regs))
268 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc);
269#ifdef CONFIG_KGDB
270 else if (notify_die(DIE_TRAP, "EBREAK", regs, 0, regs->cause, SIGTRAP)
271 == NOTIFY_STOP)
272 return;
273#endif
25#include <asm/csr.h>
26#include <asm/processor.h>
27#include <asm/ptrace.h>
28#include <asm/syscall.h>
29#include <asm/thread_info.h>
30#include <asm/vector.h>
31#include <asm/irq_stack.h>
32

--- 234 unchanged lines hidden (view full) ---

267
268 if (user_mode(regs))
269 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc);
270#ifdef CONFIG_KGDB
271 else if (notify_die(DIE_TRAP, "EBREAK", regs, 0, regs->cause, SIGTRAP)
272 == NOTIFY_STOP)
273 return;
274#endif
274 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN)
275 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN ||
276 handle_cfi_failure(regs) == BUG_TRAP_TYPE_WARN)
275 regs->epc += get_break_insn_length(regs->epc);
276 else
277 die(regs, "Kernel BUG");
278}
279
280asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs)
281{
282 if (user_mode(regs)) {

--- 9 unchanged lines hidden (view full) ---

292
293 irqentry_nmi_exit(regs, state);
294 }
295}
296
297asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
298{
299 if (user_mode(regs)) {
277 regs->epc += get_break_insn_length(regs->epc);
278 else
279 die(regs, "Kernel BUG");
280}
281
282asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs)
283{
284 if (user_mode(regs)) {

--- 9 unchanged lines hidden (view full) ---

294
295 irqentry_nmi_exit(regs, state);
296 }
297}
298
299asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
300{
301 if (user_mode(regs)) {
300 long syscall = regs->a7;
302 ulong syscall = regs->a7;
301
302 regs->epc += 4;
303 regs->orig_a0 = regs->a0;
304
305 riscv_v_vstate_discard(regs);
306
307 syscall = syscall_enter_from_user_mode(regs, syscall);
308
303
304 regs->epc += 4;
305 regs->orig_a0 = regs->a0;
306
307 riscv_v_vstate_discard(regs);
308
309 syscall = syscall_enter_from_user_mode(regs, syscall);
310
309 if (syscall >= 0 && syscall < NR_syscalls)
311 if (syscall < NR_syscalls)
310 syscall_handler(regs, syscall);
312 syscall_handler(regs, syscall);
311 else if (syscall != -1)
313 else
312 regs->a0 = -ENOSYS;
313
314 syscall_exit_to_user_mode(regs);
315 } else {
316 irqentry_state_t state = irqentry_nmi_enter(regs);
317
318 do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->epc,
319 "Oops - environment call from U-mode");

--- 47 unchanged lines hidden (view full) ---

367 REG_L" s0, (sp) \n"
368 "addi sp, sp, "RISCV_SZPTR "\n"
369 REG_L" ra, (sp) \n"
370 "addi sp, sp, "RISCV_SZPTR "\n"
371 :
372 : [sp] "r" (sp), [regs] "r" (regs)
373 : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
374 "t0", "t1", "t2", "t3", "t4", "t5", "t6",
314 regs->a0 = -ENOSYS;
315
316 syscall_exit_to_user_mode(regs);
317 } else {
318 irqentry_state_t state = irqentry_nmi_enter(regs);
319
320 do_trap_error(regs, SIGILL, ILL_ILLTRP, regs->epc,
321 "Oops - environment call from U-mode");

--- 47 unchanged lines hidden (view full) ---

369 REG_L" s0, (sp) \n"
370 "addi sp, sp, "RISCV_SZPTR "\n"
371 REG_L" ra, (sp) \n"
372 "addi sp, sp, "RISCV_SZPTR "\n"
373 :
374 : [sp] "r" (sp), [regs] "r" (regs)
375 : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
376 "t0", "t1", "t2", "t3", "t4", "t5", "t6",
375#ifndef CONFIG_FRAME_POINTER
376 "s0",
377#endif
378 "memory");
379 } else
380#endif
381 handle_riscv_irq(regs);
382
383 irqentry_exit(regs, state);
384}
385

--- 74 unchanged lines hidden ---
377 "memory");
378 } else
379#endif
380 handle_riscv_irq(regs);
381
382 irqentry_exit(regs, state);
383}
384

--- 74 unchanged lines hidden ---