diff mbox series

riscv: fixup endian issues in module code

Message ID 20231122104547.256286-1-ben.dooks@codethink.co.uk (mailing list archive)
State Superseded, archived
Headers show
Series riscv: fixup endian issues in module code | expand

Checks

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

Commit Message

Ben Dooks Nov. 22, 2023, 10:45 a.m. UTC
There is a couple of places in the module.c file where it
is using u16 where it meant __le16. Change this and fix
the following sparse warnings:

arch/riscv/kernel/module.c:68:25: warning: cast to restricted __le16
arch/riscv/kernel/module.c:68:55: warning: cast to restricted __le16
arch/riscv/kernel/module.c:73:19: warning: incorrect type in assignment (different base types)
arch/riscv/kernel/module.c:73:19:    expected unsigned short [usertype]
arch/riscv/kernel/module.c:73:19:    got restricted __le16 [usertype]
arch/riscv/kernel/module.c:74:19: warning: incorrect type in assignment (different base types)
arch/riscv/kernel/module.c:74:19:    expected unsigned short [usertype]
arch/riscv/kernel/module.c:74:19:    got restricted __le16 [usertype]
arch/riscv/kernel/module.c:81:20: warning: cast to restricted __le16
arch/riscv/kernel/module.c:86:17: warning: incorrect type in assignment (different base types)
arch/riscv/kernel/module.c:86:17:    expected unsigned short [usertype]
arch/riscv/kernel/module.c:86:17:    got restricted __le16 [usertype]

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/riscv/kernel/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Charlie Jenkins Dec. 2, 2023, 2:05 a.m. UTC | #1
On Wed, Nov 22, 2023 at 10:45:47AM +0000, Ben Dooks wrote:
> There is a couple of places in the module.c file where it
> is using u16 where it meant __le16. Change this and fix
> the following sparse warnings:
> 
> arch/riscv/kernel/module.c:68:25: warning: cast to restricted __le16
> arch/riscv/kernel/module.c:68:55: warning: cast to restricted __le16
> arch/riscv/kernel/module.c:73:19: warning: incorrect type in assignment (different base types)
> arch/riscv/kernel/module.c:73:19:    expected unsigned short [usertype]
> arch/riscv/kernel/module.c:73:19:    got restricted __le16 [usertype]
> arch/riscv/kernel/module.c:74:19: warning: incorrect type in assignment (different base types)
> arch/riscv/kernel/module.c:74:19:    expected unsigned short [usertype]
> arch/riscv/kernel/module.c:74:19:    got restricted __le16 [usertype]
> arch/riscv/kernel/module.c:81:20: warning: cast to restricted __le16
> arch/riscv/kernel/module.c:86:17: warning: incorrect type in assignment (different base types)
> arch/riscv/kernel/module.c:86:17:    expected unsigned short [usertype]
> arch/riscv/kernel/module.c:86:17:    got restricted __le16 [usertype]
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/riscv/kernel/module.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
> index b5109a3889c9..82f9266ae434 100644
> --- a/arch/riscv/kernel/module.c
> +++ b/arch/riscv/kernel/module.c
> @@ -64,7 +64,7 @@ static bool riscv_insn_valid_32bit_offset(ptrdiff_t val)
>  
>  static int riscv_insn_rmw(void *location, u32 keep, u32 set)
>  {
> -	u16 *parcel = location;
> +	__le16 *parcel = location;
>  	u32 insn = (u32)le16_to_cpu(parcel[0]) | (u32)le16_to_cpu(parcel[1]) << 16;
>  
>  	insn &= keep;
> @@ -77,7 +77,7 @@ static int riscv_insn_rmw(void *location, u32 keep, u32 set)
>  
>  static int riscv_insn_rvc_rmw(void *location, u16 keep, u16 set)
>  {
> -	u16 *parcel = location;
> +	__le16  *parcel = location;
>  	u16 insn = le16_to_cpu(*parcel);
>  
>  	insn &= keep;
> -- 
> 2.37.2.352.g3c44437643
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

We had the same idea :). I sent out a patch with the same changes a
couple days before this [1]. I did some shuffling of my series and the
patch ended up in [2] which will hopefully end up in an rc soon.

[1] https://lore.kernel.org/lkml/20231117-module_fixup-v1-2-62bb777f6825@rivosinc.com/
[2] https://lore.kernel.org/linux-riscv/20231127-module_linking_freeing-v4-2-a2ca1d7027d0@rivosinc.com/
diff mbox series

Patch

diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index b5109a3889c9..82f9266ae434 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -64,7 +64,7 @@  static bool riscv_insn_valid_32bit_offset(ptrdiff_t val)
 
 static int riscv_insn_rmw(void *location, u32 keep, u32 set)
 {
-	u16 *parcel = location;
+	__le16 *parcel = location;
 	u32 insn = (u32)le16_to_cpu(parcel[0]) | (u32)le16_to_cpu(parcel[1]) << 16;
 
 	insn &= keep;
@@ -77,7 +77,7 @@  static int riscv_insn_rmw(void *location, u32 keep, u32 set)
 
 static int riscv_insn_rvc_rmw(void *location, u16 keep, u16 set)
 {
-	u16 *parcel = location;
+	__le16  *parcel = location;
 	u16 insn = le16_to_cpu(*parcel);
 
 	insn &= keep;