Skip to contentSkip to conversation

drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size

PATCH In review kbuild test robot 5 participants 7 messages Dec 19, 2016 – Jan 4, 2017 5 messages not in the archive EFI

lore
Share & tools
lore

kbuild test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git urgent
head:   5615742edc64c99bbdec5e98bf9d9d872756d99c
commit: 5615742edc64c99bbdec5e98bf9d9d872756d99c [1/1] efi/libstub: arm*: Pass latest memory map to the kernel
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git checkout 5615742edc64c99bbdec5e98bf9d9d872756d99c
# save the attached .config to linux build tree
make.cross ARCH=arm

All warnings (new ones prefixed by >>):

drivers/firmware/efi/libstub/fdt.c: In function 'allocate_new_fdt_and_exit_boot':

>> drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
            (u64)memory_map, (u32)map_size);
            ^

vim +303 drivers/firmware/efi/libstub/fdt.c

287 new_fdt_size += EFI_PAGE_SIZE;
288 } else {
289 pr_efi_err(sys_table, "Unable to construct new device tree.\n");
290 goto fail_free_new_fdt;
291 }
292 }
293
294 priv.runtime_map = runtime_map;
295 priv.runtime_entry_count = &runtime_entry_count;
296 status = efi_exit_boot_services(sys_table, handle, &map, &priv,
297 exit_boot_func);
298
299 if (status == EFI_SUCCESS) {
300 efi_set_virtual_address_map_t *svam;
301
302 status = update_fdt_memmap((void *)*new_fdt_addr,

 > 303						   (u64)memory_map, (u32)map_size);

304 if (status != EFI_SUCCESS) {
305 /*
306 * The kernel won't get far without the memory map, but
307 * may still be able to print something meaningful so
308 * return success here.
309 */
310 return EFI_SUCCESS;
311 }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

A message that is not in the archive (sent off-list or not yet received): 201612200741.F41hYqms%[email protected]

#2 lore raw
Quoted 38 lines · Fengguang Wu
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git urgent
head:   5615742edc64c99bbdec5e98bf9d9d872756d99c
commit: 5615742edc64c99bbdec5e98bf9d9d872756d99c [1/1] efi/libstub: arm*: Pass latest memory map to the kernel
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git checkout 5615742edc64c99bbdec5e98bf9d9d872756d99c
# save the attached .config to linux build tree
make.cross ARCH=arm

All warnings (new ones prefixed by >>):

drivers/firmware/efi/libstub/fdt.c: In function 'allocate_new_fdt_and_exit_boot':

Quoted 1 line
Quoted 1 line

drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

            (u64)memory_map, (u32)map_size);
            ^

vim +303 drivers/firmware/efi/libstub/fdt.c

   287				new_fdt_size += EFI_PAGE_SIZE;
   288			} else {
   289				pr_efi_err(sys_table, "Unable to construct new device tree.\n");
   290				goto fail_free_new_fdt;
   291			}
   292		}
   293	
   294		priv.runtime_map = runtime_map;
   295		priv.runtime_entry_count = &runtime_entry_count;
   296		status = efi_exit_boot_services(sys_table, handle, &map, &priv,
   297						exit_boot_func);
   298	
   299		if (status == EFI_SUCCESS) {
   300			efi_set_virtual_address_map_t *svam;
   301	
   302			status = update_fdt_memmap((void *)*new_fdt_addr,
Quoted 1 line

303 (u64)memory_map, (u32)map_size);

Quoted 9 lines
   304			if (status != EFI_SUCCESS) {
   305				/*
   306				 * The kernel won't get far without the memory map, but
   307				 * may still be able to print something meaningful so
   308				 * return success here.
   309				 */
   310				return EFI_SUCCESS;
   311			}

James, could you take care of fixing this up? You need to cast memory_map to unsigned long before u64 on ARM.

A message that is not in the archive (sent off-list or not yet received): 20161220113956.GB2225-mF/unelCI9GS6iBeEJttW/[email protected]

#4 lore raw

Hi Matt,

Quoted 2 lines · Matt Fleming

James, could you take care of fixing this up? You need to cast memory_map to unsigned long before u64 on ARM.

Yes, sure - sorry I didn't spot this. It turns out my ARM config didn't build the EFI stub. Oops.

Fixup patch incoming,

Thanks,

James

#5 lore raw

PATCH 1/1 efi/libstub: arm*: double cast memory_map to hide compiler warning

In reply to a message not in the archive

"efi/libstub: arm*: Pass latest memory map to the kernel" added a new call to update fdt in-place. This caused a new warning on 32bit ARM:

../drivers/firmware/efi/libstub/fdt.c: In function 'allocate_new_fdt_and_exit_boot':
../drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

         (u64)memory_map, (u32)map_size);
         ^

Cast to an integer of native pointer size first.

---
I guess this too needs to go to stable unless you intend to squash it?

 drivers/firmware/efi/libstub/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/firmware/efi/libstub/fdt.c +2 -1
index 6d33d70..9b11b05 100644
@@ -300,7 +300,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
 		efi_set_virtual_address_map_t *svam;
 
 		status = update_fdt_memmap((void *)*new_fdt_addr,
-					   (u64)memory_map, (u32)map_size);
+					   (u64)(unsigned long)memory_map,
+					   (u32)map_size);
 		if (status != EFI_SUCCESS) {
 			/*
 			 * The kernel won't get far without the memory map, but
Signature · 1 line
2.10.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Re: [PATCH] efi/libstub: arm*: double cast memory_map to hide compiler warning

Quoted 10 lines · James Morse

"efi/libstub: arm*: Pass latest memory map to the kernel" added a new call to update fdt in-place. This caused a new warning on 32bit ARM:

../drivers/firmware/efi/libstub/fdt.c: In function 'allocate_new_fdt_and_exit_boot':
../drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

         (u64)memory_map, (u32)map_size);
         ^

Cast to an integer of native pointer size first.

Quoted 7 lines

---
I guess this too needs to go to stable unless you intend to squash it?

 drivers/firmware/efi/libstub/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Thanks James, I've folded this into your previous patch.

A message that is not in the archive (sent off-list or not yet received): 20161220140728.GE2225-mF/unelCI9GS6iBeEJttW/[email protected]

#9 lore raw

Re: [PATCH] efi/libstub: arm*: double cast memory_map to hide compiler warning

Quoted 16 lines · Matt Fleming
Quoted 15 lines · James Morse

"efi/libstub: arm*: Pass latest memory map to the kernel" added a new call to update fdt in-place. This caused a new warning on 32bit ARM:

../drivers/firmware/efi/libstub/fdt.c: In function 'allocate_new_fdt_and_exit_boot':
../drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

         (u64)memory_map, (u32)map_size);
         ^

Cast to an integer of native pointer size first.

---
I guess this too needs to go to stable unless you intend to squash it?

Quoted 9 lines
Quoted 2 lines
 drivers/firmware/efi/libstub/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Thanks James, I've folded this into your previous patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks James. I'm happy to see this got cleaned up and sorted out while I was on vacation. I see Ard submitted a pull request already, but for what its worth, the latest version on the EFI urgent branch tested ok on the platforms I have available.

Signature · 4 lines
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

A message that is not in the archive (sent off-list or not yet received): 976c2a58-7522-96d5-7b37-2baffdaa409d-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#11 lore raw

Re: [PATCH] efi/libstub: arm*: double cast memory_map to hide compiler warning

Quoted 32 lines · Jeffrey Hugo
Quoted 24 lines · Matt Fleming
Quoted 13 lines · James Morse

"efi/libstub: arm*: Pass latest memory map to the kernel" added a new call to update fdt in-place. This caused a new warning on 32bit ARM:

../drivers/firmware/efi/libstub/fdt.c: In function 'allocate_new_fdt_and_exit_boot':
../drivers/firmware/efi/libstub/fdt.c:303:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

         (u64)memory_map, (u32)map_size);
         ^

Cast to an integer of native pointer size first.

Quoted 7 lines

---
I guess this too needs to go to stable unless you intend to squash it?

 drivers/firmware/efi/libstub/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 6 lines

Thanks James, I've folded this into your previous patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 5 lines

Thanks James. I'm happy to see this got cleaned up and sorted out while I was on vacation. I see Ard submitted a pull request already, but for what its worth, the latest version on the EFI urgent branch tested ok on the platforms I have available.

Thanks for confirming

Cheers,
Ard.