Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb:
kgdboc,tty: Fix tty polling search to use name correctly
kgdb, x86_64: fix PS CS SS registers in gdb serial
kgdb, x86_64: gdb serial has BX and DX reversed
kgdb, x86, arm, mips, powerpc: ignore user space single stepping
kgdb: could not write to the last of valid memory with kgdb

+63 -38
-2
arch/arm/kernel/kgdb.c
··· 111 111 case 'D': 112 112 case 'k': 113 113 case 'c': 114 - kgdb_contthread = NULL; 115 - 116 114 /* 117 115 * Try to read optional parameter, pc unchanged if no parm. 118 116 * If this was a compiled breakpoint, we need to move
+1 -2
arch/mips/kernel/kgdb.c
··· 236 236 237 237 atomic_set(&kgdb_cpu_doing_single_step, -1); 238 238 if (remcom_in_buffer[0] == 's') 239 - if (kgdb_contthread) 240 - atomic_set(&kgdb_cpu_doing_single_step, cpu); 239 + atomic_set(&kgdb_cpu_doing_single_step, cpu); 241 240 242 241 return 0; 243 242 }
+2 -3
arch/powerpc/kernel/kgdb.c
··· 347 347 linux_regs->msr |= MSR_SE; 348 348 #endif 349 349 kgdb_single_step = 1; 350 - if (kgdb_contthread) 351 - atomic_set(&kgdb_cpu_doing_single_step, 352 - raw_smp_processor_id()); 350 + atomic_set(&kgdb_cpu_doing_single_step, 351 + raw_smp_processor_id()); 353 352 } 354 353 return 0; 355 354 }
+32 -11
arch/x86/kernel/kgdb.c
··· 69 69 */ 70 70 void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs) 71 71 { 72 + #ifndef CONFIG_X86_32 73 + u32 *gdb_regs32 = (u32 *)gdb_regs; 74 + #endif 72 75 gdb_regs[GDB_AX] = regs->ax; 73 76 gdb_regs[GDB_BX] = regs->bx; 74 77 gdb_regs[GDB_CX] = regs->cx; ··· 79 76 gdb_regs[GDB_SI] = regs->si; 80 77 gdb_regs[GDB_DI] = regs->di; 81 78 gdb_regs[GDB_BP] = regs->bp; 82 - gdb_regs[GDB_PS] = regs->flags; 83 79 gdb_regs[GDB_PC] = regs->ip; 84 80 #ifdef CONFIG_X86_32 81 + gdb_regs[GDB_PS] = regs->flags; 85 82 gdb_regs[GDB_DS] = regs->ds; 86 83 gdb_regs[GDB_ES] = regs->es; 87 84 gdb_regs[GDB_CS] = regs->cs; ··· 97 94 gdb_regs[GDB_R13] = regs->r13; 98 95 gdb_regs[GDB_R14] = regs->r14; 99 96 gdb_regs[GDB_R15] = regs->r15; 97 + gdb_regs32[GDB_PS] = regs->flags; 98 + gdb_regs32[GDB_CS] = regs->cs; 99 + gdb_regs32[GDB_SS] = regs->ss; 100 100 #endif 101 101 gdb_regs[GDB_SP] = regs->sp; 102 102 } ··· 118 112 */ 119 113 void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) 120 114 { 115 + #ifndef CONFIG_X86_32 116 + u32 *gdb_regs32 = (u32 *)gdb_regs; 117 + #endif 121 118 gdb_regs[GDB_AX] = 0; 122 119 gdb_regs[GDB_BX] = 0; 123 120 gdb_regs[GDB_CX] = 0; ··· 138 129 gdb_regs[GDB_FS] = 0xFFFF; 139 130 gdb_regs[GDB_GS] = 0xFFFF; 140 131 #else 141 - gdb_regs[GDB_PS] = *(unsigned long *)(p->thread.sp + 8); 142 - gdb_regs[GDB_PC] = 0; 132 + gdb_regs32[GDB_PS] = *(unsigned long *)(p->thread.sp + 8); 133 + gdb_regs32[GDB_CS] = __KERNEL_CS; 134 + gdb_regs32[GDB_SS] = __KERNEL_DS; 135 + gdb_regs[GDB_PC] = p->thread.ip; 143 136 gdb_regs[GDB_R8] = 0; 144 137 gdb_regs[GDB_R9] = 0; 145 138 gdb_regs[GDB_R10] = 0; ··· 164 153 */ 165 154 void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs) 166 155 { 156 + #ifndef CONFIG_X86_32 157 + u32 *gdb_regs32 = (u32 *)gdb_regs; 158 + #endif 167 159 regs->ax = gdb_regs[GDB_AX]; 168 160 regs->bx = gdb_regs[GDB_BX]; 169 161 regs->cx = gdb_regs[GDB_CX]; ··· 174 160 regs->si = gdb_regs[GDB_SI]; 175 161 regs->di = gdb_regs[GDB_DI]; 176 162 regs->bp = gdb_regs[GDB_BP]; 177 - regs->flags = gdb_regs[GDB_PS]; 178 163 regs->ip = gdb_regs[GDB_PC]; 179 164 #ifdef CONFIG_X86_32 165 + regs->flags = gdb_regs[GDB_PS]; 180 166 regs->ds = gdb_regs[GDB_DS]; 181 167 regs->es = gdb_regs[GDB_ES]; 182 168 regs->cs = gdb_regs[GDB_CS]; ··· 189 175 regs->r13 = gdb_regs[GDB_R13]; 190 176 regs->r14 = gdb_regs[GDB_R14]; 191 177 regs->r15 = gdb_regs[GDB_R15]; 178 + regs->flags = gdb_regs32[GDB_PS]; 179 + regs->cs = gdb_regs32[GDB_CS]; 180 + regs->ss = gdb_regs32[GDB_SS]; 192 181 #endif 193 182 } 194 183 ··· 395 378 if (remcomInBuffer[0] == 's') { 396 379 linux_regs->flags |= X86_EFLAGS_TF; 397 380 kgdb_single_step = 1; 398 - if (kgdb_contthread) { 399 - atomic_set(&kgdb_cpu_doing_single_step, 400 - raw_smp_processor_id()); 401 - } 381 + atomic_set(&kgdb_cpu_doing_single_step, 382 + raw_smp_processor_id()); 402 383 } 403 384 404 385 get_debugreg(dr6, 6); ··· 481 466 482 467 case DIE_DEBUG: 483 468 if (atomic_read(&kgdb_cpu_doing_single_step) == 484 - raw_smp_processor_id() && 485 - user_mode(regs)) 486 - return single_step_cont(regs, args); 469 + raw_smp_processor_id()) { 470 + if (user_mode(regs)) 471 + return single_step_cont(regs, args); 472 + break; 473 + } else if (test_thread_flag(TIF_SINGLESTEP)) 474 + /* This means a user thread is single stepping 475 + * a system call which should be ignored 476 + */ 477 + return NOTIFY_DONE; 487 478 /* fall through */ 488 479 default: 489 480 if (user_mode(regs))
+12 -2
drivers/char/tty_io.c
··· 695 695 { 696 696 struct tty_driver *p, *res = NULL; 697 697 int tty_line = 0; 698 + int len; 698 699 char *str; 700 + 701 + for (str = name; *str; str++) 702 + if ((*str >= '0' && *str <= '9') || *str == ',') 703 + break; 704 + if (!*str) 705 + return NULL; 706 + 707 + len = str - name; 708 + tty_line = simple_strtoul(str, &str, 10); 699 709 700 710 mutex_lock(&tty_mutex); 701 711 /* Search through the tty devices to look for a match */ 702 712 list_for_each_entry(p, &tty_drivers, tty_drivers) { 703 - str = name + strlen(p->name); 704 - tty_line = simple_strtoul(str, &str, 10); 713 + if (strncmp(name, p->name, len) != 0) 714 + continue; 705 715 if (*str == ',') 706 716 str++; 707 717 if (*str == '\0')
+11 -13
include/asm-x86/kgdb.h
··· 39 39 GDB_FS, /* 14 */ 40 40 GDB_GS, /* 15 */ 41 41 }; 42 + #define NUMREGBYTES ((GDB_GS+1)*4) 42 43 #else /* ! CONFIG_X86_32 */ 43 - enum regnames { 44 + enum regnames64 { 44 45 GDB_AX, /* 0 */ 45 - GDB_DX, /* 1 */ 46 + GDB_BX, /* 1 */ 46 47 GDB_CX, /* 2 */ 47 - GDB_BX, /* 3 */ 48 + GDB_DX, /* 3 */ 48 49 GDB_SI, /* 4 */ 49 50 GDB_DI, /* 5 */ 50 51 GDB_BP, /* 6 */ ··· 59 58 GDB_R14, /* 14 */ 60 59 GDB_R15, /* 15 */ 61 60 GDB_PC, /* 16 */ 62 - GDB_PS, /* 17 */ 63 61 }; 64 - #endif /* CONFIG_X86_32 */ 65 62 66 - /* 67 - * Number of bytes of registers: 68 - */ 69 - #ifdef CONFIG_X86_32 70 - # define NUMREGBYTES 64 71 - #else 72 - # define NUMREGBYTES ((GDB_PS+1)*8) 73 - #endif 63 + enum regnames32 { 64 + GDB_PS = 34, 65 + GDB_CS, 66 + GDB_SS, 67 + }; 68 + #define NUMREGBYTES ((GDB_SS+1)*4) 69 + #endif /* CONFIG_X86_32 */ 74 70 75 71 static inline void arch_kgdb_breakpoint(void) 76 72 {
+5 -5
kernel/kgdb.c
··· 488 488 if (err) 489 489 return err; 490 490 if (CACHE_FLUSH_IS_SAFE) 491 - flush_icache_range(addr, addr + length + 1); 491 + flush_icache_range(addr, addr + length); 492 492 return 0; 493 493 } 494 494 ··· 1462 1462 * Get the passive CPU lock which will hold all the non-primary 1463 1463 * CPU in a spin state while the debugger is active 1464 1464 */ 1465 - if (!kgdb_single_step || !kgdb_contthread) { 1465 + if (!kgdb_single_step) { 1466 1466 for (i = 0; i < NR_CPUS; i++) 1467 1467 atomic_set(&passive_cpu_wait[i], 1); 1468 1468 } ··· 1475 1475 1476 1476 #ifdef CONFIG_SMP 1477 1477 /* Signal the other CPUs to enter kgdb_wait() */ 1478 - if ((!kgdb_single_step || !kgdb_contthread) && kgdb_do_roundup) 1478 + if ((!kgdb_single_step) && kgdb_do_roundup) 1479 1479 kgdb_roundup_cpus(flags); 1480 1480 #endif 1481 1481 ··· 1494 1494 kgdb_post_primary_code(ks->linux_regs, ks->ex_vector, ks->err_code); 1495 1495 kgdb_deactivate_sw_breakpoints(); 1496 1496 kgdb_single_step = 0; 1497 - kgdb_contthread = NULL; 1497 + kgdb_contthread = current; 1498 1498 exception_level = 0; 1499 1499 1500 1500 /* Talk to debugger with gdbserial protocol */ ··· 1508 1508 kgdb_info[ks->cpu].task = NULL; 1509 1509 atomic_set(&cpu_in_kgdb[ks->cpu], 0); 1510 1510 1511 - if (!kgdb_single_step || !kgdb_contthread) { 1511 + if (!kgdb_single_step) { 1512 1512 for (i = NR_CPUS-1; i >= 0; i--) 1513 1513 atomic_set(&passive_cpu_wait[i], 0); 1514 1514 /*