mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 10:25:06 +07:00
ee72e0e70c
The macro __BUG_INSN currently is defined as the "ebreak" opcode. The is_valid_bugaddr() function compares the instruction pointed to by $sepc with macro __BUG_INSN to check whether the current trap exception is caused by an "ebreak" instruction. However, this check flow is possibly erroneous because if C extension is supported, the expected trap instruction "ebreak" is possibly translated to "c.ebreak" by the assembler. Therefore, it requires a mechanism to distinguish the length of the instruction in $spec and compare it to the correct trap instruction. Signed-off-by: Vincent Chen <vincentc@andestech.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
102 lines
2.5 KiB
C
102 lines
2.5 KiB
C
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation, version 2.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#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>
|
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
|
#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 */
|
|
|
|
#ifndef __ASSEMBLY__
|
|
typedef u32 bug_insn_t;
|
|
|
|
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
|
|
#define __BUG_ENTRY_ADDR RISCV_INT " 1b - 2b"
|
|
#define __BUG_ENTRY_FILE RISCV_INT " %0 - 2b"
|
|
#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" \
|
|
RISCV_SHORT " %1\n\t" \
|
|
RISCV_SHORT " %2"
|
|
#else
|
|
#define __BUG_ENTRY \
|
|
__BUG_ENTRY_ADDR "\n\t" \
|
|
RISCV_SHORT " %2"
|
|
#endif
|
|
|
|
#define __BUG_FLAGS(flags) \
|
|
do { \
|
|
__asm__ __volatile__ ( \
|
|
"1:\n\t" \
|
|
"ebreak\n" \
|
|
".pushsection __bug_table,\"aw\"\n\t" \
|
|
"2:\n\t" \
|
|
__BUG_ENTRY "\n\t" \
|
|
".org 2b + %3\n\t" \
|
|
".popsection" \
|
|
: \
|
|
: "i" (__FILE__), "i" (__LINE__), \
|
|
"i" (flags), \
|
|
"i" (sizeof(struct bug_entry))); \
|
|
} while (0)
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
#else /* CONFIG_GENERIC_BUG */
|
|
#ifndef __ASSEMBLY__
|
|
#define __BUG_FLAGS(flags) do { \
|
|
__asm__ __volatile__ ("ebreak\n"); \
|
|
} while (0)
|
|
#endif /* !__ASSEMBLY__ */
|
|
#endif /* CONFIG_GENERIC_BUG */
|
|
|
|
#define BUG() do { \
|
|
__BUG_FLAGS(0); \
|
|
unreachable(); \
|
|
} while (0)
|
|
|
|
#define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
|
|
|
|
#define HAVE_ARCH_BUG
|
|
|
|
#include <asm-generic/bug.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
struct pt_regs;
|
|
struct task_struct;
|
|
|
|
extern void die(struct pt_regs *regs, const char *str);
|
|
extern void do_trap(struct pt_regs *regs, int signo, int code,
|
|
unsigned long addr, struct task_struct *tsk);
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_RISCV_BUG_H */
|