Deleted Added
full compact
vmm.c (241489) vmm.c (241982)
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

--- 63 unchanged lines hidden (view full) ---

72 int hostcpu; /* host cpuid this vcpu last ran on */
73 uint64_t guest_msrs[VMM_MSR_NUM];
74 struct vlapic *vlapic;
75 int vcpuid;
76 struct savefpu *guestfpu; /* guest fpu state */
77 void *stats;
78 struct vm_exit exitinfo;
79 enum x2apic_state x2apic_state;
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

--- 63 unchanged lines hidden (view full) ---

72 int hostcpu; /* host cpuid this vcpu last ran on */
73 uint64_t guest_msrs[VMM_MSR_NUM];
74 struct vlapic *vlapic;
75 int vcpuid;
76 struct savefpu *guestfpu; /* guest fpu state */
77 void *stats;
78 struct vm_exit exitinfo;
79 enum x2apic_state x2apic_state;
80 int nmi_pending;
80};
81#define VCPU_F_PINNED 0x0001
82
83#define VCPU_PINCPU(vm, vcpuid) \
84 ((vm->vcpu[vcpuid].flags & VCPU_F_PINNED) ? vm->vcpu[vcpuid].pincpu : -1)
85
86#define VCPU_UNPIN(vm, vcpuid) (vm->vcpu[vcpuid].flags &= ~VCPU_F_PINNED)
87

--- 44 unchanged lines hidden (view full) ---

132#define VMSETREG(vmi, vcpu, num, val) \
133 (ops != NULL ? (*ops->vmsetreg)(vmi, vcpu, num, val) : ENXIO)
134#define VMGETDESC(vmi, vcpu, num, desc) \
135 (ops != NULL ? (*ops->vmgetdesc)(vmi, vcpu, num, desc) : ENXIO)
136#define VMSETDESC(vmi, vcpu, num, desc) \
137 (ops != NULL ? (*ops->vmsetdesc)(vmi, vcpu, num, desc) : ENXIO)
138#define VMINJECT(vmi, vcpu, type, vec, ec, ecv) \
139 (ops != NULL ? (*ops->vminject)(vmi, vcpu, type, vec, ec, ecv) : ENXIO)
81};
82#define VCPU_F_PINNED 0x0001
83
84#define VCPU_PINCPU(vm, vcpuid) \
85 ((vm->vcpu[vcpuid].flags & VCPU_F_PINNED) ? vm->vcpu[vcpuid].pincpu : -1)
86
87#define VCPU_UNPIN(vm, vcpuid) (vm->vcpu[vcpuid].flags &= ~VCPU_F_PINNED)
88

--- 44 unchanged lines hidden (view full) ---

133#define VMSETREG(vmi, vcpu, num, val) \
134 (ops != NULL ? (*ops->vmsetreg)(vmi, vcpu, num, val) : ENXIO)
135#define VMGETDESC(vmi, vcpu, num, desc) \
136 (ops != NULL ? (*ops->vmgetdesc)(vmi, vcpu, num, desc) : ENXIO)
137#define VMSETDESC(vmi, vcpu, num, desc) \
138 (ops != NULL ? (*ops->vmsetdesc)(vmi, vcpu, num, desc) : ENXIO)
139#define VMINJECT(vmi, vcpu, type, vec, ec, ecv) \
140 (ops != NULL ? (*ops->vminject)(vmi, vcpu, type, vec, ec, ecv) : ENXIO)
140#define VMNMI(vmi, vcpu) \
141 (ops != NULL ? (*ops->vmnmi)(vmi, vcpu) : ENXIO)
142#define VMGETCAP(vmi, vcpu, num, retval) \
143 (ops != NULL ? (*ops->vmgetcap)(vmi, vcpu, num, retval) : ENXIO)
144#define VMSETCAP(vmi, vcpu, num, val) \
145 (ops != NULL ? (*ops->vmsetcap)(vmi, vcpu, num, val) : ENXIO)
146
147#define fpu_start_emulating() start_emulating()
148#define fpu_stop_emulating() stop_emulating()
149

--- 555 unchanged lines hidden (view full) ---

705 return (EINVAL);
706
707 if (vector < 0 || vector > 255)
708 return (EINVAL);
709
710 return (VMINJECT(vm->cookie, vcpuid, type, vector, code, code_valid));
711}
712
141#define VMGETCAP(vmi, vcpu, num, retval) \
142 (ops != NULL ? (*ops->vmgetcap)(vmi, vcpu, num, retval) : ENXIO)
143#define VMSETCAP(vmi, vcpu, num, val) \
144 (ops != NULL ? (*ops->vmsetcap)(vmi, vcpu, num, val) : ENXIO)
145
146#define fpu_start_emulating() start_emulating()
147#define fpu_stop_emulating() stop_emulating()
148

--- 555 unchanged lines hidden (view full) ---

704 return (EINVAL);
705
706 if (vector < 0 || vector > 255)
707 return (EINVAL);
708
709 return (VMINJECT(vm->cookie, vcpuid, type, vector, code, code_valid));
710}
711
712VMM_STAT_DEFINE(VCPU_NMI_COUNT, "number of NMIs delivered to vcpu");
713
713int
714int
714vm_inject_nmi(struct vm *vm, int vcpu)
715vm_inject_nmi(struct vm *vm, int vcpuid)
715{
716{
716 int error;
717 struct vcpu *vcpu;
717
718
718 if (vcpu < 0 || vcpu >= VM_MAXCPU)
719 if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
719 return (EINVAL);
720
720 return (EINVAL);
721
721 error = VMNMI(vm->cookie, vcpu);
722 vm_interrupt_hostcpu(vm, vcpu);
723 return (error);
722 vcpu = &vm->vcpu[vcpuid];
723
724 vcpu->nmi_pending = 1;
725 vm_interrupt_hostcpu(vm, vcpuid);
726 return (0);
724}
725
726int
727}
728
729int
730vm_nmi_pending(struct vm *vm, int vcpuid)
731{
732 struct vcpu *vcpu;
733
734 if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
735 panic("vm_nmi_pending: invalid vcpuid %d", vcpuid);
736
737 vcpu = &vm->vcpu[vcpuid];
738
739 return (vcpu->nmi_pending);
740}
741
742void
743vm_nmi_clear(struct vm *vm, int vcpuid)
744{
745 struct vcpu *vcpu;
746
747 if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
748 panic("vm_nmi_pending: invalid vcpuid %d", vcpuid);
749
750 vcpu = &vm->vcpu[vcpuid];
751
752 if (vcpu->nmi_pending == 0)
753 panic("vm_nmi_clear: inconsistent nmi_pending state");
754
755 vcpu->nmi_pending = 0;
756 vmm_stat_incr(vm, vcpuid, VCPU_NMI_COUNT, 1);
757}
758
759int
727vm_get_capability(struct vm *vm, int vcpu, int type, int *retval)
728{
729 if (vcpu < 0 || vcpu >= VM_MAXCPU)
730 return (EINVAL);
731
732 if (type < 0 || type >= VM_CAP_MAX)
733 return (EINVAL);
734

--- 183 unchanged lines hidden ---
760vm_get_capability(struct vm *vm, int vcpu, int type, int *retval)
761{
762 if (vcpu < 0 || vcpu >= VM_MAXCPU)
763 return (EINVAL);
764
765 if (type < 0 || type >= VM_CAP_MAX)
766 return (EINVAL);
767

--- 183 unchanged lines hidden ---