Skip to content

Commit 4a017c0

Browse files
florommelgregkh
authored andcommitted
kgdbts: fix hw_access_break_test
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 <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9ca12e5 commit 4a017c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/misc/kgdbts.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#include <linux/kallsyms.h>
9696

9797
#include <asm/sections.h>
98+
#include <asm/rwonce.h>
9899

99100
#define v1printk(a...) do { \
100101
if (verbose) \
@@ -126,7 +127,6 @@ static int final_ack;
126127
static int force_hwbrks;
127128
static int hwbreaks_ok;
128129
static int hw_break_val;
129-
static int hw_break_val2;
130130
static int cont_instead_of_sstep;
131131
static unsigned long cont_thread_id;
132132
static unsigned long sstep_thread_id;
@@ -284,7 +284,7 @@ static void hw_rem_access_break(char *arg)
284284

285285
static void hw_break_val_access(void)
286286
{
287-
hw_break_val2 = hw_break_val;
287+
READ_ONCE(hw_break_val);
288288
}
289289

290290
static void hw_break_val_write(void)

0 commit comments

Comments
 (0)