The branch main has been updated by corvink:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=16f23f75432915e64a34357e7d5f26bca82f8219

commit 16f23f75432915e64a34357e7d5f26bca82f8219
Author:     Corvin Köhne <corv...@freebsd.org>
AuthorDate: 2021-09-09 09:37:04 +0000
Commit:     Corvin Köhne <corv...@freebsd.org>
CommitDate: 2023-04-26 07:58:37 +0000

    bhyve: pass E820 table to guest
    
    E820 table will be used to report valid RAM ranges and reserve special
    memory areas like graphics memory for GPU passthrough.
    
    Reviewed by:            markj
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D39550
---
 usr.sbin/bhyve/Makefile   |  1 +
 usr.sbin/bhyve/bhyverun.c | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index 7f67c5bf0489..02a1f67d66eb 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -29,6 +29,7 @@ SRCS= \
        crc16.c                 \
        ctl_util.c              \
        ctl_scsi_all.c          \
+       e820.c                  \
        fwctl.c                 \
        gdb.c                   \
        hda_codec.c             \
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index d447a9ee60e4..627a86d71e0e 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -91,6 +91,7 @@ __FBSDID("$FreeBSD$");
 #include "config.h"
 #include "inout.h"
 #include "debug.h"
+#include "e820.h"
 #include "fwctl.h"
 #include "gdb.h"
 #include "ioapic.h"
@@ -1242,6 +1243,7 @@ main(int argc, char *argv[])
        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;
@@ -1486,6 +1488,11 @@ main(int argc, char *argv[])
                exit(4);
        }
 
+       if (e820_init(ctx) != 0) {
+               fprintf(stderr, "Unable to setup E820");
+               exit(4);
+       }
+
        /*
         * Exit if a device emulation finds an error in its initilization
         */
@@ -1576,6 +1583,18 @@ main(int argc, char *argv[])
                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");
+               exit(4);
+       }
+       free(e820_fwcfg_item);
+
        if (lpc_bootrom() && strcmp(lpc_fwcfg(), "bhyve") == 0) {
                fwctl_init();
        }

Reply via email to