diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -19,8 +19,7 @@ BHYVE_SYSDIR?=${SRCTOP} -SRCS= \ - acpi_device.c \ +SRCS= acpi_device.c \ acpi.c \ audio.c \ basl.c \ @@ -33,7 +32,6 @@ crc16.c \ ctl_util.c \ ctl_scsi_all.c \ - e820.c \ gdb.c \ hda_codec.c \ inout.c \ @@ -41,7 +39,6 @@ kernemu_dev.c \ mem.c \ mevent.c \ - mptbl.c \ net_backends.c \ net_utils.c \ pci_ahci.c \ @@ -84,7 +81,9 @@ .if ${MACHINE_CPUARCH} == "amd64" SRCS+= atkbdc.c \ + e820.c \ fwctl.c \ + mptbl.c \ post.c \ ps2kbd.c \ ps2mouse.c \ diff --git a/usr.sbin/bhyve/e820.h b/usr.sbin/bhyve/amd64/e820.h rename from usr.sbin/bhyve/e820.h rename to usr.sbin/bhyve/amd64/e820.h --- a/usr.sbin/bhyve/e820.h +++ b/usr.sbin/bhyve/amd64/e820.h @@ -41,5 +41,5 @@ const uint64_t alignment, const enum e820_memory_type type, const enum e820_allocation_strategy strategy); void e820_dump_table(void); -struct qemu_fwcfg_item *e820_get_fwcfg_item(void); int e820_init(struct vmctx *const ctx); +int e820_finalize(void); diff --git a/usr.sbin/bhyve/e820.c b/usr.sbin/bhyve/amd64/e820.c rename from usr.sbin/bhyve/e820.c rename to usr.sbin/bhyve/amd64/e820.c --- a/usr.sbin/bhyve/e820.c +++ b/usr.sbin/bhyve/amd64/e820.c @@ -105,7 +105,7 @@ } } -struct qemu_fwcfg_item * +static struct qemu_fwcfg_item * e820_get_fwcfg_item(void) { struct qemu_fwcfg_item *fwcfg_item; @@ -466,3 +466,25 @@ return (0); } + +int +e820_finalize(void) +{ + struct qemu_fwcfg_item *e820_fwcfg_item; + int error; + + e820_fwcfg_item = e820_get_fwcfg_item(); + if (e820_fwcfg_item == NULL) { + warnx("invalid e820 table"); + return (ENOMEM); + } + error = qemu_fwcfg_add_file("etc/e820", + e820_fwcfg_item->size, e820_fwcfg_item->data); + if (error != 0) { + warnx("could not add qemu fwcfg etc/e820"); + return (error); + } + free(e820_fwcfg_item); + + return (0); +} diff --git a/usr.sbin/bhyve/mptbl.h b/usr.sbin/bhyve/amd64/mptbl.h rename from usr.sbin/bhyve/mptbl.h rename to usr.sbin/bhyve/amd64/mptbl.h diff --git a/usr.sbin/bhyve/mptbl.c b/usr.sbin/bhyve/amd64/mptbl.c rename from usr.sbin/bhyve/mptbl.c rename to usr.sbin/bhyve/amd64/mptbl.c diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -93,8 +93,8 @@ #include "config.h" #include "inout.h" #include "debug.h" -#include "e820.h" #ifdef __amd64__ +#include "e820.h" #include "amd64/fwctl.h" #endif #include "gdb.h" @@ -102,7 +102,9 @@ #include "kernemu_dev.h" #include "mem.h" #include "mevent.h" -#include "mptbl.h" +#ifdef __amd64__ +#include "amd64/mptbl.h" +#endif #include "pci_emul.h" #include "pci_irq.h" #include "pci_lpc.h" @@ -1248,7 +1250,6 @@ int max_vcpus, memflags; struct vcpu *bsp; struct vmctx *ctx; - struct qemu_fwcfg_item *e820_fwcfg_item; uint64_t rip; size_t memsize; const char *optstr, *value, *vmname; @@ -1373,9 +1374,11 @@ case 'x': set_config_bool("x86.x2apic", true); break; +#ifdef __amd64__ case 'Y': set_config_bool("x86.mptable", false); break; +#endif case 'h': usage(0); default: @@ -1575,9 +1578,7 @@ error = vm_get_register(bsp, VM_REG_GUEST_RIP, &rip); assert(error == 0); - /* - * build the guest tables, MP etc. - */ +#ifdef __amd64__ if (get_config_bool_default("x86.mptable", true)) { error = mptable_build(ctx, guest_ncpus); if (error) { @@ -1585,6 +1586,7 @@ exit(4); } } +#endif error = smbios_build(ctx); if (error != 0) @@ -1595,17 +1597,11 @@ assert(error == 0); } - e820_fwcfg_item = e820_get_fwcfg_item(); - if (e820_fwcfg_item == NULL) { - fprintf(stderr, "invalid e820 table"); - exit(4); - } - if (qemu_fwcfg_add_file("etc/e820", e820_fwcfg_item->size, - e820_fwcfg_item->data) != 0) { - fprintf(stderr, "could not add qemu fwcfg etc/e820"); +#ifdef __amd64__ + error = e820_finalize(); + if (error != 0) exit(4); - } - free(e820_fwcfg_item); +#endif #ifdef __amd64__ if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0) { diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -86,7 +86,6 @@ #include "ioapic.h" #include "mem.h" #include "mevent.h" -#include "mptbl.h" #include "pci_emul.h" #include "pci_irq.h" #include "pci_lpc.h"