18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _PARISC_BUG_H 38c2ecf20Sopenharmony_ci#define _PARISC_BUG_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/kernel.h> /* for BUGFLAG_TAINT */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* 88c2ecf20Sopenharmony_ci * Tell the user there is some problem. 98c2ecf20Sopenharmony_ci * The offending file and line are encoded in the __bug_table section. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifdef CONFIG_BUG 138c2ecf20Sopenharmony_ci#define HAVE_ARCH_BUG 148c2ecf20Sopenharmony_ci#define HAVE_ARCH_WARN_ON 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* the break instruction is used as BUG() marker. */ 178c2ecf20Sopenharmony_ci#define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff" 188c2ecf20Sopenharmony_ci#define PARISC_BUG_BREAK_INSN 0x03ffe01f /* PARISC_BUG_BREAK_ASM */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#if defined(CONFIG_64BIT) 218c2ecf20Sopenharmony_ci#define ASM_WORD_INSN ".dword\t" 228c2ecf20Sopenharmony_ci#else 238c2ecf20Sopenharmony_ci#define ASM_WORD_INSN ".word\t" 248c2ecf20Sopenharmony_ci#endif 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_BUGVERBOSE 278c2ecf20Sopenharmony_ci#define BUG() \ 288c2ecf20Sopenharmony_ci do { \ 298c2ecf20Sopenharmony_ci asm volatile("\n" \ 308c2ecf20Sopenharmony_ci "1:\t" PARISC_BUG_BREAK_ASM "\n" \ 318c2ecf20Sopenharmony_ci "\t.pushsection __bug_table,\"aw\"\n" \ 328c2ecf20Sopenharmony_ci "2:\t" ASM_WORD_INSN "1b, %c0\n" \ 338c2ecf20Sopenharmony_ci "\t.short %c1, %c2\n" \ 348c2ecf20Sopenharmony_ci "\t.org 2b+%c3\n" \ 358c2ecf20Sopenharmony_ci "\t.popsection" \ 368c2ecf20Sopenharmony_ci : : "i" (__FILE__), "i" (__LINE__), \ 378c2ecf20Sopenharmony_ci "i" (0), "i" (sizeof(struct bug_entry)) ); \ 388c2ecf20Sopenharmony_ci unreachable(); \ 398c2ecf20Sopenharmony_ci } while(0) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#else 428c2ecf20Sopenharmony_ci#define BUG() \ 438c2ecf20Sopenharmony_ci do { \ 448c2ecf20Sopenharmony_ci asm volatile(PARISC_BUG_BREAK_ASM : : ); \ 458c2ecf20Sopenharmony_ci unreachable(); \ 468c2ecf20Sopenharmony_ci } while(0) 478c2ecf20Sopenharmony_ci#endif 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_BUGVERBOSE 508c2ecf20Sopenharmony_ci#define __WARN_FLAGS(flags) \ 518c2ecf20Sopenharmony_ci do { \ 528c2ecf20Sopenharmony_ci asm volatile("\n" \ 538c2ecf20Sopenharmony_ci "1:\t" PARISC_BUG_BREAK_ASM "\n" \ 548c2ecf20Sopenharmony_ci "\t.pushsection __bug_table,\"aw\"\n" \ 558c2ecf20Sopenharmony_ci "2:\t" ASM_WORD_INSN "1b, %c0\n" \ 568c2ecf20Sopenharmony_ci "\t.short %c1, %c2\n" \ 578c2ecf20Sopenharmony_ci "\t.org 2b+%c3\n" \ 588c2ecf20Sopenharmony_ci "\t.popsection" \ 598c2ecf20Sopenharmony_ci : : "i" (__FILE__), "i" (__LINE__), \ 608c2ecf20Sopenharmony_ci "i" (BUGFLAG_WARNING|(flags)), \ 618c2ecf20Sopenharmony_ci "i" (sizeof(struct bug_entry)) ); \ 628c2ecf20Sopenharmony_ci } while(0) 638c2ecf20Sopenharmony_ci#else 648c2ecf20Sopenharmony_ci#define __WARN_FLAGS(flags) \ 658c2ecf20Sopenharmony_ci do { \ 668c2ecf20Sopenharmony_ci asm volatile("\n" \ 678c2ecf20Sopenharmony_ci "1:\t" PARISC_BUG_BREAK_ASM "\n" \ 688c2ecf20Sopenharmony_ci "\t.pushsection __bug_table,\"aw\"\n" \ 698c2ecf20Sopenharmony_ci "2:\t" ASM_WORD_INSN "1b\n" \ 708c2ecf20Sopenharmony_ci "\t.short %c0\n" \ 718c2ecf20Sopenharmony_ci "\t.org 2b+%c1\n" \ 728c2ecf20Sopenharmony_ci "\t.popsection" \ 738c2ecf20Sopenharmony_ci : : "i" (BUGFLAG_WARNING|(flags)), \ 748c2ecf20Sopenharmony_ci "i" (sizeof(struct bug_entry)) ); \ 758c2ecf20Sopenharmony_ci } while(0) 768c2ecf20Sopenharmony_ci#endif 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#define WARN_ON(x) ({ \ 808c2ecf20Sopenharmony_ci int __ret_warn_on = !!(x); \ 818c2ecf20Sopenharmony_ci if (__builtin_constant_p(__ret_warn_on)) { \ 828c2ecf20Sopenharmony_ci if (__ret_warn_on) \ 838c2ecf20Sopenharmony_ci __WARN(); \ 848c2ecf20Sopenharmony_ci } else { \ 858c2ecf20Sopenharmony_ci if (unlikely(__ret_warn_on)) \ 868c2ecf20Sopenharmony_ci __WARN(); \ 878c2ecf20Sopenharmony_ci } \ 888c2ecf20Sopenharmony_ci unlikely(__ret_warn_on); \ 898c2ecf20Sopenharmony_ci}) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#endif 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#include <asm-generic/bug.h> 948c2ecf20Sopenharmony_ci#endif 958c2ecf20Sopenharmony_ci 96