The branch stable/13 has been updated by corvink:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=03d8264dcaf4c529011d2a4577a540ae4eb9c11f

commit 03d8264dcaf4c529011d2a4577a540ae4eb9c11f
Author:     Corvin Köhne <[email protected]>
AuthorDate: 2021-09-09 09:37:04 +0000
Commit:     Corvin Köhne <[email protected]>
CommitDate: 2023-05-08 08:21:32 +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
    
    (cherry picked from commit 16f23f75432915e64a34357e7d5f26bca82f8219)
---
 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 f5031a5bae07..c2b426359c22 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -28,6 +28,7 @@ SRCS= \
        console.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 dd30eb4405ef..fbc1fd99ea59 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"
@@ -1246,6 +1247,7 @@ main(int argc, char *argv[])
        int c, error;
        int max_vcpus, memflags;
        struct vmctx *ctx;
+       struct qemu_fwcfg_item *e820_fwcfg_item;
        uint64_t rip;
        size_t memsize;
        const char *optstr, *value, *vmname;
@@ -1478,6 +1480,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
         */
@@ -1572,6 +1579,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