Skip to content

Commit

Permalink
core: support larger values for CFG_TEE_CORE_NB_CORE
Browse files Browse the repository at this point in the history
With larger values of CFG_TEE_CORE_NB_CORE (for example, 18 on the
marvell-cnf10ka platform) CORE_MMU_BASE_TABLE_OFFSET becomes to large to
be used as an immediate value in add and sub assembly instructions. This
is handle by using the new add_imm and sub_imm macros where needed. But
the add_imm and sub_imm macros can't handle complex defines so
CORE_MMU_BASE_TABLE_OFFSET must be evaluated in asm-defines.c first.

This should fix errors like:
core/arch/arm/kernel/thread_a64.S: Assembler messages:
core/arch/arm/kernel/thread_a64.S:339: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:347: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:355: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:372: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:379: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:386: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:660: Error: immediate out of range
core/arch/arm/kernel/thread_a64.S:732: Error: immediate out of range
make: *** [mk/compile.mk:165: out/core/arch/arm/kernel/thread_a64.o] Error 1

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Gowthami <gthiagarajan@marvell.com>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
jenswi-linaro authored and jforissier committed Aug 30, 2023
1 parent 733655e commit f9f2a14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions core/arch/arm/kernel/asm-defines.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <kernel/boot.h>
#include <kernel/thread.h>
#include <kernel/thread_private.h>
#include <mm/core_mmu_arch.h>
#include <sm/pm.h>
#include <sm/sm.h>
#include <types_ext.h>
Expand Down Expand Up @@ -157,4 +158,13 @@ DEFINES
offsetof(struct boot_embdata, reloc_offset));
DEFINE(BOOT_EMBDATA_RELOC_LEN,
offsetof(struct boot_embdata, reloc_len));

#ifdef CORE_MMU_BASE_TABLE_OFFSET
/*
* This define is too complex to be used as an argument for the
* macros add_imm and sub_imm so evaluate it here.
*/
DEFINE(__CORE_MMU_BASE_TABLE_OFFSET, CORE_MMU_BASE_TABLE_OFFSET);
#endif

}
8 changes: 4 additions & 4 deletions core/arch/arm/kernel/thread_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ END_FUNC thread_unwind_user_mode

/* Update the mapping to use the full kernel mapping */
mrs x0, ttbr0_el1
sub x0, x0, #CORE_MMU_BASE_TABLE_OFFSET
sub_imm x0, __CORE_MMU_BASE_TABLE_OFFSET
/* switch to kernel mode ASID */
bic x0, x0, #BIT(TTBR_ASID_SHIFT)
msr ttbr0_el1, x0
Expand Down Expand Up @@ -657,7 +657,7 @@ BTI( bti j)

/* Update the mapping to exclude the full kernel mapping */
mrs x0, ttbr0_el1
add x0, x0, #CORE_MMU_BASE_TABLE_OFFSET
add_imm x0, __CORE_MMU_BASE_TABLE_OFFSET
orr x0, x0, #BIT(TTBR_ASID_SHIFT) /* switch to user mode ASID */
msr ttbr0_el1, x0
isb
Expand Down Expand Up @@ -729,8 +729,8 @@ icache_inv_user_range:
BTI( bti j)
/* Update the mapping to exclude the full kernel mapping */
mrs x5, ttbr0_el1 /* this register must be preserved */
add x2, x5, #CORE_MMU_BASE_TABLE_OFFSET
orr x2, x2, #BIT(TTBR_ASID_SHIFT) /* switch to user mode ASID */
orr x2, x5, #BIT(TTBR_ASID_SHIFT) /* switch to user mode ASID */
add_imm x2, __CORE_MMU_BASE_TABLE_OFFSET
msr ttbr0_el1, x2
isb

Expand Down

0 comments on commit f9f2a14

Please sign in to comment.