[PATCH 1/1] x86: all firmware tables must be paragraph aligned

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Tue Jan 2 00:05:34 CET 2024


On 1/1/24 23:41, Simon Glass wrote:
> On Mon, Jan 1, 2024 at 4:52 AM Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
>>
>> On qemu-x86_64_defconfig the following was observed:
>>
>>      => efidebug tables
>>      00000000000f0074  eb9d2d31-2d88-11d3-9a16-0090273fc14d  SMBIOS table
>>
>> The SMBIOS configuration table does not point to a paragraph aligned
>> address. The reason is that in write_tables() rom_addr is not aligned and
>> copied to gd->arch.smbios_start.
>>
>> The Simple Firmware Interface requires that the SFI table is paragraph
>> aligned but our code does not guarantee this.
>>
>> As all tables written in write_tables() must be paragraph aligned, we
> 
> paragraph-aligned
> 
> But was is a paragraph? Is that an x86 term?

The term paragraph is used by the SMBIOS spec.

The reason why non-UEFI x86 requires low addresses (< 1MiB) for tables 
is that booting starts in real-mode.

Any memory address evenly divisible by 16 is called a paragraph 
boundary. [1]

[1] Memory Paragraphs in Real Mode
     http://www.c-jump.com/CIS77/ASM/Memory/M77_0080_paragraphs.htm

A segment begins on a paragraph boundary, which is an address divisible 
by decimal 16 or hex 10. [2]

[2] Programming with 8086 microprocessor
     https://www.uobabylon.edu.iq/eprints/publication_1_2613_35.pdf

Best regards

Heinrich

> 
>> should implement the address rounding in write_tables() and not in table
>> specific routines like copy_pirq_routing_table().
>>
>> Add paragraph alignment in write_tables().
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>> ---
>>   arch/x86/lib/tables.c | 2 ++
>>   1 file changed, 2 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>
> 
> 
>>
>> diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
>> index 5b5070f7ca..89d4d30a6a 100644
>> --- a/arch/x86/lib/tables.c
>> +++ b/arch/x86/lib/tables.c
>> @@ -97,6 +97,8 @@ int write_tables(void)
>>                  int size = table->size ? : CONFIG_ROM_TABLE_SIZE;
>>                  u32 rom_table_end;
>>
>> +               rom_addr = ALIGN(rom_addr, 16);
>> +
>>                  if (!strcmp("smbios", table->name))
>>                          gd->arch.smbios_start = rom_addr;
>>
>> --
>> 2.43.0
>>



More information about the U-Boot mailing list