Commit 12c16919 authored by Christoph Müllner's avatar Christoph Müllner Committed by Palmer Dabbelt

tools: selftests: riscv: Fix compile warnings in mm tests

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: default avatarChristoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20231123185821.2272504-6-christoph.muellner@vrull.euSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent e1baf5e6
...@@ -18,6 +18,8 @@ struct addresses { ...@@ -18,6 +18,8 @@ struct addresses {
int *on_56_addr; int *on_56_addr;
}; };
// Only works on 64 bit
#if __riscv_xlen == 64
static inline void do_mmaps(struct addresses *mmap_addresses) static inline void do_mmaps(struct addresses *mmap_addresses)
{ {
/* /*
...@@ -50,6 +52,7 @@ 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_addresses->on_56_addr =
mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0); mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0);
} }
#endif /* __riscv_xlen == 64 */
static inline int memory_layout(void) static inline int memory_layout(void)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment