Fix ptrace debugctlmsr stomping and kill ptrace-bts
Subsystems (11)
cover Fix ptrace debugctlmsr stomping and kill ptrace-bts
ptrace was stomping all over debugctlmsr and since ptrace-bts was never used kill that and reimplement ptrace block-step to not trample on the msr.
PATCH 1/3 perf, x86: clean up debugctlmsr bit definitions
Move all debugctlmsr thingies into msr-index.h
--- arch/x86/include/asm/msr-index.h | 13 ++++++++----- arch/x86/kernel/cpu/perf_event_intel_ds.c | 23 +++++++---------------- arch/x86/kernel/cpu/perf_event_intel_lbr.c | 7 ++----- 3 files changed, 17 insertions(+), 26 deletions(-)
arch/x86/include/asm/msr-index.h +8 -5
@@ -71,11 +71,14 @@#define MSR_IA32_LASTINTTOIP 0x000001de/* DEBUGCTLMSR bits (others vary by model): */ -#define _DEBUGCTLMSR_LBR 0/* last branch recording */ -#define _DEBUGCTLMSR_BTF 1/* single-step on branches */ - -#define DEBUGCTLMSR_LBR (1UL << _DEBUGCTLMSR_LBR) -#define DEBUGCTLMSR_BTF (1UL << _DEBUGCTLMSR_BTF) +#define DEBUGCTLMSR_LBR (1UL << 0)/* last branch recording */ +#define DEBUGCTLMSR_BTF (1UL << 1)/* single-step on branches */ +#define DEBUGCTLMSR_TR (1UL << 6) +#define DEBUGCTLMSR_BTS (1UL << 7) +#define DEBUGCTLMSR_BTINT (1UL << 8) +#define DEBUGCTLMSR_BTS_OFF_OS (1UL << 9) +#define DEBUGCTLMSR_BTS_OFF_USR (1UL << 10) +#define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI (1UL << 11)#define MSR_IA32_MC0_CTL 0x00000400#define MSR_IA32_MC0_STATUS 0x00000401
arch/x86/kernel/cpu/perf_event_intel_ds.c +7 -16
@@ -38,15 +38,6 @@ struct pebs_record_nhm { };/* -* Bits in the debugctlmsr controlling branch tracing. -*/ -#define X86_DEBUGCTL_TR (1 << 6) -#define X86_DEBUGCTL_BTS (1 << 7) -#define X86_DEBUGCTL_BTINT (1 << 8) -#define X86_DEBUGCTL_BTS_OFF_OS (1 << 9) -#define X86_DEBUGCTL_BTS_OFF_USR (1 << 10) - -/* * A debug store configuration. * * We only support architectures that use 64bit fields.
@@ -193,15 +184,15 @@ static void intel_pmu_enable_bts(u64 con debugctlmsr =get_debugctlmsr (); - debugctlmsr |=X86_DEBUGCTL_TR ; - debugctlmsr |=X86_DEBUGCTL_BTS ; - debugctlmsr |=X86_DEBUGCTL_BTINT ; + debugctlmsr |=DEBUGCTLMSR_TR ; + debugctlmsr |=DEBUGCTLMSR_BTS ; + debugctlmsr |=DEBUGCTLMSR_BTINT ;if (!(config &ARCH_PERFMON_EVENTSEL_OS )) - debugctlmsr |=X86_DEBUGCTL_BTS_OFF_OS ; + debugctlmsr |=DEBUGCTLMSR_BTS_OFF_OS ;if (!(config &ARCH_PERFMON_EVENTSEL_USR )) - debugctlmsr |=X86_DEBUGCTL_BTS_OFF_USR ; + debugctlmsr |=DEBUGCTLMSR_BTS_OFF_USR ;update_debugctlmsr (debugctlmsr); }
@@ -217,8 +208,8 @@ static void intel_pmu_disable_bts(void) debugctlmsr =get_debugctlmsr (); debugctlmsr &= - ~(X86_DEBUGCTL_TR |X86_DEBUGCTL_BTS |X86_DEBUGCTL_BTINT | -X86_DEBUGCTL_BTS_OFF_OS |X86_DEBUGCTL_BTS_OFF_USR ); + ~(DEBUGCTLMSR_TR |DEBUGCTLMSR_BTS |DEBUGCTLMSR_BTINT | +DEBUGCTLMSR_BTS_OFF_OS |DEBUGCTLMSR_BTS_OFF_USR );update_debugctlmsr (debugctlmsr); }
arch/x86/kernel/cpu/perf_event_intel_lbr.c +2 -5
@@ -12,15 +12,12 @@ enum {* otherwise it becomes near impossible to get a reliable stack. */ -#define X86_DEBUGCTL_LBR (1 << 0) -#define X86_DEBUGCTL_FREEZE_LBRS_ON_PMI (1 << 11) -static void __intel_pmu_lbr_enable (void ) {u64 debugctl;rdmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); - debugctl |= (X86_DEBUGCTL_LBR |X86_DEBUGCTL_FREEZE_LBRS_ON_PMI ); + debugctl |= (DEBUGCTLMSR_LBR |DEBUGCTLMSR_FREEZE_LBRS_ON_PMI );wrmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); }
@@ -29,7 +26,7 @@ static void __intel_pmu_lbr_disable(voidu64 debugctl;rdmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); - debugctl &= ~(X86_DEBUGCTL_LBR |X86_DEBUGCTL_FREEZE_LBRS_ON_PMI ); + debugctl &= ~(DEBUGCTLMSR_LBR |DEBUGCTLMSR_FREEZE_LBRS_ON_PMI );wrmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); }
[tip:perf/core] perf, x86: Clean up debugctlmsr bit definitions
Commit-ID: 7c5ecaf7666617889f337296c610815b519abfa9 Gitweb: http://git.kernel.org/tip/7c5ecaf7666617889f337296c610815b519abfa9 Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 25 Mar 2010 14:51:49 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 26 Mar 2010 09:41:03 +0100
perf, x86: Clean up debugctlmsr bit definitions
Move all debugctlmsr thingies into msr-index.h
LKML-Reference: <[email protected]>
--- arch/x86/include/asm/msr-index.h | 13 ++++++++----- arch/x86/kernel/cpu/perf_event_intel_ds.c | 23 +++++++---------------- arch/x86/kernel/cpu/perf_event_intel_lbr.c | 7 ++----- 3 files changed, 17 insertions(+), 26 deletions(-)
arch/x86/include/asm/msr-index.h +8 -5
@@ -71,11 +71,14 @@#define MSR_IA32_LASTINTTOIP 0x000001de/* DEBUGCTLMSR bits (others vary by model): */ -#define _DEBUGCTLMSR_LBR 0/* last branch recording */ -#define _DEBUGCTLMSR_BTF 1/* single-step on branches */ - -#define DEBUGCTLMSR_LBR (1UL << _DEBUGCTLMSR_LBR) -#define DEBUGCTLMSR_BTF (1UL << _DEBUGCTLMSR_BTF) +#define DEBUGCTLMSR_LBR (1UL << 0)/* last branch recording */ +#define DEBUGCTLMSR_BTF (1UL << 1)/* single-step on branches */ +#define DEBUGCTLMSR_TR (1UL << 6) +#define DEBUGCTLMSR_BTS (1UL << 7) +#define DEBUGCTLMSR_BTINT (1UL << 8) +#define DEBUGCTLMSR_BTS_OFF_OS (1UL << 9) +#define DEBUGCTLMSR_BTS_OFF_USR (1UL << 10) +#define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI (1UL << 11)#define MSR_IA32_MC0_CTL 0x00000400#define MSR_IA32_MC0_STATUS 0x00000401
arch/x86/kernel/cpu/perf_event_intel_ds.c +7 -16
@@ -38,15 +38,6 @@ struct pebs_record_nhm { };/* -* Bits in the debugctlmsr controlling branch tracing. -*/ -#define X86_DEBUGCTL_TR (1 << 6) -#define X86_DEBUGCTL_BTS (1 << 7) -#define X86_DEBUGCTL_BTINT (1 << 8) -#define X86_DEBUGCTL_BTS_OFF_OS (1 << 9) -#define X86_DEBUGCTL_BTS_OFF_USR (1 << 10) - -/* * A debug store configuration. * * We only support architectures that use 64bit fields.
@@ -193,15 +184,15 @@ static void intel_pmu_enable_bts(u64 config) debugctlmsr =get_debugctlmsr (); - debugctlmsr |=X86_DEBUGCTL_TR ; - debugctlmsr |=X86_DEBUGCTL_BTS ; - debugctlmsr |=X86_DEBUGCTL_BTINT ; + debugctlmsr |=DEBUGCTLMSR_TR ; + debugctlmsr |=DEBUGCTLMSR_BTS ; + debugctlmsr |=DEBUGCTLMSR_BTINT ;if (!(config &ARCH_PERFMON_EVENTSEL_OS )) - debugctlmsr |=X86_DEBUGCTL_BTS_OFF_OS ; + debugctlmsr |=DEBUGCTLMSR_BTS_OFF_OS ;if (!(config &ARCH_PERFMON_EVENTSEL_USR )) - debugctlmsr |=X86_DEBUGCTL_BTS_OFF_USR ; + debugctlmsr |=DEBUGCTLMSR_BTS_OFF_USR ;update_debugctlmsr (debugctlmsr); }
@@ -217,8 +208,8 @@ static void intel_pmu_disable_bts(void) debugctlmsr =get_debugctlmsr (); debugctlmsr &= - ~(X86_DEBUGCTL_TR |X86_DEBUGCTL_BTS |X86_DEBUGCTL_BTINT | -X86_DEBUGCTL_BTS_OFF_OS |X86_DEBUGCTL_BTS_OFF_USR ); + ~(DEBUGCTLMSR_TR |DEBUGCTLMSR_BTS |DEBUGCTLMSR_BTINT | +DEBUGCTLMSR_BTS_OFF_OS |DEBUGCTLMSR_BTS_OFF_USR );update_debugctlmsr (debugctlmsr); }
arch/x86/kernel/cpu/perf_event_intel_lbr.c +2 -5
@@ -12,15 +12,12 @@ enum {* otherwise it becomes near impossible to get a reliable stack. */ -#define X86_DEBUGCTL_LBR (1 << 0) -#define X86_DEBUGCTL_FREEZE_LBRS_ON_PMI (1 << 11) -static void __intel_pmu_lbr_enable (void ) {u64 debugctl;rdmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); - debugctl |= (X86_DEBUGCTL_LBR |X86_DEBUGCTL_FREEZE_LBRS_ON_PMI ); + debugctl |= (DEBUGCTLMSR_LBR |DEBUGCTLMSR_FREEZE_LBRS_ON_PMI );wrmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); }
@@ -29,7 +26,7 @@ static void __intel_pmu_lbr_disable(void)u64 debugctl;rdmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); - debugctl &= ~(X86_DEBUGCTL_LBR |X86_DEBUGCTL_FREEZE_LBRS_ON_PMI ); + debugctl &= ~(DEBUGCTLMSR_LBR |DEBUGCTLMSR_FREEZE_LBRS_ON_PMI );wrmsrl (MSR_IA32_DEBUGCTLMSR , debugctl); }
PATCH 2/3 x86, ptrace, bts: Delete the never used ptrace-bts code
In reply to Peter ZijlstraTIF_DEBUGCTLMSR is trampling all over that MSR without regard for other uses (perf) and doesn't provide the flexibility needed for perf.
Its users are ptrace-block-step and ptrace-bts, since ptrace-bts was never used and ptrace-block-step can be implemented using a much simpler approach axe all of it.
--- arch/x86/Kconfig.cpu | 20 arch/x86/Kconfig.debug | 9 arch/x86/include/asm/ds.h | 302 ------- arch/x86/include/asm/processor.h | 32 arch/x86/include/asm/ptrace-abi.h | 59 - arch/x86/include/asm/ptrace.h | 10 arch/x86/include/asm/thread_info.h | 6 arch/x86/kernel/Makefile | 2 arch/x86/kernel/cpu/intel.c | 2 arch/x86/kernel/ds.c | 1437 ------------------------------------- arch/x86/kernel/ds_selftest.c | 408 ---------- arch/x86/kernel/ds_selftest.h | 15 arch/x86/kernel/dumpstack.c | 5 arch/x86/kernel/kprobes.c | 6 arch/x86/kernel/process.c | 9 arch/x86/kernel/process_32.c | 8 arch/x86/kernel/process_64.c | 8 arch/x86/kernel/ptrace.c | 382 --------- arch/x86/kernel/step.c | 36 arch/x86/kernel/traps.c | 5 include/linux/ftrace.h | 12 include/linux/mm.h | 4 include/linux/ptrace.h | 12 include/linux/sched.h | 9 kernel/fork.c | 3 kernel/ptrace.c | 1 kernel/sched.c | 43 - kernel/trace/Kconfig | 11 kernel/trace/Makefile | 1 kernel/trace/trace.h | 4 kernel/trace/trace_entries.h | 12 kernel/trace/trace_hw_branches.c | 312 -------- kernel/trace/trace_selftest.c | 57 - mm/mlock.c | 41 - 34 files changed, 8 insertions(+), 3275 deletions(-)
arch/x86/kernel/ptrace.c +0 -382
@@ -2,9 +2,6 @@/* * Pentium III FXSR, SSE support * Gareth Hughes <[email protected]>, May 2000 -* -* BTS tracing -* Markus Metzger <[email protected]>, Dec 2007 */ #include <linux/kernel.h>
@@ -21,7 +18,6 @@#include <linux/audit.h> #include <linux/seccomp.h> #include <linux/signal.h> -#include <linux/workqueue.h> #include <linux/perf_event.h> #include <linux/hw_breakpoint.h>
@@ -35,7 +31,6 @@#include <asm/desc.h> #include <asm/prctl.h> #include <asm/proto.h> -#include <asm/ds.h> #include <asm/hw_breakpoint.h> #include "tls.h"
@@ -788,342 +783,6 @@ static int ioperm_get(struct task_struct 0, IO_BITMAP_BYTES); } -#ifdef CONFIG_X86_PTRACE_BTS -/* -* A branch trace store context. -* -* Contexts may only be installed by ptrace_bts_config() and only for -* ptraced tasks. -* -* Contexts are destroyed when the tracee is detached from the tracer. -* The actual destruction work requires interrupts enabled, so the -* work is deferred and will be scheduled during __ptrace_unlink(). -* -* Contexts hold an additional task_struct reference on the traced -* task, as well as a reference on the tracer's mm. -* -* Ptrace already holds a task_struct for the duration of ptrace operations, -* but since destruction is deferred, it may be executed after both -* tracer and tracee exited. -*/ -struct bts_context { -/* The branch trace handle. */ -struct bts_tracer *tracer; - -/* The buffer used to store the branch trace and its size. */ -void *buffer; -unsigned int size; - -/* The mm that paid for the above buffer. */ -struct mm_struct *mm; - -/* The task this context belongs to. */ -struct task_struct *task; - -/* The signal to send on a bts buffer overflow. */ -unsigned int bts_ovfl_signal; - -/* The work struct to destroy a context. */ -struct work_struct work; -}; - -static int alloc_bts_buffer (struct bts_context *context,unsigned int size) -{ -void *buffer =NULL ; -int err = -ENOMEM ; - - err =account_locked_memory (current->mm, current->signal->rlim, size); -if (err <0 ) -return err; - - buffer =kzalloc (size,GFP_KERNEL ); -if (!buffer) - goto out_refund; - - context->buffer = buffer; - context->size = size; - context->mm =get_task_mm (current); - -return 0 ; - - out_refund: -refund_locked_memory (current->mm, size); -return err; -} - -static inline void free_bts_buffer (struct bts_context *context) -{ -if (!context->buffer) -return ; - -kfree (context->buffer); - context->buffer =NULL ; - -refund_locked_memory (context->mm, context->size); - context->size =0 ; - -mmput (context->mm); - context->mm =NULL ; -} - -static void free_bts_context_work (struct work_struct *w) -{ -struct bts_context *context; - - context = container_of(w, struct bts_context, work); - -ds_release_bts (context->tracer); -put_task_struct (context->task); -free_bts_buffer (context); -kfree (context); -} - -static inline void free_bts_context (struct bts_context *context) -{ -INIT_WORK (&context->work, free_bts_context_work); -schedule_work (&context->work); -} - -static inline struct bts_context *alloc_bts_context (struct task_struct *task) -{ -struct bts_context *context =kzalloc (sizeof (*context),GFP_KERNEL ); -if (context) { - context->task = task; - task->bts = context; - -get_task_struct (task); - } - -return context; -} - -static int ptrace_bts_read_record (struct task_struct *child,size_t index, -struct bts_struct __user *out) -{ -struct bts_context *context; -const struct bts_trace *trace; -struct bts_struct bts; -const unsigned char *at; -int error; - - context = child->bts; -if (!context) -return -ESRCH ; - - trace =ds_read_bts (context->tracer); -if (!trace) -return -ESRCH ; - - at = trace->ds.top - ((index +1 ) * trace->ds.size); -if ((void *)at < trace->ds.begin) - at += (trace->ds.n * trace->ds.size); - -if (!trace->read) -return -EOPNOTSUPP ; - - error = trace->read (context->tracer, at, &bts); -if (error <0 ) -return error; - -if (copy_to_user (out, &bts,sizeof (bts))) -return -EFAULT ; - -return sizeof (bts); -} - -static int ptrace_bts_drain (struct task_struct *child, -long size, -struct bts_struct __user *out) -{ -struct bts_context *context; -const struct bts_trace *trace; -const unsigned char *at; -int error, drained =0 ; - - context = child->bts; -if (!context) -return -ESRCH ; - - trace =ds_read_bts (context->tracer); -if (!trace) -return -ESRCH ; - -if (!trace->read) -return -EOPNOTSUPP ; - -if (size < (trace->ds.top - trace->ds.begin)) -return -EIO ; - -for (at = trace->ds.begin; (void *)at < trace->ds.top; - out++, drained++, at += trace->ds.size) { -struct bts_struct bts; - - error = trace->read (context->tracer, at, &bts); -if (error <0 ) -return error; - -if (copy_to_user (out, &bts,sizeof (bts))) -return -EFAULT ; - } - -memset (trace->ds.begin,0 , trace->ds.n * trace->ds.size); - - error =ds_reset_bts (context->tracer); -if (error <0 ) -return error; - -return drained; -} - -static int ptrace_bts_config (struct task_struct *child, -long cfg_size, -const struct ptrace_bts_config __user *ucfg) -{ -struct bts_context *context; -struct ptrace_bts_config cfg; -unsigned int flags =0 ; - -if (cfg_size <sizeof (cfg)) -return -EIO ; - -if (copy_from_user (&cfg, ucfg,sizeof (cfg))) -return -EFAULT ; - - context = child->bts; -if (!context) - context =alloc_bts_context (child); -if (!context) -return -ENOMEM ; - -if (cfg.flags &PTRACE_BTS_O_SIGNAL ) { -if (!cfg.signal) -return -EINVAL ; - -return -EOPNOTSUPP ; - context->bts_ovfl_signal = cfg.signal; - } - -ds_release_bts (context->tracer); - context->tracer =NULL ; - -if ((cfg.flags &PTRACE_BTS_O_ALLOC ) && (cfg.size != context->size)) { -int err; - -free_bts_buffer (context); -if (!cfg.size) -return 0 ; - - err =alloc_bts_buffer (context, cfg.size); -if (err <0 ) -return err; - } - -if (cfg.flags &PTRACE_BTS_O_TRACE ) - flags |=BTS_USER ; - -if (cfg.flags &PTRACE_BTS_O_SCHED ) - flags |=BTS_TIMESTAMPS ; - - context->tracer = -ds_request_bts_task (child, context->buffer, context->size, -NULL , (size_t )-1 , flags); -if (unlikely (IS_ERR (context->tracer))) { -int error =PTR_ERR (context->tracer); - -free_bts_buffer (context); - context->tracer =NULL ; -return error; - } - -return sizeof (cfg); -} - -static int ptrace_bts_status (struct task_struct *child, -long cfg_size, -struct ptrace_bts_config __user *ucfg) -{ -struct bts_context *context; -const struct bts_trace *trace; -struct ptrace_bts_config cfg; - - context = child->bts; -if (!context) -return -ESRCH ; - -if (cfg_size <sizeof (cfg)) -return -EIO ; - - trace =ds_read_bts (context->tracer); -if (!trace) -return -ESRCH ; - -memset (&cfg,0 ,sizeof (cfg)); - cfg.size = trace->ds.end - trace->ds.begin; - cfg.signal = context->bts_ovfl_signal; - cfg.bts_size =sizeof (struct bts_struct ); - -if (cfg.signal) - cfg.flags |=PTRACE_BTS_O_SIGNAL ; - -if (trace->ds.flags &BTS_USER ) - cfg.flags |=PTRACE_BTS_O_TRACE ; - -if (trace->ds.flags &BTS_TIMESTAMPS ) - cfg.flags |=PTRACE_BTS_O_SCHED ; - -if (copy_to_user (ucfg, &cfg,sizeof (cfg))) -return -EFAULT ; - -return sizeof (cfg); -} - -static int ptrace_bts_clear (struct task_struct *child) -{ -struct bts_context *context; -const struct bts_trace *trace; - - context = child->bts; -if (!context) -return -ESRCH ; - - trace =ds_read_bts (context->tracer); -if (!trace) -return -ESRCH ; - -memset (trace->ds.begin,0 , trace->ds.n * trace->ds.size); - -return ds_reset_bts (context->tracer); -} - -static int ptrace_bts_size (struct task_struct *child) -{ -struct bts_context *context; -const struct bts_trace *trace; - - context = child->bts; -if (!context) -return -ESRCH ; - - trace =ds_read_bts (context->tracer); -if (!trace) -return -ESRCH ; - -return (trace->ds.top - trace->ds.begin) / trace->ds.size; -} - -/* -* Called from __ptrace_unlink() after the child has been moved back -* to its original parent. -*/ -void ptrace_bts_untrace (struct task_struct *child) -{ -if (unlikely (child->bts)) { -free_bts_context (child->bts); - child->bts =NULL ; - } -} -#endif /* CONFIG_X86_PTRACE_BTS */ -/* * Called by kernel/ptrace.c when detaching.. *
@@ -1251,39 +910,6 @@ long arch_ptrace(struct task_struct *chibreak ;#endif -/* -* These bits need more cooking - not enabled yet: -*/ -#ifdef CONFIG_X86_PTRACE_BTS -case PTRACE_BTS_CONFIG : - ret =ptrace_bts_config - (child, data, (struct ptrace_bts_config __user *)addr); -break ; - -case PTRACE_BTS_STATUS : - ret =ptrace_bts_status - (child, data, (struct ptrace_bts_config __user *)addr); -break ; - -case PTRACE_BTS_SIZE : - ret =ptrace_bts_size (child); -break ; - -case PTRACE_BTS_GET : - ret =ptrace_bts_read_record - (child, data, (struct bts_struct __user *) addr); -break ; - -case PTRACE_BTS_CLEAR : - ret =ptrace_bts_clear (child); -break ; - -case PTRACE_BTS_DRAIN : - ret =ptrace_bts_drain - (child, data, (struct bts_struct __user *) addr); -break ; -#endif /* CONFIG_X86_PTRACE_BTS */ -default : ret =ptrace_request (child, request, addr, data);break ;
@@ -1543,14 +1169,6 @@ long compat_arch_ptrace(struct task_strucase PTRACE_GET_THREAD_AREA :case PTRACE_SET_THREAD_AREA : -#ifdef CONFIG_X86_PTRACE_BTS -case PTRACE_BTS_CONFIG : -case PTRACE_BTS_STATUS : -case PTRACE_BTS_SIZE : -case PTRACE_BTS_GET : -case PTRACE_BTS_CLEAR : -case PTRACE_BTS_DRAIN : -#endif /* CONFIG_X86_PTRACE_BTS */ return arch_ptrace (child, request, addr, data);default :
include/linux/mm.h +0 -4
@@ -19,7 +19,6 @@ struct anon_vma;struct file_ra_state ;struct user_struct ;struct writeback_control ; -struct rlimit ;#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */ extern unsigned long max_mapnr;
@@ -1449,9 +1448,6 @@ int vmemmap_populate_basepages(struct paint vmemmap_populate (struct page *start_page,unsigned long pages,int node);void vmemmap_populate_print_last (void ); -extern int account_locked_memory (struct mm_struct *mm,struct rlimit *rlim, -size_t size); -extern void refund_locked_memory (struct mm_struct *mm,size_t size);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,
mm/mlock.c +0 -41
44 lines not on this page · raw message
arch/x86/Kconfig.cpu +0 -20
@@ -502,23 +502,3 @@ config CPU_SUP_UMC_32 CPU might render the kernel unbootable. If unsure, say N. - -config X86_DS - def_bool X86_PTRACE_BTS - depends on X86_DEBUGCTLMSR - select HAVE_HW_BRANCH_TRACER - -config X86_PTRACE_BTS - bool "Branch Trace Store" - default y - depends on X86_DEBUGCTLMSR - depends on BROKEN - ---help--- - This adds a ptrace interface to the hardware's branch trace store. - - Debuggers may use it to collect an execution trace of the debugged - application in order to answer the question 'how did I get here?'. - Debuggers may trace user mode as well as kernel mode. - - Say Y unless there is no application development on this machine - and you want to save a small amount of code size.
arch/x86/include/asm/ptrace.h +1 -9
@@ -127,12 +127,10 @@ struct pt_regs {#endif /* __KERNEL__ */ #endif /* !__i386__ */ -#ifdef __KERNEL__ -#include <linux/init.h> +#include <linux/stddef.h> -struct cpuinfo_x86 ;struct task_struct ;extern unsigned long profile_pc (struct pt_regs *regs);
@@ -289,12 +287,6 @@ extern int do_get_thread_area(struct tasextern int do_set_thread_area (struct task_struct *p,int idx,struct user_desc __user *info,int can_allocate); -#ifdef CONFIG_X86_PTRACE_BTS -extern void ptrace_bts_untrace (struct task_struct *tsk); - -#define arch_ptrace_untrace (tsk) ptrace_bts_untrace(tsk) -#endif /* CONFIG_X86_PTRACE_BTS */ -#endif /* __KERNEL__ */ #endif /* !__ASSEMBLY__ */
include/linux/ptrace.h +0 -12
@@ -345,18 +345,6 @@ static inline void user_single_step_sigi#define arch_ptrace_stop (code, info) do { } while (0)#endif -#ifndef arch_ptrace_untrace -/* -* Do machine-specific work before untracing child. -* -* This is called for a normal detach as well as from ptrace_exit() -* when the tracing task dies. -* -* Called with write_lock(&tasklist_lock) held. -*/ -#define arch_ptrace_untrace (task) do { } while (0) -#endif -extern int task_current_syscall (struct task_struct *target,long *callno,unsigned long args[6 ],unsigned int maxargs,unsigned long *sp,unsigned long *pc);
include/linux/sched.h +0 -9
@@ -99,7 +99,6 @@ struct futex_pi_state;struct robust_list_head ;struct bio_list ;struct fs_struct ; -struct bts_context ;struct perf_event_context ;/*
@@ -1268,12 +1267,6 @@ struct task_struct {struct list_head ptraced;struct list_head ptrace_entry; -/* -* This is the tracer handle for the ptrace BTS extension. -* This field actually belongs to the ptracer task. -*/ -struct bts_context *bts; -/* PID/PID hash table linkage. */ struct pid_link pids[PIDTYPE_MAX ];struct list_head thread_group;
@@ -2119,10 +2112,8 @@ extern void set_task_comm(struct task_stextern char *get_task_comm (char *to,struct task_struct *tsk);#ifdef CONFIG_SMP -extern void wait_task_context_switch (struct task_struct *p);extern unsigned long wait_task_inactive (struct task_struct *,long match_state);#else -static inline void wait_task_context_switch (struct task_struct *p) {}static inline unsigned long wait_task_inactive (struct task_struct *p,long match_state) {
kernel/fork.c +0 -3
@@ -1108,9 +1108,6 @@ static struct task_struct *copy_process( p->memcg_batch.do_batch =0 ; p->memcg_batch.memcg =NULL ;#endif - - p->bts =NULL ; - p->stack_start = stack_start;/* Perform scheduler related setup. Assign this task to a CPU. */
kernel/ptrace.c +0 -1
@@ -76,7 +76,6 @@ void __ptrace_unlink(struct task_struct child->parent = child->real_parent;list_del_init (&child->ptrace_entry); -arch_ptrace_untrace (child);if (task_is_traced (child))ptrace_untrace (child); }
arch/x86/include/asm/processor.h +0 -32
@@ -21,7 +21,6 @@ struct mm_struct;#include <asm/msr.h> #include <asm/desc_defs.h> #include <asm/nops.h> -#include <asm/ds.h> #include <linux/personality.h> #include <linux/cpumask.h>
@@ -473,10 +472,6 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; -/* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set. */ -unsigned long debugctlmsr; -/* Debug Store context; see asm/ds.h */ -struct ds_context *ds_ctx; };static inline unsigned long native_get_debugreg (int regno)
@@ -814,21 +809,6 @@ static inline unsigned long get_debugctlreturn debugctlmsr; } -static inline unsigned long get_debugctlmsr_on_cpu (int cpu) -{ -u64 debugctlmsr =0 ; -u32 val1, val2; - -#ifndef CONFIG_X86_DEBUGCTLMSR -if (boot_cpu_data.x86 <6 ) -return 0 ; -#endif -rdmsr_on_cpu (cpu,MSR_IA32_DEBUGCTLMSR , &val1, &val2); - debugctlmsr = val1 | ((u64 )val2 <<32 ); - -return debugctlmsr; -} -static inline void update_debugctlmsr (unsigned long debugctlmsr) {#ifndef CONFIG_X86_DEBUGCTLMSR
@@ -838,18 +818,6 @@ static inline void update_debugctlmsr(unwrmsrl (MSR_IA32_DEBUGCTLMSR , debugctlmsr); } -static inline void update_debugctlmsr_on_cpu (int cpu, -unsigned long debugctlmsr) -{ -#ifndef CONFIG_X86_DEBUGCTLMSR -if (boot_cpu_data.x86 <6 ) -return ; -#endif -wrmsr_on_cpu (cpu,MSR_IA32_DEBUGCTLMSR , - (u32)((u64 )debugctlmsr), - (u32)((u64 )debugctlmsr >>32 )); -} -/* * from system description table in BIOS. Mostly for MCA use, but * others may find it useful:
arch/x86/kernel/process.c +0 -9
@@ -20,7 +20,6 @@#include <asm/idle.h> #include <asm/uaccess.h> #include <asm/i387.h> -#include <asm/ds.h> #include <asm/debugreg.h> unsigned long idle_halt;
@@ -50,8 +49,6 @@ void free_thread_xstate(struct task_strukmem_cache_free (task_xstate_cachep, tsk->thread.xstate); tsk->thread.xstate =NULL ; } - -WARN (tsk->thread.ds_ctx,"leaking DS context\n" ); }void free_thread_info (struct thread_info *ti)
@@ -198,12 +195,6 @@ void __switch_to_xtra(struct task_struct prev = &prev_p->thread; next = &next_p->thread; -if (test_tsk_thread_flag (next_p,TIF_DS_AREA_MSR ) || -test_tsk_thread_flag (prev_p,TIF_DS_AREA_MSR )) -ds_switch_to (prev_p, next_p); -else if (next->debugctlmsr != prev->debugctlmsr) -update_debugctlmsr (next->debugctlmsr); -if (test_tsk_thread_flag (prev_p,TIF_NOTSC ) ^test_tsk_thread_flag (next_p,TIF_NOTSC )) {/* prev and next are different */
arch/x86/kernel/process_32.c +0 -8
@@ -55,7 +55,6 @@#include <asm/cpu.h> #include <asm/idle.h> #include <asm/syscalls.h> -#include <asm/ds.h> #include <asm/debugreg.h> asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
@@ -238,13 +237,6 @@ int copy_thread(unsigned long clone_flagkfree (p->thread.io_bitmap_ptr); p->thread.io_bitmap_max =0 ; } - -clear_tsk_thread_flag (p,TIF_DS_AREA_MSR ); - p->thread.ds_ctx =NULL ; - -clear_tsk_thread_flag (p,TIF_DEBUGCTLMSR ); - p->thread.debugctlmsr =0 ; -return err; }
arch/x86/kernel/process_64.c +0 -8
@@ -49,7 +49,6 @@#include <asm/ia32.h> #include <asm/idle.h> #include <asm/syscalls.h> -#include <asm/ds.h> #include <asm/debugreg.h> asmlinkage extern void ret_from_fork(void);
@@ -313,13 +312,6 @@ int copy_thread(unsigned long clone_flagif (err) goto out; } - -clear_tsk_thread_flag (p,TIF_DS_AREA_MSR ); - p->thread.ds_ctx =NULL ; - -clear_tsk_thread_flag (p,TIF_DEBUGCTLMSR ); - p->thread.debugctlmsr =0 ; - err =0 ; out:if (err && p->thread.io_bitmap_ptr) {
kernel/trace/trace_selftest.c +0 -57
69 lines not on this page · raw message
kernel/trace/trace_hw_branches.c deleted +0 -312
312 lines not on this page · raw message
kernel/sched.c +0 -43
49 lines not on this page · raw message
kernel/trace/trace.h +0 -4
@@ -34,7 +34,6 @@ enum trace_type {TRACE_GRAPH_RET ,TRACE_GRAPH_ENT ,TRACE_USER_STACK , -TRACE_HW_BRANCHES ,TRACE_KMEM_ALLOC ,TRACE_KMEM_FREE , TRACE_BLK,
@@ -229,7 +228,6 @@ extern void __ftrace_bad_type(void); TRACE_GRAPH_ENT); \ IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \TRACE_GRAPH_RET ); \ - IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \TRACE_KMEM_ALLOC ); \ IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \
@@ -467,8 +465,6 @@ extern int trace_selftest_startup_syspro struct trace_array *tr);extern int trace_selftest_startup_branch (struct tracer *trace,struct trace_array *tr); -extern int trace_selftest_startup_hw_branches (struct tracer *trace, -struct trace_array *tr);extern int trace_selftest_startup_ksym (struct tracer *trace,struct trace_array *tr);#endif /* CONFIG_FTRACE_STARTUP_TEST */
arch/x86/Kconfig.debug +0 -9
@@ -174,15 +174,6 @@ config IOMMU_LEAK Add a simple leak tracer to the IOMMU code. This is useful when you are debugging a buggy device driver that leaks IOMMU mappings. -config X86_DS_SELFTEST - bool "DS selftest" - default y - depends on DEBUG_KERNEL - depends on X86_DS - ---help--- - Perform Debug Store selftests at boot time. - If in doubt, say "N". - config HAVE_MMIOTRACE_SUPPORT def_bool y
arch/x86/kernel/Makefile +0 -2
@@ -47,8 +47,6 @@ obj-$(CONFIG_X86_TRAMPOLINE) += trampoli obj-y += process.o obj-y += i387.o xsave.o obj-y += ptrace.o -obj-$(CONFIG_X86_DS) += ds.o -obj-$(CONFIG_X86_DS_SELFTEST) += ds_selftest.o obj-$(CONFIG_X86_32) += tls.o obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o
arch/x86/include/asm/ptrace-abi.h +0 -59
63 lines not on this page · raw message
include/linux/ftrace.h +0 -12
@@ -504,18 +504,6 @@ extern int ftrace_dump_on_oops;#define INIT_TRACE_RECURSION #endif -#ifdef CONFIG_HW_BRANCH_TRACER - -void trace_hw_branch (u64 from,u64 to); -void trace_hw_branch_oops (void ); - -#else /* CONFIG_HW_BRANCH_TRACER */ - -static inline void trace_hw_branch (u64 from,u64 to) {} -static inline void trace_hw_branch_oops (void ) {} - -#endif /* CONFIG_HW_BRANCH_TRACER */ -#ifdef CONFIG_FTRACE_SYSCALLS unsigned long arch_syscall_addr (int nr);
kernel/trace/Kconfig +0 -11
@@ -44,9 +44,6 @@ config HAVE_FTRACE_MCOUNT_RECORD help See Documentation/trace/ftrace-design.txt -config HAVE_HW_BRANCH_TRACER - bool - config HAVE_SYSCALL_TRACEPOINTS bool help
@@ -374,14 +371,6 @@ config STACK_TRACER Say N if unsure. -config HW_BRANCH_TRACER - depends on HAVE_HW_BRANCH_TRACER - bool "Trace hw branches" - select GENERIC_TRACER - help - This tracer records all branches on the system in a circular - buffer, giving access to the last N branches for each cpu. - config KMEMTRACE bool "Trace SLAB allocations" select GENERIC_TRACER
kernel/trace/Makefile +0 -1
@@ -41,7 +41,6 @@ obj-$(CONFIG_MMIOTRACE) += trace_mmiotra obj-$(CONFIG_BOOT_TRACER) += trace_boot.o obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += trace_functions_graph.o obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o -obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o obj-$(CONFIG_KMEMTRACE) += kmemtrace.o obj-$(CONFIG_WORKQUEUE_TRACER) += trace_workqueue.o obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
arch/x86/include/asm/thread_info.h +1 -5
@@ -92,8 +92,6 @@ struct thread_info {#define TIF_IO_BITMAP 22/* uses I/O bitmap */ #define TIF_FREEZE 23/* is freezing for suspend */ #define TIF_FORCED_TF 24/* true if TF in eflags artificially */ -#define TIF_DEBUGCTLMSR 25/* uses thread_struct.debugctlmsr */ -#define TIF_DS_AREA_MSR 26/* uses thread_struct.ds_area_msr */ #define TIF_LAZY_MMU_UPDATES 27/* task is updating the mmu lazily */ #define TIF_SYSCALL_TRACEPOINT 28/* syscall tracepoint instrumentation */
@@ -115,8 +113,6 @@ struct thread_info {#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)#define _TIF_FREEZE (1 << TIF_FREEZE)#define _TIF_FORCED_TF (1 << TIF_FORCED_TF) -#define _TIF_DEBUGCTLMSR (1 << TIF_DEBUGCTLMSR) -#define _TIF_DS_AREA_MSR (1 << TIF_DS_AREA_MSR)#define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
@@ -147,7 +143,7 @@ struct thread_info {/* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW \ - (_TIF_IO_BITMAP|_TIF_DEBUGCTLMSR|_TIF_DS_AREA_MSR|_TIF_NOTSC) + (_TIF_IO_BITMAP|_TIF_NOTSC)#define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY)#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
arch/x86/kernel/cpu/intel.c +0 -2
@@ -12,7 +12,6 @@#include <asm/processor.h> #include <asm/pgtable.h> #include <asm/msr.h> -#include <asm/ds.h> #include <asm/bugs.h> #include <asm/cpu.h>
@@ -367,7 +366,6 @@ static void __cpuinit init_intel(structset_cpu_cap (c,X86_FEATURE_BTS );if (!(l1 & (1 <<12 )))set_cpu_cap (c,X86_FEATURE_PEBS ); -ds_init_intel (c); }if (c->x86 ==6 && c->x86_model ==29 && cpu_has_clflush)
arch/x86/include/asm/ds.h deleted +0 -302
302 lines not on this page · raw message
arch/x86/kernel/ds.c deleted +0 -1437
1,362 lines not on this page · raw message
arch/x86/kernel/ds_selftest.c deleted +0 -408
408 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
[tip:perf/core] x86, perf, bts, mm: Delete the never used BTS-ptrace code
Commit-ID: faa4602e47690fb11221e00f9b9697c8dc0d4b19 Gitweb: http://git.kernel.org/tip/faa4602e47690fb11221e00f9b9697c8dc0d4b19 Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 25 Mar 2010 14:51:50 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 26 Mar 2010 11:33:55 +0100
x86, perf, bts, mm: Delete the never used BTS-ptrace code
Support for the PMU's BTS features has been upstreamed in v2.6.32, but we still have the old and disabled ptrace-BTS, as Linus noticed it not so long ago.
It's buggy: TIF_DEBUGCTLMSR is trampling all over that MSR without regard for other uses (perf) and doesn't provide the flexibility needed for perf either.
Its users are ptrace-block-step and ptrace-bts, since ptrace-bts was never used and ptrace-block-step can be implemented using a much simpler approach.
So axe all 3000 lines of it. That includes the *locked_memory*() APIs in mm/mlock.c as well.
LKML-Reference: <[email protected]>
--- arch/x86/Kconfig.cpu | 20 - arch/x86/Kconfig.debug | 9 - arch/x86/include/asm/ds.h | 302 -------- arch/x86/include/asm/processor.h | 33 +- arch/x86/include/asm/ptrace-abi.h | 57 +-- arch/x86/include/asm/ptrace.h | 6 - arch/x86/include/asm/thread_info.h | 6 +- arch/x86/kernel/Makefile | 2 - arch/x86/kernel/cpu/intel.c | 2 - arch/x86/kernel/ds.c | 1437 ------------------------------------ arch/x86/kernel/ds_selftest.c | 408 ---------- arch/x86/kernel/ds_selftest.h | 15 - arch/x86/kernel/dumpstack.c | 5 - arch/x86/kernel/kprobes.c | 6 +- arch/x86/kernel/process.c | 9 - arch/x86/kernel/process_32.c | 8 - arch/x86/kernel/process_64.c | 8 - arch/x86/kernel/ptrace.c | 382 ---------- arch/x86/kernel/step.c | 36 +- arch/x86/kernel/traps.c | 5 - include/linux/ftrace.h | 12 - include/linux/mm.h | 4 - include/linux/ptrace.h | 12 - include/linux/sched.h | 9 - kernel/fork.c | 3 - kernel/ptrace.c | 1 - kernel/sched.c | 43 -- kernel/trace/Kconfig | 11 - kernel/trace/Makefile | 1 - kernel/trace/trace.h | 4 - kernel/trace/trace_entries.h | 12 - kernel/trace/trace_hw_branches.c | 312 -------- kernel/trace/trace_selftest.c | 57 -- mm/mlock.c | 41 - 34 files changed, 9 insertions(+), 3269 deletions(-)
arch/x86/Kconfig.cpu +0 -20
@@ -502,23 +502,3 @@ config CPU_SUP_UMC_32 CPU might render the kernel unbootable. If unsure, say N. - -config X86_DS - def_bool X86_PTRACE_BTS - depends on X86_DEBUGCTLMSR - select HAVE_HW_BRANCH_TRACER - -config X86_PTRACE_BTS - bool "Branch Trace Store" - default y - depends on X86_DEBUGCTLMSR - depends on BROKEN - ---help--- - This adds a ptrace interface to the hardware's branch trace store. - - Debuggers may use it to collect an execution trace of the debugged - application in order to answer the question 'how did I get here?'. - Debuggers may trace user mode as well as kernel mode. - - Say Y unless there is no application development on this machine - and you want to save a small amount of code size.
arch/x86/Kconfig.debug +0 -9
@@ -174,15 +174,6 @@ config IOMMU_LEAK Add a simple leak tracer to the IOMMU code. This is useful when you are debugging a buggy device driver that leaks IOMMU mappings. -config X86_DS_SELFTEST - bool "DS selftest" - default y - depends on DEBUG_KERNEL - depends on X86_DS - ---help--- - Perform Debug Store selftests at boot time. - If in doubt, say "N". - config HAVE_MMIOTRACE_SUPPORT def_bool y
arch/x86/include/asm/ds.h deleted +0 -302
302 lines not on this page · raw message
arch/x86/include/asm/processor.h +1 -32
@@ -21,7 +21,6 @@ struct mm_struct;#include <asm/msr.h> #include <asm/desc_defs.h> #include <asm/nops.h> -#include <asm/ds.h> #include <linux/personality.h> #include <linux/cpumask.h>
@@ -29,6 +28,7 @@ struct mm_struct;#include <linux/threads.h> #include <linux/math64.h> #include <linux/init.h> +#include <linux/err.h> #define HBP_NUM 4/*
@@ -473,10 +473,6 @@ struct thread_struct {unsigned long iopl;/* Max allowed port in the bitmap, in bytes: */ unsigned io_bitmap_max; -/* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set. */ -unsigned long debugctlmsr; -/* Debug Store context; see asm/ds.h */ -struct ds_context *ds_ctx; };static inline unsigned long native_get_debugreg (int regno)
@@ -814,21 +810,6 @@ static inline unsigned long get_debugctlmsr(void)return debugctlmsr; } -static inline unsigned long get_debugctlmsr_on_cpu (int cpu) -{ -u64 debugctlmsr =0 ; -u32 val1, val2; - -#ifndef CONFIG_X86_DEBUGCTLMSR -if (boot_cpu_data.x86 <6 ) -return 0 ; -#endif -rdmsr_on_cpu (cpu,MSR_IA32_DEBUGCTLMSR , &val1, &val2); - debugctlmsr = val1 | ((u64 )val2 <<32 ); - -return debugctlmsr; -} -static inline void update_debugctlmsr (unsigned long debugctlmsr) {#ifndef CONFIG_X86_DEBUGCTLMSR
@@ -838,18 +819,6 @@ static inline void update_debugctlmsr(unsigned long debugctlmsr)wrmsrl (MSR_IA32_DEBUGCTLMSR , debugctlmsr); } -static inline void update_debugctlmsr_on_cpu (int cpu, -unsigned long debugctlmsr) -{ -#ifndef CONFIG_X86_DEBUGCTLMSR -if (boot_cpu_data.x86 <6 ) -return ; -#endif -wrmsr_on_cpu (cpu,MSR_IA32_DEBUGCTLMSR , - (u32)((u64 )debugctlmsr), - (u32)((u64 )debugctlmsr >>32 )); -} -/* * from system description table in BIOS. Mostly for MCA use, but * others may find it useful:
arch/x86/include/asm/ptrace-abi.h +1 -56
62 lines not on this page · raw message
arch/x86/include/asm/ptrace.h +0 -6
@@ -289,12 +289,6 @@ extern int do_get_thread_area(struct task_struct *p, int idx,extern int do_set_thread_area (struct task_struct *p,int idx,struct user_desc __user *info,int can_allocate); -#ifdef CONFIG_X86_PTRACE_BTS -extern void ptrace_bts_untrace (struct task_struct *tsk); - -#define arch_ptrace_untrace (tsk) ptrace_bts_untrace(tsk) -#endif /* CONFIG_X86_PTRACE_BTS */ -#endif /* __KERNEL__ */ #endif /* !__ASSEMBLY__ */
arch/x86/include/asm/thread_info.h +1 -5
@@ -92,8 +92,6 @@ struct thread_info {#define TIF_IO_BITMAP 22/* uses I/O bitmap */ #define TIF_FREEZE 23/* is freezing for suspend */ #define TIF_FORCED_TF 24/* true if TF in eflags artificially */ -#define TIF_DEBUGCTLMSR 25/* uses thread_struct.debugctlmsr */ -#define TIF_DS_AREA_MSR 26/* uses thread_struct.ds_area_msr */ #define TIF_LAZY_MMU_UPDATES 27/* task is updating the mmu lazily */ #define TIF_SYSCALL_TRACEPOINT 28/* syscall tracepoint instrumentation */
@@ -115,8 +113,6 @@ struct thread_info {#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)#define _TIF_FREEZE (1 << TIF_FREEZE)#define _TIF_FORCED_TF (1 << TIF_FORCED_TF) -#define _TIF_DEBUGCTLMSR (1 << TIF_DEBUGCTLMSR) -#define _TIF_DS_AREA_MSR (1 << TIF_DS_AREA_MSR)#define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
@@ -147,7 +143,7 @@ struct thread_info {/* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW \ - (_TIF_IO_BITMAP|_TIF_DEBUGCTLMSR|_TIF_DS_AREA_MSR|_TIF_NOTSC) + (_TIF_IO_BITMAP|_TIF_NOTSC)#define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY)#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
arch/x86/kernel/Makefile +0 -2
@@ -47,8 +47,6 @@ obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o obj-y += process.o obj-y += i387.o xsave.o obj-y += ptrace.o -obj-$(CONFIG_X86_DS) += ds.o -obj-$(CONFIG_X86_DS_SELFTEST) += ds_selftest.o obj-$(CONFIG_X86_32) += tls.o obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o
arch/x86/kernel/cpu/intel.c +0 -2
@@ -12,7 +12,6 @@#include <asm/processor.h> #include <asm/pgtable.h> #include <asm/msr.h> -#include <asm/ds.h> #include <asm/bugs.h> #include <asm/cpu.h>
@@ -367,7 +366,6 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)set_cpu_cap (c,X86_FEATURE_BTS );if (!(l1 & (1 <<12 )))set_cpu_cap (c,X86_FEATURE_PEBS ); -ds_init_intel (c); }if (c->x86 ==6 && c->x86_model ==29 && cpu_has_clflush)
arch/x86/kernel/ds.c deleted +0 -1437
1,437 lines not on this page · raw message
arch/x86/kernel/ds_selftest.c deleted +0 -408
408 lines not on this page · raw message
arch/x86/kernel/ds_selftest.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* -* Debug Store support - selftest -* -* -* Copyright (C) 2009 Intel Corporation. -* Markus Metzger <[email protected]>, 2009 -*/ - -#ifdef CONFIG_X86_DS_SELFTEST -extern int ds_selftest_bts (void ); -extern int ds_selftest_pebs (void ); -#else -static inline int ds_selftest_bts (void ) {return 0 ; } -static inline int ds_selftest_pebs (void ) {return 0 ; } -#endif
arch/x86/kernel/dumpstack.c +0 -5
@@ -224,11 +224,6 @@ unsigned __kprobes long oops_begin(void)int cpu;unsigned long flags; -/* notify the hw-branch tracer so it may disable tracing and -add the last trace to the trace buffer - -the earlier this happens, the more useful the trace. */ -trace_hw_branch_oops (); -oops_enter ();/* racy, but better than risking deadlock. */
arch/x86/kernel/kprobes.c +2 -4
@@ -422,14 +422,12 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,static void __kprobes clear_btf (void ) { -if (test_thread_flag (TIF_DEBUGCTLMSR )) -update_debugctlmsr (0 ); +/* XXX */ }static void __kprobes restore_btf (void ) { -if (test_thread_flag (TIF_DEBUGCTLMSR )) -update_debugctlmsr (current->thread.debugctlmsr); +/* XXX */ } void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
arch/x86/kernel/process.c +0 -9
@@ -20,7 +20,6 @@#include <asm/idle.h> #include <asm/uaccess.h> #include <asm/i387.h> -#include <asm/ds.h> #include <asm/debugreg.h> unsigned long idle_halt;
@@ -50,8 +49,6 @@ void free_thread_xstate(struct task_struct *tsk)kmem_cache_free (task_xstate_cachep, tsk->thread.xstate); tsk->thread.xstate =NULL ; } - -WARN (tsk->thread.ds_ctx,"leaking DS context\n" ); }void free_thread_info (struct thread_info *ti)
@@ -198,12 +195,6 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, prev = &prev_p->thread; next = &next_p->thread; -if (test_tsk_thread_flag (next_p,TIF_DS_AREA_MSR ) || -test_tsk_thread_flag (prev_p,TIF_DS_AREA_MSR )) -ds_switch_to (prev_p, next_p); -else if (next->debugctlmsr != prev->debugctlmsr) -update_debugctlmsr (next->debugctlmsr); -if (test_tsk_thread_flag (prev_p,TIF_NOTSC ) ^test_tsk_thread_flag (next_p,TIF_NOTSC )) {/* prev and next are different */
arch/x86/kernel/process_32.c +0 -8
@@ -55,7 +55,6 @@#include <asm/cpu.h> #include <asm/idle.h> #include <asm/syscalls.h> -#include <asm/ds.h> #include <asm/debugreg.h> asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
@@ -238,13 +237,6 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,kfree (p->thread.io_bitmap_ptr); p->thread.io_bitmap_max =0 ; } - -clear_tsk_thread_flag (p,TIF_DS_AREA_MSR ); - p->thread.ds_ctx =NULL ; - -clear_tsk_thread_flag (p,TIF_DEBUGCTLMSR ); - p->thread.debugctlmsr =0 ; -return err; }
arch/x86/kernel/process_64.c +0 -8
@@ -49,7 +49,6 @@#include <asm/ia32.h> #include <asm/idle.h> #include <asm/syscalls.h> -#include <asm/ds.h> #include <asm/debugreg.h> asmlinkage extern void ret_from_fork(void);
@@ -313,13 +312,6 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,if (err) goto out; } - -clear_tsk_thread_flag (p,TIF_DS_AREA_MSR ); - p->thread.ds_ctx =NULL ; - -clear_tsk_thread_flag (p,TIF_DEBUGCTLMSR ); - p->thread.debugctlmsr =0 ; - err =0 ; out:if (err && p->thread.io_bitmap_ptr) {
arch/x86/kernel/ptrace.c +0 -382
418 lines not on this page · raw message
arch/x86/kernel/step.c +4 -32
@@ -158,22 +158,6 @@ static int enable_single_step(struct task_struct *child) }/* -* Install this value in MSR_IA32_DEBUGCTLMSR whenever child is running. -*/ -static void write_debugctlmsr (struct task_struct *child,unsigned long val) -{ -if (child->thread.debugctlmsr == val) -return ; - - child->thread.debugctlmsr = val; - -if (child != current) -return ; - -update_debugctlmsr (val); -} - -/* * Enable single or block step. */ static void enable_step (struct task_struct *child,bool block)
@@ -185,17 +169,9 @@ static void enable_step(struct task_struct *child, bool block)* So noone should try to use debugger block stepping in a program * that uses user-mode single stepping itself. */ -if (enable_single_step (child) && block) { -set_tsk_thread_flag (child,TIF_DEBUGCTLMSR ); -write_debugctlmsr (child, - child->thread.debugctlmsr |DEBUGCTLMSR_BTF ); - }else { -write_debugctlmsr (child, - child->thread.debugctlmsr & ~DEBUGCTLMSR_BTF ); - -if (!child->thread.debugctlmsr) -clear_tsk_thread_flag (child,TIF_DEBUGCTLMSR ); - } +if (!enable_single_step (child)) +return ; +/* XXX */ }void user_enable_single_step (struct task_struct *child)
@@ -213,11 +189,7 @@ void user_disable_single_step(struct task_struct *child)/* * Make sure block stepping (BTF) is disabled. */ -write_debugctlmsr (child, - child->thread.debugctlmsr & ~DEBUGCTLMSR_BTF ); - -if (!child->thread.debugctlmsr) -clear_tsk_thread_flag (child,TIF_DEBUGCTLMSR ); +/* XXX */ /* Always clear TIF_SINGLESTEP... */ clear_tsk_thread_flag (child,TIF_SINGLESTEP );
arch/x86/kernel/traps.c +0 -5
@@ -543,11 +543,6 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)/* DR6 may or may not be cleared by the CPU */ set_debugreg (0 ,6 ); -/* -* The processor cleared BTF, so don't mark that we need it set. -*/ -clear_tsk_thread_flag (tsk,TIF_DEBUGCTLMSR ); - tsk->thread.debugctlmsr =0 ;/* Store the virtualized DR6 value */ tsk->thread.debugreg6 = dr6;
include/linux/ftrace.h +0 -12
@@ -504,18 +504,6 @@ extern int ftrace_dump_on_oops;#define INIT_TRACE_RECURSION #endif -#ifdef CONFIG_HW_BRANCH_TRACER - -void trace_hw_branch (u64 from,u64 to); -void trace_hw_branch_oops (void ); - -#else /* CONFIG_HW_BRANCH_TRACER */ - -static inline void trace_hw_branch (u64 from,u64 to) {} -static inline void trace_hw_branch_oops (void ) {} - -#endif /* CONFIG_HW_BRANCH_TRACER */ -#ifdef CONFIG_FTRACE_SYSCALLS unsigned long arch_syscall_addr (int nr);
include/linux/mm.h +0 -4
@@ -19,7 +19,6 @@ struct anon_vma;struct file_ra_state ;struct user_struct ;struct writeback_control ; -struct rlimit ;#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */ extern unsigned long max_mapnr;
@@ -1449,9 +1448,6 @@ int vmemmap_populate_basepages(struct page *start_page,int vmemmap_populate (struct page *start_page,unsigned long pages,int node);void vmemmap_populate_print_last (void ); -extern int account_locked_memory (struct mm_struct *mm,struct rlimit *rlim, -size_t size); -extern void refund_locked_memory (struct mm_struct *mm,size_t size);enum mf_flags {MF_COUNT_INCREASED =1 <<0 ,
include/linux/ptrace.h +0 -12
@@ -345,18 +345,6 @@ static inline void user_single_step_siginfo(struct task_struct *tsk,#define arch_ptrace_stop (code, info) do { } while (0)#endif -#ifndef arch_ptrace_untrace -/* -* Do machine-specific work before untracing child.
Lines of this file are not shown. View the raw message.
kernel/sched.c +0 -43
43 lines not on this page · raw message
kernel/trace/trace_hw_branches.c deleted +0 -312
312 lines not on this page · raw message
kernel/trace/trace_selftest.c +0 -57
57 lines not on this page · raw message
mm/mlock.c +0 -41
41 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 3/3 x86, ptrace: Fix block-step
In reply to Peter ZijlstraImplement ptrace-block-step using TIF_BLOCKSTEP which will set DEBUGCTLMSR_BTF when set for a task while preserving any other DEBUGCTLMSR bits.
--- arch/x86/include/asm/processor.h | 4 ++-- arch/x86/include/asm/thread_info.h | 4 +++- arch/x86/kernel/kprobes.c | 14 ++++++++++++-- arch/x86/kernel/process.c | 11 +++++++++++ arch/x86/kernel/step.c | 24 ++++++++++++++++++++---- arch/x86/kernel/traps.c | 5 +++++ 6 files changed, 53 insertions(+), 9 deletions(-)
arch/x86/include/asm/processor.h +2 -2
@@ -798,7 +798,7 @@ extern void cpu_init(void);static inline unsigned long get_debugctlmsr (void ) { -unsigned long debugctlmsr =0 ; +unsigned long debugctlmsr =0 ;#ifndef CONFIG_X86_DEBUGCTLMSR if (boot_cpu_data.x86 <6 )
@@ -806,7 +806,7 @@ static inline unsigned long get_debugctl#endif rdmsrl (MSR_IA32_DEBUGCTLMSR , debugctlmsr); -return debugctlmsr; +return debugctlmsr; }static inline void update_debugctlmsr (unsigned long debugctlmsr)
arch/x86/include/asm/thread_info.h +3 -1
@@ -92,6 +92,7 @@ struct thread_info {#define TIF_IO_BITMAP 22/* uses I/O bitmap */ #define TIF_FREEZE 23/* is freezing for suspend */ #define TIF_FORCED_TF 24/* true if TF in eflags artificially */ +#define TIF_BLOCKSTEP 25/* set when we want DEBUGCTLMSR_BTF */ #define TIF_LAZY_MMU_UPDATES 27/* task is updating the mmu lazily */ #define TIF_SYSCALL_TRACEPOINT 28/* syscall tracepoint instrumentation */
@@ -113,6 +114,7 @@ struct thread_info {#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)#define _TIF_FREEZE (1 << TIF_FREEZE)#define _TIF_FORCED_TF (1 << TIF_FORCED_TF) +#define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)#define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
@@ -143,7 +145,7 @@ struct thread_info {/* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW \ - (_TIF_IO_BITMAP|_TIF_NOTSC) + (_TIF_IO_BITMAP|_TIF_NOTSC|_TIF_BLOCKSTEP)#define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY)#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
arch/x86/kernel/kprobes.c +12 -2
@@ -422,12 +422,22 @@ static void __kprobes set_current_kprobestatic void __kprobes clear_btf (void ) { -/* XXX */ +if (test_thread_flag (TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); + } }static void __kprobes restore_btf (void ) { -/* XXX */ +if (test_thread_flag (TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl |=DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); + } } void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
arch/x86/kernel/process.c +11 -0
@@ -195,6 +195,17 @@ void __switch_to_xtra(struct task_struct prev = &prev_p->thread; next = &next_p->thread; +if (test_tsk_thread_flag (prev_p,TIF_BLOCKSTEP ) ^ +test_tsk_thread_flag (next_p,TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +if (test_tsk_thread_flag (next_p,TIF_BLOCKSTEP )) + debugctl |=DEBUGCTLMSR_BTF ; + +update_debugctlmsr (debugctl); + } +if (test_tsk_thread_flag (prev_p,TIF_NOTSC ) ^test_tsk_thread_flag (next_p,TIF_NOTSC )) {/* prev and next are different */
arch/x86/kernel/step.c +20 -4
@@ -169,9 +169,19 @@ static void enable_step(struct task_stru* So noone should try to use debugger block stepping in a program * that uses user-mode single stepping itself. */ -if (!enable_single_step (child)) -return ; -/* XXX */ +if (enable_single_step (child) && block) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl |=DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); +set_tsk_thread_flag (child,TIF_BLOCKSTEP ); + }else if (test_tsk_thread_flag (child,TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); +clear_tsk_thread_flag (child,TIF_BLOCKSTEP ); + } }void user_enable_single_step (struct task_struct *child)
@@ -189,7 +199,13 @@ void user_disable_single_step(struct tas/* * Make sure block stepping (BTF) is disabled. */ -/* XXX */ +if (test_tsk_thread_flag (child,TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); +clear_tsk_thread_flag (child,TIF_BLOCKSTEP ); + }/* Always clear TIF_SINGLESTEP... */ clear_tsk_thread_flag (child,TIF_SINGLESTEP );
arch/x86/kernel/traps.c +5 -0
@@ -551,6 +551,11 @@ dotraplinkage void __kprobes do_debug(st/* DR6 may or may not be cleared by the CPU */ set_debugreg (0 ,6 ); +/* +* The processor cleared BTF, so don't mark that we need it set. +*/ +clear_tsk_thread_flag (tsk,TIF_BLOCKSTEP ); +/* Store the virtualized DR6 value */ tsk->thread.debugreg6 = dr6;
[tip:perf/core] x86, ptrace: Fix block-step
Commit-ID: ea8e61b7bbc4a2faef77db34eb2db2a2c2372ff6 Gitweb: http://git.kernel.org/tip/ea8e61b7bbc4a2faef77db34eb2db2a2c2372ff6 Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 25 Mar 2010 14:51:51 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 26 Mar 2010 11:33:57 +0100
x86, ptrace: Fix block-step
Implement ptrace-block-step using TIF_BLOCKSTEP which will set DEBUGCTLMSR_BTF when set for a task while preserving any other DEBUGCTLMSR bits.
LKML-Reference: <[email protected]>
--- arch/x86/include/asm/processor.h | 4 ++-- arch/x86/include/asm/thread_info.h | 4 +++- arch/x86/kernel/kprobes.c | 14 ++++++++++++-- arch/x86/kernel/process.c | 11 +++++++++++ arch/x86/kernel/step.c | 24 ++++++++++++++++++++---- arch/x86/kernel/traps.c | 5 +++++ 6 files changed, 53 insertions(+), 9 deletions(-)
arch/x86/include/asm/processor.h +2 -2
@@ -799,7 +799,7 @@ extern void cpu_init(void);static inline unsigned long get_debugctlmsr (void ) { -unsigned long debugctlmsr =0 ; +unsigned long debugctlmsr =0 ;#ifndef CONFIG_X86_DEBUGCTLMSR if (boot_cpu_data.x86 <6 )
@@ -807,7 +807,7 @@ static inline unsigned long get_debugctlmsr(void)#endif rdmsrl (MSR_IA32_DEBUGCTLMSR , debugctlmsr); -return debugctlmsr; +return debugctlmsr; }static inline void update_debugctlmsr (unsigned long debugctlmsr)
arch/x86/include/asm/thread_info.h +3 -1
@@ -92,6 +92,7 @@ struct thread_info {#define TIF_IO_BITMAP 22/* uses I/O bitmap */ #define TIF_FREEZE 23/* is freezing for suspend */ #define TIF_FORCED_TF 24/* true if TF in eflags artificially */ +#define TIF_BLOCKSTEP 25/* set when we want DEBUGCTLMSR_BTF */ #define TIF_LAZY_MMU_UPDATES 27/* task is updating the mmu lazily */ #define TIF_SYSCALL_TRACEPOINT 28/* syscall tracepoint instrumentation */
@@ -113,6 +114,7 @@ struct thread_info {#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)#define _TIF_FREEZE (1 << TIF_FREEZE)#define _TIF_FORCED_TF (1 << TIF_FORCED_TF) +#define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)#define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
@@ -143,7 +145,7 @@ struct thread_info {/* flags to check in __switch_to() */ #define _TIF_WORK_CTXSW \ - (_TIF_IO_BITMAP|_TIF_NOTSC) + (_TIF_IO_BITMAP|_TIF_NOTSC|_TIF_BLOCKSTEP)#define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY)#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
arch/x86/kernel/kprobes.c +12 -2
@@ -422,12 +422,22 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,static void __kprobes clear_btf (void ) { -/* XXX */ +if (test_thread_flag (TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); + } }static void __kprobes restore_btf (void ) { -/* XXX */ +if (test_thread_flag (TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl |=DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); + } } void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
arch/x86/kernel/process.c +11 -0
@@ -195,6 +195,17 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, prev = &prev_p->thread; next = &next_p->thread; +if (test_tsk_thread_flag (prev_p,TIF_BLOCKSTEP ) ^ +test_tsk_thread_flag (next_p,TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +if (test_tsk_thread_flag (next_p,TIF_BLOCKSTEP )) + debugctl |=DEBUGCTLMSR_BTF ; + +update_debugctlmsr (debugctl); + } +if (test_tsk_thread_flag (prev_p,TIF_NOTSC ) ^test_tsk_thread_flag (next_p,TIF_NOTSC )) {/* prev and next are different */
arch/x86/kernel/step.c +20 -4
@@ -169,9 +169,19 @@ static void enable_step(struct task_struct *child, bool block)* So noone should try to use debugger block stepping in a program * that uses user-mode single stepping itself. */ -if (!enable_single_step (child)) -return ; -/* XXX */ +if (enable_single_step (child) && block) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl |=DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); +set_tsk_thread_flag (child,TIF_BLOCKSTEP ); + }else if (test_tsk_thread_flag (child,TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); +clear_tsk_thread_flag (child,TIF_BLOCKSTEP ); + } }void user_enable_single_step (struct task_struct *child)
@@ -189,7 +199,13 @@ void user_disable_single_step(struct task_struct *child)/* * Make sure block stepping (BTF) is disabled. */ -/* XXX */ +if (test_tsk_thread_flag (child,TIF_BLOCKSTEP )) { +unsigned long debugctl =get_debugctlmsr (); + + debugctl &= ~DEBUGCTLMSR_BTF ; +update_debugctlmsr (debugctl); +clear_tsk_thread_flag (child,TIF_BLOCKSTEP ); + }/* Always clear TIF_SINGLESTEP... */ clear_tsk_thread_flag (child,TIF_SINGLESTEP );
arch/x86/kernel/traps.c +5 -0
@@ -544,6 +544,11 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)/* DR6 may or may not be cleared by the CPU */ set_debugreg (0 ,6 ); +/* +* The processor cleared BTF, so don't mark that we need it set. +*/ +clear_tsk_thread_flag (tsk,TIF_BLOCKSTEP ); +/* Store the virtualized DR6 value */ tsk->thread.debugreg6 = dr6;