summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@joyent.com>2018-03-29 20:18:19 +0000
committerJohn Levon <john.levon@joyent.com>2018-03-29 20:22:30 +0000
commit966ea1794ae987e496f16d40f7b45be7e16445cf (patch)
tree1c5110a888d1fa30a03ae17cb44b68fb8369b21b
parent2949a1032201150f88cbdd0caa1c59564b68345c (diff)
downloadillumos-joyent-966ea1794ae987e496f16d40f7b45be7e16445cf.tar.gz
OS-6848 vm_localize_resources() CPU check is wrong
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Approved by: Patrick Mooney <patrick.mooney@joyent.com>
-rw-r--r--usr/src/uts/i86pc/io/vmm/vmm.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr/src/uts/i86pc/io/vmm/vmm.c b/usr/src/uts/i86pc/io/vmm/vmm.c
index 2e5198310c..24b8a9433b 100644
--- a/usr/src/uts/i86pc/io/vmm/vmm.c
+++ b/usr/src/uts/i86pc/io/vmm/vmm.c
@@ -111,7 +111,10 @@ struct vcpu {
kcondvar_t vcpu_cv; /* (o) cpu waiter cv */
kcondvar_t state_cv; /* (o) IDLE-transition cv */
#endif /* __FreeBSD__ */
- int hostcpu; /* (o) vcpu's host cpu */
+ int hostcpu; /* (o) vcpu's current host cpu */
+#ifndef __FreeBSD__
+ int lasthostcpu; /* (o) vcpu's last host cpu */
+#endif
int reqidle; /* (i) request vcpu to idle */
struct vlapic *vlapic; /* (i) APIC device model */
enum x2apic_state x2apic_state; /* (i) APIC mode */
@@ -314,6 +317,9 @@ vcpu_init(struct vm *vm, int vcpu_id, bool create)
vcpu_lock_init(vcpu);
vcpu->state = VCPU_IDLE;
vcpu->hostcpu = NOCPU;
+#ifndef __FreeBSD__
+ vcpu->lasthostcpu = NOCPU;
+#endif
vcpu->guestfpu = fpu_save_area_alloc();
vcpu->stats = vmm_stat_alloc();
}
@@ -1269,6 +1275,11 @@ vcpu_set_state_locked(struct vm *vm, int vcpuid, enum vcpu_state newstate,
VCPU_CTR2(vm, vcpuid, "vcpu state changed from %s to %s",
vcpu_state2str(vcpu->state), vcpu_state2str(newstate));
+#ifndef __FreeBSD__
+ if (vcpu->state == VCPU_RUNNING)
+ vcpu->lasthostcpu = curcpu;
+#endif
+
vcpu->state = newstate;
if (newstate == VCPU_RUNNING)
vcpu->hostcpu = curcpu;
@@ -1745,7 +1756,7 @@ vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip)
static void
vm_localize_resources(struct vm *vm, struct vcpu *vcpu)
{
- if (vcpu->hostcpu == curcpu)
+ if (vcpu->lasthostcpu == curcpu)
return;
/*