bhyverun.c (265062) | bhyverun.c (265101) |
---|---|
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/usr.sbin/bhyve/bhyverun.c 265062 2014-04-28 22:06:40Z neel $ | 26 * $FreeBSD: head/usr.sbin/bhyve/bhyverun.c 265101 2014-04-29 18:42:56Z neel $ |
27 */ 28 29#include <sys/cdefs.h> | 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/bhyverun.c 265062 2014-04-28 22:06:40Z neel $"); | 30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/bhyverun.c 265101 2014-04-29 18:42:56Z neel $"); |
31 32#include <sys/types.h> 33#include <sys/mman.h> 34#include <sys/time.h> 35 36#include <machine/atomic.h> 37#include <machine/segments.h> 38 --- 70 unchanged lines hidden (view full) --- 109 uint64_t vmexit_bogus_switch; 110 uint64_t vmexit_hlt; 111 uint64_t vmexit_pause; 112 uint64_t vmexit_mtrap; 113 uint64_t vmexit_inst_emul; 114 uint64_t cpu_switch_rotate; 115 uint64_t cpu_switch_direct; 116 int io_reset; | 31 32#include <sys/types.h> 33#include <sys/mman.h> 34#include <sys/time.h> 35 36#include <machine/atomic.h> 37#include <machine/segments.h> 38 --- 70 unchanged lines hidden (view full) --- 109 uint64_t vmexit_bogus_switch; 110 uint64_t vmexit_hlt; 111 uint64_t vmexit_pause; 112 uint64_t vmexit_mtrap; 113 uint64_t vmexit_inst_emul; 114 uint64_t cpu_switch_rotate; 115 uint64_t cpu_switch_direct; 116 int io_reset; |
117 int io_poweroff; |
|
117} stats; 118 119struct mt_vmm_info { 120 pthread_t mt_thr; 121 struct vmctx *mt_ctx; 122 int mt_vcpu; 123} mt_vmm_info[VM_MAXCPU]; 124 --- 107 unchanged lines hidden (view full) --- 232 exit(1); 233 } 234 235 CPU_CLR_ATOMIC(vcpu, &cpumask); 236 return (CPU_EMPTY(&cpumask)); 237} 238 239static int | 118} stats; 119 120struct mt_vmm_info { 121 pthread_t mt_thr; 122 struct vmctx *mt_ctx; 123 int mt_vcpu; 124} mt_vmm_info[VM_MAXCPU]; 125 --- 107 unchanged lines hidden (view full) --- 233 exit(1); 234 } 235 236 CPU_CLR_ATOMIC(vcpu, &cpumask); 237 return (CPU_EMPTY(&cpumask)); 238} 239 240static int |
240vmexit_catch_reset(void) 241{ 242 stats.io_reset++; 243 return (VMEXIT_RESET); 244} 245 246static int | |
247vmexit_catch_inout(void) 248{ 249 return (VMEXIT_ABORT); 250} 251 252static int 253vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu, 254 uint32_t eax) --- 33 unchanged lines hidden (view full) --- 288 error = emulate_inout(ctx, vcpu, in, port, bytes, &eax, strictio); 289 if (error == INOUT_OK && in) 290 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, eax); 291 292 switch (error) { 293 case INOUT_OK: 294 return (VMEXIT_CONTINUE); 295 case INOUT_RESET: | 241vmexit_catch_inout(void) 242{ 243 return (VMEXIT_ABORT); 244} 245 246static int 247vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu, 248 uint32_t eax) --- 33 unchanged lines hidden (view full) --- 282 error = emulate_inout(ctx, vcpu, in, port, bytes, &eax, strictio); 283 if (error == INOUT_OK && in) 284 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, eax); 285 286 switch (error) { 287 case INOUT_OK: 288 return (VMEXIT_CONTINUE); 289 case INOUT_RESET: |
290 stats.io_reset++; |
|
296 return (VMEXIT_RESET); 297 case INOUT_POWEROFF: | 291 return (VMEXIT_RESET); 292 case INOUT_POWEROFF: |
293 stats.io_poweroff++; |
|
298 return (VMEXIT_POWEROFF); 299 default: 300 fprintf(stderr, "Unhandled %s%c 0x%04x\n", 301 in ? "in" : "out", 302 bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'), port); 303 return (vmexit_catch_inout()); 304 } 305} --- 54 unchanged lines hidden (view full) --- 360 361 newcpu = spinup_ap(ctx, *pvcpu, 362 vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip); 363 364 return (retval); 365} 366 367static int | 294 return (VMEXIT_POWEROFF); 295 default: 296 fprintf(stderr, "Unhandled %s%c 0x%04x\n", 297 in ? "in" : "out", 298 bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'), port); 299 return (vmexit_catch_inout()); 300 } 301} --- 54 unchanged lines hidden (view full) --- 356 357 newcpu = spinup_ap(ctx, *pvcpu, 358 vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip); 359 360 return (retval); 361} 362 363static int |
368vmexit_spindown_cpu(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) 369{ 370 int lastcpu; 371 372 lastcpu = fbsdrun_deletecpu(ctx, *pvcpu); 373 if (!lastcpu) 374 pthread_exit(NULL); 375 return (vmexit_catch_reset()); 376} 377 378static int | |
379vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 380{ 381 382 fprintf(stderr, "vm exit[%d]\n", *pvcpu); 383 fprintf(stderr, "\treason\t\tVMX\n"); 384 fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip); 385 fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length); 386 fprintf(stderr, "\tstatus\t\t%d\n", vmexit->u.vmx.status); --- 109 unchanged lines hidden (view full) --- 496 [VM_EXITCODE_INOUT] = vmexit_inout, 497 [VM_EXITCODE_VMX] = vmexit_vmx, 498 [VM_EXITCODE_BOGUS] = vmexit_bogus, 499 [VM_EXITCODE_RDMSR] = vmexit_rdmsr, 500 [VM_EXITCODE_WRMSR] = vmexit_wrmsr, 501 [VM_EXITCODE_MTRAP] = vmexit_mtrap, 502 [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul, 503 [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap, | 364vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 365{ 366 367 fprintf(stderr, "vm exit[%d]\n", *pvcpu); 368 fprintf(stderr, "\treason\t\tVMX\n"); 369 fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip); 370 fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length); 371 fprintf(stderr, "\tstatus\t\t%d\n", vmexit->u.vmx.status); --- 109 unchanged lines hidden (view full) --- 481 [VM_EXITCODE_INOUT] = vmexit_inout, 482 [VM_EXITCODE_VMX] = vmexit_vmx, 483 [VM_EXITCODE_BOGUS] = vmexit_bogus, 484 [VM_EXITCODE_RDMSR] = vmexit_rdmsr, 485 [VM_EXITCODE_WRMSR] = vmexit_wrmsr, 486 [VM_EXITCODE_MTRAP] = vmexit_mtrap, 487 [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul, 488 [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap, |
504 [VM_EXITCODE_SPINDOWN_CPU] = vmexit_spindown_cpu, | |
505 [VM_EXITCODE_SUSPENDED] = vmexit_suspend 506}; 507 508static void 509vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) 510{ 511 cpuset_t mask; 512 int error, rc, prevcpu; --- 279 unchanged lines hidden --- | 489 [VM_EXITCODE_SUSPENDED] = vmexit_suspend 490}; 491 492static void 493vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) 494{ 495 cpuset_t mask; 496 int error, rc, prevcpu; --- 279 unchanged lines hidden --- |