From nobody Mon Jun 20 15:36:28 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6001D86C93A; Mon, 20 Jun 2022 15:36:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LRYf42Bkyz4mkr; Mon, 20 Jun 2022 15:36:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655739388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e6T/vCgCGLMsEYAScjiTll5ho008wJJtIxxrL4Ud7CE=; b=jLVEks6yCZtKK3UjtdOvK+GWN+UjBxNAz5eidkqzShKDzjwR1E+ZLz+j7Ft/6CkT/dCNtp 9bfQOOOlFO1Lw3DqQZUH9siZ6XMCaMJ1wFKQ8vnrUoM6hkK12FgVqEXCiMwH1XhurX64JH HKVoK9RmRTfJPwdw0TnPfTdrhCT7Nq+vqVoRxKsDC06AWa+G8t2BqPKOfFVRWGCLZ7Hn5b KGJzk0+y0bwQiS9Cd77/E6lulKijWQXNnSZIOLETlO85vay+MTUvWQCz/3/pTEUN0C80wu Hf0ttVknu9Pu1NJ/MB5hFP7x9miTnJugtSVznjoorvQCB0p8YhnMaUOp+dKxmg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2BA971FEB2; Mon, 20 Jun 2022 15:36:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25KFaSuL031507; Mon, 20 Jun 2022 15:36:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25KFaS6H031506; Mon, 20 Jun 2022 15:36:28 GMT (envelope-from git) Date: Mon, 20 Jun 2022 15:36:28 GMT Message-Id: <202206201536.25KFaS6H031506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 2131fdf0bac1 - stable/13 - bhyve: use bhyve_config for SMBIOS strings List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2131fdf0bac16be8df9583b0d52e1183f822bce8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655739388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e6T/vCgCGLMsEYAScjiTll5ho008wJJtIxxrL4Ud7CE=; b=ilrWWIz+gUdCD84QL5fWzEpLGG9RGdeLSE3R7FEXd+3oXR+4C/ehD5lF/RMLxHunhekZHM C/Oo8scQTuFo00leps96HwnYeMgAJXKZ4VNKgTHXX5iJ0rnvyJegVOo+SJLq7siYSigA5m SE9gQ1WiHUBjVNY/RO72vNRLYIkdBV8Ei0FoVoX50RWZPXVJvsPlRL/c5P+SeLMO/n4MyO q17WeB8woUMgEHka0TM6Se19GO0z6077i1KB6QERjwP1AQoTRDjTWRtA8f1xVsqp/2Rl6z ingKqpahor+qIC4V9tSGJXcFMwaBS24X5ioDxbZOnxCok+WP7/tfX5rOhhoopw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655739388; a=rsa-sha256; cv=none; b=CortHIFFQjxfNPXX7XU3KoyO9h9hrt6npZjjCTihesQlEguHjB0PcFu4lhV3YdmKlRUMfO odcsg/NLQ1xCbReNUS3d6SgKE55BduVxRv9IJd8f2j4xPXoJd4bgxEd4yOKUpgNP/mucv7 QeC4GTlmgRj9x/qxaR8MXEDp7OuHkZRNMEizIjSRrZyH0pRf8FKbwzrvvaMpW9Hl0jt4VS IPiWFYXvpJUEwdI6kAPK7TChrSqh6wPFEqdb49gNwhoEyaO9EVM0OMrUlaWIeqtNLCG+8r asjSmnFvtxtv76wPUOqjftlsBOjxd2R05+7A5hZcQS7jwnmHwu4Wz8O+dw6qaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=2131fdf0bac16be8df9583b0d52e1183f822bce8 commit 2131fdf0bac16be8df9583b0d52e1183f822bce8 Author: Corvin Köhne AuthorDate: 2022-05-30 08:01:36 +0000 Commit: Emmanuel Vadot CommitDate: 2022-06-20 15:05:36 +0000 bhyve: use bhyve_config for SMBIOS strings Some software uses SMBIOS entries to identify the system on which it's running. In order to make it possible to use such software inside a VM, SMBIOS entries should be configurable. Therefore, bhyve_config can be used. While only a few SMBIOS entries might be of interest, it makes sense that all SMBIOS entries are configurable. This way all SMBIOS tables are build the same way and there's no special handling for some tables. Reviewed by: jhb Sponsored by: Beckhoff Automation GmbH & Co. KG MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D34465 (cherry picked from commit 8284799a232941c164acec425a881b5abb976751) --- usr.sbin/bhyve/bhyve_config.5 | 46 ++++++++++++++ usr.sbin/bhyve/smbiostbl.c | 136 +++++++++++++++++++++++------------------- 2 files changed, 121 insertions(+), 61 deletions(-) diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index 77d0bbaedaca..fbbea50bc7be 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -150,6 +150,52 @@ then .Xr bhyve 8 will write all of its configuration variables to stdout and exit. No VM will be started. +.It Va bios.vendor Ta string Ta BHYVE Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va bios.version Ta string Ta 14.0 Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va bios.release_date Ta string Ta 10/17/2021 Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va system.family_name Ta string Ta Virtual Machine Ta +Family the computer belongs to. +This value is used for the guest's System Management BIOS System Information structure. +.It Va system.manufacturer Ta string Ta FreeBSD Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va system.product_name Ta string Ta BHYVE Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va system.serial_number Ta string Ta None Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va system.sku Ta string Ta None Ta +Stock keeping unit of the computer. +It's also called product ID or purchase order number. +This value is used for the guest's System Management BIOS System Information structure. +.It Va system.version Ta string Ta 1.0 Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va board.manufacturer Ta string Ta FreeBSD Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va board.product_name Ta string Ta BHYVE Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va board.version Ta string Ta 1.0 Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va board.serial_number Ta string Ta None Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va board.asset_tag Ta string Ta None Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va board.location Ta string Ta None Ta +Describes the board's location within the chassis. +This value is used for the guest's System Management BIOS System Information structure. +.It Va chassis.manufacturer Ta string Ta FreeBSD Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va chassis.version Ta string Ta 1.0 Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va chassis.serial_number Ta string Ta None Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va chassis.asset_tag Ta string Ta None Ta +This value is used for the guest's System Management BIOS System Information structure. +.It Va chassis.sku Ta string Ta None Ta +Stock keeping unit of the chassis. +It's also called product ID or purchase order number. +This value is used for the guest's System Management BIOS System Information structure. .El .Ss x86-Specific Settings .Bl -column "x86.vmexit_on_pause" "integer" "Default" diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c index 2b12c0b272b0..9bb7b569eda4 100644 --- a/usr.sbin/bhyve/smbiostbl.c +++ b/usr.sbin/bhyve/smbiostbl.c @@ -76,13 +76,18 @@ struct smbios_structure { uint16_t handle; } __packed; +struct smbios_string { + const char *node; + const char *value; +}; + typedef int (*initializer_func_t)(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); struct smbios_template_entry { struct smbios_structure *entry; - const char **strings; + struct smbios_string *strings; initializer_func_t initializer; }; @@ -350,11 +355,11 @@ struct smbios_table_type0 smbios_type0_template = { 0xff /* embedded controller firmware minor release */ }; -const char *smbios_type0_strings[] = { - "BHYVE", /* vendor string */ - FIRMWARE_VERSION, /* bios version string */ - FIRMWARE_RELEASE_DATE, /* bios release date string */ - NULL +struct smbios_string smbios_type0_strings[] = { + { "bios.vendor", "BHYVE" }, /* vendor string */ + { "bios.version", FIRMWARE_VERSION }, /* bios version string */ + { "bios.release_date", FIRMWARE_RELEASE_DATE }, /* bios release date string */ + { 0 } }; struct smbios_table_type1 smbios_type1_template = { @@ -370,17 +375,17 @@ struct smbios_table_type1 smbios_type1_template = { }; static int smbios_type1_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); -const char *smbios_type1_strings[] = { - "FreeBSD", /* manufacturer string */ - "BHYVE", /* product name string */ - "1.0", /* version string */ - "None", /* serial number string */ - "None", /* sku string */ - "Virtual Machine", /* family name string */ - NULL +struct smbios_string smbios_type1_strings[] = { + { "system.manufacturer", "FreeBSD" }, /* manufacturer string */ + { "system.product_name", "BHYVE" }, /* product string */ + { "system.version", "1.0" }, /* version string */ + { "system.serial_number", "None" }, /* serial number string */ + { "system.sku", "None" }, /* sku string */ + { "system.family_name", "Virtual Machine" }, /* family string */ + { 0 } }; struct smbios_table_type2 smbios_type2_template = { @@ -397,14 +402,14 @@ struct smbios_table_type2 smbios_type2_template = { 0 }; -const char *smbios_type2_strings[] = { - "FreeBSD", /* manufacturer string */ - "BHYVE", /* product name string */ - "1.0", /* version string */ - "None", /* serial number string */ - "None", /* asset tag string */ - "None", /* location string */ - NULL +struct smbios_string smbios_type2_strings[] = { + { "board.manufacturer", "FreeBSD" }, /* manufacturer string */ + { "board.product_name", "BHYVE" }, /* product name string */ + { "board.version", "1.0" }, /* version string */ + { "board.serial_number", "None" }, /* serial number string */ + { "board.asset_tag", "None" }, /* asset tag string */ + { "board.location", "None" }, /* location string */ + { 0 } }; struct smbios_table_type3 smbios_type3_template = { @@ -426,13 +431,13 @@ struct smbios_table_type3 smbios_type3_template = { 5 /* sku number string */ }; -const char *smbios_type3_strings[] = { - "FreeBSD", /* manufacturer string */ - "1.0", /* version string */ - "None", /* serial number string */ - "None", /* asset tag string */ - "None", /* sku number string */ - NULL +struct smbios_string smbios_type3_strings[] = { + { "chassis.manufacturer", "FreeBSD" }, /* manufacturer string */ + { "chassis.version", "1.0" }, /* version string */ + { "chassis.serial_number", "None" }, /* serial number string */ + { "chassis.asset_tag", "None" }, /* asset tag string */ + { "chassis.sku", "None" }, /* sku number string */ + { 0 } }; struct smbios_table_type4 smbios_type4_template = { @@ -462,18 +467,18 @@ struct smbios_table_type4 smbios_type4_template = { SMBIOS_PRF_OTHER }; -const char *smbios_type4_strings[] = { - " ", /* socket designation string */ - " ", /* manufacturer string */ - " ", /* version string */ - "None", /* serial number string */ - "None", /* asset tag string */ - "None", /* part number string */ - NULL +struct smbios_string smbios_type4_strings[] = { + { NULL, " " }, /* socket designation string */ + { NULL, " " }, /* manufacturer string */ + { NULL, " " }, /* version string */ + { NULL, "None" }, /* serial number string */ + { NULL, "None" }, /* asset tag string */ + { NULL, "None" }, /* part number string */ + { 0 } }; static int smbios_type4_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); struct smbios_table_type16 smbios_type16_template = { @@ -488,7 +493,7 @@ struct smbios_table_type16 smbios_type16_template = { }; static int smbios_type16_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); struct smbios_table_type17 smbios_type17_template = { @@ -517,18 +522,18 @@ struct smbios_table_type17 smbios_type17_template = { 0 /* configured voltage in mv (0=unknown) */ }; -const char *smbios_type17_strings[] = { - " ", /* device locator string */ - " ", /* physical bank locator string */ - " ", /* manufacturer string */ - "None", /* serial number string */ - "None", /* asset tag string */ - "None", /* part number string */ - NULL +struct smbios_string smbios_type17_strings[] = { + { NULL, " " }, /* device locator string */ + { NULL, " " }, /* physical bank locator string */ + { NULL, " " }, /* manufacturer string */ + { NULL, "None" }, /* serial number string */ + { NULL, "None" }, /* asset tag string */ + { NULL, "None" }, /* part number string */ + { 0 } }; static int smbios_type17_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); struct smbios_table_type19 smbios_type19_template = { @@ -542,7 +547,7 @@ struct smbios_table_type19 smbios_type19_template = { }; static int smbios_type19_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); struct smbios_table_type32 smbios_type32_template = { @@ -556,7 +561,7 @@ struct smbios_table_type127 smbios_type127_template = { }; static int smbios_generic_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size); static struct smbios_template_entry smbios_template[] = { @@ -598,7 +603,7 @@ static uint16_t type16_handle; static int smbios_generic_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size) { struct smbios_structure *entry; @@ -610,11 +615,20 @@ smbios_generic_initializer(struct smbios_structure *template_entry, if (template_strings != NULL) { int i; - for (i = 0; template_strings[i] != NULL; i++) { + for (i = 0; template_strings[i].value != NULL; i++) { const char *string; int len; - string = template_strings[i]; + if (template_strings[i].node == NULL) { + string = template_strings[i].value; + } else { + set_config_value_if_unset( + template_strings[i].node, + template_strings[i].value); + string = get_config_value( + template_strings[i].node); + } + len = strlen(string) + 1; memcpy(curaddr, string, len); curaddr += len; @@ -636,7 +650,7 @@ smbios_generic_initializer(struct smbios_structure *template_entry, static int smbios_type1_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size) { struct smbios_table_type1 *type1; @@ -692,7 +706,7 @@ smbios_type1_initializer(struct smbios_structure *template_entry, static int smbios_type4_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size) { int i; @@ -734,7 +748,7 @@ smbios_type4_initializer(struct smbios_structure *template_entry, static int smbios_type16_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size) { struct smbios_table_type16 *type16; @@ -751,7 +765,7 @@ smbios_type16_initializer(struct smbios_structure *template_entry, static int smbios_type17_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size) { struct smbios_table_type17 *type17; @@ -795,7 +809,7 @@ smbios_type17_initializer(struct smbios_structure *template_entry, static int smbios_type19_initializer(struct smbios_structure *template_entry, - const char **template_strings, char *curaddr, char **endaddr, + struct smbios_string *template_strings, char *curaddr, char **endaddr, uint16_t *n, uint16_t *size) { struct smbios_table_type19 *type19; @@ -892,7 +906,7 @@ smbios_build(struct vmctx *ctx) maxssize = 0; for (i = 0; smbios_template[i].entry != NULL; i++) { struct smbios_structure *entry; - const char **strings; + struct smbios_string *strings; initializer_func_t initializer; char *endaddr; uint16_t size;