]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kgdbts: fix hw_access_break_test
authorFlorian Rommel <mail@florommel.de>
Mon, 12 Aug 2024 08:54:59 +0000 (10:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Aug 2024 09:27:38 +0000 (11:27 +0200)
The test for access watchpoints (hw_access_break_test) was broken
(always failed) because the compiler optimized out the write to the
static helper variable (hw_break_val2), as it is never read anywhere.
This resulted in the target variable (hw_break_val) not being accessed
and thus the breakpoint not being triggered.

Remove the helper variable (hw_break_val2), and use READ_ONCE to force
reading the target variable (hw_break_val).

Signed-off-by: Florian Rommel <mail@florommel.de>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20240812085459.291741-1-mail@florommel.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/kgdbts.c

index 88b91ad8e5413a6a6c361084ae85a51925bb8776..0cf31164b4706e332199c95ab467d0cb6d63bf9b 100644 (file)
@@ -95,6 +95,7 @@
 #include <linux/kallsyms.h>
 
 #include <asm/sections.h>
+#include <asm/rwonce.h>
 
 #define v1printk(a...) do {            \
        if (verbose)                    \
@@ -126,7 +127,6 @@ static int final_ack;
 static int force_hwbrks;
 static int hwbreaks_ok;
 static int hw_break_val;
-static int hw_break_val2;
 static int cont_instead_of_sstep;
 static unsigned long cont_thread_id;
 static unsigned long sstep_thread_id;
@@ -284,7 +284,7 @@ static void hw_rem_access_break(char *arg)
 
 static void hw_break_val_access(void)
 {
-       hw_break_val2 = hw_break_val;
+       READ_ONCE(hw_break_val);
 }
 
 static void hw_break_val_write(void)