Commit 150f5164 authored by Markus Metzger's avatar Markus Metzger Committed by Ingo Molnar

x86, ds: allow small debug store buffers

Check the buffer size more precisely to allow buffers for exactly
one element provided the base address is already properly aligned.

Add a debug store selftest.
Reported-by: default avatarStephane Eranian <eranian@googlemail.com>
Signed-off-by: default avatarMarkus Metzger <markus.t.metzger@intel.com>
Cc: roland@redhat.com
Cc: eranian@googlemail.com
Cc: oleg@redhat.com
Cc: juan.villacis@intel.com
Cc: ak@linux.jf.intel.com
LKML-Reference: <20090403144606.139137000@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 608780a9
...@@ -656,6 +656,7 @@ static int ds_request(struct ds_tracer *tracer, struct ds_trace *trace, ...@@ -656,6 +656,7 @@ static int ds_request(struct ds_tracer *tracer, struct ds_trace *trace,
{ {
struct ds_context *context; struct ds_context *context;
int error; int error;
size_t req_size;
error = -EOPNOTSUPP; error = -EOPNOTSUPP;
if (!ds_cfg.sizeof_rec[qual]) if (!ds_cfg.sizeof_rec[qual])
...@@ -665,9 +666,13 @@ static int ds_request(struct ds_tracer *tracer, struct ds_trace *trace, ...@@ -665,9 +666,13 @@ static int ds_request(struct ds_tracer *tracer, struct ds_trace *trace,
if (!base) if (!base)
goto out; goto out;
/* We need space for alignment adjustments in ds_init_ds_trace(). */ req_size = ds_cfg.sizeof_rec[qual];
/* We might need space for alignment adjustments. */
if (!IS_ALIGNED((unsigned long)base, DS_ALIGNMENT))
req_size += DS_ALIGNMENT;
error = -EINVAL; error = -EINVAL;
if (size < (DS_ALIGNMENT + ds_cfg.sizeof_rec[qual])) if (size < req_size)
goto out; goto out;
if (th != (size_t)-1) { if (th != (size_t)-1) {
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <asm/ds.h> #include <asm/ds.h>
#define BUFFER_SIZE 521 /* Intentionally chose an odd size. */ #define BUFFER_SIZE 521 /* Intentionally chose an odd size. */
#define SMALL_BUFFER_SIZE 24 /* A single bts entry. */
struct ds_selftest_bts_conf { struct ds_selftest_bts_conf {
struct bts_tracer *tracer; struct bts_tracer *tracer;
...@@ -381,7 +381,7 @@ int ds_selftest_bts(void) ...@@ -381,7 +381,7 @@ int ds_selftest_bts(void)
conf.suspend = ds_suspend_bts_noirq; conf.suspend = ds_suspend_bts_noirq;
conf.resume = ds_resume_bts_noirq; conf.resume = ds_resume_bts_noirq;
conf.tracer = conf.tracer =
ds_request_bts_task(current, buffer, BUFFER_SIZE, ds_request_bts_task(current, buffer, SMALL_BUFFER_SIZE,
NULL, (size_t)-1, BTS_KERNEL); NULL, (size_t)-1, BTS_KERNEL);
local_irq_save(irq); local_irq_save(irq);
ds_selftest_bts_cpu(&conf); ds_selftest_bts_cpu(&conf);
......
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