Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5351C4706F for ; Mon, 1 Jan 2024 17:34:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34D8687073; Mon, 1 Jan 2024 18:34:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=xypron.glpk@gmx.de header.b="CmRjWNyA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 26495877EC; Mon, 1 Jan 2024 18:34:21 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DEB1386FF7 for ; Mon, 1 Jan 2024 18:34:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1704130457; x=1704735257; i=xypron.glpk@gmx.de; bh=/Ozctm96UxEQDZtJsVbnp5SU8CbGB3IdNp3PeDOcf6E=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=CmRjWNyAobTrwIP5an5CErw/Yu+oITXfA13aCQJ+Yec/hgpb307pVyCCWhqGqBkg eWWAYTLRLcwfntmE/W5ODL7oAVus223vscXweaHDzM/6u1chAfX8B+S3g4Ga9+uSR Z7U8SPZqxFxw6xkras06vo/pbqa3sa3UMY8w8t+ZjgadEP+KssolwoN/eLzUDpKfF igDG4grfs41e4XKzMtsn17vFs6g6dkuci+9CE6FLYWbWHrW3anL9YQujOLfCS52Le jUD6bTA0TjVCIsP7nZ0AZdrjYL/3dYHJRj2JUvw8RbQgI15y98leokcYLf+e8j5kr BJGTOHdkahWm/gAmXg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.123.94] ([178.202.40.247]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTiTt-1roEL61Uvl-00U4r4; Mon, 01 Jan 2024 18:34:17 +0100 Message-ID: <3ea1e2b4-8a52-4e20-beb8-6520f7df0139@gmx.de> Date: Mon, 1 Jan 2024 18:34:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 04/12] smbios: Use SMBIOS 3.0 to support an address above 4GB To: Simon Glass Cc: Ilias Apalodimas , Peter Robinson , U-Boot Mailing List References: <20231231152555.464874-1-sjg@chromium.org> <20231231152555.464874-5-sjg@chromium.org> Content-Language: en-US, de-DE From: Heinrich Schuchardt In-Reply-To: <20231231152555.464874-5-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:33sTEcIQH0BagRWYBTD4eT76Pk1yUHoVBCKwaWoiIfXYjeIWbqq jZ0KW9eUK+sC7mhKJVu+GZv+a77mvEDN/vPZBPBFh6/rm7HsFhW7GO0eQicxP+I2g1IQYgI mS3B3IWXikdM9ypJ87nbhlTildUvmjX1NVuh4ESHCgWkr6YCJ90SVjarTlQS2W2+Zlf6pFl pVSNyB8r/G8co4zRcFtDA== UI-OutboundReport: notjunk:1;M01:P0:PY+Mup87cwc=;oBC8qrQZhEdIs9mtdwi974cr3XU WW1bQ/gjFrbyo+1NMQrHSwuEPvPTL2HVEVWCna8jDLGFFD4ItiEACQ9rg/dU3DhIP6E6f8LsT 4ouIxwvHV1ULqLW301CvsWmkZwJXiPZFscsI4Cle+feWQq2DlXfWXHDyWBJc1Mh+GfZGb69tT aA7MIgIW056n/9CM9Qmveos3lJRqkMYiTAI6Z+hiNB48ncOzK2Yj83V3c/qwW8nT5OpDZ2b7C wAqsjYSmh2b4o2bCrNKZCixFQTpzGYc5sWc2ErD9syOcLEcPLFqmDFgWcmKOt70299/Q4ILxz mg54NruwhnpRJgTaDRr+wjmVnf27kRfFLM9hcPqjj4jlGe/wo8CeOVcXE9u2Yy77ZXCMlPzWQ SwxtKVJcK5FzhsVnOFfIWHYXUw3ZIrokdR0Nfa8MO4VEK1UjtlkCsNL3lOfGsRUz9vzgFHTVk 5KCrEV5rQhaLPTnXB+vmkjA/+ECllXchbJ43sSVr3sJnGWRQLzLqKzqXimY9JXNwyEnWnpCuq lrQtWq0+M0W7H5uZog5O1MY2Hu1nso6o9Y9MNaPkcdZLibEZGl6zH2auhyFUkx7KJae6Qz4NM 0Y9HEvllNXT23w6Znq3AfFZkRQYuTOfuRZhgTQw103rqrmxNw7/U6tbqmQfM4N+1cjq7j9MAY wQBRVUfG30LC48XmbSQ1Ch06YaasHDDKRpPAy05IeyLg9xeKRWLnHWVmNdTsYWV4w7MEPq9Sw wz0R6rMq6f/ShEi0hSdreiKQ4gK0tIFfhCuT30SVNPWaeKrI0bYuHiOA/qMOyyiWTcirp7bcX dVf4L6Pobk8ksz5kdSlyA4iXBaik0HuJ+KllmeFUw7dCWmbuaRJlorzv0o0sPDIsX68f5ONJ7 KAIXNKhAp9DwF3Z5Rc+oK5z7D7ddRA10I0/wvpmUn3eZI9sA9IbgK5y6G1lH9679Ks7L8l/GR VbZiqQ== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 12/31/23 16:25, Simon Glass wrote: > When the SMBIOS table is written to an address above 4GB a 32-bit table > address is not large enough. > > Use an SMBIOS3 table in that case. > > Note that we cannot use efi_allocate_pages() since this function has > nothing to do with EFI. There is no equivalent function to allocate > memory below 4GB in U-Boot. One solution would be to create a separate > malloc() pool, or just always put the malloc() pool below 4GB. > > - Use log_debug() for warning > - Rebase on Heinrich's smbios.h patch > - Set the checksum for SMBIOS3 > > Signed-off-by: Simon Glass > --- > > (no changes since v4) > > Changes in v4: > - Check the start of the table rather than the end > > Changes in v2: > - Check the end of the table rather than the start. > > include/smbios.h | 6 +++++- > lib/smbios.c | 30 +++++++++++++++++++++++++----- > 2 files changed, 30 insertions(+), 6 deletions(-) > > diff --git a/include/smbios.h b/include/smbios.h > index e601283d293..77be58887a2 100644 > --- a/include/smbios.h > +++ b/include/smbios.h > @@ -12,7 +12,7 @@ > > /* SMBIOS spec version implemented */ > #define SMBIOS_MAJOR_VER 3 > -#define SMBIOS_MINOR_VER 0 > +#define SMBIOS_MINOR_VER 7 > > enum { > SMBIOS_STR_MAX =3D 64, /* Maximum length allowed for a string */ > @@ -80,6 +80,10 @@ struct __packed smbios3_entry { > u64 struct_table_address; > }; > > +/* These two structures should use the same amount of 16-byte-aligned s= pace */ I cannot see from where you take such a requirement. By chance it is fulfilled by the current definitions. If this a leftover from debugging we should remove it. Best regards Heinrich > +static_assert(ALIGN(16, sizeof(struct smbios_entry)) =3D=3D > + ALIGN(16, sizeof(struct smbios3_entry))); > + > /* BIOS characteristics */ > #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7) > #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11) > diff --git a/lib/smbios.c b/lib/smbios.c > index eea72670bd9..7f79d969c92 100644 > --- a/lib/smbios.c > +++ b/lib/smbios.c > @@ -567,7 +567,11 @@ ulong write_smbios_table(ulong addr) > addr =3D ALIGN(addr, 16); > start_addr =3D addr; > > - addr +=3D sizeof(struct smbios_entry); > + /* > + * So far we don't know which struct will be used, but they both end > + * up using the same amount of 16-bit-aligned space > + */ > + addr +=3D max(sizeof(struct smbios_entry), sizeof(struct smbios3_entry= )); > addr =3D ALIGN(addr, 16); > tables =3D addr; > > @@ -590,16 +594,32 @@ ulong write_smbios_table(ulong addr) > * We must use a pointer here so things work correctly on sandbox. Th= e > * user of this table is not aware of the mapping of addresses to > * sandbox's DRAM buffer. > + * > + * Check the address of the end of the tables. If it is above 4GB then > + * it is sensible to use SMBIOS3 even if the start of the table is bel= ow > + * 4GB (this case is very unlikely to happen in practice) > */ > table_addr =3D (ulong)map_sysmem(tables, 0); > - if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) = { > + if (sizeof(table_addr) > sizeof(u32) && addr >=3D (ulong)UINT_MAX) { > + struct smbios3_entry *se; > /* > * We need to put this >32-bit pointer into the table but the > * field is only 32 bits wide. > */ > - printf("WARNING: SMBIOS table_address overflow %llx\n", > - (unsigned long long)table_addr); > - addr =3D 0; > + log_debug("WARNING: Using SMBIOS3.0 due to table-address overflow %lx= \n", > + table_addr); > + se =3D map_sysmem(start_addr, sizeof(struct smbios_entry)); > + memset(se, '\0', sizeof(struct smbios_entry)); > + memcpy(se->anchor, "_SM3_", 5); > + se->length =3D sizeof(struct smbios3_entry); > + se->major_ver =3D SMBIOS_MAJOR_VER; > + se->minor_ver =3D SMBIOS_MINOR_VER; > + se->doc_rev =3D 0; > + se->entry_point_rev =3D 1; > + se->max_struct_size =3D len; > + se->struct_table_address =3D table_addr; > + se->checksum =3D table_compute_checksum(se, > + sizeof(struct smbios3_entry)); > } else { > struct smbios_entry *se; >