public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] ARM: MMUless Core: Fix insmod error - module relocation out of range
@ 2012-10-03  3:43 Pratyush Anand
  2012-10-03  9:25 ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: Pratyush Anand @ 2012-10-03  3:43 UTC (permalink / raw)
  To: linux-arm-kernel

From: Neha MAKHIJA <neha.makhija-ext@st.com>

ARM supports 32Mb jump. Hence branch instruction has a limited range.

For MMU systems, the module area is located just before the kernel memory
because this allows function calls to be linked directly without any indirect
branches.

In case of MMU-less system, Module area is given whole of the DDR address
space.  Since, module_alloc() calls vmalloc(), the module area goes outside the
allowed jump range. Due to this insmod will not be able to load the modules
giving out of range relocation errors.

Solution - Add the mlong-calls flags while compiling the modules. This tells
the compiler to perform function calls by first loading the address of the
function and then performing a subroutine function call on this register.

Signed-off-by: Neha Makhija <neha.makhija-ext@st.com>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
---
 arch/arm/Makefile |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 88eec8f..78b5c12 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -112,6 +112,10 @@ CFLAGS_MODULE	+=-fno-optimize-sibling-calls
 endif
 endif
 
+ifeq ($(CONFIG_MMU),)
+CFLAGS_MODULE  +=-mlong-calls
+endif
+
 # Need -Uarm for gcc < 3.x
 KBUILD_CFLAGS	+=$(CFLAGS_ABI) $(CFLAGS_THUMB2) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
 KBUILD_AFLAGS	+=$(CFLAGS_ABI) $(AFLAGS_THUMB2) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] ARM: MMUless Core: Fix insmod error - module relocation out of range
  2012-10-03  3:43 [PATCH] ARM: MMUless Core: Fix insmod error - module relocation out of range Pratyush Anand
@ 2012-10-03  9:25 ` Catalin Marinas
  2012-10-03  9:48   ` Russell King - ARM Linux
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2012-10-03  9:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 3 October 2012 04:43, Pratyush Anand <pratyush.anand@st.com> wrote:
> From: Neha MAKHIJA <neha.makhija-ext@st.com>
>
> ARM supports 32Mb jump. Hence branch instruction has a limited range.
>
> For MMU systems, the module area is located just before the kernel memory
> because this allows function calls to be linked directly without any indirect
> branches.
>
> In case of MMU-less system, Module area is given whole of the DDR address
> space.  Since, module_alloc() calls vmalloc(), the module area goes outside the
> allowed jump range. Due to this insmod will not be able to load the modules
> giving out of range relocation errors.
>
> Solution - Add the mlong-calls flags while compiling the modules. This tells
> the compiler to perform function calls by first loading the address of the
> function and then performing a subroutine function call on this register.

Do we need the module loader to handle additional relocations or they
are all already handled?

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ARM: MMUless Core: Fix insmod error - module relocation out of range
  2012-10-03  9:25 ` Catalin Marinas
@ 2012-10-03  9:48   ` Russell King - ARM Linux
  2012-10-03 10:02     ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2012-10-03  9:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 03, 2012 at 10:25:09AM +0100, Catalin Marinas wrote:
> On 3 October 2012 04:43, Pratyush Anand <pratyush.anand@st.com> wrote:
> > From: Neha MAKHIJA <neha.makhija-ext@st.com>
> >
> > ARM supports 32Mb jump. Hence branch instruction has a limited range.
> >
> > For MMU systems, the module area is located just before the kernel memory
> > because this allows function calls to be linked directly without any indirect
> > branches.
> >
> > In case of MMU-less system, Module area is given whole of the DDR address
> > space.  Since, module_alloc() calls vmalloc(), the module area goes outside the
> > allowed jump range. Due to this insmod will not be able to load the modules
> > giving out of range relocation errors.
> >
> > Solution - Add the mlong-calls flags while compiling the modules. This tells
> > the compiler to perform function calls by first loading the address of the
> > function and then performing a subroutine function call on this register.
> 
> Do we need the module loader to handle additional relocations or they
> are all already handled?

I have explained this extensively when the 2.6 module loader came into
being.  It's not about additional relocations, it's about the addressible
range of the 'b' instruction.

Please search the archives for the explanation.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ARM: MMUless Core: Fix insmod error - module relocation out of range
  2012-10-03  9:48   ` Russell King - ARM Linux
@ 2012-10-03 10:02     ` Catalin Marinas
  0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2012-10-03 10:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 03, 2012 at 10:48:02AM +0100, Russell King - ARM Linux wrote:
> On Wed, Oct 03, 2012 at 10:25:09AM +0100, Catalin Marinas wrote:
> > On 3 October 2012 04:43, Pratyush Anand <pratyush.anand@st.com> wrote:
> > > From: Neha MAKHIJA <neha.makhija-ext@st.com>
> > >
> > > ARM supports 32Mb jump. Hence branch instruction has a limited range.
> > >
> > > For MMU systems, the module area is located just before the kernel memory
> > > because this allows function calls to be linked directly without any indirect
> > > branches.
> > >
> > > In case of MMU-less system, Module area is given whole of the DDR address
> > > space.  Since, module_alloc() calls vmalloc(), the module area goes outside the
> > > allowed jump range. Due to this insmod will not be able to load the modules
> > > giving out of range relocation errors.
> > >
> > > Solution - Add the mlong-calls flags while compiling the modules. This tells
> > > the compiler to perform function calls by first loading the address of the
> > > function and then performing a subroutine function call on this register.
> > 
> > Do we need the module loader to handle additional relocations or they
> > are all already handled?
> 
> I have explained this extensively when the 2.6 module loader came into
> being.  It's not about additional relocations, it's about the addressible
> range of the 'b' instruction.

But doesn't -mlong-calls generate the function calls by first loading
the address in a register?

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-03 10:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-03  3:43 [PATCH] ARM: MMUless Core: Fix insmod error - module relocation out of range Pratyush Anand
2012-10-03  9:25 ` Catalin Marinas
2012-10-03  9:48   ` Russell King - ARM Linux
2012-10-03 10:02     ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox