From nobody Mon May 20 19:42:21 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 ARC-Seal: i=1; a=rsa-sha256; t=1645113457; cv=none; d=zohomail.com; s=zohoarc; b=LhAd3UFMEK9M66/8rK+65CAT+cmcXyov9LPu5hc3xy2FTzpcN7Fv7ZhCCxrl3KINpLQtkCEQ6zY0+CO2XJ8+u1iW9/a7W+KhebpfTgARuJArviDlzbBeQcuxr8tA+RWOi+DNKWcFd57taxlTxDNRI0yhIQW5JzbfmT9JqLPF5bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645113457; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bHSDtq9nX65sHhUSEmWXPKE+bo44P0ZIROyPp3M0lPU=; b=QbD+kbGc57T0EGOVumr3XEeR/CXonn/MmBJMSnulyiUxNN8Gg7chpa/jklEaBvsjdL6MOoyAp6b6HnjCZdy+wSnPL1enHd3hsVvy8NE/CQyjTIFgu/Yp7Zuz9VfMGI1jbQ+uVLWOcJhCPx68OY1VrtJFq9dBNr1kvRVOfFK9q9E= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645113457752302.5073261270775; Thu, 17 Feb 2022 07:57:37 -0800 (PST) Received: from localhost ([::1]:53876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKjA0-00006X-9E for importer@patchew.org; Thu, 17 Feb 2022 10:57:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKiUO-0008Nw-Gd for qemu-devel@nongnu.org; Thu, 17 Feb 2022 10:14:36 -0500 Received: from [2607:f8b0:4864:20::102a] (port=51983 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nKiUM-0007cg-JA for qemu-devel@nongnu.org; Thu, 17 Feb 2022 10:14:36 -0500 Received: by mail-pj1-x102a.google.com with SMTP id y9so5877159pjf.1 for ; Thu, 17 Feb 2022 07:14:34 -0800 (PST) Received: from anisinha-lenovo.ba.nuagenetworks.net ([203.163.242.253]) by smtp.googlemail.com with ESMTPSA id z9sm8456884pgz.32.2022.02.17.07.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bHSDtq9nX65sHhUSEmWXPKE+bo44P0ZIROyPp3M0lPU=; b=nFpXzO3vP4ajhzV2ZleSfcF/EEOyxwRq6cA6zyfDQelXrPwHdmfwf4ubY9BCPhxtZz Ntkh5zD+3GhMpyWTSJdglPsCKH/wAM6SmbJXuHvICg8wJO7mZ9N1uDg5QysSwhYXytC1 pOZHyuVikwu4DuAZCRqWBqeLcsE2lRpsGHO2NEnL4GyoAbNkQgbX0rvPH2hFRrTjDPPi l7rOCl62JWn61ibkzNTeiCuLEwWGYey5PXpcwpRZ2wNYBLe2/i4wmF5/PUtXzirewRm7 cGXqlrm/eTPsWH2EYgF7JqQGDBIevAqoeteNnuCWbj4X3nEzBXbcc3LsRz5B3sD5+Nj4 j7hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bHSDtq9nX65sHhUSEmWXPKE+bo44P0ZIROyPp3M0lPU=; b=d0LqQaV1vf/Nmu7URBOUMF6pjJtGMecfaUkmxNp94+RioqijRto2WDEcUclJT0AHp6 PUU/9qfIKHaF9tnT+SrJiPSojs/vpzxwq9SGmy+d0BYWA6/9jFCAqdUsm/l42Zh3SJiw OsqkJtzpUHSnHPHJfEm/eM3I6zJa3IpYEAXyWxE6ZWpIsyyNTmMD9vmZuBaggqgjK1Dn bbD06ZRiicg9tsj+yri4BCiHmb1qLcf3bkyO+aOIjB6gGxf/LzSYre2dN1ajz8vPZ3/A hetfNj53g/7m9wIeD6vSfcRd+XuRSXD5PMM1LG7RIi1MQYgezWV+9ciNxFUhpq1SmuKK BT0g== X-Gm-Message-State: AOAM532AcQRcx+2Ua8n5vxjD+tAYtzW/CZ3oHQKLdjSmVJGErfrzZEt4 G6Rb6AEkLsMq+Ys4vTXMhsSUOM2T5AFkTQ== X-Google-Smtp-Source: ABdhPJxLoiamXGllwlJN/XDxNBkcTQiuihO+LKGwpXnIz1nzubTiz1tYfs5zCjDFYqtAbpYm8cFT6A== X-Received: by 2002:a17:90b:368c:b0:1b8:57c5:3fde with SMTP id mj12-20020a17090b368c00b001b857c53fdemr3514554pjb.244.1645110872706; Thu, 17 Feb 2022 07:14:32 -0800 (PST) From: Ani Sinha To: qemu-devel@nongnu.org, "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha Subject: [PATCH v4 1/3] hw/smbios: code cleanup - use macro definitions for table header handles Date: Thu, 17 Feb 2022 20:44:08 +0530 Message-Id: <20220217151410.300210-2-ani@anisinha.ca> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217151410.300210-1-ani@anisinha.ca> References: <20220217151410.300210-1-ani@anisinha.ca> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102a (failed) 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: none client-ip=2607:f8b0:4864:20::102a; envelope-from=ani@anisinha.ca; helo=mail-pj1-x102a.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZohoMail-DKIM: pass (identity @anisinha-ca.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1645113459261100001 Content-Type: text/plain; charset="utf-8" This is a minor cleanup. Using macro definitions makes the code more readable. It is at once clear which tables use which handle numbers in their header. It also makes it easy to calculate the gaps between the numbers and update them if needed. Reviewed-by: Igor Mammedov Signed-off-by: Ani Sinha --- hw/smbios/smbios.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 6013df1698..56b412ce35 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -549,9 +549,23 @@ bool smbios_skip_table(uint8_t type, bool required_tab= le) return true; } =20 +#define T0_BASE 0x000 +#define T1_BASE 0x100 +#define T2_BASE 0x200 +#define T3_BASE 0x300 +#define T4_BASE 0x400 +#define T11_BASE 0xe00 + +#define T16_BASE 0x1000 +#define T17_BASE 0x1100 +#define T19_BASE 0x1300 +#define T32_BASE 0x2000 +#define T41_BASE 0x2900 +#define T127_BASE 0x7F00 + static void smbios_build_type_0_table(void) { - SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS= */ + 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); @@ -599,7 +613,7 @@ static void smbios_encode_uuid(struct smbios_uuid *uuid= , QemuUUID *in) =20 static void smbios_build_type_1_table(void) { - SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */ + 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); @@ -619,7 +633,7 @@ static void smbios_build_type_1_table(void) =20 static void smbios_build_type_2_table(void) { - SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */ + SMBIOS_BUILD_TABLE_PRE(2, T2_BASE, false); /* optional */ =20 SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer); SMBIOS_TABLE_SET_STR(2, product_str, type2.product); @@ -637,7 +651,7 @@ static void smbios_build_type_2_table(void) =20 static void smbios_build_type_3_table(void) { - SMBIOS_BUILD_TABLE_PRE(3, 0x300, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(3, T3_BASE, true); /* required */ =20 SMBIOS_TABLE_SET_STR(3, manufacturer_str, type3.manufacturer); t->type =3D 0x01; /* Other */ @@ -662,7 +676,7 @@ static void smbios_build_type_4_table(MachineState *ms,= unsigned instance) { char sock_str[128]; =20 - SMBIOS_BUILD_TABLE_PRE(4, 0x400 + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(4, T4_BASE + instance, true); /* required */ =20 snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance= ); SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str); @@ -702,7 +716,7 @@ static void smbios_build_type_11_table(void) return; } =20 - SMBIOS_BUILD_TABLE_PRE(11, 0xe00, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(11, T11_BASE, true); /* required */ =20 snprintf(count_str, sizeof(count_str), "%zu", type11.nvalues); t->count =3D type11.nvalues; @@ -722,7 +736,7 @@ static void smbios_build_type_16_table(unsigned dimm_cn= t) { uint64_t size_kb; =20 - SMBIOS_BUILD_TABLE_PRE(16, 0x1000, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(16, T16_BASE, true); /* required */ =20 t->location =3D 0x01; /* Other */ t->use =3D 0x03; /* System memory */ @@ -749,7 +763,7 @@ static void smbios_build_type_17_table(unsigned instanc= e, uint64_t size) char loc_str[128]; uint64_t size_mb; =20 - SMBIOS_BUILD_TABLE_PRE(17, 0x1100 + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(17, T17_BASE + instance, true); /* required */ =20 t->physical_memory_array_handle =3D cpu_to_le16(0x1000); /* Type 16 ab= ove */ t->memory_error_information_handle =3D cpu_to_le16(0xFFFE); /* Not pro= vided */ @@ -790,7 +804,7 @@ static void smbios_build_type_19_table(unsigned instanc= e, { uint64_t end, start_kb, end_kb; =20 - SMBIOS_BUILD_TABLE_PRE(19, 0x1300 + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + instance, true); /* required */ =20 end =3D start + size - 1; assert(end > start); @@ -814,7 +828,7 @@ static void smbios_build_type_19_table(unsigned instanc= e, =20 static void smbios_build_type_32_table(void) { - SMBIOS_BUILD_TABLE_PRE(32, 0x2000, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(32, T32_BASE, true); /* required */ =20 memset(t->reserved, 0, 6); t->boot_status =3D 0; /* No errors detected */ @@ -828,7 +842,7 @@ static void smbios_build_type_41_table(Error **errp) struct type41_instance *t41; =20 QTAILQ_FOREACH(t41, &type41, next) { - SMBIOS_BUILD_TABLE_PRE(41, 0x2900 + instance, true); + SMBIOS_BUILD_TABLE_PRE(41, T41_BASE + instance, true); =20 SMBIOS_TABLE_SET_STR(41, reference_designation_str, t41->designati= on); t->device_type =3D t41->kind; @@ -871,7 +885,7 @@ static void smbios_build_type_41_table(Error **errp) =20 static void smbios_build_type_127_table(void) { - SMBIOS_BUILD_TABLE_PRE(127, 0x7F00, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(127, T127_BASE, true); /* required */ SMBIOS_BUILD_TABLE_POST; } =20 --=20 2.25.1 From nobody Mon May 20 19:42:21 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 ARC-Seal: i=1; a=rsa-sha256; t=1645112178; cv=none; d=zohomail.com; s=zohoarc; b=JSUhfWhKqGFW27Ul9MqvZTbfj0nKnoJKHSrePURnd5iKCmJexoYG7WM75SMnBK4+nffspnJWmFqYtp4z39NXn2xehVgJgYK34xvCM0eJ7Ax2G8JY3b/4cqatvMhRRyD5vOZRSTQ9AKlzdZN/3pFRKnK16ZIe+SD/oTDzPuRJUVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645112178; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rjh7+VUyyC1W9oWLXjXeD2Pl8AMEHbHBcf/pXVbnb1c=; b=lfTwwDjf3zgbdOIio0e03vEcSpY7vkqlXMR8egwWUQdav2tG70F8XZ17xPBYX+/POZx03L5EQJimA0LTXRu7fPMQY8H1zurm3j5YOG5Nb0/xKU7/o8tGVUePW/GH66tmo5fNvwIPNbgIW75yt+tRq9XbU0iOrQ3+i5jIRyuQfWY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645112177960999.3136606835836; Thu, 17 Feb 2022 07:36:17 -0800 (PST) Received: from localhost ([::1]:40548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKipM-0005Q6-1P for importer@patchew.org; Thu, 17 Feb 2022 10:36:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKiUS-00009Z-AU for qemu-devel@nongnu.org; Thu, 17 Feb 2022 10:14:40 -0500 Received: from [2607:f8b0:4864:20::431] (port=36665 helo=mail-pf1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nKiUQ-0007cs-Kb for qemu-devel@nongnu.org; Thu, 17 Feb 2022 10:14:40 -0500 Received: by mail-pf1-x431.google.com with SMTP id z16so5231768pfh.3 for ; Thu, 17 Feb 2022 07:14:37 -0800 (PST) Received: from anisinha-lenovo.ba.nuagenetworks.net ([203.163.242.253]) by smtp.googlemail.com with ESMTPSA id z9sm8456884pgz.32.2022.02.17.07.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:14:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=rjh7+VUyyC1W9oWLXjXeD2Pl8AMEHbHBcf/pXVbnb1c=; b=LzQLT1q2rlUIjbmDRKJBGhYLGvcGgJ/6WARToUeSwQspE0ImWwEV0tPOo7jvgMFJb/ yktf8z210aStik1uK22oYgTC0TeIfgVpRsBACP6DhIlQiAaG44MwCkVSRkC5zIUyIdmX /fT4ucWh9MaJ3ILxXFRSufyd+7MZXH1GqFQA5laaSeZnc91fvlINnaYY4ZhqebUL+QEf JPTHek7jVLgp8Hfy8VgTAaSXR3OMbXFWsYR7XRAC88swjrRoJpy8mBzGI5nTZoNgPJRK oxq2VOtXoQwhr1IWM2jUfyVUDGh79ZNPicKRgZPMJW3AQtdgVuh/9BrvIVGMvqjkjhY+ wxGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rjh7+VUyyC1W9oWLXjXeD2Pl8AMEHbHBcf/pXVbnb1c=; b=vs/8tgzuCNuFBc8cOiZhmRPbFFP/rowF3gFQaX8X9hMF0ES70gLjLtgI6DUd5YZhCI BP3qAshu/EXhezEv8lkS0Q50W/qcH75b5zSKBxX/veI79eNj6GLKAF3p3PHMn2HR6uRp GpKgQY9X4syMHG2M9yHG3FswA9HEhzSUx3yT9VYAy7XXNP1TJWaqr6SWJEKbDrPvVPam Z7xDIsRDdT78TX405XmHF/9WIn9tKlEFIawBc/UblGM5rATDroWfzm7rsMOliID+qy4g nBRF7nuhloXXEK9jmMkdIXRayeBDzqCKYAqHzu40oGZ8S0zlMHYBwy2lw/EtIQq4lvmI jM8w== X-Gm-Message-State: AOAM531E9QgQFz0kpVor8gCralcgPabNyKPXNyS1IOj8cM4ikAM+PRbS Ejp+xBE2QZVG5+RHDTjUQfFu2IiMEXv1zg== X-Google-Smtp-Source: ABdhPJzdSg6QhQZycerTATXNNk+nx3o57ot0f75RyY387Yf1Vy4M7NE+2sLgN5n5CiodET874EgKBg== X-Received: by 2002:a63:6b8a:0:b0:373:1037:1c65 with SMTP id g132-20020a636b8a000000b0037310371c65mr2750188pgc.7.1645110875954; Thu, 17 Feb 2022 07:14:35 -0800 (PST) From: Ani Sinha To: qemu-devel@nongnu.org, "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha Subject: [PATCH v4 2/3] hw/smbios: fix overlapping table handle numbers with large memory vms Date: Thu, 17 Feb 2022 20:44:09 +0530 Message-Id: <20220217151410.300210-3-ani@anisinha.ca> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217151410.300210-1-ani@anisinha.ca> References: <20220217151410.300210-1-ani@anisinha.ca> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::431 (failed) 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: none client-ip=2607:f8b0:4864:20::431; envelope-from=ani@anisinha.ca; helo=mail-pf1-x431.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZohoMail-DKIM: pass (identity @anisinha-ca.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1645112180614100001 Content-Type: text/plain; charset="utf-8" The current smbios table implementation splits the main memory in 16 GiB (DIMM like) chunks. With the current smbios table assignment code, we can h= ave only 512 such chunks before the 16 bit handle numbers in the header for tab= les 17 and 19 conflict. A guest with more than 8 TiB of memory will hit this limitation and would fail with the following assertion in isa-debugcon: ASSERT_EFI_ERROR (Status =3D Already started) ASSERT /builddir/build/BUILD/edk2-ca407c7246bf/OvmfPkg/SmbiosPlatformDxe/Sm= biosPlatformDxe.c(125): !EFI_ERROR (Status) This change adds an additional offset between tables 17 and 19 handle numbe= rs when configuring VMs larger than 8 TiB of memory. The value of the offset is calculated to be equal to the additional space required to be reserved in order to accomodate more DIMM entries without the table handles collidin= g. In normal cases where the VM memory is smaller or equal to 8 TiB, this offs= et value is 0. Hence in this case, no additional handle numbers are reserved a= nd table handle values remain as before. Since smbios memory is not transmitted over the wire during migration, this change can break migration for large memory vms if the guest is in the middle of generating the tables during migration. However, in those situations, qemu generates invalid table handles anyway with or without this fix. Hence, we do not preserve the old bug by introducing compat knobs/mach= ine types. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2023977 Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov --- hw/smbios/smbios.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) changelog: v4: addressed Igor's suggestions on v3 with the commit log. v3: reworded the commit log and comment in code. diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 56b412ce35..44c53797a4 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -799,12 +799,13 @@ static void smbios_build_type_17_table(unsigned insta= nce, uint64_t size) SMBIOS_BUILD_TABLE_POST; } =20 -static void smbios_build_type_19_table(unsigned instance, +static void smbios_build_type_19_table(unsigned instance, unsigned offset, uint64_t start, uint64_t size) { uint64_t end, start_kb, end_kb; =20 - SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + offset + instance, + true); /* required */ =20 end =3D start + size - 1; assert(end > start); @@ -996,7 +997,7 @@ void smbios_get_tables(MachineState *ms, uint8_t **anchor, size_t *anchor_len, Error **errp) { - unsigned i, dimm_cnt; + unsigned i, dimm_cnt, offset; =20 if (smbios_legacy) { *tables =3D *anchor =3D NULL; @@ -1026,6 +1027,16 @@ void smbios_get_tables(MachineState *ms, =20 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= een + * 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; + smbios_build_type_16_table(dimm_cnt); =20 for (i =3D 0; i < dimm_cnt; i++) { @@ -1033,7 +1044,7 @@ void smbios_get_tables(MachineState *ms, } =20 for (i =3D 0; i < mem_array_size; i++) { - smbios_build_type_19_table(i, mem_array[i].address, + smbios_build_type_19_table(i, offset, mem_array[i].address, mem_array[i].length); } =20 --=20 2.25.1 From nobody Mon May 20 19:42:21 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 ARC-Seal: i=1; a=rsa-sha256; t=1645112416; cv=none; d=zohomail.com; s=zohoarc; b=TKfRXEBEKGXyiNcEfFyf5cBMxbUCLeBtQ2huKX0ULga/N7O1NXDeGNkIIiqZ1UpY6nMR6GVmXjYTC+0m+vD5Re1hqWJCrx1HiwyxiX3lU1Qd2rD3xOKhJeMFqhOPfQxUif9qVOuABP4Lgb40duPXe01rw0q3lSvgPIqsE0wrNtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645112416; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QjYn/nDcS9vSkBLMNCNGY4sLg2O1EWN+YW+PnfRwmZE=; b=oEdVCDMrV9k1ybE/j2nmoXR7VjgYjUo4kQ65ThGeOT2cvIFc28WoquJGNe0LoV/LBU2AjbGj9rm4rsrip4SDAkUou/pe8pYBb01RjeE8YJyvgDF/bLlTH1U/ifEfL1e+aj3kwzBbTALKlZuA3j/lBAQCnCfkst2voQNoQu5GjrU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1645112416311158.52456572855465; Thu, 17 Feb 2022 07:40:16 -0800 (PST) Received: from localhost ([::1]:47956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nKitE-000273-IC for importer@patchew.org; Thu, 17 Feb 2022 10:40:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nKiUT-0000AR-Tt for qemu-devel@nongnu.org; Thu, 17 Feb 2022 10:14:44 -0500 Received: from [2607:f8b0:4864:20::536] (port=39735 helo=mail-pg1-x536.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nKiUS-0007cx-Is for qemu-devel@nongnu.org; Thu, 17 Feb 2022 10:14:41 -0500 Received: by mail-pg1-x536.google.com with SMTP id 195so5286436pgc.6 for ; Thu, 17 Feb 2022 07:14:40 -0800 (PST) Received: from anisinha-lenovo.ba.nuagenetworks.net ([203.163.242.253]) by smtp.googlemail.com with ESMTPSA id z9sm8456884pgz.32.2022.02.17.07.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QjYn/nDcS9vSkBLMNCNGY4sLg2O1EWN+YW+PnfRwmZE=; b=G6qfXj7G21WnhiyNsyWUXjhnJnmDuxgiFVDVZROknMAesK/KyvheZ+k9oAlfNcYZvi /trsR+UY8v5/5W3NHcL8Tgkiq26J7Tlbug4BRn51+ArMHA9tB4I57s3yAQs/0j/39k4j +9nzFrVQftlTIIuyvvDrkm0Fo6J1cUEvUhfYquuHS7cEg780ez66JRPqw5mSyJAC06Lu EjDvW4MOdZgoXIsjNFG4yCD5OBQUuS8+h8lPRLqnjc+KaS4o0WJAZzZ1uau0ikfPMmc1 Cw/KQwe1RQ1raqmfb26TUUGu4D599ZyaDBkdWmWDa275KVb2mPLkIn737v65ga9mBLUq V+Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QjYn/nDcS9vSkBLMNCNGY4sLg2O1EWN+YW+PnfRwmZE=; b=JZ+7WLIoiPf4yjekQp7FhC0+tqEkHV4dpY7aEi+YUnP+NTOk9R1ALWEMYlQoViiPCV IRP2b6OoipW5p475EUxjUqX1xjvW23jaeTC+BLTrpWictMVQ3bW1EhpiZHQ+no33hUfs rVMaD28NpnMdp8uMgSqnj2BAUfmU/xSUTmVhY1gcDYSFTyypNpHw0mHUO94tDLX1R7Ie qOuUpVxxRwUeRZ1bonChpklnZfM5lzAhDjk52nNRhGwvtwe8TTBVaL3PJ5q8AJ3wtP47 tSdrUxzhikyCsx1w4VkrXnUdSEMiUrwWpHTbTOOrPVqq7qzx03xbG9hZAk9r+c9Ehr/p rwAA== X-Gm-Message-State: AOAM530IGKXZrWNwfkZRJ1d0NpSZZvv1JQ8TXmRG4rQJoRnWr+bikbib ruqp+zb8X87tMfrAgaeTGERqPZqHzGQzJQ== X-Google-Smtp-Source: ABdhPJwJfuJsza9bOLk1az7yAjn26Odscx3WOcJ7M3kUVM2LUvyDKoP2wZCFSw/acJxZPsolG5qEHA== X-Received: by 2002:a05:6a00:1249:b0:4e1:5aa4:9ac6 with SMTP id u9-20020a056a00124900b004e15aa49ac6mr3334326pfi.72.1645110879093; Thu, 17 Feb 2022 07:14:39 -0800 (PST) From: Ani Sinha To: qemu-devel@nongnu.org, "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha Subject: [PATCH v4 3/3] hw/smbios: add assertion to ensure handles of tables 19 and 32 do not collide Date: Thu, 17 Feb 2022 20:44:10 +0530 Message-Id: <20220217151410.300210-4-ani@anisinha.ca> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217151410.300210-1-ani@anisinha.ca> References: <20220217151410.300210-1-ani@anisinha.ca> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::536 (failed) 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: none client-ip=2607:f8b0:4864:20::536; envelope-from=ani@anisinha.ca; helo=mail-pg1-x536.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" X-ZohoMail-DKIM: pass (identity @anisinha-ca.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1645112445135100001 Content-Type: text/plain; charset="utf-8" Since change dcf359832eec02 ("hw/smbios: fix table memory corruption with l= arge memory vms") we reserve additional space between handle numbers of tables 17 and 19 for large VMs. This may cause table 19 to collide with table 32 in their handle numbers for those large VMs. This change adds an assertion to ensure numbers do not collide. If they do, qemu crashes with useful debug information for taking additional steps. Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov --- hw/smbios/smbios.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 44c53797a4..1f8d5c252f 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1048,6 +1048,12 @@ void smbios_get_tables(MachineState *ms, 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)); + smbios_build_type_32_table(); smbios_build_type_38_table(); smbios_build_type_41_table(errp); --=20 2.25.1