Skip to content

Commit f4ea8e0

Browse files
committed
lkdtm/bugs: Do not confuse the clang/objtool with busy wait loop
Since commit eb972ea ("lkdtm/bugs: Add cases for BUG and PANIC occurring in hardirq context"), building with clang for x86_64 results in the following warnings: vmlinux.o: warning: objtool: lkdtm_PANIC_IN_HARDIRQ(): unexpected end of section .text.lkdtm_PANIC_IN_HARDIRQ vmlinux.o: warning: objtool: lkdtm_BUG_IN_HARDIRQ(): unexpected end of section .text.lkdtm_BUG_IN_HARDIRQ caused by busy "while (wait_for_...);" loops. Add READ_ONCE() and cpu_relax() to better indicate the intention and avoid any unwanted compiler optimisations. Fixes: eb972ea ("lkdtm/bugs: Add cases for BUG and PANIC occurring in hardirq context") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202512190111.jxFSqxUH-lkp@intel.com/ Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 98a97bf commit f4ea8e0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/misc/lkdtm/bugs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ static void lkdtm_PANIC_IN_HARDIRQ(void)
120120
CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
121121
hrtimer_start(&timer, us_to_ktime(100), HRTIMER_MODE_REL_HARD);
122122

123-
while (wait_for_panic)
124-
;
123+
while (READ_ONCE(wait_for_panic))
124+
cpu_relax();
125125

126126
hrtimer_cancel(&timer);
127127
}
@@ -150,8 +150,8 @@ static void lkdtm_BUG_IN_HARDIRQ(void)
150150
CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
151151
hrtimer_start(&timer, us_to_ktime(100), HRTIMER_MODE_REL_HARD);
152152

153-
while (wait_for_bug)
154-
;
153+
while (READ_ONCE(wait_for_bug))
154+
cpu_relax();
155155

156156
hrtimer_cancel(&timer);
157157
}

0 commit comments

Comments
 (0)