On 02/07/15 07:40, Prafull Suryawanshi wrote: > Thanks Daniel for reply. > > On 01/07/15 10:01, Prafull Suryawanshi wrote: >>> Hi, >>> >>> Anyone can point me what function of KGDB code gets called when >>> hardware watchpoint or breakpoint hits. >>> I earlier asked question about aarch64 hardware watchpoint but I think >>> this is proper question. > >> You mean how does the arm64 specific trap handling code actually enter >> kgdb? It calls kgdb_handle_exception. > > ok. In my case, this is not getting called. I am not sure how aarch64 > triggers this exception though. > >> For software breakpoint and single step exceptions the code in >> arch/arm64/kernel/debug-monitors.c calls into kgdb from hooks registered >> using register_step_hook() and register_break_hook(). > > Are you suggesting that we might need to add hook here for hw > watchpoint handler?
No. This code is just an illustration of how arch/arm64's existing s/ware breakpoint and kgdb code works together to ensure kgdb_handle_exception gets called from the arm64 exception handlers. >> Hardware breakpoints and watchpoint are handled by >> arch/arm64/kernel/hw_breakpoint.c . You have extended this code? > > Not actually. I extended code in arch/arm64/kernel/kgdb.c. I > implemented the arch_kgdb_ops for set_hw_breakpoint and siblings. > It is similar like how x86 handled. > In case of x86, arch_kgdb_ops.*hw*break* related functions calls from > kgdb.c to hw_breakpoint.c. > So I have implemented in similar fashion. The x86 watchpoint code works by setting up a perf watchpoint which it knows will result in the x86 debug trap handler calling notify_die(DIE_DEBUG, ...) when that perf watchpoint is hit. kgdb normally adds itself to the die notifier list and the x86 version of the notify handler contains extra logic (compared to arm64) to spot userspace watchpoints and ignores them. >>> I have implemented support for aarch64 and can see one CPU halt on the >>> code where watchpoint being getting written. > >> If you have not entered kgdb by calling kgdb_handle_exception() I think >> this is expected. When kgdb enters it will automatically generate IPIs >> to get the other CPUs to halt. > > That might explain the situation I am facing. By the way there is hook > handler already in arch/arm64/kernel/hw_breakpoint.c in > arch_hw_breakpoint_init which is watchpoint_handler. > I checked it but this also does not get called. > > As we can set hardware watchpoint in usermode on aarch64 which goes > through ptrace->arch/arm64/kernel/hw_breakpoint.c. So there must be > getting some callback called when watchpoint being hit. > I was hoping similar would work in kgdb case as well. arm64 does not notify_die(DIE_DEBUG, ...) during debug exceptions. The debug hooks you have observed can only support a single handler (i.e. breakpoint_handler and watchpoint_handler). You will have to provide code to make the call into kgdb (and you probably need to discuss how best to do this with the arm64 maintainers). > So far, I verified that one of CPU halts at watchpoint update code and > other 3 are loops in cpu-idle. > Any suggestion how to proceed will really help here. If you cannot get the system to call either breakpoint_handler or watchpoint_handler then take a good look at your watchpoint install code. The CPU shouldn't halt here and is suggests the watchpoint itself may be bad (or too widely set). Daniel. ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ Kgdb-bugreport mailing list Kgdb-bugreport@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport