Commit aadb1350 authored by danh-arm's avatar danh-arm Committed by GitHub
Browse files

Merge pull request #662 from sandrine-bailleux-arm/sb/rodata-xn

Map read-only data as execute-never
parents 9306f135 91fad655
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <platform_def.h> #include <platform_def.h>
#include <plat_arm.h> #include <plat_arm.h>
#include <sp805.h> #include <sp805.h>
#include <utils.h>
#include <xlat_tables.h>
#include "../../../bl1/bl1_private.h" #include "../../../bl1/bl1_private.h"
...@@ -118,15 +120,18 @@ void bl1_early_platform_setup(void) ...@@ -118,15 +120,18 @@ void bl1_early_platform_setup(void)
*****************************************************************************/ *****************************************************************************/
void arm_bl1_plat_arch_setup(void) void arm_bl1_plat_arch_setup(void)
{ {
arm_configure_mmu_el3(bl1_tzram_layout.total_base, arm_setup_page_tables(bl1_tzram_layout.total_base,
bl1_tzram_layout.total_size, bl1_tzram_layout.total_size,
BL1_RO_BASE, BL_CODE_BASE,
BL1_RO_LIMIT BL1_CODE_LIMIT,
BL1_RO_DATA_BASE,
BL1_RO_DATA_LIMIT
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, BL1_COHERENT_RAM_BASE, , BL1_COHERENT_RAM_BASE,
BL1_COHERENT_RAM_LIMIT BL1_COHERENT_RAM_LIMIT
#endif #endif
); );
enable_mmu_el3(0);
} }
void bl1_plat_arch_setup(void) void bl1_plat_arch_setup(void)
......
...@@ -36,16 +36,6 @@ ...@@ -36,16 +36,6 @@
#include <plat_arm.h> #include <plat_arm.h>
#include <string.h> #include <string.h>
/*
* The next 2 constants identify the extents of the code & RO data region.
* These addresses are used by the MMU setup code and therefore they must be
* page-aligned. It is the responsibility of the linker script to ensure that
* __RO_START__ and __RO_END__ linker symbols refer to page-aligned addresses.
*/
#define BL2_RO_BASE (unsigned long)(&__RO_START__)
#define BL2_RO_LIMIT (unsigned long)(&__RO_END__)
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
/* /*
* The next 2 constants identify the extents of the coherent memory region. * The next 2 constants identify the extents of the coherent memory region.
...@@ -234,15 +224,18 @@ void bl2_platform_setup(void) ...@@ -234,15 +224,18 @@ void bl2_platform_setup(void)
******************************************************************************/ ******************************************************************************/
void arm_bl2_plat_arch_setup(void) void arm_bl2_plat_arch_setup(void)
{ {
arm_configure_mmu_el1(bl2_tzram_layout.total_base, arm_setup_page_tables(bl2_tzram_layout.total_base,
bl2_tzram_layout.total_size, bl2_tzram_layout.total_size,
BL2_RO_BASE, BL_CODE_BASE,
BL2_RO_LIMIT BL_CODE_LIMIT,
BL_RO_DATA_BASE,
BL_RO_DATA_LIMIT
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, BL2_COHERENT_RAM_BASE, , BL2_COHERENT_RAM_BASE,
BL2_COHERENT_RAM_LIMIT BL2_COHERENT_RAM_LIMIT
#endif #endif
); );
enable_mmu_el1(0);
} }
void bl2_plat_arch_setup(void) void bl2_plat_arch_setup(void)
......
/* /*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -36,16 +36,6 @@ ...@@ -36,16 +36,6 @@
#include <plat_arm.h> #include <plat_arm.h>
#include <string.h> #include <string.h>
/*
* The next 2 constants identify the extents of the code & RO data region.
* These addresses are used by the MMU setup code and therefore they must be
* page-aligned. It is the responsibility of the linker script to ensure that
* __RO_START__ and __RO_END__ linker symbols refer to page-aligned addresses.
*/
#define BL2U_RO_BASE (unsigned long)(&__RO_START__)
#define BL2U_RO_LIMIT (unsigned long)(&__RO_END__)
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
/* /*
* The next 2 constants identify the extents of the coherent memory region. * The next 2 constants identify the extents of the coherent memory region.
...@@ -102,16 +92,19 @@ void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info) ...@@ -102,16 +92,19 @@ void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
******************************************************************************/ ******************************************************************************/
void arm_bl2u_plat_arch_setup(void) void arm_bl2u_plat_arch_setup(void)
{ {
arm_configure_mmu_el1(BL2U_RO_LIMIT, arm_setup_page_tables(BL2U_BASE,
BL31_LIMIT, BL31_LIMIT,
BL2U_RO_BASE, BL_CODE_BASE,
BL2U_RO_LIMIT BL_CODE_LIMIT,
BL_RO_DATA_BASE,
BL_RO_DATA_LIMIT
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, ,
BL2U_COHERENT_RAM_BASE, BL2U_COHERENT_RAM_BASE,
BL2U_COHERENT_RAM_LIMIT BL2U_COHERENT_RAM_LIMIT
#endif #endif
); );
enable_mmu_el1(0);
} }
void bl2u_plat_arch_setup(void) void bl2u_plat_arch_setup(void)
......
...@@ -38,16 +38,6 @@ ...@@ -38,16 +38,6 @@
#include <plat_arm.h> #include <plat_arm.h>
#include <platform.h> #include <platform.h>
/*
* The next 3 constants identify the extents of the code, RO data region and the
* limit of the BL31 image. These addresses are used by the MMU setup code and
* therefore they must be page-aligned. It is the responsibility of the linker
* script to ensure that __RO_START__, __RO_END__ & __BL31_END__ linker symbols
* refer to page-aligned addresses.
*/
#define BL31_RO_BASE (unsigned long)(&__RO_START__)
#define BL31_RO_LIMIT (unsigned long)(&__RO_END__)
#define BL31_END (unsigned long)(&__BL31_END__) #define BL31_END (unsigned long)(&__BL31_END__)
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
...@@ -246,20 +236,25 @@ void bl31_plat_runtime_setup(void) ...@@ -246,20 +236,25 @@ void bl31_plat_runtime_setup(void)
} }
/******************************************************************************* /*******************************************************************************
* Perform the very early platform specific architectural setup here. At the * Perform the very early platform specific architectural setup shared between
* moment this is only intializes the mmu in a quick and dirty way. * ARM standard platforms. This only does basic initialization. Later
* architectural setup (bl31_arch_setup()) does not do anything platform
* specific.
******************************************************************************/ ******************************************************************************/
void arm_bl31_plat_arch_setup(void) void arm_bl31_plat_arch_setup(void)
{ {
arm_configure_mmu_el3(BL31_RO_BASE, arm_setup_page_tables(BL31_BASE,
(BL31_END - BL31_RO_BASE), BL31_END - BL31_BASE,
BL31_RO_BASE, BL_CODE_BASE,
BL31_RO_LIMIT BL_CODE_LIMIT,
BL_RO_DATA_BASE,
BL_RO_DATA_LIMIT
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, BL31_COHERENT_RAM_BASE, , BL31_COHERENT_RAM_BASE,
BL31_COHERENT_RAM_LIMIT BL31_COHERENT_RAM_LIMIT
#endif #endif
); );
enable_mmu_el3(0);
} }
void bl31_plat_arch_setup(void) void bl31_plat_arch_setup(void)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <cci.h> #include <cci.h>
#include <plat_arm.h> #include <plat_arm.h>
#include <platform_def.h> #include <platform_def.h>
#include <utils.h>
static const int cci_map[] = { static const int cci_map[] = {
PLAT_ARM_CCI_CLUSTER0_SL_IFACE_IX, PLAT_ARM_CCI_CLUSTER0_SL_IFACE_IX,
......
...@@ -85,6 +85,11 @@ $(eval $(call add_define,ARM_BL31_IN_DRAM)) ...@@ -85,6 +85,11 @@ $(eval $(call add_define,ARM_BL31_IN_DRAM))
# Enable PSCI_STAT_COUNT/RESIDENCY APIs on ARM platforms # Enable PSCI_STAT_COUNT/RESIDENCY APIs on ARM platforms
ENABLE_PSCI_STAT = 1 ENABLE_PSCI_STAT = 1
# On ARM platforms, separate the code and read-only data sections to allow
# mapping the former as executable and the latter as execute-never.
SEPARATE_CODE_AND_RODATA := 1
PLAT_INCLUDES += -Iinclude/common/tbbr \ PLAT_INCLUDES += -Iinclude/common/tbbr \
-Iinclude/plat/arm/common \ -Iinclude/plat/arm/common \
-Iinclude/plat/arm/common/aarch64 -Iinclude/plat/arm/common/aarch64
......
/* /*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <assert.h> #include <assert.h>
#include <bl_common.h> /* For ARRAY_SIZE */
#include <debug.h> #include <debug.h>
#include <firmware_image_package.h> #include <firmware_image_package.h>
#include <io_driver.h> #include <io_driver.h>
...@@ -37,6 +36,7 @@ ...@@ -37,6 +36,7 @@
#include <io_storage.h> #include <io_storage.h>
#include <platform_def.h> #include <platform_def.h>
#include <string.h> #include <string.h>
#include <utils.h>
/* IO devices */ /* IO devices */
static const io_dev_connector_t *fip_dev_con; static const io_dev_connector_t *fip_dev_con;
......
/* /*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -35,16 +35,6 @@ ...@@ -35,16 +35,6 @@
#include <platform_tsp.h> #include <platform_tsp.h>
#include <plat_arm.h> #include <plat_arm.h>
/*
* The next 3 constants identify the extents of the code & RO data region and
* the limit of the BL32 image. These addresses are used by the MMU setup code
* and therefore they must be page-aligned. It is the responsibility of the
* linker script to ensure that __RO_START__, __RO_END__ & & __BL32_END__
* linker symbols refer to page-aligned addresses.
*/
#define BL32_RO_BASE (unsigned long)(&__RO_START__)
#define BL32_RO_LIMIT (unsigned long)(&__RO_END__)
#define BL32_END (unsigned long)(&__BL32_END__) #define BL32_END (unsigned long)(&__BL32_END__)
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
...@@ -98,13 +88,16 @@ void tsp_platform_setup(void) ...@@ -98,13 +88,16 @@ void tsp_platform_setup(void)
******************************************************************************/ ******************************************************************************/
void tsp_plat_arch_setup(void) void tsp_plat_arch_setup(void)
{ {
arm_configure_mmu_el1(BL32_RO_BASE, arm_setup_page_tables(BL32_BASE,
(BL32_END - BL32_RO_BASE), (BL32_END - BL32_BASE),
BL32_RO_BASE, BL_CODE_BASE,
BL32_RO_LIMIT BL_CODE_LIMIT,
BL_RO_DATA_BASE,
BL_RO_DATA_LIMIT
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, BL32_COHERENT_RAM_BASE, , BL32_COHERENT_RAM_BASE,
BL32_COHERENT_RAM_LIMIT BL32_COHERENT_RAM_LIMIT
#endif #endif
); );
enable_mmu_el1(0);
} }
/* /*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <debug.h> #include <debug.h>
#include <mt8173_def.h> #include <mt8173_def.h>
#include <platform_def.h> #include <platform_def.h>
#include <utils.h>
#include <xlat_tables.h> #include <xlat_tables.h>
static const int cci_map[] = { static const int cci_map[] = {
......
/* /*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <arm_gic.h> #include <arm_gic.h>
#include <bl_common.h> #include <bl_common.h>
#include <mt8173_def.h> #include <mt8173_def.h>
#include <utils.h>
const unsigned int mt_irq_sec_array[] = { const unsigned int mt_irq_sec_array[] = {
MT_IRQ_SEC_SGI_0, MT_IRQ_SEC_SGI_0,
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <xlat_tables.h> #include <xlat_tables.h>
#include <platform_def.h> #include <platform_def.h>
#include <plat_private.h> #include <plat_private.h>
#include <utils.h>
#ifdef PLAT_RK_CCI_BASE #ifdef PLAT_RK_CCI_BASE
static const int cci_map[] = { static const int cci_map[] = {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <bl_common.h> #include <bl_common.h>
#include <gicv2.h> #include <gicv2.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
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <gicv3.h> #include <gicv3.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
......
...@@ -147,18 +147,20 @@ void bl31_plat_runtime_setup(void) ...@@ -147,18 +147,20 @@ void bl31_plat_runtime_setup(void)
} }
/* /*
* Perform the very early platform specific architectural setup here. At the * Perform the very early platform specific architectural setup here.
* moment this is only intializes the MMU in a quick and dirty way.
*/ */
void bl31_plat_arch_setup(void) void bl31_plat_arch_setup(void)
{ {
plat_arm_interconnect_init(); plat_arm_interconnect_init();
plat_arm_interconnect_enter_coherency(); plat_arm_interconnect_enter_coherency();
arm_configure_mmu_el3(BL31_RO_BASE, arm_setup_page_tables(BL31_RO_BASE,
BL31_COHERENT_RAM_LIMIT - BL31_RO_BASE, BL31_COHERENT_RAM_LIMIT - BL31_RO_BASE,
BL31_RO_BASE, BL31_RO_BASE,
BL31_RO_LIMIT, BL31_RO_LIMIT,
0,
0,
BL31_COHERENT_RAM_BASE, BL31_COHERENT_RAM_BASE,
BL31_COHERENT_RAM_LIMIT); BL31_COHERENT_RAM_LIMIT);
enable_mmu_el3(0);
} }
/* /*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <gicv2.h> #include <gicv2.h>
#include <bl_common.h> #include <bl_common.h>
#include <mmio.h> #include <mmio.h>
#include <utils.h>
#include "pm_api_sys.h" #include "pm_api_sys.h"
#include "pm_client.h" #include "pm_client.h"
#include "pm_ipi.h" #include "pm_ipi.h"
......
/* /*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -90,13 +90,16 @@ void tsp_platform_setup(void) ...@@ -90,13 +90,16 @@ void tsp_platform_setup(void)
******************************************************************************/ ******************************************************************************/
void tsp_plat_arch_setup(void) void tsp_plat_arch_setup(void)
{ {
arm_configure_mmu_el1(BL32_RO_BASE, arm_setup_page_tables(BL32_RO_BASE,
(BL32_END - BL32_RO_BASE), (BL32_END - BL32_RO_BASE),
BL32_RO_BASE, BL32_RO_BASE,
BL32_RO_LIMIT BL32_RO_LIMIT,
0,
0
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
, BL32_COHERENT_RAM_BASE, , BL32_COHERENT_RAM_BASE,
BL32_COHERENT_RAM_LIMIT BL32_COHERENT_RAM_LIMIT
#endif #endif
); );
enable_mmu_el1(0);
} }
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