EFI: Fix relocating ESRT for dom0
PATCH 1/1 EFI: Fix relocating ESRT for dom0
Fix calculating the table size - it consists of a header + entries, not just entries.
This bug caused the last entry to have garbage in its final fields, including LowestSupportedFwVersion and CapsuleFlags, which (usually) made fwupd to detect firmware update availability, but refuse actually installing it.
--- xen/common/efi/boot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/efi/boot.c +2 -1
@@ -675,7 +675,8 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)if ( esrt_ptr->FwResourceCount > available_len /sizeof (esrt_ptr->Entries[0 ]) )return 0 ; -return esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]); +return offsetof(EFI_SYSTEM_RESOURCE_TABLE , Entries) + + esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]); }static EFI_GUID __initdata esrt_guid =EFI_SYSTEM_RESOURCE_TABLE_GUID ;
Signature · 1 line
2.51.0
Quoted 5 lines · Marek Marczykowski-Górecki
Fix calculating the table size - it consists of a header + entries, not just entries.
This bug caused the last entry to have garbage in its final fields, including LowestSupportedFwVersion and CapsuleFlags, which (usually) made fwupd to detect firmware update availability, but refuse actually
"made fwupd able to"
Quoted 13 lines
installing it.
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Marek Marczykowski-Górecki <[email protected]>--- xen/common/efi/boot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/common/efi/boot.c +0
-0
xen/common/efi/boot.c static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc) · line 679
Quoted 6 lines
xen/common/efi/boot.c +2
-1@@ -675,7 +675,8 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)if ( esrt_ptr->FwResourceCount > available_len /sizeof (esrt_ptr->Entries[0 ]) )return 0 ; -return esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]); +return offsetof(EFI_SYSTEM_RESOURCE_TABLE , Entries) + + esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]);
offsetof(EFI_SYSTEM_RESOURCE_TABLE, Entries[esrt_ptr->FwResourceCount])
is a shorter expression with the same answer, and a pattern we use elsewhere. I can fix on commit if you're happy.
~Andrew
Quoted 25 lines · Andrew Cooper
Quoted 5 lines · Marek Marczykowski-Górecki
Fix calculating the table size - it consists of a header + entries, not just entries.
This bug caused the last entry to have garbage in its final fields, including LowestSupportedFwVersion and CapsuleFlags, which (usually) made fwupd to detect firmware update availability, but refuse actually"made fwupd able to"
Quoted 16 lines
installing it.
Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Marek Marczykowski-Górecki <[email protected]>--- xen/common/efi/boot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/common/efi/boot.c +0
-0@@ -675,7 +675,8 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)if ( esrt_ptr->FwResourceCount > available_len /sizeof (esrt_ptr->Entries[0 ]) )return 0 ;
Quoted 8 lines
xen/common/efi/boot.c static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc) · line 679
Quoted 3 lines
xen/common/efi/boot.c +2
-1-return esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]); +return offsetof(EFI_SYSTEM_RESOURCE_TABLE , Entries) + + esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]);
offsetof(EFI_SYSTEM_RESOURCE_TABLE, Entries[esrt_ptr->FwResourceCount])is a shorter expression with the same answer, and a pattern we use elsewhere. I can fix on commit if you're happy.
Fine with me, thanks.
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 18 lines · Marek Marczykowski-Górecki
Fix calculating the table size - it consists of a header + entries, not just entries.
This bug caused the last entry to have garbage in its final fields, including LowestSupportedFwVersion and CapsuleFlags, which (usually) made fwupd to detect firmware update availability, but refuse actually installing it.Fixes dc7da0874ba4 ("EFI: preserve the System Resource Table for dom0")Signed-off-by Marek Marczykowski-Górecki <[email protected]>---
xen/common/efi/boot.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)xen/common/efi/boot.c +0
-0
xen/common/efi/boot.c static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc) · line 682
Quoted 9 lines
xen/common/efi/boot.c +2
-1@@ -675,7 +675,8 @@ static size_t __init get_esrt_size(const EFI_MEMORY_DESCRIPTOR *desc)if ( esrt_ptr->FwResourceCount > available_len /sizeof (esrt_ptr->Entries[0 ]) )return 0 ; -return esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]); +return offsetof(EFI_SYSTEM_RESOURCE_TABLE , Entries) + + esrt_ptr->FwResourceCount *sizeof (esrt_ptr->Entries[0 ]); }static EFI_GUID __initdata esrt_guid =EFI_SYSTEM_RESOURCE_TABLE_GUID ;
With Andy's suggestions,