[PATCH 3/5] smbios: Use SMBIOS 3.0 to support an address above 4GB
Simon Glass
sjg at chromium.org
Thu Oct 12 05:45:24 CEST 2023
Hi Heinrich,
On Sun, 8 Oct 2023 at 19:48, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 10/8/23 23:36, 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.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > include/smbios.h | 22 +++++++++++++++++++++-
> > lib/smbios.c | 22 ++++++++++++++++++----
> > 2 files changed, 39 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/smbios.h b/include/smbios.h
> > index c9df2706f5a6..ddabb558299e 100644
> > --- a/include/smbios.h
> > +++ b/include/smbios.h
> > @@ -12,7 +12,8 @@
> >
> > /* SMBIOS spec version implemented */
> > #define SMBIOS_MAJOR_VER 3
> > -#define SMBIOS_MINOR_VER 0
> > +#define SMBIOS_MINOR_VER 7
> > +
> >
> > enum {
> > SMBIOS_STR_MAX = 64, /* Maximum length allowed for a string */
> > @@ -54,6 +55,25 @@ struct __packed smbios_entry {
> > u8 bcd_rev;
> > };
> >
> > +struct __packed smbios3_entry {
> > + u8 anchor[5];
> > + u8 checksum;
> > + u8 length;
> > + u8 major_ver;
> > +
> > + u8 minor_ver;
> > + u8 docrev;
> > + u8 entry_point_rev;
> > + u8 reserved;
> > + u32 max_struct_size;
> > +
> > + u64 struct_table_address;
> > +};
> > +
> > +/* These two structures should use the same amount of 16-byte-aligned space */
> > +static_assert(ALIGN(16, sizeof(struct smbios_entry)) ==
> > + 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 c7a557bc9b7b..82e259f31791 100644
> > --- a/lib/smbios.c
> > +++ b/lib/smbios.c
> > @@ -487,7 +487,11 @@ ulong write_smbios_table(ulong addr)
> > addr = ALIGN(addr, 16);
> > start_addr = addr;
> >
> > - addr += 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 += max(sizeof(struct smbios_entry), sizeof(struct smbios3_entry));
> > addr = ALIGN(addr, 16);
> > tables = addr;
> >
> > @@ -513,13 +517,23 @@ ulong write_smbios_table(ulong addr)
> > */
> > table_addr = (ulong)map_sysmem(tables, 0);
> > if (sizeof(table_addr) > sizeof(u32) && table_addr > (ulong)UINT_MAX) {
>
> You have to check the end address of the table not the start address here.
>
> The SMBIOS specification says that you should always supply a 32bit
> SMBIOS entry point. Of course this is not possible on boards that don't
> have low memory.
>
> In install_smbios_table() this can be achieved by calling
> efi_allocate_pages() with EFI_MAX_ALLOCATE_TYPE and a maximum address of
> 4 GiB - 1. Only if this fails use high memory.
Hmm perhaps we need a way to allocate memory below 4GB in U-Boot? How
does this EFI function work?
I don't think EFI has been set up by the time this function is called.
Regards,
Simon
More information about the U-Boot
mailing list