* [PATCH] tools: testing: fix phys_addr_t size on 64-bit systems
@ 2024-10-17 16:56 Lorenzo Stoakes
2024-10-17 17:11 ` Liam R. Howlett
2024-10-22 14:03 ` Lorenzo Stoakes
0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Stoakes @ 2024-10-17 16:56 UTC (permalink / raw)
To: Andrew Morton
Cc: Liam R . Howlett, Vlastimil Babka, Jann Horn, linux-mm, linux-kernel
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(+)
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: testing: fix phys_addr_t size on 64-bit systems
2024-10-17 16:56 [PATCH] tools: testing: fix phys_addr_t size on 64-bit systems Lorenzo Stoakes
@ 2024-10-17 17:11 ` Liam R. Howlett
2024-10-22 14:03 ` Lorenzo Stoakes
1 sibling, 0 replies; 3+ messages in thread
From: Liam R. Howlett @ 2024-10-17 17:11 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Andrew Morton, Vlastimil Babka, Jann Horn, linux-mm, linux-kernel
* 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: testing: fix phys_addr_t size on 64-bit systems
2024-10-17 16:56 [PATCH] tools: testing: fix phys_addr_t size on 64-bit systems Lorenzo Stoakes
2024-10-17 17:11 ` Liam R. Howlett
@ 2024-10-22 14:03 ` Lorenzo Stoakes
1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Stoakes @ 2024-10-22 14:03 UTC (permalink / raw)
To: Andrew Morton
Cc: Liam R . Howlett, Vlastimil Babka, Jann Horn, linux-mm, linux-kernel
On Thu, Oct 17, 2024 at 05:56:38PM +0100, Lorenzo Stoakes wrote:
> 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(+)
>
> 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
>
Andrew - apologies, I made a mistake here, VMA tests are not properly
importing the bit-length.h header (the radix tree tests do appear to be)
and we are overwriting that constant (ahem)...
Could you apply the following fix-patch? Thanks!
----8<----
From 92c247fe99b57f14b91c5e7479cb29616f0c8281 Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Date: Tue, 22 Oct 2024 15:01:58 +0100
Subject: [PATCH] correctly set bit length in VMA and radix tree tests
---
tools/testing/shared/shared.mk | 2 +-
tools/testing/vma/vma.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/shared/shared.mk b/tools/testing/shared/shared.mk
index b37362224a73..923ee2492256 100644
--- a/tools/testing/shared/shared.mk
+++ b/tools/testing/shared/shared.mk
@@ -69,7 +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" > $@; \
+ echo "#define CONFIG_PHYS_ADDR_T_$(LONG_BIT)BIT 1" >> $@; \
fi
FORCE: ;
diff --git a/tools/testing/vma/vma.c b/tools/testing/vma/vma.c
index b33b47342d41..8fab5e13c7c3 100644
--- a/tools/testing/vma/vma.c
+++ b/tools/testing/vma/vma.c
@@ -4,6 +4,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include "generated/bit-length.h"
+
#include "maple-shared.h"
#include "vma_internal.h"
--
2.47.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-22 14:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-17 16:56 [PATCH] tools: testing: fix phys_addr_t size on 64-bit systems Lorenzo Stoakes
2024-10-17 17:11 ` Liam R. Howlett
2024-10-22 14:03 ` Lorenzo Stoakes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox