From nobody Tue Nov 26 09:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708534876; cv=none; d=zohomail.com; s=zohoarc; b=CM9Cr5M0g83PMsJF6xOgsA2J4cS8A+LjtH9xWG7kNdttwNe+pPYHMDCTevWBr+X0yBaC8Gg8L9IRJJckfmwDBYLjjiUOR9NrwLvC3nMp+W0PBCJ/Y066LxbECAYrTpJ2xtgcPI1QzdOQkHVbXWFIohCn7/mjB409YmjeMK1QeIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708534876; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mbb6F/kEymqfJxvlakPQcJAgpZqMaRxUss3YZiC7LPU=; b=R8wLro0MKx1zNdwUzUyNT87Xxw6YseBYJV1nqpK5xBpNPsyoyH3Ml2b+tu3ZiZ+DZGGM0Q0DJR+L3B8UKkyRpCi/7r6PNh0lXq0asurh4UeX/eZ6Vz7u87BOTFmmbkk64cTQm+SvgwV2NOoVztDW0RIrc70HJ2ZLTRbQ9L0IvQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708534876792189.7234842322698; Wed, 21 Feb 2024 09:01:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcpxb-0006VB-UW; Wed, 21 Feb 2024 12:00:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3MSzWZQwKChgByz652GH23yB4CC492.0CAE2AI-12J29BCB4BI.CF4@flex--nabihestefan.bounces.google.com>) id 1rcpxW-0006Mr-Ki for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:00:40 -0500 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3MSzWZQwKChgByz652GH23yB4CC492.0CAE2AI-12J29BCB4BI.CF4@flex--nabihestefan.bounces.google.com>) id 1rcpxU-00037P-7x for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:00:37 -0500 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-607cd6c11d7so101458267b3.0 for ; Wed, 21 Feb 2024 09:00:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708534833; x=1709139633; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Mbb6F/kEymqfJxvlakPQcJAgpZqMaRxUss3YZiC7LPU=; b=sJ/c7HSaj6d9qA/gmF2W7UGWRM4Z2GMCScw6ex2t0VOXOHVh2GdQhYKqLcASXZI8sq hmzh137v7g7gVhYxEuUFlVtKkOMztIjL+W+e/5/PCLg8sOYT06hoKHDmToLWO+dXyebO JfFhGLVR4D090yRSTyAU+UDskHBp/SO47kqoD8IepjruebPeAS4hPfDrq9q/dHf9Ousm SNoAzgtiMWytRdRC4vJCzCxAbyT+2xFDKOEifQ3zUx+AmfRmk5I2P8IuN34hQNT/XKy2 3WCauzVL6qf37jAEGTORkjDjlMPYosoJnKrDu9pLFBRz9+tSzPSIoj4xBsgx+pC/6lVU 6e9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708534833; x=1709139633; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mbb6F/kEymqfJxvlakPQcJAgpZqMaRxUss3YZiC7LPU=; b=IMXDIlY2D86PSS05NOpU+s/3LV2q++8qJBUsxYi00TVQfJ1S+ZkHBsH+sLvSCrBu2t x660/Ikn0tNhI2xwRMIAS8LZxZkcREf9cyFFrZShbV18YTr/M0lmPwvd/C6zdXbmwJoN GI9+J8xnJ67q6Kisj8CnFaDarP4HAxHbVX0rNZFhGwmIC1GjTVBWms6WX/JLyVDUxqou 83qvgrzcHz8Fori8VzMq7Lw4lrD/r5ARlnBtNOKLNBURbvfjlRHZGLsZHempHaNVgZQw dmiMYkPG5F7YCIA2uxb3AG1DTOGB+mgSsRq86r4TQ/8v1r5mefvVbmNqa9MnLePbbkrC emeA== X-Forwarded-Encrypted: i=1; AJvYcCViVZ753cFtbZ8a16I1qG7aQz7+C/YCQ+thuQS/TzTLlSCvBEyqmSYrYckr10zN8/jMesFcuvaMVytSE9Wh9LlAg76E4fs= X-Gm-Message-State: AOJu0YzSefuJpT38o691B+f1tiaRvXag495kXEMN+WHptDxntl345nFA gtLmpnpdA7GOzu226RQcOGWa9jcp1hh+1WHt5WwCiDVxsccXWlu/qIIWII9kFZV6qFNgpETZ/WT Mb8imkW1R+K0+hm29e7M1ICF3Ng== X-Google-Smtp-Source: AGHT+IGpVFzx0UGI3M5BFpE/hmh31dUzXAItDfCRiZEOZikplzFcedrVvubmvJBHcWxGa6sB3OXRnumAwMxwxyavkfI= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a81:f20f:0:b0:608:788f:8cfa with SMTP id i15-20020a81f20f000000b00608788f8cfamr609080ywm.1.1708534833092; Wed, 21 Feb 2024 09:00:33 -0800 (PST) Date: Wed, 21 Feb 2024 17:00:26 +0000 In-Reply-To: <20240221170027.1027325-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20240221170027.1027325-1-nabihestefan@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221170027.1027325-2-nabihestefan@google.com> Subject: [PATCH 1/2] Implement base of SMBIOS type 9 descriptor. From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-block@nongnu.org, its@irrelevant.dk, kbusch@kernel.org, eric.auger@redhat.com, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, flwu@google.com, nabihestefan@google.com 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=2607:f8b0:4864:20::114a; envelope-from=3MSzWZQwKChgByz652GH23yB4CC492.0CAE2AI-12J29BCB4BI.CF4@flex--nabihestefan.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708534878792100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Felix Wu Version 2.1+. Signed-off-by: Felix Wu Signed-off-by: Nabih Estefan --- hw/smbios/smbios.c | 99 ++++++++++++++++++++++++++++++++++++ include/hw/firmware/smbios.h | 13 +++++ qemu-options.hx | 3 ++ 3 files changed, 115 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index a3c4e52ce9..38b3ea172c 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -121,6 +121,16 @@ struct type8_instance { }; static QTAILQ_HEAD(, type8_instance) type8 =3D QTAILQ_HEAD_INITIALIZER(typ= e8); =20 +/* type 9 instance for parsing */ +struct type9_instance { + const char *slot_designation; + uint8_t slot_type, slot_data_bus_width, current_usage, slot_length, + slot_characteristics1, slot_characteristics2; + uint16_t slot_id; + QTAILQ_ENTRY(type9_instance) next; +}; +static QTAILQ_HEAD(, type9_instance) type9 =3D QTAILQ_HEAD_INITIALIZER(typ= e9); + static struct { size_t nvalues; char **values; @@ -380,6 +390,54 @@ static const QemuOptDesc qemu_smbios_type8_opts[] =3D { { /* end of list */ } }; =20 +static const QemuOptDesc qemu_smbios_type9_opts[] =3D { + { + .name =3D "type", + .type =3D QEMU_OPT_NUMBER, + .help =3D "SMBIOS element type", + }, + { + .name =3D "slot_designation", + .type =3D QEMU_OPT_STRING, + .help =3D "string number for reference designation", + }, + { + .name =3D "slot_type", + .type =3D QEMU_OPT_NUMBER, + .help =3D "connector type", + }, + { + .name =3D "slot_data_bus_width", + .type =3D QEMU_OPT_NUMBER, + .help =3D "port type", + }, + { + .name =3D "current_usage", + .type =3D QEMU_OPT_NUMBER, + .help =3D "current usage", + }, + { + .name =3D "slot_length", + .type =3D QEMU_OPT_NUMBER, + .help =3D "system slot length", + }, + { + .name =3D "slot_id", + .type =3D QEMU_OPT_NUMBER, + .help =3D "system slot id", + }, + { + .name =3D "slot_characteristics1", + .type =3D QEMU_OPT_NUMBER, + .help =3D "slot characteristics1, see the spec", + }, + { + .name =3D "slot_characteristics2", + .type =3D QEMU_OPT_NUMBER, + .help =3D "slot characteristics2, see the spec", + }, +}; + static const QemuOptDesc qemu_smbios_type11_opts[] =3D { { .name =3D "type", @@ -609,6 +667,7 @@ bool smbios_skip_table(uint8_t type, bool required_tabl= e) #define T2_BASE 0x200 #define T3_BASE 0x300 #define T4_BASE 0x400 +#define T9_BASE 0x900 #define T11_BASE 0xe00 =20 #define T16_BASE 0x1000 @@ -807,6 +866,28 @@ static void smbios_build_type_8_table(void) } } =20 +static void smbios_build_type_9_table(void) +{ + unsigned instance =3D 0; + struct type9_instance *t9; + + QTAILQ_FOREACH(t9, &type9, next) { + SMBIOS_BUILD_TABLE_PRE(9, T9_BASE + instance, true); + + SMBIOS_TABLE_SET_STR(9, slot_designation, t9->slot_designation); + t->slot_type =3D t9->slot_type; + t->slot_data_bus_width =3D t9->slot_data_bus_width; + t->current_usage =3D t9->current_usage; + t->slot_length =3D t9->slot_length; + t->slot_id =3D t9->slot_id; + t->slot_characteristics1 =3D t9->slot_characteristics1; + t->slot_characteristics2 =3D t9->slot_characteristics2; + + SMBIOS_BUILD_TABLE_POST; + instance++; + } +} + static void smbios_build_type_11_table(void) { char count_str[128]; @@ -1126,6 +1207,7 @@ void smbios_get_tables(MachineState *ms, } =20 smbios_build_type_8_table(); + smbios_build_type_9_table(); smbios_build_type_11_table(); =20 #define MAX_DIMM_SZ (16 * GiB) @@ -1460,6 +1542,23 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) t8_i->port_type =3D qemu_opt_get_number(opts, "port_type", 0); QTAILQ_INSERT_TAIL(&type8, t8_i, next); return; + case 9: { + if (!qemu_opts_validate(opts, qemu_smbios_type9_opts, errp)) { + return; + } + struct type9_instance *t; + t =3D g_new0(struct type9_instance, 1); + save_opt(&t->slot_designation, opts, "slot_designation"); + t->slot_type =3D qemu_opt_get_number(opts, "slot_type", 0); + t->slot_data_bus_width =3D qemu_opt_get_number(opts, "slot_dat= a_bus_width", 0); + t->current_usage =3D qemu_opt_get_number(opts, "current_usage"= , 0); + t->slot_length =3D qemu_opt_get_number(opts, "slot_length", 0); + t->slot_id =3D qemu_opt_get_number(opts, "slot_id", 0); + t->slot_characteristics1 =3D qemu_opt_get_number(opts, "slot_c= haracteristics1", 0); + t->slot_characteristics2 =3D qemu_opt_get_number(opts, "slot_c= haracteristics2", 0); + QTAILQ_INSERT_TAIL(&type9, t, next); + return; + } case 11: if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) { return; diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 6e514982d4..9ab114aea2 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -211,6 +211,19 @@ struct smbios_type_8 { uint8_t port_type; } QEMU_PACKED; =20 +/* SMBIOS type 9 - System Slots (v2.1+) */ +struct smbios_type_9 { + struct smbios_structure_header header; + uint8_t slot_designation; + uint8_t slot_type; + uint8_t slot_data_bus_width; + uint8_t current_usage; + uint8_t slot_length; + uint16_t slot_id; + uint8_t slot_characteristics1; + uint8_t slot_characteristics2; +} QEMU_PACKED; + /* SMBIOS type 11 - OEM strings */ struct smbios_type_11 { struct smbios_structure_header header; diff --git a/qemu-options.hx b/qemu-options.hx index 8547254dbf..9ddb1b1fb3 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2717,6 +2717,9 @@ SRST ``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr][,processor-family=3D%d][,processor= -id=3D%d]`` Specify SMBIOS type 4 fields =20 +``-smbios type=3D9[,slot_designation=3Dstr][,slot_type=3D%d][,slot_data_bu= s_width=3D%d][,current_usage=3D%d][,slot_length=3D%d][,slot_id=3D%d][,slot_= characteristics1=3D%d][,slot_characteristics12=3D%d]`` + Specify SMBIOS type 9 fields + ``-smbios type=3D11[,value=3Dstr][,path=3Dfilename]`` Specify SMBIOS type 11 fields =20 --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Tue Nov 26 09:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708534988; cv=none; d=zohomail.com; s=zohoarc; b=cno8gdtZZXVdqZy5ROupb+CNu6rLzHf81ZDhkGlCT8hlZMaERM22TSEsEtz2BuyK5v9K1fe0XjxUZwhdr2JGTC0EwK4rmRGFAB5Qla3ZzxxBvAGhK8/111qm1RJYEssU/bbpA72WG/1wpMeo4LEU2Z9JSghswgpGceCZQCdDOxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708534988; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pUXKy3XKiq+5p9TeSf8xJ6UxKnHtPGAsZsl63BQGiN8=; b=NMAnIqLZystKfO8rSt7OeXYJ8bQNcqWYNzo2j2kugZselGP6lKZN2Zyw6bq0Ax/5fLximDXvJfdprk+rowN4pgQAIbSeildBgIOwny3/w6V2Sr0OxU9n6zadrLpfz451+oX1m2Gex+r0SJ0iJ6l0YMXV6YNx6av9neckmB0KTTs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170853498890466.10147558179096; Wed, 21 Feb 2024 09:03:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcpxc-0006Ve-Hs; Wed, 21 Feb 2024 12:00:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3MizWZQwKChkCz0763HI34zC5DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--nabihestefan.bounces.google.com>) id 1rcpxY-0006Os-DX for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:00:40 -0500 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3MizWZQwKChkCz0763HI34zC5DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--nabihestefan.bounces.google.com>) id 1rcpxW-00038K-CS for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:00:40 -0500 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-608405e0340so14801997b3.0 for ; Wed, 21 Feb 2024 09:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708534834; x=1709139634; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=pUXKy3XKiq+5p9TeSf8xJ6UxKnHtPGAsZsl63BQGiN8=; b=WcEJD6hlJGhEWv7Mf2v1HpEr9gBwOeGZ/C0zuemAUlWm5w9om1lBtVf53c+HxdiY9s 398LoKzhlbWpuoszx7As/WouCCkpDvMIH86VNvAoyYk5zbbSx0KUuo1edXpNx4JJRr/F Z8c9230E09V2kLTc4egrCDSpgAS3Tmeje5buuWDRsav+ff02I6fTS595ko+fibfPDWPK FpY2k6chR7RnJBZsk3FkxY/cfpVxQ4D4WKRjo+8aSUlJYPUcd43r15MIXjIOESCRWqkB W9nt/J8mJL+tfV9f2IkHROqMiBkhw9nd44p5y4K7Hg3ERO6A5N0ovg7/dSrtIMjMhBH0 jAUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708534834; x=1709139634; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pUXKy3XKiq+5p9TeSf8xJ6UxKnHtPGAsZsl63BQGiN8=; b=fAEZarx0oEae9tEHEvoBwsfxryMPkeBTgVV05T46JH3pjO4pVozwPxt5QpqkuvV7Cs w/NObmZ2IBc8v2H0UEABBITSVDV5wLwk82dnXxVVE/p9X0FZGzLRu6KRzkyYsHrMQrCg K5jiUH8l0Pox7jw0yGyNDNksV8f1GkpQk5WNRGskV7F0v0ATCXkpd+1JR9XBO6EUjfWg HqdYf2+cjrPi5R7eU86AxYwd40vT90eU7xbjly495BAWNmZxC41ACuJO4Q66qOETDY6U NAH7PkFmt+bciLO6xoxeGSbjcHxbSICcbdV4qnyJ4lf/ixzZNOyQt4Xr9WZS6SZY5C27 kjyA== X-Forwarded-Encrypted: i=1; AJvYcCWVsNuZhHVpaeGn2/VyWvVAq1w5AZPphaN8Rv6+Mom3eMVqqEw4JpRXhebfTzz5kg89iZGEehPont2NK0xfOYdmgy8diQo= X-Gm-Message-State: AOJu0YzbVI254ieShk434/fsBlLHVo43i6/hI9VjRfpax5+4sXt2esZM jrWNpmglTS3GF7TfSnC8Z1Ol7DJnJkORlU5HUvUKUc9kY5cQy76gYkM7hWPGAnir5NZMRvquVxu gEzX4zD28CtF+pr++CZmv/Uy8yg== X-Google-Smtp-Source: AGHT+IFundAyljS/0wGrrnfcyT5GcT6rdSWJljtZkw5WVSSIhsb9mZPjsepb6jSIQlTswmaHnKHFWEmABs8g07C4VQo= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a0d:e692:0:b0:608:6894:120 with SMTP id p140-20020a0de692000000b0060868940120mr1008189ywe.4.1708534834637; Wed, 21 Feb 2024 09:00:34 -0800 (PST) Date: Wed, 21 Feb 2024 17:00:27 +0000 In-Reply-To: <20240221170027.1027325-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20240221170027.1027325-1-nabihestefan@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221170027.1027325-3-nabihestefan@google.com> Subject: [PATCH 2/2] Implement SMBIOS type 9 v2.6 From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-block@nongnu.org, its@irrelevant.dk, kbusch@kernel.org, eric.auger@redhat.com, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, flwu@google.com, nabihestefan@google.com 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=2607:f8b0:4864:20::114a; envelope-from=3MizWZQwKChkCz0763HI34zC5DD5A3.1DBF3BJ-23K3ACDC5CJ.DG5@flex--nabihestefan.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708534991073100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Felix Wu Signed-off-by: Felix Wu Signed-off-by: Nabih Estefan --- hw/smbios/smbios.c | 49 +++++++++++++++++++++++++++++++++--- include/hw/firmware/smbios.h | 4 +++ qemu-options.hx | 2 +- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 38b3ea172c..e3d5d8f2e2 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -123,7 +123,7 @@ static QTAILQ_HEAD(, type8_instance) type8 =3D QTAILQ_H= EAD_INITIALIZER(type8); =20 /* type 9 instance for parsing */ struct type9_instance { - const char *slot_designation; + const char *slot_designation, *pcidev; uint8_t slot_type, slot_data_bus_width, current_usage, slot_length, slot_characteristics1, slot_characteristics2; uint16_t slot_id; @@ -436,6 +436,11 @@ static const QemuOptDesc qemu_smbios_type9_opts[] =3D { .type =3D QEMU_OPT_NUMBER, .help =3D "slot characteristics2, see the spec", }, + { + .name =3D "pci_device", + .type =3D QEMU_OPT_STRING, + .help =3D "PCI device, if provided." + } }; =20 static const QemuOptDesc qemu_smbios_type11_opts[] =3D { @@ -866,7 +871,7 @@ static void smbios_build_type_8_table(void) } } =20 -static void smbios_build_type_9_table(void) +static void smbios_build_type_9_table(Error **errp) { unsigned instance =3D 0; struct type9_instance *t9; @@ -883,6 +888,43 @@ static void smbios_build_type_9_table(void) t->slot_characteristics1 =3D t9->slot_characteristics1; t->slot_characteristics2 =3D t9->slot_characteristics2; =20 + if (t9->pcidev) { + PCIDevice *pdev =3D NULL; + int rc =3D pci_qdev_find_device(t9->pcidev, &pdev); + if (rc !=3D 0) { + error_setg(errp, + "No PCI device %s for SMBIOS type 9 entry %s", + t9->pcidev, t9->slot_designation); + return; + } + /* + * We only handle the case were the device is attached to + * the PCI root bus. The general case is more complex as + * bridges are enumerated later and the table would need + * to be updated at this moment. + */ + if (!pci_bus_is_root(pci_get_bus(pdev))) { + error_setg(errp, + "Cannot create type 9 entry for PCI device %s: " + "not attached to the root bus", + t9->pcidev); + return; + } + t->segment_group_number =3D cpu_to_le16(0); + t->bus_number =3D pci_dev_bus_num(pdev); + t->device_number =3D pdev->devfn; + } else { + /* + * Per SMBIOS spec, For slots that are not of the PCI, AGP, PC= I-X, + * or PCI-Express type that do not have bus/device/function + * information, 0FFh should be populated in the fields of Segm= ent + * Group Number, Bus Number, Device/Function Number. + */ + t->segment_group_number =3D 0xff; + t->bus_number =3D 0xff; + t->device_number =3D 0xff; + } + SMBIOS_BUILD_TABLE_POST; instance++; } @@ -1207,7 +1249,7 @@ void smbios_get_tables(MachineState *ms, } =20 smbios_build_type_8_table(); - smbios_build_type_9_table(); + smbios_build_type_9_table(errp); smbios_build_type_11_table(); =20 #define MAX_DIMM_SZ (16 * GiB) @@ -1556,6 +1598,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) t->slot_id =3D qemu_opt_get_number(opts, "slot_id", 0); t->slot_characteristics1 =3D qemu_opt_get_number(opts, "slot_c= haracteristics1", 0); t->slot_characteristics2 =3D qemu_opt_get_number(opts, "slot_c= haracteristics2", 0); + save_opt(&t->pcidev, opts, "pcidev"); QTAILQ_INSERT_TAIL(&type9, t, next); return; } diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 9ab114aea2..c21b8d3285 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -222,6 +222,10 @@ struct smbios_type_9 { uint16_t slot_id; uint8_t slot_characteristics1; uint8_t slot_characteristics2; + /* SMBIOS spec v2.6+ */ + uint16_t segment_group_number; + uint8_t bus_number; + uint8_t device_number; } QEMU_PACKED; =20 /* SMBIOS type 11 - OEM strings */ diff --git a/qemu-options.hx b/qemu-options.hx index 9ddb1b1fb3..6a16b808cf 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2717,7 +2717,7 @@ SRST ``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr][,processor-family=3D%d][,processor= -id=3D%d]`` Specify SMBIOS type 4 fields =20 -``-smbios type=3D9[,slot_designation=3Dstr][,slot_type=3D%d][,slot_data_bu= s_width=3D%d][,current_usage=3D%d][,slot_length=3D%d][,slot_id=3D%d][,slot_= characteristics1=3D%d][,slot_characteristics12=3D%d]`` +``-smbios type=3D9[,slot_designation=3Dstr][,slot_type=3D%d][,slot_data_bu= s_width=3D%d][,current_usage=3D%d][,slot_length=3D%d][,slot_id=3D%d][,slot_= characteristics1=3D%d][,slot_characteristics12=3D%d][,pci_device=3Dstr]`` Specify SMBIOS type 9 fields =20 ``-smbios type=3D11[,value=3Dstr][,path=3Dfilename]`` --=20 2.44.0.rc0.258.g7320e95886-goog