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
This commit is contained in:
Corvin Köhne 2021-09-09 11:37:04 +02:00
parent a8a8e9af57
commit 16f23f7543
No known key found for this signature in database
GPG Key ID: D854DA56315E026A
2 changed files with 20 additions and 0 deletions

View File

@ -29,6 +29,7 @@ SRCS= \
crc16.c \
ctl_util.c \
ctl_scsi_all.c \
e820.c \
fwctl.c \
gdb.c \
hda_codec.c \

View File

@ -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();
}