From: Heinrich Schuchardt Date: Sat, 26 Sep 2020 05:50:36 +0000 (+0200) Subject: riscv: restore global data pointer in trap handler X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=c48e9f310b950e39a91cea74b6708dd4fe2eb39c;p=u-boot.git 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 Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- diff --git a/arch/riscv/lib/interrupts.c b/arch/riscv/lib/interrupts.c index cd47e64487..8ff40f0f36 100644 --- a/arch/riscv/lib/interrupts.c +++ b/arch/riscv/lib/interrupts.c @@ -111,6 +111,9 @@ ulong handle_trap(ulong cause, ulong epc, ulong tval, struct pt_regs *regs) { ulong is_irq, irq; + /* An UEFI application may have changed gd. Restore U-Boot's gd. */ + efi_restore_gd(); + is_irq = (cause & MCAUSE_INT); irq = (cause & ~MCAUSE_INT);