Avoid a race as described in the code comment.
Also remove a related smp_wmb() from booke's kvmppc_prepare_to_enter().
I can't see any reason for it, and the book3s_pr version doesn't have it.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
out:
vcpu->mode = OUTSIDE_GUEST_MODE;
- smp_wmb();
return ret;
}
break;
}
+ vcpu->mode = IN_GUEST_MODE;
+
+ /*
+ * Reading vcpu->requests must happen after setting vcpu->mode,
+ * so we don't miss a request because the requester sees
+ * OUTSIDE_GUEST_MODE and assumes we'll be checking requests
+ * before next entering the guest (and thus doesn't IPI).
+ */
smp_mb();
+
if (vcpu->requests) {
/* Make sure we process requests preemptable */
local_irq_enable();
#endif
kvm_guest_enter();
-
- /* Going into guest context! Yay! */
- vcpu->mode = IN_GUEST_MODE;
- smp_wmb();
-
break;
}