hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/lib/bug.c
....@@ -47,6 +47,9 @@
4747 #include <linux/bug.h>
4848 #include <linux/sched.h>
4949 #include <linux/rculist.h>
50
+#include <linux/ftrace.h>
51
+
52
+#include <trace/hooks/bug.h>
5053
5154 extern struct bug_entry __start___bug_table[], __stop___bug_table[];
5255
....@@ -153,6 +156,8 @@
153156 if (!bug)
154157 return BUG_TRAP_TYPE_NONE;
155158
159
+ disable_trace_on_warning();
160
+
156161 file = NULL;
157162 line = 0;
158163
....@@ -178,6 +183,15 @@
178183 bug->flags |= BUGFLAG_DONE;
179184 }
180185
186
+ /*
187
+ * BUG() and WARN_ON() families don't print a custom debug message
188
+ * before triggering the exception handler, so we must add the
189
+ * "cut here" line now. WARN() issues its own "cut here" before the
190
+ * extra debugging message it writes before triggering the handler.
191
+ */
192
+ if ((bug->flags & BUGFLAG_NO_CUT_HERE) == 0)
193
+ printk(KERN_DEFAULT CUT_HERE);
194
+
181195 if (warning) {
182196 /* this is a WARN_ON rather than BUG/BUG_ON */
183197 __warn(file, line, (void *)bugaddr, BUG_GET_TAINT(bug), regs,
....@@ -185,13 +199,14 @@
185199 return BUG_TRAP_TYPE_WARN;
186200 }
187201
188
- printk(KERN_DEFAULT CUT_HERE);
189
-
190202 if (file)
191203 pr_crit("kernel BUG at %s:%u!\n", file, line);
192204 else
193205 pr_crit("Kernel BUG at %pB [verbose debug info unavailable]\n",
194206 (void *)bugaddr);
207
+ pr_flush(1000, true);
208
+
209
+ trace_android_rvh_report_bug(file, line, bugaddr);
195210
196211 return BUG_TRAP_TYPE_BUG;
197212 }