diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2008-01-30 07:31:20 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:31:20 -0500 |
commit | e4811f2568c55e595a7bf15a3b9aba863b31fb94 (patch) | |
tree | 3ec3065b06cb5e083ff39b56d242b27e897a4b80 /arch/x86/kernel/ptrace.c | |
parent | 3c68904fee1459b6d51040864e15d19098eedef7 (diff) |
x86, ptrace: change BTS GET ptrace interface
Change the ptrace interface to mimick an array from newst to oldest.
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/ptrace.c')
-rw-r--r-- | arch/x86/kernel/ptrace.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index ec86abaab530..3e78c124e2d2 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -479,26 +479,33 @@ static int ptrace_bts_get_buffer_size(struct task_struct *child) | |||
479 | return ds_get_bts_size((void *)child->thread.ds_area_msr); | 479 | return ds_get_bts_size((void *)child->thread.ds_area_msr); |
480 | } | 480 | } |
481 | 481 | ||
482 | static int ptrace_bts_get_index(struct task_struct *child) | ||
483 | { | ||
484 | if (!child->thread.ds_area_msr) | ||
485 | return -ENXIO; | ||
486 | |||
487 | return ds_get_bts_index((void *)child->thread.ds_area_msr); | ||
488 | } | ||
489 | |||
490 | static int ptrace_bts_read_record(struct task_struct *child, | 482 | static int ptrace_bts_read_record(struct task_struct *child, |
491 | long index, | 483 | long index, |
492 | struct bts_struct __user *out) | 484 | struct bts_struct __user *out) |
493 | { | 485 | { |
494 | struct bts_struct ret; | 486 | struct bts_struct ret; |
495 | int retval; | 487 | int retval; |
488 | int bts_size; | ||
489 | int bts_index; | ||
496 | 490 | ||
497 | if (!child->thread.ds_area_msr) | 491 | if (!child->thread.ds_area_msr) |
498 | return -ENXIO; | 492 | return -ENXIO; |
499 | 493 | ||
494 | if (index < 0) | ||
495 | return -EINVAL; | ||
496 | |||
497 | bts_size = ds_get_bts_size((void *)child->thread.ds_area_msr); | ||
498 | if (bts_size <= index) | ||
499 | return -EINVAL; | ||
500 | |||
501 | /* translate the ptrace bts index into the ds bts index */ | ||
502 | bts_index = ds_get_bts_index((void *)child->thread.ds_area_msr); | ||
503 | bts_index -= (index + 1); | ||
504 | if (bts_index < 0) | ||
505 | bts_index += bts_size; | ||
506 | |||
500 | retval = ds_read_bts((void *)child->thread.ds_area_msr, | 507 | retval = ds_read_bts((void *)child->thread.ds_area_msr, |
501 | index, &ret); | 508 | bts_index, &ret); |
502 | if (retval) | 509 | if (retval) |
503 | return retval; | 510 | return retval; |
504 | 511 | ||
@@ -813,10 +820,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
813 | ret = ptrace_bts_get_buffer_size(child); | 820 | ret = ptrace_bts_get_buffer_size(child); |
814 | break; | 821 | break; |
815 | 822 | ||
816 | case PTRACE_BTS_GET_INDEX: | ||
817 | ret = ptrace_bts_get_index(child); | ||
818 | break; | ||
819 | |||
820 | case PTRACE_BTS_READ_RECORD: | 823 | case PTRACE_BTS_READ_RECORD: |
821 | ret = ptrace_bts_read_record | 824 | ret = ptrace_bts_read_record |
822 | (child, data, | 825 | (child, data, |
@@ -1017,7 +1020,6 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) | |||
1017 | case PTRACE_BTS_MAX_BUFFER_SIZE: | 1020 | case PTRACE_BTS_MAX_BUFFER_SIZE: |
1018 | case PTRACE_BTS_ALLOCATE_BUFFER: | 1021 | case PTRACE_BTS_ALLOCATE_BUFFER: |
1019 | case PTRACE_BTS_GET_BUFFER_SIZE: | 1022 | case PTRACE_BTS_GET_BUFFER_SIZE: |
1020 | case PTRACE_BTS_GET_INDEX: | ||
1021 | case PTRACE_BTS_READ_RECORD: | 1023 | case PTRACE_BTS_READ_RECORD: |
1022 | case PTRACE_BTS_CONFIG: | 1024 | case PTRACE_BTS_CONFIG: |
1023 | case PTRACE_BTS_STATUS: | 1025 | case PTRACE_BTS_STATUS: |