vmm.c (263035) | vmm.c (263211) |
---|---|
1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/amd64/vmm/vmm.c 263035 2014-03-11 16:56:00Z tychon $ | 26 * $FreeBSD: head/sys/amd64/vmm/vmm.c 263211 2014-03-15 23:09:34Z tychon $ |
27 */ 28 29#include <sys/cdefs.h> | 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm.c 263035 2014-03-11 16:56:00Z tychon $"); | 30__FBSDID("$FreeBSD: head/sys/amd64/vmm/vmm.c 263211 2014-03-15 23:09:34Z tychon $"); |
31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/module.h> 36#include <sys/sysctl.h> 37#include <sys/malloc.h> 38#include <sys/pcpu.h> --- 51 unchanged lines hidden (view full) --- 90 struct vlapic *vlapic; 91 int vcpuid; 92 struct savefpu *guestfpu; /* guest fpu state */ 93 uint64_t guest_xcr0; 94 void *stats; 95 struct vm_exit exitinfo; 96 enum x2apic_state x2apic_state; 97 int nmi_pending; | 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/module.h> 36#include <sys/sysctl.h> 37#include <sys/malloc.h> 38#include <sys/pcpu.h> --- 51 unchanged lines hidden (view full) --- 90 struct vlapic *vlapic; 91 int vcpuid; 92 struct savefpu *guestfpu; /* guest fpu state */ 93 uint64_t guest_xcr0; 94 void *stats; 95 struct vm_exit exitinfo; 96 enum x2apic_state x2apic_state; 97 int nmi_pending; |
98 int extint_pending; |
|
98 struct vm_exception exception; 99 int exception_pending; 100}; 101 102#define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN) 103#define vcpu_lock(v) mtx_lock_spin(&((v)->mtx)) 104#define vcpu_unlock(v) mtx_unlock_spin(&((v)->mtx)) 105#define vcpu_assert_locked(v) mtx_assert(&((v)->mtx), MA_OWNED) --- 1240 unchanged lines hidden (view full) --- 1346 1347 if (vcpu->nmi_pending == 0) 1348 panic("vm_nmi_clear: inconsistent nmi_pending state"); 1349 1350 vcpu->nmi_pending = 0; 1351 vmm_stat_incr(vm, vcpuid, VCPU_NMI_COUNT, 1); 1352} 1353 | 99 struct vm_exception exception; 100 int exception_pending; 101}; 102 103#define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN) 104#define vcpu_lock(v) mtx_lock_spin(&((v)->mtx)) 105#define vcpu_unlock(v) mtx_unlock_spin(&((v)->mtx)) 106#define vcpu_assert_locked(v) mtx_assert(&((v)->mtx), MA_OWNED) --- 1240 unchanged lines hidden (view full) --- 1347 1348 if (vcpu->nmi_pending == 0) 1349 panic("vm_nmi_clear: inconsistent nmi_pending state"); 1350 1351 vcpu->nmi_pending = 0; 1352 vmm_stat_incr(vm, vcpuid, VCPU_NMI_COUNT, 1); 1353} 1354 |
1355static VMM_STAT(VCPU_EXTINT_COUNT, "number of ExtINTs delivered to vcpu"); 1356 |
|
1354int | 1357int |
1358vm_inject_extint(struct vm *vm, int vcpuid) 1359{ 1360 struct vcpu *vcpu; 1361 1362 if (vcpuid < 0 || vcpuid >= VM_MAXCPU) 1363 return (EINVAL); 1364 1365 vcpu = &vm->vcpu[vcpuid]; 1366 1367 vcpu->extint_pending = 1; 1368 vcpu_notify_event(vm, vcpuid, false); 1369 return (0); 1370} 1371 1372int 1373vm_extint_pending(struct vm *vm, int vcpuid) 1374{ 1375 struct vcpu *vcpu; 1376 1377 if (vcpuid < 0 || vcpuid >= VM_MAXCPU) 1378 panic("vm_extint_pending: invalid vcpuid %d", vcpuid); 1379 1380 vcpu = &vm->vcpu[vcpuid]; 1381 1382 return (vcpu->extint_pending); 1383} 1384 1385void 1386vm_extint_clear(struct vm *vm, int vcpuid) 1387{ 1388 struct vcpu *vcpu; 1389 1390 if (vcpuid < 0 || vcpuid >= VM_MAXCPU) 1391 panic("vm_extint_pending: invalid vcpuid %d", vcpuid); 1392 1393 vcpu = &vm->vcpu[vcpuid]; 1394 1395 if (vcpu->extint_pending == 0) 1396 panic("vm_extint_clear: inconsistent extint_pending state"); 1397 1398 vcpu->extint_pending = 0; 1399 vmm_stat_incr(vm, vcpuid, VCPU_EXTINT_COUNT, 1); 1400} 1401 1402int |
|
1355vm_get_capability(struct vm *vm, int vcpu, int type, int *retval) 1356{ 1357 if (vcpu < 0 || vcpu >= VM_MAXCPU) 1358 return (EINVAL); 1359 1360 if (type < 0 || type >= VM_CAP_MAX) 1361 return (EINVAL); 1362 --- 287 unchanged lines hidden --- | 1403vm_get_capability(struct vm *vm, int vcpu, int type, int *retval) 1404{ 1405 if (vcpu < 0 || vcpu >= VM_MAXCPU) 1406 return (EINVAL); 1407 1408 if (type < 0 || type >= VM_CAP_MAX) 1409 return (EINVAL); 1410 --- 287 unchanged lines hidden --- |