From 2b67b2d784b2e7e7c3923acf8f13d615d5a09dae Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Tue, 29 Dec 2020 01:59:57 +0000 Subject: [PATCH] fel: Fix SPL size check against thunk addr We have a check to avoid that the SPL accidentally overwrites the thunk buffer we use to execute code on the board. Unfortunately this compares the SPL *size* against the thunk *address*, which is only valid when the SPL starts at 0 (older 32-bit SoCs). Factor in the SoC dependent SPL start address, to make this check work properly on newer (64-bit) SoCs. Signed-off-by: Andre Przywara --- fel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fel.c b/fel.c index 1555184..8990e6e 100644 --- a/fel.c +++ b/fel.c @@ -808,8 +808,8 @@ void aw_fel_write_and_execute_spl(feldev_handle *dev, uint8_t *buf, size_t len) } /* Clarify the SPL size limitations, and bail out if they are not met */ - if (soc_info->thunk_addr < spl_len_limit) - spl_len_limit = soc_info->thunk_addr; + if (soc_info->thunk_addr - soc_info->spl_addr < spl_len_limit) + spl_len_limit = soc_info->thunk_addr - soc_info->spl_addr; if (spl_len > spl_len_limit) pr_fatal("SPL: too large (need %u, have %u)\n",