Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bug: Add report_bug_entry()

Add a report_bug() variant where the bug_entry is already known. This
is useful when the exception instruction is not instantiated per-site.
But instead has a single instance. In such a case the bug_entry
address might be passed along in a known register or something.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251110115757.575795595@infradead.org

+29 -7
+8
include/linux/bug.h
··· 42 42 struct bug_entry *find_bug(unsigned long bugaddr); 43 43 44 44 enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs); 45 + enum bug_trap_type report_bug_entry(struct bug_entry *bug, struct pt_regs *regs); 45 46 46 47 /* These are defined by the architecture */ 47 48 int is_valid_bugaddr(unsigned long addr); ··· 63 62 } 64 63 65 64 struct bug_entry; 65 + 66 + static inline enum bug_trap_type 67 + report_bug_entry(struct bug_entry *bug, struct pt_regs *regs) 68 + { 69 + return BUG_TRAP_TYPE_BUG; 70 + } 71 + 66 72 static inline void bug_get_file_line(struct bug_entry *bug, const char **file, 67 73 unsigned int *line) 68 74 {
+21 -7
lib/bug.c
··· 183 183 printk("%s", fmt); 184 184 } 185 185 186 - static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *regs) 186 + static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs) 187 187 { 188 188 bool warning, once, done, no_cut, has_args; 189 189 const char *file, *fmt; 190 190 unsigned line; 191 191 192 - if (!is_valid_bugaddr(bugaddr)) 193 - return BUG_TRAP_TYPE_NONE; 192 + if (!bug) { 193 + if (!is_valid_bugaddr(bugaddr)) 194 + return BUG_TRAP_TYPE_NONE; 194 195 195 - bug = find_bug(bugaddr); 196 - if (!bug) 197 - return BUG_TRAP_TYPE_NONE; 196 + bug = find_bug(bugaddr); 197 + if (!bug) 198 + return BUG_TRAP_TYPE_NONE; 199 + } 198 200 199 201 disable_trace_on_warning(); 200 202 ··· 246 244 return BUG_TRAP_TYPE_BUG; 247 245 } 248 246 247 + enum bug_trap_type report_bug_entry(struct bug_entry *bug, struct pt_regs *regs) 248 + { 249 + enum bug_trap_type ret; 250 + bool rcu = false; 251 + 252 + rcu = warn_rcu_enter(); 253 + ret = __report_bug(bug, 0, regs); 254 + warn_rcu_exit(rcu); 255 + 256 + return ret; 257 + } 258 + 249 259 enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) 250 260 { 251 261 enum bug_trap_type ret; 252 262 bool rcu = false; 253 263 254 264 rcu = warn_rcu_enter(); 255 - ret = __report_bug(bugaddr, regs); 265 + ret = __report_bug(NULL, bugaddr, regs); 256 266 warn_rcu_exit(rcu); 257 267 258 268 return ret;