aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/ptrace.c
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2008-11-25 03:05:27 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-25 11:31:12 -0500
commit6abb11aecd888d1da6276399380b7355f127c006 (patch)
treeef64f865780fa85f4ef102e6de4dd0a589302d32 /arch/x86/kernel/ptrace.c
parentca0002a179bfa532d009a9272d619732872c49bd (diff)
x86, bts, ptrace: move BTS buffer allocation from ds.c into ptrace.c
Impact: restructure DS memory allocation to be done by the usage site of DS Require pre-allocated buffers in ds.h. Move the BTS buffer allocation for ptrace into ptrace.c. The pointer to the allocated buffer is stored in the traced task's task_struct together with the handle returned by ds_request_bts(). Removes memory accounting code. Signed-off-by: Markus Metzger <markus.t.metzger@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/ptrace.c')
-rw-r--r--arch/x86/kernel/ptrace.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 76adf5b640ff..2c8ec1ba75e6 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -758,6 +758,10 @@ static int ptrace_bts_config(struct task_struct *child,
758 bts_ovfl_callback_t ovfl = NULL; 758 bts_ovfl_callback_t ovfl = NULL;
759 unsigned int sig = 0; 759 unsigned int sig = 0;
760 760
761 error = -EINVAL;
762 if (cfg.size < (10 * bts_cfg.sizeof_bts))
763 goto errout;
764
761 if (cfg.flags & PTRACE_BTS_O_SIGNAL) { 765 if (cfg.flags & PTRACE_BTS_O_SIGNAL) {
762 if (!cfg.signal) 766 if (!cfg.signal)
763 goto errout; 767 goto errout;
@@ -768,14 +772,26 @@ static int ptrace_bts_config(struct task_struct *child,
768 sig = cfg.signal; 772 sig = cfg.signal;
769 } 773 }
770 774
771 if (child->bts) 775 if (child->bts) {
772 (void)ds_release_bts(child->bts); 776 (void)ds_release_bts(child->bts);
777 kfree(child->bts_buffer);
778
779 child->bts = NULL;
780 child->bts_buffer = NULL;
781 }
782
783 error = -ENOMEM;
784 child->bts_buffer = kzalloc(cfg.size, GFP_KERNEL);
785 if (!child->bts_buffer)
786 goto errout;
773 787
774 child->bts = ds_request_bts(child, /* base = */ NULL, cfg.size, 788 child->bts = ds_request_bts(child, child->bts_buffer, cfg.size,
775 ovfl, /* th = */ (size_t)-1); 789 ovfl, /* th = */ (size_t)-1);
776 if (IS_ERR(child->bts)) { 790 if (IS_ERR(child->bts)) {
777 error = PTR_ERR(child->bts); 791 error = PTR_ERR(child->bts);
792 kfree(child->bts_buffer);
778 child->bts = NULL; 793 child->bts = NULL;
794 child->bts_buffer = NULL;
779 goto errout; 795 goto errout;
780 } 796 }
781 797
@@ -972,6 +988,8 @@ void ptrace_disable(struct task_struct *child)
972#ifdef CONFIG_X86_PTRACE_BTS 988#ifdef CONFIG_X86_PTRACE_BTS
973 if (child->bts) { 989 if (child->bts) {
974 (void)ds_release_bts(child->bts); 990 (void)ds_release_bts(child->bts);
991 kfree(child->bts_buffer);
992 child->bts_buffer = NULL;
975 993
976 child->thread.debugctlmsr &= ~bts_cfg.debugctl_mask; 994 child->thread.debugctlmsr &= ~bts_cfg.debugctl_mask;
977 if (!child->thread.debugctlmsr) 995 if (!child->thread.debugctlmsr)