Generic Linux architectural discussions
 help / color / mirror / Atom feed
* [x86] BUG()/BUG_ON() macros cannot be disabled
@ 2018-09-25 11:35 Alexander Lochmann
  2018-09-25 11:35 ` Alexander Lochmann
  2018-09-25 12:06 ` Arnd Bergmann
  0 siblings, 2 replies; 12+ messages in thread
From: Alexander Lochmann @ 2018-09-25 11:35 UTC (permalink / raw)
  To: arnd; +Cc: linux-arch, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 975 bytes --]

Hi Arnd,

I recently tried to disable the BUG macros on x86-32. I disabled the
config item in 'General Setup -> Configure standard kernel features
(expert users) -> BUG() support'.
However, BUG/BUG_ON is still defined. In the !CONFIG_BUG branch in
include/asm-generic/bug.h (line 181) the code checks for the existence
of architecture-specific variants of those macros.
Since x86 defines its own version of BUG(), line 182 is *not* used.
In the following, the x86 variant of BUG() is then used to define the
BUG_ON() macro.

I propose a patch that really disables both macros if the developer
wants it.
It undefines the respective x86 variants, and defines both macros as
'empty' macros.

Regards,
Alex

-- 
Technische Universität Dortmund
Alexander Lochmann                PGP key: 0xBC3EF6FD
Otto-Hahn-Str. 16                 phone:  +49.231.7556141
D-44227 Dortmund                  fax:    +49.231.7556116
http://ess.cs.tu-dortmund.de/Staff/al

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: disable-bug-macro.patch --]
[-- Type: text/x-patch; name="disable-bug-macro.patch", Size: 766 bytes --]

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 20561a60db9c..1e7977582277 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -178,14 +178,17 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 })
 
 #else /* !CONFIG_BUG */
-#ifndef HAVE_ARCH_BUG
-#define BUG() do {} while (1)
+#ifdef HAVE_ARCH_BUG
+#undef BUG
 #endif
 
-#ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#ifdef HAVE_ARCH_BUG_ON
+#undef BUG_ON
 #endif
 
+#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#define BUG() do {} while (1)
+
 #ifndef HAVE_ARCH_WARN_ON
 #define WARN_ON(condition) ({						\
 	int __ret_warn_on = !!(condition);				\

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-09-25 19:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-25 11:35 [x86] BUG()/BUG_ON() macros cannot be disabled Alexander Lochmann
2018-09-25 11:35 ` Alexander Lochmann
2018-09-25 12:06 ` Arnd Bergmann
2018-09-25 12:06   ` Arnd Bergmann
2018-09-25 12:13   ` Alexander Lochmann
2018-09-25 12:13     ` Alexander Lochmann
2018-09-25 12:20     ` Arnd Bergmann
2018-09-25 12:20       ` Arnd Bergmann
2018-09-25 12:58       ` Alexander Lochmann
2018-09-25 12:58         ` Alexander Lochmann
2018-09-25 12:31   ` Alexander Stein
2018-09-25 12:31     ` Alexander Stein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox