Use a lock when printing trap info
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 27 Apr 2016 16:35:14 +0000 (12:35 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 May 2016 21:11:15 +0000 (17:11 -0400)
In case of errors in parallel.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/trap.c

index f36ce77..02abbe1 100644 (file)
@@ -20,7 +20,9 @@ static void print_unhandled_trap(struct proc *p, struct user_context *ctx,
        struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
        uint32_t vcoreid = pcpui->owning_vcoreid;
        struct preempt_data *vcpd = &p->procdata->vcore_preempt_data[vcoreid];
+       static spinlock_t print_trap_lock = SPINLOCK_INITIALIZER;
 
+       spin_lock(&print_trap_lock);
        if (!proc_is_vcctx_ready(p))
                printk("Unhandled user trap from early SCP\n");
        else if (vcpd->notif_disabled)
@@ -30,6 +32,7 @@ static void print_unhandled_trap(struct proc *p, struct user_context *ctx,
        debug_addr_proc(p, get_user_ctx_pc(ctx));
        print_vmrs(p);
        backtrace_user_ctx(p, ctx);
+       spin_unlock(&print_trap_lock);
 }
 
 /* Traps that are considered normal operations. */