[PATCH v2 1/1] riscv: restore global data pointer in trap handler

Rick Chen rickchen36 at gmail.com
Mon Sep 28 09:45:11 CEST 2020


> From: Heinrich Schuchardt [mailto:xypron.glpk at gmx.de]
> Sent: Sunday, September 27, 2020 4:24 PM
> To: Rick Jian-Zhi Chen(陳建志)
> Cc: Simon Glass; Sean Anderson; Bin Meng; u-boot at lists.denx.de; Alexander Graf; Abner Chang; Heinrich Schuchardt
> Subject: [PATCH v2 1/1] riscv: restore global data pointer in trap handler
>
> The gp register is used to store U-Boot's global data pointer. We should
> not assume that an UEFI application leaves the gp register unchanged as
> the UEFI specifications does not define who is the owner of the gp and tp
> registers.
>
> So the following sequence should be followed in the trap handler:
>
> * save the caller's gp register
> * restore the global data pointer
> * serve interrupts or print crash dump and reset
> * restore the caller's gp register
>
> Cc: Abner Chang <abner.chang at hpe.com>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> v2:
>         Saving and restoring the caller's x3 is already handled in mtrap.S.
>         efi_loader.h provides an empty fallback efi_restore_gd() function
>         if CONFIG_EFI_LOADER=n.
> ---
>  arch/riscv/lib/interrupts.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Rick Chen <rick at andestech.com>


More information about the U-Boot mailing list