Commit e4811f25 authored by Markus Metzger's avatar Markus Metzger Committed by Ingo Molnar
Browse files

x86, ptrace: change BTS GET ptrace interface



Change the ptrace interface to mimick an array from newst to oldest.
Signed-off-by: default avatarMarkus Metzger <markus.t.metzger@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 3c68904f
...@@ -479,26 +479,33 @@ static int ptrace_bts_get_buffer_size(struct task_struct *child) ...@@ -479,26 +479,33 @@ static int ptrace_bts_get_buffer_size(struct task_struct *child)
return ds_get_bts_size((void *)child->thread.ds_area_msr); return ds_get_bts_size((void *)child->thread.ds_area_msr);
} }
static int ptrace_bts_get_index(struct task_struct *child)
{
if (!child->thread.ds_area_msr)
return -ENXIO;
return ds_get_bts_index((void *)child->thread.ds_area_msr);
}
static int ptrace_bts_read_record(struct task_struct *child, static int ptrace_bts_read_record(struct task_struct *child,
long index, long index,
struct bts_struct __user *out) struct bts_struct __user *out)
{ {
struct bts_struct ret; struct bts_struct ret;
int retval; int retval;
int bts_size;
int bts_index;
if (!child->thread.ds_area_msr) if (!child->thread.ds_area_msr)
return -ENXIO; return -ENXIO;
if (index < 0)
return -EINVAL;
bts_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
if (bts_size <= index)
return -EINVAL;
/* translate the ptrace bts index into the ds bts index */
bts_index = ds_get_bts_index((void *)child->thread.ds_area_msr);
bts_index -= (index + 1);
if (bts_index < 0)
bts_index += bts_size;
retval = ds_read_bts((void *)child->thread.ds_area_msr, retval = ds_read_bts((void *)child->thread.ds_area_msr,
index, &ret); bts_index, &ret);
if (retval) if (retval)
return retval; return retval;
...@@ -813,10 +820,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -813,10 +820,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
ret = ptrace_bts_get_buffer_size(child); ret = ptrace_bts_get_buffer_size(child);
break; break;
case PTRACE_BTS_GET_INDEX:
ret = ptrace_bts_get_index(child);
break;
case PTRACE_BTS_READ_RECORD: case PTRACE_BTS_READ_RECORD:
ret = ptrace_bts_read_record ret = ptrace_bts_read_record
(child, data, (child, data,
...@@ -1017,7 +1020,6 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) ...@@ -1017,7 +1020,6 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_BTS_MAX_BUFFER_SIZE: case PTRACE_BTS_MAX_BUFFER_SIZE:
case PTRACE_BTS_ALLOCATE_BUFFER: case PTRACE_BTS_ALLOCATE_BUFFER:
case PTRACE_BTS_GET_BUFFER_SIZE: case PTRACE_BTS_GET_BUFFER_SIZE:
case PTRACE_BTS_GET_INDEX:
case PTRACE_BTS_READ_RECORD: case PTRACE_BTS_READ_RECORD:
case PTRACE_BTS_CONFIG: case PTRACE_BTS_CONFIG:
case PTRACE_BTS_STATUS: case PTRACE_BTS_STATUS:
......
...@@ -99,32 +99,27 @@ ...@@ -99,32 +99,27 @@
ENXIO........no buffer allocated */ ENXIO........no buffer allocated */
#define PTRACE_BTS_GET_BUFFER_SIZE 42 #define PTRACE_BTS_GET_BUFFER_SIZE 42
/* Return the index of the next bts record to be written, /* Read the DATA'th bts record into a ptrace_bts_record buffer
if successful; -1, otherwise. provided in ADDR.
EOPNOTSUPP...processor does not support bts tracing Records are ordered from newest to oldest.
ENXIO........no buffer allocated
After the first warp-around, this is the start of the circular bts buffer. */
#define PTRACE_BTS_GET_INDEX 43
/* Read the DATA'th bts record into a ptrace_bts_record buffer provided in ADDR.
Return 0, if successful; -1, otherwise Return 0, if successful; -1, otherwise
EOPNOTSUPP...processor does not support bts tracing EOPNOTSUPP...processor does not support bts tracing
ENXIO........no buffer allocated ENXIO........no buffer allocated
EINVAL.......invalid index */ EINVAL.......invalid index */
#define PTRACE_BTS_READ_RECORD 44 #define PTRACE_BTS_READ_RECORD 43
/* Configure last branch trace; the configuration is given as a bit-mask of /* Configure last branch trace; the configuration is given as a bit-mask of
PTRACE_BTS_O_* options in DATA; parameter ADDR is ignored. PTRACE_BTS_O_* options in DATA; parameter ADDR is ignored.
Return 0, if successful; -1, otherwise Return 0, if successful; -1, otherwise
EOPNOTSUPP...processor does not support bts tracing EOPNOTSUPP...processor does not support bts tracing
ENXIO........no buffer allocated */ ENXIO........no buffer allocated */
#define PTRACE_BTS_CONFIG 45 #define PTRACE_BTS_CONFIG 44
/* Return the configuration as bit-mask of PTRACE_BTS_O_* options /* Return the configuration as bit-mask of PTRACE_BTS_O_* options
if successful; -1, otherwise. if successful; -1, otherwise.
EOPNOTSUPP...processor does not support bts tracing EOPNOTSUPP...processor does not support bts tracing
ENXIO........no buffer allocated */ ENXIO........no buffer allocated */
#define PTRACE_BTS_STATUS 46 #define PTRACE_BTS_STATUS 45
/* Trace configuration options */ /* Trace configuration options */
/* Collect last branch trace */ /* Collect last branch trace */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment