diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -28,7 +28,6 @@ crc16.c \ ctl_scsi_all.c \ ctl_util.c \ - e820.c \ gdb.c \ hda_codec.c \ inout.c \ @@ -37,7 +36,6 @@ kernemu_dev.c \ mem.c \ mevent.c \ - mptbl.c \ net_backends.c \ net_utils.c \ pci_ahci.c \ diff --git a/usr.sbin/bhyve/amd64/Makefile.inc b/usr.sbin/bhyve/amd64/Makefile.inc --- a/usr.sbin/bhyve/amd64/Makefile.inc +++ b/usr.sbin/bhyve/amd64/Makefile.inc @@ -1,6 +1,8 @@ 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 @@ -89,8 +89,8 @@ #include "config.h" #include "inout.h" #include "debug.h" -#include "e820.h" #ifdef __amd64__ +#include "amd64/e820.h" #include "amd64/fwctl.h" #endif #include "gdb.h" @@ -98,7 +98,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" @@ -1221,7 +1223,6 @@ int max_vcpus, memflags; struct vcpu *bsp; struct vmctx *ctx; - struct qemu_fwcfg_item *e820_fwcfg_item; size_t memsize; const char *optstr, *value, *vmname; #ifdef BHYVE_SNAPSHOT @@ -1349,9 +1350,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: @@ -1476,10 +1479,12 @@ exit(4); } +#ifdef __amd64__ if (e820_init(ctx) != 0) { fprintf(stderr, "Unable to setup E820"); exit(4); } +#endif /* * Exit if a device emulation finds an error in its initialization @@ -1552,9 +1557,7 @@ } #endif - /* - * build the guest tables, MP etc. - */ +#ifdef __amd64__ if (get_config_bool_default("x86.mptable", true)) { error = mptable_build(ctx, guest_ncpus); if (error) { @@ -1562,6 +1565,7 @@ exit(4); } } +#endif error = smbios_build(ctx); if (error != 0) @@ -1572,17 +1576,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/pci_gvt-d.c b/usr.sbin/bhyve/pci_gvt-d.c --- a/usr.sbin/bhyve/pci_gvt-d.c +++ b/usr.sbin/bhyve/pci_gvt-d.c @@ -17,7 +17,7 @@ #include #include -#include "e820.h" +#include "amd64/e820.h" #include "pci_gvt-d-opregion.h" #include "pci_passthru.h" 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 @@ -84,7 +84,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"