| /src/sys/amd64/vmm/ |
| H A D | vmm.c | 95 #define VMM_CTR0(vcpu, format) \ argument 96 VCPU_CTR0((vcpu)->vm, (vcpu)->vcpuid, format) 98 #define VMM_CTR1(vcpu, format, p1) \ argument 99 VCPU_CTR1((vcpu)->vm, (vcpu)->vcpuid, format, p1) 101 #define VMM_CTR2(vcpu, format, p1, p2) \ argument 102 VCPU_CTR2((vcpu)->vm, (vcpu)->vcpuid, format, p1, p2) 104 #define VMM_CTR3(vcpu, format, p1, p2, p3) \ argument 105 VCPU_CTR3((vcpu)->vm, (vcpu)->vcpuid, format, p1, p2, p3) 107 #define VMM_CTR4(vcpu, format, p1, p2, p3, p4) \ argument 108 VCPU_CTR4((vcpu)->vm, (vcpu)->vcpuid, format, p1, p2, p3, p4) [all …]
|
| H A D | vmm_lapic.h | 32 struct vcpu; 36 int lapic_rdmsr(struct vcpu *vcpu, u_int msr, uint64_t *rval, bool *retu); 37 int lapic_wrmsr(struct vcpu *vcpu, u_int msr, uint64_t wval, bool *retu); 39 int lapic_mmio_read(struct vcpu *vcpu, uint64_t gpa, 41 int lapic_mmio_write(struct vcpu *vcpu, uint64_t gpa, 48 int lapic_set_intr(struct vcpu *vcpu, int vector, bool trig); 53 lapic_intr_level(struct vcpu *vcpu, int vector) in lapic_intr_level() argument 56 return (lapic_set_intr(vcpu, vector, LAPIC_TRIG_LEVEL)); in lapic_intr_level() 60 lapic_intr_edge(struct vcpu *vcpu, int vector) in lapic_intr_edge() argument 63 return (lapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE)); in lapic_intr_edge() [all …]
|
| H A D | vmm_instruction_emul.c | 283 vie_read_register(struct vcpu *vcpu, enum vm_reg_name reg, uint64_t *rval) in vie_read_register() argument 287 error = vm_get_register(vcpu, reg, rval); in vie_read_register() 319 vie_read_bytereg(struct vcpu *vcpu, struct vie *vie, uint8_t *rval) in vie_read_bytereg() argument 326 error = vm_get_register(vcpu, reg, &val); in vie_read_bytereg() 340 vie_write_bytereg(struct vcpu *vcpu, struct vie *vie, uint8_t byte) in vie_write_bytereg() argument 347 error = vm_get_register(vcpu, reg, &origval); in vie_write_bytereg() 360 error = vm_set_register(vcpu, reg, val); in vie_write_bytereg() 366 vie_update_register(struct vcpu *vcpu, enum vm_reg_name reg, in vie_update_register() argument 375 error = vie_read_register(vcpu, reg, &origval); in vie_update_register() 390 error = vm_set_register(vcpu, reg, val); in vie_update_register() [all …]
|
| /src/sys/dev/vmm/ |
| H A D | vmm_vm.c | 24 "IPI vector used for vcpu notifications"); 27 * Invoke the rendezvous function on the specified vcpu if applicable. Return 31 vm_rendezvous(struct vcpu *vcpu) in vm_rendezvous() argument 33 struct vm *vm = vcpu->vm; in vm_rendezvous() 36 mtx_assert(&vcpu->vm->rendezvous_mtx, MA_OWNED); in vm_rendezvous() 37 KASSERT(vcpu->vm->rendezvous_func != NULL, in vm_rendezvous() 44 vcpuid = vcpu->vcpuid; in vm_rendezvous() 47 (*vm->rendezvous_func)(vcpu, vm->rendezvous_arg); in vm_rendezvous() 60 vm_handle_rendezvous(struct vcpu *vcpu) in vm_handle_rendezvous() argument 66 vm = vcpu->vm; in vm_handle_rendezvous() [all …]
|
| H A D | vmm_vm.h | 19 struct vcpu; 30 * (a) allocated when vcpu is created 31 * (i) initialized when vcpu is created and when it is reinitialized 32 * (o) initialized the first time the vcpu is created 35 struct vcpu { struct 37 enum vcpu_state state; /* (o) vcpu state */ argument 39 int hostcpu; /* (o) vcpu's host cpu */ argument 40 int reqidle; /* (i) request vcpu to idle */ argument 48 #define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN) argument 56 int vcpu_set_state(struct vcpu *vcpu, enum vcpu_state state, bool from_idle); [all …]
|
| /src/sys/riscv/vmm/ |
| H A D | vmm.c | 83 static VMM_STAT(VCPU_TOTAL_RUNTIME, "vcpu total runtime"); 91 vcpu_cleanup(struct vcpu *vcpu, bool destroy) in vcpu_cleanup() argument 93 vmmops_vcpu_cleanup(vcpu->cookie); in vcpu_cleanup() 94 vcpu->cookie = NULL; in vcpu_cleanup() 96 vmm_stat_free(vcpu->stats); in vcpu_cleanup() 97 fpu_save_area_free(vcpu->guestfpu); in vcpu_cleanup() 98 vcpu_lock_destroy(vcpu); in vcpu_cleanup() 99 free(vcpu, M_VMM); in vcpu_cleanup() 103 static struct vcpu * 106 struct vcpu *vcpu; in vcpu_alloc() local [all …]
|
| /src/sys/amd64/vmm/amd/ |
| H A D | svm.c | 296 svm_set_tsc_offset(struct svm_vcpu *vcpu, uint64_t offset) in svm_set_tsc_offset() argument 300 ctrl = svm_get_vmcb_ctrl(vcpu); in svm_set_tsc_offset() 303 svm_set_dirty(vcpu, VMCB_CACHE_I); in svm_set_tsc_offset() 304 SVM_CTR1(vcpu, "tsc offset changed to %#lx", offset); in svm_set_tsc_offset() 306 vm_set_tsc_offset(vcpu->vcpu, offset); in svm_set_tsc_offset() 383 * Allow vcpu to read or write the 'msr' without trapping into the hypervisor. 419 svm_get_intercept(struct svm_vcpu *vcpu, int idx, uint32_t bitmask) in svm_get_intercept() argument 425 ctrl = svm_get_vmcb_ctrl(vcpu); in svm_get_intercept() 430 svm_set_intercept(struct svm_vcpu *vcpu, int idx, uint32_t bitmask, int enabled) in svm_set_intercept() argument 437 ctrl = svm_get_vmcb_ctrl(vcpu); in svm_set_intercept() [all …]
|
| H A D | svm_softc.h | 40 uint32_t rflags_tf; /* saved RFLAGS.TF value when single-stepping a vcpu */ 52 struct vcpu *vcpu; member 53 struct vmcb *vmcb; /* hardware saved vcpu context */ 54 struct svm_regctx swctx; /* software saved vcpu context */ 57 int lastcpu; /* host cpu that the vcpu last ran on */ 59 long eptgen; /* pmap->pm_eptgen when the vcpu last ran */ 77 #define SVM_CTR0(vcpu, format) \ argument 78 VCPU_CTR0((vcpu)->sc->vm, (vcpu)->vcpuid, format) 80 #define SVM_CTR1(vcpu, format, p1) \ argument 81 VCPU_CTR1((vcpu)->sc->vm, (vcpu)->vcpuid, format, p1) [all …]
|
| H A D | vmcb.c | 118 vmcb_access(struct svm_vcpu *vcpu, int write, int ident, uint64_t *val) in vmcb_access() argument 124 vmcb = svm_get_vmcb(vcpu); in vmcb_access() 147 SVM_CTR1(vcpu, "Invalid size %d for VMCB access: %d", bytes); in vmcb_access() 153 svm_set_dirty(vcpu, 0xffffffff); in vmcb_access() 162 vmcb_read(struct svm_vcpu *vcpu, int ident, uint64_t *retval) in vmcb_read() argument 169 vmcb = svm_get_vmcb(vcpu); in vmcb_read() 174 return (vmcb_access(vcpu, 0, ident, retval)); in vmcb_read() 248 *retval = vlapic_get_cr8(vm_lapic(vcpu->vcpu)); in vmcb_read() 268 vmcb_write(struct svm_vcpu *vcpu, int ident, uint64_t val) in vmcb_write() argument 275 vmcb = svm_get_vmcb(vcpu); in vmcb_write() [all …]
|
| /src/sys/arm64/vmm/ |
| H A D | vmm.c | 79 static VMM_STAT(VCPU_TOTAL_RUNTIME, "vcpu total runtime"); 177 vcpu_cleanup(struct vcpu *vcpu, bool destroy) in vcpu_cleanup() argument 179 vmmops_vcpu_cleanup(vcpu->cookie); in vcpu_cleanup() 180 vcpu->cookie = NULL; in vcpu_cleanup() 182 vmm_stat_free(vcpu->stats); in vcpu_cleanup() 183 fpu_save_area_free(vcpu->guestfpu); in vcpu_cleanup() 184 vcpu_lock_destroy(vcpu); in vcpu_cleanup() 185 free(vcpu, M_VMM); in vcpu_cleanup() 189 static struct vcpu * 192 struct vcpu *vcpu; in vcpu_alloc() local [all …]
|
| /src/lib/libvmmapi/ |
| H A D | vmmapi.h | 46 struct vcpu; 123 struct vcpu *vm_vcpu_open(struct vmctx *ctx, int vcpuid); 124 void vm_vcpu_close(struct vcpu *vcpu); 125 int vcpu_id(struct vcpu *vcpu); 135 int vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging, 138 int vm_gla2gpa_nofault(struct vcpu *vcpu, 149 int vm_set_desc(struct vcpu *vcpu, int reg, 151 int vm_get_desc(struct vcpu *vcpu, int reg, 153 int vm_get_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *seg_desc); 155 int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); [all …]
|
| /src/usr.sbin/bhyve/amd64/ |
| H A D | task_switch.c | 100 GETREG(struct vcpu *vcpu, int reg) in GETREG() argument 105 error = vm_get_register(vcpu, reg, &val); in GETREG() 111 SETREG(struct vcpu *vcpu, int reg, uint64_t val) in SETREG() argument 115 error = vm_set_register(vcpu, reg, val); in SETREG() 151 sel_exception(struct vcpu *vcpu, int vector, uint16_t sel, int ext) in sel_exception() argument 165 vm_inject_fault(vcpu, vector, 1, sel); in sel_exception() 173 desc_table_limit_check(struct vcpu *vcpu, uint16_t sel) in desc_table_limit_check() argument 180 error = vm_get_desc(vcpu, reg, &base, &limit, &access); in desc_table_limit_check() 203 desc_table_rw(struct vcpu *vcpu, struct vm_guest_paging *paging, in desc_table_rw() argument 213 error = vm_get_desc(vcpu, reg, &base, &limit, &access); in desc_table_rw() [all …]
|
| H A D | vmexit.c | 60 vm_inject_fault(struct vcpu *vcpu, int vector, int errcode_valid, in vm_inject_fault() argument 67 error = vm_inject_exception(vcpu, vector, errcode_valid, errcode, in vm_inject_fault() 73 vmexit_inout(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun) in vmexit_inout() argument 84 error = emulate_inout(ctx, vcpu, vme); in vmexit_inout() 97 vmexit_rdmsr(struct vmctx *ctx __unused, struct vcpu *vcpu, in vmexit_rdmsr() argument 108 error = emulate_rdmsr(vcpu, vme->u.msr.code, &val); in vmexit_rdmsr() 112 EPRINTLN("rdmsr to register %#x on vcpu %d", in vmexit_rdmsr() 113 vme->u.msr.code, vcpu_id(vcpu)); in vmexit_rdmsr() 116 vm_inject_gp(vcpu); in vmexit_rdmsr() 122 error = vm_set_register(vcpu, VM_REG_GUEST_RAX, eax); in vmexit_rdmsr() [all …]
|
| /src/lib/libvmmapi/amd64/ |
| H A D | vmmapi_machdep.c | 97 vm_set_desc(struct vcpu *vcpu, int reg, in vm_set_desc() argument 109 error = vcpu_ioctl(vcpu, VM_SET_SEGMENT_DESCRIPTOR, &vmsegdesc); in vm_set_desc() 114 vm_get_desc(struct vcpu *vcpu, int reg, uint64_t *base, uint32_t *limit, in vm_get_desc() argument 123 error = vcpu_ioctl(vcpu, VM_GET_SEGMENT_DESCRIPTOR, &vmsegdesc); in vm_get_desc() 133 vm_get_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *seg_desc) in vm_get_seg_desc() argument 137 error = vm_get_desc(vcpu, reg, &seg_desc->base, &seg_desc->limit, in vm_get_seg_desc() 143 vm_lapic_irq(struct vcpu *vcpu, int vector) in vm_lapic_irq() argument 150 return (vcpu_ioctl(vcpu, VM_LAPIC_IRQ, &vmirq)); in vm_lapic_irq() 154 vm_lapic_local_irq(struct vcpu *vcpu, int vector) in vm_lapic_local_irq() argument 161 return (vcpu_ioctl(vcpu, VM_LAPIC_LOCAL_IRQ, &vmirq)); in vm_lapic_local_irq() [all …]
|
| H A D | vmmapi_freebsd_machdep.c | 66 * Setup the 'vcpu' register set such that it will begin execution at 70 vm_setup_freebsd_registers_i386(struct vcpu *vcpu, uint32_t eip, in vm_setup_freebsd_registers_i386() argument 80 error = vm_get_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, &tmp); in vm_setup_freebsd_registers_i386() 83 error = vm_set_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, 1); in vm_setup_freebsd_registers_i386() 88 if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0) in vm_setup_freebsd_registers_i386() 91 if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, 0)) != 0) in vm_setup_freebsd_registers_i386() 98 if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, 0))) in vm_setup_freebsd_registers_i386() 101 gdt = vm_map_gpa(vcpu->ctx, gdtbase, 0x1000); in vm_setup_freebsd_registers_i386() 107 error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR, in vm_setup_freebsd_registers_i386() 117 error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags); in vm_setup_freebsd_registers_i386() [all …]
|
| /src/sys/amd64/include/ |
| H A D | vmm.h | 36 struct vcpu; 181 DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, 236 int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); 237 int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); 238 int vm_get_seg_desc(struct vcpu *vcpu, int reg, 240 int vm_set_seg_desc(struct vcpu *vcpu, int reg, 242 int vm_run(struct vcpu *vcpu); 243 int vm_inject_nmi(struct vcpu *vcpu); 244 int vm_nmi_pending(struct vcpu *vcpu); 245 void vm_nmi_clear(struct vcpu *vcpu); [all …]
|
| /src/sys/amd64/vmm/intel/ |
| H A D | vmx.c | 818 * bitmap is currently per-VM rather than per-vCPU while the in vmx_modinit() 820 * per-vCPU basis). in vmx_modinit() 1132 vmx_vcpu_init(void *vmi, struct vcpu *vcpu1, int vcpuid) in vmx_vcpu_init() 1136 struct vmx_vcpu *vcpu; in vmx_vcpu_init() local 1143 vcpu = malloc(sizeof(*vcpu), M_VMX, M_WAITOK | M_ZERO); in vmx_vcpu_init() 1144 vcpu->vmx = vmx; in vmx_vcpu_init() 1145 vcpu->vcpu = vcpu1; in vmx_vcpu_init() 1146 vcpu->vcpuid = vcpuid; in vmx_vcpu_init() 1147 vcpu->vmcs = malloc_aligned(sizeof(*vmcs), PAGE_SIZE, M_VMX, in vmx_vcpu_init() 1149 vcpu->apic_page = malloc_aligned(PAGE_SIZE, PAGE_SIZE, M_VMX, in vmx_vcpu_init() [all …]
|
| H A D | vmx.h | 98 int lastcpu; /* host cpu that this 'vcpu' last ran on */ 129 struct vcpu *vcpu; member 152 #define VMX_CTR0(vcpu, format) \ argument 153 VCPU_CTR0((vcpu)->vmx->vm, (vcpu)->vcpuid, format) 155 #define VMX_CTR1(vcpu, format, p1) \ argument 156 VCPU_CTR1((vcpu)->vmx->vm, (vcpu)->vcpuid, format, p1) 158 #define VMX_CTR2(vcpu, format, p1, p2) \ argument 159 VCPU_CTR2((vcpu)->vmx->vm, (vcpu)->vcpuid, format, p1, p2) 161 #define VMX_CTR3(vcpu, format, p1, p2, p3) \ argument 162 VCPU_CTR3((vcpu)->vmx->vm, (vcpu)->vcpuid, format, p1, p2, p3) [all …]
|
| /src/sys/contrib/xen/ |
| H A D | vcpu.h | 2 * vcpu.h 4 * VCPU initialisation, query, and hotplug. 35 * @cmd == VCPUOP_??? (VCPU operation). 36 * @vcpuid == VCPU to operate on. 41 * Initialise a VCPU. Each VCPU can be initialised only once. A 42 * newly-initialised VCPU will not run until it is brought up by VCPUOP_up. 45 * structure containing the initial state for the VCPU. For x86 52 * Bring up a VCPU. This makes the VCPU runnable. This operation will fail 53 * if the VCPU has not been initialised (VCPUOP_initialise). 58 * Bring down a VCPU (i.e., make it non-runnable). [all …]
|
| /src/usr.sbin/bhyvectl/amd64/ |
| H A D | bhyvectl_machdep.c | 185 bhyvectl_dump_vm_run_exitcode(struct vm_exit *vmexit, int vcpu) in bhyvectl_dump_vm_run_exitcode() argument 187 printf("vm exit[%d]\n", vcpu); in bhyvectl_dump_vm_run_exitcode() 327 print_msr_pm(uint64_t msr, int vcpu, int readable, int writeable) in print_msr_pm() argument 331 printf("%-20s[%d]\t\t%c%c\n", msr_name(msr), vcpu, in print_msr_pm() 340 dump_amd_msr_pm(const char *bitmap, int vcpu) in dump_amd_msr_pm() argument 352 print_msr_pm(msr, vcpu, readable, writeable); in dump_amd_msr_pm() 358 print_msr_pm(msr + MSR_AMD6TH_START, vcpu, readable, in dump_amd_msr_pm() 365 print_msr_pm(msr + MSR_AMD7TH_START, vcpu, readable, in dump_amd_msr_pm() 374 dump_intel_msr_pm(const char *bitmap, int vcpu) in dump_intel_msr_pm() argument 386 print_msr_pm(msr, vcpu, readable, writeable); in dump_intel_msr_pm() [all …]
|
| /src/usr.sbin/bhyve/aarch64/ |
| H A D | vmexit.c | 61 vmexit_inst_emul(struct vmctx *ctx __unused, struct vcpu *vcpu, in vmexit_inst_emul() argument 71 err = emulate_mem(vcpu, vme->u.inst_emul.gpa, vie, in vmexit_inst_emul() 90 vmexit_reg_emul(struct vmctx *ctx __unused, struct vcpu *vcpu __unused, in vmexit_reg_emul() 105 vmexit_suspend(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun) in vmexit_suspend() argument 109 int vcpuid = vcpu_id(vcpu); in vmexit_suspend() 135 vmexit_debug(struct vmctx *ctx __unused, struct vcpu *vcpu, in vmexit_debug() argument 138 gdb_cpu_suspend(vcpu); in vmexit_debug() 141 * window between activation of the vCPU thread and the STARTUP IPI. in vmexit_debug() 148 vmexit_bogus(struct vmctx *ctx __unused, struct vcpu *vcpu __unused, in vmexit_bogus() 176 for (int vcpu = 0; vcpu < guest_ncpus; vcpu++) { in smccc_affinity_info() local [all …]
|
| /src/sys/riscv/include/ |
| H A D | vmm.h | 45 struct vcpu; 146 DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, 158 int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); 159 int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); 160 int vm_run(struct vcpu *vcpu); 162 void *vcpu_get_cookie(struct vcpu *vcpu); 163 int vm_get_capability(struct vcpu *vcpu, int type, int *val); 164 int vm_set_capability(struct vcpu *vcpu, int type, int val); 165 int vm_inject_exception(struct vcpu *vcpu, uint64_t scause); 171 struct vm_exit *vm_exitinfo(struct vcpu *vcpu); [all …]
|
| /src/usr.sbin/bhyve/ |
| H A D | mem.c | 64 * Per-vCPU cache. Since most accesses from a vCPU will be to 142 typedef int (mem_cb_t)(struct vcpu *vcpu, uint64_t gpa, struct mem_range *mr, 146 mem_read(struct vcpu *vcpu, uint64_t gpa, uint64_t *rval, int size, void *arg) in mem_read() argument 151 error = (*mr->handler)(vcpu, MEM_F_READ, gpa, size, rval, mr->arg1, in mem_read() 157 mem_write(struct vcpu *vcpu, uint64_t gpa, uint64_t wval, int size, void *arg) in mem_write() argument 162 error = (*mr->handler)(vcpu, MEM_F_WRITE, gpa, size, &wval, mr->arg1, in mem_write() 168 access_memory(struct vcpu *vcpu, uint64_t paddr, mem_cb_t *cb, void *arg) in access_memory() argument 174 vcpuid = vcpu_id(vcpu); in access_memory() 179 * First check the per-vCPU cache in access_memory() 190 /* Update the per-vCPU cache */ in access_memory() [all …]
|
| /src/sys/arm64/vmm/io/ |
| H A D | vtimer.h | 77 int vtimer_phys_ctl_read(struct vcpu *vcpu, uint64_t *rval, void *arg); 78 int vtimer_phys_ctl_write(struct vcpu *vcpu, uint64_t wval, void *arg); 79 int vtimer_phys_cnt_read(struct vcpu *vcpu, uint64_t *rval, void *arg); 80 int vtimer_phys_cnt_write(struct vcpu *vcpu, uint64_t wval, void *arg); 81 int vtimer_phys_cval_read(struct vcpu *vcpu, uint64_t *rval, void *arg); 82 int vtimer_phys_cval_write(struct vcpu *vcpu, uint64_t wval, void *arg); 83 int vtimer_phys_tval_read(struct vcpu *vcpu, uint64_t *rval, void *arg); 84 int vtimer_phys_tval_write(struct vcpu *vcpu, uint64_t wval, void *arg);
|
| /src/sys/arm64/include/ |
| H A D | vmm.h | 38 struct vcpu; 159 DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu, 179 int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); 180 int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); 181 int vm_run(struct vcpu *vcpu); 183 void *vcpu_get_cookie(struct vcpu *vcpu); 184 int vm_get_capability(struct vcpu *vcpu, int type, int *val); 185 int vm_set_capability(struct vcpu *vcpu, int type, int val); 186 int vm_inject_exception(struct vcpu *vcpu, uint64_t esr, uint64_t far); 192 struct vm_exit *vm_exitinfo(struct vcpu *vcpu); [all …]
|