@@ -69,7 +69,6 @@ namespace Bootloader{
69
69
sizeof (sha2_hash_t ));
70
70
}
71
71
72
- // @TODO RTC:167740 remove magic number check once fsp/op signs HBB
73
72
/**
74
73
* @brief Memcmp a vaddr to the known secureboot magic number
75
74
*
@@ -97,24 +96,48 @@ namespace Bootloader{
97
96
const sha2_hash_t * i_hwKeyHash )
98
97
{
99
98
#ifdef CONFIG_SECUREBOOT
100
- // @TODO RTC:167740 remove magic number check once fsp/op signs HBB
101
- if (cmpSecurebootMagicNumber (reinterpret_cast < const uint8_t * >
102
- (i_pContainer )))
99
+ BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_START );
100
+
101
+ uint64_t l_rc = 0 ;
102
+
103
+ // @TODO RTC:166848 Move find/get secure rom logic out of ROM verify
104
+ // Find secure ROM addr
105
+ // Get starting address of ROM size and code which is the next 8 byte
106
+ // aligned address after the bootloader end.
107
+ // [hbbl][pad:8:if-applicable][securerom-size:8][securerom]
108
+ const void * l_pBootloaderEnd = & bootloader_end_address ;
109
+ uint64_t l_bootloaderSize = 0 ;
110
+ memcpy (& l_bootloaderSize , l_pBootloaderEnd , sizeof (l_bootloaderSize ));
111
+ uint64_t l_rom_startAddr = getHRMOR () + ALIGN_8 (l_bootloaderSize );
112
+ // Get Rom Size
113
+ // @TODO RTC:166848 Store size so hb can use
114
+ uint64_t l_secureRomSize = 0 ;
115
+ memcpy (& l_secureRomSize , reinterpret_cast < void * > (l_rom_startAddr ),
116
+ sizeof (l_secureRomSize ));
117
+ l_rom_startAddr += sizeof (l_secureRomSize );
118
+
119
+ // Beginning of SecureROM has a info structure
120
+ // Get Secure ROM info
121
+ const auto l_pSecRomInfo = reinterpret_cast < SecureRomInfo * > (
122
+ l_rom_startAddr );
123
+
124
+ // # @TODO RTC:170136 terminate in this case
125
+ // Ensure SecureRom is actually present
126
+ if ( !secureRomInfoValid (l_pSecRomInfo ) )
127
+ {
128
+ BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_NO_EYECATCH );
129
+ }
130
+ // # @TODO RTC:170136 terminate in this case
131
+ else if ( !cmpSecurebootMagicNumber (reinterpret_cast < const uint8_t * >
132
+ (i_pContainer )))
133
+ {
134
+ BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_NO_MAGIC_NUM );
135
+ }
136
+ else
103
137
{
104
- BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_HBB_START );
105
-
106
- uint64_t l_rc = 0 ;
107
-
108
- const void * l_pBootloaderEnd = & bootloader_end_address ;
109
-
110
- // Get starting address of ROM code which is the next 8 byte aligned
111
- // address after the bootloader end.
112
- uint64_t l_size = 0 ;
113
- memcpy (& l_size , l_pBootloaderEnd , sizeof (l_size ));
114
- uint64_t l_rom_startAddr = getHRMOR () + ALIGN_8 (l_size );
115
-
116
138
// Set startAddr to ROM_verify() function at an offset of Secure ROM
117
139
uint64_t l_rom_verify_startAddr = l_rom_startAddr
140
+ + l_pSecRomInfo -> branchtableOffset
118
141
+ ROM_VERIFY_FUNCTION_OFFSET ;
119
142
120
143
// Declare local input struct
@@ -128,18 +151,17 @@ namespace Bootloader{
128
151
// Use current hw hash key
129
152
memcpy (& l_hw_parms .hw_key_hash , i_hwKeyHash , sizeof (sha2_hash_t ));
130
153
131
- const ROM_container_raw * l_container =
132
- reinterpret_cast < const ROM_container_raw * > (i_pContainer );
154
+ const auto l_container = reinterpret_cast < const ROM_container_raw * >
155
+ (i_pContainer );
133
156
134
157
l_rc = call_rom_verify (reinterpret_cast < void * >
135
158
(l_rom_verify_startAddr ),
136
159
l_container ,
137
160
& l_hw_parms );
138
-
139
161
if (l_rc != 0 )
140
162
{
141
163
// Verification of Container failed.
142
- BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_HBB_FAIL );
164
+ BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_FAIL );
143
165
/*@
144
166
* @errortype
145
167
* @moduleid MOD_BOOTLOADER_VERIFY
@@ -156,11 +178,7 @@ namespace Bootloader{
156
178
157
179
}
158
180
159
- BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_HBB_SUCCESS );
160
- }
161
- else
162
- {
163
- BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_HBB_SKIP );
181
+ BOOTLOADER_TRACE (BTLDR_TRC_MAIN_VERIFY_SUCCESS );
164
182
}
165
183
#endif
166
184
}
@@ -260,10 +278,11 @@ namespace Bootloader{
260
278
verifyContainer (l_src_addr , & l_hwKeyHash );
261
279
262
280
// Increment past secure header
263
- #ifdef CONFIG_SECUREBOOT
264
- l_src_addr += PAGE_SIZE /sizeof (uint64_t );
265
- l_hbbLength -= PAGE_SIZE ;
266
- #endif
281
+ if (isSecureSection (PNOR ::HB_BASE_CODE ))
282
+ {
283
+ l_src_addr += PAGE_SIZE /sizeof (uint64_t );
284
+ l_hbbLength -= PAGE_SIZE ;
285
+ }
267
286
268
287
// Copy HBB image into address where it executes
269
288
for (uint32_t i = 0 ;
0 commit comments