From: Phil Chang <phil.chang@mediatek.com>
To: <jens.wiklander@linaro.org>
Cc: <sumit.garg@linaro.org>, <matthias.bgg@gmail.com>,
<op-tee@lists.trustedfirmware.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>, <phil.chang@mediatek.com>
Subject: [PATCH] optee: make tee_shm_register vmalloc supported
Date: Fri, 4 Feb 2022 17:32:54 +0800 [thread overview]
Message-ID: <20220204093254.2467-1-phil.chang@mediatek.com> (raw)
This patch allowed the tee shm use vmalloc area buffer.
Signed-off-by: Phil Chang <phil.chang@mediatek.com>
---
Hi,
In some low-memory devices, it's hard to aquire large-orders pages,
this pathes is allowed user use scatter pages to register shm.
Thanks.
drivers/tee/optee/call.c | 2 +-
drivers/tee/tee_shm.c | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c
index b25cc1fac945..937bcc7df8e4 100644
--- a/drivers/tee/optee/call.c
+++ b/drivers/tee/optee/call.c
@@ -362,7 +362,7 @@ int optee_check_mem_type(unsigned long start, size_t num_pages)
* Allow kernel address to register with OP-TEE as kernel
* pages are configured as normal memory only.
*/
- if (virt_addr_valid(start))
+ if (virt_addr_valid(start) || is_vmalloc_addr((void *)start))
return 0;
mmap_read_lock(mm);
diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 499fccba3d74..31d0c10485ff 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -195,6 +195,20 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
if (flags & TEE_SHM_USER_MAPPED) {
rc = pin_user_pages_fast(start, num_pages, FOLL_WRITE,
shm->pages);
+ } else if (is_vmalloc_addr((void *)start)) {
+ struct page *page;
+ int i;
+
+ for (i = 0; i < num_pages; i++) {
+ page = vmalloc_to_page((void *)(start + PAGE_SIZE * i));
+ if (!page) {
+ ret = ERR_PTR(-ENOMEM);
+ goto err;
+ }
+ get_page(page);
+ shm->pages[i] = page;
+ }
+ rc = num_pages;
} else {
struct kvec *kiov;
int i;
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-02-04 9:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 9:32 Phil Chang [this message]
2022-02-04 11:08 ` [PATCH] optee: make tee_shm_register vmalloc supported Sumit Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220204093254.2467-1-phil.chang@mediatek.com \
--to=phil.chang@mediatek.com \
--cc=jens.wiklander@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=op-tee@lists.trustedfirmware.org \
--cc=sumit.garg@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox