From nobody Sun Apr 28 15:11:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599584241; cv=none; d=zohomail.com; s=zohoarc; b=mWlke2mcK28DlLkpPX17nCTi7chp6vd3TOcIuiSlcI1HB1zJLTGOpZFl9WT7nzsieNXnWh3ZauGjEROx350w214t34zMYxe9IPfoOMXDqmqIDkbELQC69E9k50/AFD4T7tIq0OJgXA3oSZdnTs7ZMrfIK/PSCtwicAoNuTIwfCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599584241; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DR8fEE6Cder7F+A8nXVYFkHXNu1LdDIWy3p/lb+xK3U=; b=FU45jFB+zEI6bErJZKYfzRRakH0zQWG2gX59RZ91YsSr1wP9L21G5RxdhrmaPG0sAQo1vHtGt8vbBjhwwFjreXWeJZy1svtqGM4J6XUldK6EcLd5RGng1WAeHP1s3Hz7xr95L3ORvYqUkWlRfh/w3PWzwPMHdQjFaS7xMumGLRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599584241549649.07216560492; Tue, 8 Sep 2020 09:57:21 -0700 (PDT) Received: from localhost ([::1]:44698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFgvo-0002KZ-57 for importer@patchew.org; Tue, 08 Sep 2020 12:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFgtc-0006e7-V9 for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFgtZ-00048Q-EO for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-fauQwu7bM0Co-CCXqAjQbA-1; Tue, 08 Sep 2020 12:54:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 372641084D73; Tue, 8 Sep 2020 16:54:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-113-154.ams2.redhat.com [10.36.113.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 373A160C0F; Tue, 8 Sep 2020 16:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599584100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DR8fEE6Cder7F+A8nXVYFkHXNu1LdDIWy3p/lb+xK3U=; b=FiL0GEtwceO7SLDt4dT0rCO4lpgyBDMeRowpdLbHNr3dGkBqcPLoduVeHtDODwYnkbWmx+ 07An09ZiuDaeVRPLATjZbB3eTfEOt8NslzaCKcsNPLvunAhLr9qk+oKt8Bp592788ljtBz eAUEhQsE1CnX6kGSvcrTy6GVL2wNVx4= X-MC-Unique: fauQwu7bM0Co-CCXqAjQbA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/5] hw/smbios: support loading OEM strings values from a file Date: Tue, 8 Sep 2020 17:54:34 +0100 Message-Id: <20200908165438.1008942-2-berrange@redhat.com> In-Reply-To: <20200908165438.1008942-1-berrange@redhat.com> References: <20200908165438.1008942-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/08 02:10:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Laszlo Ersek , Markus Armbruster , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Some applications want to pass quite large values for the OEM strings entries. Rather than having huge strings on the command line, it would be better to load them from a file, as supported with -fw_cfg. This introduces the "valuefile" parameter allowing for: $ echo -n "thisthing" > mydata.txt $ qemu-system-x86_64 \ -smbios type=3D11,value=3Dsomething \ -smbios type=3D11,valuefile=3Dmydata.txt \ -smbios type=3D11,value=3Dsomemore \ ...other args... Now in the guest $ dmidecide -t 11 Getting SMBIOS data from sysfs. SMBIOS 2.8 present. Handle 0x0E00, DMI type 11, 5 bytes OEM Strings String 1: something String 2: thisthing String 3: somemore Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/smbios/smbios.c | 72 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 7cc950b41c..8450fad285 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -110,7 +110,7 @@ static struct { =20 static struct { size_t nvalues; - const char **values; + char **values; } type11; =20 static struct { @@ -314,6 +314,11 @@ static const QemuOptDesc qemu_smbios_type11_opts[] =3D= { .type =3D QEMU_OPT_STRING, .help =3D "OEM string data", }, + { + .name =3D "path", + .type =3D QEMU_OPT_STRING, + .help =3D "OEM string data from file", + }, }; =20 static const QemuOptDesc qemu_smbios_type17_opts[] =3D { @@ -641,6 +646,8 @@ static void smbios_build_type_11_table(void) =20 for (i =3D 0; i < type11.nvalues; i++) { SMBIOS_TABLE_SET_STR_LIST(11, type11.values[i]); + g_free(type11.values[i]); + type11.values[i] =3D NULL; } =20 SMBIOS_BUILD_TABLE_POST; @@ -940,9 +947,8 @@ static void save_opt(const char **dest, QemuOpts *opts,= const char *name) =20 =20 struct opt_list { - const char *name; size_t *ndest; - const char ***dest; + char ***dest; }; =20 static int save_opt_one(void *opaque, @@ -951,23 +957,61 @@ static int save_opt_one(void *opaque, { struct opt_list *opt =3D opaque; =20 - if (!g_str_equal(name, opt->name)) { - return 0; + if (g_str_equal(name, "path")) { + g_autoptr(GByteArray) data =3D g_byte_array_new(); + g_autofree char *buf =3D g_new(char, 4096); + ssize_t ret; + int fd =3D qemu_open(value, O_RDONLY); + if (fd < 0) { + error_setg(errp, "Unable to open %s: %s", value, strerror(errn= o)); + return -1; + } + + while (1) { + ret =3D read(fd, buf, 4096); + if (ret =3D=3D 0) { + break; + } + if (ret < 0) { + error_setg(errp, "Unable to read from %s: %s", + value, strerror(errno)); + return -1; + } + if (memchr(buf, '\0', ret)) { + error_setg(errp, "NUL in OEM strings value in %s", value); + return -1; + } + g_byte_array_append(data, (guint8 *)buf, ret); + } + + close(fd); + + *opt->dest =3D g_renew(char *, *opt->dest, (*opt->ndest) + 1); + (*opt->dest)[*opt->ndest] =3D (char *)g_byte_array_free(data, FAL= SE); + (*opt->ndest)++; + data =3D NULL; + } else if (g_str_equal(name, "value")) { + *opt->dest =3D g_renew(char *, *opt->dest, (*opt->ndest) + 1); + (*opt->dest)[*opt->ndest] =3D g_strdup(value); + (*opt->ndest)++; + } else if (!g_str_equal(name, "type")) { + error_setg(errp, "Unexpected option %s", name); + return -1; } =20 - *opt->dest =3D g_renew(const char *, *opt->dest, (*opt->ndest) + 1); - (*opt->dest)[*opt->ndest] =3D value; - (*opt->ndest)++; return 0; } =20 -static void save_opt_list(size_t *ndest, const char ***dest, - QemuOpts *opts, const char *name) +static bool save_opt_list(size_t *ndest, char ***dest, QemuOpts *opts, + Error **errp) { struct opt_list opt =3D { - name, ndest, dest, + ndest, dest, }; - qemu_opt_foreach(opts, save_opt_one, &opt, NULL); + if (!qemu_opt_foreach(opts, save_opt_one, &opt, errp)) { + return false; + } + return true; } =20 void smbios_entry_add(QemuOpts *opts, Error **errp) @@ -1149,7 +1193,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) { return; } - save_opt_list(&type11.nvalues, &type11.values, opts, "value"); + if (!save_opt_list(&type11.nvalues, &type11.values, opts, errp= )) { + return; + } return; case 17: if (!qemu_opts_validate(opts, qemu_smbios_type17_opts, errp)) { --=20 2.26.2 From nobody Sun Apr 28 15:11:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599584154; cv=none; d=zohomail.com; s=zohoarc; b=RlispMbesPjiTo3weg3w4xl1Lopjck87YKKziXCKQO9PXXACr4ascneVmi/QWVnXVEOrLFd3qvFaq15NJFtLJGVbB3VeFlEiORS8uU1I0/vWqfjwx0eRenoBKiU8L4YQO0OOUAj62niGKWgmWP9ZtwqRocyedgMDHyrOSMeLra8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599584154; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Crh3iw0bD87S4zWLCtdBOPh17sv2ir+oVFB/4hdOyc=; b=Izcie+g7s7jNwJlSFoo8185cROBrnElFmt+MzEXqI9qw3Gi/9on6RLo155t1BiOBNm11Yd1BjMk743nDlq2Q4tbzjcJl1DpQCX+jtYMgopZpaYjxK44D95fc8GdVg+8xEcpPlKgxxJf0jv5QBqSnz0aLQejE4qE0EaZwMIFegcU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599584154364818.0702540563609; Tue, 8 Sep 2020 09:55:54 -0700 (PDT) Received: from localhost ([::1]:37862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFguO-0007n5-Ou for importer@patchew.org; Tue, 08 Sep 2020 12:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFgtb-0006dE-VJ for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFgtZ-00048T-Ft for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-TCV6RZn4NHC0LMCVc8EKsw-1; Tue, 08 Sep 2020 12:54:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 827B98D5640; Tue, 8 Sep 2020 16:54:57 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-113-154.ams2.redhat.com [10.36.113.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98BA660C0F; Tue, 8 Sep 2020 16:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599584100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Crh3iw0bD87S4zWLCtdBOPh17sv2ir+oVFB/4hdOyc=; b=I7WwTWYVES1MuSBCJriU6Cg2eLjU0iPmkUKq9WO2wA7imtpOJnqyEVOb4n8Qb3ooI2xWm9 GRaDPOcL8aN8t0Kzt0KuHcGmgArakbmipxmJFq4sgsJY8mKomHUf00D92aC8P/e00uhwC0 M0ndolKHNCqHI7UMEvgSeVlFvNwnRrY= X-MC-Unique: TCV6RZn4NHC0LMCVc8EKsw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/5] hw/smbios: report error if table size is too large Date: Tue, 8 Sep 2020 17:54:35 +0100 Message-Id: <20200908165438.1008942-3-berrange@redhat.com> In-Reply-To: <20200908165438.1008942-1-berrange@redhat.com> References: <20200908165438.1008942-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/08 12:54:58 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Laszlo Ersek , Markus Armbruster , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The SMBIOS 2.1 entry point uses a uint16 data type for reporting the total length of the tables. If the user passes -smbios configuration to QEMU that causes the table size to exceed this limit then various bad behaviours result, including - firmware hangs in an infinite loop - firmware triggers a KVM crash on bad memory access - firmware silently discards user's SMBIOS data replacing it with a generic data set. Limiting the size to 0xffff in QEMU avoids triggering most of these problems. There is a remaining bug in SeaBIOS which tries to prepend its own data for table 0, and does not check whether there is sufficient space before attempting this. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/smbios/smbios.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 8450fad285..3c87be6c91 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -365,6 +365,13 @@ static void smbios_register_config(void) =20 opts_init(smbios_register_config); =20 +/* + * The SMBIOS 2.1 "structure table length" field in the + * entry point uses a 16-bit integer, so we're limited + * in total table size + */ +#define SMBIOS_21_MAX_TABLES_LEN 0xffff + static void smbios_validate_table(MachineState *ms) { uint32_t expect_t4_count =3D smbios_legacy ? @@ -375,6 +382,13 @@ static void smbios_validate_table(MachineState *ms) expect_t4_count, smbios_type4_count); exit(1); } + + if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_21 && + smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) { + error_report("SMBIOS 2.1 table length %zu exceeds %d", + smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN); + exit(1); + } } =20 =20 --=20 2.26.2 From nobody Sun Apr 28 15:11:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599584195; cv=none; d=zohomail.com; s=zohoarc; b=EW9Hyr0Ihaqou/LXmpQC8EeqXs9gANfdq43OgRVe/TatF2g+0ae+aqHRIXMSdoC7WL9BFsxu+Lf5iZTwoR57hmUIPh7kaeQdNdlRitDxPHyxWRlODuqps5BX/Fj3qzVxlWlqFdqmR3TFG7K1SoZtAISzE/Cz2HtZ+N1z1WJcPkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599584195; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZRGvBAH+dKo4eQmW709G3GxhMXaX4ecI/lRwbDTiydg=; b=Rxy+QeVJ5T+be+kVIlDBZ2ipx5MYFrNME4Ou/vo9LC139uGRnhnvtJR3HBN/s4ekI2yuGJzCcYUpdWzziYzbBb+ggUnnXz+R+YbkIxP+k+5VGIFYQErP4RWYu4LhYgbuYjY2amg7Bf1n5fTmQuMobfG6N9Vc1EuSioeds3KWsrA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599584195150653.7089049136227; Tue, 8 Sep 2020 09:56:35 -0700 (PDT) Received: from localhost ([::1]:41416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFgv3-0000x2-SD for importer@patchew.org; Tue, 08 Sep 2020 12:56:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFgu1-0007QF-FK for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:29 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:45971 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFgtz-0004Gt-LN for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-CXGMf-EwPvS8ncmQ2_ERKQ-1; Tue, 08 Sep 2020 12:55:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 828751DDEF; Tue, 8 Sep 2020 16:55:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-113-154.ams2.redhat.com [10.36.113.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9D4660C0F; Tue, 8 Sep 2020 16:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599584127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZRGvBAH+dKo4eQmW709G3GxhMXaX4ecI/lRwbDTiydg=; b=c9YE+rOK4E+eEbl0itOAMZqssScG7iCra4jKEr2ldqKsuMLdOvc5xyEQCll7U+FcfvIt5r TdDfzAtm8fOKe7Gz+gzSZxd3qjwcQdYA1pdFiI03flHPcB6OAQRC+bIiK7qFotPjwcg4/A VXO0RYyDmMZ9/XICmQW7PX57zlCnh7g= X-MC-Unique: CXGMf-EwPvS8ncmQ2_ERKQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/5] qemu-options: document SMBIOS type 11 settings Date: Tue, 8 Sep 2020 17:54:36 +0100 Message-Id: <20200908165438.1008942-4-berrange@redhat.com> In-Reply-To: <20200908165438.1008942-1-berrange@redhat.com> References: <20200908165438.1008942-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/08 03:00:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NUMERIC_HTTP_ADDR=1.242, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, WEIRD_PORT=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Laszlo Ersek , Markus Armbruster , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- qemu-options.hx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index b0f020594e..0cd231b164 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2296,6 +2296,8 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, "-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr= ][,serial=3Dstr]\n" " [,asset=3Dstr][,part=3Dstr][,max-speed=3D%d][,current-s= peed=3D%d]\n" " specify SMBIOS type 4 fields\n" + "-smbios type=3D11[,value=3Dstr][,path=3Dfilename]\n" + " specify SMBIOS type 11 fields\n" "-smbios type=3D17[,loc_pfx=3Dstr][,bank=3Dstr][,manufacturer=3Dstr][,= serial=3Dstr]\n" " [,asset=3Dstr][,part=3Dstr][,speed=3D%d]\n" " specify SMBIOS type 17 fields\n", @@ -2319,6 +2321,45 @@ SRST ``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr]`` Specify SMBIOS type 4 fields =20 +``-smbios type=3D11[,value=3Dstr][,path=3Dfilename]`` + Specify SMBIOS type 11 fields inline + + This argument can be repeated multiple times, and values are added in = the order they are parsed. + Applications intending to use OEM strings data are encouraged to use t= heir application name as + a prefix for the value string. This facilitates passing information fo= r multiple applications + concurrently. + + The ``value=3Dstr`` syntax provides the string data inline, while the = ``path=3Dfilename`` syntax + loads data from a file on disk. Note that the file is not permitted to= contain any NUL bytes. + + Both the ``value`` and ``path`` options can be repeated multiple times= and will be added to + the SMBIOS table in the order in which they appear. + + Note that on the x86 architecture, the total size of all SMBIOS tables= is limited to 65535 + bytes. Thus the OEM strings data is not suitable for passing large amo= unts of data into the + guest. Instead it should be used as a indicator to inform the guest wh= ere to locate the real + data set, for example, by specifying the serial ID of a block device. + + An example passing three strings is + + .. parsed-literal:: + + -smbios type=3D11,value=3Dcloud-init:ds=3Dnocloud-net;s=3Dhttp://1= 0.10.0.1:8000/,\\ + value=3Danaconda:method=3Dhttp://dl.fedoraproject.= org/pub/fedora/linux/releases/25/x86_64/os,\\ + path=3D/some/file/with/oemstringsdata.txt + + In the guest OS this is visible with the ``dmidecode`` command + + .. parsed-literal:: + + $ dmidecode -t 11 + Handle 0x0E00, DMI type 11, 5 bytes + OEM Strings + String 1: cloud-init:ds=3Dnocloud-net;s=3Dhttp://10.10.0.1:8= 000/ + String 2: anaconda:method=3Dhttp://dl.fedoraproject.org/pub/= fedora/linux/releases/25/x86_64/os + String 3: myapp:some extra data + + ``-smbios type=3D17[,loc_pfx=3Dstr][,bank=3Dstr][,manufacturer=3Dstr][,ser= ial=3Dstr][,asset=3Dstr][,part=3Dstr][,speed=3D%d]`` Specify SMBIOS type 17 fields ERST --=20 2.26.2 From nobody Sun Apr 28 15:11:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599584250; cv=none; d=zohomail.com; s=zohoarc; b=Ort5BAz50HNJoybXUVQ6OmHx3j2NKtO30xraqMifV1aqNMEl3lkzydBrotAMbwtuJWD4tSk/AFenI9v4DMEoTr3l/plKWt9Yz+5ychpp3ZONwulXlYqfTEO9BWgpnwqVsiv63vw/PUpvqPUOZqoeyPeOA2lOSHKhah9iZ+O0Lqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599584250; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rj6tl8vJktVOIqI1vfX25IIFjgimVSwYC7WLuDLq2mA=; b=k8+b9yhBemNL/b6PHjBHIvmoG0BoYDb7TNHwAC+TfQe2hUmwzuj1FKEOH2kBY88nTPJkcqnkpN1aeK0OHRaoPhAQJjf+4RcY+j+/mVcQXg9QSmznW8mmJRek2Bl5+Yj7h0tVA+5SpiSIvr/Whuimdd9187qYdXljkmA/czzPiTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15995842502272.5661296302824894; Tue, 8 Sep 2020 09:57:30 -0700 (PDT) Received: from localhost ([::1]:45334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFgvw-0002aO-VN for importer@patchew.org; Tue, 08 Sep 2020 12:57:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFgtt-00079O-Iv for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:21 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:27571 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFgtr-0004EM-Ll for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-Kz7jg38ENXesN0-iMNyxNw-1; Tue, 08 Sep 2020 12:55:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 034D61084D63; Tue, 8 Sep 2020 16:55:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-113-154.ams2.redhat.com [10.36.113.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id E101860C0F; Tue, 8 Sep 2020 16:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599584118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rj6tl8vJktVOIqI1vfX25IIFjgimVSwYC7WLuDLq2mA=; b=GKB3YyxWc4P7QDj24lb2Jb1EIdws5Oxe1X7nghNWPeBbVQxmGdat0fMkEm7ju/pdoIxuRL w/ryYAcIoq6P+hbs+uKiRJzLx32XGQML6UyUCjI8Jup1/bK8gunnylYI6N9onHBYMxcfK9 vQNBqjoZbEvcwHKrAynF2ijthDzq7IM= X-MC-Unique: Kz7jg38ENXesN0-iMNyxNw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/5] hw/smbios: use qapi for SMBIOS entry point type enum Date: Tue, 8 Sep 2020 17:54:37 +0100 Message-Id: <20200908165438.1008942-5-berrange@redhat.com> In-Reply-To: <20200908165438.1008942-1-berrange@redhat.com> References: <20200908165438.1008942-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/08 03:00:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Laszlo Ersek , Markus Armbruster , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This refactoring prepares for exposing the SMBIOS entry point type as a machine property on x86. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/virt.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/smbios/smbios.c | 9 +++++---- include/hw/firmware/smbios.h | 9 ++------- qapi/machine.json | 12 ++++++++++++ 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index acf9bfbece..fd32b10f75 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1450,7 +1450,7 @@ static void virt_build_smbios(VirtMachineState *vms) =20 smbios_set_defaults("QEMU", product, vmc->smbios_old_sys_ver ? "1.0" : mc->name, false, - true, SMBIOS_ENTRY_POINT_30); + true, SMBIOS_ENTRY_POINT_TYPE_3_0); =20 smbios_get_tables(MACHINE(vms), NULL, 0, &smbios_tables, &smbios_table= s_len, &smbios_anchor, &smbios_anchor_len); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 32b1453e6a..1c5bc6ae6e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -179,7 +179,7 @@ static void pc_init1(MachineState *machine, smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_21); + SMBIOS_ENTRY_POINT_TYPE_2_1); } =20 /* allocate ram and load rom/bios */ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0cb9c18cd4..cc202407c7 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -204,7 +204,7 @@ static void pc_q35_init(MachineState *machine) smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_21); + SMBIOS_ENTRY_POINT_TYPE_2_1); } =20 /* allocate ram and load rom/bios */ diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 3c87be6c91..c99c9b01ae 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -61,7 +61,7 @@ uint8_t *smbios_tables; size_t smbios_tables_len; unsigned smbios_table_max; unsigned smbios_table_cnt; -static SmbiosEntryPointType smbios_ep_type =3D SMBIOS_ENTRY_POINT_21; +static SmbiosEntryPointType smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_2_1; =20 static SmbiosEntryPoint ep; =20 @@ -383,7 +383,7 @@ static void smbios_validate_table(MachineState *ms) exit(1); } =20 - if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_21 && + if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_2_1 && smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) { error_report("SMBIOS 2.1 table length %zu exceeds %d", smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN); @@ -831,7 +831,7 @@ void smbios_set_defaults(const char *manufacturer, cons= t char *product, static void smbios_entry_point_setup(void) { switch (smbios_ep_type) { - case SMBIOS_ENTRY_POINT_21: + case SMBIOS_ENTRY_POINT_TYPE_2_1: memcpy(ep.ep21.anchor_string, "_SM_", 4); memcpy(ep.ep21.intermediate_anchor_string, "_DMI_", 5); ep.ep21.length =3D sizeof(struct smbios_21_entry_point); @@ -854,7 +854,7 @@ static void smbios_entry_point_setup(void) ep.ep21.structure_table_address =3D cpu_to_le32(0); =20 break; - case SMBIOS_ENTRY_POINT_30: + case SMBIOS_ENTRY_POINT_TYPE_3_0: memcpy(ep.ep30.anchor_string, "_SM3_", 5); ep.ep30.length =3D sizeof(struct smbios_30_entry_point); ep.ep30.entry_point_revision =3D 1; @@ -939,6 +939,7 @@ void smbios_get_tables(MachineState *ms, *tables =3D smbios_tables; *tables_len =3D smbios_tables_len; *anchor =3D (uint8_t *)&ep; + g_printerr("Total len %zu\n", smbios_tables_len); =20 /* calculate length based on anchor string */ if (!strncmp((char *)&ep, "_SM_", 4)) { diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 02a0ced0a0..cb1299ad7a 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -1,6 +1,8 @@ #ifndef QEMU_SMBIOS_H #define QEMU_SMBIOS_H =20 +#include "qapi/qapi-types-machine.h" + /* * SMBIOS Support * @@ -23,13 +25,6 @@ struct smbios_phys_mem_area { uint64_t length; }; =20 -/* - * SMBIOS spec defined tables - */ -typedef enum SmbiosEntryPointType { - SMBIOS_ENTRY_POINT_21, - SMBIOS_ENTRY_POINT_30, -} SmbiosEntryPointType; =20 /* SMBIOS Entry Point * There are two types of entry points defined in the SMBIOS specification diff --git a/qapi/machine.json b/qapi/machine.json index abc6fd0477..a58cf2694f 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -937,3 +937,15 @@ 'data': 'NumaOptions', 'allow-preconfig': true } + +## +# @SmbiosEntryPointType: +# +# @2_1: SMBIOS version 2.1 +# +# @3_0: SMBIOS version 3.0 +# +# Since: 5.2 +## +{ 'enum': 'SmbiosEntryPointType', + 'data': [ '2_1', '3_0' ] } --=20 2.26.2 From nobody Sun Apr 28 15:11:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599584310; cv=none; d=zohomail.com; s=zohoarc; b=nTnMQzoB0RvIdZO9kaK7VcSnnGOhMYcCM6VdJht4R3E42PdP9UgLCXcd1bZ4Lz1HXLYyhTenE0ckjLmwhB+6cw1cQCNami+wLcbgZXKRmHnCUvpntV84eA2DEFmw7gYN7VfQpc/fTj9JYXr+Zh2ovPSX2/gqiFweeUm62iPI9IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599584310; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7mfcLUk8WHP0NVHkcizMVA7sBj5Ca5AZ2tn+WQE8aUs=; b=Gn1xHSUr7jlIHqBmER8Ah6kzVK12y7Tcmfkj2wvHdRuUMv/axpQNOoyMOjbAPpglssCby0AkxxNNzsSBJVMOaT/LioehdhqTU3SdyeyDR9oER7cF1eHJgDqa32yRxC4qRehp0Kp+MI3WSIo5DMbfzAKY/BrWFcFSU4Du8uxBTjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599584310510272.0409021812874; Tue, 8 Sep 2020 09:58:30 -0700 (PDT) Received: from localhost ([::1]:48424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFgwv-0003so-7M for importer@patchew.org; Tue, 08 Sep 2020 12:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFgtx-0007Ho-P8 for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFgtw-0004GZ-5D for qemu-devel@nongnu.org; Tue, 08 Sep 2020 12:55:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-R5EAJ874MqeunE8EogHBTg-1; Tue, 08 Sep 2020 12:55:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9415B192C8AE; Tue, 8 Sep 2020 16:55:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-113-154.ams2.redhat.com [10.36.113.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 560A060CD1; Tue, 8 Sep 2020 16:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599584123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7mfcLUk8WHP0NVHkcizMVA7sBj5Ca5AZ2tn+WQE8aUs=; b=AoPrznLE0qKIadz8rKB9Fm1PXr+kdkF5y5WCafp/Uk1OMPNADa36Z90Z87nL9BIrIg8kPA Is4P1gjAwWwamkrFEtElliRrmeoI734T+T2+wfqqqGv7Mf2uQcq9J1WDSqyBybL1S35YGl FuKBxaP9zp80gEWIeMAr+BZWHBIvZT8= X-MC-Unique: R5EAJ874MqeunE8EogHBTg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 5/5] hw/i386: expose a "smbios_ep" PC machine property Date: Tue, 8 Sep 2020 17:54:38 +0100 Message-Id: <20200908165438.1008942-6-berrange@redhat.com> In-Reply-To: <20200908165438.1008942-1-berrange@redhat.com> References: <20200908165438.1008942-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/08 02:10:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Laszlo Ersek , Markus Armbruster , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The i440fx and Q35 machine types are both hardcoded to use the legacy SMBIOS 2.1 entry point. This is a sensible conservative choice because SeaBIOS only supports SMBIOS 2.1 EDK2, however, can also support SMBIOS 3.0 and QEMU already uses this on the ARM virt machine type. This adds a property to allow the choice of SMBIOS entry point versions For example to opt in to version 3.0 $QEMU -machine q35,smbios_ep=3D3_0 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc.c | 26 ++++++++++++++++++++++++++ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- include/hw/i386/pc.h | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d11daacc23..cfce279eed 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -81,6 +81,7 @@ #include "hw/mem/nvdimm.h" #include "qapi/error.h" #include "qapi/qapi-visit-common.h" +#include "qapi/qapi-visit-machine.h" #include "qapi/visitor.h" #include "hw/core/cpu.h" #include "hw/usb.h" @@ -1834,6 +1835,23 @@ static void pc_machine_set_pit(Object *obj, bool val= ue, Error **errp) pcms->pit_enabled =3D value; } =20 +static void pc_machine_get_smbios_ep(Object *obj, Visitor *v, const char *= name, + void *opaque, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + SmbiosEntryPointType smbios_ep =3D pcms->smbios_ep; + + visit_type_SmbiosEntryPointType(v, name, &smbios_ep, errp); +} + +static void pc_machine_set_smbios_ep(Object *obj, Visitor *v, const char *= name, + void *opaque, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + visit_type_SmbiosEntryPointType(v, name, &pcms->smbios_ep, errp); +} + static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -1879,6 +1897,8 @@ static void pc_machine_initfn(Object *obj) pcms->vmport =3D ON_OFF_AUTO_OFF; #endif /* CONFIG_VMPORT */ pcms->max_ram_below_4g =3D 0; /* use default */ + pcms->smbios_ep =3D SMBIOS_ENTRY_POINT_TYPE_2_1; + /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled =3D PC_MACHINE_GET_CLASS(pcms)->has_acpi_buil= d; pcms->smbus_enabled =3D true; @@ -2004,6 +2024,12 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) =20 object_class_property_add_bool(oc, PC_MACHINE_PIT, pc_machine_get_pit, pc_machine_set_pit); + + object_class_property_add(oc, PC_MACHINE_SMBIOS_EP, "str", + pc_machine_get_smbios_ep, pc_machine_set_smbios_ep, + NULL, NULL); + object_class_property_set_description(oc, PC_MACHINE_SMBIOS_EP, + "SMBIOS Entry Point version [v2_1, v3_0]"); } =20 static const TypeInfo pc_machine_info =3D { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1c5bc6ae6e..3626e5425f 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -179,7 +179,7 @@ static void pc_init1(MachineState *machine, smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_TYPE_2_1); + pcms->smbios_ep); } =20 /* allocate ram and load rom/bios */ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index cc202407c7..7cf08fa364 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -204,7 +204,7 @@ static void pc_q35_init(MachineState *machine) smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)", mc->name, pcmc->smbios_legacy_mode, pcmc->smbios_uuid_encoded, - SMBIOS_ENTRY_POINT_TYPE_2_1); + pcms->smbios_ep); } =20 /* allocate ram and load rom/bios */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index fe52e165b2..f5d2ebcb49 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -10,6 +10,7 @@ =20 #include "hw/acpi/acpi_dev_interface.h" #include "hw/hotplug.h" +#include "hw/firmware/smbios.h" =20 #define HPET_INTCAP "hpet-intcap" =20 @@ -38,6 +39,7 @@ struct PCMachineState { /* Configuration options: */ uint64_t max_ram_below_4g; OnOffAuto vmport; + SmbiosEntryPointType smbios_ep; =20 bool acpi_build_enabled; bool smbus_enabled; @@ -59,6 +61,7 @@ struct PCMachineState { #define PC_MACHINE_SMBUS "smbus" #define PC_MACHINE_SATA "sata" #define PC_MACHINE_PIT "pit" +#define PC_MACHINE_SMBIOS_EP "smbios-ep" =20 /** * PCMachineClass: --=20 2.26.2