From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH v2 3/7] x86, ptrace: Ifdef HW_BREAKPOINTS code in ptrace Date: Mon, 10 Mar 2014 15:35:22 +0100 Message-ID: <20140310143522.GB21735@redhat.com> References: <2741f8cbe6346ef051f7f7b1c39f9a026942b763.1394418994.git.josh@joshtriplett.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Suravee Suthikulpanit , Frederic Weisbecker , David Herrmann , Stephane Eranian , Paul Gortmaker , Paul Mackerras , "H. Peter Anvin" , Thomas Gleixner , Andi Kleen , x86@kernel.org, Ingo Molnar , oprofile-list@lists.sf.net, Mel Gorman , Arnaldo Carvalho de Melo , Borislav Petkov , Dave Young , Peter Zijlstra , Gleb Natapov , Steven Rostedt , Bin Gao , Matt Fleming , Jacob Shin , linux-kernel@vger.kernel.org, Torsten Kaiser Return-path: Content-Disposition: inline In-Reply-To: <2741f8cbe6346ef051f7f7b1c39f9a026942b763.1394418994.git.josh@joshtriplett.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: oprofile-list-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On 03/09, Josh Triplett wrote: > > +#ifdef CONFIG_HW_BREAKPOINTS > + > static void ptrace_triggered(struct perf_event *bp, > struct perf_sample_data *data, > struct pt_regs *regs) > @@ -778,6 +780,34 @@ static int ptrace_set_debugreg(struct task_struct *tsk, int n, > return rc; > } > > +#else > + > +/* Without breakpoints only handle DR6 */ > +static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n) > +{ > + struct thread_struct *thread = &tsk->thread; > + > + if (n == 6) > + return thread->debugreg6; > + return 0; > +} > + > +/* Without breakpoints only handle DR6 */ > +static int ptrace_set_debugreg(struct task_struct *tsk, int n, > + unsigned long val) > +{ > + struct thread_struct *thread = &tsk->thread; > + int rc = -EIO; > + > + if (n == 6) { > + thread->debugreg6 = val; > + rc = 0; > + } > + return rc; > +} > + > +#endif OK, but then perhaps this patch should also make thread_struct->ptrace_bps[] depend on CONFIG_HW_BREAKPOINTS ? This needs more changes though. In particular, it seems it makes sense to move flush_ptrace_hw_breakpoint() to x86/kernel/ptrace.c, so that it can live in the same ifdef'ed section. copy_threads() needs a cleanup anyway... But I won't insist if you prefer to do this later. Oleg. ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech