binman: x86: Tidy up skip-at-start settings
Subsystems (2)
cover binman: x86: Tidy up skip-at-start settings
A recent series [1] adjusted how Binman handles the skip-at-start property.
This first patch in this series fixes a bug in coral due to this change. The remaining two patches remove work-arounds which are no-longer needed on x86
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=441782
Simon Glass (3):
x86: Stop working around skip-at-start
binman: Read the skip-at-start value on startup
binman: x86: Write skip-at-start when end-at-4gb is used
arch/x86/lib/fsp2/fsp_init.c | 3 +-- lib/binman.c | 16 ++++++++++++++-- tools/binman/etype/section.py | 6 +++++- 3 files changed, 20 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 x86: Stop working around skip-at-start
With a recent Binman change, the skip-at-start property is now honoured, meaning that all image-pos values in the affected section start from the skip-at-start value.
The x86 code works around the old behaviour at present, so update it.
This fixes booting on coral
---
arch/x86/cpu/intel_common/intel_opregion.c | 1 + arch/x86/lib/fsp2/fsp_init.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/cpu/intel_common/intel_opregion.c +1 -0
@@ -31,6 +31,7 @@ static int locate_vbt(char **vbtp, int *sizep) size = vbt.size;if (size >sizeof (vbt_data))return log_msg_ret ("vbt" , -E2BIG ); + vbt.image_pos +=CONFIG_ROM_SIZE ; ret =spi_flash_read_dm (dev, vbt.image_pos, size, vbt_data);if (ret)return log_msg_ret ("read" , ret);
arch/x86/lib/fsp2/fsp_init.c +1 -1
@@ -141,7 +141,7 @@ int fsp_locate_fsp(enum fsp_type_t type, struct binman_entry *entry,if (ret)return log_msg_ret ("binman entry" , ret);if (!use_spi_flash) - rom_offset = (map_base & mask) -CONFIG_ROM_SIZE ; + rom_offset = map_base +CONFIG_ROM_SIZE ; }else { ret = -ENOENT ;if (false)
Signature · 1 line
2.43.0
PATCH 2/3 binman: Read the skip-at-start value on startup
In reply to Simon GlassThis value provides an offset for all image-pos values in the image. Read it on startup so that we can take account of it when calculating positions.
---
lib/binman.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
lib/binman.c +14 -2
@@ -16,12 +16,15 @@* struct binman_info - Information needed by the binman library * * @image: Node describing the image we are running from +* @skip_at_start: Number of bytes skipped at the start of the image. This is +* the value of the skip-at-start property for the image * @rom_offset: Offset from an image_pos to the memory-mapped address, or * ROM_OFFSET_NONE if the ROM is not memory-mapped. Can be positive or * negative */ struct binman_info {ofnode image; +uint skip_at_start;int rom_offset; };
@@ -80,7 +83,14 @@ static int binman_entry_find_internal(ofnode node, const char *name,int binman_entry_find (const char *name,struct binman_entry *entry) { -return binman_entry_find_internal (binman->image, name, entry); +int ret; + + ret =binman_entry_find_internal (binman->image, name, entry); +if (ret) +return log_msg_ret ("bef" , ret); + entry->image_pos -= binman->skip_at_start; + +return 0 ; }int binman_entry_map (ofnode parent,const char *name,void **bufp,int *sizep)
@@ -107,7 +117,7 @@ ofnode binman_section_find_node(const char *name)void binman_set_rom_offset (int rom_offset) { - binman->rom_offset = rom_offset; + binman->rom_offset = rom_offset - binman->skip_at_start; }int binman_get_rom_offset (void )
@@ -140,10 +150,12 @@ int binman_init(void) binman =malloc (sizeof (struct binman_info ));if (!binman)return log_msg_ret ("space for binman" , -ENOMEM ); +memset (binman,'\0' ,sizeof (struct binman_info )); ret =find_image_node (&binman->image);if (ret)return log_msg_ret ("node" , -ENOENT );binman_set_rom_offset (ROM_OFFSET_NONE ); +ofnode_read_u32 (binman->image,"skip-at-start" , &binman->skip_at_start);log_debug ("binman: Selected image node '%s'\n" ,ofnode_get_name (binman->image));
Signature · 1 line
2.43.0
PATCH 3/3 binman: x86: Write skip-at-start when end-at-4gb is used
In reply to Simon GlassThe end-at-4gb property implies a value for skip-at-start so add it into the output FDT so that U-Boot can read it.
Now that skip-at-start is implemented, we can drop the workarounds used in the x86 code to obtain the correct image-pos value.
---
arch/x86/cpu/intel_common/intel_opregion.c | 1 - arch/x86/lib/fsp2/fsp_init.c | 3 +-- tools/binman/etype/section.py | 6 +++++- 3 files changed, 6 insertions(+), 4 deletions(-)
arch/x86/cpu/intel_common/intel_opregion.c +0 -1
@@ -31,7 +31,6 @@ static int locate_vbt(char **vbtp, int *sizep) size = vbt.size;if (size >sizeof (vbt_data))return log_msg_ret ("vbt" , -E2BIG ); - vbt.image_pos +=CONFIG_ROM_SIZE ; ret =spi_flash_read_dm (dev, vbt.image_pos, size, vbt_data);if (ret)return log_msg_ret ("read" , ret);
arch/x86/lib/fsp2/fsp_init.c +1 -2
@@ -107,7 +107,6 @@ int fsp_locate_fsp(enum fsp_type_t type, struct binman_entry *entry, bool use_spi_flash, struct udevice **devp, struct fsp_header **hdrp, ulong *rom_offsetp) { - ulong mask = CONFIG_ROM_SIZE - 1; struct udevice *dev;ulong rom_offset =0 ;uint map_size;
@@ -141,7 +140,7 @@ int fsp_locate_fsp(enum fsp_type_t type, struct binman_entry *entry,if (ret)return log_msg_ret ("binman entry" , ret);if (!use_spi_flash) - rom_offset = map_base +CONFIG_ROM_SIZE ; + rom_offset = map_base; }else { ret = -ENOENT ;if (false)
tools/binman/etype/section.py +5 -1
@@ -189,7 +189,7 @@ class Entry_section(Entry): self._sort = fdt_util.GetBool(self._node, 'sort-by-offset') self._end_at_4gb = fdt_util.GetBool(self._node, 'end-at-4gb') self._skip_at_start = fdt_util.GetInt(self._node, 'skip-at-start') - if self._end_at_4gb: + if self._end_at_4gb and self.GetImage().copy_to_orig: if not self.size: self.Raise("Section size must be provided when using end-at-4gb") if self._skip_at_start is not None:
@@ -263,6 +263,8 @@ class Entry_section(Entry): super().AddMissingProperties(have_image_pos) if self.compress != 'none': have_image_pos = False + if self._end_at_4gb: + state.AddZeroProp(self._node, 'skip-at-start') for entry in self._entries.values(): entry.AddMissingProperties(have_image_pos)
@@ -505,6 +507,8 @@ class Entry_section(Entry): def SetCalculatedProperties(self): super().SetCalculatedProperties() + if self._end_at_4gb: + state.SetInt(self._node, 'skip-at-start', self._skip_at_start) for entry in self._entries.values(): entry.SetCalculatedProperties()
Signature · 1 line
2.43.0