diff mbox series

[U-Boot,2/6] x86: Change __kernel_size_t conditionals to use compiler provided defines

Message ID 1529656712-3660-3-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 5460fd076263a461442e4beb3215466536166026
Delegated to: Bin Meng
Headers show
Series x86: efi: payload: Various fixes | expand

Commit Message

Bin Meng June 22, 2018, 8:38 a.m. UTC
Since commit bb0bb91cf0aa ("efi_stub: Use efi_uintn_t"), EFI x86
64-bit payload does not work anymore. The call to GetMemoryMap()
in efi_stub.c fails with return code EFI_INVALID_PARAMETER. Since
the payload itself is still 32-bit U-Boot, efi_uintn_t gets wrongly
interpreted as int, but it should actually be long in a 64-bit EFI
environment.

This changes the x86 __kernel_size_t conditionals to use compiler
provided defines instead. That way we always adhere to the build
environment we're in and the definitions adjust automatically.

Fixes: bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/x86/include/asm/posix_types.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Simon Glass June 23, 2018, 2:22 p.m. UTC | #1
On 22 June 2018 at 02:38, Bin Meng <bmeng.cn@gmail.com> wrote:
> Since commit bb0bb91cf0aa ("efi_stub: Use efi_uintn_t"), EFI x86
> 64-bit payload does not work anymore. The call to GetMemoryMap()
> in efi_stub.c fails with return code EFI_INVALID_PARAMETER. Since
> the payload itself is still 32-bit U-Boot, efi_uintn_t gets wrongly
> interpreted as int, but it should actually be long in a 64-bit EFI
> environment.
>
> This changes the x86 __kernel_size_t conditionals to use compiler
> provided defines instead. That way we always adhere to the build
> environment we're in and the definitions adjust automatically.
>
> Fixes: bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  arch/x86/include/asm/posix_types.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Bin Meng June 24, 2018, 12:54 a.m. UTC | #2
On Sat, Jun 23, 2018 at 10:22 PM, Simon Glass <sjg@chromium.org> wrote:
> On 22 June 2018 at 02:38, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Since commit bb0bb91cf0aa ("efi_stub: Use efi_uintn_t"), EFI x86
>> 64-bit payload does not work anymore. The call to GetMemoryMap()
>> in efi_stub.c fails with return code EFI_INVALID_PARAMETER. Since
>> the payload itself is still 32-bit U-Boot, efi_uintn_t gets wrongly
>> interpreted as int, but it should actually be long in a 64-bit EFI
>> environment.
>>
>> This changes the x86 __kernel_size_t conditionals to use compiler
>> provided defines instead. That way we always adhere to the build
>> environment we're in and the definitions adjust automatically.
>>
>> Fixes: bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>> ---
>>
>>  arch/x86/include/asm/posix_types.h | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/include/asm/posix_types.h b/arch/x86/include/asm/posix_types.h
index 717f6cb..dbcea7f 100644
--- a/arch/x86/include/asm/posix_types.h
+++ b/arch/x86/include/asm/posix_types.h
@@ -16,7 +16,8 @@  typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
 typedef unsigned short	__kernel_uid_t;
 typedef unsigned short	__kernel_gid_t;
-#if CONFIG_IS_ENABLED(X86_64)
+/* checking against __x86_64__ covers both 64-bit EFI stub and 64-bit U-Boot */
+#if defined(__x86_64__)
 typedef unsigned long	__kernel_size_t;
 typedef long		__kernel_ssize_t;
 #else