* (unknown), @ 2014-05-23 2:50 Wang, Yalin 2014-05-23 2:51 ` how to creat watchpoint in kernel for data access debug Wang, Yalin 0 siblings, 1 reply; 9+ messages in thread From: Wang, Yalin @ 2014-05-23 2:50 UTC (permalink / raw) To: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org', 'Will Deacon' Hi I have a problems that I want create a watchpoint to monitor a data for Debug in kernel , but I don't know how to do it , I try the kprobes , but seems it only support create .text section probe , Can't monitor data access , then I try perf_event_create to create a hardware Data watchpoint , it can work , but has a problem: When the data access hit , I don't know how to bypass this time's watchpoint , This need simulate the data access or step the break instructions in data abort Exception handler , seems kernel don't provide these for perf_event .. I test this on ARM arch , My question is that how to create data watchpoint in kernel ? It there some modules have implemented this ? Thanks Sony Mobile Communications Tel: My Number +18610323092 yalin.wang@sonymobile.com (shall be a link, optional part) sonymobile.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* how to creat watchpoint in kernel for data access debug 2014-05-23 2:50 (unknown), Wang, Yalin @ 2014-05-23 2:51 ` Wang, Yalin 2014-05-23 13:45 ` Will Deacon 0 siblings, 1 reply; 9+ messages in thread From: Wang, Yalin @ 2014-05-23 2:51 UTC (permalink / raw) To: Wang, Yalin, 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org', 'Will Deacon' Sorry, add a title . Hi I have a problems that I want create a watchpoint to monitor a data for Debug in kernel , but I don't know how to do it , I try the kprobes , but seems it only support create .text section probe , Can't monitor data access , then I try perf_event_create to create a hardware Data watchpoint , it can work , but has a problem: When the data access hit , I don't know how to bypass this time's watchpoint , This need simulate the data access or step the break instructions in data abort Exception handler , seems kernel don't provide these for perf_event .. I test this on ARM arch , My question is that how to create data watchpoint in kernel ? It there some modules have implemented this ? Thanks Sony Mobile Communications Tel: My Number +18610323092 yalin.wang@sonymobile.com (shall be a link, optional part) sonymobile.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: how to creat watchpoint in kernel for data access debug 2014-05-23 2:51 ` how to creat watchpoint in kernel for data access debug Wang, Yalin @ 2014-05-23 13:45 ` Will Deacon 2014-05-24 3:48 ` Wang, Yalin 0 siblings, 1 reply; 9+ messages in thread From: Will Deacon @ 2014-05-23 13:45 UTC (permalink / raw) To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' On Fri, May 23, 2014 at 03:51:17AM +0100, Wang, Yalin wrote: > I have a problems that I want create a watchpoint to monitor a data for > Debug in kernel , but I don't know how to do it , I try the kprobes , but > seems it only support create .text section probe , Can't monitor data > access , then I try perf_event_create to create a hardware Data > watchpoint , it can work , but has a problem: When the data access hit , I > don't know how to bypass this time's watchpoint , This need simulate the > data access or step the break instructions in data abort Exception > handler , seems kernel don't provide these for perf_event .. > > I test this on ARM arch , > My question is that how to create data watchpoint in kernel ? It depends on why you want the watchpoint. If it's for counting accesses to that data, then you can use the perf tool and the perf code will try to deal with the single-stepping for you. Otherwise, you can investigate KGDB, but I've never tried it myself (and I don't think it uses hardware watchpoint for ARM).. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: how to creat watchpoint in kernel for data access debug 2014-05-23 13:45 ` Will Deacon @ 2014-05-24 3:48 ` Wang, Yalin 2014-06-03 16:45 ` Will Deacon 0 siblings, 1 reply; 9+ messages in thread From: Wang, Yalin @ 2014-05-24 3:48 UTC (permalink / raw) To: 'Will Deacon' Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' Hi Will, Thanks for your suggestion, The scenario that I encounter is a little special : I found our kernel memory will be corrupt in stability test , Seems that someone write a memory that doesn't belong to it . But I can't find who does it , the bug is hard to reproduce , So I want make a debug SW in kernel , which can monitor some data access, When someone access it , the callback function can check if it's right . If it's wrong, then crash the kernel do get a ram dump . So kgdb or perf seems not suitable in this condition , We need users to use devices, not just test the device in Lab . For watchpoint breakpoint, can it be implement by software on ARM arch? I think It's impossible , instruction breakpoint can be implemented by Software through undefined instruction in kernel , but data access watchpoint Seems can't be done by this method, at least on ARM arch , am I right ? Is there some modules have implement watchpoint probe function just like kporbe in kernel ? Appreciate for your point out and help . Thanks -----Original Message----- From: Will Deacon [mailto:will.deacon@arm.com] Sent: Friday, May 23, 2014 9:46 PM To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org'; 'linux-arch-owner@vger.kernel.org' Subject: Re: how to creat watchpoint in kernel for data access debug On Fri, May 23, 2014 at 03:51:17AM +0100, Wang, Yalin wrote: > I have a problems that I want create a watchpoint to monitor a data > for Debug in kernel , but I don't know how to do it , I try the > kprobes , but seems it only support create .text section probe , Can't > monitor data access , then I try perf_event_create to create a > hardware Data watchpoint , it can work , but has a problem: When the > data access hit , I don't know how to bypass this time's watchpoint , > This need simulate the data access or step the break instructions in > data abort Exception handler , seems kernel don't provide these for perf_event .. > > I test this on ARM arch , > My question is that how to create data watchpoint in kernel ? It depends on why you want the watchpoint. If it's for counting accesses to that data, then you can use the perf tool and the perf code will try to deal with the single-stepping for you. Otherwise, you can investigate KGDB, but I've never tried it myself (and I don't think it uses hardware watchpoint for ARM).. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: how to creat watchpoint in kernel for data access debug 2014-05-24 3:48 ` Wang, Yalin @ 2014-06-03 16:45 ` Will Deacon 2014-06-04 3:05 ` Wang, Yalin 0 siblings, 1 reply; 9+ messages in thread From: Will Deacon @ 2014-06-03 16:45 UTC (permalink / raw) To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' On Sat, May 24, 2014 at 04:48:20AM +0100, Wang, Yalin wrote: > Hi Will, Hello, Sorry for the delayed reply, it took me a while to work out what your issue is. > Thanks for your suggestion, > The scenario that I encounter is a little special : > I found our kernel memory will be corrupt in stability test , > Seems that someone write a memory that doesn't belong to it . > But I can't find who does it , the bug is hard to reproduce , > So I want make a debug SW in kernel , which can monitor some data access, > When someone access it , the callback function can check if it's right . > If it's wrong, then crash the kernel do get a ram dump . > > > So kgdb or perf seems not suitable in this condition , > We need users to use devices, not just test the device in Lab . I think Google did something similar to this with ChromeOS on the Exynos5-based chromebooks: https://chromium-review.googlesource.com/#/c/188479/3/arch/arm/kernel/hw_breakpoint.c I don't think that has a place in the mainline kernel, but you could certainly adapt it for your debugging purposes. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: how to creat watchpoint in kernel for data access debug 2014-06-03 16:45 ` Will Deacon @ 2014-06-04 3:05 ` Wang, Yalin 2014-06-04 18:01 ` Will Deacon 0 siblings, 1 reply; 9+ messages in thread From: Wang, Yalin @ 2014-06-04 3:05 UTC (permalink / raw) To: 'Will Deacon' Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' Hi Will, Thanks for your proposal, The patch google made is just like The one I tried before , Then the problems come : After register the perf_event callback, In the callback function , In google's patch , it is function crbug_345917_handler( ), It just call panic( ) , But My callback function will do some check , Sometimes, I want to bypass this time's breakpoint, Problems is that I don't know how to bypass it, If I return directly in the callback function , The breakpoint will trap again and again endless .. Thank you very much . -----Original Message----- From: Will Deacon [mailto:will.deacon@arm.com] Sent: Wednesday, June 04, 2014 12:45 AM To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org'; 'linux-arch-owner@vger.kernel.org' Subject: Re: how to creat watchpoint in kernel for data access debug On Sat, May 24, 2014 at 04:48:20AM +0100, Wang, Yalin wrote: > Hi Will, Hello, Sorry for the delayed reply, it took me a while to work out what your issue is. > Thanks for your suggestion, > The scenario that I encounter is a little special : > I found our kernel memory will be corrupt in stability test , Seems > that someone write a memory that doesn't belong to it . > But I can't find who does it , the bug is hard to reproduce , So I > want make a debug SW in kernel , which can monitor some data access, > When someone access it , the callback function can check if it's right . > If it's wrong, then crash the kernel do get a ram dump . > > > So kgdb or perf seems not suitable in this condition , We need users > to use devices, not just test the device in Lab . I think Google did something similar to this with ChromeOS on the Exynos5-based chromebooks: https://chromium-review.googlesource.com/#/c/188479/3/arch/arm/kernel/hw_breakpoint.c I don't think that has a place in the mainline kernel, but you could certainly adapt it for your debugging purposes. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: how to creat watchpoint in kernel for data access debug 2014-06-04 3:05 ` Wang, Yalin @ 2014-06-04 18:01 ` Will Deacon 2014-06-05 3:40 ` Wang, Yalin 0 siblings, 1 reply; 9+ messages in thread From: Will Deacon @ 2014-06-04 18:01 UTC (permalink / raw) To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' On Wed, Jun 04, 2014 at 04:05:03AM +0100, Wang, Yalin wrote: > Hi Will, > > Thanks for your proposal, > The patch google made is just like > The one I tried before , > Then the problems come : > After register the perf_event callback, > In the callback function , > In google's patch , it is function crbug_345917_handler( ), > It just call panic( ) , > But My callback function will do some check , > Sometimes, I want to bypass this time's breakpoint, > Problems is that I don't know how to bypass it, > If I return directly in the callback function , > The breakpoint will trap again and again endless .. Take a look at enable_single_step, which uses mismatch breakpoints to try and do the step. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: how to creat watchpoint in kernel for data access debug 2014-06-04 18:01 ` Will Deacon @ 2014-06-05 3:40 ` Wang, Yalin 2014-06-16 12:55 ` Will Deacon 0 siblings, 1 reply; 9+ messages in thread From: Wang, Yalin @ 2014-06-05 3:40 UTC (permalink / raw) To: 'Will Deacon' Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' Hi Will, Thanks for your point out very much , I see your meaning , And I do a try , But Seems it can just work when you register a Perf event with a NULL callback function, https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/arch/arm/kernel/hw_breakpoint.c#n758 i don't know why it design like this? If it can always step the watchpoint, Will be suitable for my use. Thanks -----Original Message----- From: Will Deacon [mailto:will.deacon@arm.com] Sent: Thursday, June 05, 2014 2:02 AM To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org'; 'linux-arch-owner@vger.kernel.org' Subject: Re: how to creat watchpoint in kernel for data access debug On Wed, Jun 04, 2014 at 04:05:03AM +0100, Wang, Yalin wrote: > Hi Will, > > Thanks for your proposal, > The patch google made is just like > The one I tried before , > Then the problems come : > After register the perf_event callback, In the callback function , In > google's patch , it is function crbug_345917_handler( ), It just call > panic( ) , But My callback function will do some check , Sometimes, I > want to bypass this time's breakpoint, Problems is that I don't know > how to bypass it, If I return directly in the callback function , The > breakpoint will trap again and again endless .. Take a look at enable_single_step, which uses mismatch breakpoints to try and do the step. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: how to creat watchpoint in kernel for data access debug 2014-06-05 3:40 ` Wang, Yalin @ 2014-06-16 12:55 ` Will Deacon 0 siblings, 0 replies; 9+ messages in thread From: Will Deacon @ 2014-06-16 12:55 UTC (permalink / raw) To: Wang, Yalin Cc: 'linux-mmc@vger.kernel.org', 'linux-arch-owner@vger.kernel.org' On Thu, Jun 05, 2014 at 04:40:02AM +0100, Wang, Yalin wrote: > Hi Will, > > Thanks for your point out very much , > I see your meaning , > And I do a try , > But Seems it can just work when you register a > Perf event with a NULL callback function, > > https://git.kernel.org/cgit/linux/kernel/git/will/linux.git/tree/arch/arm/kernel/hw_breakpoint.c#n758 > > i don't know why it design like this? That's so that ptrace users can deal with the stepping themselves, which is expected by programs such as GDB. Also, not all ARM CPUs have mismatch breakpoints (e.g. ARMv6), so software emulation is required there. Will ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-06-16 12:55 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-05-23 2:50 (unknown), Wang, Yalin 2014-05-23 2:51 ` how to creat watchpoint in kernel for data access debug Wang, Yalin 2014-05-23 13:45 ` Will Deacon 2014-05-24 3:48 ` Wang, Yalin 2014-06-03 16:45 ` Will Deacon 2014-06-04 3:05 ` Wang, Yalin 2014-06-04 18:01 ` Will Deacon 2014-06-05 3:40 ` Wang, Yalin 2014-06-16 12:55 ` Will Deacon
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.