From nobody Sun May 12 04:47:25 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=1710259883; cv=none; d=zohomail.com; s=zohoarc; b=mOc3eVxqZcxyPMLQWKD4XuFjxmiLDzpbFHe+y+3XV9X/G8Qv5qq6AU4JKqJtnYN+VrILozp3kfgjQq9o9wnA45Z1rFCfuZWzUZMNri/SkHA+areVzFO5d3+1ParqFP79RnpjmAuZRXY/CIKrhn9Xu91y4tYJUrScu9XX0zwmHz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259883; 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=mWwbFnSncZ+zAOksFy4zspAoUh0fXOGP9SXeGYgnjqm0UNTrhvYrjpGxhK1P7s6AzP547Ewa9cSfJRBsiPmej0vX+FDio4UPa71DozLLlVFK8e2qtbbAVDB00hp/vgI1+B1OdaehdAylLNOEJY9cp1MJL+DOro6w8K08X+PoA9Y= 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 1710259883075472.4129418782816; Tue, 12 Mar 2024 09:11:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4iZ-0005y3-2M; Tue, 12 Mar 2024 12:11:07 -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 1rk4iU-0005x1-5n for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:02 -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 1rk4iR-000790-H4 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:01 -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-466-Fi7SKRRVOdua3BnMuQ3EmQ-1; Tue, 12 Mar 2024 12:10:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 4EF282804809; Tue, 12 Mar 2024 16:10:54 +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 39B913C23; Tue, 12 Mar 2024 16:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259857; 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=igafqrvUjpq40YUBZExoEop3JK8aUaKEzOLTkx++posOchspfSLAnBW7wDwSJ6yEdnEzUb bBZ6r92txNnTjGhpr1sCVEpg2ihwfZjovfVMZq1kOh1dz/nDjlxZftkgLcVbVfJdcJvXXl Sjn3yU3v/MmJULvb9Z6eaath5aYJMpg= X-MC-Unique: Fi7SKRRVOdua3BnMuQ3EmQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 01/20] tests: smbios: make it possible to write SMBIOS only test Date: Tue, 12 Mar 2024 17:10:31 +0100 Message-Id: <20240312161050.2248814-2-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710259885610100003 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 Sun May 12 04:47:25 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=1710259969; cv=none; d=zohomail.com; s=zohoarc; b=C9hWIRvOUmwCPPwydYB2+xD3RMCAgMZbBuhlMZ0tgONN1YeVg1UJ8zoJoc7GT7md1uUnqlMbOn8WDQNyDAf1coAmOryK1m8iNCgS7hLMpvkQXgry6BKjegrMDujacs+j8eI6qol/gCF5i4DWemdlWQbltJEvXHR32IByiWu0Gxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259969; 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=lkIimrq3jjShxq7/hjJhHLilFvvgKMlJm4YoeBmvfVK9nVW2JujEFxB0C5IO1zQIQs4SoOqIENeGmkQrAldIstx7VArOr7iIqlsPu2XTa56QcSm2mmA1ptXH7Scat3MXD0E6HdihsPIm9EL0CLzYwfCnA3z1cee8tsAI+bIbLSE= 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 1710259969053373.90241920958374; Tue, 12 Mar 2024 09:12:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4io-00068E-7L; Tue, 12 Mar 2024 12:11: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 1rk4iY-0005y5-0L for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:06 -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 1rk4iT-0007A2-6O for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:05 -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-227-PLPqCaKnOm-hAVHhAmhEvQ-1; Tue, 12 Mar 2024 12:10:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 7B1118007AB; Tue, 12 Mar 2024 16:10:55 +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 7FE4E3C21; Tue, 12 Mar 2024 16:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259858; 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=Eg+iDVEZ1kfhXJ2CjxqqxMWGzUKTK9qWWzPnXz++1VDLiJAa8xcjk08N0d3X5Bntq01tA9 kauWp2FtMuv9kZ04/YIFV+vmd9DV0in5rTcNJDxKUm9HLjmbiFxJuVW2Rq2oTs4NOAVbdI Gw1i7nghRI+rq8jaNle82Vu2xnCVlqI= X-MC-Unique: PLPqCaKnOm-hAVHhAmhEvQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 02/20] tests: smbios: add test for -smbios type=11 option Date: Tue, 12 Mar 2024 17:10:32 +0100 Message-Id: <20240312161050.2248814-3-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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: 1710259971182100003 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 Sun May 12 04:47:25 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=1710260056; cv=none; d=zohomail.com; s=zohoarc; b=hrOg7ePqLqovW1S7QxqegxiDWhNq0vRrIvqJU91imTVJQGYoRHBESeN1o1BKSACa1oMUzzksQzCI0ejkkklharAVo8uYQhs96YlKtLaGKPBbuvrp1fdM2YGIUaHWcEzCs2Ty+IyKrMXmguLtrCF/nsYzQuNp/fssmw7SLNRzzsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260056; 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=R2xc5cJhFUTmQmWhpPApWDaMT2eoXFkkvAtAOnHK750BKQPRGYACSU7MFuA7Y4yI8K+zctQgeURbosR7NRvir8tAznbzjSRDTeV9bDhaMui/tIyY/LrlubbIGiVoQCEOlBXMtzTzS+PDxvkBa3F/QlqxGuESxgXdWZTBVEDSeYY= 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 1710260056363243.20301290933253; Tue, 12 Mar 2024 09:14:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4im-00063l-Ak; Tue, 12 Mar 2024 12:11: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 1rk4iV-0005xN-Bv for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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 1rk4iS-00079p-NF for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:02 -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-295-gzSZ8MBdPvqXzaUzD-p20g-1; Tue, 12 Mar 2024 12:10:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 A69472804626; Tue, 12 Mar 2024 16:10:56 +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 ABEF53C24; Tue, 12 Mar 2024 16:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259858; 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=PWlSif5zJElAY7gIhcythS1WEBdF7uqS87DgCbDOZ9Sve4kfd5JthpSaPIIw1lGxeBFRyr nihk8xqLbpSkscEnPvKSSLz7h48E53f75wPJK6wRScdwe7ZE+ekMK5mvsbQp3Up8jY5bSo gm/j/NorYzJSn3tQcZ1wAQTcJA4pY+g= X-MC-Unique: gzSZ8MBdPvqXzaUzD-p20g-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 03/20] tests: smbios: add test for legacy mode CLI options Date: Tue, 12 Mar 2024 17:10:33 +0100 Message-Id: <20240312161050.2248814-4-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710260057605100001 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 Sun May 12 04:47:25 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=1710259894; cv=none; d=zohomail.com; s=zohoarc; b=AhOWGeO06xU5Oxei6nLrQmTTxJPz6g8Tfbx07oh/GF9KHz6QLIbJq3+LrrSi8ckRa8W4o7AnOdq40u5r7OeLfNqd2KEXn3VVPkj/o/PBd4UmQbdrcv9FO5UnXyaSQ+Ylv8emtiiubDm7r/O4B2w2r5raqwh79MiVTepztMlUUGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259894; 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=f4c9OhW/hQJQKbDD3J0uL/RxP31+gk21VGQFZ1SY7OM=; b=AG5KYlRxx8371FDAtqMUjCMri09aKPxFhLJGXMi0nBHPBj9x+B07QDpiWcsV5e0WuSNEli7ej9Jb4i+Uo7PRaskJ69sNo0Gw/7QPQWp+db+9cjeq70Myu7jZ7qae1z+xc6ZQ6vw06nGrI2eAcSUsjzeYCm2UDBikZAHo4G3p5nA= 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 1710259894056428.6117148386103; Tue, 12 Mar 2024 09:11:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4iu-0006Hk-Mo; Tue, 12 Mar 2024 12:11:28 -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 1rk4iX-0005y4-T8 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:06 -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 1rk4iV-0007Bn-4z for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:05 -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-583-5Atmn7RtMbCFuCI867FFkw-1; Tue, 12 Mar 2024 12:10:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 D2445800265; Tue, 12 Mar 2024 16:10:57 +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 D7C8A3C21; Tue, 12 Mar 2024 16:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259861; 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=f4c9OhW/hQJQKbDD3J0uL/RxP31+gk21VGQFZ1SY7OM=; b=IEWA6mK2J75YZfyfhYjnl38/ZB6GMvg5/gN6rZZENlFhiPC4vRXNMhNGl0Mqp3KHe6UT6q G4JHfs4793bgQ2MTiMS+Y0NXS1qbCnfEO3eqXaCjfXrgYYj2c9Jzm3umkoL42vyJuoPKOR qDs6bi/sBNalFEAFvefC0+AOFzeo5LE= X-MC-Unique: 5Atmn7RtMbCFuCI867FFkw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 04/20] smbios: cleanup smbios_get_tables() from legacy handling Date: Tue, 12 Mar 2024 17:10:34 +0100 Message-Id: <20240312161050.2248814-5-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710259895264100001 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 a3c4e52ce9..8e86c62184 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1106,12 +1106,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 Sun May 12 04:47:25 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=1710259953; cv=none; d=zohomail.com; s=zohoarc; b=SfCRx2GZi2MnKJA05MNf5EJKdjkKcwA04Jo6E9dO3sLcZCsxJXRkjszsnxc/X98UYgYvCf6a3zQPmF/5HSM+mPh7bjuoWFs+oD9wuEg2q6Zfonl8oHh3hbYpilIF17VOfNMKL66vzMmZUazCJ9mzTbiW/HfwKCvDY4PA+GKiiAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259953; 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=aSsOcNW5C4Sfk8owtfk708TMLJwGV5ZqPTaDuS5v5F4=; b=SdbCb3HzG8kagEmtrd5MljPzDrXTa3BWoKm9XBHoZ3tPHpgCF2eYqQ5mp3GIvCsyt7ZVb1W7BPVAddhNsAnB5r9VEZUpy8LQutva0QoM7TcqjwSCj1jEQIm9cAVLtvfvoWM9M5cKV7z6+pMybtRgt4fhbVfcxrlY0CEQ0yfZYnE= 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 1710259953058531.2107212175587; Tue, 12 Mar 2024 09:12:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4il-000641-NJ; Tue, 12 Mar 2024 12:11: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 1rk4iX-0005xz-A8 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:06 -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 1rk4iV-0007By-3J for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:04 -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-284-mS3t-OtgMEGvUl-ry0YuoA-1; Tue, 12 Mar 2024 12:10:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 0ACA41C068CB; Tue, 12 Mar 2024 16:10:59 +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 0F2FB3C22; Tue, 12 Mar 2024 16:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259861; 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=aSsOcNW5C4Sfk8owtfk708TMLJwGV5ZqPTaDuS5v5F4=; b=XTDIk8rWOSZzmVDJd+C7o1D+Xm6be9X3v126aai2s0D1UwZmmMg2znn6UkrKtEpdn3eaKr jfDDMHTqXCrugyhjijDEu6JgafevsNgEpnBU4Kk06hXcSLjFJ0BLyCb709qG+BjMoUiS5J DXyze3Bez09UkVSNPH4v7h9XV832qSY= X-MC-Unique: mS3t-OtgMEGvUl-ry0YuoA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 05/20] smbios: get rid of smbios_smp_sockets global Date: Tue, 12 Mar 2024 17:10:35 +0100 Message-Id: <20240312161050.2248814-6-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710259955370100001 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 6e514982d4..a187fbbd3d 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -296,7 +296,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 8e86c62184..15339d8dbe 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); @@ -476,14 +476,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 @@ -571,7 +568,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; @@ -581,7 +578,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; @@ -1112,10 +1109,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 @@ -1160,7 +1156,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 Sun May 12 04:47:25 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=1710260117; cv=none; d=zohomail.com; s=zohoarc; b=E8ZXWZXjKyArrnOVEtmqQ7xQeg9RVUHxl7XYqUK70qeU7ADh8nyv02vl8+6sIaRWWWTuc7qPWmapxKX1Ng6v2RZ8apdpithD8bV75wpPBL4xOhnw0q/o60YeB5/eXj/RhN52p7nXs4sMgn++4mSy6Z62CnMAM1THB4miyuqcY2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260117; 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=0iWNVUyhni6FRMovVlSl30ipAzUSKstUsEhq4kAyQNY=; b=BrKC/4eoFZEcx7zuUCUkodJeGqL4t3ce1a7xU08a62C3VcCFsfdvgEyC0TzxzfYcehEuHq2nOWJzX1wdLUKY7nDIwgScDJJDlVn0JFuBdOuRHY2otH3bJiQcaoErUsFBXzmfVwKjVCT+I8y1TUyPjnHQyfpPf9//Y8xhrX9HrNY= 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 1710260117943958.954933597107; Tue, 12 Mar 2024 09:15:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jG-0006vQ-HL; Tue, 12 Mar 2024 12:11:50 -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 1rk4im-00066I-GD for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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 1rk4iY-0007Ey-VJ for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-362-J50qd_4DPDSVpjs_3iFwww-1; Tue, 12 Mar 2024 12:11:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 5483438300A7; Tue, 12 Mar 2024 16:11:00 +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 3AEF63C23; Tue, 12 Mar 2024 16:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259865; 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=0iWNVUyhni6FRMovVlSl30ipAzUSKstUsEhq4kAyQNY=; b=E04auBm7B+Zk4NFSNhApfw7D/wsiKazn5oWBwdXsoEFbYx8xYjHoDW1rjWjDo+bIX1rtLq C/prjmmXhrjpbtYkcQbOLb0caEIiCKkCkvoWiXLf5pxJ/F8vzLiUSgoPMD8y9ydVw9aXTL RaQ7oCyd5jwnwkhEOW1Z5SFtbv/51Kk= X-MC-Unique: J50qd_4DPDSVpjs_3iFwww-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Daniel Henrique Barboza , Fiona Ebner Subject: [PATCH v3 06/20] smbios: get rid of smbios_legacy global Date: Tue, 12 Mar 2024 17:10:36 +0100 Message-Id: <20240312161050.2248814-7-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710260120017100003 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 a187fbbd3d..0818184834 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -293,7 +293,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 0af1943697..8588681f27 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1633,7 +1633,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 1e98d8bda5..8c7601ef91 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 15339d8dbe..c46fc93357 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 @@ -570,9 +569,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) { @@ -1006,28 +1012,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); @@ -1103,6 +1094,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 Sun May 12 04:47:25 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=1710260058; cv=none; d=zohomail.com; s=zohoarc; b=dzBUVUmWUPBzFibZhReBlYwQLRXOdvYbzj3rGFGn6/iR/28ZXZHNzTVErTlKXs4s2pXJZtPyiW577mYMUmjAzhFOujPWYQ4DSTBKr+92ZhhWFJtSrm9kBqioauqFYQJ+/+kS4wf/gl/EEpByiI7OKeylK5DJr/8dVWqnFzkyr8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260058; 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=AbaFjK2bt30jAVZJxlI6zpld6TfSuw7Oq94dK+97nYE=; b=TTYNfvIBfDmyVUzgpxvlwyzXvyY7ZxW9SbqVQlnu98pB18CZuLgSbG36jhnkTBO26p66qqaz10vkeaumsLSzEgui7szifU7Vmcqi/FcE0dTfMHoW7t8f0x+gq1UFbOxulHJ71oFsSf7dQ7TP98TjrYCVnubSom5HPdIydVet7VU= 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 1710260058382326.5483055790768; Tue, 12 Mar 2024 09:14:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4iu-0006EN-HD; Tue, 12 Mar 2024 12:11:28 -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 1rk4ie-0005z1-Nf for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:14 -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 1rk4iY-0007FE-VQ for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:12 -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-540-IQZBUYscPzW-tz5RUhTBwA-1; Tue, 12 Mar 2024 12:11:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 033C98A5E60; Tue, 12 Mar 2024 16:11:02 +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 85AE63C21; Tue, 12 Mar 2024 16:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259865; 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=AbaFjK2bt30jAVZJxlI6zpld6TfSuw7Oq94dK+97nYE=; b=BefYTORhKvU3eTrXnvhw1NhhpWmsQtGcAZn5+Y0IDv3A7Wl1SN7wlsiBgZNW9R3KIULIF1 jD7fwJujF/0rpZ3lBHRpam71n5fZJJ+X1jONueVZs3YLWVOqqOCmbd3GDfUDUIagVRN3eo W62E53H1stlSAyEuZnSQJCmq9YRXm+4= X-MC-Unique: IQZBUYscPzW-tz5RUhTBwA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Fiona Ebner , Ani Sinha Subject: [PATCH v3 07/20] smbios: avoid mangling user provided tables Date: Tue, 12 Mar 2024 17:10:37 +0100 Message-Id: <20240312161050.2248814-8-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710260059672100005 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 --- hw/smbios/smbios.c | 179 +++++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 87 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index c46fc93357..aa2cc5bdbd 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 @@ -569,9 +576,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, @@ -581,12 +587,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; } @@ -1094,67 +1121,67 @@ 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_11_table(); + smbios_build_type_8_table(); + 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; @@ -1254,13 +1281,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; @@ -1277,9 +1301,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); @@ -1300,34 +1324,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 Sun May 12 04:47:25 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=1710259984; cv=none; d=zohomail.com; s=zohoarc; b=l4lMRCK3YlOFr7T5sPlAPSC7AIFQ88ZOGwX28hbyf1DQaiOXkWYf0u+/YwvhkSWRhCPO8Gnj8mbH5hMINPB5Edt4FNJsxGO66+e9Rw+g+UC/uQqeEw6uVhMKJH6cRL6X6ZGH4tW7WIXRllskdU06nFzK58tRx37gPckqlzZt96U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259984; 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=TXhti8GjCiKDQVKe6ZdQvxF0sHLFcQvkDcPjISJFWyU=; b=C7aUDvV5MqzK7+MOh1Sh/SGAzhdWoznE7CTdslXlTIZSS52zwNuGoKazDPwGkxxwpbeSYeIdsZa8vFBzdkdP83BnlMc+xQtGySKmQ7ExmQrNsvgdbnrwLPWHJ9UpVYuXoJg/R1NmgFS5xgvmGB+2bnvL2QFnRvlObEjIKzJrzzQ= 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 1710259984786708.650504332318; Tue, 12 Mar 2024 09:13:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4iy-0006NP-Tz; Tue, 12 Mar 2024 12:11:32 -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 1rk4id-0005yz-7a for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:14 -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 1rk4ib-0007FJ-1O for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-104-mJO7pFXDOMWXlyQD_e22xA-1; Tue, 12 Mar 2024 12:11:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 2F7A28007C9; Tue, 12 Mar 2024 16:11:03 +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 33E1C3C22; Tue, 12 Mar 2024 16:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259866; 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=TXhti8GjCiKDQVKe6ZdQvxF0sHLFcQvkDcPjISJFWyU=; b=c5NdivWpDdqUBXpqOTcUomFYkEytZ1rBhc5ovW7CaK7T0Rt0rgMhKOfi4jU0mpBdb1BFBr +g+d11rgNcDBhiIkpl0NQb2VtIpf8MFEIQ0UxrbPhavSQ02ZV8hdVaIjXcquFqHtYfr3Vs 0htsIHY+SNn6HULsEX40cKS6lm9RUrQ= X-MC-Unique: mJO7pFXDOMWXlyQD_e22xA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 08/20] smbios: don't check type4 structures in legacy mode Date: Tue, 12 Mar 2024 17:10:38 +0100 Message-Id: <20240312161050.2248814-9-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710259985480100001 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 0818184834..1fbff3c55f 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -296,7 +296,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 aa2cc5bdbd..97cf762228 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -482,14 +482,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", @@ -574,7 +577,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; @@ -587,6 +590,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); @@ -613,7 +622,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; } @@ -1180,7 +1189,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 Sun May 12 04:47:25 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=1710259929; cv=none; d=zohomail.com; s=zohoarc; b=NSre/NzVtpnGehRYiN/A5sn+kbu5yilHb/dH/BS9ENXa4hDmtUw1M19I3mwzz3c0jh9sf0P/kTp3ZLREkFYx32/XTcnl9T/+5iYfqo0+onHt6FOioQVnzisqpqcKup2RfAg8VeB3KWq7CeOoqXCtRDizomUJLe5nJXI6ARchCGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259929; 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=+1D+Sr9w0lEiS4tSeA2OrzahtWnEpnL/9KKsdlZY5pM=; b=ZPdtYcTroG/MxpTLlwlyNusRPFrNuT9/4YXM1DMJIvglctMgZtu0utskG9CG4rnE5i/dcyglt1tcDvSyS0LiSwII/Nba5DPiJL98wG5BM3E8XCM4LfG1iYgiiqXpGBa+L9TnecwTJGknxZ7ytBXkVjrMggtI+0Wt8YBW/ZVSRmQ= 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 1710259929707977.9328605770316; Tue, 12 Mar 2024 09:12:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4j7-0006Ws-J3; Tue, 12 Mar 2024 12:11: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 1rk4ih-0005zc-Qv for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:16 -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 1rk4iY-0007FK-Vj for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:15 -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-614-QMx4Rl55OFqNvRGpXFU2rg-1; Tue, 12 Mar 2024 12:11:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 428048A5E79 for ; Tue, 12 Mar 2024 16:11:04 +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 6077937F1; Tue, 12 Mar 2024 16:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259866; 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=+1D+Sr9w0lEiS4tSeA2OrzahtWnEpnL/9KKsdlZY5pM=; b=cb+W/WHRZ99bm7912NojhNRGB+/yQYQ2hc2QgaFxem3qho9ZAIbsTRoHCEGdgiZadUKbbH cCWjO+6EBrXvxHiKycL+hRecw0D2v5rjx4r+RLtHg6Ujq6cSxqZzFujIifRfMtHLl/ZMcb pjOCiN5/uYCoYo5H18sHy7IhiOkS7i4= X-MC-Unique: QMx4Rl55OFqNvRGpXFU2rg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha Subject: [PATCH v3 09/20] smbios: add smbios_add_usr_blob_size() helper Date: Tue, 12 Mar 2024 17:10:39 +0100 Message-Id: <20240312161050.2248814-10-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1710259931157100003 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 97cf762228..01180bd82c 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1287,6 +1287,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; @@ -1334,10 +1342,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 Sun May 12 04:47:25 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=1710260114; cv=none; d=zohomail.com; s=zohoarc; b=CJ1jC9BkkI0NNxmULjB0Gie4py/RUdqZHdBwKAu/8XUwrS1gkfw0SjUgsCil1EJgwWNjYXtrIKssM0uorFOxM9Y2AFpJrj/o4y4XbSAjC/Xr6sawvnVbTzy4LJstyUkB15W5h/8smKeRTYY9sj2q9Mtw14p7WayEr3yxI9wfiTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260114; 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=QDv/zSINy8tH9Na/1QKSCrzsfkFA7AteZ7unQaoq+p4=; b=LuzE4VRk1mT+cG3L2qJ7+0YgReZjvx3KM8huv2yxuQgPLJmGf+YmHu9PJ6YQ3SZBZNJCnkvZO9iK/afqmhSzi5RdIf46nZ3FBWAIxHhgNT1Hf7QmfJsABG+mDjtZ/vHVf+crw1TA+5nzmrMvPaD2l8PMGAi2FlWHB/+lSP1qYIo= 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 17102601143771019.4726530369352; Tue, 12 Mar 2024 09:15:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4j2-0006UB-Lv; Tue, 12 Mar 2024 12:11: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 1rk4ih-0005zZ-BS for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:16 -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 1rk4id-0007Fj-19 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:14 -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-577-1U1IhB0nNiOYy0vlX6GpAg-1; Tue, 12 Mar 2024 12:11:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 53EE48007B5 for ; Tue, 12 Mar 2024 16:11: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 72A5A37F2; Tue, 12 Mar 2024 16:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259867; 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=QDv/zSINy8tH9Na/1QKSCrzsfkFA7AteZ7unQaoq+p4=; b=OmnAgXqEPyK2hssb5oIAXd7cSgNvAbOd9Armd2w6/L62idKod/MxAOepvXshrzQCHy35qI HJzsoBJ38ZKqw+vDQU4QvYICQqGaX+7Ji2CGEeqwqNwbb1HqP4vcKQfPUcQXAp5ka5NjGy 2psRUjfFH7kQ+Whkkm1DHLrRxnoMxZ0= X-MC-Unique: 1U1IhB0nNiOYy0vlX6GpAg-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha Subject: [PATCH v3 10/20] smbios: rename/expose structures/bitmaps used by both legacy and modern code Date: Tue, 12 Mar 2024 17:10:40 +0100 Message-Id: <20240312161050.2248814-11-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710260116181100003 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 1fbff3c55f..bea5c3f1b1 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 01180bd82c..86cf66b5ce 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; @@ -536,36 +528,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 @@ -583,14 +575,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); @@ -631,10 +623,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) { @@ -661,25 +653,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; @@ -709,18 +701,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; } @@ -1055,9 +1047,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); @@ -1329,13 +1321,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) { @@ -1366,41 +1358,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 Sun May 12 04:47:25 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=1710259921; cv=none; d=zohomail.com; s=zohoarc; b=A05thP+whO6obZ66OJV41ojBd7H3wZuRHS7SzZ52szCv4e3hF5O6u6XYWF1j9F0TqHwkBsd+RHd9jBV1OO2f5AvMzwDXSFk+WOlSbjZEDqi0Fw3A584WrX3LG8knuw5SPmWGgcNEg5/LBAIxSsZKMmvNcUNlyRrqs/SJXZHAGDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259921; 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=WmAyNvxtIaU6Ri0kA8UDcfYKbt9d2VuNEx69ywijBZU=; b=L1461ZHKRkLCgKkX9Xqecgz/+WsziR8YMF2XCCmEdgNySglwuTdmDeVgfqHG9hjUO24bI6mzYQWqp2UxjXwOCVLv4AgV/Es2KxtFkmxfmYoNFOzJTE02TquU5eFJgOBxDGsy4GA9WuwXJQ+YWribHIIIJdFCBbrgVM3mX66OTMo= 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 1710259921032438.66878171122994; Tue, 12 Mar 2024 09:12:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4ir-0006EC-JO; Tue, 12 Mar 2024 12:11:26 -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 1rk4ih-0005za-Co for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:16 -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 1rk4id-0007GG-0e for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:14 -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-651-NqDbV97EP6mvqwefXxRPOQ-1; Tue, 12 Mar 2024 12:11:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 80F0585200E for ; Tue, 12 Mar 2024 16:11: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 858B23C21; Tue, 12 Mar 2024 16:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259869; 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=WmAyNvxtIaU6Ri0kA8UDcfYKbt9d2VuNEx69ywijBZU=; b=N5Md3AaK67XqVhTNYtKyCy2Y/NQx1gFmAdW0qiHsxASCKkLWT7rv0q2ChvyjgEKBzYFqW1 gEvWIL8zA20tKlidPa+Iy2DwOyw2gvWSCM0qYmf6cuYrLsRMixUmRVEnVxpdpEwVqfc/sq gRC06noOhc5xHOYUzqV1uC+c9dCffBM= X-MC-Unique: NqDbV97EP6mvqwefXxRPOQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha Subject: [PATCH v3 11/20] smbios: build legacy mode code only for 'pc' machine Date: Tue, 12 Mar 2024 17:10:41 +0100 Message-Id: <20240312161050.2248814-12-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710259923437100001 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 bea5c3f1b1..7f47475aa4 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; @@ -306,6 +309,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 86cf66b5ce..fb1f05fcde 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 @@ -483,7 +457,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) { @@ -493,134 +467,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)) { @@ -1279,14 +1125,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 Sun May 12 04:47:25 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=1710259988; cv=none; d=zohomail.com; s=zohoarc; b=oH0MvNuTPYF+9kpbYCp0RkG5iprIpv8kD69daOJdY280fyNNPMmxag/NsG3QrM3/DYkKpiHs9EsHTpJnLmvUUViSIUKjMYwJqJCTA6i0XFYbz7g/+0VLQ8S9Rt+dPTWEasv85aiUlweCh539Ms/Zz+2YxBNrgDc6ozT23w+9wYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259988; 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=KZem5r/33t4PpBOE0DrjG0AXp6uMKHnkqPTKd1sRtKk=; b=Pj6+JP9esp0/g4XinrxsAaXMWMG9P5Boor/umas65ayd8b6ToveBqWygOc0Xoa0qT1PJcLM5bu7GwE+wMhbTXciJGx5i2zk2j/IcZc3SyKzyQOqhROLo1o29z0sH7KD0sS0HEctoDwEY76AwoLhpbPpjDqKVRU77NIymgg7hRcc= 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 1710259988421475.5615743965909; Tue, 12 Mar 2024 09:13:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4j0-0006MQ-Bk; Tue, 12 Mar 2024 12:11: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 1rk4if-0005z4-6G for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:16 -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 1rk4id-0007G9-12 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:12 -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-303-DszxrhnqPFSVjqEiNqZKZQ-1; Tue, 12 Mar 2024 12:11:08 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 92CEE101A588 for ; Tue, 12 Mar 2024 16:11:07 +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 B1A593C22; Tue, 12 Mar 2024 16:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259869; 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=KZem5r/33t4PpBOE0DrjG0AXp6uMKHnkqPTKd1sRtKk=; b=cNyzCYfwi2+/LIAV433KUp68bSw1ssbg9vjQd8dOTWEUR6Lk2Y7dgLMbwBPo4uHTrvuwRM GnBN7mwZrh/C9gsx15SsSeKht2Xx87kM6YBqKxstBa/lBHmxJSGEXq+FBbZfM/h5eZxwKS TFIVrzc5yVpBZj6xYWVM5v6403Rx/fA= X-MC-Unique: DszxrhnqPFSVjqEiNqZKZQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha Subject: [PATCH v3 12/20] smbios: handle errors consistently Date: Tue, 12 Mar 2024 17:10:42 +0100 Message-Id: <20240312161050.2248814-13-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710259989290100001 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 7f47475aa4..89bb10510a 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -309,7 +309,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); @@ -317,7 +317,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 fb1f05fcde..d9ba2072b1 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" @@ -448,23 +447,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) @@ -1027,15 +1028,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); @@ -1044,6 +1048,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 Sun May 12 04:47:25 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=1710260018; cv=none; d=zohomail.com; s=zohoarc; b=TDsxWuLuZZnbQ+EOKw7FuXeRNZhZ9BSuhRd1XlX0FX6X8F+bq6K9rcVztBhG57vk+i5aBBkXsFGfB4b9YUzqCHVQMettwR9PiOrmzTPgHtSW2Xb42/4/J2Vzyt4h7PO3epgkkgc1X0YISJQmumU2tFdZjRcnFRWO6aVuGJe6sVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260018; 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=rXvF/hE33p7N/N4jaK3iwPapuqTqxVdSYWV30bUDz3M=; b=YBfFLCPZjmN8VpV5wba4JzXHlrcRGtyuME1WGRqD0dfranOS5lSFMtKLpDYWoy8z39Wk80/DBCV0Pfv5onnIKzok5Pp2EC+w26tIwJkyHDeEIs1FNH8LtpQdnkh6fx2vkXDtBPgO4N+cNi/HY+roY5HK/lEiG3panPg7feOhVhw= 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 1710260018202710.2819062611597; Tue, 12 Mar 2024 09:13:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jA-0006av-PW; Tue, 12 Mar 2024 12:11: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 1rk4ij-00060l-42 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:18 -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 1rk4ig-0007Gl-Cg for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-28-AchHfLpNP9mU1tw3x9oRBw-1; Tue, 12 Mar 2024 12:11:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 DA6578007BA; Tue, 12 Mar 2024 16:11: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 C3F773C24; Tue, 12 Mar 2024 16:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259873; 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=rXvF/hE33p7N/N4jaK3iwPapuqTqxVdSYWV30bUDz3M=; b=EltWKu5eilpaRDDut0tp/tqZ3DDTB7jxybKrdngyCl2YEbt3cH3Q41dwYXtAbfzjpEmDm0 E2m9/8l/cfYQxFwrIaixwRNy4aa7S8FOVhPH+axf2NsKI+KIXeotwFsfRgzdwpKZ9QeY4G voIOIDkkC0N8zyuTTagNgeNj0xeB+uM= X-MC-Unique: AchHfLpNP9mU1tw3x9oRBw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Daniel Henrique Barboza , Ani Sinha , Fiona Ebner Subject: [PATCH v3 13/20] smbios: get rid of global smbios_ep_type Date: Tue, 12 Mar 2024 17:10:43 +0100 Message-Id: <20240312161050.2248814-14-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710260019482100001 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 89bb10510a..d128aef31d 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -309,16 +309,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 8588681f27..780224ee5b 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1634,13 +1634,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 f5ff970acf..a8e8aa2ac8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -691,7 +691,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 8c7601ef91..05f616682a 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 d9ba2072b1..5a791fd9eb 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 @@ -457,9 +456,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); @@ -605,14 +604,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 @@ -888,11 +888,10 @@ void smbios_set_default_processor_family(uint16_t pro= cessor_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); @@ -909,9 +908,9 @@ void smbios_set_defaults(const char *manufacturer, cons= t 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); @@ -961,6 +960,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, @@ -969,6 +969,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; @@ -983,7 +986,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(); @@ -1031,10 +1034,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 Sun May 12 04:47:25 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=1710259925; cv=none; d=zohomail.com; s=zohoarc; b=LQqw8QXZQdwveXwqKwfTCs4pt95p5mdMHtQf8elukOdOH7fmoXUFi+3VgMPJg+lHaJjKnSuUDEPYR+iHOZzdP6OyRiNvBrslwu5vTRof0kNAvNK1iU6HBfkvUHUyotdt2zixCXzcKi+5hJdMEMqfq1iIJBXr9t0BXQpQC5HDNHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259925; 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=IzIyBHphGbPNS4xIl9gbBGxoZiLCXyGk+veHTAfrusM=; b=FXSAaGQIUMhggbwkumoJgrC3UoCpjO7GtO0uzFvBKWx83yFc4RZuM3MSjmAfUZGLa2YqT2984cX+S3YrDGeJGzVPlEoe/y6SaJOmEN36AFOPiZ3P3NxGrMy3RvkL9DhrPKh5BqU5cuRhH5ed3Mp00LuQiiKXwufvyhovISZtL+0= 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 171025992502860.51170467085103; Tue, 12 Mar 2024 09:12:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jB-0006j6-Eo; Tue, 12 Mar 2024 12:11:47 -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 1rk4ij-00060m-87 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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 1rk4ih-0007IU-ON for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:16 -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-501-aZO3EuyyOHuhal9PwEGXEQ-1; Tue, 12 Mar 2024 12:11:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 EE1F71C02D39; Tue, 12 Mar 2024 16:11: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 18C023C21; Tue, 12 Mar 2024 16:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259875; 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=IzIyBHphGbPNS4xIl9gbBGxoZiLCXyGk+veHTAfrusM=; b=IYZL6XJiL5U38G8M2I9NBAovTBsQY3TbDkugAnVA6fzKYt/h1mEl/bGgXxZfXO1oAIjOAE avtEHGEos9sKG9qaKjgWZfPvOpv48AIR5BKQyeeOogGCvL2bUjZiQ0BA0SZmEjuWlnOgp+ p2a8V4jI1d1c8ZjWPMfSzD1CCyKYPs8= X-MC-Unique: aZO3EuyyOHuhal9PwEGXEQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Fiona Ebner Subject: [PATCH v3 14/20] smbios: clear smbios_type4_count before building tables Date: Tue, 12 Mar 2024 17:10:44 +0100 Message-Id: <20240312161050.2248814-15-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710259925563100001 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 5a791fd9eb..d3d89b4dd0 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -973,6 +973,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 Sun May 12 04:47:25 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=1710259949; cv=none; d=zohomail.com; s=zohoarc; b=MgJO5hxbhwEdCYjaLaFJA/3Bpo3gbOo0eiIjHiKQl6aWIzL5OCocmKPV1yJyQ5mnpXyNq9KN9ESENzWEvJPnsdly3Ac1O0zM1BemYhtaEEFD3WFMPkMahjwtVz/Gk5nsXgE8kPGH9ZN2UJPt8loHYQmPPTUfVslYY7zoam3I5OY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259949; 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=kerbBVBPCguhbQbGW46+yfkBdknhHG+yCLs926a95NE8fFROkggCOSukkKYs1JdzxIZWRX1+vZ4eQfrVInjqonTUUxk7bxZSi94EomJl4KSzYrhsHiztYoRtpsvzlcPN3KWYiAA8SUdtdh4zB744WmwfpVtonuf1PAKQgxSwVqU= 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 1710259949356629.2153729065105; Tue, 12 Mar 2024 09:12:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jF-0006po-Vq; Tue, 12 Mar 2024 12:11:50 -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 1rk4ij-00060k-3R for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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 1rk4ih-0007IO-E5 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-187-PnevPRyiNxGqjaP8oWU_uw-1; Tue, 12 Mar 2024 12:11:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 3FF7D857E74; Tue, 12 Mar 2024 16:11: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 2AD083C22; Tue, 12 Mar 2024 16:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259874; 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=h4xv7eOnVoTJqrannxgToMmPgKAUXHXsjuRA2qVsklMXXo69zjETukiKXbhtlFQorCfnmP 2Xl6bpRaSWhWABg3U4TMOwywyEsuqMYuXkbzGDzi6xGqT9uTGAKSt2wS0wKTVGAmV1NsXK 5qA7Nou1tsz0uwQQFwcdkdoRnoT+AEk= X-MC-Unique: PnevPRyiNxGqjaP8oWU_uw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Markus Armbruster , Ani Sinha , Fiona Ebner Subject: [PATCH v3 15/20] smbios: extend smbios-entry-point-type with 'auto' value Date: Tue, 12 Mar 2024 17:10:45 +0100 Message-Id: <20240312161050.2248814-16-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710259951108100005 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 Sun May 12 04:47:25 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=1710260048; cv=none; d=zohomail.com; s=zohoarc; b=nhJlF7N6s5Pc7I3YUnWyVG0IoPwkmK9KNonqd/LmAlnfHCWOWR7PjoS2WlYBY1s7B7g7r+mVeexzv3HcN3ERNNmMajPSRtNHDMFXkinPON/T3n+BjVyHPyEGsnUdl0JImvK/YgOFFK7OmCKT0ifa7voPMzXCBIRuuhWqOe7ef7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260048; 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=bcRD5eJH0Tgzy5QwaOjcQclSDY34FVFXN6sYMbePaxM=; b=XxPxpQlGK3jgKjJ7UO3B1wWzROIEKEaNVkc94LaD/VS+wTuBfJKIvpMWsDLIqiUGXST6RqnUSvNRD8TT5FuHK0Ef/k/FG6nWIjclmDPcK/lmkjCMOCcAGH9d+op7CHAh4LTK09QRE+3pUycu1OD4/7/8EUgBV6VIZqhvnNDqZSI= 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 1710260048582248.9769440747658; Tue, 12 Mar 2024 09:14:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4j8-0006Z0-L5; Tue, 12 Mar 2024 12:11: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 1rk4ii-00060i-UQ for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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 1rk4ih-0007HQ-4I for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-235-Ya-gpOwYOGyPcNleIqHqcQ-1; Tue, 12 Mar 2024 12:11:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 6B5CB800279; Tue, 12 Mar 2024 16:11: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 70AEF3C24; Tue, 12 Mar 2024 16:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259874; 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=bcRD5eJH0Tgzy5QwaOjcQclSDY34FVFXN6sYMbePaxM=; b=R8lqgqY33cQz48Yf+Dwjwgoh0OMoUgdYzyRKmUlSbmtirtCIOnkujSnyuXa2U10MOp96mF plN5ewZjQIFa6i4DIqZZb1Xo7rPT2dJKe+EvV+W45pRCti2FBxlgZzWnbDUHtOt6zkWlqk mcoVS8Q+1ReXaehM7IJoOYUbYNO0dgY= X-MC-Unique: Ya-gpOwYOGyPcNleIqHqcQ-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 16/20] smbios: in case of entry point is 'auto' try to build v2 tables 1st Date: Tue, 12 Mar 2024 17:10:46 +0100 Message-Id: <20240312161050.2248814-17-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710260049568100001 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 d3d89b4dd0..c4a953bbc9 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -959,7 +959,7 @@ static void smbios_entry_point_setup(SmbiosEntryPointTy= pe 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, @@ -968,6 +968,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); @@ -1053,11 +1054,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 Sun May 12 04:47:25 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=1710259994; cv=none; d=zohomail.com; s=zohoarc; b=CH01Mad4D9SX4bMNF2c1IbrCwQopfNlAuSPnbMzd6r0l6afA+FPYUJU8abstIBXYVHwRVBzs6s1adbHxfG4zzrfjjwrMgweqbX1HgUIZ3P6gAaMK5cBVKbzxS/pCXf5tu2Z6RrA9Ei88VBtiQUWqGpk0mXhWv3l+uwXss1AV7hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710259994; 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=6SHi24zPgK8xZYDP+B0kH79rrN8fNzqjNmEOAexIpII=; b=VAWG5g5ZFwlZy1j3O47ed6Iqel671jm1/KtiDIZt9BknJ9LQouTY8gMFd7r6MWyZm/ms+lEkWmcul6YjR+VGHib6PJow8pKAahDJIL2LeZj0VtCkHnVzuPikXTq590ha9OsU2be2IUKUaESUhS9EKXSA8V/voipE6EyXri2pzYk= 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 1710259994737661.245629409004; Tue, 12 Mar 2024 09:13:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jR-0007an-Q5; Tue, 12 Mar 2024 12:12:01 -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 1rk4is-0006Eh-9X for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:28 -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 1rk4ik-0007JQ-DQ for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:25 -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-79--WZ8VG5fPLOD5azsTyli3w-1; Tue, 12 Mar 2024 12:11:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 977F23CBDF64; Tue, 12 Mar 2024 16:11: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 9C4EF3C21; Tue, 12 Mar 2024 16:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259877; 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=6SHi24zPgK8xZYDP+B0kH79rrN8fNzqjNmEOAexIpII=; b=htFCf9KQSHPzI3obmLfV+3I7e6VGgcWL6BD6PpOxyG7n7RNDSTcGw+G7wawheu+zjJ55HN c+lB2jaN5sX+xeAHjw79oxMWZiWTtl1iXXU/1RhD/hcIIVQxA4ouwDIykaY/H1+BqKFSeb llsZ+fUjeWKZuzlbNUpM7wxLJIfV/6k= X-MC-Unique: -WZ8VG5fPLOD5azsTyli3w-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 17/20] smbios: error out when building type 4 table is not possible Date: Tue, 12 Mar 2024 17:10:47 +0100 Message-Id: <20240312161050.2248814-18-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1710259995303100001 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 c4a953bbc9..b64d3bc227 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -605,7 +605,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; @@ -659,6 +660,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; @@ -988,7 +995,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 Sun May 12 04:47:25 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=1710260104; cv=none; d=zohomail.com; s=zohoarc; b=LW/xQfd5MpHvVPA9JPxTxx9DeEs6A6RL5Lp/b5n8OdzGUoI2VHpcA8g9LnzAM6jKI8pmjJKRfuwiv6Ud5Hp9iLdv0SVP4YGUollEnxkK/8Vs59PpkzBiC6fPItPUHnIKX8tOAsFHfP+EOYHKN9/7icUt5IC5FZYGW1FPE3JqMH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260104; 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=S7m+iv1L8xZmLqzKuwwkLnKPQ9kycHeq6yAfshz1HuFWO1qt6D8iWjg4uCkLuIPf+T6NG9tBWq1WaRdY6zjHbcjNn2dJyVSBHKVT44QZ3ceBPu2GWeIOiiJ8tM6DlHq/6iC/s1hMryollJGoB+S9rlSwJfVlMFMN5OalsBqdYRc= 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 1710260104500482.6265199347249; Tue, 12 Mar 2024 09:15:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jM-00073x-G8; Tue, 12 Mar 2024 12:11:56 -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 1rk4ik-00063D-Mf for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:18 -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 1rk4ij-0007J3-3K for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-248-KFWQ6EhnOcabyhpF_5iZsw-1; Tue, 12 Mar 2024 12:11:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 A8FDE1819FC2 for ; Tue, 12 Mar 2024 16:11: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 C84473C24; Tue, 12 Mar 2024 16:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259876; 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=TaD/Bul1OefpcvEI3rwPPydptplOUnmeMd0h4jzE8gqpQVDGTvGl9J3rrfJBd6RUSwhBzn h55+3tiK8Itnmq9VrSiJplADF99FxcL1QoTjMsn8kCh0SppOgkaCv9ysnR4tMUk3YnckdY 0yHGTuSUmqoN1Hcbx6/k0qoRBgUBn9Q= X-MC-Unique: KFWQ6EhnOcabyhpF_5iZsw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha Subject: [PATCH v3 18/20] tests: acpi/smbios: whitelist expected blobs Date: Tue, 12 Mar 2024 17:10:48 +0100 Message-Id: <20240312161050.2248814-19-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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: 1710260105963100003 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 Sun May 12 04:47:25 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=1710260064; cv=none; d=zohomail.com; s=zohoarc; b=V43bZ4Rv6HehbYn6pnKIZVFeg3UGEPVeKBXWRzrCnIjHqi4Rcdc2kQ0PDk1B/ML275VUwXUQdzogz6IwMFk8B8QgWuKsb6PfeqHAsA8lPGCfTQZy40qWgBy893/oZlUwzz/djz9wYAc4Y+CfgZyTQFWxJz501HjCkfJdVrFt+Z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260064; 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=NX+1pUcb26oyJWxuy8qD9M8Pf9c6lEpEj7bKRXsqTus=; b=UTXOQNI9gXSMBj3iVqfXY8Ba21QiNcUY/FlPJz3cUMoxlhvPYZWN6/Qpbm4BbicjEJ43yXSnHJSR9PcHPeCNlCgnqif9p0iBEUrT087RU0uhW6AZcH/xJWMuHMyUwy90K+1BdGhNlkEgRjcp4DuLW9jtNsGIakkSCXpVeGEpgPw= 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 1710260064215928.0681976967439; Tue, 12 Mar 2024 09:14:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4jH-0006ym-4q; Tue, 12 Mar 2024 12:11:51 -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 1rk4io-0006BV-Ls for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:23 -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 1rk4im-0007Jq-BR for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11: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-251-OczK7HlsM1KDT531lisNIw-1; Tue, 12 Mar 2024 12:11:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 D4CAE1C07F4D; Tue, 12 Mar 2024 16:11: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 D9E6D3C23; Tue, 12 Mar 2024 16:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259879; 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=NX+1pUcb26oyJWxuy8qD9M8Pf9c6lEpEj7bKRXsqTus=; b=MLk0OdE5WLjqINVMUlYqN3LCKniLnp0hrndk39uOU0p+2lPk/dEVaRHsKK3GF8478ZCMeF F2qITvkNU1/jTT1ZzM2bsAg5vhrmmVUheNOjodOfXYOZnbdX4irWUFhzKKeu4cwoQNDjKq ZX1d73MYx+QDekmnr1NH/h4+w/KJlio= X-MC-Unique: OczK7HlsM1KDT531lisNIw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha , Fiona Ebner Subject: [PATCH v3 19/20] pc/q35: set SMBIOS entry point type to 'auto' by default Date: Tue, 12 Mar 2024 17:10:49 +0100 Message-Id: <20240312161050.2248814-20-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710260065660100003 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 a8e8aa2ac8..cf16337341 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1847,7 +1847,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 319bc4b180..bb80c10b96 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -526,12 +526,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 45a4102e75..6fef3b17bb 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -369,10 +369,13 @@ 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; 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 Sun May 12 04:47:25 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=1710260024; cv=none; d=zohomail.com; s=zohoarc; b=YaUBGrPhN0fnXgc+Y1EDR8la1EqBfXjjh+963eL++oWm2LpXR4wa1BOi+P0Docmb1a6p+3/sdVqrNwE7frczHon/ZXvZCUbstnrNvGk1TD36zkTAUI6wEQp+A162fdC7eqYwMWksFey+Pw+rFfURsaO5LcTJtjOOGgkOHVKL/JM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710260024; 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=ZdfilKnBJqnXQTZ8G8LsoMbkq0HgG345O1uSBcom9VTusX7LH/FfDaXXwWgCqh6AvXFnW6JAyqsYRO1Q8XSK38lMT5KDaE/ikWIeJd3cnQ0YsMkSa/STYXlWOTIWp3IjQhHe3ZEIwh8CMMn5bis6Ta5c5w8d74gSAZ/XVEVUTgI= 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 1710260024092420.4585921145764; Tue, 12 Mar 2024 09:13:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk4j8-0006XJ-8s; Tue, 12 Mar 2024 12:11: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 1rk4in-00067z-Kr for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:22 -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 1rk4im-0007Jf-6U for qemu-devel@nongnu.org; Tue, 12 Mar 2024 12:11:21 -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-593-g7g4TVVpM9uUUOvXXarkQw-1; Tue, 12 Mar 2024 12:11:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 E63EB1C07F46 for ; Tue, 12 Mar 2024 16:11: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 11B353C21; Tue, 12 Mar 2024 16:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259878; 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=N5cSJyvBbGl7TIpjcOCGEII7GLMED6fmOefm/ztQ9SSsZ8OxOHL80PFu/Y8vjdmcOviJd0 sq3o7a254HhSahOBIxuncChcn9fuYARCyC/n+KKD4spIhm33RpMYfH5su+ForMxbjG6ljQ mtx8ZeghQuFauvmb/BX3rFZTYPMIdAY= X-MC-Unique: g7g4TVVpM9uUUOvXXarkQw-1 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, mst@redhat.com, Ani Sinha Subject: [PATCH v3 20/20] tests: acpi: update expected SSDT.dimmpxm blob Date: Tue, 12 Mar 2024 17:10:50 +0100 Message-Id: <20240312161050.2248814-21-imammedo@redhat.com> In-Reply-To: <20240312161050.2248814-1-imammedo@redhat.com> References: <20240312161050.2248814-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1710260025439100003 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