diff mbox series

efi_loader: build warning in efi_tcg2.c

Message ID 20210528014748.24504-1-masahisa.kojima@linaro.org
State New
Headers show
Series efi_loader: build warning in efi_tcg2.c | expand

Commit Message

Masahisa Kojima May 28, 2021, 1:47 a.m. UTC
Building 32bit boards with the TCG2 protocol enabled leads to a build
warning due to a missing conversion.

    lib/efi_loader/efi_tcg2.c: In function 'tcg2_measure_pe_image':
    lib/efi_loader/efi_tcg2.c:856:47: error: cast from pointer to
    integer of different size [-Werror=pointer-to-int-cast]
      856 |  image_load_event->image_location_in_memory = (efi_physical_addr_t)efi;
          |                                               ^
    lib/efi_loader/efi_tcg2.c: In function 'efi_tcg2_hash_log_extend_event':
    lib/efi_loader/efi_tcg2.c:947:22: error: cast to pointer from integer
    of different size [-Werror=int-to-pointer-cast]
      947 |   ret = efi_check_pe((void *)data_to_hash, data_to_hash_len,
          |                      ^
    lib/efi_loader/efi_tcg2.c:953:28: error: cast to pointer from
    integer of different size [-Werror=int-to-pointer-cast]
      953 |   ret = tcg2_hash_pe_image((void *)data_to_hash, data_to_hash_len,
          |                            ^

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>

---
 lib/efi_loader/efi_tcg2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.17.1

Comments

Heinrich Schuchardt May 28, 2021, 8:09 a.m. UTC | #1
On 28.05.21 03:47, Masahisa Kojima wrote:
> Building 32bit boards with the TCG2 protocol enabled leads to a build

> warning due to a missing conversion.

>

>     lib/efi_loader/efi_tcg2.c: In function 'tcg2_measure_pe_image':

>     lib/efi_loader/efi_tcg2.c:856:47: error: cast from pointer to

>     integer of different size [-Werror=pointer-to-int-cast]

>       856 |  image_load_event->image_location_in_memory = (efi_physical_addr_t)efi;

>           |                                               ^

>     lib/efi_loader/efi_tcg2.c: In function 'efi_tcg2_hash_log_extend_event':

>     lib/efi_loader/efi_tcg2.c:947:22: error: cast to pointer from integer

>     of different size [-Werror=int-to-pointer-cast]

>       947 |   ret = efi_check_pe((void *)data_to_hash, data_to_hash_len,

>           |                      ^

>     lib/efi_loader/efi_tcg2.c:953:28: error: cast to pointer from

>     integer of different size [-Werror=int-to-pointer-cast]

>       953 |   ret = tcg2_hash_pe_image((void *)data_to_hash, data_to_hash_len,

>           |                            ^

>

> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>


I will squash the changes into your previous patch. Cf.

https://source.denx.de/u-boot/custodians/u-boot-efi/-/commit/fd22139cee34750500a5f4cf9f312818226a38e4

Best regards

Heinrich

> ---

>  lib/efi_loader/efi_tcg2.c | 10 +++++-----

>  1 file changed, 5 insertions(+), 5 deletions(-)

>

> diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c

> index 3dd417aa27..47bc371477 100644

> --- a/lib/efi_loader/efi_tcg2.c

> +++ b/lib/efi_loader/efi_tcg2.c

> @@ -853,7 +853,7 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,

>  	if (!image_load_event)

>  		return EFI_OUT_OF_RESOURCES;

>

> -	image_load_event->image_location_in_memory = (efi_physical_addr_t)efi;

> +	image_load_event->image_location_in_memory = (uintptr_t)efi;

>  	image_load_event->image_length_in_memory = efi_size;

>  	image_load_event->length_of_device_path = device_path_length;

>

> @@ -944,14 +944,14 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags,

>  	if (flags & PE_COFF_IMAGE) {

>  		IMAGE_NT_HEADERS32 *nt;

>

> -		ret = efi_check_pe((void *)data_to_hash, data_to_hash_len,

> -				   (void **)&nt);

> +		ret = efi_check_pe((void *)(uintptr_t)data_to_hash,

> +				   data_to_hash_len, (void **)&nt);

>  		if (ret != EFI_SUCCESS) {

>  			log_err("Not a valid PE-COFF file\n");

>  			goto out;

>  		}

> -		ret = tcg2_hash_pe_image((void *)data_to_hash, data_to_hash_len,

> -					 &digest_list);

> +		ret = tcg2_hash_pe_image((void *)(uintptr_t)data_to_hash,

> +					 data_to_hash_len, &digest_list);

>  	} else {

>  		ret = tcg2_create_digest((u8 *)(uintptr_t)data_to_hash,

>  					 data_to_hash_len, &digest_list);

>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 3dd417aa27..47bc371477 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -853,7 +853,7 @@  efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
 	if (!image_load_event)
 		return EFI_OUT_OF_RESOURCES;
 
-	image_load_event->image_location_in_memory = (efi_physical_addr_t)efi;
+	image_load_event->image_location_in_memory = (uintptr_t)efi;
 	image_load_event->image_length_in_memory = efi_size;
 	image_load_event->length_of_device_path = device_path_length;
 
@@ -944,14 +944,14 @@  efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags,
 	if (flags & PE_COFF_IMAGE) {
 		IMAGE_NT_HEADERS32 *nt;
 
-		ret = efi_check_pe((void *)data_to_hash, data_to_hash_len,
-				   (void **)&nt);
+		ret = efi_check_pe((void *)(uintptr_t)data_to_hash,
+				   data_to_hash_len, (void **)&nt);
 		if (ret != EFI_SUCCESS) {
 			log_err("Not a valid PE-COFF file\n");
 			goto out;
 		}
-		ret = tcg2_hash_pe_image((void *)data_to_hash, data_to_hash_len,
-					 &digest_list);
+		ret = tcg2_hash_pe_image((void *)(uintptr_t)data_to_hash,
+					 data_to_hash_len, &digest_list);
 	} else {
 		ret = tcg2_create_digest((u8 *)(uintptr_t)data_to_hash,
 					 data_to_hash_len, &digest_list);