Unverified Commit cf0886e2 authored by Soby Mathew's avatar Soby Mathew Committed by GitHub
Browse files

Merge pull request #1644 from soby-mathew/sm/pie_proto

Position Indepedent Executable (PIE) Support
parents c38941f0 fc922ca8
...@@ -27,6 +27,16 @@ func cortex_deimos_core_pwr_dwn ...@@ -27,6 +27,16 @@ func cortex_deimos_core_pwr_dwn
ret ret
endfunc cortex_deimos_core_pwr_dwn endfunc cortex_deimos_core_pwr_dwn
#if REPORT_ERRATA
/*
* Errata printing function for Cortex Deimos. Must follow AAPCS.
*/
func cortex_deimos_errata_report
ret
endfunc cortex_deimos_errata_report
#endif
/* --------------------------------------------- /* ---------------------------------------------
* This function provides Cortex-Deimos specific * This function provides Cortex-Deimos specific
* register information for crash reporting. * register information for crash reporting.
......
...@@ -19,6 +19,16 @@ func cortex_helios_cpu_pwr_dwn ...@@ -19,6 +19,16 @@ func cortex_helios_cpu_pwr_dwn
ret ret
endfunc cortex_helios_cpu_pwr_dwn endfunc cortex_helios_cpu_pwr_dwn
#if REPORT_ERRATA
/*
* Errata printing function for Cortex Helios. Must follow AAPCS.
*/
func cortex_helios_errata_report
ret
endfunc cortex_helios_errata_report
#endif
.section .rodata.cortex_helios_regs, "aS" .section .rodata.cortex_helios_regs, "aS"
cortex_helios_regs: /* The ascii list of register names to be reported */ cortex_helios_regs: /* The ascii list of register names to be reported */
.asciz "cpuectlr_el1", "" .asciz "cpuectlr_el1", ""
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_START__, PMF_SVC_DESCS_START); IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_START__, PMF_SVC_DESCS_START);
IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_END__, PMF_SVC_DESCS_END); IMPORT_SYM(uintptr_t, __PMF_SVC_DESCS_END__, PMF_SVC_DESCS_END);
IMPORT_SYM(uintptr_t, __PERCPU_TIMESTAMP_SIZE__, PMF_PERCPU_TIMESTAMP_SIZE); IMPORT_SYM(uintptr_t, __PMF_PERCPU_TIMESTAMP_END__, PMF_PERCPU_TIMESTAMP_END);
IMPORT_SYM(intptr_t, __PMF_TIMESTAMP_START__, PMF_TIMESTAMP_ARRAY_START); IMPORT_SYM(intptr_t, __PMF_TIMESTAMP_START__, PMF_TIMESTAMP_ARRAY_START);
IMPORT_SYM(uintptr_t, __PMF_TIMESTAMP_END__, PMF_TIMESTAMP_ARRAY_END);
#define PMF_PERCPU_TIMESTAMP_SIZE (PMF_PERCPU_TIMESTAMP_END - PMF_TIMESTAMP_ARRAY_START)
#define PMF_SVC_DESCS_MAX 10 #define PMF_SVC_DESCS_MAX 10
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
.globl rom_lib_init .globl rom_lib_init
.extern __DATA_RAM_START__, __DATA_ROM_START__, __DATA_SIZE__ .extern __DATA_RAM_START__, __DATA_ROM_START__, __DATA_RAM_END__
.extern memset, memcpy .extern memset, memcpy
rom_lib_init: rom_lib_init:
...@@ -16,13 +16,19 @@ rom_lib_init: ...@@ -16,13 +16,19 @@ rom_lib_init:
1: stp x29, x30, [sp, #-16]! 1: stp x29, x30, [sp, #-16]!
adrp x0, __DATA_RAM_START__ adrp x0, __DATA_RAM_START__
ldr x1,= __DATA_ROM_START__ adrp x1, __DATA_ROM_START__
ldr x2, =__DATA_SIZE__ add x1, x1, :lo12:__DATA_ROM_START__
adrp x2, __DATA_RAM_END__
add x2, x2, :lo12:__DATA_RAM_END__
sub x2, x2, x0
bl memcpy bl memcpy
ldr x0, =__BSS_START__ adrp x0,__BSS_START__
add x0, x0, :lo12:__BSS_START__
mov x1, #0 mov x1, #0
ldr x2, =__BSS_SIZE__ adrp x2, __BSS_END__
add x2, x2, :lo12:__BSS_END__
sub x2, x2, x0
bl memset bl memset
ldp x29, x30, [sp], #16 ldp x29, x30, [sp], #16
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
tlbi_invalidate_all \el tlbi_invalidate_all \el
mov x7, x0 mov x7, x0
ldr x0, =mmu_cfg_params adrp x0, mmu_cfg_params
add x0, x0, :lo12:mmu_cfg_params
/* MAIR */ /* MAIR */
ldr x1, [x0, #(MMU_CFG_MAIR << 3)] ldr x1, [x0, #(MMU_CFG_MAIR << 3)]
......
...@@ -64,6 +64,9 @@ DYN_DISABLE_AUTH := 0 ...@@ -64,6 +64,9 @@ DYN_DISABLE_AUTH := 0
# Build option to enable MPAM for lower ELs # Build option to enable MPAM for lower ELs
ENABLE_MPAM_FOR_LOWER_ELS := 0 ENABLE_MPAM_FOR_LOWER_ELS := 0
# Flag to Enable Position Independant support (PIE)
ENABLE_PIE := 0
# Flag to enable Performance Measurement Framework # Flag to enable Performance Measurement Framework
ENABLE_PMF := 0 ENABLE_PMF := 0
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
.globl plat_arm_calc_core_pos .globl plat_arm_calc_core_pos
.macro fvp_choose_gicmmap param1, param2, x_tmp, w_tmp, res .macro fvp_choose_gicmmap param1, param2, x_tmp, w_tmp, res
ldr \x_tmp, =V2M_SYSREGS_BASE + V2M_SYS_ID mov_imm \x_tmp, V2M_SYSREGS_BASE + V2M_SYS_ID
ldr \w_tmp, [\x_tmp] ldr \w_tmp, [\x_tmp]
ubfx \w_tmp, \w_tmp, #V2M_SYS_ID_BLD_SHIFT, #V2M_SYS_ID_BLD_LENGTH ubfx \w_tmp, \w_tmp, #V2M_SYS_ID_BLD_SHIFT, #V2M_SYS_ID_BLD_LENGTH
cmp \w_tmp, #BLD_GIC_VE_MMAP cmp \w_tmp, #BLD_GIC_VE_MMAP
...@@ -48,7 +48,7 @@ func plat_secondary_cold_boot_setup ...@@ -48,7 +48,7 @@ func plat_secondary_cold_boot_setup
* --------------------------------------------- * ---------------------------------------------
*/ */
mrs x0, mpidr_el1 mrs x0, mpidr_el1
ldr x1, =PWRC_BASE mov_imm x1, PWRC_BASE
str w0, [x1, #PPOFFR_OFF] str w0, [x1, #PPOFFR_OFF]
/* --------------------------------------------- /* ---------------------------------------------
...@@ -72,8 +72,8 @@ func plat_secondary_cold_boot_setup ...@@ -72,8 +72,8 @@ func plat_secondary_cold_boot_setup
b secondary_cold_boot_wait b secondary_cold_boot_wait
gicv2_bypass_disable: gicv2_bypass_disable:
ldr x0, =VE_GICC_BASE mov_imm x0, VE_GICC_BASE
ldr x1, =BASE_GICC_BASE mov_imm x1, BASE_GICC_BASE
fvp_choose_gicmmap x0, x1, x2, w2, x1 fvp_choose_gicmmap x0, x1, x2, w2, x1
mov w0, #(IRQ_BYP_DIS_GRP1 | FIQ_BYP_DIS_GRP1) mov w0, #(IRQ_BYP_DIS_GRP1 | FIQ_BYP_DIS_GRP1)
orr w0, w0, #(IRQ_BYP_DIS_GRP0 | FIQ_BYP_DIS_GRP0) orr w0, w0, #(IRQ_BYP_DIS_GRP0 | FIQ_BYP_DIS_GRP0)
...@@ -128,7 +128,7 @@ func plat_get_my_entrypoint ...@@ -128,7 +128,7 @@ func plat_get_my_entrypoint
* --------------------------------------------------------------------- * ---------------------------------------------------------------------
*/ */
mrs x2, mpidr_el1 mrs x2, mpidr_el1
ldr x1, =PWRC_BASE mov_imm x1, PWRC_BASE
str w2, [x1, #PSYSR_OFF] str w2, [x1, #PSYSR_OFF]
ldr w2, [x1, #PSYSR_OFF] ldr w2, [x1, #PSYSR_OFF]
ubfx w2, w2, #PSYSR_WK_SHIFT, #PSYSR_WK_WIDTH ubfx w2, w2, #PSYSR_WK_SHIFT, #PSYSR_WK_WIDTH
...@@ -171,7 +171,7 @@ endfunc plat_get_my_entrypoint ...@@ -171,7 +171,7 @@ endfunc plat_get_my_entrypoint
*/ */
func plat_is_my_cpu_primary func plat_is_my_cpu_primary
mrs x0, mpidr_el1 mrs x0, mpidr_el1
ldr x1, =MPIDR_AFFINITY_MASK mov_imm x1, MPIDR_AFFINITY_MASK
and x0, x0, x1 and x0, x0, x1
cmp x0, #FVP_PRIMARY_CPU cmp x0, #FVP_PRIMARY_CPU
cset w0, eq cset w0, eq
......
...@@ -202,7 +202,9 @@ ENABLE_AMU := 1 ...@@ -202,7 +202,9 @@ ENABLE_AMU := 1
DYNAMIC_WORKAROUND_CVE_2018_3639 := 1 DYNAMIC_WORKAROUND_CVE_2018_3639 := 1
# Enable reclaiming of BL31 initialisation code for secondary cores stacks for FVP # Enable reclaiming of BL31 initialisation code for secondary cores stacks for FVP
ifneq (${RESET_TO_BL31},1)
RECLAIM_INIT_CODE := 1 RECLAIM_INIT_CODE := 1
endif
ifeq (${ENABLE_AMU},1) ifeq (${ENABLE_AMU},1)
BL31_SOURCES += lib/cpus/aarch64/cortex_a75_pubsub.c \ BL31_SOURCES += lib/cpus/aarch64/cortex_a75_pubsub.c \
......
...@@ -25,11 +25,13 @@ ...@@ -25,11 +25,13 @@
static entry_point_info_t bl32_image_ep_info; static entry_point_info_t bl32_image_ep_info;
static entry_point_info_t bl33_image_ep_info; static entry_point_info_t bl33_image_ep_info;
#if !RESET_TO_BL31
/* /*
* Check that BL31_BASE is above ARM_TB_FW_CONFIG_LIMIT. The reserved page * Check that BL31_BASE is above ARM_TB_FW_CONFIG_LIMIT. The reserved page
* is required for SOC_FW_CONFIG/TOS_FW_CONFIG passed from BL2. * is required for SOC_FW_CONFIG/TOS_FW_CONFIG passed from BL2.
*/ */
CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows); CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows);
#endif
/* Weak definitions may be overridden in specific ARM standard platform */ /* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak bl31_early_platform_setup2 #pragma weak bl31_early_platform_setup2
...@@ -38,8 +40,8 @@ CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows); ...@@ -38,8 +40,8 @@ CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows);
#pragma weak bl31_plat_get_next_image_ep_info #pragma weak bl31_plat_get_next_image_ep_info
#define MAP_BL31_TOTAL MAP_REGION_FLAT( \ #define MAP_BL31_TOTAL MAP_REGION_FLAT( \
BL31_BASE, \ BL31_START, \
BL31_END - BL31_BASE, \ BL31_END - BL31_START, \
MT_MEMORY | MT_RW | MT_SECURE) MT_MEMORY | MT_RW | MT_SECURE)
#if RECLAIM_INIT_CODE #if RECLAIM_INIT_CODE
IMPORT_SYM(unsigned long, __INIT_CODE_START__, BL_INIT_CODE_BASE); IMPORT_SYM(unsigned long, __INIT_CODE_START__, BL_INIT_CODE_BASE);
......
...@@ -130,6 +130,11 @@ ARM_CRYPTOCELL_INTEG := 0 ...@@ -130,6 +130,11 @@ ARM_CRYPTOCELL_INTEG := 0
$(eval $(call assert_boolean,ARM_CRYPTOCELL_INTEG)) $(eval $(call assert_boolean,ARM_CRYPTOCELL_INTEG))
$(eval $(call add_define,ARM_CRYPTOCELL_INTEG)) $(eval $(call add_define,ARM_CRYPTOCELL_INTEG))
# Enable PIE support for RESET_TO_BL31 case
ifeq (${RESET_TO_BL31},1)
ENABLE_PIE := 1
endif
# CryptoCell integration relies on coherent buffers for passing data from # CryptoCell integration relies on coherent buffers for passing data from
# the AP CPU to the CryptoCell # the AP CPU to the CryptoCell
ifeq (${ARM_CRYPTOCELL_INTEG},1) ifeq (${ARM_CRYPTOCELL_INTEG},1)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <plat_arm.h> #include <plat_arm.h>
#include <platform.h> #include <platform.h>
#include <platform_def.h> #include <platform_def.h>
#include <utils.h>
/****************************************************************************** /******************************************************************************
* The following functions are defined as weak to allow a platform to override * The following functions are defined as weak to allow a platform to override
...@@ -33,10 +34,16 @@ static const interrupt_prop_t arm_interrupt_props[] = { ...@@ -33,10 +34,16 @@ static const interrupt_prop_t arm_interrupt_props[] = {
/* /*
* We save and restore the GICv3 context on system suspend. Allocate the * We save and restore the GICv3 context on system suspend. Allocate the
* data in the designated EL3 Secure carve-out memory * data in the designated EL3 Secure carve-out memory. The `volatile`
* is used to prevent the compiler from removing the gicv3 contexts even
* though the DEFINE_LOAD_SYM_ADDR creates a dummy reference to it.
*/ */
static gicv3_redist_ctx_t rdist_ctx __section("arm_el3_tzc_dram"); static volatile gicv3_redist_ctx_t rdist_ctx __section("arm_el3_tzc_dram");
static gicv3_dist_ctx_t dist_ctx __section("arm_el3_tzc_dram"); static volatile gicv3_dist_ctx_t dist_ctx __section("arm_el3_tzc_dram");
/* Define accessor function to get reference to the GICv3 context */
DEFINE_LOAD_SYM_ADDR(rdist_ctx)
DEFINE_LOAD_SYM_ADDR(dist_ctx)
/* /*
* MPIDR hashing function for translating MPIDRs read from GICR_TYPER register * MPIDR hashing function for translating MPIDRs read from GICR_TYPER register
...@@ -134,6 +141,10 @@ void plat_arm_gic_redistif_off(void) ...@@ -134,6 +141,10 @@ void plat_arm_gic_redistif_off(void)
*****************************************************************************/ *****************************************************************************/
void plat_arm_gic_save(void) void plat_arm_gic_save(void)
{ {
gicv3_redist_ctx_t * const rdist_context =
(gicv3_redist_ctx_t *)LOAD_ADDR_OF(rdist_ctx);
gicv3_dist_ctx_t * const dist_context =
(gicv3_dist_ctx_t *)LOAD_ADDR_OF(dist_ctx);
/* /*
* If an ITS is available, save its context before * If an ITS is available, save its context before
...@@ -149,10 +160,10 @@ void plat_arm_gic_save(void) ...@@ -149,10 +160,10 @@ void plat_arm_gic_save(void)
* we only need to save the context of the CPU that is issuing * we only need to save the context of the CPU that is issuing
* the SYSTEM SUSPEND call, i.e. the current CPU. * the SYSTEM SUSPEND call, i.e. the current CPU.
*/ */
gicv3_rdistif_save(plat_my_core_pos(), &rdist_ctx); gicv3_rdistif_save(plat_my_core_pos(), rdist_context);
/* Save the GIC Distributor context */ /* Save the GIC Distributor context */
gicv3_distif_save(&dist_ctx); gicv3_distif_save(dist_context);
/* /*
* From here, all the components of the GIC can be safely powered down * From here, all the components of the GIC can be safely powered down
...@@ -163,8 +174,13 @@ void plat_arm_gic_save(void) ...@@ -163,8 +174,13 @@ void plat_arm_gic_save(void)
void plat_arm_gic_resume(void) void plat_arm_gic_resume(void)
{ {
const gicv3_redist_ctx_t *rdist_context =
(gicv3_redist_ctx_t *)LOAD_ADDR_OF(rdist_ctx);
const gicv3_dist_ctx_t *dist_context =
(gicv3_dist_ctx_t *)LOAD_ADDR_OF(dist_ctx);
/* Restore the GIC Distributor context */ /* Restore the GIC Distributor context */
gicv3_distif_init_restore(&dist_ctx); gicv3_distif_init_restore(dist_context);
/* /*
* Restore the GIC Redistributor and ITS contexts after the * Restore the GIC Redistributor and ITS contexts after the
...@@ -172,7 +188,7 @@ void plat_arm_gic_resume(void) ...@@ -172,7 +188,7 @@ void plat_arm_gic_resume(void)
* we only need to restore the context of the CPU that issued * we only need to restore the context of the CPU that issued
* the SYSTEM SUSPEND call. * the SYSTEM SUSPEND call.
*/ */
gicv3_rdistif_init_restore(plat_my_core_pos(), &rdist_ctx); gicv3_rdistif_init_restore(plat_my_core_pos(), rdist_context);
/* /*
* If an ITS is available, restore its context after * If an ITS is available, restore its context after
......
...@@ -108,7 +108,7 @@ endfunc plat_is_my_cpu_primary ...@@ -108,7 +108,7 @@ endfunc plat_is_my_cpu_primary
func plat_is_my_cpu_primary func plat_is_my_cpu_primary
mov x9, x30 mov x9, x30
bl plat_my_core_pos bl plat_my_core_pos
ldr x1, =SCP_BOOT_CFG_ADDR mov_imm x1, SCP_BOOT_CFG_ADDR
ldr x1, [x1] ldr x1, [x1]
ubfx x1, x1, #PLAT_CSS_PRIMARY_CPU_SHIFT, \ ubfx x1, x1, #PLAT_CSS_PRIMARY_CPU_SHIFT, \
#PLAT_CSS_PRIMARY_CPU_BIT_WIDTH #PLAT_CSS_PRIMARY_CPU_BIT_WIDTH
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment