summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-09-05 22:04:21 +0200
committerRichard Braun <rbraun@sceen.net>2017-09-05 22:04:21 +0200
commit8b1b21a33dbe4b114400090ff385c4bf8daea0c8 (patch)
tree3aa9f196f4e3ad4c59507a7f9b884d9bf078c7e9
parent1d6ea814d13a05fd4d64e0764acf667f67679092 (diff)
kern/xcall: make sure functions are always run from interrupt context
-rw-r--r--kern/xcall.c12
-rw-r--r--kern/xcall.h3
-rw-r--r--test/test_xcall.c2
3 files changed, 5 insertions, 12 deletions
diff --git a/kern/xcall.c b/kern/xcall.c
index b5ed4b24..9cef07a7 100644
--- a/kern/xcall.c
+++ b/kern/xcall.c
@@ -127,22 +127,13 @@ xcall_call(xcall_fn_t fn, void *arg, unsigned int cpu)
struct xcall_cpu_data *local_data, *remote_data;
struct xcall *call;
+ assert(cpu_intr_enabled());
assert(fn != NULL);
remote_data = percpu_ptr(xcall_cpu_data, cpu);
thread_preempt_disable();
- /* TODO Fix to match interrupt context semantics */
- if (cpu == cpu_id()) {
- unsigned long flags;
-
- cpu_intr_save(&flags);
- fn(arg);
- cpu_intr_restore(flags);
- goto out;
- }
-
local_data = xcall_cpu_data_get();
call = xcall_cpu_data_get_send_call(local_data, cpu);
xcall_set(call, fn, arg);
@@ -159,7 +150,6 @@ xcall_call(xcall_fn_t fn, void *arg, unsigned int cpu)
spinlock_unlock(&remote_data->lock);
-out:
thread_preempt_enable();
}
diff --git a/kern/xcall.h b/kern/xcall.h
index 27b6af25..df364870 100644
--- a/kern/xcall.h
+++ b/kern/xcall.h
@@ -36,7 +36,8 @@ typedef void (*xcall_fn_t)(void *arg);
* has finished running on the target processor, with the side effects of
* the function visible.
*
- * The function is run in interrupt context.
+ * The function is run in interrupt context. Interrupts must be enabled
+ * when calling this function.
*/
void xcall_call(xcall_fn_t fn, void *arg, unsigned int cpu);
diff --git a/test/test_xcall.c b/test/test_xcall.c
index 4e02d6f3..f516401e 100644
--- a/test/test_xcall.c
+++ b/test/test_xcall.c
@@ -37,6 +37,8 @@ test_fn(void *arg)
{
(void)arg;
+ assert(thread_interrupted());
+
printf("function called, running on cpu%u\n", cpu_id());
test_done = 1;
}