summaryrefslogtreecommitdiff
path: root/recipes-security/optee/optee-os/0002-core-Allow-mobj_phys-to-allocate-IO-regions.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-security/optee/optee-os/0002-core-Allow-mobj_phys-to-allocate-IO-regions.patch')
-rw-r--r--recipes-security/optee/optee-os/0002-core-Allow-mobj_phys-to-allocate-IO-regions.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/recipes-security/optee/optee-os/0002-core-Allow-mobj_phys-to-allocate-IO-regions.patch b/recipes-security/optee/optee-os/0002-core-Allow-mobj_phys-to-allocate-IO-regions.patch
new file mode 100644
index 0000000..365caad
--- /dev/null
+++ b/recipes-security/optee/optee-os/0002-core-Allow-mobj_phys-to-allocate-IO-regions.patch
@@ -0,0 +1,52 @@
+From 5f1dc306a77f8ed94ec4775c3d78fec743c9f185 Mon Sep 17 00:00:00 2001
+From: Pipat Methavanitpong <pipat.methavanitpong@linaro.org>
+Date: Mon, 3 Feb 2020 15:25:09 +0900
+Subject: [PATCH 2/2] core: Allow mobj_phys to allocate IO regions
+
+This commit makes mobj_phys to allocate IO regions.
+It distinguishes between memory and IO allocation requests by
+using `battr` and `cattr` parameters. If `battr` is `CORE_MEM_TA_RAM`
+and `cattr` is `TEE_NATTR_CACHE_NONCACHE`, then it is an IO allocation
+request.
+
+Signed-off-by: Pipat Methavanitpong <pipat1010@gmail.com>
+Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
+---
+ core/arch/arm/mm/mobj.c | 13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/core/arch/arm/mm/mobj.c b/core/arch/arm/mm/mobj.c
+index 7a129cf5..1ab96f3d 100644
+--- a/core/arch/arm/mm/mobj.c
++++ b/core/arch/arm/mm/mobj.c
+@@ -147,7 +147,10 @@ struct mobj *mobj_phys_alloc(paddr_t pa, size_t size, uint32_t cattr,
+ area_type = MEM_AREA_TEE_RAM_RW_DATA;
+ break;
+ case CORE_MEM_TA_RAM:
+- area_type = MEM_AREA_TA_RAM;
++ if (cattr == TEE_MATTR_CACHE_NONCACHE)
++ area_type = MEM_AREA_IO_NSEC;
++ else
++ area_type = MEM_AREA_TA_RAM;
+ break;
+ case CORE_MEM_NSEC_SHM:
+ area_type = MEM_AREA_NSEC_SHM;
+@@ -161,9 +164,13 @@ struct mobj *mobj_phys_alloc(paddr_t pa, size_t size, uint32_t cattr,
+ }
+
+ /* Only SDP memory may not have a virtual address */
+- va = phys_to_virt(pa, area_type);
+- if (!va && battr != CORE_MEM_SDP_MEM)
++ if (area_type == MEM_AREA_IO_SEC || area_type == MEM_AREA_IO_NSEC)
++ va = phys_to_virt_io(pa);
++ else
++ va = phys_to_virt(pa, area_type);
++ if (!va && battr != CORE_MEM_SDP_MEM) {
+ return NULL;
++ }
+
+ moph = calloc(1, sizeof(*moph));
+ if (!moph)
+--
+2.17.1
+