Tegra: sanity check NS address and size before use
This patch updates the 'bl31_check_ns_address()' helper function to check that the memory address and size passed by the NS world are not zero. The helper fucntion also returns the error code as soon as it detects inconsistencies, to avoid multiple error paths from kicking in for the same input parameters. Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Change-Id: I46264f913954614bedcbde12e47ea0c70cd19be0
This commit is contained in:
parent
a7749acc10
commit
685e56092d
|
@ -367,7 +367,15 @@ void bl31_plat_arch_setup(void)
|
|||
int32_t bl31_check_ns_address(uint64_t base, uint64_t size_in_bytes)
|
||||
{
|
||||
uint64_t end = base + size_in_bytes - U(1);
|
||||
int32_t ret = 0;
|
||||
|
||||
/*
|
||||
* Sanity check the input values
|
||||
*/
|
||||
if ((base == 0U) || (size_in_bytes == 0U)) {
|
||||
ERROR("NS address 0x%llx (%lld bytes) is invalid\n",
|
||||
base, size_in_bytes);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the NS DRAM address is valid
|
||||
|
@ -376,7 +384,7 @@ int32_t bl31_check_ns_address(uint64_t base, uint64_t size_in_bytes)
|
|||
(end > TEGRA_DRAM_END)) {
|
||||
|
||||
ERROR("NS address 0x%llx is out-of-bounds!\n", base);
|
||||
ret = -EFAULT;
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -385,9 +393,9 @@ int32_t bl31_check_ns_address(uint64_t base, uint64_t size_in_bytes)
|
|||
*/
|
||||
if ((base < (uint64_t)TZDRAM_END) && (end > tegra_bl31_phys_base)) {
|
||||
ERROR("NS address 0x%llx overlaps TZDRAM!\n", base);
|
||||
ret = -ENOTSUP;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* valid NS address */
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue