From 7d74487c2afb0d9c69ab6c640060bdf711929edc Mon Sep 17 00:00:00 2001 From: Varun Wadekar Date: Thu, 28 Jun 2018 11:03:41 -0700 Subject: [PATCH] Tegra186: store TZDRAM base/size to scratch registers This patch saves the TZDRAM base and size values to secure scratch registers, for the WB0. The WB0 reads these values and uses them to verify integrity of the TZDRAM aperture. Change-Id: Ic70914cb958249f06cb58025a24d13734a85e16e Signed-off-by: Jeetesh Burman Signed-off-by: Varun Wadekar --- plat/nvidia/tegra/soc/t186/plat_memctrl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plat/nvidia/tegra/soc/t186/plat_memctrl.c b/plat/nvidia/tegra/soc/t186/plat_memctrl.c index 4ca5e77ad..a97496bd1 100644 --- a/plat/nvidia/tegra/soc/t186/plat_memctrl.c +++ b/plat/nvidia/tegra/soc/t186/plat_memctrl.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,7 +11,11 @@ #include #include #include +#include #include +#include + +extern uint64_t tegra_bl31_phys_base; /******************************************************************************* * Array to hold stream_id override config register offsets @@ -540,6 +545,13 @@ tegra_mc_settings_t *tegra_get_mc_settings(void) void plat_memctrl_tzdram_setup(uint64_t phys_base, uint64_t size_in_bytes) { uint32_t val; + uint64_t src_base_tzdram; + const plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params(); + uint64_t src_len_in_bytes = BL31_END - BL31_START; + + /* base address of BL3-1 source in TZDRAM */ + src_base_tzdram = params_from_bl2->tzdram_base + + tegra186_get_cpu_reset_handler_size(); /* * Setup the Memory controller to allow only secure accesses to @@ -568,6 +580,15 @@ void plat_memctrl_tzdram_setup(uint64_t phys_base, uint64_t size_in_bytes) val = tegra_mc_read_32(MC_SECURITY_CFG3_0) & MC_SECURITY_BOM_HI_MASK; mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_TZDRAM_ADDR_HI, val); + /* + * save tzdram_addr_lo and ATF-size, this would be used in SC7-RF to + * generate SHA256. + */ + mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV68_LO, + (uint32_t)src_base_tzdram); + mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV0_HI, + (uint32_t)src_len_in_bytes); + /* * MCE propagates the security configuration values across the * CCPLEX.