Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBBL could be assembled using linker script rather than cat and dd #156

Open
ghost opened this issue Dec 5, 2018 · 2 comments
Open

HBBL could be assembled using linker script rather than cat and dd #156

ghost opened this issue Dec 5, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 5, 2018

The Hostboot Boot Loader image is made up of a few things:

  1. The Host Boot Boot Loader itself
  2. The securerom image (the size of the image and then the image itself)
  3. the hash of the hardware keys in the last 64 bytes of the image

This is currently constructed first using the linker script src/bootloader.ld for step 1, and subsequently manipulated in genPnorImages.pl to do 2 and 3.

There's no reason 2 and 3 couldn't be done by the linker script, which would give us the benefit of being able to catch HBBL and/or securerom growing beyond the maximum allowed HBBL size (which is restricted due to the size of the SBE SEEPROM)

@ghost ghost added the enhancement label Dec 5, 2018
@ghost
Copy link
Author

ghost commented Dec 6, 2018

Something like this for the linker script

--- a/src/bootloader.ld
+++ b/src/bootloader.ld
@@ -27,6 +27,8 @@ base_load_address = 0x00000000;
 sbe_hb_structures = 0x00000004;
 /* Text section offset = 12KB (space reserved for exception vectors)      */
 text_load_address = 0x00003000;
+max_hbbl_size = 0x5000;
+hw_key_hash_size = 64;
 
 SECTIONS
 {
@@ -92,6 +94,23 @@ SECTIONS
         *(.dtors)
         *(.interp)
     }
+
+    . = ALIGN(0x8);
+    QUAD(end_securerom - start_securerom);
+
+    .securerom : {
+        start_securerom = .;
+        KEEP(*(.securerom))
+        end_securerom = .;
+    }
+
+    . = max_hbbl_size + text_load_address - hw_key_hash_size;
+    .hwkeyhash : {
+        start_hwkeyhash = .;
+       KEEP(*(.hwkeyhash))
+       end_hwkeyhash = .;
+    }
+    . = max_hbbl_size + text_load_address;
 }

and then you just need to link in two files like this:

securerom.S

	.section ".securerom","a"
	.incbin "securerom.bin"

and
hwkeyhash.S

	.section ".hwkeyhash","a"
	.incbin "hwkeyhash.bin"

the reason this is currently tricky is that Hostboot makefiles don't follow the advice "Recursive Make Considered Harmful" and thus things get weird.

@ghost
Copy link
Author

ghost commented Dec 6, 2018

This would let us remove dd and cat invocations in src/build/mkrules/hbfw/img/makefile as well as in genPnorImages.pl and have a flashable hbbl.bin image come directly out of the link operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants