aboutsummaryrefslogtreecommitdiff
path: root/services/spd
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2019-01-03 10:44:22 -0800
committerVarun Wadekar <vwadekar@nvidia.com>2019-02-05 08:27:43 -0800
commit15440c528004915a79f62e6a6da30e10c49673a4 (patch)
treeb04f71f245a0e0b178d5d7420d84f886d2feda16 /services/spd
parent500fc9e10b3d49a5108d8775c0e47d9666d83c57 (diff)
downloadtrusted-firmware-a-15440c528004915a79f62e6a6da30e10c49673a4.tar.gz
spd: trusty: memmap trusty's code memory before peeking
This patch dynamically maps the first page of trusty's code memory, before accessing it to find out if we are running a 32-bit or 64-bit image. On Tegra platforms, this means we have to increase the mappings to accomodate the new memmap entry. Change-Id: If370d1e6cfcccd69b260134c1b462d8d17bee03d Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'services/spd')
-rw-r--r--services/spd/trusty/trusty.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/services/spd/trusty/trusty.c b/services/spd/trusty/trusty.c
index ce942dd2c7..b059a4352a 100644
--- a/services/spd/trusty/trusty.c
+++ b/services/spd/trusty/trusty.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
+#include <xlat_tables_v2.h>
#include <arch_helpers.h>
#include <bl31/bl31.h>
@@ -412,6 +413,14 @@ static int32_t trusty_setup(void)
return -1;
}
+ /* memmap first page of trusty's code memory before peeking */
+ ret = mmap_add_dynamic_region(ep_info->pc, /* PA */
+ ep_info->pc, /* VA */
+ PAGE_SIZE, /* size */
+ MT_SECURE | MT_RW_DATA); /* attrs */
+ assert(ret == 0);
+
+ /* peek into trusty's code to see if we have a 32-bit or 64-bit image */
instr = *(uint32_t *)ep_info->pc;
if (instr >> 24 == 0xeaU) {
@@ -424,6 +433,9 @@ static int32_t trusty_setup(void)
return -1;
}
+ /* unmap trusty's memory page */
+ (void)mmap_remove_dynamic_region(ep_info->pc, PAGE_SIZE);
+
SET_PARAM_HEAD(ep_info, PARAM_EP, VERSION_1, SECURE | EP_ST_ENABLE);
if (!aarch32)
ep_info->spsr = SPSR_64(MODE_EL1, MODE_SP_ELX,