diff mbox series

[5/5] tools: selftests: riscv: Fix compile warnings in mm tests

Message ID 20231123185821.2272504-6-christoph.muellner@vrull.eu (mailing list archive)
State Accepted
Commit 12c16919652b5873f524c8b361336ecfa5ce5e6b
Headers show
Series tools: selftests: riscv: Fix compiler warnings | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-5-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-5-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-5-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-5-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-5-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-5-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-5-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-5-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-5-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-5-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-5-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-5-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

Christoph Müllner Nov. 23, 2023, 6:58 p.m. UTC
From: Christoph Müllner <christoph.muellner@vrull.eu>

When building the mm tests with a riscv32 compiler, we see a range
of shift-count-overflow errors from shifting 1UL by more than 32 bits
in do_mmaps(). Since, the relevant code is only called from code that
is gated by `__riscv_xlen == 64`, we can just apply the same gating
to do_mmaps().

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
 tools/testing/selftests/riscv/mm/mmap_test.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Alexandre Ghiti Dec. 15, 2023, 1:50 p.m. UTC | #1
On 23/11/2023 19:58, Christoph Muellner wrote:
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> When building the mm tests with a riscv32 compiler, we see a range
> of shift-count-overflow errors from shifting 1UL by more than 32 bits
> in do_mmaps(). Since, the relevant code is only called from code that
> is gated by `__riscv_xlen == 64`, we can just apply the same gating
> to do_mmaps().
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>   tools/testing/selftests/riscv/mm/mmap_test.h | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/riscv/mm/mmap_test.h b/tools/testing/selftests/riscv/mm/mmap_test.h
> index 9b8434f62f57..2e0db9c5be6c 100644
> --- a/tools/testing/selftests/riscv/mm/mmap_test.h
> +++ b/tools/testing/selftests/riscv/mm/mmap_test.h
> @@ -18,6 +18,8 @@ struct addresses {
>   	int *on_56_addr;
>   };
>   
> +// Only works on 64 bit
> +#if __riscv_xlen == 64
>   static inline void do_mmaps(struct addresses *mmap_addresses)
>   {
>   	/*
> @@ -50,6 +52,7 @@ static inline void do_mmaps(struct addresses *mmap_addresses)
>   	mmap_addresses->on_56_addr =
>   		mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0);
>   }
> +#endif /* __riscv_xlen == 64 */
>   
>   static inline int memory_layout(void)
>   {


You can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks!

Alex
diff mbox series

Patch

diff --git a/tools/testing/selftests/riscv/mm/mmap_test.h b/tools/testing/selftests/riscv/mm/mmap_test.h
index 9b8434f62f57..2e0db9c5be6c 100644
--- a/tools/testing/selftests/riscv/mm/mmap_test.h
+++ b/tools/testing/selftests/riscv/mm/mmap_test.h
@@ -18,6 +18,8 @@  struct addresses {
 	int *on_56_addr;
 };
 
+// Only works on 64 bit
+#if __riscv_xlen == 64
 static inline void do_mmaps(struct addresses *mmap_addresses)
 {
 	/*
@@ -50,6 +52,7 @@  static inline void do_mmaps(struct addresses *mmap_addresses)
 	mmap_addresses->on_56_addr =
 		mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0);
 }
+#endif /* __riscv_xlen == 64 */
 
 static inline int memory_layout(void)
 {