linux/arch/riscv/mm
Karl Mehltretter d4f25b097e riscv: fix load_unaligned_zeropad() fixup for RV32
The fixup for load_unaligned_zeropad() runs when REG_L crosses into an
unmapped page. REG_L is lw on RV32 and ld on RV64, but the fixup assumes
an 8-byte load: it rounds the address down to 8 bytes and derives the
shift from three address bits.

On RV32, a load starting in the last three bytes of a mapped page selects
the word four bytes earlier and shifts it by 40, 48, or 56 bits, more than
the register width. The caller gets earlier bytes instead of the string
tail followed by zeroes. This affects RV32 MMU kernels built with
RISCV_EFFICIENT_UNALIGNED_ACCESS=y, which selects DCACHE_WORD_ACCESS
and lets dcache name hashing and comparison and strscpy() use this
path.

Derive the alignment and offset masks from sizeof(data) instead of a fixed
8. This makes RV32 use the correct source word. RV64 code is unchanged: the
complete extable.o is byte-for-byte identical before and after.

Fixes: d0fdc20b04 ("riscv: select DCACHE_WORD_ACCESS for efficient unaligned access HW")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://patch.msgid.link/20260907190750.26303-1-kmehltretter@gmail.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
History 2026-10-07 20:25:09 -06:00
..
cache-ops.c riscv: split cache ops out of dma-noncoherent.c 2023-11-07 09:37:42 -08:00
cacheflush.c riscv: fix various typos in comments and code 2026-04-04 18:42:39 -06:00
context.c riscv: Fix a comment typo in set_mm_asid() 2025-03-18 13:02:47 +00:00
dma-noncoherent.c driver core: Replace dev->dma_coherent with dev_dma_coherent() 2026-04-26 23:43:58 +02:00
extable.c riscv: fix load_unaligned_zeropad() fixup for RV32 2026-10-07 20:25:09 -06:00
fault.c riscv: mm: Add page fault trace points 2025-07-09 15:27:01 -04:00
hugetlbpage.c mm, arch: consolidate hugetlb CMA reservation 2026-01-26 20:02:19 -08:00
init.c riscv: mm: make EXECMEM_KPROBES writable without CONFIG_STRICT_MODULE_RWX 2026-08-31 19:11:22 -06:00
kasan_init.c riscv: remove unreachable invalid range check in kasan_init() 2026-07-01 09:22:40 +03:00
Makefile mm: rename GENERIC_PTDUMP and PTDUMP_CORE 2025-03-17 00:05:32 -07:00
pageattr.c mm/pagewalk: split walk_page_range_novma() into kernel/user parts 2025-07-09 22:42:05 -07:00
pgtable.c mm: change to return bool for ptep_test_and_clear_young() 2026-04-05 13:53:35 -07:00
physaddr.c riscv: fix various typos in comments and code 2026-04-04 18:42:39 -06:00
pmem.c RISC-V: capitalise CMO op macros 2023-11-05 09:11:23 -08:00
ptdump.c riscv: ptdump: Replace unbounded sprintf() in dump_prot() 2026-06-06 20:17:52 -06:00
tlbflush.c riscv: mm: Apply Svinval in update_mmu_cache() 2026-08-07 19:24:29 -06:00