Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
| Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| #include "config.h" | #include "config.h" | ||||
| #include "inout.h" | #include "inout.h" | ||||
| #include "debug.h" | #include "debug.h" | ||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| #include "amd64/e820.h" | #include "amd64/e820.h" | ||||
| #include "amd64/fwctl.h" | #include "amd64/fwctl.h" | ||||
| #endif | #endif | ||||
| #include "gdb.h" | #include "gdb.h" | ||||
| #include "ioapic.h" | |||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| #include "amd64/ioapic.h" | |||||
| #include "amd64/kernemu_dev.h" | #include "amd64/kernemu_dev.h" | ||||
| #endif | #endif | ||||
| #include "mem.h" | #include "mem.h" | ||||
| #include "mevent.h" | #include "mevent.h" | ||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| #include "amd64/mptbl.h" | #include "amd64/mptbl.h" | ||||
| #endif | #endif | ||||
| #include "pci_emul.h" | #include "pci_emul.h" | ||||
| #include "pci_irq.h" | #ifdef __amd64__ | ||||
| #include "pci_lpc.h" | #include "amd64/pci_irq.h" | ||||
| #include "amd64/pci_lpc.h" | |||||
| #endif | |||||
| #include "qemu_fwcfg.h" | #include "qemu_fwcfg.h" | ||||
| #include "smbiostbl.h" | #include "smbiostbl.h" | ||||
| #ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
| #include "snapshot.h" | #include "snapshot.h" | ||||
| #endif | #endif | ||||
| #include "tpm_device.h" | #include "tpm_device.h" | ||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| #include "amd64/rtc.h" | #include "amd64/rtc.h" | ||||
| ▲ Show 20 Lines • Show All 521 Lines • ▼ Show 20 Lines | |||||
| do_open(const char *vmname) | do_open(const char *vmname) | ||||
| { | { | ||||
| struct vmctx *ctx; | struct vmctx *ctx; | ||||
| int error; | int error; | ||||
| bool reinit, romboot; | bool reinit, romboot; | ||||
| reinit = romboot = false; | reinit = romboot = false; | ||||
| #ifdef __amd64__ | |||||
| if (lpc_bootrom()) | if (lpc_bootrom()) | ||||
| romboot = true; | romboot = true; | ||||
| #endif | |||||
| error = vm_create(vmname); | error = vm_create(vmname); | ||||
| if (error) { | if (error) { | ||||
| if (errno == EEXIST) { | if (errno == EEXIST) { | ||||
| if (romboot) { | if (romboot) { | ||||
| reinit = true; | reinit = true; | ||||
| } else { | } else { | ||||
| /* | /* | ||||
| ▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | case 'G': | ||||
| parse_gdb_options(optarg); | parse_gdb_options(optarg); | ||||
| break; | break; | ||||
| case 'k': | case 'k': | ||||
| parse_simple_config_file(optarg); | parse_simple_config_file(optarg); | ||||
| break; | break; | ||||
| case 'K': | case 'K': | ||||
| set_config_value("keyboard.layout", optarg); | set_config_value("keyboard.layout", optarg); | ||||
| break; | break; | ||||
| #ifdef __amd64__ | |||||
| case 'l': | case 'l': | ||||
| if (strncmp(optarg, "help", strlen(optarg)) == 0) { | if (strncmp(optarg, "help", strlen(optarg)) == 0) { | ||||
| lpc_print_supported_devices(); | lpc_print_supported_devices(); | ||||
| exit(0); | exit(0); | ||||
| } else if (lpc_device_parse(optarg) != 0) { | } else if (lpc_device_parse(optarg) != 0) { | ||||
| errx(EX_USAGE, "invalid lpc device " | errx(EX_USAGE, "invalid lpc device " | ||||
| "configuration '%s'", optarg); | "configuration '%s'", optarg); | ||||
| } | } | ||||
| break; | break; | ||||
| #endif | |||||
| #ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
| case 'r': | case 'r': | ||||
| restore_file = optarg; | restore_file = optarg; | ||||
| break; | break; | ||||
| #endif | #endif | ||||
| case 's': | case 's': | ||||
| if (strncmp(optarg, "help", strlen(optarg)) == 0) { | if (strncmp(optarg, "help", strlen(optarg)) == 0) { | ||||
| pci_print_supported_devices(); | pci_print_supported_devices(); | ||||
| ▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | #endif | ||||
| init_mem(guest_ncpus); | init_mem(guest_ncpus); | ||||
| init_inout(); | init_inout(); | ||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| kernemu_dev_init(); | kernemu_dev_init(); | ||||
| #endif | #endif | ||||
| init_bootrom(ctx); | init_bootrom(ctx); | ||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| atkbdc_init(ctx); | atkbdc_init(ctx); | ||||
| #endif | |||||
| pci_irq_init(ctx); | pci_irq_init(ctx); | ||||
| ioapic_init(ctx); | ioapic_init(ctx); | ||||
| #endif | |||||
| #ifdef __amd64__ | #ifdef __amd64__ | ||||
| rtc_init(ctx); | rtc_init(ctx); | ||||
| sci_init(ctx); | sci_init(ctx); | ||||
| #endif | #endif | ||||
| if (qemu_fwcfg_init(ctx) != 0) { | if (qemu_fwcfg_init(ctx) != 0) { | ||||
| fprintf(stderr, "qemu fwcfg initialization error"); | fprintf(stderr, "qemu fwcfg initialization error"); | ||||
| Show All 29 Lines | #endif | ||||
| * Initialize after PCI, to allow a bootrom file to reserve the high | * Initialize after PCI, to allow a bootrom file to reserve the high | ||||
| * region. | * region. | ||||
| */ | */ | ||||
| if (get_config_bool("acpi_tables")) | if (get_config_bool("acpi_tables")) | ||||
| vmgenc_init(ctx); | vmgenc_init(ctx); | ||||
| init_gdb(ctx); | init_gdb(ctx); | ||||
| #ifdef __amd64__ | |||||
| if (lpc_bootrom()) { | if (lpc_bootrom()) { | ||||
| if (vm_set_capability(bsp, VM_CAP_UNRESTRICTED_GUEST, 1)) { | if (vm_set_capability(bsp, VM_CAP_UNRESTRICTED_GUEST, 1)) { | ||||
| fprintf(stderr, "ROM boot failed: unrestricted guest " | fprintf(stderr, "ROM boot failed: unrestricted guest " | ||||
| "capability not available\n"); | "capability not available\n"); | ||||
| exit(4); | exit(4); | ||||
| } | } | ||||
| error = vcpu_reset(bsp); | error = vcpu_reset(bsp); | ||||
| assert(error == 0); | assert(error == 0); | ||||
| } | } | ||||
| #endif | |||||
| /* | /* | ||||
| * Add all vCPUs. | * Add all vCPUs. | ||||
| */ | */ | ||||
| for (int vcpuid = 0; vcpuid < guest_ncpus; vcpuid++) | for (int vcpuid = 0; vcpuid < guest_ncpus; vcpuid++) | ||||
| spinup_vcpu(&vcpu_info[vcpuid], vcpuid == BSP); | spinup_vcpu(&vcpu_info[vcpuid], vcpuid == BSP); | ||||
| #ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||