From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429966; cv=none; d=zohomail.com; s=zohoarc; b=ONHf+IxjwOasiwF5FWBgg1F6VwWZaMj9KhOXVWnl3eSjeSwYz32Lyyt0qNSLGxC1dNZ+J/rkfO3Tj+jI+gioktGvalzoV54SQro9s/RcysT7kI4G3Cdgw7zmo+pbmb+q+F8r4VyuwxMMbybGEXVY2ZGz6Kltx5kID128bcTgGWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429966; h=Content-Type: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=zrOfTp4lXNJjHFK37vxizV4ejdSxQomjIbB/lBZGO04=; b=CIafvbxd7k2HoopKhPFfUotDwaaMAFv7YsA52lJQ4IHdjqXzN/1WDfULrjXSSK2jbfZjqIDjVTjKM1qeCzHYsjkg0wIR9T0hHjUApKZTORvaHTT9EVBnA6bZIBVQvQE8JTceWrevtw+VPoSi5QCYZJTZZo++UQScypKsNi190EI= 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 1710429966128270.34360278034205; Thu, 14 Mar 2024 08:26:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvN-0007Cs-DH; Thu, 14 Mar 2024 11:23:17 -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 1rkmvG-0007A7-Lu for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvF-0003ji-7R for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-373-go_irbkuPWKku7JEYtS7gg-1; Thu, 14 Mar 2024 11:23:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB761800268; Thu, 14 Mar 2024 15:23:05 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0050A17A90; Thu, 14 Mar 2024 15:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429787; 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=zrOfTp4lXNJjHFK37vxizV4ejdSxQomjIbB/lBZGO04=; b=QSSHemC8iRFrucF0pvWEIe+wwZ2jHmhzV/OLPz3VeM9da+zUp9F+3oGJrMcQBSPCegLaTP JojRDKigcfxOm93jKCjN/JGvcnXFarpQcoIp+j5AP1VD5mKLO5FSyJeXc4KMklotTQvWYj lXT+m1lra2bJi7Y9rVQyLjzO29PSMPM= X-MC-Unique: go_irbkuPWKku7JEYtS7gg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 01/21] tests: smbios: make it possible to write SMBIOS only test Date: Thu, 14 Mar 2024 16:22:42 +0100 Message-Id: <20240314152302.2324164-2-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429968171100003 Cureently it not possible to run SMBIOS test without ACPI one, which gets into the way when testing ACPI-less configs. Extract SMBIOS testing into separate routines that could also be run without ACPI dependency and use that for testing SMBIOS. As the 1st user add "acpi/piix4/smbios-options" test case. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- tests/qtest/bios-tables-test.c | 47 +++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 21811a1ab5..b2992bafa8 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -858,16 +858,8 @@ static void test_vm_prepare(const char *params, test_d= ata *data) g_free(args); } =20 -static void process_acpi_tables_noexit(test_data *data) +static void process_smbios_tables_noexit(test_data *data) { - test_acpi_load_tables(data); - - if (getenv(ACPI_REBUILD_EXPECTED_AML)) { - dump_aml_files(data, true); - } else { - test_acpi_asl(data); - } - /* * TODO: make SMBIOS tests work with UEFI firmware, * Bug on uefi-test-tools to provide entry point: @@ -879,6 +871,27 @@ static void process_acpi_tables_noexit(test_data *data) } } =20 +static void test_smbios(const char *params, test_data *data) +{ + test_vm_prepare(params, data); + boot_sector_test(data->qts); + process_smbios_tables_noexit(data); + qtest_quit(data->qts); +} + +static void process_acpi_tables_noexit(test_data *data) +{ + test_acpi_load_tables(data); + + if (getenv(ACPI_REBUILD_EXPECTED_AML)) { + dump_aml_files(data, true); + } else { + test_acpi_asl(data); + } + + process_smbios_tables_noexit(data); +} + static void process_acpi_tables(test_data *data) { process_acpi_tables_noexit(data); @@ -2064,6 +2077,20 @@ static void test_acpi_q35_pvpanic_isa(void) free_test_data(&data); } =20 +static void test_acpi_pc_smbios_options(void) +{ + uint8_t req_type11[] =3D { 11 }; + test_data data =3D { + .machine =3D MACHINE_PC, + .variant =3D ".pc_smbios_options", + .required_struct_types =3D req_type11, + .required_struct_types_len =3D ARRAY_SIZE(req_type11), + }; + + test_smbios("-smbios type=3D11,value=3DTEST", &data); + free_test_data(&data); +} + static void test_oem_fields(test_data *data) { int i; @@ -2215,6 +2242,8 @@ int main(int argc, char *argv[]) #ifdef CONFIG_POSIX qtest_add_func("acpi/piix4/acpierst", test_acpi_piix4_acpi_ers= t); #endif + qtest_add_func("acpi/piix4/smbios-options", + test_acpi_pc_smbios_options); } if (qtest_has_machine(MACHINE_Q35)) { qtest_add_func("acpi/q35", test_acpi_q35_tcg); --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429979; cv=none; d=zohomail.com; s=zohoarc; b=FOaYxxNDn16uVPMAyJha7qdUrjSNzgSsk/dPmFm5XsOdmk+yyEeyAuLWqdt36bZMAIK246cVd/x9TaNFQa87CLerVUAP15fdLNT8RPfSZmt5MIGzAKNRaN6MQlA3yKgY/eueLko0QLpunolQ5KYq9S6mHIzd8na7n9j/D9O27z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429979; h=Content-Type: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=6tmmkz0v1gAREBV/ns3ox69HHc78tIUnrLE1mw14Ye8=; b=fcB/YD9+choq2yHHUSzvbbkIPRmC3Di4LEyEwvvS3S6oZjpm5v+DYSfrt0KpmeNBZtcVj2n4dwUJ29d5aFC1qKHasKIqN3Jz7YvQr0n31Wnp9OVa25VyaGg31CjkHG2VZMCO3gUb8swMZic3OvQ3Q9kWpNztYq9GEPM1KZeQeWw= 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 1710429979304695.5205474664295; Thu, 14 Mar 2024 08:26:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvN-0007E0-Le; Thu, 14 Mar 2024 11:23:17 -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 1rkmvK-0007Cg-Op for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvI-0003k8-HT for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:14 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-v1eUG4i1ODKqqymO1R1vFg-1; Thu, 14 Mar 2024 11:23:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAC2828B6AC3; Thu, 14 Mar 2024 15:23:06 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 177ED111E5; Thu, 14 Mar 2024 15:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429791; 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=6tmmkz0v1gAREBV/ns3ox69HHc78tIUnrLE1mw14Ye8=; b=bIuMI00dlicO3RERcVwicdAMWDgN1zFK/KlrbH9TJhrNp9/Z2ockeC4tv6eaCz0U5UO36g wVC86gI8kwi9l62kh5hwZZoeWNcMUZK+SBbIcaWd/wMhtl4lV6jAIoHGMFTW9GOVmoYBkk QjetgHMaxCoWe3UZ9rVk6dpl6A+9N0w= X-MC-Unique: v1eUG4i1ODKqqymO1R1vFg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 02/21] tests: smbios: add test for -smbios type=11 option Date: Thu, 14 Mar 2024 16:22:43 +0100 Message-Id: <20240314152302.2324164-3-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429980239100003 Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- tests/data/smbios/type11_blob | Bin 0 -> 11 bytes tests/qtest/bios-tables-test.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/data/smbios/type11_blob diff --git a/tests/data/smbios/type11_blob b/tests/data/smbios/type11_blob new file mode 100644 index 0000000000000000000000000000000000000000..1d8fea4b0c6f040a13ba99c3fad= 762538b795614 GIT binary patch literal 11 Scmd;PW!S(N;u;*nzyJUX)&c?m literal 0 HcmV?d00001 diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index b2992bafa8..a116f88e1d 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -2091,6 +2091,21 @@ static void test_acpi_pc_smbios_options(void) free_test_data(&data); } =20 +static void test_acpi_pc_smbios_blob(void) +{ + uint8_t req_type11[] =3D { 11 }; + test_data data =3D { + .machine =3D MACHINE_PC, + .variant =3D ".pc_smbios_blob", + .required_struct_types =3D req_type11, + .required_struct_types_len =3D ARRAY_SIZE(req_type11), + }; + + test_smbios("-machine smbios-entry-point-type=3D32 " + "-smbios file=3Dtests/data/smbios/type11_blob", &data); + free_test_data(&data); +} + static void test_oem_fields(test_data *data) { int i; @@ -2244,6 +2259,8 @@ int main(int argc, char *argv[]) #endif qtest_add_func("acpi/piix4/smbios-options", test_acpi_pc_smbios_options); + qtest_add_func("acpi/piix4/smbios-blob", + test_acpi_pc_smbios_blob); } if (qtest_has_machine(MACHINE_Q35)) { qtest_add_func("acpi/q35", test_acpi_q35_tcg); --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429969; cv=none; d=zohomail.com; s=zohoarc; b=W0NIw6gqPCBLXTG9PRt0c59kwkd7SUEDqMsJhkY9agZhcA87MSeUnpJJXSGTJs1kZxeh3H0+FmQZiLBNb9wdpmJnpBlJTY1SN4oU8HTVlEutZ25/5C2Cm3r7I/Ug7VXWhpn2s5co9wkMePpM59tyMYIPRlnWKkNYqckBpeLU8AQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429969; h=Content-Type: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=mEysAxw1rtqLbi7QK6dBGnD+kHUMmHQF+OEuJnW7U90=; b=bNbbSqOZ1ha+Vd1R4LxRBTjkv6tk6NOMtCdIeWaX+2Q4ysb4BSNQr9vIV3RHCG0rGYkfHakfpq5rP8AvKrJj5to/hMTPPnQEuGQCRMkUYYNPwMBTcnDaR1eb5haq8e4cqLN5gSQAb0fFHzWF7oS6eNonkrH2UCaZtmbZl5xQous= 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 1710429969393753.3097707655894; Thu, 14 Mar 2024 08:26:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvP-0007F5-8a; Thu, 14 Mar 2024 11:23:19 -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 1rkmvN-0007Dg-0Y for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvL-0003kV-Jy for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-464-ygMa5OFzP46mBn4ww028wg-1; Thu, 14 Mar 2024 11:23:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 063E9185A789; Thu, 14 Mar 2024 15:23:08 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26A8917A8E; Thu, 14 Mar 2024 15:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429794; 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=mEysAxw1rtqLbi7QK6dBGnD+kHUMmHQF+OEuJnW7U90=; b=YQxgKb4Lufxo7ViCbJ26SqLTRRX7uEaaLnO5sRWAUADHLO23ljLAN1tPOcAapG7idc7vka 6ZGkOMc2ouy4jtpFp/IG3hEzTB6B6MLnF2vIk9mWQZMPusgRrDtvMRT4nP62W6GOYVsp1U uaBM12BbOlYySTkfMvgOgxwArdzkPU0= X-MC-Unique: ygMa5OFzP46mBn4ww028wg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 03/21] tests: smbios: add test for legacy mode CLI options Date: Thu, 14 Mar 2024 16:22:44 +0100 Message-Id: <20240314152302.2324164-4-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429975710100001 Unfortunately having 2.0 machine type deprecated is not enough to get rid of legacy SMBIOS handling since 'isapc' also uses that and it's staying around. Hence add test for CLI options handling to be sure that it ain't broken during SMBIOS code refactoring. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- tests/data/smbios/type11_blob.legacy | Bin 0 -> 10 bytes tests/qtest/bios-tables-test.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/data/smbios/type11_blob.legacy diff --git a/tests/data/smbios/type11_blob.legacy b/tests/data/smbios/type1= 1_blob.legacy new file mode 100644 index 0000000000000000000000000000000000000000..aef463aab903405958b0a85f85c= 5980671c08bee GIT binary patch literal 10 Rcmd;PW!S(N;u;*n000Tp0s;U4 literal 0 HcmV?d00001 diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index a116f88e1d..d1ff4db7a2 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -2106,6 +2106,21 @@ static void test_acpi_pc_smbios_blob(void) free_test_data(&data); } =20 +static void test_acpi_isapc_smbios_legacy(void) +{ + uint8_t req_type11[] =3D { 1, 11 }; + test_data data =3D { + .machine =3D "isapc", + .variant =3D ".pc_smbios_legacy", + .required_struct_types =3D req_type11, + .required_struct_types_len =3D ARRAY_SIZE(req_type11), + }; + + test_smbios("-smbios file=3Dtests/data/smbios/type11_blob.legacy " + "-smbios type=3D1,family=3DTEST", &data); + free_test_data(&data); +} + static void test_oem_fields(test_data *data) { int i; @@ -2261,6 +2276,8 @@ int main(int argc, char *argv[]) test_acpi_pc_smbios_options); qtest_add_func("acpi/piix4/smbios-blob", test_acpi_pc_smbios_blob); + qtest_add_func("acpi/piix4/smbios-legacy", + test_acpi_isapc_smbios_legacy); } if (qtest_has_machine(MACHINE_Q35)) { qtest_add_func("acpi/q35", test_acpi_q35_tcg); --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429983; cv=none; d=zohomail.com; s=zohoarc; b=V8IE04J8/67PSurGJsqMHejM+hSt6KjRZDeuXp2Wton3Hwrt2AFbgsbYS647M0j4CsGBhQwFoBXlIE/epq5dn3oApdzQczEmVD2FneVpFUmBM+ogKARdb0uczLkF74I8CK/rizGwp46YecC9DY9Ll6QdLNjMkcOsioqvnsUqt9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429983; h=Content-Type: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=3/NK4ZQnSPqZ/NjcmuEjo1fejMTyk3aJALKwU//Qpd4=; b=GkJhP7tzKzZbsqFWIWrU7WNmb6EGyiH+jAkl9/hER7Ltcaau5DmxA/7p3d0fTx1QxQG8eh4A1GkBI8pd463W4Gq366RQ2dYzypcwHe1uWvzCKU7a1mxRPTMcqMGKcCf8yppJGaINA3Q5k7M5biQZOmxGCb4mZEi/NbmCuH79JhA= 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 171042998307151.867800443969145; Thu, 14 Mar 2024 08:26:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvP-0007Ep-5T; Thu, 14 Mar 2024 11:23:19 -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 1rkmvO-0007E6-6n for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvM-0003kX-2B for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:17 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-Goy66hFEMRS7x3kqJggg5A-1; Thu, 14 Mar 2024 11:23:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 177C93C0CD49; Thu, 14 Mar 2024 15:23:09 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 362D910F53; Thu, 14 Mar 2024 15:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429794; 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=3/NK4ZQnSPqZ/NjcmuEjo1fejMTyk3aJALKwU//Qpd4=; b=KrrXf3303bADK/U9oHyt2HtQyGsnGWXKQiP5l0Eg0BrQq9vnu26PfLe2LdTzKnVA4g6Ij+ r+DvDdtSwZNiM3wuHK9zGSol7msonGjMjJgXSGZT+nmRfaDyHiRWaJK/qEl9d4doo0TJxi qaAk6/dLuFcVPwhNpStr8X4Cbwwy16A= X-MC-Unique: Goy66hFEMRS7x3kqJggg5A-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 04/21] smbios: cleanup smbios_get_tables() from legacy handling Date: Thu, 14 Mar 2024 16:22:45 +0100 Message-Id: <20240314152302.2324164-5-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429984142100003 smbios_get_tables() bails out right away if leagacy mode is enabled and won't generate any SMBIOS tables. At the same time x86 specific fw_cfg_build_smbios() will genarate legacy tables and then proceed to preparing temporary mem_array for useless call to smbios_get_tables() and then discard it. Drop legacy related check in smbios_get_tables() and return from fw_cfg_build_smbios() early if legacy tables where built without proceeding to non legacy part of the function. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- hw/i386/fw_cfg.c | 1 + hw/smbios/smbios.c | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 98a478c276..a635234e68 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -74,6 +74,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState= *fw_cfg) if (smbios_tables) { fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); + return; } =20 /* build the array of physical mem area from e820 table */ diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index e3d5d8f2e2..22369b49fb 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1229,12 +1229,6 @@ void smbios_get_tables(MachineState *ms, { unsigned i, dimm_cnt, offset; =20 - if (smbios_legacy) { - *tables =3D *anchor =3D NULL; - *tables_len =3D *anchor_len =3D 0; - return; - } - if (!smbios_immutable) { smbios_build_type_0_table(); smbios_build_type_1_table(); --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429945; cv=none; d=zohomail.com; s=zohoarc; b=DYwkxVKUC06f6PJvfNcl7R+LhkHZkvs3vwb+e5DYnSF1J2azddD9t4gfU1j+y/SHyQXbvqfGR8++y2etwrFs8ldNc+2foTF5KAYrxK67Rl7Fb/phyyfT+wEKWxH5PGPd6PY6VdK+AhXqxxV4a/fSkU0+OVoUj/ik54Gv/Auzx2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429945; h=Content-Type: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=BNuuVqbnFf2X69DI7r1mO8VtMUdjo1Mq9PEC3PxXYoI=; b=ajIvJZMwm4rfMn+GhdBXeZhhsYyJnjcpkfzT7ScUtzzbGpo5w1wVlVIwBZIKSkzfuYfybUWjuat4gDBgn0rKM2XbTLQNjeq1NpN6XKTMPyoUEaYLF63PBKE/kEEcz5TGnbu5Kbdii3yCbLmTrHxvtM9C2FJplF2T72gEayMXORU= 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 1710429945736556.8303155065352; Thu, 14 Mar 2024 08:25:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvq-0007lS-J1; Thu, 14 Mar 2024 11:23:46 -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 1rkmvk-0007Y3-Ed for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvi-0003pz-Q8 for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-Kx76xNPMN4qrcwmYJ36FDA-1; Thu, 14 Mar 2024 11:23:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 254EC1019DFF; Thu, 14 Mar 2024 15:23:10 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45DF6111E5; Thu, 14 Mar 2024 15:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429818; 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=BNuuVqbnFf2X69DI7r1mO8VtMUdjo1Mq9PEC3PxXYoI=; b=iNQXo+ug82/EWPBMwHeSPK2DCIgS2ZfippPFb62PJ5TJebJ/j+ECk5qYI0Ndjcc/pslG1c NGq1nPoseVyAlT/7Gc9Hsue2KzhOI+S6XYehgdQv9gK60SCkDav6XySzTh4++Cj40DISHD d8Y9So+zi5/tAsXxGRwbK0G6TxB5Anw= X-MC-Unique: Kx76xNPMN4qrcwmYJ36FDA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 05/21] smbios: get rid of smbios_smp_sockets global Date: Thu, 14 Mar 2024 16:22:46 +0100 Message-Id: <20240314152302.2324164-6-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429948034100003 it makes smbios_validate_table() independent from smbios_smp_sockets global, which in turn lets smbios_get_tables() avoid using not related legacy code. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- goal here is to isolate legacy handling from generic smbios_get_tables() --- include/hw/firmware/smbios.h | 2 +- hw/i386/fw_cfg.c | 2 +- hw/smbios/smbios.c | 22 +++++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index c21b8d3285..36744b6cc9 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -313,7 +313,7 @@ void smbios_set_defaults(const char *manufacturer, cons= t char *product, const char *version, bool legacy_mode, bool uuid_encoded, SmbiosEntryPointType ep_type); void smbios_set_default_processor_family(uint16_t processor_family); -uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length); +uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h); void smbios_get_tables(MachineState *ms, const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index a635234e68..fcb4fb0769 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -70,7 +70,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState= *fw_cfg) /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); =20 - smbios_tables =3D smbios_get_table_legacy(ms, &smbios_tables_len); + smbios_tables =3D smbios_get_table_legacy(ms->smp.cpus, &smbios_tables= _len); if (smbios_tables) { fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 22369b49fb..50617fa585 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -70,7 +70,7 @@ static SmbiosEntryPoint ep; static int smbios_type4_count =3D 0; static bool smbios_immutable; static bool smbios_have_defaults; -static uint32_t smbios_cpuid_version, smbios_cpuid_features, smbios_smp_so= ckets; +static uint32_t smbios_cpuid_version, smbios_cpuid_features; =20 static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1); static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1); @@ -539,14 +539,11 @@ opts_init(smbios_register_config); */ #define SMBIOS_21_MAX_TABLES_LEN 0xffff =20 -static void smbios_validate_table(MachineState *ms) +static void smbios_validate_table(uint32_t expected_t4_count) { - uint32_t expect_t4_count =3D smbios_legacy ? - ms->smp.cpus : smbios_smp_sockets; - - if (smbios_type4_count && smbios_type4_count !=3D expect_t4_count) { + if (smbios_type4_count && smbios_type4_count !=3D expected_t4_count) { error_report("Expected %d SMBIOS Type 4 tables, got %d instead", - expect_t4_count, smbios_type4_count); + expected_t4_count, smbios_type4_count); exit(1); } =20 @@ -634,7 +631,7 @@ static void smbios_build_type_1_fields(void) } } =20 -uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length) +uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h) { if (!smbios_legacy) { *length =3D 0; @@ -644,7 +641,7 @@ uint8_t *smbios_get_table_legacy(MachineState *ms, size= _t *length) if (!smbios_immutable) { smbios_build_type_0_fields(); smbios_build_type_1_fields(); - smbios_validate_table(ms); + smbios_validate_table(expected_t4_count); smbios_immutable =3D true; } *length =3D smbios_entries_len; @@ -1235,10 +1232,9 @@ void smbios_get_tables(MachineState *ms, smbios_build_type_2_table(); smbios_build_type_3_table(); =20 - smbios_smp_sockets =3D ms->smp.sockets; - assert(smbios_smp_sockets >=3D 1); + assert(ms->smp.sockets >=3D 1); =20 - for (i =3D 0; i < smbios_smp_sockets; i++) { + for (i =3D 0; i < ms->smp.sockets; i++) { smbios_build_type_4_table(ms, i); } =20 @@ -1284,7 +1280,7 @@ void smbios_get_tables(MachineState *ms, smbios_build_type_41_table(errp); smbios_build_type_127_table(); =20 - smbios_validate_table(ms); + smbios_validate_table(ms->smp.sockets); smbios_entry_point_setup(); smbios_immutable =3D true; } --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429922; cv=none; d=zohomail.com; s=zohoarc; b=bUFyg3iCuGG22oIQxranBqCQ5qAUZlzbU4Tt8tIrG3kAB8DtYKz5XKOfCsnquhTz4iwRUmmCHEmy7Cn1EY2AnbTv4GWwd06X3H3pIra3erY2NwpBz6MJNUWPeHMDYW8C4ODYEiC5pbHVU2U5hIEvx7Cnf9el6EcML3Xn4KmpzNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429922; h=Content-Type: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=CRZL1avzWzkFLwaz2cNBVYSLwzPOC1TZbFobGDjGVns=; b=jWRhA9S1wrQ2XqZAXPMZbSudJc48xoJRWAPRRdHXybKEDnQkcLdrtKy2piyOakL10QKkfS0chIpGmDwPQF5LQY4WdFHMMQKKQ2Nuvg2lKkQdiY/scGTl2KT/lYOrcMGh97oMCyWumS1L7k18WFkpQsV8LrDU30gmSy6Io4AQTMA= 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 171042992219321.02787107572783; Thu, 14 Mar 2024 08:25:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvQ-0007Gn-Gu; Thu, 14 Mar 2024 11:23:20 -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 1rkmvP-0007Eo-2G for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvN-0003kl-3Q for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:18 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-rxb-JrEBNAW_0TmrBhBgSA-1; Thu, 14 Mar 2024 11:23:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53D04185A784; Thu, 14 Mar 2024 15:23:11 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5639C10F53; Thu, 14 Mar 2024 15:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429796; 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=CRZL1avzWzkFLwaz2cNBVYSLwzPOC1TZbFobGDjGVns=; b=fiVUmBCW5ih33EkiuZYxNCjAn28OGCAmO7b6oh+ClG/LwgUrJ7LXjcrAhWQ4RBZ92jxZh7 /lxHM1Bb1iw2ryh4vyt0KZyu5ntIDjbrYJNOtOiGJ+/uPtNTSvpoMFGDb3pVptF4hJW2St LSyUgDH2f8lz/S3mBmJASdEc+bWd+LA= X-MC-Unique: rxb-JrEBNAW_0TmrBhBgSA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Daniel Henrique Barboza , Fiona Ebner Subject: [PATCH v4 06/21] smbios: get rid of smbios_legacy global Date: Thu, 14 Mar 2024 16:22:47 +0100 Message-Id: <20240314152302.2324164-7-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429923952100003 clean up smbios_set_defaults() which is reused by legacy and non legacy machines from being aware of 'legacy' notion and need to turn it off. And push legacy handling up to PC machine code where it's relevant. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Acked-by: Daniel Henrique Barboza Tested-by: Fiona Ebner --- PS: I've moved/kept legacy smbios_entries to smbios_get_tables() but it at least is not visible to API users. To get rid of it as well, it would be necessary to change how '-smbios' CLI option is processed. Which is done later in the series. --- include/hw/firmware/smbios.h | 2 +- hw/arm/virt.c | 2 +- hw/i386/fw_cfg.c | 7 ++++--- hw/loongarch/virt.c | 2 +- hw/riscv/virt.c | 2 +- hw/smbios/smbios.c | 35 +++++++++++++++-------------------- 6 files changed, 23 insertions(+), 27 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 36744b6cc9..7b42e7b4ac 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -310,7 +310,7 @@ struct smbios_type_127 { void smbios_entry_add(QemuOpts *opts, Error **errp); void smbios_set_cpuid(uint32_t version, uint32_t features); void smbios_set_defaults(const char *manufacturer, const char *product, - const char *version, bool legacy_mode, + const char *version, bool uuid_encoded, SmbiosEntryPointType ep_type); void smbios_set_default_processor_family(uint16_t processor_family); uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index e5cd935232..b634c908a7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1650,7 +1650,7 @@ static void virt_build_smbios(VirtMachineState *vms) } =20 smbios_set_defaults("QEMU", product, - vmc->smbios_old_sys_ver ? "1.0" : mc->name, false, + vmc->smbios_old_sys_ver ? "1.0" : mc->name, true, SMBIOS_ENTRY_POINT_TYPE_64); =20 /* build the array of physical mem area from base_memmap */ diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index fcb4fb0769..c1e9c0fd9c 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -63,15 +63,16 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgSta= te *fw_cfg) if (pcmc->smbios_defaults) { /* These values are guest ABI, do not change */ smbios_set_defaults("QEMU", mc->desc, mc->name, - pcmc->smbios_legacy_mode, pcmc->smbios_uuid_en= coded, + pcmc->smbios_uuid_encoded, pcms->smbios_entry_point_type); } =20 /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); =20 - smbios_tables =3D smbios_get_table_legacy(ms->smp.cpus, &smbios_tables= _len); - if (smbios_tables) { + if (pcmc->smbios_legacy_mode) { + smbios_tables =3D smbios_get_table_legacy(ms->smp.cpus, + &smbios_tables_len); fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); return; diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index efce112310..53bfdcee61 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -355,7 +355,7 @@ static void virt_build_smbios(LoongArchMachineState *la= ms) return; } =20 - smbios_set_defaults("QEMU", product, mc->name, false, + smbios_set_defaults("QEMU", product, mc->name, true, SMBIOS_ENTRY_POINT_TYPE_64); =20 smbios_get_tables(ms, NULL, 0, &smbios_tables, &smbios_tables_len, diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a094af97c3..535fd047ba 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1275,7 +1275,7 @@ static void virt_build_smbios(RISCVVirtState *s) product =3D "KVM Virtual Machine"; } =20 - smbios_set_defaults("QEMU", product, mc->name, false, + smbios_set_defaults("QEMU", product, mc->name, true, SMBIOS_ENTRY_POINT_TYPE_64); =20 if (riscv_is_32bit(&s->soc[0])) { diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 50617fa585..1bae36a6e0 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -54,7 +54,6 @@ struct smbios_table { =20 static uint8_t *smbios_entries; static size_t smbios_entries_len; -static bool smbios_legacy =3D true; static bool smbios_uuid_encoded =3D true; /* end: legacy structures & constants for <=3D 2.0 machines */ =20 @@ -633,9 +632,16 @@ static void smbios_build_type_1_fields(void) =20 uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h) { - if (!smbios_legacy) { - *length =3D 0; - return NULL; + /* drop unwanted version of command-line file blob(s) */ + g_free(smbios_tables); + smbios_tables =3D NULL; + + /* also complain if fields were given for types > 1 */ + if (find_next_bit(have_fields_bitmap, + SMBIOS_MAX_TYPE + 1, 2) < SMBIOS_MAX_TYPE + 1) { + error_report("can't process fields for smbios " + "types > 1 on machine versions < 2.1!"); + exit(1); } =20 if (!smbios_immutable) { @@ -1129,28 +1135,13 @@ void smbios_set_default_processor_family(uint16_t p= rocessor_family) } =20 void smbios_set_defaults(const char *manufacturer, const char *product, - const char *version, bool legacy_mode, + const char *version, bool uuid_encoded, SmbiosEntryPointType ep_type) { smbios_have_defaults =3D true; - smbios_legacy =3D legacy_mode; smbios_uuid_encoded =3D uuid_encoded; smbios_ep_type =3D ep_type; =20 - /* drop unwanted version of command-line file blob(s) */ - if (smbios_legacy) { - g_free(smbios_tables); - /* in legacy mode, also complain if fields were given for types > = 1 */ - if (find_next_bit(have_fields_bitmap, - SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) { - error_report("can't process fields for smbios " - "types > 1 on machine versions < 2.1!"); - exit(1); - } - } else { - g_free(smbios_entries); - } - SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer); SMBIOS_SET_DEFAULT(type1.product, product); SMBIOS_SET_DEFAULT(type1.version, version); @@ -1226,6 +1217,10 @@ void smbios_get_tables(MachineState *ms, { unsigned i, dimm_cnt, offset; =20 + /* drop unwanted (legacy) version of command-line file blob(s) */ + g_free(smbios_entries); + smbios_entries =3D NULL; + if (!smbios_immutable) { smbios_build_type_0_table(); smbios_build_type_1_table(); --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429819; cv=none; d=zohomail.com; s=zohoarc; b=RSdI4Y2u+V2DKNMMnr+dW5j5T/zf1r8ofYsJtyY09y/cRxE7sw9Jze+KVEvOwtUUCWPguMpEbxOTDQHvdGZ2zZTxy7OtrmM9zWmxaAwJiahgeldRo3WC1K0/ulR7npjsig4eU9NiYlh/i9T8yUhzJiP7ZNTpbwgg6UT44zfpk20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429819; h=Content-Type: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=TOGYzj9QNMH9aiiCLO1kK5prIlGB3WSc1dt3h5FLqqw=; b=eL0HxF2qLD+hPFPH/E/TYx6V4k1z+SCvWZFQof9HshZjt0XGA5G+PjwuiuzEEZNletSGEfdge3K71hFhXjHqjf2fXewtf93QjobmpCyMYzNT8XYTUoA5ylm0djk+2NTNAbgJm9FNA+CZiQYzAirRTS2D6L3xkF+j4oC0NMGMVV4= 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 17104298196731010.04240334247; Thu, 14 Mar 2024 08:23:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvS-0007Il-4u; Thu, 14 Mar 2024 11:23:22 -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 1rkmvQ-0007HS-Mo for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvO-0003lD-Ou for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:20 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-fFNWTYUcPZKK1m9-cRkhNw-1; Thu, 14 Mar 2024 11:23:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6330B3C025AC; Thu, 14 Mar 2024 15:23:12 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 845C8111E5; Thu, 14 Mar 2024 15:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429798; 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=TOGYzj9QNMH9aiiCLO1kK5prIlGB3WSc1dt3h5FLqqw=; b=QZ1WkeomJnMll6YAvEaaPugFe8Okc3IRjEPVxJ48NA1fMtzhw3gy6fBue+HtjMTusUBgQE QX+GNIHbwdL6FZNGMyhkMHqRBfnnquWNSdCPzcvNGjXkNhu5qR2DkBOXuuzWTixcW4iow/ 3qlo2topVPowkaXGjB4IRn/G8UUC/JU= X-MC-Unique: fFNWTYUcPZKK1m9-cRkhNw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Fiona Ebner , Ani Sinha Subject: [PATCH v4 07/21] smbios: avoid mangling user provided tables Date: Thu, 14 Mar 2024 16:22:48 +0100 Message-Id: <20240314152302.2324164-8-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429821790100011 currently smbios_entry_add() preserves internally '-smbios type=3D' options but tables provided with '-smbios file=3D' are stored directly into blob that eventually will be exposed to VM. And then later QEMU adds default/'-smbios type' entries on top into the same blob. It makes impossible to generate tables more than once, hence 'immutable' guard was used. Make it possible to regenerate final blob by storing user provided blobs into a dedicated area (usr_blobs) and then copy it when composing final blob. Which also makes handling of -smbios options consistent. As side effect of this and previous commits there is no need to generate legacy smbios_entries at the time options are parsed. Instead compose smbios_entries on demand from usr_blobs like it is done for non-legacy SMBIOS tables. Signed-off-by: Igor Mammedov Tested-by: Fiona Ebner Reviewed-by: Ani Sinha --- v4: fix conflicts when rebasing on top of: 04f143d828 Implement SMBIOS type 9 v2.6 735eee07d1 Implement base of SMBIOS type 9 descriptor --- hw/smbios/smbios.c | 181 +++++++++++++++++++++++---------------------- 1 file changed, 93 insertions(+), 88 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 1bae36a6e0..db422f4fb0 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -57,6 +57,14 @@ static size_t smbios_entries_len; static bool smbios_uuid_encoded =3D true; /* end: legacy structures & constants for <=3D 2.0 machines */ =20 +/* + * SMBIOS tables provided by user with '-smbios file=3D' option + */ +uint8_t *usr_blobs; +size_t usr_blobs_len; +static GArray *usr_blobs_sizes; +static unsigned usr_table_max; +static unsigned usr_table_cnt; =20 uint8_t *smbios_tables; size_t smbios_tables_len; @@ -67,7 +75,6 @@ static SmbiosEntryPointType smbios_ep_type =3D SMBIOS_ENT= RY_POINT_TYPE_32; static SmbiosEntryPoint ep; =20 static int smbios_type4_count =3D 0; -static bool smbios_immutable; static bool smbios_have_defaults; static uint32_t smbios_cpuid_version, smbios_cpuid_features; =20 @@ -632,9 +639,8 @@ static void smbios_build_type_1_fields(void) =20 uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h) { - /* drop unwanted version of command-line file blob(s) */ - g_free(smbios_tables); - smbios_tables =3D NULL; + int i; + size_t usr_offset; =20 /* also complain if fields were given for types > 1 */ if (find_next_bit(have_fields_bitmap, @@ -644,12 +650,33 @@ uint8_t *smbios_get_table_legacy(uint32_t expected_t4= _count, size_t *length) exit(1); } =20 - if (!smbios_immutable) { - smbios_build_type_0_fields(); - smbios_build_type_1_fields(); - smbios_validate_table(expected_t4_count); - smbios_immutable =3D true; + g_free(smbios_entries); + smbios_entries_len =3D sizeof(uint16_t); + smbios_entries =3D g_malloc0(smbios_entries_len); + + for (i =3D 0, usr_offset =3D 0; usr_blobs_sizes && i < usr_blobs_sizes= ->len; + i++) + { + struct smbios_table *table; + struct smbios_structure_header *header; + size_t size =3D g_array_index(usr_blobs_sizes, size_t, i); + + header =3D (struct smbios_structure_header *)(usr_blobs + usr_offs= et); + smbios_entries =3D g_realloc(smbios_entries, smbios_entries_len + + size + sizeof(*table)); + table =3D (struct smbios_table *)(smbios_entries + smbios_entries_= len); + table->header.type =3D SMBIOS_TABLE_ENTRY; + table->header.length =3D cpu_to_le16(sizeof(*table) + size); + memcpy(table->data, header, size); + smbios_entries_len +=3D sizeof(*table) + size; + (*(uint16_t *)smbios_entries) =3D + cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); + usr_offset +=3D size; } + + smbios_build_type_0_fields(); + smbios_build_type_1_fields(); + smbios_validate_table(expected_t4_count); *length =3D smbios_entries_len; return smbios_entries; } @@ -1217,68 +1244,68 @@ void smbios_get_tables(MachineState *ms, { unsigned i, dimm_cnt, offset; =20 - /* drop unwanted (legacy) version of command-line file blob(s) */ - g_free(smbios_entries); - smbios_entries =3D NULL; + g_free(smbios_tables); + smbios_tables =3D g_memdup2(usr_blobs, usr_blobs_len); + smbios_tables_len =3D usr_blobs_len; + smbios_table_max =3D usr_table_max; + smbios_table_cnt =3D usr_table_cnt; =20 - if (!smbios_immutable) { - smbios_build_type_0_table(); - smbios_build_type_1_table(); - smbios_build_type_2_table(); - smbios_build_type_3_table(); + smbios_build_type_0_table(); + smbios_build_type_1_table(); + smbios_build_type_2_table(); + smbios_build_type_3_table(); =20 - assert(ms->smp.sockets >=3D 1); + assert(ms->smp.sockets >=3D 1); =20 - for (i =3D 0; i < ms->smp.sockets; i++) { - smbios_build_type_4_table(ms, i); - } + for (i =3D 0; i < ms->smp.sockets; i++) { + smbios_build_type_4_table(ms, i); + } =20 - smbios_build_type_8_table(); - smbios_build_type_9_table(errp); - smbios_build_type_11_table(); + smbios_build_type_8_table(); + smbios_build_type_9_table(errp); + smbios_build_type_11_table(); =20 #define MAX_DIMM_SZ (16 * GiB) #define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \ : ((current_machine->ram_size - 1)= % MAX_DIMM_SZ) + 1) =20 - dimm_cnt =3D QEMU_ALIGN_UP(current_machine->ram_size, MAX_DIMM_SZ)= / MAX_DIMM_SZ; + dimm_cnt =3D QEMU_ALIGN_UP(current_machine->ram_size, MAX_DIMM_SZ) / + MAX_DIMM_SZ; =20 - /* - * The offset determines if we need to keep additional space betwe= en - * table 17 and table 19 header handle numbers so that they do - * not overlap. For example, for a VM with larger than 8 TB guest - * memory and DIMM like chunks of 16 GiB, the default space between - * the two tables (T19_BASE - T17_BASE =3D 512) is not enough. - */ - offset =3D (dimm_cnt > (T19_BASE - T17_BASE)) ? \ - dimm_cnt - (T19_BASE - T17_BASE) : 0; + /* + * The offset determines if we need to keep additional space between + * table 17 and table 19 header handle numbers so that they do + * not overlap. For example, for a VM with larger than 8 TB guest + * memory and DIMM like chunks of 16 GiB, the default space between + * the two tables (T19_BASE - T17_BASE =3D 512) is not enough. + */ + offset =3D (dimm_cnt > (T19_BASE - T17_BASE)) ? \ + dimm_cnt - (T19_BASE - T17_BASE) : 0; =20 - smbios_build_type_16_table(dimm_cnt); + smbios_build_type_16_table(dimm_cnt); =20 - for (i =3D 0; i < dimm_cnt; i++) { - smbios_build_type_17_table(i, GET_DIMM_SZ); - } + for (i =3D 0; i < dimm_cnt; i++) { + smbios_build_type_17_table(i, GET_DIMM_SZ); + } =20 - for (i =3D 0; i < mem_array_size; i++) { - smbios_build_type_19_table(i, offset, mem_array[i].address, - mem_array[i].length); - } + for (i =3D 0; i < mem_array_size; i++) { + smbios_build_type_19_table(i, offset, mem_array[i].address, + mem_array[i].length); + } =20 - /* - * make sure 16 bit handle numbers in the headers of tables 19 - * and 32 do not overlap. - */ - assert((mem_array_size + offset) < (T32_BASE - T19_BASE)); + /* + * make sure 16 bit handle numbers in the headers of tables 19 + * and 32 do not overlap. + */ + assert((mem_array_size + offset) < (T32_BASE - T19_BASE)); =20 - smbios_build_type_32_table(); - smbios_build_type_38_table(); - smbios_build_type_41_table(errp); - smbios_build_type_127_table(); + smbios_build_type_32_table(); + smbios_build_type_38_table(); + smbios_build_type_41_table(errp); + smbios_build_type_127_table(); =20 - smbios_validate_table(ms->smp.sockets); - smbios_entry_point_setup(); - smbios_immutable =3D true; - } + smbios_validate_table(ms->smp.sockets); + smbios_entry_point_setup(); =20 /* return tables blob and entry point (anchor), and their sizes */ *tables =3D smbios_tables; @@ -1378,13 +1405,10 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) { const char *val; =20 - assert(!smbios_immutable); - val =3D qemu_opt_get(opts, "file"); if (val) { struct smbios_structure_header *header; - int size; - struct smbios_table *table; /* legacy mode only */ + size_t size; =20 if (!qemu_opts_validate(opts, qemu_smbios_file_opts, errp)) { return; @@ -1401,9 +1425,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) * (except in legacy mode, where the second '\0' is implicit and * will be inserted by the BIOS). */ - smbios_tables =3D g_realloc(smbios_tables, smbios_tables_len + siz= e); - header =3D (struct smbios_structure_header *)(smbios_tables + - smbios_tables_len); + usr_blobs =3D g_realloc(usr_blobs, usr_blobs_len + size); + header =3D (struct smbios_structure_header *)(usr_blobs + + usr_blobs_len); =20 if (load_image_size(val, (uint8_t *)header, size) !=3D size) { error_setg(errp, "Failed to load SMBIOS file %s", val); @@ -1424,34 +1448,15 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) smbios_type4_count++; } =20 - smbios_tables_len +=3D size; - if (size > smbios_table_max) { - smbios_table_max =3D size; + if (!usr_blobs_sizes) { + usr_blobs_sizes =3D g_array_new(false, false, sizeof(size_t)); } - smbios_table_cnt++; - - /* add a copy of the newly loaded blob to legacy smbios_entries */ - /* NOTE: This code runs before smbios_set_defaults(), so we don't - * yet know which mode (legacy vs. aggregate-table) will be - * required. We therefore add the binary blob to both legacy - * (smbios_entries) and aggregate (smbios_tables) tables, and - * delete the one we don't need from smbios_set_defaults(), - * once we know which machine version has been requested. - */ - if (!smbios_entries) { - smbios_entries_len =3D sizeof(uint16_t); - smbios_entries =3D g_malloc0(smbios_entries_len); + g_array_append_val(usr_blobs_sizes, size); + usr_blobs_len +=3D size; + if (size > usr_table_max) { + usr_table_max =3D size; } - smbios_entries =3D g_realloc(smbios_entries, smbios_entries_len + - size + sizeof(*table)); - table =3D (struct smbios_table *)(smbios_entries + smbios_entries_= len); - table->header.type =3D SMBIOS_TABLE_ENTRY; - table->header.length =3D cpu_to_le16(sizeof(*table) + size); - memcpy(table->data, header, size); - smbios_entries_len +=3D sizeof(*table) + size; - (*(uint16_t *)smbios_entries) =3D - cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); - /* end: add a copy of the newly loaded blob to legacy smbios_entri= es */ + usr_table_cnt++; =20 return; } --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429903; cv=none; d=zohomail.com; s=zohoarc; b=VXedvhmofQ2X+Ys68dzKp7s2Scogr7dJuZCepDAxHbcLquqRObovBWkVCqDeTI5YYiTbp9fZoglrBlIXTuvj9sswxX8aZd0yO798XFhheMDPM4lGKSUxLvShV9UZE6Me7rWBprohK1IuJnX8LN+o5LVBRLD3CPJwivE8lINsXDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429903; h=Content-Type: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=3vBD+JsOLFDqHMmIMvJXY1unlGJe0a4FPz+DicaZ/RA=; b=Bx6C4YROwbfKxUf5zNTGroMSaQnwxg3aQ70kZZHeTFB/M/cEdewcgPaodckucnmBcM+RtwVDfkRGcOJjJTKRUGWeYUOB/kdhsGRsYZZg/HKnbUElcMELxkiqwuU+h54gcUvTlhsip+pxzbkPaGZRs4ncOcZVKQ+yqv+a3UdNxvM= 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 1710429903414554.1523687651905; Thu, 14 Mar 2024 08:25:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvZ-0007MK-GG; Thu, 14 Mar 2024 11:23:29 -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 1rkmvS-0007Iz-M4 for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvQ-0003la-Tn for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:22 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-8VLbgfJsPWGjuN_QH-oKMw-1; Thu, 14 Mar 2024 11:23:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 736E01C01E9F; Thu, 14 Mar 2024 15:23:13 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 939C916A9A; Thu, 14 Mar 2024 15:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429800; 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=3vBD+JsOLFDqHMmIMvJXY1unlGJe0a4FPz+DicaZ/RA=; b=VRjRSffXe3QplIxC2jjFaYMMFsUJzQKSmCaqUBJYoOwd2XICoOXKBJdaA6lCjS/xy1rUQ4 vWcRf1d6k+4m12l0olGrXuvr6syTAQXLvM3Hx6Mdhaoj40exgiJb2pImy7dEazwwZSp54i 6IRk6qyQ2LVWDcj2OceJ8qcuLwRB+HQ= X-MC-Unique: 8VLbgfJsPWGjuN_QH-oKMw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 08/21] smbios: don't check type4 structures in legacy mode Date: Thu, 14 Mar 2024 16:22:49 +0100 Message-Id: <20240314152302.2324164-9-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429904001100001 legacy mode doesn't support structures of type 2 and more, and CLI has a check for '-smbios type' option, however it's still possible to sneak in type4 as a blob with '-smbios file' option. However doing the later makes SMBIOS tables broken since SeaBIOS doesn't expect that. Rather than trying to add support for type4 to legacy code (both QEMU and SeaBIOS), simplify smbios_get_table_legacy() by dropping not relevant check in legacy code and error out on type4 blob. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- * The issue affects 'isapc' and pc-i440fx-2.0. the later is in deprecated state and to be dropped in near future * possibly the same issue applies to other SMBIOS types above type 1 but I haven't tested that, and well tables that aren't generated by SeaBIOS can get be added just fine (tested type11 blob). So I went with a minimal change to fixup type4 only that I'm touching. Leaving the rest for other time or when someone complains about it, which is very unlikely given it's really only remaining isapc machine. I'd very much prefer to deprecate 'isapc' and then drop all legacy related code (it will benefit not only SMBIOS but other code as well). BTW: 'isapc' is in semi-dead, I cna't boot RHEL6 on it with KVM enabled anymore (RHEL9 host), TCG still boots though. One more reason to get deprecate it. --- include/hw/firmware/smbios.h | 2 +- hw/i386/fw_cfg.c | 3 +-- hw/smbios/smbios.c | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 7b42e7b4ac..0f0dca8f83 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -313,7 +313,7 @@ void smbios_set_defaults(const char *manufacturer, cons= t char *product, const char *version, bool uuid_encoded, SmbiosEntryPointType ep_type); void smbios_set_default_processor_family(uint16_t processor_family); -uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h); +uint8_t *smbios_get_table_legacy(size_t *length); void smbios_get_tables(MachineState *ms, const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index c1e9c0fd9c..d1281066f4 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -71,8 +71,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState= *fw_cfg) smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); =20 if (pcmc->smbios_legacy_mode) { - smbios_tables =3D smbios_get_table_legacy(ms->smp.cpus, - &smbios_tables_len); + smbios_tables =3D smbios_get_table_legacy(&smbios_tables_len); fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); return; diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index db422f4fb0..a96e5cd839 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -545,14 +545,17 @@ opts_init(smbios_register_config); */ #define SMBIOS_21_MAX_TABLES_LEN 0xffff =20 -static void smbios_validate_table(uint32_t expected_t4_count) +static void smbios_check_type4_count(uint32_t expected_t4_count) { if (smbios_type4_count && smbios_type4_count !=3D expected_t4_count) { error_report("Expected %d SMBIOS Type 4 tables, got %d instead", expected_t4_count, smbios_type4_count); exit(1); } +} =20 +static void smbios_validate_table(void) +{ if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 && smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) { error_report("SMBIOS 2.1 table length %zu exceeds %d", @@ -637,7 +640,7 @@ static void smbios_build_type_1_fields(void) } } =20 -uint8_t *smbios_get_table_legacy(uint32_t expected_t4_count, size_t *lengt= h) +uint8_t *smbios_get_table_legacy(size_t *length) { int i; size_t usr_offset; @@ -650,6 +653,12 @@ uint8_t *smbios_get_table_legacy(uint32_t expected_t4_= count, size_t *length) exit(1); } =20 + if (test_bit(4, have_binfile_bitmap)) { + error_report("can't process table for smbios " + "type 4 on machine versions < 2.1!"); + exit(1); + } + g_free(smbios_entries); smbios_entries_len =3D sizeof(uint16_t); smbios_entries =3D g_malloc0(smbios_entries_len); @@ -676,7 +685,7 @@ uint8_t *smbios_get_table_legacy(uint32_t expected_t4_c= ount, size_t *length) =20 smbios_build_type_0_fields(); smbios_build_type_1_fields(); - smbios_validate_table(expected_t4_count); + smbios_validate_table(); *length =3D smbios_entries_len; return smbios_entries; } @@ -1304,7 +1313,8 @@ void smbios_get_tables(MachineState *ms, smbios_build_type_41_table(errp); smbios_build_type_127_table(); =20 - smbios_validate_table(ms->smp.sockets); + smbios_check_type4_count(ms->smp.sockets); + smbios_validate_table(); smbios_entry_point_setup(); =20 /* return tables blob and entry point (anchor), and their sizes */ --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429861; cv=none; d=zohomail.com; s=zohoarc; b=QK4rEumCwQk8q6ZjRO+wohIbbaRF3XUulnlt7n7U5zg1TAg9ib+wG8dWoqcHQE2P5irrWRefwq9R9Ui0ZBzKVp06cwASaRjC5LgbL/ZWuLd62LUu4aw3FXAt7QmIUWGuoRgtqxJ0LqBKI0ZFlkloiwMlhJB94aiswSJsfN4bxCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429861; h=Content-Type: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=qbnvYYXtvyNILwnEwzPHkrZpJ1rSzEzW0RlVGP4LJxI=; b=Wy+DlIQPMRfievIMmTDL1OkGh01aiFarxRJiSoqiI/LFzdEmqbhN01qXxQOL6sLupwu5whK/MUuCa09t/Mi2eJmq+Sqq1v5HEGMRMEXWUQSUCkoQkos85WId0/Cl8I4B8V32NgGa1R8sq5wKlGp4AzJ9KqBdR4zAKHYP+p9KU4M= 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 1710429861243165.70908255940674; Thu, 14 Mar 2024 08:24:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvb-0007NB-NB; Thu, 14 Mar 2024 11:23:31 -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 1rkmvS-0007J1-OX for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvR-0003lV-Ey for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:22 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-552-pX15jfZhMJe2cDisQ_zFKQ-1; Thu, 14 Mar 2024 11:23:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 775DD101CC6B for ; Thu, 14 Mar 2024 15:23:14 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A342616A9C; Thu, 14 Mar 2024 15:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429799; 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=qbnvYYXtvyNILwnEwzPHkrZpJ1rSzEzW0RlVGP4LJxI=; b=KGINCvA9vJx8oXzQKoM4xXrhVaDuYw3wWhkpiw4H96C3sWCLjr/WMYLA2H77bknMrxsGmb NNnxirUkLEeflkJNHRi3/ziNCIf/+5jCdzU1oD9ZPF+t9BAFM6of2VvhifYpdKFV2+UpmK R2/sNHv4gIWXUhQsgiMOYXgXubcTDaw= X-MC-Unique: pX15jfZhMJe2cDisQ_zFKQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha Subject: [PATCH v4 09/21] smbios: add smbios_add_usr_blob_size() helper Date: Thu, 14 Mar 2024 16:22:50 +0100 Message-Id: <20240314152302.2324164-10-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429885401100001 it will be used by follow up patch when legacy handling is moved out into a separate file. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha --- hw/smbios/smbios.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index a96e5cd839..d530667a9d 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1411,6 +1411,14 @@ static bool save_opt_list(size_t *ndest, char ***des= t, QemuOpts *opts, return true; } =20 +static void smbios_add_usr_blob_size(size_t size) +{ + if (!usr_blobs_sizes) { + usr_blobs_sizes =3D g_array_new(false, false, sizeof(size_t)); + } + g_array_append_val(usr_blobs_sizes, size); +} + void smbios_entry_add(QemuOpts *opts, Error **errp) { const char *val; @@ -1458,10 +1466,12 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) smbios_type4_count++; } =20 - if (!usr_blobs_sizes) { - usr_blobs_sizes =3D g_array_new(false, false, sizeof(size_t)); - } - g_array_append_val(usr_blobs_sizes, size); + /* + * preserve blob size for legacy mode so it could build its + * blobs flavor from 'usr_blobs' + */ + smbios_add_usr_blob_size(size); + usr_blobs_len +=3D size; if (size > usr_table_max) { usr_table_max =3D size; --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429895; cv=none; d=zohomail.com; s=zohoarc; b=jcPbXYvIpfwXLmyVx434bNuUTim4kMJhoj5aqJm+E6n7VBvLcIZygyHb73XQNef60L5rmJ+bi4dUa0C8QV0PjxoZ1af4DR5cbyH11MJap38uw0C+AXn3T6fwANilmszDSfAH+9JgADXYV2hW1gKEKb+OMN+IVEBX9hj3s6Qp2Lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429895; h=Content-Type: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=GtVai0wfhlJK9oqZsNhUAn7YwBsNEZysKpT0qchJskI=; b=D3zDecoHKxK5vL77JGMce5E1SjpKH9Z/kYEywJYU4TwIV0HSSft1HxrsnjonpNU7FqvvFBegodjZdD75mfvBLVckJbUi2+ZfKz+3AdsWlS+HA1HusgaNDeaFj5NzuDuVfwhLrlsymvmN5rvAgjfrSJCd64MHCqFLgxYtZvVhTmA= 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 1710429895341515.7146833151204; Thu, 14 Mar 2024 08:24:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvi-0007PE-1A; Thu, 14 Mar 2024 11:23:40 -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 1rkmvV-0007KP-BP for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvS-0003lv-Oh for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:24 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-Vifs8u5cM3u8pfK4greGnQ-1; Thu, 14 Mar 2024 11:23:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D3683C025AC for ; Thu, 14 Mar 2024 15:23:15 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A725D10F53; Thu, 14 Mar 2024 15:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429802; 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=GtVai0wfhlJK9oqZsNhUAn7YwBsNEZysKpT0qchJskI=; b=Qo1i2pt97nyarupeO1bQIVvz5HsmKSVJUJBvQ0dsfTw6kBjicW1+7+SlJPzK38V/FAzoyk 2/BMyzTC3kpC0CDh6ikzCBI2S9PPAKYmv9yu/LTaW3tOWGuI8e71QPRbjw9H0aN/1t3WKP jn3d/2a3WPP1/T6065wSTrpw3M1FdGc= X-MC-Unique: Vifs8u5cM3u8pfK4greGnQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha Subject: [PATCH v4 10/21] smbios: rename/expose structures/bitmaps used by both legacy and modern code Date: Thu, 14 Mar 2024 16:22:51 +0100 Message-Id: <20240314152302.2324164-11-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429896133100001 As a preparation to move legacy handling into a separate file, add prefix 'smbios_' to type0/type1/have_binfile_bitmap/have_fields_bitmap and expose them in smbios.h so that they can be reused in legacy and modern code. Doing it as a separate patch to avoid rename cluttering follow-up patch which will move legacy code into a separate file. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha --- include/hw/firmware/smbios.h | 16 +++++ hw/smbios/smbios.c | 113 ++++++++++++++++------------------- 2 files changed, 69 insertions(+), 60 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 0f0dca8f83..05707c6341 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -2,6 +2,7 @@ #define QEMU_SMBIOS_H =20 #include "qapi/qapi-types-machine.h" +#include "qemu/bitmap.h" =20 /* * SMBIOS Support @@ -16,8 +17,23 @@ * */ =20 +typedef struct { + const char *vendor, *version, *date; + bool have_major_minor, uefi; + uint8_t major, minor; +} smbios_type0_t; +extern smbios_type0_t smbios_type0; + +typedef struct { + const char *manufacturer, *product, *version, *serial, *sku, *family; + /* uuid is in qemu_uuid */ +} smbios_type1_t; +extern smbios_type1_t smbios_type1; =20 #define SMBIOS_MAX_TYPE 127 +extern DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); +extern DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); + #define offsetofend(TYPE, MEMBER) \ (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) =20 diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index d530667a9d..e93b8f9cb1 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -78,19 +78,11 @@ static int smbios_type4_count =3D 0; static bool smbios_have_defaults; static uint32_t smbios_cpuid_version, smbios_cpuid_features; =20 -static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1); -static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1); +DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); +DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); =20 -static struct { - const char *vendor, *version, *date; - bool have_major_minor, uefi; - uint8_t major, minor; -} type0; - -static struct { - const char *manufacturer, *product, *version, *serial, *sku, *family; - /* uuid is in qemu_uuid */ -} type1; +smbios_type0_t smbios_type0; +smbios_type1_t smbios_type1; =20 static struct { const char *manufacturer, *product, *version, *serial, *asset, *locati= on; @@ -599,36 +591,36 @@ static void smbios_maybe_add_str(int type, int offset= , const char *data) static void smbios_build_type_0_fields(void) { smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str), - type0.vendor); + smbios_type0.vendor); smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_st= r), - type0.version); + smbios_type0.version); smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_release_date_str), - type0.date); - if (type0.have_major_minor) { + smbios_type0.date); + if (smbios_type0.have_major_minor) { smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_major_release), - &type0.major, 1); + &smbios_type0.major, 1); smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_minor_release), - &type0.minor, 1); + &smbios_type0.minor, 1); } } =20 static void smbios_build_type_1_fields(void) { smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_st= r), - type1.manufacturer); + smbios_type1.manufacturer); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_st= r), - type1.product); + smbios_type1.product); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str), - type1.version); + smbios_type1.version); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_s= tr), - type1.serial); + smbios_type1.serial); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str), - type1.sku); + smbios_type1.sku); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str), - type1.family); + smbios_type1.family); if (qemu_uuid_set) { /* We don't encode the UUID in the "wire format" here because this * function is for legacy mode and needs to keep the guest ABI, and @@ -646,14 +638,14 @@ uint8_t *smbios_get_table_legacy(size_t *length) size_t usr_offset; =20 /* also complain if fields were given for types > 1 */ - if (find_next_bit(have_fields_bitmap, + if (find_next_bit(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1, 2) < SMBIOS_MAX_TYPE + 1) { error_report("can't process fields for smbios " "types > 1 on machine versions < 2.1!"); exit(1); } =20 - if (test_bit(4, have_binfile_bitmap)) { + if (test_bit(4, smbios_have_binfile_bitmap)) { error_report("can't process table for smbios " "type 4 on machine versions < 2.1!"); exit(1); @@ -694,10 +686,10 @@ uint8_t *smbios_get_table_legacy(size_t *length) =20 bool smbios_skip_table(uint8_t type, bool required_table) { - if (test_bit(type, have_binfile_bitmap)) { + if (test_bit(type, smbios_have_binfile_bitmap)) { return true; /* user provided their own binary blob(s) */ } - if (test_bit(type, have_fields_bitmap)) { + if (test_bit(type, smbios_have_fields_bitmap)) { return false; /* user provided fields via command line */ } if (smbios_have_defaults && required_table) { @@ -725,25 +717,25 @@ static void smbios_build_type_0_table(void) { SMBIOS_BUILD_TABLE_PRE(0, T0_BASE, false); /* optional, leave up to BI= OS */ =20 - SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor); - SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version); + SMBIOS_TABLE_SET_STR(0, vendor_str, smbios_type0.vendor); + SMBIOS_TABLE_SET_STR(0, bios_version_str, smbios_type0.version); =20 t->bios_starting_address_segment =3D cpu_to_le16(0xE800); /* from SeaB= IOS */ =20 - SMBIOS_TABLE_SET_STR(0, bios_release_date_str, type0.date); + SMBIOS_TABLE_SET_STR(0, bios_release_date_str, smbios_type0.date); =20 t->bios_rom_size =3D 0; /* hardcoded in SeaBIOS with FIXME comment */ =20 t->bios_characteristics =3D cpu_to_le64(0x08); /* Not supported */ t->bios_characteristics_extension_bytes[0] =3D 0; t->bios_characteristics_extension_bytes[1] =3D 0x14; /* TCD/SVVP | VM = */ - if (type0.uefi) { + if (smbios_type0.uefi) { t->bios_characteristics_extension_bytes[1] |=3D 0x08; /* |=3D UEFI= */ } =20 - if (type0.have_major_minor) { - t->system_bios_major_release =3D type0.major; - t->system_bios_minor_release =3D type0.minor; + if (smbios_type0.have_major_minor) { + t->system_bios_major_release =3D smbios_type0.major; + t->system_bios_minor_release =3D smbios_type0.minor; } else { t->system_bios_major_release =3D 0; t->system_bios_minor_release =3D 0; @@ -773,18 +765,18 @@ static void smbios_build_type_1_table(void) { SMBIOS_BUILD_TABLE_PRE(1, T1_BASE, true); /* required */ =20 - SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer); - SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product); - SMBIOS_TABLE_SET_STR(1, version_str, type1.version); - SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial); + SMBIOS_TABLE_SET_STR(1, manufacturer_str, smbios_type1.manufacturer); + SMBIOS_TABLE_SET_STR(1, product_name_str, smbios_type1.product); + SMBIOS_TABLE_SET_STR(1, version_str, smbios_type1.version); + SMBIOS_TABLE_SET_STR(1, serial_number_str, smbios_type1.serial); if (qemu_uuid_set) { smbios_encode_uuid(&t->uuid, &qemu_uuid); } else { memset(&t->uuid, 0, 16); } t->wake_up_type =3D 0x06; /* power switch */ - SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku); - SMBIOS_TABLE_SET_STR(1, family_str, type1.family); + SMBIOS_TABLE_SET_STR(1, sku_number_str, smbios_type1.sku); + SMBIOS_TABLE_SET_STR(1, family_str, smbios_type1.family); =20 SMBIOS_BUILD_TABLE_POST; } @@ -1178,9 +1170,9 @@ void smbios_set_defaults(const char *manufacturer, co= nst char *product, smbios_uuid_encoded =3D uuid_encoded; smbios_ep_type =3D ep_type; =20 - SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer); - SMBIOS_SET_DEFAULT(type1.product, product); - SMBIOS_SET_DEFAULT(type1.version, version); + SMBIOS_SET_DEFAULT(smbios_type1.manufacturer, manufacturer); + SMBIOS_SET_DEFAULT(smbios_type1.product, product); + SMBIOS_SET_DEFAULT(smbios_type1.version, version); SMBIOS_SET_DEFAULT(type2.manufacturer, manufacturer); SMBIOS_SET_DEFAULT(type2.product, product); SMBIOS_SET_DEFAULT(type2.version, version); @@ -1453,13 +1445,13 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) } =20 if (header->type <=3D SMBIOS_MAX_TYPE) { - if (test_bit(header->type, have_fields_bitmap)) { + if (test_bit(header->type, smbios_have_fields_bitmap)) { error_setg(errp, "can't load type %d struct, fields already spec= ified!", header->type); return; } - set_bit(header->type, have_binfile_bitmap); + set_bit(header->type, smbios_have_binfile_bitmap); } =20 if (header->type =3D=3D 4) { @@ -1490,41 +1482,42 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) return; } =20 - if (test_bit(type, have_binfile_bitmap)) { + if (test_bit(type, smbios_have_binfile_bitmap)) { error_setg(errp, "can't add fields, binary file already loaded= !"); return; } - set_bit(type, have_fields_bitmap); + set_bit(type, smbios_have_fields_bitmap); =20 switch (type) { case 0: if (!qemu_opts_validate(opts, qemu_smbios_type0_opts, errp)) { return; } - save_opt(&type0.vendor, opts, "vendor"); - save_opt(&type0.version, opts, "version"); - save_opt(&type0.date, opts, "date"); - type0.uefi =3D qemu_opt_get_bool(opts, "uefi", false); + save_opt(&smbios_type0.vendor, opts, "vendor"); + save_opt(&smbios_type0.version, opts, "version"); + save_opt(&smbios_type0.date, opts, "date"); + smbios_type0.uefi =3D qemu_opt_get_bool(opts, "uefi", false); =20 val =3D qemu_opt_get(opts, "release"); if (val) { - if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != =3D 2) { + if (sscanf(val, "%hhu.%hhu", &smbios_type0.major, + &smbios_type0.minor) !=3D 2) { error_setg(errp, "Invalid release"); return; } - type0.have_major_minor =3D true; + smbios_type0.have_major_minor =3D true; } return; case 1: if (!qemu_opts_validate(opts, qemu_smbios_type1_opts, errp)) { return; } - save_opt(&type1.manufacturer, opts, "manufacturer"); - save_opt(&type1.product, opts, "product"); - save_opt(&type1.version, opts, "version"); - save_opt(&type1.serial, opts, "serial"); - save_opt(&type1.sku, opts, "sku"); - save_opt(&type1.family, opts, "family"); + save_opt(&smbios_type1.manufacturer, opts, "manufacturer"); + save_opt(&smbios_type1.product, opts, "product"); + save_opt(&smbios_type1.version, opts, "version"); + save_opt(&smbios_type1.serial, opts, "serial"); + save_opt(&smbios_type1.sku, opts, "sku"); + save_opt(&smbios_type1.family, opts, "family"); =20 val =3D qemu_opt_get(opts, "uuid"); if (val) { --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429934; cv=none; d=zohomail.com; s=zohoarc; b=LV0/08VKP9JVhvxkt0ObqKilR3AJXRcqkcvXy6w0Mkk2DDQgw375S5+2hytycVLZ3tD0mzgEeB/Yx+CzcNB9b3shBTMDxnbeFBVuejM0NXfjtZv94JVJZCZzGZ2CwQ3mBMcygbiIvv2kP3Pkm+Q3kjkt3nOrgTEuCcjAymmYqf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429934; h=Content-Type: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=OSnxaerN4ymPyyrFZ6x5LyHjUj2REWh+i9PPy27zBTc=; b=HRpasXyl+BHaW8215j8UGSaknCiI4cQWz6WPDMrfA612mgnVIYihcqdjf3sg/lUbaNtu2cjWw17O4aW1I0oYfEa+Zf32zmSFI03K54rMYuLThsnKQHdJgEZjkAemwvFiEmWhB/4haN+zkVF63gZVi6U/RljYbPB2/zvk2OJ7Dgo= 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 1710429934238950.3452994477901; Thu, 14 Mar 2024 08:25:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvm-0007Zg-GM; Thu, 14 Mar 2024 11:23:42 -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 1rkmvW-0007LV-W3 for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvU-0003mE-Dv for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:26 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-BQwaL-s3PfKFMhrrybztuA-1; Thu, 14 Mar 2024 11:23:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DF57186E1C1 for ; Thu, 14 Mar 2024 15:23:16 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D78D16A9A; Thu, 14 Mar 2024 15:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429803; 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=OSnxaerN4ymPyyrFZ6x5LyHjUj2REWh+i9PPy27zBTc=; b=XtOUS1z96kxfkj0YNe0ApYDZIXKPRd05uKQCV/KjcZT3mwNmrqbvaGGjEiSEWyvjOXzU6w NE/d4GuZAzD5Ezenp5ECeNHEsPRjW5prdQgP7uL7Z6wSW1soQ6D4sN0raRvbVNs8rusKrv IGeD9MY4IqDBwv2gc9YMFlv34zOqA9c= X-MC-Unique: BQwaL-s3PfKFMhrrybztuA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha Subject: [PATCH v4 11/21] smbios: build legacy mode code only for 'pc' machine Date: Thu, 14 Mar 2024 16:22:52 +0100 Message-Id: <20240314152302.2324164-12-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429936127100003 basically moving code around without functional change. And exposing some symbols so that they could be shared between smbbios.c and new smbios_legacy.c plus some meson magic to build smbios_legacy.c only for 'pc' machine and otherwise replace it with stub if not selected. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha --- v2: moved type0/type1/have_binfile_bitmap/have_fields_bitmap rename into a separate patch v3: drop blank space at the end of hw/smbios/smbios_legacy_stub.c --- include/hw/firmware/smbios.h | 5 + hw/i386/Kconfig | 1 + hw/smbios/Kconfig | 2 + hw/smbios/meson.build | 4 + hw/smbios/smbios.c | 164 +----------------------------- hw/smbios/smbios_legacy.c | 179 +++++++++++++++++++++++++++++++++ hw/smbios/smbios_legacy_stub.c | 15 +++ 7 files changed, 207 insertions(+), 163 deletions(-) create mode 100644 hw/smbios/smbios_legacy.c create mode 100644 hw/smbios/smbios_legacy_stub.c diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 05707c6341..ccc51e72f5 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -17,6 +17,9 @@ * */ =20 +extern uint8_t *usr_blobs; +extern GArray *usr_blobs_sizes; + typedef struct { const char *vendor, *version, *date; bool have_major_minor, uefi; @@ -323,6 +326,8 @@ struct smbios_type_127 { struct smbios_structure_header header; } QEMU_PACKED; =20 +void smbios_validate_table(void); +void smbios_add_usr_blob_size(size_t size); void smbios_entry_add(QemuOpts *opts, Error **errp); void smbios_set_cpuid(uint32_t version, uint32_t features); void smbios_set_defaults(const char *manufacturer, const char *product, diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index a1846be6f7..a6ee052f9a 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -76,6 +76,7 @@ config I440FX select PIIX select DIMM select SMBIOS + select SMBIOS_LEGACY select FW_CFG_DMA =20 config ISAPC diff --git a/hw/smbios/Kconfig b/hw/smbios/Kconfig index 553adf4bfc..8d989a2f1b 100644 --- a/hw/smbios/Kconfig +++ b/hw/smbios/Kconfig @@ -1,2 +1,4 @@ config SMBIOS bool +config SMBIOS_LEGACY + bool diff --git a/hw/smbios/meson.build b/hw/smbios/meson.build index 7046967462..a59039f669 100644 --- a/hw/smbios/meson.build +++ b/hw/smbios/meson.build @@ -4,5 +4,9 @@ smbios_ss.add(when: 'CONFIG_IPMI', if_true: files('smbios_type_38.c'), if_false: files('smbios_type_38-stub.c')) =20 +smbios_ss.add(when: 'CONFIG_SMBIOS_LEGACY', + if_true: files('smbios_legacy.c'), + if_false: files('smbios_legacy_stub.c')) + system_ss.add_all(when: 'CONFIG_SMBIOS', if_true: smbios_ss) system_ss.add(when: 'CONFIG_SMBIOS', if_false: files('smbios-stub.c')) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index e93b8f9cb1..f9efe01233 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -31,38 +31,12 @@ #include "hw/pci/pci_device.h" #include "smbios_build.h" =20 -/* legacy structures and constants for <=3D 2.0 machines */ -struct smbios_header { - uint16_t length; - uint8_t type; -} QEMU_PACKED; - -struct smbios_field { - struct smbios_header header; - uint8_t type; - uint16_t offset; - uint8_t data[]; -} QEMU_PACKED; - -struct smbios_table { - struct smbios_header header; - uint8_t data[]; -} QEMU_PACKED; - -#define SMBIOS_FIELD_ENTRY 0 -#define SMBIOS_TABLE_ENTRY 1 - -static uint8_t *smbios_entries; -static size_t smbios_entries_len; static bool smbios_uuid_encoded =3D true; -/* end: legacy structures & constants for <=3D 2.0 machines */ - /* * SMBIOS tables provided by user with '-smbios file=3D' option */ uint8_t *usr_blobs; size_t usr_blobs_len; -static GArray *usr_blobs_sizes; static unsigned usr_table_max; static unsigned usr_table_cnt; =20 @@ -546,7 +520,7 @@ static void smbios_check_type4_count(uint32_t expected_= t4_count) } } =20 -static void smbios_validate_table(void) +void smbios_validate_table(void) { if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 && smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) { @@ -556,134 +530,6 @@ static void smbios_validate_table(void) } } =20 - -/* legacy setup functions for <=3D 2.0 machines */ -static void smbios_add_field(int type, int offset, const void *data, size_= t len) -{ - struct smbios_field *field; - - if (!smbios_entries) { - smbios_entries_len =3D sizeof(uint16_t); - smbios_entries =3D g_malloc0(smbios_entries_len); - } - smbios_entries =3D g_realloc(smbios_entries, smbios_entries_len + - sizeof(*field) + len); - field =3D (struct smbios_field *)(smbios_entries + smbios_entries_len); - field->header.type =3D SMBIOS_FIELD_ENTRY; - field->header.length =3D cpu_to_le16(sizeof(*field) + len); - - field->type =3D type; - field->offset =3D cpu_to_le16(offset); - memcpy(field->data, data, len); - - smbios_entries_len +=3D sizeof(*field) + len; - (*(uint16_t *)smbios_entries) =3D - cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); -} - -static void smbios_maybe_add_str(int type, int offset, const char *data) -{ - if (data) { - smbios_add_field(type, offset, data, strlen(data) + 1); - } -} - -static void smbios_build_type_0_fields(void) -{ - smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str), - smbios_type0.vendor); - smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_st= r), - smbios_type0.version); - smbios_maybe_add_str(0, offsetof(struct smbios_type_0, - bios_release_date_str), - smbios_type0.date); - if (smbios_type0.have_major_minor) { - smbios_add_field(0, offsetof(struct smbios_type_0, - system_bios_major_release), - &smbios_type0.major, 1); - smbios_add_field(0, offsetof(struct smbios_type_0, - system_bios_minor_release), - &smbios_type0.minor, 1); - } -} - -static void smbios_build_type_1_fields(void) -{ - smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_st= r), - smbios_type1.manufacturer); - smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_st= r), - smbios_type1.product); - smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str), - smbios_type1.version); - smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_s= tr), - smbios_type1.serial); - smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str), - smbios_type1.sku); - smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str), - smbios_type1.family); - if (qemu_uuid_set) { - /* We don't encode the UUID in the "wire format" here because this - * function is for legacy mode and needs to keep the guest ABI, and - * because we don't know what's the SMBIOS version advertised by t= he - * BIOS. - */ - smbios_add_field(1, offsetof(struct smbios_type_1, uuid), - &qemu_uuid, 16); - } -} - -uint8_t *smbios_get_table_legacy(size_t *length) -{ - int i; - size_t usr_offset; - - /* also complain if fields were given for types > 1 */ - if (find_next_bit(smbios_have_fields_bitmap, - SMBIOS_MAX_TYPE + 1, 2) < SMBIOS_MAX_TYPE + 1) { - error_report("can't process fields for smbios " - "types > 1 on machine versions < 2.1!"); - exit(1); - } - - if (test_bit(4, smbios_have_binfile_bitmap)) { - error_report("can't process table for smbios " - "type 4 on machine versions < 2.1!"); - exit(1); - } - - g_free(smbios_entries); - smbios_entries_len =3D sizeof(uint16_t); - smbios_entries =3D g_malloc0(smbios_entries_len); - - for (i =3D 0, usr_offset =3D 0; usr_blobs_sizes && i < usr_blobs_sizes= ->len; - i++) - { - struct smbios_table *table; - struct smbios_structure_header *header; - size_t size =3D g_array_index(usr_blobs_sizes, size_t, i); - - header =3D (struct smbios_structure_header *)(usr_blobs + usr_offs= et); - smbios_entries =3D g_realloc(smbios_entries, smbios_entries_len + - size + sizeof(*table)); - table =3D (struct smbios_table *)(smbios_entries + smbios_entries_= len); - table->header.type =3D SMBIOS_TABLE_ENTRY; - table->header.length =3D cpu_to_le16(sizeof(*table) + size); - memcpy(table->data, header, size); - smbios_entries_len +=3D sizeof(*table) + size; - (*(uint16_t *)smbios_entries) =3D - cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); - usr_offset +=3D size; - } - - smbios_build_type_0_fields(); - smbios_build_type_1_fields(); - smbios_validate_table(); - *length =3D smbios_entries_len; - return smbios_entries; -} -/* end: legacy setup functions for <=3D 2.0 machines */ - - bool smbios_skip_table(uint8_t type, bool required_table) { if (test_bit(type, smbios_have_binfile_bitmap)) { @@ -1403,14 +1249,6 @@ static bool save_opt_list(size_t *ndest, char ***des= t, QemuOpts *opts, return true; } =20 -static void smbios_add_usr_blob_size(size_t size) -{ - if (!usr_blobs_sizes) { - usr_blobs_sizes =3D g_array_new(false, false, sizeof(size_t)); - } - g_array_append_val(usr_blobs_sizes, size); -} - void smbios_entry_add(QemuOpts *opts, Error **errp) { const char *val; diff --git a/hw/smbios/smbios_legacy.c b/hw/smbios/smbios_legacy.c new file mode 100644 index 0000000000..21f143e738 --- /dev/null +++ b/hw/smbios/smbios_legacy.c @@ -0,0 +1,179 @@ +/* + * SMBIOS legacy support + * + * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. + * Copyright (C) 2013 Red Hat, Inc. + * + * Authors: + * Alex Williamson + * Markus Armbruster + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "qemu/osdep.h" +#include "qemu/bswap.h" +#include "hw/firmware/smbios.h" +#include "sysemu/sysemu.h" +#include "qemu/error-report.h" + +struct smbios_header { + uint16_t length; + uint8_t type; +} QEMU_PACKED; + +struct smbios_field { + struct smbios_header header; + uint8_t type; + uint16_t offset; + uint8_t data[]; +} QEMU_PACKED; + +struct smbios_table { + struct smbios_header header; + uint8_t data[]; +} QEMU_PACKED; + +#define SMBIOS_FIELD_ENTRY 0 +#define SMBIOS_TABLE_ENTRY 1 + +static uint8_t *smbios_entries; +static size_t smbios_entries_len; +GArray *usr_blobs_sizes; + +void smbios_add_usr_blob_size(size_t size) +{ + if (!usr_blobs_sizes) { + usr_blobs_sizes =3D g_array_new(false, false, sizeof(size_t)); + } + g_array_append_val(usr_blobs_sizes, size); +} + +static void smbios_add_field(int type, int offset, const void *data, size_= t len) +{ + struct smbios_field *field; + + if (!smbios_entries) { + smbios_entries_len =3D sizeof(uint16_t); + smbios_entries =3D g_malloc0(smbios_entries_len); + } + smbios_entries =3D g_realloc(smbios_entries, smbios_entries_len + + sizeof(*field) + len); + field =3D (struct smbios_field *)(smbios_entries + smbios_entries_len); + field->header.type =3D SMBIOS_FIELD_ENTRY; + field->header.length =3D cpu_to_le16(sizeof(*field) + len); + + field->type =3D type; + field->offset =3D cpu_to_le16(offset); + memcpy(field->data, data, len); + + smbios_entries_len +=3D sizeof(*field) + len; + (*(uint16_t *)smbios_entries) =3D + cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); +} + +static void smbios_maybe_add_str(int type, int offset, const char *data) +{ + if (data) { + smbios_add_field(type, offset, data, strlen(data) + 1); + } +} + +static void smbios_build_type_0_fields(void) +{ + smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str), + smbios_type0.vendor); + smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_st= r), + smbios_type0.version); + smbios_maybe_add_str(0, offsetof(struct smbios_type_0, + bios_release_date_str), + smbios_type0.date); + if (smbios_type0.have_major_minor) { + smbios_add_field(0, offsetof(struct smbios_type_0, + system_bios_major_release), + &smbios_type0.major, 1); + smbios_add_field(0, offsetof(struct smbios_type_0, + system_bios_minor_release), + &smbios_type0.minor, 1); + } +} + +static void smbios_build_type_1_fields(void) +{ + smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_st= r), + smbios_type1.manufacturer); + smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_st= r), + smbios_type1.product); + smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str), + smbios_type1.version); + smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_s= tr), + smbios_type1.serial); + smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str), + smbios_type1.sku); + smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str), + smbios_type1.family); + if (qemu_uuid_set) { + /* + * We don't encode the UUID in the "wire format" here because this + * function is for legacy mode and needs to keep the guest ABI, and + * because we don't know what's the SMBIOS version advertised by t= he + * BIOS. + */ + smbios_add_field(1, offsetof(struct smbios_type_1, uuid), + &qemu_uuid, 16); + } +} + +uint8_t *smbios_get_table_legacy(size_t *length) +{ + int i; + size_t usr_offset; + + /* complain if fields were given for types > 1 */ + if (find_next_bit(smbios_have_fields_bitmap, + SMBIOS_MAX_TYPE + 1, 2) < SMBIOS_MAX_TYPE + 1) { + error_report("can't process fields for smbios " + "types > 1 on machine versions < 2.1!"); + exit(1); + } + + if (test_bit(4, smbios_have_binfile_bitmap)) { + error_report("can't process table for smbios " + "type 4 on machine versions < 2.1!"); + exit(1); + } + + g_free(smbios_entries); + smbios_entries_len =3D sizeof(uint16_t); + smbios_entries =3D g_malloc0(smbios_entries_len); + + for (i =3D 0, usr_offset =3D 0; usr_blobs_sizes && i < usr_blobs_sizes= ->len; + i++) + { + struct smbios_table *table; + struct smbios_structure_header *header; + size_t size =3D g_array_index(usr_blobs_sizes, size_t, i); + + header =3D (struct smbios_structure_header *)(usr_blobs + usr_offs= et); + smbios_entries =3D g_realloc(smbios_entries, smbios_entries_len + + size + sizeof(*table)); + table =3D (struct smbios_table *)(smbios_entries + smbios_entries_= len); + table->header.type =3D SMBIOS_TABLE_ENTRY; + table->header.length =3D cpu_to_le16(sizeof(*table) + size); + memcpy(table->data, header, size); + smbios_entries_len +=3D sizeof(*table) + size; + (*(uint16_t *)smbios_entries) =3D + cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); + usr_offset +=3D size; + } + + smbios_build_type_0_fields(); + smbios_build_type_1_fields(); + smbios_validate_table(); + *length =3D smbios_entries_len; + return smbios_entries; +} diff --git a/hw/smbios/smbios_legacy_stub.c b/hw/smbios/smbios_legacy_stub.c new file mode 100644 index 0000000000..f29b15316c --- /dev/null +++ b/hw/smbios/smbios_legacy_stub.c @@ -0,0 +1,15 @@ +/* + * IPMI SMBIOS firmware handling + * + * Copyright (c) 2024 Igor Mammedov, Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/firmware/smbios.h" + +void smbios_add_usr_blob_size(size_t size) +{ +} --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429890; cv=none; d=zohomail.com; s=zohoarc; b=nj+mQ1MXkJHMWWBPHVVEWfjRsBzKIy4YiZefpSUXYK8P7mu3mVC2bZudXUurBTQjnDOirHxhh55RA4WhZZ7CK9pFPna/VrpS+my87v7ikz8QZw9edG0t8QRr+FQ0SL4DhtD8a+McHWTeL25ecMi0fNkD3KMvTYefaQH9tX62N7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429890; h=Content-Type: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=nVD50WvrzaXuGyL1Pql+Sr57HUxpHuChtzoWxeSu1lg=; b=CzY5tmi5mGWAB0meuPTTOlTx4+A6XDoj1QMhqAnVzxSZ/5GpnoyFuZcPbWM4E6Wf+VTuD2F3JjcyBkfrkTYbJJwZPLUGq+MKUT0fQW9lgPYx3djPmn3CmhMXR5wNdBVNwvS1hBgFC1+4QhVtLxStkuOzqNRk31lsAqE4NK/t4bo= 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 1710429890462499.12695208732544; Thu, 14 Mar 2024 08:24:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmwA-0000GB-9v; Thu, 14 Mar 2024 11:24:06 -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 1rkmw8-00008C-7N for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:24:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmw6-0003sZ-D0 for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:24:03 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-m-OtPV2YN5mkQSO7TcXb3g-1; Thu, 14 Mar 2024 11:23:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 724AF3C0CD41 for ; Thu, 14 Mar 2024 15:23:17 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD45C111E5; Thu, 14 Mar 2024 15:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429841; 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=nVD50WvrzaXuGyL1Pql+Sr57HUxpHuChtzoWxeSu1lg=; b=VsjrvbjFaO70yJr/d7Z0ipcXpA337oMb72Vwg7DJLrH6YxQbgYumzEgog+jsf96fTb4T/l YkT2JAMqdCCn+QQK9F9XVq73mC7q6lbdNsLnhuA+1P1T2cFY6PKcg8E2bzFocXP3Pkh7Sy H8Gr/zxPmyc5qKBOsalGZFLTvOrJH3o= X-MC-Unique: m-OtPV2YN5mkQSO7TcXb3g-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha Subject: [PATCH v4 12/21] smbios: handle errors consistently Date: Thu, 14 Mar 2024 16:22:53 +0100 Message-Id: <20240314152302.2324164-13-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429891857100005 Current code uses mix of error_report()+exit(1) and error_setg() to handle errors. Use newer error_setg() everywhere, beside consistency it will allow to detect error condition without killing QEMU and attempt switch-over to SMBIOS3.x tables/entrypoint in follow up patch. while at it, clear smbios_tables pointer after freeing. that will avoid double free if smbios_get_tables() is called multiple times. Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha --- include/hw/firmware/smbios.h | 4 ++-- hw/i386/fw_cfg.c | 3 ++- hw/smbios/smbios.c | 34 ++++++++++++++++++++++------------ hw/smbios/smbios_legacy.c | 22 ++++++++++++++-------- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index ccc51e72f5..d4b91d5a14 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -326,7 +326,7 @@ struct smbios_type_127 { struct smbios_structure_header header; } QEMU_PACKED; =20 -void smbios_validate_table(void); +bool smbios_validate_table(Error **errp); void smbios_add_usr_blob_size(size_t size); void smbios_entry_add(QemuOpts *opts, Error **errp); void smbios_set_cpuid(uint32_t version, uint32_t features); @@ -334,7 +334,7 @@ void smbios_set_defaults(const char *manufacturer, cons= t char *product, const char *version, bool uuid_encoded, SmbiosEntryPointType ep_type); void smbios_set_default_processor_family(uint16_t processor_family); -uint8_t *smbios_get_table_legacy(size_t *length); +uint8_t *smbios_get_table_legacy(size_t *length, Error **errp); void smbios_get_tables(MachineState *ms, const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index d1281066f4..e387bf50d0 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -71,7 +71,8 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState= *fw_cfg) smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); =20 if (pcmc->smbios_legacy_mode) { - smbios_tables =3D smbios_get_table_legacy(&smbios_tables_len); + smbios_tables =3D smbios_get_table_legacy(&smbios_tables_len, + &error_fatal); fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); return; diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index f9efe01233..512ecd46f3 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -19,7 +19,6 @@ #include "qemu/units.h" #include "qapi/error.h" #include "qemu/config-file.h" -#include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/option.h" #include "sysemu/sysemu.h" @@ -511,23 +510,25 @@ opts_init(smbios_register_config); */ #define SMBIOS_21_MAX_TABLES_LEN 0xffff =20 -static void smbios_check_type4_count(uint32_t expected_t4_count) +static bool smbios_check_type4_count(uint32_t expected_t4_count, Error **e= rrp) { if (smbios_type4_count && smbios_type4_count !=3D expected_t4_count) { - error_report("Expected %d SMBIOS Type 4 tables, got %d instead", - expected_t4_count, smbios_type4_count); - exit(1); + error_setg(errp, "Expected %d SMBIOS Type 4 tables, got %d instead= ", + expected_t4_count, smbios_type4_count); + return false; } + return true; } =20 -void smbios_validate_table(void) +bool smbios_validate_table(Error **errp) { if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 && 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); + error_setg(errp, "SMBIOS 2.1 table length %zu exceeds %d", + smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN); + return false; } + return true; } =20 bool smbios_skip_table(uint8_t type, bool required_table) @@ -1151,15 +1152,18 @@ void smbios_get_tables(MachineState *ms, smbios_build_type_41_table(errp); smbios_build_type_127_table(); =20 - smbios_check_type4_count(ms->smp.sockets); - smbios_validate_table(); + if (!smbios_check_type4_count(ms->smp.sockets, errp)) { + goto err_exit; + } + if (!smbios_validate_table(errp)) { + goto err_exit; + } smbios_entry_point_setup(); =20 /* return tables blob and entry point (anchor), and their sizes */ *tables =3D smbios_tables; *tables_len =3D smbios_tables_len; *anchor =3D (uint8_t *)&ep; - /* calculate length based on anchor string */ if (!strncmp((char *)&ep, "_SM_", 4)) { *anchor_len =3D sizeof(struct smbios_21_entry_point); @@ -1168,6 +1172,12 @@ void smbios_get_tables(MachineState *ms, } else { abort(); } + + return; +err_exit: + g_free(smbios_tables); + smbios_tables =3D NULL; + return; } =20 static void save_opt(const char **dest, QemuOpts *opts, const char *name) diff --git a/hw/smbios/smbios_legacy.c b/hw/smbios/smbios_legacy.c index 21f143e738..a6544bf55a 100644 --- a/hw/smbios/smbios_legacy.c +++ b/hw/smbios/smbios_legacy.c @@ -19,7 +19,7 @@ #include "qemu/bswap.h" #include "hw/firmware/smbios.h" #include "sysemu/sysemu.h" -#include "qemu/error-report.h" +#include "qapi/error.h" =20 struct smbios_header { uint16_t length; @@ -128,7 +128,7 @@ static void smbios_build_type_1_fields(void) } } =20 -uint8_t *smbios_get_table_legacy(size_t *length) +uint8_t *smbios_get_table_legacy(size_t *length, Error **errp) { int i; size_t usr_offset; @@ -136,15 +136,15 @@ uint8_t *smbios_get_table_legacy(size_t *length) /* complain if fields were given for types > 1 */ if (find_next_bit(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1, 2) < SMBIOS_MAX_TYPE + 1) { - error_report("can't process fields for smbios " + error_setg(errp, "can't process fields for smbios " "types > 1 on machine versions < 2.1!"); - exit(1); + goto err_exit; } =20 if (test_bit(4, smbios_have_binfile_bitmap)) { - error_report("can't process table for smbios " - "type 4 on machine versions < 2.1!"); - exit(1); + error_setg(errp, "can't process table for smbios " + "type 4 on machine versions < 2.1!"); + goto err_exit; } =20 g_free(smbios_entries); @@ -173,7 +173,13 @@ uint8_t *smbios_get_table_legacy(size_t *length) =20 smbios_build_type_0_fields(); smbios_build_type_1_fields(); - smbios_validate_table(); + if (!smbios_validate_table(errp)) { + goto err_exit; + } + *length =3D smbios_entries_len; return smbios_entries; +err_exit: + g_free(smbios_entries); + return NULL; } --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429967; cv=none; d=zohomail.com; s=zohoarc; b=c8mx6Y4vgBgL9lhsBvUtyzVQESzCFWXhBrpCXntXKyW+eb9rISbYtmoWmbdqzcXRZe4QQgrj8a7QEWTgDYMfFFWZh5qpAWfG24dzSzoQSkyVLb+Cpp11QrPAPz37ZTR7cdIwYOMxDFDxRJF6Dcqam6+7y+SLDV8RhsstX6Al5XM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429967; h=Content-Type: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=bnirpVW4r/WZdvTVKsgbyy1bu8sL5I7faigxJwh/DIQ=; b=Mow3NEiMYiXtAkXmY929EuKnFLaHyPqOjw5Kp9fLaXYHVo+LASB9JzYVaj09Jlcphoog4XuI1My2YXT/HESjgNwf6ODPWnicUnso6Wrm9GWMjHhBXzDCXsMRXKeOa/lirio8BwpHMqRNg1hgGbSf6RyK/i6wu4Z0H9m3kX+DdD0= 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 1710429967535467.23927261843266; Thu, 14 Mar 2024 08:26:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvq-0007lZ-PS; Thu, 14 Mar 2024 11:23:46 -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 1rkmvb-0007Ni-Na for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvY-0003p1-Ob for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:31 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-bnPhBx1QOB61SdfDFHxnIQ-1; Thu, 14 Mar 2024 11:23:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B4AF879848; Thu, 14 Mar 2024 15:23:18 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A318117A93; Thu, 14 Mar 2024 15:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429808; 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=bnirpVW4r/WZdvTVKsgbyy1bu8sL5I7faigxJwh/DIQ=; b=C8HBFxFb1h8GYxLk7ACFt3wn5TDjGzqTh1SOmLkicU+iyftYAWpvLxtXoJxNpGLwxN0Y7B 8GVzNx8LaJ7Ah37vEB0v5HQYxPYoshob2Iy35hFKibUmHXezl8fapvWQQ1Fi8axZqcL8LI H/D3kixEsgqsTgkdIYEO1U9tVXFgzt4= X-MC-Unique: bnPhBx1QOB61SdfDFHxnIQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Daniel Henrique Barboza , Ani Sinha , Fiona Ebner Subject: [PATCH v4 13/21] smbios: get rid of global smbios_ep_type Date: Thu, 14 Mar 2024 16:22:54 +0100 Message-Id: <20240314152302.2324164-14-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429975761100007 Signed-off-by: Igor Mammedov Acked-by: Daniel Henrique Barboza Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- hw/i386/fw_cfg.h | 3 ++- include/hw/firmware/smbios.h | 5 +++-- hw/arm/virt.c | 4 ++-- hw/i386/fw_cfg.c | 8 ++++---- hw/i386/pc.c | 2 +- hw/loongarch/virt.c | 7 ++++--- hw/riscv/virt.c | 6 +++--- hw/smbios/smbios.c | 27 +++++++++++++++------------ hw/smbios/smbios_legacy.c | 2 +- 9 files changed, 35 insertions(+), 29 deletions(-) diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h index 1e1de6b4a3..92e310f5fd 100644 --- a/hw/i386/fw_cfg.h +++ b/hw/i386/fw_cfg.h @@ -23,7 +23,8 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms, uint16_t boot_cpus, uint16_t apic_id_limit); -void fw_cfg_build_smbios(PCMachineState *ms, FWCfgState *fw_cfg); +void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, + SmbiosEntryPointType ep_type); void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg); void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg); =20 diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index d4b91d5a14..8d3fb2fb3b 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -326,16 +326,17 @@ struct smbios_type_127 { struct smbios_structure_header header; } QEMU_PACKED; =20 -bool smbios_validate_table(Error **errp); +bool smbios_validate_table(SmbiosEntryPointType ep_type, Error **errp); void smbios_add_usr_blob_size(size_t size); void smbios_entry_add(QemuOpts *opts, Error **errp); void smbios_set_cpuid(uint32_t version, uint32_t features); void smbios_set_defaults(const char *manufacturer, const char *product, const char *version, - bool uuid_encoded, SmbiosEntryPointType ep_type); + bool uuid_encoded); void smbios_set_default_processor_family(uint16_t processor_family); uint8_t *smbios_get_table_legacy(size_t *length, Error **errp); void smbios_get_tables(MachineState *ms, + SmbiosEntryPointType ep_type, const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, uint8_t **tables, size_t *tables_len, diff --git a/hw/arm/virt.c b/hw/arm/virt.c index b634c908a7..a9a913aead 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1651,13 +1651,13 @@ static void virt_build_smbios(VirtMachineState *vms) =20 smbios_set_defaults("QEMU", product, vmc->smbios_old_sys_ver ? "1.0" : mc->name, - true, SMBIOS_ENTRY_POINT_TYPE_64); + true); =20 /* build the array of physical mem area from base_memmap */ mem_array.address =3D vms->memmap[VIRT_MEM].base; mem_array.length =3D ms->ram_size; =20 - smbios_get_tables(ms, &mem_array, 1, + smbios_get_tables(ms, SMBIOS_ENTRY_POINT_TYPE_64, &mem_array, 1, &smbios_tables, &smbios_tables_len, &smbios_anchor, &smbios_anchor_len, &error_fatal); diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index e387bf50d0..d802d2787f 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -48,7 +48,8 @@ const char *fw_cfg_arch_key_name(uint16_t key) return NULL; } =20 -void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg) +void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, + SmbiosEntryPointType ep_type) { #ifdef CONFIG_SMBIOS uint8_t *smbios_tables, *smbios_anchor; @@ -63,8 +64,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState= *fw_cfg) if (pcmc->smbios_defaults) { /* These values are guest ABI, do not change */ smbios_set_defaults("QEMU", mc->desc, mc->name, - pcmc->smbios_uuid_encoded, - pcms->smbios_entry_point_type); + pcmc->smbios_uuid_encoded); } =20 /* tell smbios about cpuid version and features */ @@ -89,7 +89,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState= *fw_cfg) array_count++; } } - smbios_get_tables(ms, mem_array, array_count, + smbios_get_tables(ms, ep_type, mem_array, array_count, &smbios_tables, &smbios_tables_len, &smbios_anchor, &smbios_anchor_len, &error_fatal); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index feb7a93083..44eb073abd 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -672,7 +672,7 @@ void pc_machine_done(Notifier *notifier, void *data) =20 acpi_setup(); if (x86ms->fw_cfg) { - fw_cfg_build_smbios(pcms, x86ms->fw_cfg); + fw_cfg_build_smbios(pcms, x86ms->fw_cfg, pcms->smbios_entry_point_= type); fw_cfg_build_feature_control(MACHINE(pcms), x86ms->fw_cfg); /* update FW_CFG_NB_CPUS to account for -device added CPUs */ fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 53bfdcee61..441d764843 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -355,10 +355,11 @@ static void virt_build_smbios(LoongArchMachineState *= lams) return; } =20 - smbios_set_defaults("QEMU", product, mc->name, - true, SMBIOS_ENTRY_POINT_TYPE_64); + smbios_set_defaults("QEMU", product, mc->name, true); =20 - smbios_get_tables(ms, NULL, 0, &smbios_tables, &smbios_tables_len, + smbios_get_tables(ms, SMBIOS_ENTRY_POINT_TYPE_64, + NULL, 0, + &smbios_tables, &smbios_tables_len, &smbios_anchor, &smbios_anchor_len, &error_fatal); =20 if (smbios_anchor) { diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 535fd047ba..72a55b8af1 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1275,8 +1275,7 @@ static void virt_build_smbios(RISCVVirtState *s) product =3D "KVM Virtual Machine"; } =20 - smbios_set_defaults("QEMU", product, mc->name, - true, SMBIOS_ENTRY_POINT_TYPE_64); + smbios_set_defaults("QEMU", product, mc->name, true); =20 if (riscv_is_32bit(&s->soc[0])) { smbios_set_default_processor_family(0x200); @@ -1288,7 +1287,8 @@ static void virt_build_smbios(RISCVVirtState *s) mem_array.address =3D s->memmap[VIRT_DRAM].base; mem_array.length =3D ms->ram_size; =20 - smbios_get_tables(ms, &mem_array, 1, + smbios_get_tables(ms, SMBIOS_ENTRY_POINT_TYPE_64, + &mem_array, 1, &smbios_tables, &smbios_tables_len, &smbios_anchor, &smbios_anchor_len, &error_fatal); diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 512ecd46f3..7fefe98c85 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -43,7 +43,6 @@ 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_TYPE_32; =20 static SmbiosEntryPoint ep; =20 @@ -520,9 +519,9 @@ static bool smbios_check_type4_count(uint32_t expected_= t4_count, Error **errp) return true; } =20 -bool smbios_validate_table(Error **errp) +bool smbios_validate_table(SmbiosEntryPointType ep_type, Error **errp) { - if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 && + if (ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 && smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) { error_setg(errp, "SMBIOS 2.1 table length %zu exceeds %d", smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN); @@ -669,14 +668,15 @@ static void smbios_build_type_3_table(void) SMBIOS_BUILD_TABLE_POST; } =20 -static void smbios_build_type_4_table(MachineState *ms, unsigned instance) +static void smbios_build_type_4_table(MachineState *ms, unsigned instance, + SmbiosEntryPointType ep_type) { char sock_str[128]; size_t tbl_len =3D SMBIOS_TYPE_4_LEN_V28; unsigned threads_per_socket; unsigned cores_per_socket; =20 - if (smbios_ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_64) { + if (ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_64) { tbl_len =3D SMBIOS_TYPE_4_LEN_V30; } =20 @@ -1011,11 +1011,10 @@ void smbios_set_default_processor_family(uint16_t p= rocessor_family) =20 void smbios_set_defaults(const char *manufacturer, const char *product, const char *version, - bool uuid_encoded, SmbiosEntryPointType ep_type) + bool uuid_encoded) { smbios_have_defaults =3D true; smbios_uuid_encoded =3D uuid_encoded; - smbios_ep_type =3D ep_type; =20 SMBIOS_SET_DEFAULT(smbios_type1.manufacturer, manufacturer); SMBIOS_SET_DEFAULT(smbios_type1.product, product); @@ -1032,9 +1031,9 @@ void smbios_set_defaults(const char *manufacturer, co= nst char *product, SMBIOS_SET_DEFAULT(type17.manufacturer, manufacturer); } =20 -static void smbios_entry_point_setup(void) +static void smbios_entry_point_setup(SmbiosEntryPointType ep_type) { - switch (smbios_ep_type) { + switch (ep_type) { case SMBIOS_ENTRY_POINT_TYPE_32: memcpy(ep.ep21.anchor_string, "_SM_", 4); memcpy(ep.ep21.intermediate_anchor_string, "_DMI_", 5); @@ -1084,6 +1083,7 @@ static void smbios_entry_point_setup(void) } =20 void smbios_get_tables(MachineState *ms, + SmbiosEntryPointType ep_type, const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, uint8_t **tables, size_t *tables_len, @@ -1092,6 +1092,9 @@ void smbios_get_tables(MachineState *ms, { unsigned i, dimm_cnt, offset; =20 + assert(ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 || + ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_64); + g_free(smbios_tables); smbios_tables =3D g_memdup2(usr_blobs, usr_blobs_len); smbios_tables_len =3D usr_blobs_len; @@ -1106,7 +1109,7 @@ void smbios_get_tables(MachineState *ms, assert(ms->smp.sockets >=3D 1); =20 for (i =3D 0; i < ms->smp.sockets; i++) { - smbios_build_type_4_table(ms, i); + smbios_build_type_4_table(ms, i, ep_type); } =20 smbios_build_type_8_table(); @@ -1155,10 +1158,10 @@ void smbios_get_tables(MachineState *ms, if (!smbios_check_type4_count(ms->smp.sockets, errp)) { goto err_exit; } - if (!smbios_validate_table(errp)) { + if (!smbios_validate_table(ep_type, errp)) { goto err_exit; } - smbios_entry_point_setup(); + smbios_entry_point_setup(ep_type); =20 /* return tables blob and entry point (anchor), and their sizes */ *tables =3D smbios_tables; diff --git a/hw/smbios/smbios_legacy.c b/hw/smbios/smbios_legacy.c index a6544bf55a..06907cd16c 100644 --- a/hw/smbios/smbios_legacy.c +++ b/hw/smbios/smbios_legacy.c @@ -173,7 +173,7 @@ uint8_t *smbios_get_table_legacy(size_t *length, Error = **errp) =20 smbios_build_type_0_fields(); smbios_build_type_1_fields(); - if (!smbios_validate_table(errp)) { + if (!smbios_validate_table(SMBIOS_ENTRY_POINT_TYPE_32, errp)) { goto err_exit; } =20 --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429968; cv=none; d=zohomail.com; s=zohoarc; b=matKpxKrmYjl1BPR+nC+tNWfgoS72b7nX9duyEESxXvwFDUADwvrs/+EQ6Q0HH9tgJyBjP/9sKLmp5EZaHlHOne9AWUAAGI320C/MoaOaSySS9ZM748ExZ9Iu/ukrB7bI5zVPrcNsIc0/m+iF38n5jDUE+w8V/mC+cO7VNSpVZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429968; h=Content-Type: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=8fDaandN3Rb3RlTcK5ErH86Z/dEUO8jTo8eBQggY7Rw=; b=UPwtIkaJlf6b2XbbtbJs19LWZgoFFIJnIvl67ZogpX8lnskpAxa44J3/F9dDk9gYF9ygc6BixCJ7bEZqqAi0L0YwlN/aaZ5TZCuQlccya8fHXEqP0cz6jeZXs+cQau6c0c6uaD2Av+hfwHGjgkAa9KCuOl8gAaTYCUbkG4xF8oM= 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 1710429968188352.11672777970784; Thu, 14 Mar 2024 08:26:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvn-0007fC-BB; Thu, 14 Mar 2024 11:23:43 -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 1rkmvW-0007LS-PR for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvV-0003mw-AN for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:26 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-VN5p5MC9PmSQphIYJkOcGw-1; Thu, 14 Mar 2024 11:23:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9026E186E1C3; Thu, 14 Mar 2024 15:23:19 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB97D17A8E; Thu, 14 Mar 2024 15:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429804; 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=8fDaandN3Rb3RlTcK5ErH86Z/dEUO8jTo8eBQggY7Rw=; b=g2eCe/yruV7tPgRRTSf2mvzyBHdopRVDfkWYVVCqVNS61ut7toY2u+dHbM+2Y5F2b8YwR0 vkBehiSg3Rtt2pKn069a3YCpsLsIcPLs2aIwJbO5sDCVC3aF8QZMlaPRAAaUjpRDCwg2Ni 4skJFiPLmo0CZiXpcCuuetJHrpTYDeU= X-MC-Unique: VN5p5MC9PmSQphIYJkOcGw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Fiona Ebner Subject: [PATCH v4 14/21] smbios: clear smbios_type4_count before building tables Date: Thu, 14 Mar 2024 16:22:55 +0100 Message-Id: <20240314152302.2324164-15-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429970074100009 it will help to keep type 4 tables accounting correct in case SMBIOS tables are built multiple times. Signed-off-by: Igor Mammedov Tested-by: Fiona Ebner --- hw/smbios/smbios.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 7fefe98c85..9aad8f2df2 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1096,6 +1096,7 @@ void smbios_get_tables(MachineState *ms, ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_64); =20 g_free(smbios_tables); + smbios_type4_count =3D 0; smbios_tables =3D g_memdup2(usr_blobs, usr_blobs_len); smbios_tables_len =3D usr_blobs_len; smbios_table_max =3D usr_table_max; --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429860; cv=none; d=zohomail.com; s=zohoarc; b=Tx62xPrZpayYRfQKOcI/DareWdfkLnptF7MTSAEJtCJcLERc88pjCKVtjTNPJoXiHTlP1gkfzb6Pva8AkBFRrIi8RH7eFsj2PTZsUKA7STKtzsl+9yiAQlLorJGOuFr/fNBpHN8GbJ3X9CBwus5NB0qe8JS3GHb7kAzmb7clqKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429860; h=Content-Type: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=WEhRrgn7jhef1qjl5d34NM0T+BDoeV1Zh9D6DKBAsDI=; b=cxHHF3K+1bA7yZbyszIl7nbD8nokhbPEkwtzgoZ1BWa8xe3UKI9mKNkrlYs4rUlCPiwkzGUJa1XqlyTemm9XezCgoHTtnqJdRIUxZ2hE+jsX7d14lFkqHqFEsNHxG3JMbNYBfyVS2Ijljo5HLol1Ryc9/aCvWPns0uG3cgroOp0= 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 171042986069026.20664802110798; Thu, 14 Mar 2024 08:24:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvf-0007OV-Vi; Thu, 14 Mar 2024 11:23:36 -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 1rkmvX-0007Lz-Hs for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvW-0003o1-1i for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-CP5iUfqiPDuFggMOeoZ1kQ-1; Thu, 14 Mar 2024 11:23:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA13E879853; Thu, 14 Mar 2024 15:23:20 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0B5510F53; Thu, 14 Mar 2024 15:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429805; 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=WEhRrgn7jhef1qjl5d34NM0T+BDoeV1Zh9D6DKBAsDI=; b=QxVCFpZK213rfhRUZqLXSzOEUxxddLqVqHRWbUb+OP/nDSbzbuSqO+rbmqH1UWiOdfmcHs IjwmA1Ph5OKURqt2Fuhux7Za8TdMKZGvYA1fzvHV+EpIKbCYP3nZTQVT2KsV8hTG1xBFCR IH6yPV3YvAbTzTU8j7zWY6ykUsYzHag= X-MC-Unique: CP5iUfqiPDuFggMOeoZ1kQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Markus Armbruster , Ani Sinha , Fiona Ebner Subject: [PATCH v4 15/21] smbios: extend smbios-entry-point-type with 'auto' value Date: Thu, 14 Mar 2024 16:22:56 +0100 Message-Id: <20240314152302.2324164-16-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429861784100001 later patches will use it to pick SMBIOS version at runtime depending on configuration. Signed-off-by: Igor Mammedov Acked-by: Markus Armbruster Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- v3: - make sure i2nd line of comment is indented on 4 spaces only --- qapi/machine.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qapi/machine.json b/qapi/machine.json index bb5a178909..0840c91e70 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1797,10 +1797,13 @@ # # @64: SMBIOS version 3.0 (64-bit) Entry Point # +# @auto: Either 2.x or 3.x SMBIOS version, 2.x if configuration can be +# described by it and 3.x otherwise (since: 9.0) +# # Since: 7.0 ## { 'enum': 'SmbiosEntryPointType', - 'data': [ '32', '64' ] } + 'data': [ '32', '64', 'auto' ] } =20 ## # @MemorySizeConfiguration: --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429961; cv=none; d=zohomail.com; s=zohoarc; b=Zp9nxsxGGQ5LnrsuRdfYSJcmkE5I2GTdfAH9SbqdON3Fj+Fm8s2SkpyPMLVbYPFXPU1HUQZi5rr5iTGsn1ZHHqqr1oIe4zzBFZpnIKCY45vbGbFBdKYwD6toPHB6EYGYgmn9O4KMNSL6hq1/qY7vwhz8VYjqJ0lSe2ceZAr0wmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429961; h=Content-Type: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=1KejdRbjD3mCxnDmdHfcSqh/anBmiXsqbBJYD+lMfvU=; b=W4esZocMckyG1pyhLZzgtRBUTNOPzyf3OC9+3+DqzolHgsHI7NsIxJVGEfNvrl16k9udi8feAu7hZwKeBKCFs8eFMWWOhRXR+4Cje3Pi0TiFACyG9jkLAhAtgbFMcMkq5BGVOkfIFclvMjmFThyWSPNdTGmGwRJw1kchQoirJqo= 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 17104299615541023.9053314019743; Thu, 14 Mar 2024 08:26:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvn-0007i0-Rg; Thu, 14 Mar 2024 11:23:43 -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 1rkmvY-0007ML-71 for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvW-0003o7-Gb for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-_cnm6hk_P-uoRZIGvfoeHg-1; Thu, 14 Mar 2024 11:23:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07AB384FA83; Thu, 14 Mar 2024 15:23:22 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25DE517A8E; Thu, 14 Mar 2024 15:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429805; 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=1KejdRbjD3mCxnDmdHfcSqh/anBmiXsqbBJYD+lMfvU=; b=Q5iGWSBs4QjimUZDTrBijAmJk0Pw1M5q0fZ2fy1cD2+IfdcC2ErB0fpKuXDUetQr1OXV3a P9sh6Ge5zuwwerCCU5PNSQNhlcgkpYYMRyj6UYJ3RhqmQNMmjIdG3nPTNNLrMWp9PRQDhR QTco9iUMssXI66k31SqNpXJ/rOTHA6A= X-MC-Unique: _cnm6hk_P-uoRZIGvfoeHg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 16/21] smbios: in case of entry point is 'auto' try to build v2 tables 1st Date: Thu, 14 Mar 2024 16:22:57 +0100 Message-Id: <20240314152302.2324164-17-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429975728100003 QEMU for some time now uses SMBIOS 3.0 for PC/Q35 machines by default, however Windows has a bug in locating SMBIOS 3.0 entrypoint and fails to find tables when booted on SeaBIOS (on UEFI SMBIOS 3.0 tables work fine since firmware hands over tables in another way) Missing SMBIOS tables may lead to some issues for guest though (worst are: possible reactiveation, inability to get virtio drivers from 'Windows Update') It's unclear at this point if MS will fix the issue on their side. So instead of it (or rather in addition) this patch will try to workaround the issue. aka, use smbios-entry-point-type=3Dauto to make QEMU try generating conservative SMBIOS 2.0 tables and if that fails (due to limits/requested configuration) fallback to SMBIOS 3.0 tables. With this in place majority of users will use SMBIOS 2.0 tables which work fine with (Windows + legacy BIOS). The configurations that is not to possible to describe with SMBIOS 2.0 will switch automatically to SMBIOS 3.0 (which will trigger Windows bug but there is nothing QEMU can do here, so go and aks Microsoft to real fix). Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- hw/smbios/smbios.c | 52 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 9aad8f2df2..d9dda226e6 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1082,7 +1082,7 @@ static void smbios_entry_point_setup(SmbiosEntryPoint= Type ep_type) } } =20 -void smbios_get_tables(MachineState *ms, +static bool smbios_get_tables_ep(MachineState *ms, SmbiosEntryPointType ep_type, const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, @@ -1091,6 +1091,7 @@ void smbios_get_tables(MachineState *ms, Error **errp) { unsigned i, dimm_cnt, offset; + ERRP_GUARD(); =20 assert(ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_32 || ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_64); @@ -1177,11 +1178,56 @@ void smbios_get_tables(MachineState *ms, abort(); } =20 - return; + return true; err_exit: g_free(smbios_tables); smbios_tables =3D NULL; - return; + return false; +} + +void smbios_get_tables(MachineState *ms, + SmbiosEntryPointType ep_type, + const struct smbios_phys_mem_area *mem_array, + const unsigned int mem_array_size, + uint8_t **tables, size_t *tables_len, + uint8_t **anchor, size_t *anchor_len, + Error **errp) +{ + Error *local_err =3D NULL; + bool is_valid; + ERRP_GUARD(); + + switch (ep_type) { + case SMBIOS_ENTRY_POINT_TYPE_AUTO: + case SMBIOS_ENTRY_POINT_TYPE_32: + is_valid =3D smbios_get_tables_ep(ms, SMBIOS_ENTRY_POINT_TYPE_32, + mem_array, mem_array_size, + tables, tables_len, + anchor, anchor_len, + &local_err); + if (is_valid || ep_type !=3D SMBIOS_ENTRY_POINT_TYPE_AUTO) { + break; + } + /* + * fall through in case AUTO endpoint is selected and + * SMBIOS 2.x tables can't be generated, to try if SMBIOS 3.x + * tables would work + */ + case SMBIOS_ENTRY_POINT_TYPE_64: + error_free(local_err); + local_err =3D NULL; + is_valid =3D smbios_get_tables_ep(ms, SMBIOS_ENTRY_POINT_TYPE_64, + mem_array, mem_array_size, + tables, tables_len, + anchor, anchor_len, + &local_err); + break; + default: + abort(); + } + if (!is_valid) { + error_propagate(errp, local_err); + } } =20 static void save_opt(const char **dest, QemuOpts *opts, const char *name) --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429930; cv=none; d=zohomail.com; s=zohoarc; b=D/c/2Gt1i/K487ViBfgsR7KRPyoMciEo2Qi0ZWhGF2R+TkC0CMrf18aXKjAGPgZg0Lc/W6qw6+81ejbqPLcuBH1oFwanju6wTC1UzRmcwptpuXPLbdhriBwsxnABS6GZzRMEsVPgoK73oroRxn4yJRPuz+ehDZv/fYJwvJzhaQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429930; h=Content-Type: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=owNmvVnee2dEyF44D7Vvo1dyUTYs+KXY6jKeIyRCEks=; b=k/IiV+4/koQgOrBW4efRXf6+fNg46N7hH8O0ejs8bdx32uqzSq+aS+IGuO1mlhwz8DKDR8iwyGzeWXtzPoEpivRjQFmWdRrLGkcbSt6EOGxkYXelHUoHlAVQO/WmJlY11yqC1XIvZSiaAzqB/fMuuvaxTiU5LJ5wzjpml5HB5pk= 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 1710429930105518.949142611916; Thu, 14 Mar 2024 08:25:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvq-0007lN-4g; Thu, 14 Mar 2024 11:23:46 -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 1rkmvY-0007MN-Jg for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvX-0003oK-5N for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:28 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-ZurpY5KmPG2JSzhqVFBwiw-1; Thu, 14 Mar 2024 11:23:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16C2A28B6AD4; Thu, 14 Mar 2024 15:23:23 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37E3E17A96; Thu, 14 Mar 2024 15:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429806; 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=owNmvVnee2dEyF44D7Vvo1dyUTYs+KXY6jKeIyRCEks=; b=U+zu2EY6lQmiv0cj7zs+VqDaZp3JmZGHIqpZi81nAnQYssPndLLMeVJV80m7h/weA/PLCr +xnNruJexVY8pM4sHrJ/CNqisfbyP44eBkGYl7WGbSUJtoaXDEwoH1j/Z3sfDk0IuTapit rMh6lyL4OG8vKwPwR+jVxc+uL1cEXjc= X-MC-Unique: ZurpY5KmPG2JSzhqVFBwiw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 17/21] smbios: error out when building type 4 table is not possible Date: Thu, 14 Mar 2024 16:22:58 +0100 Message-Id: <20240314152302.2324164-18-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429931955100003 If SMBIOS v2 version is requested but number of cores/threads are more than it's possible to describe with v2, error out instead of silently ignoring the fact and filling core/thread count with bogus values. This will help caller to decide if it should fallback to SMBIOSv3 when smbios-entry-point-type=3D'auto' Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- hw/smbios/smbios.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index d9dda226e6..be64919def 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -669,7 +669,8 @@ static void smbios_build_type_3_table(void) } =20 static void smbios_build_type_4_table(MachineState *ms, unsigned instance, - SmbiosEntryPointType ep_type) + SmbiosEntryPointType ep_type, + Error **errp) { char sock_str[128]; size_t tbl_len =3D SMBIOS_TYPE_4_LEN_V28; @@ -723,6 +724,12 @@ static void smbios_build_type_4_table(MachineState *ms= , unsigned instance, if (tbl_len =3D=3D SMBIOS_TYPE_4_LEN_V30) { t->core_count2 =3D t->core_enabled2 =3D cpu_to_le16(cores_per_sock= et); t->thread_count2 =3D cpu_to_le16(threads_per_socket); + } else if (t->core_count =3D=3D 0xFF || t->thread_count =3D=3D 0xFF) { + error_setg(errp, "SMBIOS 2.0 doesn't support number of processor " + "cores/threads more than 255, use " + "-machine smbios-entry-point-type=3D64 option to = enable " + "SMBIOS 3.0 support"); + return; } =20 SMBIOS_BUILD_TABLE_POST; @@ -1111,7 +1118,10 @@ static bool smbios_get_tables_ep(MachineState *ms, assert(ms->smp.sockets >=3D 1); =20 for (i =3D 0; i < ms->smp.sockets; i++) { - smbios_build_type_4_table(ms, i, ep_type); + smbios_build_type_4_table(ms, i, ep_type, errp); + if (*errp) { + goto err_exit; + } } =20 smbios_build_type_8_table(); --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429836; cv=none; d=zohomail.com; s=zohoarc; b=mhVGAL+1UQ+kn7lKNACFXqGOlOAEmQfZL1YMuwS5W7ljvBC1oawlnfxAS8BTwdBp8NvVylXV18Ml5xfKylNoSqlFWO5xdSvejWnWuk850gRjaxkvHg639aBD5B8Q+arDXSMFs+F92OlMGE/RcyFUUzygnPhu820U3VWo2Z996ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429836; h=Content-Type: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=7igaEh31g9P/EUDqnJLqJXf4FuWyr/DSDVJ/9clU3ZY=; b=Hd3KVyBpzPvHm6k0fxhKvoNIKr+rXMyGpFTF3eqTN8JadcUS95aAJuBqpsbKuLJ4n/F3VJbH2P7VHBec2YsWWR1KQWvC0MaoIt589WereJ1cbw8rn4rhGIsjF/DCVglSc4Gm0MIFG7f+t2t20InPskvTDLHURe2LMmokXRBeHR8= 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 1710429836865467.38068444716873; Thu, 14 Mar 2024 08:23:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmve-0007OK-3I; Thu, 14 Mar 2024 11:23: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 1rkmvY-0007MM-JM for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvX-0003oN-7d for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:28 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-k8dfL0jUMMaPEtYQnmqFTQ-1; Thu, 14 Mar 2024 11:23:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BA8238008B7 for ; Thu, 14 Mar 2024 15:23:24 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46A8317A9A; Thu, 14 Mar 2024 15:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429806; 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=7igaEh31g9P/EUDqnJLqJXf4FuWyr/DSDVJ/9clU3ZY=; b=BsgBJ+lFpVFetxWc8Qtj2n5PtqoPGxkSe1/NaO6U8UDZ8hTSwY8bvMavS075Xcq8EyZUql 9J9f0inWKFuAhckUzm+WS6DRRapH21IIJsrBUbwr2VjSsNNT6mYvymXOmXY4tPxurodKog +CydwbH+wooq/BDm1sQe3mu3hoQuoxE= X-MC-Unique: k8dfL0jUMMaPEtYQnmqFTQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha Subject: [PATCH v4 18/21] tests: acpi/smbios: whitelist expected blobs Date: Thu, 14 Mar 2024 16:22:59 +0100 Message-Id: <20240314152302.2324164-19-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429837822100001 Signed-off-by: Igor Mammedov Acked-by: Ani Sinha --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..81148a604f 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/SSDT.dimmpxm", --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429953; cv=none; d=zohomail.com; s=zohoarc; b=k1umeHNS2lOpZu9u7/MScK+sEhDFMwQA8yBEc6Vt6gvzxk10/hVzXwGVbHJ0jEVDnT79eJyP5ahOhEOFOTtFNVVHQWZTMPKSjbmDst0kGxyWLgY4hjGe9YVW8EHqcMP1wZvyygzYxd8cCvEY0212jVrw7z3YrEEF7eihfKf8EJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429953; h=Content-Type: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=QK3VzflXInySfueK+SfexWiK/O+z9FeBvoPlrZmIFkU=; b=NmaE2wrRpNwjN1VzR8JPlEbDOvIpodSnFACl7JH8eeHx237g0Umyzya10zNZSSLzcAayTGbtWQlwnZ8/Ek+/vXQSwk4SGW4sDfzLGAOYVfx5ASFcw7dpN9Co+ncG6imoPOGBGm2Ldpviz+eIsudt6eK0y6rdb/DguCJ7WN402Ug= 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 1710429953604179.8155499689974; Thu, 14 Mar 2024 08:25:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvn-0007et-8S; Thu, 14 Mar 2024 11:23:43 -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 1rkmva-0007NA-4C for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvY-0003ot-Fn for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688--9ani6VjO1GVqn51y520ZQ-1; Thu, 14 Mar 2024 11:23:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A56E800277; Thu, 14 Mar 2024 15:23:25 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BE0917A8E; Thu, 14 Mar 2024 15:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429807; 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=QK3VzflXInySfueK+SfexWiK/O+z9FeBvoPlrZmIFkU=; b=XA0tq8H9oL/jSMXjDvbOUlCJ+kMHEKoUbYuTUStNlTdVGpp5sHvnKZwm98Bo0SKCuzJMEJ TfBs8mslFbmSO79oAPK0iGBJ5pRZznbBRu1aSEQ0EfKLgxkCwVrWhF5mIDb+I2mLF7l2TJ 4v0Zwnhnr0/A1F8E86AQly+Bli6hkMo= X-MC-Unique: -9ani6VjO1GVqn51y520ZQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v4 19/21] pc/q35: set SMBIOS entry point type to 'auto' by default Date: Thu, 14 Mar 2024 16:23:00 +0100 Message-Id: <20240314152302.2324164-20-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429975721100002 Use smbios-entry-point-type=3D'auto' for newer machine types as a workaround for Windows not detecting SMBIOS tables. Which makes QEMU pick SMBIOS tables based on configuration (with 2.x preferred and fallback to 3.x if the former isn't compatible with configuration) Default compat setting of smbios-entry-point-type after series for pc/q35 machines: * 9.0-newer: 'auto' * 8.1-8.2: '64' * 8.0-older: '32' Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2008 Signed-off-by: Igor Mammedov Reviewed-by: Ani Sinha Tested-by: Fiona Ebner --- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 4 ++++ hw/i386/pc_q35.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 44eb073abd..e80f02bef4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1832,7 +1832,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->nvdimm_supported =3D true; mc->smp_props.dies_supported =3D true; mc->default_ram_id =3D "pc.ram"; - pcmc->default_smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_64; + pcmc->default_smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_AUTO; =20 object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size", pc_machine_get_max_ram_below_4g, pc_machine_set_max_ram_below_4g, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c9a6c0aa68..18ba076609 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -525,12 +525,16 @@ DEFINE_I440FX_MACHINE(v9_0, "pc-i440fx-9.0", NULL, =20 static void pc_i440fx_8_2_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); + pc_i440fx_9_0_machine_options(m); m->alias =3D NULL; m->is_default =3D false; =20 compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len); compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len); + /* For pc-i44fx-8.2 and 8.1, use SMBIOS 3.X by default */ + pcmc->default_smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_64; } =20 DEFINE_I440FX_MACHINE(v8_2, "pc-i440fx-8.2", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 8a427c4647..b5922b44af 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -376,11 +376,14 @@ DEFINE_Q35_MACHINE(v9_0, "pc-q35-9.0", NULL, =20 static void pc_q35_8_2_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_9_0_machine_options(m); m->alias =3D NULL; m->max_cpus =3D 1024; compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len); compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len); + /* For pc-q35-8.2 and 8.1, use SMBIOS 3.X by default */ + pcmc->default_smbios_ep_type =3D SMBIOS_ENTRY_POINT_TYPE_64; } =20 DEFINE_Q35_MACHINE(v8_2, "pc-q35-8.2", NULL, --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429874; cv=none; d=zohomail.com; s=zohoarc; b=lQISULVN0sDjAe9q/oE+7gQeRpDmHA5CLalIewb7vWIdPXX1yCpzb41Rciv+ujWHslvhFl+xCeuItoC7kjsgg5EYfDr0VP1a805QqyyNqyU5JDgY6sB7tQe9yd+C8bJv7fFNeV1bgOIyJZ1oz3VBAGx1uHSbbFD7EHtqEHp+eP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429874; h=Content-Type: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=gu/myyffSH5c+2Tatf3S7yexqX/32ZFWbLbXva6hqGY=; b=RQbkfTOK7hQ9O2nEcbloqUiWrX/7RCF9ir+0m4czU/FaidskaMzX64Rxwo6xGUtueq7WHadWA1gwkz3Ajzuuxxo5XT1Vu21vqQmrPNvVK6yCmIfydyDIPyZRselpkY3MNHtIghqVUnIHcJ1Rfkg8zfyX7VscyJsIsnogBoFcWGQ= 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 1710429874385324.51384395398406; Thu, 14 Mar 2024 08:24:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvo-0007ia-1l; Thu, 14 Mar 2024 11:23:44 -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 1rkmvb-0007Nf-C2 for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvY-0003p7-VT for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:31 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-sAGy6iZhMsucnng5bv1JQw-1; Thu, 14 Mar 2024 11:23:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1069F3C0D1A4 for ; Thu, 14 Mar 2024 15:23:26 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B6A9111E5; Thu, 14 Mar 2024 15:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429808; 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=gu/myyffSH5c+2Tatf3S7yexqX/32ZFWbLbXva6hqGY=; b=dVHFpsDyCjKU7hntiaw+7Hj1pZ0xFqzwo24dsMm5tSCBhKuZoJqSQ3YRD9op9dZQdpkrKk FRDem9rjLpThXMtIm5fc97ESKkvwO1LfbEGr6hy4bkTDskL0CD3z03Qq1CJtlOL/ezArgB JDfkjmWt+mxeP33039IEQRIvuLA6wlI= X-MC-Unique: sAGy6iZhMsucnng5bv1JQw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, Ani Sinha Subject: [PATCH v4 20/21] tests: acpi: update expected SSDT.dimmpxm blob Date: Thu, 14 Mar 2024 16:23:01 +0100 Message-Id: <20240314152302.2324164-21-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429875772100003 address shift is caused by switch to 32-bit SMBIOS entry point which has slightly different size from 64-bit one and happens to trigger a bit different memory layout. Expected diff: - Name (MEMA, 0x07FFE000) + Name (MEMA, 0x07FFF000) Signed-off-by: Igor Mammedov Acked-by: Ani Sinha --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/q35/SSDT.dimmpxm | Bin 1815 -> 1815 bytes 2 files changed, 1 deletion(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 81148a604f..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/SSDT.dimmpxm", diff --git a/tests/data/acpi/q35/SSDT.dimmpxm b/tests/data/acpi/q35/SSDT.di= mmpxm index 70f133412f5e0aa128ab210245a8de7304eeb843..9ea4e0d0ceaa8a5cbd706afb6d4= 9de853fafe654 100644 GIT binary patch delta 23 ecmbQvH=3DU0wIM^jboSlJzam_|9E_UV*|JeaVTLvQl delta 23 ecmbQvH=3DU0wIM^jboSlJzanD9BE_UVz|JeaVy9Ofw --=20 2.39.3 From nobody Fri May 10 00:07:46 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1710429887; cv=none; d=zohomail.com; s=zohoarc; b=l3jng43khIvOaxlWee2Zl7dxuuSZ9AVE9NcsGYWT/5yuCCiA/Y9649eNqDT4eS86JIyng/gazaBENvk0ZXNNp0KplzTgxRZP10KGs0+Ls8IZxDf4vhIXBTqRymQFU/O7myjLPSRIPeTgRa7YOdEbEsV5PjxbkmQd3ryUsdHbNUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710429887; h=Content-Type: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=v/iWXzpJZUXtfLmGV6M1GFERR/EHeCy/7kY6x+sNACw=; b=ASYswV2plYZ0+NzuDkH1HyYrTXGfPpOsqPDqXqhh14uXkUU3w1WhGYkBpm3D9YjndxExWDWD8RG5R5B1H0xb+l4nPyHMg06Zw5+UE/d2MPUO12YxRUgHNSNGZZErzq3z/dISkODcTDR7KZ3VFAQyC4/rY7gk3ArCmAiVwB4Ssrk= 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 1710429887428220.93100248782753; Thu, 14 Mar 2024 08:24:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkmvo-0007kk-R0; Thu, 14 Mar 2024 11:23:44 -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 1rkmvf-0007Or-BU for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkmvd-0003pn-Vt for qemu-devel@nongnu.org; Thu, 14 Mar 2024 11:23:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-Qo5NxH6GMOSUe8utAKX8gA-1; Thu, 14 Mar 2024 11:23:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E08CA879848 for ; Thu, 14 Mar 2024 15:23:26 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40D2917A8E; Thu, 14 Mar 2024 15:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710429813; 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=v/iWXzpJZUXtfLmGV6M1GFERR/EHeCy/7kY6x+sNACw=; b=KrBcpc7W5bHIt3RN5R3zqckkCOPKSGW6Hm9qOrq46AFRBdBXSd3Ro4jAxwTMGZmPIENna6 iItO2hASi7Mlyz/LJFi5lil+vZncWNsManbR4ZqOVkOCurNdaSNqeoU0L5GNAooUZfNUAP IpTRxyoFc++IArzK8/Y32m8U38hZlHY= X-MC-Unique: Qo5NxH6GMOSUe8utAKX8gA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com Subject: [PATCH v4 21/21] smbios: add extra comments to smbios_get_table_legacy() Date: Thu, 14 Mar 2024 16:23:02 +0100 Message-Id: <20240314152302.2324164-22-imammedo@redhat.com> In-Reply-To: <20240314152302.2324164-1-imammedo@redhat.com> References: <20240314152302.2324164-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.987, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @redhat.com) X-ZM-MESSAGEID: 1710429915541100001 Signed-off-by: Igor Mammedov --- hw/smbios/smbios_legacy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/smbios/smbios_legacy.c b/hw/smbios/smbios_legacy.c index 06907cd16c..c37a8ee821 100644 --- a/hw/smbios/smbios_legacy.c +++ b/hw/smbios/smbios_legacy.c @@ -151,6 +151,9 @@ uint8_t *smbios_get_table_legacy(size_t *length, Error = **errp) smbios_entries_len =3D sizeof(uint16_t); smbios_entries =3D g_malloc0(smbios_entries_len); =20 + /* + * build a set of legacy smbios_table entries using user provided blobs + */ for (i =3D 0, usr_offset =3D 0; usr_blobs_sizes && i < usr_blobs_sizes= ->len; i++) { @@ -166,6 +169,10 @@ uint8_t *smbios_get_table_legacy(size_t *length, Error= **errp) table->header.length =3D cpu_to_le16(sizeof(*table) + size); memcpy(table->data, header, size); smbios_entries_len +=3D sizeof(*table) + size; + /* + * update number of entries in the blob, + * see SeaBIOS: qemu_cfg_legacy():QEMU_CFG_SMBIOS_ENTRIES + */ (*(uint16_t *)smbios_entries) =3D cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1); usr_offset +=3D size; --=20 2.39.3