2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2011 NetApp, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <sys/types.h>
35 #ifndef WITHOUT_CAPSICUM
36 #include <sys/capsicum.h>
41 #include <machine/atomic.h>
42 #include <machine/segments.h>
44 #ifndef WITHOUT_CAPSICUM
45 #include <capsicum_helpers.h>
57 #include <pthread_np.h>
61 #include <machine/vmm.h>
62 #ifndef WITHOUT_CAPSICUM
63 #include <machine/vmm_dev.h>
80 #include "smbiostbl.h"
82 #include "spinup_ap.h"
85 #define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */
87 #define MB (1024UL * 1024)
88 #define GB (1024UL * MB)
90 typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu);
91 extern int vmexit_task_switch(struct vmctx *, struct vm_exit *, int *vcpu);
98 static int guest_vmexit_on_hlt, guest_vmexit_on_pause;
99 static int virtio_msix = 1;
100 static int x2apic_mode = 0; /* default is xAPIC */
103 static int strictmsr = 1;
107 static char *progname;
108 static const int BSP = 0;
110 static cpuset_t cpumask;
112 static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip);
114 static struct vm_exit vmexit[VM_MAXCPU];
117 uint64_t vmexit_bogus;
118 uint64_t vmexit_reqidle;
120 uint64_t vmexit_pause;
121 uint64_t vmexit_mtrap;
122 uint64_t vmexit_inst_emul;
123 uint64_t cpu_switch_rotate;
124 uint64_t cpu_switch_direct;
129 struct vmctx *mt_ctx;
131 } mt_vmm_info[VM_MAXCPU];
133 static cpuset_t *vcpumap[VM_MAXCPU] = { NULL };
140 "Usage: %s [-abehuwxACHPSWY] [-c vcpus] [-g <gdb port>] [-l <lpc>]\n"
141 " %*s [-m mem] [-p vcpu:hostcpu] [-s <pci>] [-U uuid] <vm>\n"
142 " -a: local apic is in xAPIC mode (deprecated)\n"
143 " -A: create ACPI tables\n"
144 " -c: # cpus (default 1)\n"
145 " -C: include guest memory in core file\n"
146 " -e: exit on unhandled I/O access\n"
149 " -H: vmexit from the guest on hlt\n"
150 " -l: LPC device configuration\n"
151 " -m: memory size in MB\n"
152 " -p: pin 'vcpu' to 'hostcpu'\n"
153 " -P: vmexit from the guest on pause\n"
154 " -s: <slot,driver,configinfo> PCI slot config\n"
155 " -S: guest memory cannot be swapped\n"
156 " -u: RTC keeps UTC time\n"
158 " -w: ignore unimplemented MSRs\n"
159 " -W: force virtio to use single-vector MSI\n"
160 " -x: local apic is in x2APIC mode\n"
161 " -Y: disable MPtable generation\n",
162 progname, (int)strlen(progname), "");
168 pincpu_parse(const char *opt)
172 if (sscanf(opt, "%d:%d", &vcpu, &pcpu) != 2) {
173 fprintf(stderr, "invalid format: %s\n", opt);
177 if (vcpu < 0 || vcpu >= VM_MAXCPU) {
178 fprintf(stderr, "vcpu '%d' outside valid range from 0 to %d\n",
179 vcpu, VM_MAXCPU - 1);
183 if (pcpu < 0 || pcpu >= CPU_SETSIZE) {
184 fprintf(stderr, "hostcpu '%d' outside valid range from "
185 "0 to %d\n", pcpu, CPU_SETSIZE - 1);
189 if (vcpumap[vcpu] == NULL) {
190 if ((vcpumap[vcpu] = malloc(sizeof(cpuset_t))) == NULL) {
194 CPU_ZERO(vcpumap[vcpu]);
196 CPU_SET(pcpu, vcpumap[vcpu]);
201 vm_inject_fault(void *arg, int vcpu, int vector, int errcode_valid,
205 int error, restart_instruction;
208 restart_instruction = 1;
210 error = vm_inject_exception(ctx, vcpu, vector, errcode_valid, errcode,
211 restart_instruction);
216 paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len)
219 return (vm_map_gpa(ctx, gaddr, len));
223 fbsdrun_vmexit_on_pause(void)
226 return (guest_vmexit_on_pause);
230 fbsdrun_vmexit_on_hlt(void)
233 return (guest_vmexit_on_hlt);
237 fbsdrun_virtio_msix(void)
240 return (virtio_msix);
244 fbsdrun_start_thread(void *param)
246 char tname[MAXCOMLEN + 1];
247 struct mt_vmm_info *mtp;
253 snprintf(tname, sizeof(tname), "vcpu %d", vcpu);
254 pthread_set_name_np(mtp->mt_thr, tname);
256 vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip);
264 fbsdrun_addcpu(struct vmctx *ctx, int fromcpu, int newcpu, uint64_t rip)
268 assert(fromcpu == BSP);
271 * The 'newcpu' must be activated in the context of 'fromcpu'. If
272 * vm_activate_cpu() is delayed until newcpu's pthread starts running
273 * then vmm.ko is out-of-sync with bhyve and this can create a race
276 error = vm_activate_cpu(ctx, newcpu);
278 err(EX_OSERR, "could not activate CPU %d", newcpu);
280 CPU_SET_ATOMIC(newcpu, &cpumask);
283 * Set up the vmexit struct to allow execution to start
286 vmexit[newcpu].rip = rip;
287 vmexit[newcpu].inst_length = 0;
289 mt_vmm_info[newcpu].mt_ctx = ctx;
290 mt_vmm_info[newcpu].mt_vcpu = newcpu;
292 error = pthread_create(&mt_vmm_info[newcpu].mt_thr, NULL,
293 fbsdrun_start_thread, &mt_vmm_info[newcpu]);
298 fbsdrun_deletecpu(struct vmctx *ctx, int vcpu)
301 if (!CPU_ISSET(vcpu, &cpumask)) {
302 fprintf(stderr, "Attempting to delete unknown cpu %d\n", vcpu);
306 CPU_CLR_ATOMIC(vcpu, &cpumask);
307 return (CPU_EMPTY(&cpumask));
311 vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu,
316 * put guest-driven debug here
319 return (VMEXIT_CONTINUE);
323 vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
326 int bytes, port, in, out;
331 port = vme->u.inout.port;
332 bytes = vme->u.inout.bytes;
333 in = vme->u.inout.in;
336 /* Extra-special case of host notifications */
337 if (out && port == GUEST_NIO_PORT) {
338 error = vmexit_handle_notify(ctx, vme, pvcpu, vme->u.inout.eax);
342 error = emulate_inout(ctx, vcpu, vme, strictio);
344 fprintf(stderr, "Unhandled %s%c 0x%04x at 0x%lx\n",
346 bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'),
348 return (VMEXIT_ABORT);
350 return (VMEXIT_CONTINUE);
355 vmexit_rdmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
362 error = emulate_rdmsr(ctx, *pvcpu, vme->u.msr.code, &val);
364 fprintf(stderr, "rdmsr to register %#x on vcpu %d\n",
365 vme->u.msr.code, *pvcpu);
367 vm_inject_gp(ctx, *pvcpu);
368 return (VMEXIT_CONTINUE);
373 error = vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RAX, eax);
377 error = vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RDX, edx);
380 return (VMEXIT_CONTINUE);
384 vmexit_wrmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
388 error = emulate_wrmsr(ctx, *pvcpu, vme->u.msr.code, vme->u.msr.wval);
390 fprintf(stderr, "wrmsr to register %#x(%#lx) on vcpu %d\n",
391 vme->u.msr.code, vme->u.msr.wval, *pvcpu);
393 vm_inject_gp(ctx, *pvcpu);
394 return (VMEXIT_CONTINUE);
397 return (VMEXIT_CONTINUE);
401 vmexit_spinup_ap(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
404 (void)spinup_ap(ctx, *pvcpu,
405 vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip);
407 return (VMEXIT_CONTINUE);
410 #define DEBUG_EPT_MISCONFIG
411 #ifdef DEBUG_EPT_MISCONFIG
412 #define EXIT_REASON_EPT_MISCONFIG 49
413 #define VMCS_GUEST_PHYSICAL_ADDRESS 0x00002400
414 #define VMCS_IDENT(x) ((x) | 0x80000000)
416 static uint64_t ept_misconfig_gpa, ept_misconfig_pte[4];
417 static int ept_misconfig_ptenum;
421 vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
424 fprintf(stderr, "vm exit[%d]\n", *pvcpu);
425 fprintf(stderr, "\treason\t\tVMX\n");
426 fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip);
427 fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length);
428 fprintf(stderr, "\tstatus\t\t%d\n", vmexit->u.vmx.status);
429 fprintf(stderr, "\texit_reason\t%u\n", vmexit->u.vmx.exit_reason);
430 fprintf(stderr, "\tqualification\t0x%016lx\n",
431 vmexit->u.vmx.exit_qualification);
432 fprintf(stderr, "\tinst_type\t\t%d\n", vmexit->u.vmx.inst_type);
433 fprintf(stderr, "\tinst_error\t\t%d\n", vmexit->u.vmx.inst_error);
434 #ifdef DEBUG_EPT_MISCONFIG
435 if (vmexit->u.vmx.exit_reason == EXIT_REASON_EPT_MISCONFIG) {
436 vm_get_register(ctx, *pvcpu,
437 VMCS_IDENT(VMCS_GUEST_PHYSICAL_ADDRESS),
439 vm_get_gpa_pmap(ctx, ept_misconfig_gpa, ept_misconfig_pte,
440 &ept_misconfig_ptenum);
441 fprintf(stderr, "\tEPT misconfiguration:\n");
442 fprintf(stderr, "\t\tGPA: %#lx\n", ept_misconfig_gpa);
443 fprintf(stderr, "\t\tPTE(%d): %#lx %#lx %#lx %#lx\n",
444 ept_misconfig_ptenum, ept_misconfig_pte[0],
445 ept_misconfig_pte[1], ept_misconfig_pte[2],
446 ept_misconfig_pte[3]);
448 #endif /* DEBUG_EPT_MISCONFIG */
449 return (VMEXIT_ABORT);
453 vmexit_svm(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
456 fprintf(stderr, "vm exit[%d]\n", *pvcpu);
457 fprintf(stderr, "\treason\t\tSVM\n");
458 fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip);
459 fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length);
460 fprintf(stderr, "\texitcode\t%#lx\n", vmexit->u.svm.exitcode);
461 fprintf(stderr, "\texitinfo1\t%#lx\n", vmexit->u.svm.exitinfo1);
462 fprintf(stderr, "\texitinfo2\t%#lx\n", vmexit->u.svm.exitinfo2);
463 return (VMEXIT_ABORT);
467 vmexit_bogus(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
470 assert(vmexit->inst_length == 0);
472 stats.vmexit_bogus++;
474 return (VMEXIT_CONTINUE);
478 vmexit_reqidle(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
481 assert(vmexit->inst_length == 0);
483 stats.vmexit_reqidle++;
485 return (VMEXIT_CONTINUE);
489 vmexit_hlt(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
495 * Just continue execution with the next instruction. We use
496 * the HLT VM exit as a way to be friendly with the host
499 return (VMEXIT_CONTINUE);
503 vmexit_pause(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
506 stats.vmexit_pause++;
508 return (VMEXIT_CONTINUE);
512 vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
515 assert(vmexit->inst_length == 0);
517 stats.vmexit_mtrap++;
519 return (VMEXIT_CONTINUE);
523 vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
528 stats.vmexit_inst_emul++;
530 vie = &vmexit->u.inst_emul.vie;
531 err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa,
532 vie, &vmexit->u.inst_emul.paging);
536 fprintf(stderr, "Unhandled memory access to 0x%lx\n",
537 vmexit->u.inst_emul.gpa);
540 fprintf(stderr, "Failed to emulate instruction [");
541 for (i = 0; i < vie->num_valid; i++) {
542 fprintf(stderr, "0x%02x%s", vie->inst[i],
543 i != (vie->num_valid - 1) ? " " : "");
545 fprintf(stderr, "] at 0x%lx\n", vmexit->rip);
546 return (VMEXIT_ABORT);
549 return (VMEXIT_CONTINUE);
552 static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER;
553 static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER;
556 vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
558 enum vm_suspend_how how;
560 how = vmexit->u.suspended.how;
562 fbsdrun_deletecpu(ctx, *pvcpu);
565 pthread_mutex_lock(&resetcpu_mtx);
566 pthread_cond_signal(&resetcpu_cond);
567 pthread_mutex_unlock(&resetcpu_mtx);
571 pthread_mutex_lock(&resetcpu_mtx);
572 while (!CPU_EMPTY(&cpumask)) {
573 pthread_cond_wait(&resetcpu_cond, &resetcpu_mtx);
575 pthread_mutex_unlock(&resetcpu_mtx);
578 case VM_SUSPEND_RESET:
580 case VM_SUSPEND_POWEROFF:
582 case VM_SUSPEND_HALT:
584 case VM_SUSPEND_TRIPLEFAULT:
587 fprintf(stderr, "vmexit_suspend: invalid reason %d\n", how);
590 return (0); /* NOTREACHED */
593 static vmexit_handler_t handler[VM_EXITCODE_MAX] = {
594 [VM_EXITCODE_INOUT] = vmexit_inout,
595 [VM_EXITCODE_INOUT_STR] = vmexit_inout,
596 [VM_EXITCODE_VMX] = vmexit_vmx,
597 [VM_EXITCODE_SVM] = vmexit_svm,
598 [VM_EXITCODE_BOGUS] = vmexit_bogus,
599 [VM_EXITCODE_REQIDLE] = vmexit_reqidle,
600 [VM_EXITCODE_RDMSR] = vmexit_rdmsr,
601 [VM_EXITCODE_WRMSR] = vmexit_wrmsr,
602 [VM_EXITCODE_MTRAP] = vmexit_mtrap,
603 [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
604 [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap,
605 [VM_EXITCODE_SUSPENDED] = vmexit_suspend,
606 [VM_EXITCODE_TASK_SWITCH] = vmexit_task_switch,
610 vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip)
613 enum vm_exitcode exitcode;
614 cpuset_t active_cpus;
616 if (vcpumap[vcpu] != NULL) {
617 error = pthread_setaffinity_np(pthread_self(),
618 sizeof(cpuset_t), vcpumap[vcpu]);
622 error = vm_active_cpus(ctx, &active_cpus);
623 assert(CPU_ISSET(vcpu, &active_cpus));
625 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, startrip);
629 error = vm_run(ctx, vcpu, &vmexit[vcpu]);
633 exitcode = vmexit[vcpu].exitcode;
634 if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) {
635 fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n",
640 rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu);
643 case VMEXIT_CONTINUE:
651 fprintf(stderr, "vm_run error %d, errno %d\n", error, errno);
655 num_vcpus_allowed(struct vmctx *ctx)
659 error = vm_get_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, &tmp);
662 * The guest is allowed to spinup more than one processor only if the
663 * UNRESTRICTED_GUEST capability is available.
672 fbsdrun_set_capabilities(struct vmctx *ctx, int cpu)
676 if (fbsdrun_vmexit_on_hlt()) {
677 err = vm_get_capability(ctx, cpu, VM_CAP_HALT_EXIT, &tmp);
679 fprintf(stderr, "VM exit on HLT not supported\n");
682 vm_set_capability(ctx, cpu, VM_CAP_HALT_EXIT, 1);
684 handler[VM_EXITCODE_HLT] = vmexit_hlt;
687 if (fbsdrun_vmexit_on_pause()) {
689 * pause exit support required for this mode
691 err = vm_get_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, &tmp);
694 "SMP mux requested, no pause support\n");
697 vm_set_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, 1);
699 handler[VM_EXITCODE_PAUSE] = vmexit_pause;
703 err = vm_set_x2apic_state(ctx, cpu, X2APIC_ENABLED);
705 err = vm_set_x2apic_state(ctx, cpu, X2APIC_DISABLED);
708 fprintf(stderr, "Unable to set x2apic state (%d)\n", err);
712 vm_set_capability(ctx, cpu, VM_CAP_ENABLE_INVPCID, 1);
715 static struct vmctx *
716 do_open(const char *vmname)
720 bool reinit, romboot;
721 #ifndef WITHOUT_CAPSICUM
723 const cap_ioctl_t *cmds;
727 reinit = romboot = false;
732 error = vm_create(vmname);
734 if (errno == EEXIST) {
739 * The virtual machine has been setup by the
740 * userspace bootloader.
750 * If the virtual machine was just created then a
751 * bootrom must be configured to boot it.
753 fprintf(stderr, "virtual machine cannot be booted\n");
758 ctx = vm_open(vmname);
764 #ifndef WITHOUT_CAPSICUM
765 cap_rights_init(&rights, CAP_IOCTL, CAP_MMAP_RW);
766 if (cap_rights_limit(vm_get_device_fd(ctx), &rights) == -1 &&
768 errx(EX_OSERR, "Unable to apply rights for sandbox");
769 vm_get_ioctls(&ncmds);
770 cmds = vm_get_ioctls(NULL);
772 errx(EX_OSERR, "out of memory");
773 if (cap_ioctls_limit(vm_get_device_fd(ctx), cmds, ncmds) == -1 &&
775 errx(EX_OSERR, "Unable to apply rights for sandbox");
776 free((cap_ioctl_t *)cmds);
780 error = vm_reinit(ctx);
790 main(int argc, char *argv[])
792 int c, error, gdb_port, err, bvmcons;
793 int max_vcpus, mptgen, memflags;
801 progname = basename(argv[0]);
809 optstr = "abehuwxACHIPSWYp:g:c:s:m:l:U:";
810 while ((c = getopt(argc, argv, optstr)) != -1) {
822 if (pincpu_parse(optarg) != 0) {
823 errx(EX_USAGE, "invalid vcpu pinning "
824 "configuration '%s'", optarg);
828 guest_ncpus = atoi(optarg);
831 memflags |= VM_MEM_F_INCORE;
834 gdb_port = atoi(optarg);
837 if (lpc_device_parse(optarg) != 0) {
838 errx(EX_USAGE, "invalid lpc device "
839 "configuration '%s'", optarg);
843 if (pci_parse_slot(optarg) != 0)
848 memflags |= VM_MEM_F_WIRED;
851 error = vm_parse_memsize(optarg, &memsize);
853 errx(EX_USAGE, "invalid memsize '%s'", optarg);
856 guest_vmexit_on_hlt = 1;
860 * The "-I" option was used to add an ioapic to the
863 * An ioapic is now provided unconditionally for each
864 * virtual machine and this option is now deprecated.
868 guest_vmexit_on_pause = 1;
877 guest_uuid_str = optarg;
904 ctx = do_open(vmname);
906 if (guest_ncpus < 1) {
907 fprintf(stderr, "Invalid guest vCPUs (%d)\n", guest_ncpus);
911 max_vcpus = num_vcpus_allowed(ctx);
912 if (guest_ncpus > max_vcpus) {
913 fprintf(stderr, "%d vCPUs requested but only %d available\n",
914 guest_ncpus, max_vcpus);
918 fbsdrun_set_capabilities(ctx, BSP);
920 vm_set_memflags(ctx, memflags);
921 err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
923 fprintf(stderr, "Unable to setup memory (%d)\n", errno);
929 fprintf(stderr, "init_msr error %d", error);
939 rtc_init(ctx, rtc_localtime);
943 * Exit if a device emulation finds an error in its initilization
945 if (init_pci(ctx) != 0)
949 init_dbgport(gdb_port);
955 if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) {
956 fprintf(stderr, "ROM boot failed: unrestricted guest "
957 "capability not available\n");
960 error = vcpu_reset(ctx, BSP);
964 error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip);
968 * build the guest tables, MP etc.
971 error = mptable_build(ctx, guest_ncpus);
976 error = smbios_build(ctx);
980 error = acpi_build(ctx, guest_ncpus);
987 #ifndef WITHOUT_CAPSICUM
988 caph_cache_catpages();
990 if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1)
991 errx(EX_OSERR, "Unable to apply rights for sandbox");
993 if (cap_enter() == -1 && errno != ENOSYS)
994 errx(EX_OSERR, "cap_enter() failed");
998 * Change the proc title to include the VM name.
1000 setproctitle("%s", vmname);
1005 fbsdrun_addcpu(ctx, BSP, BSP, rip);
1008 * Head off to the main event dispatch loop