-/* $OpenBSD: vmm.c,v 1.280 2021/04/06 00:19:58 dv Exp $ */
+/* $OpenBSD: vmm.c,v 1.281 2021/05/11 22:04:10 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
int
vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
{
- int ret = 0, resume;
+ int ret = 0;
struct region_descriptor gdt;
- struct cpu_info *ci;
+ struct cpu_info *ci = NULL;
uint64_t exit_reason;
struct schedstate_percpu *spc;
uint16_t irq;
struct vmcb *vmcb = (struct vmcb *)vcpu->vc_control_va;
- resume = 0;
irq = vrp->vrp_irq;
/*
while (ret == 0) {
vmm_update_pvclock(vcpu);
- if (!resume) {
+ if (ci != curcpu()) {
/*
* We are launching for the first time, or we are
* resuming from a different pcpu, so we need to
/* If we exited successfully ... */
if (ret == 0) {
- resume = 1;
-
vcpu->vc_gueststate.vg_rflags = vmcb->v_rflags;
/*
/* Check if we should yield - don't hog the cpu */
spc = &ci->ci_schedstate;
if (spc->spc_schedflags & SPCF_SHOULDYIELD) {
- resume = 0;
yield();
}
}