struct ds_context **p_context =
(task ? &task->thread.ds_ctx : &this_system_context);
struct ds_context *context = *p_context;
+ + unsigned long irq;
if (!context) {
- spin_unlock(&ds_lock);
-
context = kzalloc(sizeof(*context), GFP_KERNEL);
- -
- if (!context) {
- spin_lock(&ds_lock);
+ if (!context)
return NULL;
- }
context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL);
if (!context->ds) {
return NULL;
}
- spin_lock(&ds_lock);
- /*
- * Check for race - another CPU could have allocated
- * it meanwhile:
- */
- *p_context = context;
+ + spin_lock_irqsave(&ds_lock, irq);
+
- context->this = p_context;
- context->task = task;
+ if (*p_context) {
+ kfree(context->ds);
+ kfree(context);
- return *p_context;
- }
+
- *p_context = context;
+ + context = *p_context;
+ + } else {
+ + *p_context = context;
- context->this = p_context;
- context->task = task;
- if (task)
- set_tsk_thread_flag(task, TIF_DS_AREA_MSR);
+ + context->this = p_context;
+ + context->task = task;
- if (task)
- set_tsk_thread_flag(task, TIF_DS_AREA_MSR);
- if (!task || (task == current))
- wrmsr(MSR_IA32_DS_AREA, (unsigned long)context->ds, 0);
+ + if (task)
+ + set_tsk_thread_flag(task, TIF_DS_AREA_MSR);
- if (!task || (task == current))
- wrmsr(MSR_IA32_DS_AREA, (unsigned long)context->ds, 0);
-
- - get_tracer(task);
+ + if (!task || (task == current))
+ + wrmsrl(MSR_IA32_DS_AREA,
+ + (unsigned long)context->ds);
+ + }
+ + spin_unlock_irqrestore(&ds_lock, irq);
}
context->count++;
return -EOPNOTSUPP;
- - spin_lock(&ds_lock);
-
- if (!check_tracer(task))
- return -EPERM;
- -
- - error = -ENOMEM;
context = ds_alloc_context(task);
if (!context)
- goto out_unlock;
+ + return -ENOMEM;
+ +
+ + spin_lock_irqsave(&ds_lock, irq);
+
+ error = -EPERM;
+ if (!check_tracer(task))
goto out_unlock;
+ + get_tracer(task);
+ +
error = -EALREADY;
if (context->owner[qual] == current)
- - goto out_unlock;
+ + goto out_put_tracer;
error = -EPERM;
if (context->owner[qual] != NULL)
- - goto out_unlock;
+ + goto out_put_tracer;
context->owner[qual] = current;
- - spin_unlock(&ds_lock);
+ + spin_unlock_irqrestore(&ds_lock, irq);
error = -ENOMEM;