Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e651ea1 authored by Vineet Gupta's avatar Vineet Gupta
Browse files

ARC: Unaligned access emulation



ARC700 doesn't natively support unaligned access, but can be emulated
-Unaligned Access Exception
-Disassembly at the Fault address to find the exact insn (long/short)

Also per Arnd's comment, we runtime control it using 2 sysctl knobs:
* SYSCTL_ARCH_UNALIGN_ALLOW: Runtime enable/disble
* SYSCTL_ARCH_UNALIGN_NO_WARN: Warn on each emulation attempt

Originally contributed by Tim Yao <tim.yao@amlogic.com>

Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
Cc: Tim Yao <tim.yao@amlogic.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
parent bf14e3b9
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -336,6 +336,17 @@ config ARC_CURR_IN_REG
	  This reserved Register R25 to point to Current Task in
	  This reserved Register R25 to point to Current Task in
	  kernel mode. This saves memory access for each such access
	  kernel mode. This saves memory access for each such access



config ARC_MISALIGN_ACCESS
	bool "Emulate unaligned memory access (userspace only)"
	default N
	select SYSCTL_ARCH_UNALIGN_NO_WARN
	select SYSCTL_ARCH_UNALIGN_ALLOW
	help
	  This enables misaligned 16 & 32 bit memory access from user space.
	  Use ONLY-IF-ABS-NECESSARY as it will be very slow and also can hide
	  potential bugs in code

config ARC_STACK_NONEXEC
config ARC_STACK_NONEXEC
	bool "Make stack non-executable"
	bool "Make stack non-executable"
	default n
	default n
+0 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ generic-y += topology.h
generic-y += trace_clock.h
generic-y += trace_clock.h
generic-y += types.h
generic-y += types.h
generic-y += ucontext.h
generic-y += ucontext.h
generic-y += unaligned.h
generic-y += user.h
generic-y += user.h
generic-y += vga.h
generic-y += vga.h
generic-y += xor.h
generic-y += xor.h
+3 −0
Original line number Original line Diff line number Diff line
@@ -97,6 +97,9 @@ struct callee_regs {
	sp;			\
	sp;			\
})
})


/* return 1 if PC in delay slot */
#define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)

#define in_syscall(regs)    (regs->event & orig_r8_IS_SCALL)
#define in_syscall(regs)    (regs->event & orig_r8_IS_SCALL)
#define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT)
#define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT)


+29 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef _ASM_ARC_UNALIGNED_H
#define _ASM_ARC_UNALIGNED_H

/* ARC700 can't handle unaligned Data accesses. */

#include <asm-generic/unaligned.h>
#include <asm/ptrace.h>

#ifdef CONFIG_ARC_MISALIGN_ACCESS
int misaligned_fixup(unsigned long address, struct pt_regs *regs,
		     unsigned long cause, struct callee_regs *cregs);
#else
static inline int
misaligned_fixup(unsigned long address, struct pt_regs *regs,
		 unsigned long cause, struct callee_regs *cregs)
{
	return 0;
}
#endif

#endif /* _ASM_ARC_UNALIGNED_H */
+1 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ obj-$(CONFIG_MODULES) += arcksyms.o module.o
obj-$(CONFIG_SMP) 			+= smp.o
obj-$(CONFIG_SMP) 			+= smp.o
obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
obj-$(CONFIG_KPROBES)      		+= kprobes.o
obj-$(CONFIG_KPROBES)      		+= kprobes.o
obj-$(CONFIG_ARC_MISALIGN_ACCESS) 	+= unaligned.o


obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
CFLAGS_fpu.o   += -mdpfp
CFLAGS_fpu.o   += -mdpfp
Loading