aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorvin Köhne <corvink@FreeBSD.org>2022-06-21 08:35:40 +0000
committerCorvin Köhne <corvink@FreeBSD.org>2023-04-12 07:35:33 +0000
commit305edaa47918a559de46a5d72060644009f1875c (patch)
treee3053aec71eb2fc47ca74dbb26fcac9d2811f3d0
parentb6e67875a3e5bc706fe37565e464c61fe7833846 (diff)
downloadsrc-305edaa47918a559de46a5d72060644009f1875c.tar.gz
src-305edaa47918a559de46a5d72060644009f1875c.zip
bhyve: add QEMU_FWCFG_INDEX_MAX_CPUS item
Requested-by: coreboot Reviewed by: <If someone else reviewed your modification.> MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D39315
-rw-r--r--usr.sbin/bhyve/qemu_fwcfg.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c
index 3c7cd0f33224..ddd73d06d34d 100644
--- a/usr.sbin/bhyve/qemu_fwcfg.c
+++ b/usr.sbin/bhyve/qemu_fwcfg.c
@@ -44,6 +44,7 @@
#define QEMU_FWCFG_INDEX_SIGNATURE 0x00
#define QEMU_FWCFG_INDEX_ID 0x01
#define QEMU_FWCFG_INDEX_NB_CPUS 0x05
+#define QEMU_FWCFG_INDEX_MAX_CPUS 0x0F
#define QEMU_FWCFG_INDEX_FILE_DIR 0x19
#define QEMU_FWCFG_FIRST_FILE_INDEX 0x20
@@ -228,6 +229,24 @@ qemu_fwcfg_add_item_id(void)
}
static int
+qemu_fwcfg_add_item_max_cpus(void)
+{
+ uint16_t *fwcfg_max_cpus = calloc(1, sizeof(uint16_t));
+ if (fwcfg_max_cpus == NULL) {
+ return (ENOMEM);
+ }
+
+ /*
+ * We don't support cpu hotplug yet. For that reason, use guest_ncpus instead
+ * of maxcpus.
+ */
+ *fwcfg_max_cpus = htole16(guest_ncpus);
+
+ return (qemu_fwcfg_add_item(QEMU_FWCFG_ARCHITECTURE_GENERIC,
+ QEMU_FWCFG_INDEX_MAX_CPUS, sizeof(uint16_t), fwcfg_max_cpus));
+}
+
+static int
qemu_fwcfg_add_item_nb_cpus(void)
{
uint16_t *fwcfg_max_cpus = calloc(1, sizeof(uint16_t));
@@ -433,6 +452,10 @@ qemu_fwcfg_init(struct vmctx *const ctx)
warnx("%s: Unable to add nb_cpus item", __func__);
goto done;
}
+ if ((error = qemu_fwcfg_add_item_max_cpus()) != 0) {
+ warnx("%s: Unable to add max_cpus item", __func__);
+ goto done;
+ }
if ((error = qemu_fwcfg_add_item_file_dir()) != 0) {
warnx("%s: Unable to add file_dir item", __func__);
goto done;