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 | |
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>
-rw-r--r-- | arch/x86/kernel/ptrace.c | 30 | ||||
-rw-r--r-- | include/asm-x86/ptrace-abi.h | 17 |
2 files changed, 22 insertions, 25 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: |
diff --git a/include/asm-x86/ptrace-abi.h b/include/asm-x86/ptrace-abi.h index 6fadc5214e14..b473ad45e9ca 100644 --- a/include/asm-x86/ptrace-abi.h +++ b/include/asm-x86/ptrace-abi.h | |||
@@ -99,32 +99,27 @@ | |||
99 | ENXIO........no buffer allocated */ | 99 | ENXIO........no buffer allocated */ |
100 | #define PTRACE_BTS_GET_BUFFER_SIZE 42 | 100 | #define PTRACE_BTS_GET_BUFFER_SIZE 42 |
101 | 101 | ||
102 | /* Return the index of the next bts record to be written, | 102 | /* Read the DATA'th bts record into a ptrace_bts_record buffer |
103 | if successful; -1, otherwise. | 103 | provided in ADDR. |
104 | EOPNOTSUPP...processor does not support bts tracing | 104 | Records are ordered from newest to oldest. |
105 | ENXIO........no buffer allocated | ||
106 | After the first warp-around, this is the start of the circular bts buffer. */ | ||
107 | #define PTRACE_BTS_GET_INDEX 43 | ||
108 | |||
109 | /* Read the DATA'th bts record into a ptrace_bts_record buffer provided in ADDR. | ||
110 | Return 0, if successful; -1, otherwise | 105 | Return 0, if successful; -1, otherwise |
111 | EOPNOTSUPP...processor does not support bts tracing | 106 | EOPNOTSUPP...processor does not support bts tracing |
112 | ENXIO........no buffer allocated | 107 | ENXIO........no buffer allocated |
113 | EINVAL.......invalid index */ | 108 | EINVAL.......invalid index */ |
114 | #define PTRACE_BTS_READ_RECORD 44 | 109 | #define PTRACE_BTS_READ_RECORD 43 |
115 | 110 | ||
116 | /* Configure last branch trace; the configuration is given as a bit-mask of | 111 | /* Configure last branch trace; the configuration is given as a bit-mask of |
117 | PTRACE_BTS_O_* options in DATA; parameter ADDR is ignored. | 112 | PTRACE_BTS_O_* options in DATA; parameter ADDR is ignored. |
118 | Return 0, if successful; -1, otherwise | 113 | Return 0, if successful; -1, otherwise |
119 | EOPNOTSUPP...processor does not support bts tracing | 114 | EOPNOTSUPP...processor does not support bts tracing |
120 | ENXIO........no buffer allocated */ | 115 | ENXIO........no buffer allocated */ |
121 | #define PTRACE_BTS_CONFIG 45 | 116 | #define PTRACE_BTS_CONFIG 44 |
122 | 117 | ||
123 | /* Return the configuration as bit-mask of PTRACE_BTS_O_* options | 118 | /* Return the configuration as bit-mask of PTRACE_BTS_O_* options |
124 | if successful; -1, otherwise. | 119 | if successful; -1, otherwise. |
125 | EOPNOTSUPP...processor does not support bts tracing | 120 | EOPNOTSUPP...processor does not support bts tracing |
126 | ENXIO........no buffer allocated */ | 121 | ENXIO........no buffer allocated */ |
127 | #define PTRACE_BTS_STATUS 46 | 122 | #define PTRACE_BTS_STATUS 45 |
128 | 123 | ||
129 | /* Trace configuration options */ | 124 | /* Trace configuration options */ |
130 | /* Collect last branch trace */ | 125 | /* Collect last branch trace */ |