If the EFI runtime services pointers are relocated even though
relocation is skipped, it corrupts some other data resulting in some
unexpected behaviour.

In this specific case, it overwrote some page table entries resulting in
the device memory address range's mappings getting removed. Eventually,
after the completion of efi_runtime_relocate(), when a driver tries to
access its device's registers it crashes since the mappings are absent.

Signed-off-by: Varadarajan Narayanan <quic_var...@quicinc.com>
---
 common/board_r.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/board_r.c b/common/board_r.c
index 179259b00de..1dd3b96c2de 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -169,7 +169,8 @@ static int initr_reloc_global_data(void)
         */
        efi_save_gd();
 
-       efi_runtime_relocate(gd->relocaddr, NULL);
+       if (!(gd->flags & GD_FLG_SKIP_RELOC))
+               efi_runtime_relocate(gd->relocaddr, NULL);
 #endif
 
        return 0;

base-commit: 244e61fbb7f5045e4e187024f7ae80434c952145
-- 
2.34.1

Reply via email to