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

Commit fe1372ae authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov Committed by Gerrit - the friendly Code Review server
Browse files

ARM: option for loading modules into vmalloc area



Usually modules are loaded into small area prior to the kernel
text because they are linked with the kernel using short calls.
Compile-time instrumentation like GCOV or KASAN bloats code a lot,
and as a result huge modules no longer fit into reserved area.

This patch adds option CONFIG_MODULES_USE_VMALLOC which lifts
limitation on amount of loaded modules. It links modules using
long-calls (option -mlong-calls) and loads them into vmalloc area.

In few places exported symbols are called from inline assembly.
This patch adds macro for such call sites: __asmbl and __asmbl_clobber.
Call turns into single 'bl' or sequence 'movw; movt; blx' depending on
context and state of config option.

Unfortunately this option isn't compatible with CONFIG_FUNCTION_TRACER.
Compiler emits short calls to profiling function despite of -mlong-calls.
This is a bug in GCC, but ftrace anyway needs an update to handle this.

Signed-off-by: default avatarKonstantin Khlebnikov <k.khlebnikov@samsung.com>
Patch-mainline: linux-arm-kernel @ 18/11/2014, 20:21:46
Change-Id: Iea7990a033c060c26f5782125fb63d6f96a9d218
Signed-off-by: default avatarShubham Aggarwal <shubagga@codeaurora.org>
parent df1b567c
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1726,6 +1726,26 @@ config CPU_SW_DOMAIN_PAN
	  Their lower 1MB needs to remain accessible for the vectors, but
	  the remainder of userspace will become appropriately inaccessible.

config MODULES_USE_LONG_CALLS
	bool
	help
	  Use long calls for calling exported symbols.

config MODULES_USE_VMALLOC
	bool "Put modules into vmalloc area"
	select MODULES_USE_LONG_CALLS
	depends on MMU && MODULES
	depends on !XIP_KERNEL
	depends on !FUNCTION_TRACER
	help
	  Usually modules are loaded into small area prior to the kernel text
	  because they are linked with the kernel using short calls.

	  This option enables long calls and moves modules into vmalloc area.
	  This allows to load more modules but adds some perfromance penalty.

	  If unsure, say n.

config HW_PERF_EVENTS
	def_bool y
	depends on ARM_PMU
+4 −0
Original line number Diff line number Diff line
@@ -136,6 +136,10 @@ CFLAGS_ISA :=$(call cc-option,-marm,)
AFLAGS_ISA	:=$(CFLAGS_ISA)
endif

ifeq ($(CONFIG_MODULES_USE_LONG_CALLS),y)
CFLAGS_MODULE	+= -mlong-calls
endif

# Need -Uarm for gcc < 3.x
KBUILD_CFLAGS	+=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float $(call cc-option, -Uarm,)
KBUILD_AFLAGS	+=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
+13 −0
Original line number Diff line number Diff line
@@ -25,5 +25,18 @@
	  ".endif; "				\
	".endif\n\t"

/*
 * This is used for calling exported symbols from inline assembly code.
 */
#if defined(MODULE) && defined(CONFIG_MODULES_USE_LONG_CALLS)
#define __asmbl(cond, reg, target) \
	"movw	" reg ", #:lower16:" target "\n\t" \
	"movt	" reg ", #:upper16:" target "\n\t" \
	"blx" cond "	" reg "\n\t"
#define __asmbl_clobber(reg)	,reg
#else
#define __asmbl(cond, reg, target) "bl" cond "	" target"\n\t"
#define __asmbl_clobber(reg)
#endif

#endif /* __ASM_ARM_COMPILER_H */
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
		__asmeq("%1", "r2")
		__asmeq("%2", "r0")
		__asmeq("%3", "r4")
		"bl	__do_div64"
		__asmbl("", "ip",  "__do_div64")
		: "=r" (__rem), "=r" (__res)
		: "r" (__n), "r" (__base)
		: "ip", "lr", "cc");
+11 −0
Original line number Diff line number Diff line
@@ -45,6 +45,15 @@
 */
#define TASK_SIZE_26		(UL(1) << 26)

#ifdef CONFIG_MODULES_USE_VMALLOC
/*
 * Modules might be anywhere in the vmalloc area.
 */
#define MODULES_VADDR		VMALLOC_START
#define MODULES_END		VMALLOC_END

#else /* CONFIG_MODULES_USE_VMALLOC */

/*
 * The module space lives between the addresses given by TASK_SIZE
 * and PAGE_OFFSET - it must be within 32MB of the kernel text.
@@ -69,6 +78,8 @@
#define MODULES_END		(PAGE_OFFSET)
#endif

#endif /* CONFIG_MODULES_USE_VMALLOC */

/*
 * The XIP kernel gets mapped at the bottom of the module vm area.
 * Since we use sections to map it, this macro replaces the physical address
Loading