From patchwork Wed Jun 10 09:08:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "K.Prasad" X-Patchwork-Id: 28391 X-Patchwork-Delegate: david@gibson.dropbear.id.au Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 02533B70BF for ; Wed, 10 Jun 2009 19:13:18 +1000 (EST) Received: by ozlabs.org (Postfix) id E94DDDDD1C; Wed, 10 Jun 2009 19:13:17 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id E68D4DDD1B for ; Wed, 10 Jun 2009 19:13:17 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id E9EC6B7E3D for ; Wed, 10 Jun 2009 19:08:48 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 29052B76DF for ; Wed, 10 Jun 2009 19:08:29 +1000 (EST) Received: by ozlabs.org (Postfix) id 1B090DDD1B; Wed, 10 Jun 2009 19:08:29 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [59.145.155.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e28smtp06.in.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 60CC4DDD0C for ; Wed, 10 Jun 2009 19:08:28 +1000 (EST) Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by e28smtp06.in.ibm.com (8.13.1/8.13.1) with ESMTP id n5A98KZ9012127 for ; Wed, 10 Jun 2009 14:38:20 +0530 Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n5A98Kup2113776 for ; Wed, 10 Jun 2009 14:38:20 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.13.1/8.13.3) with ESMTP id n5A98Jsj017919 for ; Wed, 10 Jun 2009 19:08:19 +1000 Received: from in.ibm.com (prasadkr-t60p.in.ibm.com [9.124.31.42]) by d28av02.in.ibm.com (8.13.1/8.12.11) with ESMTP id n5A98ISj017908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 10 Jun 2009 19:08:19 +1000 Date: Wed, 10 Jun 2009 14:38:18 +0530 From: "K.Prasad" To: David Gibson , linuxppc-dev@ozlabs.org Subject: [Patch 4/6] Modify process and processor handling code to recognise hardware debug registers Message-ID: <20090610090818.GE14478@in.ibm.com> References: <20090610090316.898961359@prasadkr_t60p.in.ibm.com> MIME-Version: 1.0 Content-Disposition: inline; filename=ppc64_modify_process_handling_04 User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Michael Neuling , Benjamin Herrenschmidt , paulus@samba.org, Alan Stern , "K.Prasad" , Roland McGrath X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Modify process handling code to recognise hardware debug registers during copy and flush operations. Introduce a new TIF_DEBUG task flag to indicate a process's use of debug register. Load the debug register values into a new CPU during initialisation. Signed-off-by: K.Prasad --- arch/powerpc/kernel/process.c | 15 +++++++++++++++ arch/powerpc/kernel/smp.c | 2 ++ 2 files changed, 17 insertions(+) Index: linux-2.6-tip.hbkpt/arch/powerpc/kernel/process.c =================================================================== --- linux-2.6-tip.hbkpt.orig/arch/powerpc/kernel/process.c +++ linux-2.6-tip.hbkpt/arch/powerpc/kernel/process.c @@ -50,6 +50,7 @@ #include #ifdef CONFIG_PPC64 #include +#include #endif #include #include @@ -254,8 +255,10 @@ void do_dabr(struct pt_regs *regs, unsig 11, SIGSEGV) == NOTIFY_STOP) return; +#ifndef CONFIG_PPC64 if (debugger_dabr_match(regs)) return; +#endif /* Clear the DAC and struct entries. One shot trigger */ #if defined(CONFIG_BOOKE) @@ -372,8 +375,13 @@ struct task_struct *__switch_to(struct t #endif /* CONFIG_SMP */ +#ifdef CONFIG_PPC64 + if (unlikely(test_tsk_thread_flag(new, TIF_DEBUG))) + arch_install_thread_hw_breakpoint(new); +#else if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) set_dabr(new->thread.dabr); +#endif /* CONFIG_PPC64 */ #if defined(CONFIG_BOOKE) /* If new thread DAC (HW breakpoint) is the same then leave it */ @@ -550,6 +558,10 @@ void show_regs(struct pt_regs * regs) void exit_thread(void) { discard_lazy_cpu_state(); +#ifdef CONFIG_PPC64 + if (unlikely(test_tsk_thread_flag(current, TIF_DEBUG))) + flush_thread_hw_breakpoint(current); +#endif /* CONFIG_PPC64 */ } void flush_thread(void) @@ -672,6 +684,9 @@ int copy_thread(unsigned long clone_flag * function. */ kregs->nip = *((unsigned long *)ret_from_fork); + + if (unlikely(test_tsk_thread_flag(current, TIF_DEBUG))) + copy_thread_hw_breakpoint(current, p, clone_flags); #else kregs->nip = (unsigned long)ret_from_fork; #endif Index: linux-2.6-tip.hbkpt/arch/powerpc/kernel/smp.c =================================================================== --- linux-2.6-tip.hbkpt.orig/arch/powerpc/kernel/smp.c +++ linux-2.6-tip.hbkpt/arch/powerpc/kernel/smp.c @@ -48,6 +48,7 @@ #include #ifdef CONFIG_PPC64 #include +#include #endif #ifdef DEBUG @@ -536,6 +537,7 @@ int __devinit start_secondary(void *unus local_irq_enable(); + load_debug_registers(); cpu_idle(); return 0; }