diff mbox series

[v2,13/25] binman: Make fake blobs zero-sized by default

Message ID 20220223230040.159317-14-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show
Series binman: rockchip: Migrate from rockchip SPL_FIT_GENERATOR script | expand

Commit Message

Simon Glass Feb. 23, 2022, 11 p.m. UTC
On x86 devices having even a small amount of data can cause an overlap
between regions. For example, bayleybay complains when the intel-vga
region overlaps with u-boot-ucode:

   ImagePos    Offset      Size  Name
   <none>    00000000  00800000  main-section
   <none>     ff800000  00000080  intel-descriptor
   <none>     ff800400  00000080  intel-me
   <none>     fff00000  00098f24  u-boot-with-ucode-ptr
   <none>     fff98f24  00001aa0  u-boot-dtb-with-ucode
   <none>     fff9a9d0  0002a000  u-boot-ucode
   <none>     fffb0000  00000080  intel-vga
   ...

It is safer to use an empty file in most cases. Add an option to set the
size for those uses that need it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add a patch to make fake blobs zero-sized by default

 tools/binman/entry.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Alper Nebi Yasak March 3, 2022, 9:09 p.m. UTC | #1
On 24/02/2022 02:00, Simon Glass wrote:
> On x86 devices having even a small amount of data can cause an overlap
> between regions. For example, bayleybay complains when the intel-vga
> region overlaps with u-boot-ucode:
> 
>    ImagePos    Offset      Size  Name
>    <none>    00000000  00800000  main-section
>    <none>     ff800000  00000080  intel-descriptor
>    <none>     ff800400  00000080  intel-me
>    <none>     fff00000  00098f24  u-boot-with-ucode-ptr
>    <none>     fff98f24  00001aa0  u-boot-dtb-with-ucode
>    <none>     fff9a9d0  0002a000  u-boot-ucode
>    <none>     fffb0000  00000080  intel-vga
>    ...
> 
> It is safer to use an empty file in most cases. Add an option to set the
> size for those uses that need it.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v2:
> - Add a patch to make fake blobs zero-sized by default
> 
>  tools/binman/entry.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> diff --git a/tools/binman/entry.py b/tools/binman/entry.py

Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>

Later on, I think adding 'min-size' and 'max-size' properties for
entries could be useful for a few things including this.
Simon Glass March 6, 2022, 3:08 a.m. UTC | #2
Hi Alper,

On Thu, 3 Mar 2022 at 14:16, Alper Nebi Yasak <alpernebiyasak@gmail.com> wrote:
>
> On 24/02/2022 02:00, Simon Glass wrote:
> > On x86 devices having even a small amount of data can cause an overlap
> > between regions. For example, bayleybay complains when the intel-vga
> > region overlaps with u-boot-ucode:
> >
> >    ImagePos    Offset      Size  Name
> >    <none>    00000000  00800000  main-section
> >    <none>     ff800000  00000080  intel-descriptor
> >    <none>     ff800400  00000080  intel-me
> >    <none>     fff00000  00098f24  u-boot-with-ucode-ptr
> >    <none>     fff98f24  00001aa0  u-boot-dtb-with-ucode
> >    <none>     fff9a9d0  0002a000  u-boot-ucode
> >    <none>     fffb0000  00000080  intel-vga
> >    ...
> >
> > It is safer to use an empty file in most cases. Add an option to set the
> > size for those uses that need it.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v2:
> > - Add a patch to make fake blobs zero-sized by default
> >
> >  tools/binman/entry.py | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > diff --git a/tools/binman/entry.py b/tools/binman/entry.py
>
> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
>
> Later on, I think adding 'min-size' and 'max-size' properties for
> entries could be useful for a few things including this.

Yes I think that might become necessary.

Regards,
Simon
diff mbox series

Patch

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 2fb0050da5..e4c0fbe23d 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -988,13 +988,14 @@  features to produce new behaviours.
         if self.missing:
             missing_list.append(self)
 
-    def check_fake_fname(self, fname):
+    def check_fake_fname(self, fname, size=0):
         """If the file is missing and the entry allows fake blobs, fake it
 
         Sets self.faked to True if faked
 
         Args:
             fname (str): Filename to check
+            size (int): Size of fake file to create
 
         Returns:
             tuple:
@@ -1004,7 +1005,7 @@  features to produce new behaviours.
         if self.allow_fake and not pathlib.Path(fname).is_file():
             outfname = tools.get_output_filename(os.path.basename(fname))
             with open(outfname, "wb") as out:
-                out.truncate(1024)
+                out.truncate(size)
             self.faked = True
             tout.info(f"Entry '{self._node.path}': Faked file '{outfname}'")
             return outfname, True