Skip to contentSkip to conversation

x86/kgdb: return 0 from kgdb_arch_set_breakpoint

PATCH In review Matt Mullins 3 participants 3 messages May 31, 2019 – Jun 12, 2019 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/kgdb: return 0 from kgdb_arch_set_breakpoint

err must be nonzero in order to reach text_poke(), which caused kgdb to fail to set breakpoints:

	(gdb) break __x64_sys_sync
	Breakpoint 1 at 0xffffffff81288910: file ../fs/sync.c, line 124.
	(gdb) c
	Continuing.
	Warning:
	Cannot insert breakpoint 1.
	Cannot access memory at address 0xffffffff81288910

	Command aborted.
Fixes 86a22057127d ("x86/kgdb: Avoid redundant comparison of patched code")
---
 arch/x86/kernel/kgdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kgdb.c +1 -1
index 9a8c1648fc9a..6690c5652aeb 100644
@@ -758,7 +758,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
 		       BREAK_INSTR_SIZE);
 	bpt->type = BP_POKE_BREAKPOINT;
 
-	return err;
+	return 0;
 }
 
 int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Matt Mullins

err must be nonzero in order to reach text_poke(), which caused kgdb to fail to set breakpoints:

	(gdb) break __x64_sys_sync
	Breakpoint 1 at 0xffffffff81288910: file ../fs/sync.c, line 124.
	(gdb) c
	Continuing.
	Warning:
	Cannot insert breakpoint 1.
	Cannot access memory at address 0xffffffff81288910

	Command aborted.
Fixes 86a22057127d ("x86/kgdb: Avoid redundant comparison of patched code")

---
arch/x86/kernel/kgdb.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kgdb.c +1 -1
index 9a8c1648fc9a..6690c5652aeb 100644
@@ -758,7 +758,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
 		       BREAK_INSTR_SIZE);
 	bpt->type = BP_POKE_BREAKPOINT;
 
-	return err;
+	return 0;
 }
 
 int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
Signature · 1 line
2.17.1

My bad. Thanks for fixing it.

#2 lore raw

[tip:x86/urgent] x86/kgdb: Return 0 from kgdb_arch_set_breakpoint()

In reply to Matt Mullins
x86/kgdb: Return 0 from kgdb_arch_set_breakpoint()
Commit-ID:  71ab8323cc357c68985a2d6fc6cfc22b1dbbc1c3
Gitweb:     https://git.kernel.org/tip/71ab8323cc357c68985a2d6fc6cfc22b1dbbc1c3
Author:     Matt Mullins <[email protected]>
AuthorDate: Fri, 31 May 2019 12:47:54 -0700
Committer:  Borislav Petkov <[email protected]>
CommitDate: Wed, 12 Jun 2019 18:52:44 +0200

x86/kgdb: Return 0 from kgdb_arch_set_breakpoint()

err must be nonzero in order to reach text_poke(), which caused kgdb to fail to set breakpoints:

(gdb) break __x64_sys_sync
Breakpoint 1 at 0xffffffff81288910: file ../fs/sync.c, line 124. (gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff81288910

Command aborted.

Fixes 86a22057127d ("x86/kgdb: Avoid redundant comparison of patched code")
Cc Andy Lutomirski <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Daniel Thompson <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Rick Edgecombe <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc x86-ml <[email protected]>
---
 arch/x86/kernel/kgdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kgdb.c +1 -1
index 9a8c1648fc9a..6690c5652aeb 100644
@@ -758,7 +758,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
 		       BREAK_INSTR_SIZE);
 	bpt->type = BP_POKE_BREAKPOINT;
 
-	return err;
+	return 0;
 }
 
 int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)