Page MenuHomeFreeBSD

D39979.id121570.diff
No OneTemporary

D39979.id121570.diff

diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c
--- a/usr.sbin/bhyve/basl.c
+++ b/usr.sbin/bhyve/basl.c
@@ -20,6 +20,7 @@
#include <vmmapi.h>
#include "basl.h"
+#include "config.h"
#include "qemu_loader.h"
struct basl_table_checksum {
@@ -58,6 +59,7 @@
basl_tables);
static struct qemu_loader *basl_loader;
+static bool load_into_memory;
static __inline uint64_t
basl_le_dec(void *pp, size_t len)
@@ -151,11 +153,21 @@
return (EFAULT);
}
+ /* Cause guest bios to copy the ACPI table into guest memory. */
+ BASL_EXEC(
+ qemu_fwcfg_add_file(table->fwcfg_name, table->len, table->data));
+ BASL_EXEC(qemu_loader_alloc(basl_loader, table->fwcfg_name,
+ table->alignment, QEMU_LOADER_ALLOC_HIGH));
+
+ if (!load_into_memory) {
+ return (0);
+ }
+
/*
- * Install ACPI tables directly in guest memory for use by guests which
- * do not boot via EFI. EFI ROMs provide a pointer to the firmware
- * generated ACPI tables instead, but it doesn't hurt to install the
- * tables always.
+ * Install ACPI tables directly in guest memory for use by
+ * guests which do not boot via EFI. EFI ROMs provide a pointer
+ * to the firmware generated ACPI tables instead, but it doesn't
+ * hurt to install the tables always.
*/
gva = vm_map_gpa(table->ctx, BHYVE_ACPI_BASE + table->off, table->len);
if (gva == NULL) {
@@ -166,12 +178,6 @@
}
memcpy(gva, table->data, table->len);
- /* Cause guest bios to copy the ACPI table into guest memory. */
- BASL_EXEC(
- qemu_fwcfg_add_file(table->fwcfg_name, table->len, table->data));
- BASL_EXEC(qemu_loader_alloc(basl_loader, table->fwcfg_name,
- table->alignment, QEMU_LOADER_ALLOC_HIGH));
-
return (0);
}
@@ -195,6 +201,14 @@
assert(checksum->start < table->len);
assert(checksum->start + len <= table->len);
+ /* Cause guest bios to patch the checksum. */
+ BASL_EXEC(qemu_loader_add_checksum(basl_loader,
+ table->fwcfg_name, checksum->off, checksum->start, len));
+
+ if (!load_into_memory) {
+ continue;
+ }
+
/*
* Install ACPI tables directly in guest memory for use by
* guests which do not boot via EFI. EFI ROMs provide a pointer
@@ -228,10 +242,6 @@
sum += *(gva + i);
}
*checksum_gva = -sum;
-
- /* Cause guest bios to patch the checksum. */
- BASL_EXEC(qemu_loader_add_checksum(basl_loader,
- table->fwcfg_name, checksum->off, checksum->start, len));
}
return (0);
@@ -276,6 +286,15 @@
return (EFAULT);
}
+ /* Cause guest bios to patch the pointer. */
+ BASL_EXEC(
+ qemu_loader_add_pointer(basl_loader, table->fwcfg_name,
+ src_table->fwcfg_name, pointer->off, pointer->size));
+
+ if (!load_into_memory) {
+ continue;
+ }
+
/*
* Install ACPI tables directly in guest memory for use by
* guests which do not boot via EFI. EFI ROMs provide a pointer
@@ -299,11 +318,6 @@
val = basl_le_dec(gva + pointer->off, pointer->size);
val += BHYVE_ACPI_BASE + src_table->off;
basl_le_enc(gva + pointer->off, val, pointer->size);
-
- /* Cause guest bios to patch the pointer. */
- BASL_EXEC(
- qemu_loader_add_pointer(basl_loader, table->fwcfg_name,
- src_table->fwcfg_name, pointer->off, pointer->size));
}
return (0);
@@ -336,6 +350,15 @@
return (EINVAL);
}
+ /*
+ * If we install ACPI tables by fwcfg and by memory, Windows will use
+ * the tables from memory. This can cause issues when using advanced
+ * features like a tpm log because we aren't able to patch the memory
+ * tables accordingly.
+ */
+ load_into_memory = get_config_bool_default("acpi_tables_in_memory",
+ true);
+
/*
* We have to install all tables before we can patch them. Therefore,
* use two loops. The first one installs all tables and the second one
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -122,6 +122,10 @@
Wire guest memory.
.It Va acpi_tables Ta bool Ta false Ta
Generate ACPI tables.
+.It Va acpi_tables_in_memory Ta bool Ta true Ta
+Bhyve always exposes ACPI tables by fwcfg.
+For backward compatibility bhyve copies them into the guest memory too.
+That's not recommended for several reasons and can be avoided by setting this config value to false.
.It Va destroy_on_poweroff Ta bool Ta false Ta
Destroy the VM on guest-initiated power-off.
.It Va gdb.address Ta string Ta localhost Ta
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
@@ -1231,6 +1231,7 @@
{
set_config_bool("acpi_tables", false);
+ set_config_bool("acpi_tables_in_memory", true);
set_config_value("memory.size", "256M");
set_config_bool("x86.strictmsr", true);
set_config_value("lpc.fwcfg", "bhyve");

File Metadata

Mime Type
text/plain
Expires
Fri, Jul 3, 6:20 AM (11 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34614150
Default Alt Text
D39979.id121570.diff (4 KB)

Event Timeline