<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/tee/optee/core.c, branch linux-5.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-02-23T11:05:54Z</updated>
<entry>
<title>optee: use driver internal tee_context for some rpc</title>
<updated>2022-02-23T11:05:54Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2022-01-27T14:29:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f333857e0f857d69aea6c1fb49fbfb7cfdb69b1b'/>
<id>urn:sha1:f333857e0f857d69aea6c1fb49fbfb7cfdb69b1b</id>
<content type='text'>
commit aceeafefff736057e8f93f19bbfbef26abd94604 upstream.

Adds a driver private tee_context by moving the tee_context in struct
optee_notif to struct optee. This tee_context was previously used when
doing internal calls to secure world to deliver notification.

The new driver internal tee_context is now also when allocating driver
private shared memory. This decouples the shared memory object from its
original tee_context. This is needed when the life time of such a memory
allocation outlives the client tee_context.

This patch fixes the problem described below:

The addition of a shutdown hook by commit f25889f93184 ("optee: fix tee out
of memory failure seen during kexec reboot") introduced a kernel shutdown
regression that can be triggered after running the OP-TEE xtest suites.

Once the shutdown hook is called it is not possible to communicate any more
with the supplicant process because the system is not scheduling task any
longer. Thus if the optee driver shutdown path receives a supplicant RPC
request from the OP-TEE we will deadlock the kernel's shutdown.

Fixes: f25889f93184 ("optee: fix tee out of memory failure seen during kexec reboot")
Fixes: 217e0250cccb ("tee: use reference counting for tee_context")
Reported-by: Lars Persson &lt;larper@axis.com&gt;
Cc: stable@vger.kernel.org
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
[JW: backport to 5.16-stable + update commit message]
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: Fix incorrect page free bug</title>
<updated>2021-12-16T14:32:37Z</updated>
<author>
<name>Sumit Garg</name>
</author>
<published>2021-12-16T05:47:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=18549bf4b21c739a9def39f27dcac53e27286ab5'/>
<id>urn:sha1:18549bf4b21c739a9def39f27dcac53e27286ab5</id>
<content type='text'>
Pointer to the allocated pages (struct page *page) has already
progressed towards the end of allocation. It is incorrect to perform
__free_pages(page, order) using this pointer as we would free any
arbitrary pages. Fix this by stop modifying the page pointer.

Fixes: ec185dd3ab25 ("optee: Fix memory leak when failing to register shm pages")
Cc: stable@vger.kernel.org
Reported-by: Patrik Lantz &lt;patrik.lantz@axis.com&gt;
Signed-off-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Reviewed-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>optee: add FF-A support</title>
<updated>2021-10-18T09:44:23Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2021-07-21T15:45:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4615e5a34b95e0d81467f6d2176f19a5d184cb5d'/>
<id>urn:sha1:4615e5a34b95e0d81467f6d2176f19a5d184cb5d</id>
<content type='text'>
Adds support for using FF-A [1] as transport to the OP-TEE driver.

Introduces struct optee_msg_param_fmem which carries all information
needed when OP-TEE is calling FFA_MEM_RETRIEVE_REQ to get the shared
memory reference mapped by the hypervisor in S-EL2. Register usage is
also updated to include the information needed.

The FF-A part of this driver is enabled if CONFIG_ARM_FFA_TRANSPORT is
enabled.

[1] https://developer.arm.com/documentation/den0077/latest
Acked-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>optee: isolate smc abi</title>
<updated>2021-10-18T09:44:23Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2021-07-21T14:30:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c51a564a5b48355f30309b84cdffe3f96d1ae0d3'/>
<id>urn:sha1:c51a564a5b48355f30309b84cdffe3f96d1ae0d3</id>
<content type='text'>
Isolate the ABI based on raw SMCs. Code specific to the raw SMC ABI is
moved into smc_abi.c. This makes room for other ABIs with a clear
separation.

The driver changes to use module_init()/module_exit() instead of
module_platform_driver(). The platform_driver_register() and
platform_driver_unregister() functions called directly to keep the same
behavior. This is needed because module_platform_driver() is based on
module_driver() which can only be used once in a module.

A function optee_rpc_cmd() is factored out from the function
handle_rpc_func_cmd() to handle the ABI independent part of RPC
processing.

This patch is not supposed to change the driver behavior, it's only a
matter of reorganizing the code.

Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>optee: refactor driver with internal callbacks</title>
<updated>2021-10-15T09:55:42Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2021-03-25T14:08:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4602c5842f649da2fbd2cea3560af750cfbd59e3'/>
<id>urn:sha1:4602c5842f649da2fbd2cea3560af750cfbd59e3</id>
<content type='text'>
The OP-TEE driver is refactored with three internal callbacks replacing
direct calls to optee_from_msg_param(), optee_to_msg_param() and
optee_do_call_with_arg().

These functions a central to communicating with OP-TEE in secure world
by using the SMC Calling Convention directly.

This refactoring makes room for using other primitives to communicate
with OP-TEE in secure world while being able to reuse as much as
possible from the present driver.

Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>optee: simplify optee_release()</title>
<updated>2021-10-15T09:55:41Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2021-03-25T14:08:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c0ab6db39a908d86ed44e8a5632548e2ec1b4dca'/>
<id>urn:sha1:c0ab6db39a908d86ed44e8a5632548e2ec1b4dca</id>
<content type='text'>
Simplifies optee_release() with a new helper function,
optee_close_session_helper() which has been factored out from
optee_close_session().

A separate optee_release_supp() is added for the supplicant device.

Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: Fix missing devices unregister during optee_remove</title>
<updated>2021-10-12T11:24:39Z</updated>
<author>
<name>Sumit Garg</name>
</author>
<published>2021-10-12T07:31:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7f565d0ead264329749c0da488de9c8dfa2f18ce'/>
<id>urn:sha1:7f565d0ead264329749c0da488de9c8dfa2f18ce</id>
<content type='text'>
When OP-TEE driver is built as a module, OP-TEE client devices
registered on TEE bus during probe should be unregistered during
optee_remove. So implement optee_unregister_devices() accordingly.

Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
Reported-by: Sudeep Holla &lt;sudeep.holla@arm.com&gt;
Signed-off-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: Correct inappropriate usage of TEE_SHM_DMA_BUF flag</title>
<updated>2021-07-21T05:55:50Z</updated>
<author>
<name>Sumit Garg</name>
</author>
<published>2021-06-14T22:33:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=376e4199e327a5cf29b8ec8fb0f64f3d8b429819'/>
<id>urn:sha1:376e4199e327a5cf29b8ec8fb0f64f3d8b429819</id>
<content type='text'>
Currently TEE_SHM_DMA_BUF flag has been inappropriately used to not
register shared memory allocated for private usage by underlying TEE
driver: OP-TEE in this case. So rather add a new flag as TEE_SHM_PRIV
that can be utilized by underlying TEE drivers for private allocation
and usage of shared memory.

With this corrected, allow tee_shm_alloc_kernel_buf() to allocate a
shared memory region without the backing of dma-buf.

Cc: stable@vger.kernel.org
Signed-off-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Co-developed-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Signed-off-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Reviewed-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>optee: Clear stale cache entries during initialization</title>
<updated>2021-07-21T05:39:44Z</updated>
<author>
<name>Tyler Hicks</name>
</author>
<published>2021-06-14T22:33:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b5c10dd04b7418793517e3286cde5c04759a86de'/>
<id>urn:sha1:b5c10dd04b7418793517e3286cde5c04759a86de</id>
<content type='text'>
The shm cache could contain invalid addresses if
optee_disable_shm_cache() was not called from the .shutdown hook of the
previous kernel before a kexec. These addresses could be unmapped or
they could point to mapped but unintended locations in memory.

Clear the shared memory cache, while being careful to not translate the
addresses returned from OPTEE_SMC_DISABLE_SHM_CACHE, during driver
initialization. Once all pre-cache shm objects are removed, proceed with
enabling the cache so that we know that we can handle cached shm objects
with confidence later in the .shutdown hook.

Cc: stable@vger.kernel.org
Signed-off-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Reviewed-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>optee: fix tee out of memory failure seen during kexec reboot</title>
<updated>2021-07-21T05:39:43Z</updated>
<author>
<name>Allen Pais</name>
</author>
<published>2021-06-14T22:33:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f25889f93184db8b07a543cc2bbbb9a8fcaf4333'/>
<id>urn:sha1:f25889f93184db8b07a543cc2bbbb9a8fcaf4333</id>
<content type='text'>
The following out of memory errors are seen on kexec reboot
from the optee core.

[    0.368428] tee_bnxt_fw optee-clnt0: tee_shm_alloc failed
[    0.368461] tee_bnxt_fw: probe of optee-clnt0 failed with error -22

tee_shm_release() is not invoked on dma shm buffer.

Implement .shutdown() method to handle the release of the buffers
correctly.

More info:
https://github.com/OP-TEE/optee_os/issues/3637

Cc: stable@vger.kernel.org
Signed-off-by: Allen Pais &lt;apais@linux.microsoft.com&gt;
Reviewed-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Reviewed-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
</feed>
