mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 17:44:19 +00:00
fix(qemu): fix RMM manifest checksum calculation
Commit 71c4443886ff ("fix(lib/rmm_el3_ifc): add console name to checksum
calculation") on TF-RMM updated the checksum calcualtion of the RMM
manifest to include the console names.
Include console names in the QEMU manifest to remain compatible with
RMM, just like commit aa99881d30
("fix(rme): add console name to
checksum calculation") did for FVP.
Checksum calculation is done by adding together 64-bit values. Add a
helper that does this.
Change-Id: Ica6cab628160593830270bef1acdeb475d1c0c36
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
This commit is contained in:
parent
6157ef37fb
commit
d08dca4263
1 changed files with 22 additions and 3 deletions
|
@ -258,6 +258,23 @@ static void plat_get_memory_node(int index, struct ns_dram_bank *bank_ptr)
|
|||
}
|
||||
#endif /* PLAT_qemu */
|
||||
|
||||
/*
|
||||
* Calculate checksum of 64-bit words @buffer, of @size bytes
|
||||
*/
|
||||
static uint64_t checksum_calc(uint64_t *buffer, size_t size)
|
||||
{
|
||||
uint64_t sum = 0UL;
|
||||
|
||||
assert(((uintptr_t)buffer & (sizeof(uint64_t) - 1UL)) == 0UL);
|
||||
assert((size & (sizeof(uint64_t) - 1UL)) == 0UL);
|
||||
|
||||
for (unsigned long i = 0UL; i < (size / sizeof(uint64_t)); i++) {
|
||||
sum += buffer[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
|
||||
{
|
||||
int i, last;
|
||||
|
@ -352,10 +369,12 @@ int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
|
|||
last = num_banks - 1;
|
||||
for (i = 0; i < num_banks; i++) {
|
||||
plat_get_memory_node(i, &bank_ptr[last]);
|
||||
checksum += bank_ptr[last].base + bank_ptr[last].size;
|
||||
last--;
|
||||
}
|
||||
|
||||
checksum += checksum_calc((uint64_t *)bank_ptr,
|
||||
num_banks * sizeof(*bank_ptr));
|
||||
|
||||
/* Checksum must be 0 */
|
||||
manifest->plat_dram.checksum = ~checksum + 1UL;
|
||||
|
||||
|
@ -373,8 +392,8 @@ int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
|
|||
strlcpy(console_ptr[0].name, "pl011", sizeof(console_ptr[0].name));
|
||||
|
||||
/* Update checksum */
|
||||
checksum += console_ptr[0].base + console_ptr[0].map_pages +
|
||||
console_ptr[0].clk_in_hz + console_ptr[0].baud_rate;
|
||||
checksum += checksum_calc((uint64_t *)console_ptr,
|
||||
num_consoles * sizeof(*console_ptr));
|
||||
|
||||
/* Checksum must be 0 */
|
||||
manifest->plat_console.checksum = ~checksum + 1UL;
|
||||
|
|
Loading…
Add table
Reference in a new issue