On Mon, 25 Jun 2007, Roland McGrath wrote:Of course, calling register_kernel_hw_breakpoint() with three extra arguments is a waste of an instruction also, if one of those arguments isn't used. And yet it's not clear that either of these really is a waste. Suppose somebody ports code from x86 to PPC64 and leaves a breakpoint length set to HW_BREAKPOINT_LEN_4. Clearly we would want to return an error. This means that the length value _has_ to be tested, even if it won't be used for anything. And this means the length _has_ to be passed along somehow, either as an argument or as a field value. All right, I'll change it. And I'll encapsulate those fields. I still think it will accomplish nothing more than hiding some implementation details which don't really need to be hidden. It's below. The patch logs the value of DR6 when each debug interrupt occurs, and it adds another sysfs attribute to the bptest driver. The attribute is named "test", and it contains the value that the IRQ handler will write back to DR6. Combine this with the Alt-SysRq-P change already submitted, and you can get a clear view of what's going on. I see. So I could add a CONFIG_HW_BREAKPOINT option and make CONFIG_PTRACE depend on it. That will be simple enough. Do you think it would make sense to allow utrace without hw-breakpoint? All right, I'll fix that back up. No, because do_debug always writes a 0 to DR6 after reading it; consequently DR_STEP does not remain set on later exceptions. Unless we do something like this we would never know whether we entered the handler because of a single-step exception or not. But the same effect could occur because of a bogus debug exception caused by lazy DR7 switching. I'll have to add back in code to detect that case. Alan Stern Index: usb-2.6/arch/i386/kernel/traps.c =================================================================== --- usb-2.6.orig/arch/i386/kernel/traps.c +++ usb-2.6/arch/i386/kernel/traps.c @@ -802,13 +802,17 @@ fastcall void __kprobes do_int3(struct p * find every occurrence of the TF bit that could be saved away even * by user code) */ +unsigned long dr6test; +EXPORT_SYMBOL(dr6test); + fastcall void __kprobes do_debug(struct pt_regs * regs, long error_code) { struct task_struct *tsk = current; unsigned long dr6; get_debugreg(dr6, 6); - set_debugreg(0, 6); /* DR6 may or may not be cleared by the CPU */ + printk(KERN_INFO "dr6 = %08lx\n", dr6); + set_debugreg(dr6test, 6); /* DR6 may or may not be cleared by the CPU */ /* Store the virtualized DR6 value */ tsk->thread.vdr6 = dr6; Index: usb-2.6/bptest/bptest.c =================================================================== --- usb-2.6.orig/bptest/bptest.c +++ usb-2.6/bptest/bptest.c @@ -58,6 +58,22 @@ MODULE_AUTHOR("Alan Stern <stern@rowland MODULE_DESCRIPTION("Hardware Breakpoint test driver"); MODULE_LICENSE("GPL"); +extern unsigned long dr6test; + +static ssize_t test_store(struct device_driver *d, const char *buf, + size_t count) +{ + if (sscanf(buf, "%lx", &dr6test) <= 0) + return -EIO; + return count; +} + +static ssize_t test_show(struct device_driver *d, char *buf) +{ + return sprintf(buf, "dr6test: %08lx\n", dr6test); +} +static DRIVER_ATTR(test, 0600, test_show, test_store); + static struct hw_breakpoint bps[4]; @@ -402,6 +418,7 @@ static struct driver_attribute *(bptest_ &driver_attr_call, &driver_attr_read, &driver_attr_write, + &driver_attr_test, NULL }; -
| Rafael J. Wysocki | [Bug #11355] Regression in 2.6.27-rc2 when cross-building the kernel |
| David Miller | [GIT]: Networking |
| Robin Lee Powell | NFS hang + umount -f: better behaviour requested. |
| Artem Bityutskiy | [PATCH 11/22 take 3] UBI: user-interfaces unit |
git: | |
| David Symonds | Re: I don't want the .git directory next to my code. |
| Petr Baudis | [ANNOUNCE] TopGit - A different patch queue manager |
| Daniel Barkalow | Non-http dumb protocols |
| Kevin Ballard | Re: git on MacOSX and files with decomposed utf-8 file names |
| Jim Winstead Jr. | Re: Root Disk/Book Disk Compatibility |
| Linus Benedict Torvalds | Trying to answer ... |
| Linus Torvalds | Re: mget / mput = bad director components |
| Gerard A. Allan | BUG REPORT --- call chsvga (really call getkey) |
| c l | site-to-site vpn 4.0 to cisco 3000 |
| Darren Spruell | Re: OpenBSD as Virtualbox guest |
| Richard Stallman | Real men don't attack straw men |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
