From 5e2409f69fd5bd618d2c90a064f8922f0669c6a2 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 29 Nov 2021 11:03:25 +0100 Subject: [PATCH] Ensure only one thread is running per CPU --- emu_nosv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/emu_nosv.c b/emu_nosv.c index 096ebc9..78e6af0 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -458,6 +458,26 @@ pre_ss(struct ovni_emu *emu, int st) } } +static void +check_affinity(struct ovni_emu *emu) +{ + struct ovni_ethread *th = emu->cur_thread; + struct ovni_cpu *cpu = th->cpu; + + if(!cpu || cpu->virtual) + return; + + if(th->state != TH_ST_RUNNING) + return; + + if(cpu->nrunning_threads > 1) + { + err("cpu %s has more than one thread running\n", + cpu->name); + abort(); + } +} + void hook_pre_nosv(struct ovni_emu *emu) { @@ -478,4 +498,7 @@ hook_pre_nosv(struct ovni_emu *emu) default: break; } + + if(emu->enable_linter) + check_affinity(emu); }