-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access normal world memory from OPTEE core - translation fault #2933
Comments
If answer to 1st question if yes and to the 2nd is no, than you are attempting to use in the secure world a virtual address related to the non-secure world. This is not valid. For a TA to access a (non-secure) shared memory buffer, the client application shall pass the buffer reference as an argument of type
|
@etienne-lms Thanks for the reply!
The code above works fine if I copy a smaller size. Seems like it has a problem when I'm copying a large size. Do I have to increase something like CFG_TEE_RAM_VA_SIZE or something else? |
I understand that you register an non-secure physical memory area in OP-TEE core through For your TA to access your non-secure frame buffer, the standard way would be:
And in this case, if Without |
@etienne-lms Thanks a lot! I used shared memory and I could read the whole buffer in the TA. But I had to allocate a new buffer in the host application and copy the whole framebuffer to it. Then passed the newly allocated buffer to the shared memory. When I used passed a pointer from my mmap to the buffer, the TEEC_InvokeCommand fails. The pointer from mmap is fine cause I can read the values from the address.
Also, I still don't know how I can access the NW buffer in TA without using the shared buffer. I think using the shared buffer causes some overhead. |
I think the base flow for sequence should be like this (edited: there were obvious mistakes):
I was to point you at https://github.com/linaro-swg/optee_examples but I see there is no example on shared memory. Here,
OP-TEE is based on the GPD TEE specification that describes the interface between CAs & TAs. Use and management of shared is described. Technically speaking, is it is possible to have a persistent mapping of non-secure memory in a TA. OP-TEE does not propose such hack/support.
Yes, you are right. But OP-TEE may already have something for your case. When OP-TEE is built with |
@etienne-lms Thanks! But, I still don't know why the mmap()ed memory fails but if I allocate a new buffer it works. My code sequence is exactly like your code. Basically, when I use the fbp pointer as the buffer Invoke fails and when I change it to the tmp (which I got from calloc()) it works. I don't know why there should be any difference for the Invoke. Also, checked the libteec library and looks like that the ioctl() fails. Here is the error code: Thanks! |
I think you need to enable debug traces in OP-TEE OS/core and maybe in OP-TEE Linux driver. What is possible is that the buffer you try to register fails to be used by OP-TEE Linux driver or by the secure world. For example, if the buffer was allocated from Ion, or some specific memory management stack, maybe OP-TEE Linux driver fails to construct a OP-TEE description of the buffer (list of physical pages used), or maybe OP-TEE core rejected the listed physical pages as being used as shared memory. |
@etienne-lms Thanks! You're right. I saw that the TEEC_RegisterSharedMemory() failed before I did the Invoke. I debugged in the Linux driver and looks like that the tee_shm_register() fails. Inside this function the get_user_pages_fast() fails. What do you think might be the cause of the problem and how can I get around with it? Also my mmap() uses "dma_mmap_writecombine()" to create the mapping in the driver. Thanks! |
If your buffer is related to a dma-buf reference, maybe you can use |
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time. |
Hi all,
I'm trying to copy a large memory buffer in the normal world to a buffer allocated in TA (using Tee_Malloc) at OPTEE kernel but it crashed with this error:
E/TC:6 0 Core data-abort at address 0x3c400000 (translation fault).
I'm doing memcpy() for size of 8294400 bytes. Here is the code:
core_mmu_add_mapping(MEM_AREA_RAM_NSEC, paddr, 2025);
va = phys_to_virt(paddr, MEM_AREA_RAM_NSEC);
tee_svc_copy_to_user(TA_va, va, 2025*4096); //memcpy()
The starting virtual address for the normal world buffer (in the OPTEE) is 0x3c100000 and the memcpy crashes at the address: 0x3c400000. Looks like that it can only copy for 0x300000 size. Also, I can read the normal world memory addresses with no problem by using the same mapping and phys_to_virt() technique. The code above works fine if I copy a smaller size. Seems like it has a problem when I'm copying a large size.
Does anybody have an idea what's the problem? I looked into discussions and tried some solutions such as increasing the PGT_CACHE_SIZE or CFG_CORE_HEAP_SIZE but it didn't change anything. I tried to break down the copy into multiple smaller chunks but the same issue. I'm trying on Hikey board.
Thanks a lot!
The text was updated successfully, but these errors were encountered: