diff mbox series

tools: testing: fix phys_addr_t size on 64-bit systems

Message ID 20241017165638.95602-1-lorenzo.stoakes@oracle.com (mailing list archive)
State New
Headers show
Series tools: testing: fix phys_addr_t size on 64-bit systems | expand

Commit Message

Lorenzo Stoakes Oct. 17, 2024, 4:56 p.m. UTC
The phys_addr_t size is predicated on whether CONFIG_PHYS_ADDR_T_64BIT is
set or not.

In the VMA tests, virt_to_phys() from tools/include/linux casts a volatile
void * pointer to phys_addr_t, if CONFIG_PHYS_ADDR_T_64BIT is not set, this
will be 32-bit and trigger a warning.

Obviously this might also lead to truncation, which we would rather avoid.

Fix this by adjusting the generation of generated/bit-length.h to generate
a CONFIG_PHYS_ADDR_T{bits}BIT define.

This does result in the generation of the useless CONFIG_PHYS_ADDR_T_32BIT
define for 32-bit systems, but this should have no effect, and makes
implementation of this easier.

This resolves the issue and the warning.

Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 tools/testing/shared/shared.mk | 1 +
 1 file changed, 1 insertion(+)

Comments

Liam R. Howlett Oct. 17, 2024, 5:11 p.m. UTC | #1
* Lorenzo Stoakes <lorenzo.stoakes@oracle.com> [241017 12:56]:
> The phys_addr_t size is predicated on whether CONFIG_PHYS_ADDR_T_64BIT is
> set or not.
> 
> In the VMA tests, virt_to_phys() from tools/include/linux casts a volatile
> void * pointer to phys_addr_t, if CONFIG_PHYS_ADDR_T_64BIT is not set, this
> will be 32-bit and trigger a warning.
> 
> Obviously this might also lead to truncation, which we would rather avoid.
> 
> Fix this by adjusting the generation of generated/bit-length.h to generate
> a CONFIG_PHYS_ADDR_T{bits}BIT define.
> 
> This does result in the generation of the useless CONFIG_PHYS_ADDR_T_32BIT
> define for 32-bit systems, but this should have no effect, and makes
> implementation of this easier.
> 
> This resolves the issue and the warning.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

Thanks, I just saw this, but your change fixes the vma test code for me.

Tested-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>

(both tags since I don't see the double tag in the submitting-patches
doc)

> ---
>  tools/testing/shared/shared.mk | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/shared/shared.mk b/tools/testing/shared/shared.mk
> index a6bc51d0b0bf..b37362224a73 100644
> --- a/tools/testing/shared/shared.mk
> +++ b/tools/testing/shared/shared.mk
> @@ -69,6 +69,7 @@ generated/bit-length.h: FORCE
>  	@if ! grep -qws CONFIG_$(LONG_BIT)BIT generated/bit-length.h; then   \
>  		echo "Generating $@";                                        \
>  		echo "#define CONFIG_$(LONG_BIT)BIT 1" > $@;                 \
> +		echo "#define CONFIG_PHYS_ADDR_T_$(LONG_BIT)BIT 1" > $@;     \
>  	fi
>  
>  FORCE: ;
> -- 
> 2.46.2
>
diff mbox series

Patch

diff --git a/tools/testing/shared/shared.mk b/tools/testing/shared/shared.mk
index a6bc51d0b0bf..b37362224a73 100644
--- a/tools/testing/shared/shared.mk
+++ b/tools/testing/shared/shared.mk
@@ -69,6 +69,7 @@  generated/bit-length.h: FORCE
 	@if ! grep -qws CONFIG_$(LONG_BIT)BIT generated/bit-length.h; then   \
 		echo "Generating $@";                                        \
 		echo "#define CONFIG_$(LONG_BIT)BIT 1" > $@;                 \
+		echo "#define CONFIG_PHYS_ADDR_T_$(LONG_BIT)BIT 1" > $@;     \
 	fi
 
 FORCE: ;