diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2017-06-02 13:07:24 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2017-06-02 15:48:36 +0200 |
commit | bce4951c2b0143aadc21c1cb592eaf0fc1a87d75 (patch) | |
tree | 64b5e2b6aec20aa7de19a0c66c8751dc175406c9 | |
parent | afc0c182d6c1c726c10a2922dae3cdf6a915779f (diff) |
core: add linker.h for link script symbols
Moves all core extern declarations of linker script symbols into
<kernel/linker.h>.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | core/arch/arm/include/kernel/generic_boot.h | 56 | ||||
-rw-r--r-- | core/arch/arm/include/kernel/linker.h | 121 | ||||
-rw-r--r-- | core/arch/arm/kernel/abort.c | 14 | ||||
-rw-r--r-- | core/arch/arm/kernel/generic_boot.c | 15 | ||||
-rw-r--r-- | core/arch/arm/kernel/pseudo_ta.c | 5 | ||||
-rw-r--r-- | core/arch/arm/mm/core_mmu.c | 7 | ||||
-rw-r--r-- | core/arch/arm/tee/init.c | 16 | ||||
-rw-r--r-- | core/include/kernel/asan.h | 17 | ||||
-rw-r--r-- | core/include/kernel/dt.h | 2 | ||||
-rw-r--r-- | core/kernel/asan.c | 20 | ||||
-rw-r--r-- | core/kernel/dt.c | 1 |
11 files changed, 164 insertions, 110 deletions
diff --git a/core/arch/arm/include/kernel/generic_boot.h b/core/arch/arm/include/kernel/generic_boot.h index f262b296..b23e0511 100644 --- a/core/arch/arm/include/kernel/generic_boot.h +++ b/core/arch/arm/include/kernel/generic_boot.h @@ -61,60 +61,4 @@ int generic_boot_core_release(size_t core_idx, paddr_t entry); paddr_t generic_boot_core_hpen(void); #endif -#define VCORE_UNPG_RX_PA ((paddr_t)__vcore_unpg_rx_start) -#define VCORE_UNPG_RX_SZ ((size_t)__vcore_unpg_rx_size) -#define VCORE_UNPG_RO_PA ((paddr_t)__vcore_unpg_ro_start) -#define VCORE_UNPG_RO_SZ ((size_t)__vcore_unpg_ro_size) -#define VCORE_UNPG_RW_PA ((paddr_t)__vcore_unpg_rw_start) -#define VCORE_UNPG_RW_SZ ((size_t)__vcore_unpg_rw_size) -#define VCORE_INIT_RX_PA ((paddr_t)__vcore_init_rx_start) -#define VCORE_INIT_RX_SZ ((size_t)__vcore_init_rx_size) -#define VCORE_INIT_RO_PA ((paddr_t)__vcore_init_ro_start) -#define VCORE_INIT_RO_SZ ((size_t)__vcore_init_ro_size) - -extern uint8_t __vcore_unpg_rx_start[]; -extern uint8_t __vcore_unpg_rx_size[]; -extern uint8_t __vcore_unpg_ro_start[]; -extern uint8_t __vcore_unpg_ro_size[]; -extern uint8_t __vcore_unpg_rw_start[]; -extern uint8_t __vcore_unpg_rw_size[]; -extern uint8_t __vcore_init_rx_start[]; -extern uint8_t __vcore_init_rx_size[]; -extern uint8_t __vcore_init_ro_start[]; -extern uint8_t __vcore_init_ro_size[]; - -extern uint8_t __text_start[]; -extern initcall_t __initcall_start; -extern initcall_t __initcall_end; -extern uint8_t __data_start[]; -extern uint8_t __data_end[]; -extern uint8_t __rodata_start[]; -extern uint8_t __rodata_end[]; -extern uint8_t __bss_start[]; -extern uint8_t __bss_end[]; -extern uint8_t __nozi_start[]; -extern uint8_t __nozi_end[]; -extern uint8_t __nozi_stack_start[]; -extern uint8_t __nozi_stack_end[]; -extern uint8_t __init_start[]; -extern uint8_t __init_size[]; -extern uint8_t __tmp_hashes_start[]; -extern uint8_t __tmp_hashes_size[]; -extern uint8_t __heap1_start[]; -extern uint8_t __heap1_end[]; -extern uint8_t __heap2_start[]; -extern uint8_t __heap2_end[]; -extern uint8_t __pageable_part_start[]; -extern uint8_t __pageable_part_end[]; -extern uint8_t __pageable_start[]; -extern uint8_t __pageable_end[]; -extern uint8_t __asan_shadow_start[]; -extern uint8_t __asan_shadow_end[]; -extern vaddr_t __ctor_list; -extern vaddr_t __ctor_end; -extern uint8_t __end[]; - -/* Generated by core/arch/arm/kernel/link.mk */ -extern const char core_v_str[]; - #endif /* KERNEL_GENERIC_BOOT_H */ diff --git a/core/arch/arm/include/kernel/linker.h b/core/arch/arm/include/kernel/linker.h new file mode 100644 index 00000000..57fdae9e --- /dev/null +++ b/core/arch/arm/include/kernel/linker.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __KERNEL_LINKER_H +#define __KERNEL_LINKER_H + +#include <initcall.h> +#include <kernel/pseudo_ta.h> +#include <kernel/dt.h> +#include <mm/core_mmu.h> +#include <types_ext.h> + +/* + * Symbols exported by the link script. + */ + + +/* + * These addresses will be the start or end of the exception binary search + * index table (.ARM.exidx section) + */ +extern const uint8_t __exidx_start[]; +extern const uint8_t __exidx_end[]; + +extern const struct pseudo_ta_head __start_ta_head_section; +extern const struct pseudo_ta_head __stop_ta_head_section; + +extern const struct core_mmu_phys_mem __start_phys_sdp_mem_section; +extern const struct core_mmu_phys_mem __end_phys_sdp_mem_section; +extern const struct core_mmu_phys_mem __start_phys_mem_map_section; +extern const struct core_mmu_phys_mem __end_phys_mem_map_section; + +#define VCORE_UNPG_RX_PA ((paddr_t)__vcore_unpg_rx_start) +#define VCORE_UNPG_RX_SZ ((size_t)__vcore_unpg_rx_size) +#define VCORE_UNPG_RO_PA ((paddr_t)__vcore_unpg_ro_start) +#define VCORE_UNPG_RO_SZ ((size_t)__vcore_unpg_ro_size) +#define VCORE_UNPG_RW_PA ((paddr_t)__vcore_unpg_rw_start) +#define VCORE_UNPG_RW_SZ ((size_t)__vcore_unpg_rw_size) +#define VCORE_INIT_RX_PA ((paddr_t)__vcore_init_rx_start) +#define VCORE_INIT_RX_SZ ((size_t)__vcore_init_rx_size) +#define VCORE_INIT_RO_PA ((paddr_t)__vcore_init_ro_start) +#define VCORE_INIT_RO_SZ ((size_t)__vcore_init_ro_size) +extern const uint8_t __vcore_unpg_rx_start[]; +extern const uint8_t __vcore_unpg_rx_size[]; +extern const uint8_t __vcore_unpg_ro_start[]; +extern const uint8_t __vcore_unpg_ro_size[]; +extern const uint8_t __vcore_unpg_rw_start[]; +extern const uint8_t __vcore_unpg_rw_size[]; +extern const uint8_t __vcore_init_rx_start[]; +extern const uint8_t __vcore_init_rx_size[]; +extern const uint8_t __vcore_init_ro_start[]; +extern const uint8_t __vcore_init_ro_size[]; + +extern const uint8_t __text_start[]; +extern const uint8_t __end[]; + +extern const initcall_t __initcall_start; +extern const initcall_t __initcall_end; + +extern const uint8_t __data_start[]; +extern const uint8_t __data_end[]; +extern const uint8_t __rodata_start[]; +extern const uint8_t __rodata_end[]; +extern const uint8_t __bss_start[]; +extern const uint8_t __bss_end[]; +extern const uint8_t __nozi_start[]; +extern const uint8_t __nozi_end[]; +extern const uint8_t __nozi_stack_start[]; +extern const uint8_t __nozi_stack_end[]; +extern const uint8_t __init_start[]; +extern const uint8_t __init_size[]; +extern const uint8_t __tmp_hashes_start[]; +extern const uint8_t __tmp_hashes_size[]; + +extern uint8_t __heap1_start[]; +extern const uint8_t __heap1_end[]; +extern uint8_t __heap2_start[]; +extern const uint8_t __heap2_end[]; + +extern const uint8_t __pageable_part_start[]; +extern const uint8_t __pageable_part_end[]; +extern const uint8_t __pageable_start[]; +extern const uint8_t __pageable_end[]; + +extern const uint8_t __asan_shadow_start[]; +extern const uint8_t __asan_shadow_end[]; +extern const vaddr_t __ctor_list; +extern const vaddr_t __ctor_end; + + +extern const struct dt_driver __rodata_dtdrv_start; +extern const struct dt_driver __rodata_dtdrv_end; + +/* Generated by core/arch/arm/kernel/link.mk */ +extern const char core_v_str[]; + +#endif /*__KERNEL_LINKER_H*/ + diff --git a/core/arch/arm/kernel/abort.c b/core/arch/arm/kernel/abort.c index f21bdf3f..8e966f95 100644 --- a/core/arch/arm/kernel/abort.c +++ b/core/arch/arm/kernel/abort.c @@ -25,18 +25,19 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <arm.h> #include <kernel/abort.h> +#include <kernel/linker.h> #include <kernel/misc.h> -#include <kernel/tee_ta_manager.h> #include <kernel/panic.h> -#include <kernel/user_ta.h> +#include <kernel/tee_ta_manager.h> #include <kernel/unwind.h> +#include <kernel/user_ta.h> #include <mm/core_mmu.h> #include <mm/mobj.h> #include <mm/tee_pager.h> #include <tee/tee_svc.h> #include <trace.h> -#include <arm.h> #include "thread_private.h" @@ -71,13 +72,6 @@ static void get_current_ta_exidx(uaddr_t *exidx, size_t *exidx_sz) #ifdef ARM32 /* - * These are set in the linker script. Their addresses will be the start or end - * of the exception binary search index table (.ARM.exidx section) - */ -extern uint8_t __exidx_start[]; -extern uint8_t __exidx_end[]; - -/* * Kernel or user mode unwind (32-bit execution state). */ static void __print_stack_unwind_arm32(struct abort_info *ai) diff --git a/core/arch/arm/kernel/generic_boot.c b/core/arch/arm/kernel/generic_boot.c index 9e7e5b28..d9d4eba6 100644 --- a/core/arch/arm/kernel/generic_boot.c +++ b/core/arch/arm/kernel/generic_boot.c @@ -31,23 +31,24 @@ #include <console.h> #include <inttypes.h> #include <keep.h> +#include <kernel/asan.h> #include <kernel/generic_boot.h> -#include <kernel/thread.h> -#include <kernel/panic.h> +#include <kernel/linker.h> #include <kernel/misc.h> -#include <kernel/asan.h> +#include <kernel/panic.h> +#include <kernel/thread.h> #include <malloc.h> -#include <mm/core_mmu.h> #include <mm/core_memprot.h> +#include <mm/core_mmu.h> #include <mm/tee_mm.h> #include <mm/tee_mmu.h> #include <mm/tee_pager.h> #include <sm/tee_mon.h> -#include <trace.h> +#include <stdio.h> #include <tee/tee_cryp_provider.h> +#include <trace.h> #include <utee_defines.h> #include <util.h> -#include <stdio.h> #include <platform_config.h> @@ -325,7 +326,7 @@ static void init_runtime(unsigned long pageable_part) #ifdef CFG_CORE_SANITIZE_KADDRESS static void init_run_constructors(void) { - vaddr_t *ctor; + const vaddr_t *ctor; for (ctor = &__ctor_list; ctor < &__ctor_end; ctor++) ((void (*)(void))(*ctor))(); diff --git a/core/arch/arm/kernel/pseudo_ta.c b/core/arch/arm/kernel/pseudo_ta.c index 78b2bfd3..c499978e 100644 --- a/core/arch/arm/kernel/pseudo_ta.c +++ b/core/arch/arm/kernel/pseudo_ta.c @@ -26,6 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <initcall.h> +#include <kernel/linker.h> #include <kernel/panic.h> #include <kernel/pseudo_ta.h> #include <kernel/tee_ta_manager.h> @@ -215,10 +216,6 @@ static const struct tee_ta_ops pseudo_ta_ops = { }; -/* Defined in link script */ -extern const struct pseudo_ta_head __start_ta_head_section; -extern const struct pseudo_ta_head __stop_ta_head_section; - /* Insures declared pseudo TAs conforms with core expectations */ static TEE_Result verify_pseudo_tas_conformance(void) { diff --git a/core/arch/arm/mm/core_mmu.c b/core/arch/arm/mm/core_mmu.c index e45ce0a3..a993c3f2 100644 --- a/core/arch/arm/mm/core_mmu.c +++ b/core/arch/arm/mm/core_mmu.c @@ -29,6 +29,7 @@ #include <arm.h> #include <assert.h> #include <kernel/generic_boot.h> +#include <kernel/linker.h> #include <kernel/panic.h> #include <kernel/tee_l2cc_mutex.h> #include <kernel/tee_misc.h> @@ -201,9 +202,6 @@ static struct tee_mmap_region *find_map_by_pa(unsigned long pa) } #ifdef CFG_SECURE_DATA_PATH -extern const struct core_mmu_phys_mem __start_phys_sdp_mem_section; -extern const struct core_mmu_phys_mem __end_phys_sdp_mem_section; - static bool pbuf_is_sdp_mem(paddr_t pbuf, size_t len) { const struct core_mmu_phys_mem *mem; @@ -301,9 +299,6 @@ static void verify_sdp_mem_areas(struct tee_mmap_region *mem_map __unused, } #endif /* CFG_SECURE_DATA_PATH */ -extern const struct core_mmu_phys_mem __start_phys_mem_map_section; -extern const struct core_mmu_phys_mem __end_phys_mem_map_section; - static void add_phys_mem(struct tee_mmap_region *memory_map, size_t num_elems, const struct core_mmu_phys_mem *mem, size_t *last) { diff --git a/core/arch/arm/tee/init.c b/core/arch/arm/tee/init.c index 66d2a2bc..8cf24704 100644 --- a/core/arch/arm/tee/init.c +++ b/core/arch/arm/tee/init.c @@ -26,18 +26,18 @@ */ #include <initcall.h> -#include <malloc.h> /* required for inits */ - -#include <sm/tee_mon.h> +#include <kernel/linker.h> #include <kernel/tee_misc.h> -#include <mm/core_memprot.h> -#include <trace.h> #include <kernel/time_source.h> -#include <kernel/generic_boot.h> +#include <malloc.h> /* required for inits */ +#include <mm/core_memprot.h> #include <mm/tee_mmu.h> -#include <tee/tee_fs.h> +#include <sm/tee_mon.h> #include <tee/tee_cryp_provider.h> +#include <tee/tee_fs.h> #include <tee/tee_svc.h> +#include <trace.h> + #include <platform_config.h> @@ -45,7 +45,7 @@ static void call_initcalls(void) { - initcall_t *call; + const initcall_t *call; for (call = &__initcall_start; call < &__initcall_end; call++) { TEE_Result ret; diff --git a/core/include/kernel/asan.h b/core/include/kernel/asan.h index 6eaa1191..36a362aa 100644 --- a/core/include/kernel/asan.h +++ b/core/include/kernel/asan.h @@ -38,21 +38,24 @@ #ifndef ASM #include <types_ext.h> -void asan_set_shadowed(void *va_begin, void *va_end); +void asan_set_shadowed(const void *va_begin, const void *va_end); void asan_start(void); #ifdef CFG_CORE_SANITIZE_KADDRESS -void asan_tag_no_access(void *begin, void *end); -void asan_tag_access(void *begin, void *end); -void asan_tag_heap_free(void *begin, void *end); +void asan_tag_no_access(const void *begin, const void *end); +void asan_tag_access(const void *begin, const void *end); +void asan_tag_heap_free(const void *begin, const void *end); #else -static inline void asan_tag_no_access(void *begin __unused, void *end __unused) +static inline void asan_tag_no_access(const void *begin __unused, + const void *end __unused) { } -static inline void asan_tag_access(void *begin __unused, void *end __unused) +static inline void asan_tag_access(const void *begin __unused, + const void *end __unused) { } -static inline void asan_tag_heap_free(void *begin __unused, void *end __unused) +static inline void asan_tag_heap_free(const void *begin __unused, + const void *end __unused) { } #endif diff --git a/core/include/kernel/dt.h b/core/include/kernel/dt.h index 9d30db5c..123533c5 100644 --- a/core/include/kernel/dt.h +++ b/core/include/kernel/dt.h @@ -59,8 +59,6 @@ struct dt_driver { #define __dt_driver __section(".rodata.dtdrv") -extern const struct dt_driver __rodata_dtdrv_start, __rodata_dtdrv_end; - /* * Find a driver that is suitable for the given DT node, that is, with * a matching "compatible" property. diff --git a/core/kernel/asan.c b/core/kernel/asan.c index 695f8179..6d5baea1 100644 --- a/core/kernel/asan.c +++ b/core/kernel/asan.c @@ -54,19 +54,19 @@ static vaddr_t asan_va_base; static size_t asan_va_size; static bool asan_active; -static int8_t *va_to_shadow(void *va) +static int8_t *va_to_shadow(const void *va) { vaddr_t sa = ((vaddr_t)va / ASAN_BLOCK_SIZE) + CFG_ASAN_SHADOW_OFFSET; return (int8_t *)sa; } -static size_t va_range_to_shadow_size(void *begin, void *end) +static size_t va_range_to_shadow_size(const void *begin, const void *end) { return ((vaddr_t)end - (vaddr_t)begin) / ASAN_BLOCK_SIZE; } -static bool va_range_inside_shadow(void *begin, void *end) +static bool va_range_inside_shadow(const void *begin, const void *end) { vaddr_t b = (vaddr_t)begin; vaddr_t e = (vaddr_t)end; @@ -76,7 +76,7 @@ static bool va_range_inside_shadow(void *begin, void *end) return (b >= asan_va_base) && (e <= (asan_va_base + asan_va_size)); } -static bool va_range_outside_shadow(void *begin, void *end) +static bool va_range_outside_shadow(const void *begin, const void *end) { vaddr_t b = (vaddr_t)begin; vaddr_t e = (vaddr_t)end; @@ -86,17 +86,17 @@ static bool va_range_outside_shadow(void *begin, void *end) return (e <= asan_va_base) || (b >= (asan_va_base + asan_va_size)); } -static size_t va_misalignment(void *va) +static size_t va_misalignment(const void *va) { return (vaddr_t)va & ASAN_BLOCK_MASK; } -static bool va_is_well_aligned(void *va) +static bool va_is_well_aligned(const void *va) { return !va_misalignment(va); } -void asan_set_shadowed(void *begin, void *end) +void asan_set_shadowed(const void *begin, const void *end) { vaddr_t b = (vaddr_t)begin; vaddr_t e = (vaddr_t)end; @@ -110,7 +110,7 @@ void asan_set_shadowed(void *begin, void *end) asan_va_size = e - b; } -void asan_tag_no_access(void *begin, void *end) +void asan_tag_no_access(const void *begin, const void *end) { assert(va_is_well_aligned(begin)); assert(va_is_well_aligned(end)); @@ -120,7 +120,7 @@ void asan_tag_no_access(void *begin, void *end) va_range_to_shadow_size(begin, end)); } -void asan_tag_access(void *begin, void *end) +void asan_tag_access(const void *begin, const void *end) { if (!asan_va_base) return; @@ -133,7 +133,7 @@ void asan_tag_access(void *begin, void *end) *va_to_shadow(end) = ASAN_BLOCK_SIZE - va_misalignment(end); } -void asan_tag_heap_free(void *begin, void *end) +void asan_tag_heap_free(const void *begin, const void *end) { if (!asan_va_base) return; diff --git a/core/kernel/dt.c b/core/kernel/dt.c index 2317ca7a..3d88c49e 100644 --- a/core/kernel/dt.c +++ b/core/kernel/dt.c @@ -27,6 +27,7 @@ #include <assert.h> #include <kernel/dt.h> +#include <kernel/linker.h> #include <libfdt.h> #include <mm/core_memprot.h> #include <mm/core_mmu.h> |