summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/trusty/sysdeps.h4
-rw-r--r--lib/trusty/ql-tipc/ipc_dev.c13
-rw-r--r--lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c17
3 files changed, 14 insertions, 20 deletions
diff --git a/include/trusty/sysdeps.h b/include/trusty/sysdeps.h
index 08bc913230..6b50522762 100644
--- a/include/trusty/sysdeps.h
+++ b/include/trusty/sysdeps.h
@@ -110,11 +110,9 @@ void trusty_free(void *addr);
/*
* Allocate @count contiguous pages to be shared with secure side.
*
- * @mem_inf: Stores cache attributes
* Returns: vaddr of allocated memory
*/
-void *trusty_alloc_pages(struct ns_mem_page_info *mem_inf,
- unsigned count) TRUSTY_ATTR_WARN_UNUSED_RESULT;
+void *trusty_alloc_pages(unsigned count) TRUSTY_ATTR_WARN_UNUSED_RESULT;
/*
* Free @count pages at @vaddr allocated by trusty_alloc_pages
*/
diff --git a/lib/trusty/ql-tipc/ipc_dev.c b/lib/trusty/ql-tipc/ipc_dev.c
index 0f6f5f9090..720acf22be 100644
--- a/lib/trusty/ql-tipc/ipc_dev.c
+++ b/lib/trusty/ql-tipc/ipc_dev.c
@@ -24,6 +24,7 @@
#include <trusty/trusty_dev.h>
#include <trusty/trusty_ipc.h>
+#include <trusty/trusty_mem.h>
#include <trusty/util.h>
#define NS_PTE_PHYSADDR(pte) ((pte) & 0xFFFFFFFFF000ULL)
@@ -176,13 +177,20 @@ int trusty_ipc_dev_create(struct trusty_ipc_dev **idev,
/* allocate shared buffer */
dev->buf_size = shared_buf_size;
- dev->buf_vaddr = trusty_alloc_pages(&dev->buf_ns,
- shared_buf_size / PAGE_SIZE);
+ dev->buf_vaddr = trusty_alloc_pages(shared_buf_size / PAGE_SIZE);
if (!dev->buf_vaddr) {
trusty_error("%s: failed to allocate shared memory\n", __func__);
rc = TRUSTY_ERR_NO_MEMORY;
goto err_alloc_pages;
}
+
+ /* Get memory attributes */
+ rc = trusty_encode_page_info(&dev->buf_ns, dev->buf_vaddr);
+ if (rc != 0) {
+ trusty_error("%s: failed to get shared memory attributes\n", __func__);
+ rc = TRUSTY_ERR_GENERIC;
+ goto err_page_info;
+ }
/* call secure OS to register shared buffer */
rc = trusty_dev_init_ipc(dev->tdev, &dev->buf_ns, dev->buf_size);
if (rc != 0) {
@@ -197,6 +205,7 @@ int trusty_ipc_dev_create(struct trusty_ipc_dev **idev,
*idev = dev;
return TRUSTY_ERR_NONE;
+err_page_info:
err_create_sec_dev:
trusty_free_pages(dev->buf_vaddr, dev->buf_size / PAGE_SIZE);
err_alloc_pages:
diff --git a/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c b/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c
index f0d6c69abd..b42cd20d4f 100644
--- a/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c
+++ b/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c
@@ -99,22 +99,9 @@ void trusty_free(void *addr)
free(addr);
}
-void *trusty_alloc_pages(struct ns_mem_page_info *page_info, unsigned count)
+void *trusty_alloc_pages(unsigned count)
{
- void *va = NULL;
- int res;
-
- va = memalign(PAGE_SIZE, count * PAGE_SIZE);
- if (!va)
- return NULL;
-
- /* get memory attibutes */
- res = trusty_encode_page_info(page_info, va);
- if (res) {
- trusty_free_pages(va, count);
- return NULL;
- }
- return va;
+ return memalign(PAGE_SIZE, count * PAGE_SIZE);
}
void trusty_free_pages(void *va, unsigned count)