2005-04-17 05:20:36 +07:00
|
|
|
#ifndef _ASM_ARM_MODULE_H
|
|
|
|
#define _ASM_ARM_MODULE_H
|
|
|
|
|
2012-09-28 12:01:03 +07:00
|
|
|
#include <asm-generic/module.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-02-11 19:09:54 +07:00
|
|
|
struct unwind_table;
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARM_UNWIND
|
2010-08-19 21:16:37 +07:00
|
|
|
enum {
|
|
|
|
ARM_SEC_INIT,
|
|
|
|
ARM_SEC_DEVINIT,
|
|
|
|
ARM_SEC_CORE,
|
2010-08-19 21:19:04 +07:00
|
|
|
ARM_SEC_EXIT,
|
|
|
|
ARM_SEC_DEVEXIT,
|
2013-08-29 06:08:01 +07:00
|
|
|
ARM_SEC_HOT,
|
|
|
|
ARM_SEC_UNLIKELY,
|
2010-08-19 21:16:37 +07:00
|
|
|
ARM_SEC_MAX,
|
|
|
|
};
|
2014-11-24 22:54:35 +07:00
|
|
|
#endif
|
2010-11-12 20:02:46 +07:00
|
|
|
|
ARM: 8662/1: module: split core and init PLT sections
Since commit 35fa91eed817 ("ARM: kernel: merge core and init PLTs"),
the ARM module PLT code allocates all PLT entries in a single core
section, since the overhead of having a separate init PLT section is
not justified by the small number of PLT entries usually required for
init code.
However, the core and init module regions are allocated independently,
and there is a corner case where the core region may be allocated from
the VMALLOC region if the dedicated module region is exhausted, but the
init region, being much smaller, can still be allocated from the module
region. This puts the PLT entries out of reach of the relocated branch
instructions, defeating the whole purpose of PLTs.
So split the core and init PLT regions, and name the latter ".init.plt"
so it gets allocated along with (and sufficiently close to) the .init
sections that it serves. Also, given that init PLT entries may need to
be emitted for branches that target the core module, modify the logic
that disregards defined symbols to only disregard symbols that are
defined in the same section.
Fixes: 35fa91eed817 ("ARM: kernel: merge core and init PLTs")
Cc: <stable@vger.kernel.org> # v4.9+
Reported-by: Angus Clark <angus@angusclark.org>
Tested-by: Angus Clark <angus@angusclark.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2017-02-23 01:40:12 +07:00
|
|
|
struct mod_plt_sec {
|
|
|
|
struct elf32_shdr *plt;
|
|
|
|
int plt_count;
|
|
|
|
};
|
|
|
|
|
2010-08-19 21:16:37 +07:00
|
|
|
struct mod_arch_specific {
|
2014-11-24 22:54:35 +07:00
|
|
|
#ifdef CONFIG_ARM_UNWIND
|
2010-11-12 20:02:46 +07:00
|
|
|
struct unwind_table *unwind[ARM_SEC_MAX];
|
2012-09-28 12:01:03 +07:00
|
|
|
#endif
|
2014-11-24 22:54:35 +07:00
|
|
|
#ifdef CONFIG_ARM_MODULE_PLTS
|
ARM: 8662/1: module: split core and init PLT sections
Since commit 35fa91eed817 ("ARM: kernel: merge core and init PLTs"),
the ARM module PLT code allocates all PLT entries in a single core
section, since the overhead of having a separate init PLT section is
not justified by the small number of PLT entries usually required for
init code.
However, the core and init module regions are allocated independently,
and there is a corner case where the core region may be allocated from
the VMALLOC region if the dedicated module region is exhausted, but the
init region, being much smaller, can still be allocated from the module
region. This puts the PLT entries out of reach of the relocated branch
instructions, defeating the whole purpose of PLTs.
So split the core and init PLT regions, and name the latter ".init.plt"
so it gets allocated along with (and sufficiently close to) the .init
sections that it serves. Also, given that init PLT entries may need to
be emitted for branches that target the core module, modify the logic
that disregards defined symbols to only disregard symbols that are
defined in the same section.
Fixes: 35fa91eed817 ("ARM: kernel: merge core and init PLTs")
Cc: <stable@vger.kernel.org> # v4.9+
Reported-by: Angus Clark <angus@angusclark.org>
Tested-by: Angus Clark <angus@angusclark.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2017-02-23 01:40:12 +07:00
|
|
|
struct mod_plt_sec core;
|
|
|
|
struct mod_plt_sec init;
|
2014-11-24 22:54:35 +07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val);
|
2009-02-11 19:09:54 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching
This idea came from Nicolas, Eric Miao produced an initial version,
which was then rewritten into this.
Patch the physical to virtual translations at runtime. As we modify
the code, this makes it incompatible with XIP kernels, but allows us
to achieve this with minimal loss of performance.
As many translations are of the form:
physical = virtual + (PHYS_OFFSET - PAGE_OFFSET)
virtual = physical - (PHYS_OFFSET - PAGE_OFFSET)
we generate an 'add' instruction for __virt_to_phys(), and a 'sub'
instruction for __phys_to_virt(). We calculate at run time (PHYS_OFFSET
- PAGE_OFFSET) by comparing the address prior to MMU initialization with
where it should be once the MMU has been initialized, and place this
constant into the above add/sub instructions.
Once we have (PHYS_OFFSET - PAGE_OFFSET), we can calculate the real
PHYS_OFFSET as PAGE_OFFSET is a build-time constant, and save this for
the C-mode PHYS_OFFSET variable definition to use.
At present, we are unable to support Realview with Sparsemem enabled
as this uses a complex mapping function, and MSM as this requires a
constant which will not fit in our math instruction.
Add a module version magic string for this feature to prevent
incompatible modules being loaded.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-05 02:09:43 +07:00
|
|
|
* Add the ARM architecture version to the version magic string
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching
This idea came from Nicolas, Eric Miao produced an initial version,
which was then rewritten into this.
Patch the physical to virtual translations at runtime. As we modify
the code, this makes it incompatible with XIP kernels, but allows us
to achieve this with minimal loss of performance.
As many translations are of the form:
physical = virtual + (PHYS_OFFSET - PAGE_OFFSET)
virtual = physical - (PHYS_OFFSET - PAGE_OFFSET)
we generate an 'add' instruction for __virt_to_phys(), and a 'sub'
instruction for __phys_to_virt(). We calculate at run time (PHYS_OFFSET
- PAGE_OFFSET) by comparing the address prior to MMU initialization with
where it should be once the MMU has been initialized, and place this
constant into the above add/sub instructions.
Once we have (PHYS_OFFSET - PAGE_OFFSET), we can calculate the real
PHYS_OFFSET as PAGE_OFFSET is a build-time constant, and save this for
the C-mode PHYS_OFFSET variable definition to use.
At present, we are unable to support Realview with Sparsemem enabled
as this uses a complex mapping function, and MSM as this requires a
constant which will not fit in our math instruction.
Add a module version magic string for this feature to prevent
incompatible modules being loaded.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-05 02:09:43 +07:00
|
|
|
#define MODULE_ARCH_VERMAGIC_ARMVSN "ARMv" __stringify(__LINUX_ARM_ARCH__) " "
|
|
|
|
|
|
|
|
/* Add __virt_to_phys patching state as well */
|
|
|
|
#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
|
|
|
|
#define MODULE_ARCH_VERMAGIC_P2V "p2v8 "
|
|
|
|
#else
|
|
|
|
#define MODULE_ARCH_VERMAGIC_P2V ""
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 23:54:52 +07:00
|
|
|
/* Add instruction set architecture tag to distinguish ARM/Thumb kernels */
|
|
|
|
#ifdef CONFIG_THUMB2_KERNEL
|
|
|
|
#define MODULE_ARCH_VERMAGIC_ARMTHUMB "thumb2 "
|
|
|
|
#else
|
|
|
|
#define MODULE_ARCH_VERMAGIC_ARMTHUMB ""
|
|
|
|
#endif
|
|
|
|
|
ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching
This idea came from Nicolas, Eric Miao produced an initial version,
which was then rewritten into this.
Patch the physical to virtual translations at runtime. As we modify
the code, this makes it incompatible with XIP kernels, but allows us
to achieve this with minimal loss of performance.
As many translations are of the form:
physical = virtual + (PHYS_OFFSET - PAGE_OFFSET)
virtual = physical - (PHYS_OFFSET - PAGE_OFFSET)
we generate an 'add' instruction for __virt_to_phys(), and a 'sub'
instruction for __phys_to_virt(). We calculate at run time (PHYS_OFFSET
- PAGE_OFFSET) by comparing the address prior to MMU initialization with
where it should be once the MMU has been initialized, and place this
constant into the above add/sub instructions.
Once we have (PHYS_OFFSET - PAGE_OFFSET), we can calculate the real
PHYS_OFFSET as PAGE_OFFSET is a build-time constant, and save this for
the C-mode PHYS_OFFSET variable definition to use.
At present, we are unable to support Realview with Sparsemem enabled
as this uses a complex mapping function, and MSM as this requires a
constant which will not fit in our math instruction.
Add a module version magic string for this feature to prevent
incompatible modules being loaded.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-05 02:09:43 +07:00
|
|
|
#define MODULE_ARCH_VERMAGIC \
|
|
|
|
MODULE_ARCH_VERMAGIC_ARMVSN \
|
2011-02-25 23:54:52 +07:00
|
|
|
MODULE_ARCH_VERMAGIC_ARMTHUMB \
|
ARM: P2V: introduce phys_to_virt/virt_to_phys runtime patching
This idea came from Nicolas, Eric Miao produced an initial version,
which was then rewritten into this.
Patch the physical to virtual translations at runtime. As we modify
the code, this makes it incompatible with XIP kernels, but allows us
to achieve this with minimal loss of performance.
As many translations are of the form:
physical = virtual + (PHYS_OFFSET - PAGE_OFFSET)
virtual = physical - (PHYS_OFFSET - PAGE_OFFSET)
we generate an 'add' instruction for __virt_to_phys(), and a 'sub'
instruction for __phys_to_virt(). We calculate at run time (PHYS_OFFSET
- PAGE_OFFSET) by comparing the address prior to MMU initialization with
where it should be once the MMU has been initialized, and place this
constant into the above add/sub instructions.
Once we have (PHYS_OFFSET - PAGE_OFFSET), we can calculate the real
PHYS_OFFSET as PAGE_OFFSET is a build-time constant, and save this for
the C-mode PHYS_OFFSET variable definition to use.
At present, we are unable to support Realview with Sparsemem enabled
as this uses a complex mapping function, and MSM as this requires a
constant which will not fit in our math instruction.
Add a module version magic string for this feature to prevent
incompatible modules being loaded.
Tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2011-01-05 02:09:43 +07:00
|
|
|
MODULE_ARCH_VERMAGIC_P2V
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif /* _ASM_ARM_MODULE_H */
|