Skip to content

Commit 31fb6f4

Browse files
mariobalanica6by9
authored andcommitted
arm64: mm: Handle alignment faults
Allow kernel/user space code to perform unaligned accesses to memory regions that do not normally support them (e.g. device mappings) by trapping alignment faults on common load/store instructions and breaking up the offending accesses into naturally aligned ones. Signed-off-by: Mario Bălănică <mariobalanica02@gmail.com>
1 parent 0deed8f commit 31fb6f4

File tree

5 files changed

+1046
-2
lines changed

5 files changed

+1046
-2
lines changed

arch/arm64/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,15 @@ config ARM64_TAGGED_ADDR_ABI
16961696
to system calls as pointer arguments. For details, see
16971697
Documentation/arch/arm64/tagged-address-abi.rst.
16981698

1699+
config ARM64_ALIGNMENT_FIXUPS
1700+
bool "Fix up misaligned multi-word loads and stores in 64-bit kernel/user space"
1701+
default y
1702+
help
1703+
This option enables kernel/user space code to perform unaligned accesses
1704+
to memory regions that do not normally support them (e.g. device mappings)
1705+
by trapping alignment faults on common load/store instructions and breaking
1706+
up the offending accesses into properly aligned ones.
1707+
16991708
menuconfig COMPAT
17001709
bool "Kernel support for 32-bit EL0"
17011710
depends on ARM64_4K_PAGES || EXPERT

arch/arm64/include/asm/exception.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void do_sp_pc_abort(unsigned long addr, unsigned long esr, struct pt_regs *regs)
8282
void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr);
8383
void do_el0_cp15(unsigned long esr, struct pt_regs *regs);
8484
int do_compat_alignment_fixup(unsigned long addr, struct pt_regs *regs);
85+
int do_alignment_fixup(unsigned long addr, unsigned int esr, struct pt_regs *regs);
8586
void do_el0_svc(struct pt_regs *regs);
8687
void do_el0_svc_compat(struct pt_regs *regs);
8788
void do_el0_fpac(struct pt_regs *regs, unsigned long esr);

arch/arm64/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \
3636
syscall.o proton-pack.o idle.o patching.o pi/ \
3737
rsi.o jump_label.o
3838

39+
obj-$(CONFIG_ARM64_ALIGNMENT_FIXUPS) += alignment.o
3940
obj-$(CONFIG_COMPAT) += sys32.o signal32.o \
4041
sys_compat.o
4142
obj-$(CONFIG_COMPAT) += sigreturn32.o

0 commit comments

Comments
 (0)