Skip to content

Commit 86a2205

Browse files
anadavIngo Molnar
authored andcommitted
x86/kgdb: Avoid redundant comparison of patched code
text_poke() already ensures that the written value is the correct one and fails if that is not the case. There is no need for an additional comparison. Remove it. Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Rick Edgecombe <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent b3fd8e8 commit 86a2205

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

arch/x86/kernel/kgdb.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,6 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip)
747747
int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
748748
{
749749
int err;
750-
char opc[BREAK_INSTR_SIZE];
751750

752751
bpt->type = BP_BREAKPOINT;
753752
err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
@@ -766,21 +765,13 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
766765
return -EBUSY;
767766
text_poke_kgdb((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
768767
BREAK_INSTR_SIZE);
769-
err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
770-
if (err)
771-
return err;
772-
if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
773-
return -EINVAL;
774768
bpt->type = BP_POKE_BREAKPOINT;
775769

776770
return err;
777771
}
778772

779773
int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
780774
{
781-
int err;
782-
char opc[BREAK_INSTR_SIZE];
783-
784775
if (bpt->type != BP_POKE_BREAKPOINT)
785776
goto knl_write;
786777
/*
@@ -791,10 +782,7 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
791782
goto knl_write;
792783
text_poke_kgdb((void *)bpt->bpt_addr, bpt->saved_instr,
793784
BREAK_INSTR_SIZE);
794-
err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
795-
if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
796-
goto knl_write;
797-
return err;
785+
return 0;
798786

799787
knl_write:
800788
return probe_kernel_write((char *)bpt->bpt_addr,

0 commit comments

Comments
 (0)