+CC Heinrich who has looked the relocation stuff a bit more On Thu, 27 Mar 2025 at 23:22, Ilias Apalodimas <[email protected]> wrote: > > On Thu, 27 Mar 2025 at 08:12, Varadarajan Narayanan > <[email protected]> wrote: > > > > On Wed, Mar 26, 2025 at 09:28:04AM +0200, Ilias Apalodimas wrote: > > > Hi Varadarajan > > > > > > On Wed, 26 Mar 2025 at 07:47, Varadarajan Narayanan > > > <[email protected]> wrote: > > > > > > > > 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. > > > > > > How were those page table entries added? > > > > initr_caches -> > > enable_caches -> > > setup_pgtables (arch/arm/mach-snapdragon/board.c) > > > > > The runtime service relocation might have overwritten those now, but > > > since they are not in protected memory this can happen arbitrarily. > > > > To avoid relocating U-Boot, I had OR'ed GD_FLG_SKIP_RELOC to gd->flags > > in init_sequence_f -> mach_cpu_init(). Hope that is the right place and > > way to do it.
Looking at it a bit more, doing it there seems correct. This will skip relocation in board_f functions > > I'll have a look at the relocation stuff, but off the top of my head, > I don't remember. > > > > > > > Signed-off-by: Varadarajan Narayanan <[email protected]> > > > > --- > > > > 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); > > > > > > Have you tested booting with EFI with this change? > > > > Yes, tested this with both GD_FLG_SKIP_RELOC set and not set. > > > > Used the command 'bootefi bootmgr' and Linux is able to boot. > > Have you tried to call any runtime services -- e.g efival -l will dump > all the EFI variables The efi runtime relocation data are not in rela.dyn, that data is in .efi_runtime_rel. I don't know why we relocate runtime services later than the initial relocation code, but skipping them here seems correct. Heinrich? Thanks /Ilias > > Thanks > /Ilias > > > > Thanks > > Varada

