From nobody Tue Oct 22 22:26:07 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1727291199; cv=none; d=zohomail.com; s=zohoarc; b=i5iMbiEeaMGsb5NFZOXu2TQ8cbbF9AnXG3tOTaVP65+UcqG+Z42p8V/GXng4i2knHnZEQGwp0aVjJaJVFxfouOtZeZqfPBE+WpjLEo8ymHxT6bmuSngiU/t5mTRSP8EZKA/ErcSzP84l9ys0woKFijyIneRStjdiuTH03y8MVcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727291199; h=Content-Transfer-Encoding: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=6UcRTZcKey+l4g54CJLxGmkuebFnwMhES2SY5pkGUHM=; b=kiZkEN/GFngQBBLTq+YBF26KScJNLTXk0EEv3dI1c4W6OhgEydfTyCWbbBw6hiA9A/w+O4ieS1N4Xpz1SAFiS43iZxjMxeiqvmnyS/S/3/1JMVdiRwS/yv1TKMQ5cYpkNX1nsngLc14iiVSycy1L+qAvoJZZ+xWs0WDAkSrLKms= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727291199529509.84667778008554; Wed, 25 Sep 2024 12:06:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stXKR-00035W-E2; Wed, 25 Sep 2024 15:05:35 -0400 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 ) id 1stXKP-00034Q-4q for qemu-devel@nongnu.org; Wed, 25 Sep 2024 15:05:33 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1stXKN-0005ne-7A for qemu-devel@nongnu.org; Wed, 25 Sep 2024 15:05:32 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-535694d67eeso237424e87.0 for ; Wed, 25 Sep 2024 12:05:30 -0700 (PDT) Received: from fitlet2.primaryno.de ([185.154.111.57]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-537a86489c7sm602736e87.195.2024.09.25.12.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 12:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727291128; x=1727895928; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6UcRTZcKey+l4g54CJLxGmkuebFnwMhES2SY5pkGUHM=; b=LWaFn+6jPlp2n0rHzDlPsBdeQ+DCZvAsDxBxNiUfgYf1wknBBwZuEwvM+rMwWD31EY AnFVKfE1rkVWhAzuu6avfwE4vNezSZltelWgFUd8jHfY3gXhvzX5e4Rv52NlqDb6IOd4 4h1N4fCx8QOl8L1wHQj+EomgmN4x+QZXGVctmoK2ysw2bbhGeo3bkLxMrv109eysRHSx q2FuDXeTTjDKtSFBwkxEkR4bwxy8DcEHMo0c1WcmIIiE8J3eQcRvf3OIb3pWKd0Z8vnI VB/rRQiVudU00fIhiz7x5lFAYT3Jgc0IPSxgM5j3iNNIWew5WV/IR4pwa9ri5EpuyqDZ Q9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727291128; x=1727895928; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6UcRTZcKey+l4g54CJLxGmkuebFnwMhES2SY5pkGUHM=; b=aGNZgzDIshxuQ15wepC8xt+1Jm/kDmXg8058AwY+k06e5//x1T2O2rlvYemTXa9sC0 Nu/hY5KZej+Etp6iZO3EIRrPRgX1zBVOer1CIfQZzZKtg2UUzx8cs+RP8dcRko3rL+qn 6yHuS9tM3xFoq64Q5SVXS5PgequLi8WQ9k4+BLF4N02rpCP3wJ3HTUw9jrxQ7+N8SrDK H0yzLUo2rcZQm/YypmKku10Y+Lk795L52fkOFkURDM+ikKC/kAEdqvKfhjY9GQXzQLAF +w3rZcVMDMYYwFQcz1eUd8UzhiAelqwKZ5AF942VVxsvUK7ZFZDJOItRS3WoN8PjZvZD 2edg== X-Forwarded-Encrypted: i=1; AJvYcCW22YeNRIQYU1Z+R/ucw6qD+OEO6JOJzaQ5xkECnK+BBjfx+QQ0ggsw5skZAam5bWwUcco0At8oWZQy@nongnu.org X-Gm-Message-State: AOJu0Yyqt9P19FMiIwkoU6n3b8ZRgPGwcd1r64USUMP4W1+3s+saO3C9 7QUlNie6hEFs6J3bpkj+/9XPsMbSkIczf1/c9E4rjHmgN4wJo5CP X-Google-Smtp-Source: AGHT+IGWZm6dzyKfOwfneyi01xYmldIx5ikczAsNb7VhjhLU8VFI/7qOowxZKPeRtpPc5MxdGEe27A== X-Received: by 2002:a05:6512:1255:b0:533:4784:6aec with SMTP id 2adb3069b0e04-53896bfc46bmr221463e87.27.1727291128172; Wed, 25 Sep 2024 12:05:28 -0700 (PDT) From: Hal Martin To: mst@redhat.com Cc: Hal Martin , qemu-devel@nongnu.org, imammedo@redhat.com, anisinha@redhat.com Subject: [PATCH v3] hw/smbios: support for type 7 (cache information) Date: Wed, 25 Sep 2024 19:04:45 +0000 Message-Id: <20240925190445.20700-1-hal.martin@gmail.com> X-Mailer: git-send-email 2.38.5 In-Reply-To: <20240924162918.3be98058@imammedo.users.ipa.redhat.com> References: <20240924162918.3be98058@imammedo.users.ipa.redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::12e; envelope-from=hal.martin@gmail.com; helo=mail-lf1-x12e.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=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.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 @gmail.com) X-ZM-MESSAGEID: 1727291202058116600 Content-Type: text/plain; charset="utf-8" This patch adds support for SMBIOS type 7 (Cache Information) to qemu. level: cache level (1-8) size: cache size in bytes Example usage: -smbios type=3D7,level=3D1,size=3D0x8000 Signed-off-by: Hal Martin --- hw/smbios/smbios.c | 65 ++++++++++++++++++++++++++++++++++++ include/hw/firmware/smbios.h | 18 ++++++++++ qemu-options.hx | 2 ++ 3 files changed, 85 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index a394514264..c8c62d8064 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -83,6 +83,12 @@ static struct { .processor_family =3D 0x01, /* Other */ }; =20 +struct type7_instance { + uint16_t level, size; + QTAILQ_ENTRY(type7_instance) next; +}; +static QTAILQ_HEAD(, type7_instance) type7 =3D QTAILQ_HEAD_INITIALIZER(typ= e7); + struct type8_instance { const char *internal_reference, *external_reference; uint8_t connector_type, port_type; @@ -330,6 +336,23 @@ static const QemuOptDesc qemu_smbios_type4_opts[] =3D { { /* end of list */ } }; =20 +static const QemuOptDesc qemu_smbios_type7_opts[] =3D { + { + .name =3D "type", + .type =3D QEMU_OPT_NUMBER, + .help =3D "SMBIOS element type", + },{ + .name =3D "level", + .type =3D QEMU_OPT_NUMBER, + .help =3D "cache level", + },{ + .name =3D "size", + .type =3D QEMU_OPT_NUMBER, + .help =3D "cache size", + }, + { /* end of list */ } +}; + static const QemuOptDesc qemu_smbios_type8_opts[] =3D { { .name =3D "type", @@ -733,6 +756,34 @@ static void smbios_build_type_4_table(MachineState *ms= , unsigned instance, smbios_type4_count++; } =20 +static void smbios_build_type_7_table(void) +{ + unsigned instance =3D 0; + struct type7_instance *t7; + char designation[20]; + + QTAILQ_FOREACH(t7, &type7, next) { + SMBIOS_BUILD_TABLE_PRE(7, T0_BASE + instance, true); + sprintf(designation, "CPU Internal L%d", t7->level); + SMBIOS_TABLE_SET_STR(7, socket_designation, designation); + /* cache not socketed, enabled, write back */ + t->cache_configuration =3D cpu_to_le16(0x180 | ((t7->level) - 1)); + t->installed_size =3D cpu_to_le16(t7->size); + /* set max size to installed size */ + t->maximum_cache_size =3D cpu_to_le16(t7->size); + t->supported_sram_type =3D cpu_to_le16(0x10); /* pipeline burst */ + t->current_sram_type =3D cpu_to_le16(0x10); /* pipeline burst */ + t->cache_speed =3D 0x1; /* 1 ns */ + t->error_correction_type =3D 0x6; /* Multi-bit ECC */ + t->system_cache_type =3D 0x05; /* Unified */ + t->associativity =3D 0x6; /* Fully Associative */ + t->maximum_cache_size2 =3D cpu_to_le32(t7->size); + t->installed_cache_size2 =3D cpu_to_le32(t7->size); + SMBIOS_BUILD_TABLE_POST; + instance++; + } +} + static void smbios_build_type_8_table(void) { unsigned instance =3D 0; @@ -1120,6 +1171,7 @@ static bool smbios_get_tables_ep(MachineState *ms, } } =20 + smbios_build_type_7_table(); smbios_build_type_8_table(); smbios_build_type_9_table(errp); smbios_build_type_11_table(); @@ -1478,6 +1530,19 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) UINT16_MAX); } return; + case 7: + if (!qemu_opts_validate(opts, qemu_smbios_type7_opts, errp)) { + return; + } + struct type7_instance *t7_i; + t7_i =3D g_new0(struct type7_instance, 1); + t7_i->level =3D qemu_opt_get_number(opts, "level", 0x0); + t7_i->size =3D qemu_opt_get_number(opts, "size", 0x0200); + /* Only cache levels 1-8 are permitted */ + if (t7_i->level > 0 && t7_i->level < 9) { + QTAILQ_INSERT_TAIL(&type7, t7_i, next); + } + return; case 8: if (!qemu_opts_validate(opts, qemu_smbios_type8_opts, errp)) { return; diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index f066ab7262..1ea1506b46 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -220,6 +220,24 @@ typedef enum smbios_type_4_len_ver { SMBIOS_TYPE_4_LEN_V30 =3D offsetofend(struct smbios_type_4, thread_cou= nt2), } smbios_type_4_len_ver; =20 +/* SMBIOS type 7 - Cache Information (v2.0+) */ +struct smbios_type_7 { + struct smbios_structure_header header; + uint8_t socket_designation; + uint16_t cache_configuration; + uint16_t maximum_cache_size; + uint16_t installed_size; + uint16_t supported_sram_type; + uint16_t current_sram_type; + uint8_t cache_speed; + uint8_t error_correction_type; + uint8_t system_cache_type; + uint8_t associativity; + uint32_t maximum_cache_size2; + uint32_t installed_cache_size2; + /* contained elements follow */ +} QEMU_PACKED; + /* SMBIOS type 8 - Port Connector Information */ struct smbios_type_8 { struct smbios_structure_header header; diff --git a/qemu-options.hx b/qemu-options.hx index d94e2cbbae..21c05821d5 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2706,6 +2706,8 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " [,asset=3Dstr][,part=3Dstr][,max-speed=3D%d][,current-s= peed=3D%d]\n" " [,processor-family=3D%d][,processor-id=3D%d]\n" " specify SMBIOS type 4 fields\n" + "-smbios type=3D7[,level=3D%d][,size=3D%d]\n" + " specify SMBIOS type 7 fields\n" "-smbios type=3D8[,external_reference=3Dstr][,internal_reference=3Dstr= ][,connector_type=3D%d][,port_type=3D%d]\n" " specify SMBIOS type 8 fields\n" "-smbios type=3D11[,value=3Dstr][,path=3Dfilename]\n" --=20 2.42.0