diff mbox

[U-Boot,v2,2/3] x86: efi: Fix EFI 64-bit payload build warnings

Message ID 1472114839-6792-2-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 3e6cc35f4e8fb5010421e606cfab0e00d0adacc0
Delegated to: Bin Meng
Headers show

Commit Message

Bin Meng Aug. 25, 2016, 8:47 a.m. UTC
There are lots of warnings when building EFI 64-bit payload.

include/asm-generic/bitops/__fls.h:17:2:
  warning: left shift count >= width of type
  	if (!(word & (~0ul << 32))) {
			^

In fact, U-Boot itself as EFI payload is running in 32-bit mode.
So BITS_PER_LONG needs to still be 32, but EFI status codes are
64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG
to bridge those status codes with U-Boot's BITS_PER_LONG.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- Rework the patch to fix 64-bit payload boot issue

 arch/x86/include/asm/types.h |  4 ----
 include/efi.h                | 32 ++++++++++++++++++++------------
 2 files changed, 20 insertions(+), 16 deletions(-)

Comments

Bin Meng Aug. 29, 2016, 1:47 a.m. UTC | #1
Hi Simon,

On Thu, Aug 25, 2016 at 4:47 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> There are lots of warnings when building EFI 64-bit payload.
>
> include/asm-generic/bitops/__fls.h:17:2:
>   warning: left shift count >= width of type
>         if (!(word & (~0ul << 32))) {
>                         ^
>
> In fact, U-Boot itself as EFI payload is running in 32-bit mode.
> So BITS_PER_LONG needs to still be 32, but EFI status codes are
> 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG
> to bridge those status codes with U-Boot's BITS_PER_LONG.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - Rework the patch to fix 64-bit payload boot issue
>
>  arch/x86/include/asm/types.h |  4 ----
>  include/efi.h                | 32 ++++++++++++++++++++------------
>  2 files changed, 20 insertions(+), 16 deletions(-)
>

Please have a look at this.

Regards,
Bin
Simon Glass Aug. 29, 2016, 7:38 p.m. UTC | #2
On 25 August 2016 at 02:47, Bin Meng <bmeng.cn@gmail.com> wrote:
> There are lots of warnings when building EFI 64-bit payload.
>
> include/asm-generic/bitops/__fls.h:17:2:
>   warning: left shift count >= width of type
>         if (!(word & (~0ul << 32))) {
>                         ^
>
> In fact, U-Boot itself as EFI payload is running in 32-bit mode.
> So BITS_PER_LONG needs to still be 32, but EFI status codes are
> 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG
> to bridge those status codes with U-Boot's BITS_PER_LONG.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - Rework the patch to fix 64-bit payload boot issue
>
>  arch/x86/include/asm/types.h |  4 ----
>  include/efi.h                | 32 ++++++++++++++++++++------------
>  2 files changed, 20 insertions(+), 16 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Bin Meng Aug. 30, 2016, 1:29 a.m. UTC | #3
On Tue, Aug 30, 2016 at 3:38 AM, Simon Glass <sjg@chromium.org> wrote:
> On 25 August 2016 at 02:47, Bin Meng <bmeng.cn@gmail.com> wrote:
>> There are lots of warnings when building EFI 64-bit payload.
>>
>> include/asm-generic/bitops/__fls.h:17:2:
>>   warning: left shift count >= width of type
>>         if (!(word & (~0ul << 32))) {
>>                         ^
>>
>> In fact, U-Boot itself as EFI payload is running in 32-bit mode.
>> So BITS_PER_LONG needs to still be 32, but EFI status codes are
>> 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG
>> to bridge those status codes with U-Boot's BITS_PER_LONG.
>>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>
>> ---
>>
>> Changes in v2:
>> - Rework the patch to fix 64-bit payload boot issue
>>
>>  arch/x86/include/asm/types.h |  4 ----
>>  include/efi.h                | 32 ++++++++++++++++++++------------
>>  2 files changed, 20 insertions(+), 16 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

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

Patch

diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index 766617f..880dcb4 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -44,11 +44,7 @@  typedef __INT64_TYPE__ s64;
 typedef __UINT64_TYPE__ u64;
 #endif
 
-#ifdef CONFIG_EFI_STUB_64BIT
-#define BITS_PER_LONG 64
-#else
 #define BITS_PER_LONG 32
-#endif
 /* Dma addresses are 32-bits wide.  */
 
 typedef u32 dma_addr_t;
diff --git a/include/efi.h b/include/efi.h
index 21921f1..83de2d4 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -27,19 +27,27 @@ 
 
 struct efi_device_path;
 
+#define EFI_BITS_PER_LONG	BITS_PER_LONG
+
+/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
+#ifdef CONFIG_EFI_STUB_64BIT
+#undef EFI_BITS_PER_LONG
+#define EFI_BITS_PER_LONG	64
+#endif
+
 #define EFI_SUCCESS		0
-#define EFI_LOAD_ERROR		(1 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_INVALID_PARAMETER	(2 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_UNSUPPORTED		(3 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_BAD_BUFFER_SIZE	(4 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_BUFFER_TOO_SMALL	(5 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_NOT_READY		(6 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_DEVICE_ERROR	(7 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_WRITE_PROTECTED	(8 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_OUT_OF_RESOURCES	(9 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_NOT_FOUND		(14 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_ACCESS_DENIED	(15 | (1UL << (BITS_PER_LONG - 1)))
-#define EFI_SECURITY_VIOLATION	(26 | (1UL << (BITS_PER_LONG - 1)))
+#define EFI_LOAD_ERROR		(1 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_INVALID_PARAMETER	(2 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_UNSUPPORTED		(3 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_BAD_BUFFER_SIZE	(4 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_BUFFER_TOO_SMALL	(5 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_NOT_READY		(6 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_DEVICE_ERROR	(7 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_WRITE_PROTECTED	(8 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_OUT_OF_RESOURCES	(9 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_NOT_FOUND		(14 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_ACCESS_DENIED	(15 | (1UL << (EFI_BITS_PER_LONG - 1)))
+#define EFI_SECURITY_VIOLATION	(26 | (1UL << (EFI_BITS_PER_LONG - 1)))
 
 typedef unsigned long efi_status_t;
 typedef u64 efi_physical_addr_t;