riscv: Fix default misaligned access trap
PATCH 1/1 riscv: Fix default misaligned access trap
Commit d1703dc7bc8e ("RISC-V: Detect unaligned vector accesses supported") removed the default handlers for handle_misaligned_load() and handle_misaligned_store(). When the kernel is compiled without RISCV_SCALAR_MISALIGNED, these handlers are never defined, causing compilation errors.
--- arch/riscv/include/asm/entry-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/riscv/include/asm/entry-common.h +12 -0
@@ -25,7 +25,19 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,void handle_page_fault (struct pt_regs *regs);void handle_break (struct pt_regs *regs); +#ifdef CONFIG_RISCV_SCALAR_MISALIGNED int handle_misaligned_load (struct pt_regs *regs);int handle_misaligned_store (struct pt_regs *regs); +#else +static inline int handle_misaligned_load (struct pt_regs *regs) +{ +return -1 ; +} + +static inline int handle_misaligned_store (struct pt_regs *regs) +{ +return -1 ; +} +#endif #endif /* _ASM_RISCV_ENTRY_COMMON_H */
---
base-commit: 74741a050b79d31d8d2eeee12c77736596d0a6b2
change-id: 20241107-fix_handle_misaligned_load-8be86cb0806e
Signature · 1 line
- Charlie
Quoted 5 lines · Charlie Jenkins
Commit
d1703dc7bc8e("RISC-V: Detect unaligned vector accesses supported") removed the default handlers forhandle_misaligned_load()andhandle_misaligned_store(). When the kernel is compiled withoutRISCV_SCALAR_MISALIGNED
Technically CONFIG_RISCV_MISALIGNED.
I apparently changed +obj-y += traps_misaligned.o to +obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.o in V2 and didn't change that check back oops sorry.
Quoted 4 lines
, these handlers are never defined, causing
compilation errors.Signed-off-by Charlie Jenkins <[email protected]>
Quoted 36 lines
Fixes d1703dc7bc8e ("RISC-V: Detect unaligned vector accesses supported")--- arch/riscv/include/asm/entry-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/riscv/include/asm/entry-common.h +12
-1@@ -25,7 +25,19 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,void handle_page_fault (struct pt_regs *regs);void handle_break (struct pt_regs *regs); +#ifdef CONFIG_RISCV_SCALAR_MISALIGNED int handle_misaligned_load (struct pt_regs *regs);int handle_misaligned_store (struct pt_regs *regs); +#else +static inline int handle_misaligned_load (struct pt_regs *regs) +{ +return -1 ; +} + +static inline int handle_misaligned_store (struct pt_regs *regs) +{ +return -1 ; +} +#endif #endif /* _ASM_RISCV_ENTRY_COMMON_H */ ---base-commit:
74741a050b79d31d8d2eeee12c77736596d0a6b2
change-id: 20241107-fix_handle_misaligned_load-8be86cb0806e --
- Charlie
Quoted 31 lines · Jesse T
Quoted 5 lines · Charlie Jenkins
Commit
d1703dc7bc8e("RISC-V: Detect unaligned vector accesses supported") removed the default handlers forhandle_misaligned_load()andhandle_misaligned_store(). When the kernel is compiled withoutRISCV_SCALAR_MISALIGNEDTechnically
CONFIG_RISCV_MISALIGNED.
I apparently changed+obj-y += traps_misaligned.oto+obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.oin V2 and didn't change that check back oops sorry.Quoted 4 lines
, these handlers are never defined, causing
compilation errors.Signed-off-by Charlie Jenkins <[email protected]>Signed-off-by Jesse Taube <[email protected]>Quoted 13 lines
Fixes d1703dc7bc8e ("RISC-V: Detect unaligned vector accesses supported")--- arch/riscv/include/asm/entry-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/riscv/include/asm/entry-common.h +0
-0@@ -25,7 +25,19 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,void handle_page_fault (struct pt_regs *regs);void handle_break (struct pt_regs *regs);
Quoted 1 line
arch/riscv/include/asm/entry-common.h static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, · line 28
Quoted 1 line
arch/riscv/include/asm/entry-common.h +1
-0+#ifdef CONFIG_RISCV_SCALAR_MISALIGNED
Meant to say to change this to CONFIG_RISCV_MISALIGNED.
As they are defined when CONFIG_RISCV_SCALAR_MISALIGNED is false and CONFIG_RISCV_VECTOE_MISALIGNED is true. they are only not defined when CONFIG_RISCV_SCALAR_MISALIGNED is false.
Quoted 22 lines
Quoted 22 lines
arch/riscv/include/asm/entry-common.h +11
-1int handle_misaligned_load (struct pt_regs *regs);int handle_misaligned_store (struct pt_regs *regs); +#else +static inline int handle_misaligned_load (struct pt_regs *regs) +{ +return -1 ; +} + +static inline int handle_misaligned_store (struct pt_regs *regs) +{ +return -1 ; +} +#endif #endif /* _ASM_RISCV_ENTRY_COMMON_H */ ---base-commit:
74741a050b79d31d8d2eeee12c77736596d0a6b2
change-id: 20241107-fix_handle_misaligned_load-8be86cb0806e --
- Charlie
Quoted 32 lines · Jesse T
Quoted 31 lines · Jesse T
Quoted 5 lines · Charlie Jenkins
Commit
d1703dc7bc8e("RISC-V: Detect unaligned vector accesses supported") removed the default handlers forhandle_misaligned_load()andhandle_misaligned_store(). When the kernel is compiled withoutRISCV_SCALAR_MISALIGNEDTechnically
CONFIG_RISCV_MISALIGNED.
I apparently changed+obj-y += traps_misaligned.oto+obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.oin V2 and didn't change that check back oops sorry.Quoted 4 lines
, these handlers are never defined, causing
compilation errors.Signed-off-by Charlie Jenkins <[email protected]>Signed-off-by Jesse Taube <[email protected]>Quoted 13 lines
Fixes d1703dc7bc8e ("RISC-V: Detect unaligned vector accesses supported")--- arch/riscv/include/asm/entry-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/riscv/include/asm/entry-common.h +0
-0@@ -25,7 +25,19 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,void handle_page_fault (struct pt_regs *regs);void handle_break (struct pt_regs *regs);
Quoted 6 lines
Quoted 1 line
arch/riscv/include/asm/entry-common.h static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, · line 28
Quoted 1 line
arch/riscv/include/asm/entry-common.h +1
-0+#ifdef CONFIG_RISCV_SCALAR_MISALIGNED Meant to say to change this to
CONFIG_RISCV_MISALIGNED.
As they are defined whenCONFIG_RISCV_SCALAR_MISALIGNEDis false andCONFIG_RISCV_VECTOE_MISALIGNEDis true. they are only not defined whenCONFIG_RISCV_SCALAR_MISALIGNEDis false.
Oh yes, thank you!
- Charlie
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
arch/riscv/include/asm/entry-common.h +11
-1int handle_misaligned_load (struct pt_regs *regs);int handle_misaligned_store (struct pt_regs *regs); +#else +static inline int handle_misaligned_load (struct pt_regs *regs) +{ +return -1 ; +} + +static inline int handle_misaligned_store (struct pt_regs *regs) +{ +return -1 ; +} +#endif #endif /* _ASM_RISCV_ENTRY_COMMON_H */ ---base-commit:
74741a050b79d31d8d2eeee12c77736596d0a6b2
change-id: 20241107-fix_handle_misaligned_load-8be86cb0806e --
- Charlie