* [PATCH 1/1] efi_loader: allow compiling with clang
@ 2020-05-27 0:54 Heinrich Schuchardt
2020-05-27 1:56 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2020-05-27 0:54 UTC (permalink / raw)
To: u-boot
On ARM systems gd is stored in register r9 or x18. When compiling with
clang gd is defined as a macro calling function gd_ptr(). So we can not
make assignments to gd.
In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
have to restore gd when reentering U-Boot.
Define a new function set_gd() for setting gd and use it in the UEFI
sub-system.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
arch/arm/include/asm/global_data.h | 9 +++++++++
lib/efi_loader/efi_boottime.c | 10 +++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index f23b6bfb75..7c0905d240 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -117,4 +117,13 @@ static inline gd_t *get_gd(void)
#endif
#endif
+static inline void set_gd(volatile gd_t *gd_ptr)
+{
+#ifdef CONFIG_ARM64
+ __asm__ volatile("ldr x18, %0\n" : : "m"(gd_ptr));
+#else
+ __asm__ volatile("ldr r9, %0\n" : : "m"(gd_ptr));
+#endif
+}
+
#endif /* __ASM_GBL_DATA_H */
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index db34938196..1591ad8300 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -49,7 +49,7 @@ static efi_handle_t current_image;
* restriction so we need to manually swap its and our view of that register on
* EFI callback entry/exit.
*/
-static volatile void *efi_gd, *app_gd;
+static volatile gd_t *efi_gd, *app_gd;
#endif
/* 1 if inside U-Boot code, 0 if inside EFI payload code */
@@ -89,7 +89,7 @@ int __efi_entry_check(void)
#ifdef CONFIG_ARM
assert(efi_gd);
app_gd = gd;
- gd = efi_gd;
+ set_gd(efi_gd);
#endif
return ret;
}
@@ -99,7 +99,7 @@ int __efi_exit_check(void)
{
int ret = --entry_count == 0;
#ifdef CONFIG_ARM
- gd = app_gd;
+ set_gd(app_gd);
#endif
return ret;
}
@@ -123,7 +123,7 @@ void efi_restore_gd(void)
/* Only restore if we're already in EFI context */
if (!efi_gd)
return;
- gd = efi_gd;
+ set_gd(efi_gd);
#endif
}
@@ -2920,7 +2920,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
* otherwise __efi_entry_check() will put the wrong value into
* app_gd.
*/
- gd = app_gd;
+ set_gd(app_gd);
#endif
/*
* To get ready to call EFI_EXIT below we have to execute the
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 1/1] efi_loader: allow compiling with clang
2020-05-27 0:54 [PATCH 1/1] efi_loader: allow compiling with clang Heinrich Schuchardt
@ 2020-05-27 1:56 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-05-27 1:56 UTC (permalink / raw)
To: u-boot
On Wed, May 27, 2020 at 02:54:06AM +0200, Heinrich Schuchardt wrote:
> On ARM systems gd is stored in register r9 or x18. When compiling with
> clang gd is defined as a macro calling function gd_ptr(). So we can not
> make assignments to gd.
>
> In the UEFI sub-system we need to save gd when leaving to UEFI binaries and
> have to restore gd when reentering U-Boot.
>
> Define a new function set_gd() for setting gd and use it in the UEFI
> sub-system.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com> [Raspberry Pi 3, 32bit, Clang 10]
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200526/98a81fc9/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-27 1:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 0:54 [PATCH 1/1] efi_loader: allow compiling with clang Heinrich Schuchardt
2020-05-27 1:56 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.