2019-05-29 10:18:00 -04:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2017-07-10 21:00:26 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_RISCV_BUG_H
|
|
|
|
#define _ASM_RISCV_BUG_H
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/const.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
#include <asm/asm.h>
|
|
|
|
|
2019-03-04 22:23:34 -05:00
|
|
|
#define __INSN_LENGTH_MASK _UL(0x3)
|
|
|
|
#define __INSN_LENGTH_32 _UL(0x3)
|
|
|
|
#define __COMPRESSED_INSN_MASK _UL(0xffff)
|
|
|
|
|
|
|
|
#define __BUG_INSN_32 _UL(0x00100073) /* ebreak */
|
|
|
|
#define __BUG_INSN_16 _UL(0x9002) /* c.ebreak */
|
2017-07-10 21:00:26 -04:00
|
|
|
|
|
|
|
typedef u32 bug_insn_t;
|
|
|
|
|
|
|
|
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
|
2017-11-29 20:55:13 -05:00
|
|
|
#define __BUG_ENTRY_ADDR RISCV_INT " 1b - 2b"
|
|
|
|
#define __BUG_ENTRY_FILE RISCV_INT " %0 - 2b"
|
2017-07-10 21:00:26 -04:00
|
|
|
#else
|
|
|
|
#define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
|
|
|
|
#define __BUG_ENTRY_FILE RISCV_PTR " %0"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_BUGVERBOSE
|
|
|
|
#define __BUG_ENTRY \
|
|
|
|
__BUG_ENTRY_ADDR "\n\t" \
|
|
|
|
__BUG_ENTRY_FILE "\n\t" \
|
2019-03-04 22:23:33 -05:00
|
|
|
RISCV_SHORT " %1\n\t" \
|
|
|
|
RISCV_SHORT " %2"
|
2017-07-10 21:00:26 -04:00
|
|
|
#else
|
|
|
|
#define __BUG_ENTRY \
|
2019-03-04 22:23:33 -05:00
|
|
|
__BUG_ENTRY_ADDR "\n\t" \
|
|
|
|
RISCV_SHORT " %2"
|
2017-07-10 21:00:26 -04:00
|
|
|
#endif
|
|
|
|
|
2019-10-17 13:37:29 -04:00
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
2019-03-04 22:23:33 -05:00
|
|
|
#define __BUG_FLAGS(flags) \
|
2017-07-10 21:00:26 -04:00
|
|
|
do { \
|
|
|
|
__asm__ __volatile__ ( \
|
|
|
|
"1:\n\t" \
|
|
|
|
"ebreak\n" \
|
2019-03-04 22:23:33 -05:00
|
|
|
".pushsection __bug_table,\"aw\"\n\t" \
|
2017-07-10 21:00:26 -04:00
|
|
|
"2:\n\t" \
|
|
|
|
__BUG_ENTRY "\n\t" \
|
2019-03-04 22:23:33 -05:00
|
|
|
".org 2b + %3\n\t" \
|
2017-07-10 21:00:26 -04:00
|
|
|
".popsection" \
|
|
|
|
: \
|
|
|
|
: "i" (__FILE__), "i" (__LINE__), \
|
2019-03-04 22:23:33 -05:00
|
|
|
"i" (flags), \
|
|
|
|
"i" (sizeof(struct bug_entry))); \
|
2017-07-10 21:00:26 -04:00
|
|
|
} while (0)
|
|
|
|
#else /* CONFIG_GENERIC_BUG */
|
2019-03-04 22:23:33 -05:00
|
|
|
#define __BUG_FLAGS(flags) do { \
|
2017-07-10 21:00:26 -04:00
|
|
|
__asm__ __volatile__ ("ebreak\n"); \
|
|
|
|
} while (0)
|
|
|
|
#endif /* CONFIG_GENERIC_BUG */
|
|
|
|
|
2019-03-04 22:23:33 -05:00
|
|
|
#define BUG() do { \
|
|
|
|
__BUG_FLAGS(0); \
|
|
|
|
unreachable(); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
|
|
|
|
|
2017-07-10 21:00:26 -04:00
|
|
|
#define HAVE_ARCH_BUG
|
|
|
|
|
|
|
|
#include <asm-generic/bug.h>
|
|
|
|
|
|
|
|
struct pt_regs;
|
|
|
|
struct task_struct;
|
|
|
|
|
2019-10-17 13:37:29 -04:00
|
|
|
void die(struct pt_regs *regs, const char *str);
|
|
|
|
void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr);
|
2017-07-10 21:00:26 -04:00
|
|
|
|
|
|
|
#endif /* _ASM_RISCV_BUG_H */
|