riscv: Avoid unaligned access when relocating modules
authorEmil Renner Berthing <kernel@esmil.dk>
Wed, 1 Nov 2023 18:32:59 +0000 (11:32 -0700)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 7 Nov 2023 22:59:30 +0000 (14:59 -0800)
commit8cbe0accc4a6ba7ed34812a1c7e1ba67e7f7b2a4
tree507e4c1a5cb4c6351359693d61471e89877c713c
parent0bb80ecc33a8fb5a682236443c1e740d5c917d1d
riscv: Avoid unaligned access when relocating modules

With the C-extension regular 32bit instructions are not
necessarily aligned on 4-byte boundaries. RISC-V instructions
are in fact an ordered list of 16bit little-endian
"parcels", so access the instruction as such.

This should also make the code work in case someone builds
a big-endian RISC-V machine.

Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20231101-module_relocations-v9-1-8dfa3483c400@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/module.c