]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
feat(drtm): ensure that passed region lies within Non-Secure region of DRAM
authorManish V Badarkhe <Manish.Badarkhe@arm.com>
Wed, 13 Jul 2022 08:47:03 +0000 (09:47 +0100)
committerManish V Badarkhe <Manish.Badarkhe@arm.com>
Wed, 5 Oct 2022 14:25:28 +0000 (15:25 +0100)
Ensured DLME data region and DRTM parameters are lies within Non-Secure
region of DRAM by calling platform function 'plat_drtm_validate_ns_region'.

Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Change-Id: I93ead775f45ca7748193631f8f9eec4326fcf20a

services/std_svc/drtm/drtm_main.c

index bec4b72f1d48204a68500e2a5b6901f963f27a4c..443516d286e9c3f9143c7fce3fe889069f23110b 100644 (file)
@@ -328,6 +328,14 @@ static enum drtm_retc drtm_dl_check_args(uint64_t x1,
        }
 
        args_mapping_size = ALIGNED_UP(sizeof(struct_drtm_dl_args), DRTM_PAGE_SIZE);
+
+       /* check DRTM parameters are within NS address region */
+       rc = plat_drtm_validate_ns_region(x1, args_mapping_size);
+       if (rc != 0) {
+               ERROR("DRTM: parameters lies within secure memory\n");
+               return INVALID_PARAMETERS;
+       }
+
        rc = mmap_add_dynamic_region_alloc_va(x1, &args_mapping, args_mapping_size,
                                              MT_MEMORY | MT_NS | MT_RO |
                                              MT_SHAREABILITY_ISH);
@@ -371,14 +379,6 @@ static enum drtm_retc drtm_dl_check_args(uint64_t x1,
        dlme_data_start = a->dlme_paddr + a->dlme_data_off;
        dlme_data_end = dlme_end;
 
-       /*
-        * TODO: validate that the DLME physical address range is all NS memory,
-        * return INVALID_PARAMETERS if it is not.
-        * Note that this check relies on platform-specific information. For
-        * examples, see psci_plat_pm_ops->validate_ns_entrypoint() or
-        * arm_validate_ns_entrypoint().
-        */
-
        /* Check the DLME regions arguments. */
        if ((dlme_start % DRTM_PAGE_SIZE) != 0) {
                ERROR("DRTM: argument DLME region is not "
@@ -428,6 +428,13 @@ static enum drtm_retc drtm_dl_check_args(uint64_t x1,
                return INVALID_PARAMETERS;
        }
 
+       /* check DLME region (paddr + size) is within a NS address region */
+       rc = plat_drtm_validate_ns_region(dlme_start, (size_t)a->dlme_size);
+       if (rc != 0) {
+               ERROR("DRTM: DLME region lies within secure memory\n");
+               return INVALID_PARAMETERS;
+       }
+
        /* Check the Normal World DCE region arguments. */
        if (a->dce_nwd_paddr != 0) {
                uint32_t dce_nwd_start = a->dce_nwd_paddr;