bhyverun.c (f927afc1a6fe8257e28d79e8bb77305c2958724a) bhyverun.c (4fe5b70cae6761b9205ff35b72ccfe60d7326301)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

84#include "acpi.h"
85#ifdef __amd64__
86#include "amd64/atkbdc.h"
87#endif
88#include "bootrom.h"
89#include "config.h"
90#include "inout.h"
91#include "debug.h"
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

84#include "acpi.h"
85#ifdef __amd64__
86#include "amd64/atkbdc.h"
87#endif
88#include "bootrom.h"
89#include "config.h"
90#include "inout.h"
91#include "debug.h"
92#include "e820.h"
93#ifdef __amd64__
92#ifdef __amd64__
93#include "amd64/e820.h"
94#include "amd64/fwctl.h"
95#endif
96#include "gdb.h"
97#include "ioapic.h"
98#include "kernemu_dev.h"
99#include "mem.h"
100#include "mevent.h"
94#include "amd64/fwctl.h"
95#endif
96#include "gdb.h"
97#include "ioapic.h"
98#include "kernemu_dev.h"
99#include "mem.h"
100#include "mevent.h"
101#include "mptbl.h"
101#ifdef __amd64__
102#include "amd64/mptbl.h"
103#endif
102#include "pci_emul.h"
103#include "pci_irq.h"
104#include "pci_lpc.h"
105#include "qemu_fwcfg.h"
106#include "smbiostbl.h"
107#ifdef BHYVE_SNAPSHOT
108#include "snapshot.h"
109#endif

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

1216
1217int
1218main(int argc, char *argv[])
1219{
1220 int c, error;
1221 int max_vcpus, memflags;
1222 struct vcpu *bsp;
1223 struct vmctx *ctx;
104#include "pci_emul.h"
105#include "pci_irq.h"
106#include "pci_lpc.h"
107#include "qemu_fwcfg.h"
108#include "smbiostbl.h"
109#ifdef BHYVE_SNAPSHOT
110#include "snapshot.h"
111#endif

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

1218
1219int
1220main(int argc, char *argv[])
1221{
1222 int c, error;
1223 int max_vcpus, memflags;
1224 struct vcpu *bsp;
1225 struct vmctx *ctx;
1224 struct qemu_fwcfg_item *e820_fwcfg_item;
1225 size_t memsize;
1226 const char *optstr, *value, *vmname;
1227#ifdef BHYVE_SNAPSHOT
1228 char *restore_file;
1229 struct restore_state rstate;
1230
1231 restore_file = NULL;
1232#endif

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

1344 set_config_bool("x86.strictmsr", false);
1345 break;
1346 case 'W':
1347 set_config_bool("virtio_msix", false);
1348 break;
1349 case 'x':
1350 set_config_bool("x86.x2apic", true);
1351 break;
1226 size_t memsize;
1227 const char *optstr, *value, *vmname;
1228#ifdef BHYVE_SNAPSHOT
1229 char *restore_file;
1230 struct restore_state rstate;
1231
1232 restore_file = NULL;
1233#endif

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

1345 set_config_bool("x86.strictmsr", false);
1346 break;
1347 case 'W':
1348 set_config_bool("virtio_msix", false);
1349 break;
1350 case 'x':
1351 set_config_bool("x86.x2apic", true);
1352 break;
1353#ifdef __amd64__
1352 case 'Y':
1353 set_config_bool("x86.mptable", false);
1354 break;
1354 case 'Y':
1355 set_config_bool("x86.mptable", false);
1356 break;
1357#endif
1355 case 'h':
1356 usage(0);
1357 default:
1358 usage(1);
1359 }
1360 }
1361 argc -= optind;
1362 argv += optind;

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

1471 }
1472
1473 if (qemu_fwcfg_add_file("opt/bhyve/hw.ncpu", sizeof(guest_ncpus),
1474 &guest_ncpus) != 0) {
1475 fprintf(stderr, "Could not add qemu fwcfg opt/bhyve/hw.ncpu");
1476 exit(4);
1477 }
1478
1358 case 'h':
1359 usage(0);
1360 default:
1361 usage(1);
1362 }
1363 }
1364 argc -= optind;
1365 argv += optind;

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

1474 }
1475
1476 if (qemu_fwcfg_add_file("opt/bhyve/hw.ncpu", sizeof(guest_ncpus),
1477 &guest_ncpus) != 0) {
1478 fprintf(stderr, "Could not add qemu fwcfg opt/bhyve/hw.ncpu");
1479 exit(4);
1480 }
1481
1482#ifdef __amd64__
1479 if (e820_init(ctx) != 0) {
1480 fprintf(stderr, "Unable to setup E820");
1481 exit(4);
1482 }
1483 if (e820_init(ctx) != 0) {
1484 fprintf(stderr, "Unable to setup E820");
1485 exit(4);
1486 }
1487#endif
1483
1484 /*
1485 * Exit if a device emulation finds an error in its initialization
1486 */
1487 if (init_pci(ctx) != 0) {
1488 perror("device emulation initialization error");
1489 exit(4);
1490 }

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

1547 fprintf(stdout, "Resuming pci devs...\r\n");
1548 if (vm_resume_devices() != 0) {
1549 fprintf(stderr, "Failed to resume PCI device state.\n");
1550 exit(1);
1551 }
1552 }
1553#endif
1554
1488
1489 /*
1490 * Exit if a device emulation finds an error in its initialization
1491 */
1492 if (init_pci(ctx) != 0) {
1493 perror("device emulation initialization error");
1494 exit(4);
1495 }

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

1552 fprintf(stdout, "Resuming pci devs...\r\n");
1553 if (vm_resume_devices() != 0) {
1554 fprintf(stderr, "Failed to resume PCI device state.\n");
1555 exit(1);
1556 }
1557 }
1558#endif
1559
1555 /*
1556 * build the guest tables, MP etc.
1557 */
1560#ifdef __amd64__
1558 if (get_config_bool_default("x86.mptable", true)) {
1559 error = mptable_build(ctx, guest_ncpus);
1560 if (error) {
1561 perror("error to build the guest tables");
1562 exit(4);
1563 }
1564 }
1561 if (get_config_bool_default("x86.mptable", true)) {
1562 error = mptable_build(ctx, guest_ncpus);
1563 if (error) {
1564 perror("error to build the guest tables");
1565 exit(4);
1566 }
1567 }
1568#endif
1565
1566 error = smbios_build(ctx);
1567 if (error != 0)
1568 exit(4);
1569
1570 if (get_config_bool("acpi_tables")) {
1571 error = acpi_build(ctx, guest_ncpus);
1572 assert(error == 0);
1573 }
1574
1569
1570 error = smbios_build(ctx);
1571 if (error != 0)
1572 exit(4);
1573
1574 if (get_config_bool("acpi_tables")) {
1575 error = acpi_build(ctx, guest_ncpus);
1576 assert(error == 0);
1577 }
1578
1575 e820_fwcfg_item = e820_get_fwcfg_item();
1576 if (e820_fwcfg_item == NULL) {
1577 fprintf(stderr, "invalid e820 table");
1579#ifdef __amd64__
1580 error = e820_finalize();
1581 if (error != 0)
1578 exit(4);
1582 exit(4);
1579 }
1580 if (qemu_fwcfg_add_file("etc/e820", e820_fwcfg_item->size,
1581 e820_fwcfg_item->data) != 0) {
1582 fprintf(stderr, "could not add qemu fwcfg etc/e820");
1583 exit(4);
1584 }
1585 free(e820_fwcfg_item);
1583#endif
1586
1587#ifdef __amd64__
1588 if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0) {
1589 fwctl_init();
1590 }
1591#endif
1592
1593 /*

--- 44 unchanged lines hidden ---
1584
1585#ifdef __amd64__
1586 if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0) {
1587 fwctl_init();
1588 }
1589#endif
1590
1591 /*

--- 44 unchanged lines hidden ---