# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1195910960 0
# Node ID ee519207734fcd9874647268f756a6c503963782
# Parent 7eea09b188395a8e2d893bae4d5dab9b29f3ad71
[Mini-OS] Make sure schedule() is called safely
If a thread tries to sleep from a callback or with callbacks disabled,
Mini-OS will completely lock, so make sure this never happens.
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxx>
---
extras/mini-os/hypervisor.c | 5 +++++
extras/mini-os/include/hypervisor.h | 2 ++
extras/mini-os/sched.c | 8 ++++++++
3 files changed, 15 insertions(+)
diff -r 7eea09b18839 -r ee519207734f extras/mini-os/hypervisor.c
--- a/extras/mini-os/hypervisor.c Sat Nov 24 13:28:54 2007 +0000
+++ b/extras/mini-os/hypervisor.c Sat Nov 24 13:29:20 2007 +0000
@@ -33,6 +33,8 @@
((sh)->evtchn_pending[idx] & \
~(sh)->evtchn_mask[idx])
+int in_callback;
+
void do_hypervisor_callback(struct pt_regs *regs)
{
unsigned long l1, l2, l1i, l2i;
@@ -41,6 +43,7 @@ void do_hypervisor_callback(struct pt_re
shared_info_t *s = HYPERVISOR_shared_info;
vcpu_info_t *vcpu_info = &s->vcpu_info[cpu];
+ in_callback = 1;
vcpu_info->evtchn_upcall_pending = 0;
/* NB. No need for a barrier here -- XCHG is a barrier on x86. */
@@ -59,6 +62,8 @@ void do_hypervisor_callback(struct pt_re
do_event(port, regs);
}
}
+
+ in_callback = 0;
}
diff -r 7eea09b18839 -r ee519207734f extras/mini-os/include/hypervisor.h
--- a/extras/mini-os/include/hypervisor.h Sat Nov 24 13:28:54 2007 +0000
+++ b/extras/mini-os/include/hypervisor.h Sat Nov 24 13:29:20 2007 +0000
@@ -42,4 +42,6 @@ void unmask_evtchn(u32 port);
void unmask_evtchn(u32 port);
void clear_evtchn(u32 port);
+extern int in_callback;
+
#endif /* __HYPERVISOR_H__ */
diff -r 7eea09b18839 -r ee519207734f extras/mini-os/sched.c
--- a/extras/mini-os/sched.c Sat Nov 24 13:28:54 2007 +0000
+++ b/extras/mini-os/sched.c Sat Nov 24 13:29:20 2007 +0000
@@ -125,6 +125,14 @@ void schedule(void)
unsigned long flags;
prev = current;
local_irq_save(flags);
+ if (in_callback) {
+ printk("Must not call schedule() from a callback\n");
+ BUG();
+ }
+ if (flags) {
+ printk("Must not call schedule() with IRQs disabled\n");
+ BUG();
+ }
list_for_each(iterator, &exited_threads)
{
thread = list_entry(iterator, struct thread, thread_list);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|