<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/tee, branch v5.4.150</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.150</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.150'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-08-15T11:08:02Z</updated>
<entry>
<title>tee: Correct inappropriate usage of TEE_SHM_DMA_BUF flag</title>
<updated>2021-08-15T11:08:02Z</updated>
<author>
<name>Sumit Garg</name>
<email>sumit.garg@linaro.org</email>
</author>
<published>2021-06-14T22:33:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=236aca70929db3aa87dfb8fbc5329aa027a62e91'/>
<id>urn:sha1:236aca70929db3aa87dfb8fbc5329aa027a62e91</id>
<content type='text'>
[ Upstream commit 376e4199e327a5cf29b8ec8fb0f64f3d8b429819 ]

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;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>optee: Fix memory leak when failing to register shm pages</title>
<updated>2021-08-12T11:21:01Z</updated>
<author>
<name>Tyler Hicks</name>
<email>tyhicks@linux.microsoft.com</email>
</author>
<published>2021-06-14T22:33:10Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3c712f14d8a9354a8807c15c64c8dd334499cc42'/>
<id>urn:sha1:3c712f14d8a9354a8807c15c64c8dd334499cc42</id>
<content type='text'>
commit ec185dd3ab257dc2a60953fdf1b6622f524cc5b7 upstream.

Free the previously allocated pages when we encounter an error condition
while attempting to register the pages with the secure world.

Fixes: a249dd200d03 ("tee: optee: Fix dynamic shm pool allocations")
Fixes: 5a769f6ff439 ("optee: Fix multi page dynamic shm pool alloc")
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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tee: add tee_shm_alloc_kernel_buf()</title>
<updated>2021-08-12T11:21:01Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2021-06-14T22:33:14Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0572199b78b39d09757688217245fb933d2e4752'/>
<id>urn:sha1:0572199b78b39d09757688217245fb933d2e4752</id>
<content type='text'>
commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream.

Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory
from a kernel driver. This function can later be made more lightweight
by unnecessary dma-buf export.

Cc: stable@vger.kernel.org
Reviewed-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
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>optee: Clear stale cache entries during initialization</title>
<updated>2021-08-12T11:21:01Z</updated>
<author>
<name>Tyler Hicks</name>
<email>tyhicks@linux.microsoft.com</email>
</author>
<published>2021-06-14T22:33:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b247bf412cc235c0d9e33407364f620be5a43d56'/>
<id>urn:sha1:b247bf412cc235c0d9e33407364f620be5a43d56</id>
<content type='text'>
commit b5c10dd04b7418793517e3286cde5c04759a86de upstream.

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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: do not check memref size on return from Secure World</title>
<updated>2021-05-11T12:04:06Z</updated>
<author>
<name>Jerome Forissier</name>
<email>jerome@forissier.org</email>
</author>
<published>2021-03-22T10:40:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fe53f8fd64d7ef200a189a4430e9cd6bc7f5d537'/>
<id>urn:sha1:fe53f8fd64d7ef200a189a4430e9cd6bc7f5d537</id>
<content type='text'>
[ Upstream commit c650b8dc7a7910eb25af0aac1720f778b29e679d ]

When Secure World returns, it may have changed the size attribute of the
memory references passed as [in/out] parameters. The GlobalPlatform TEE
Internal Core API specification does not restrict the values that this
size can take. In particular, Secure World may increase the value to be
larger than the size of the input buffer to indicate that it needs more.

Therefore, the size check in optee_from_msg_param() is incorrect and
needs to be removed. This fixes a number of failed test cases in the
GlobalPlatform TEE Initial Configuratiom Test Suite v2_0_0_0-2017_06_09
when OP-TEE is compiled without dynamic shared memory support
(CFG_CORE_DYN_SHM=n).

Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Suggested-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Jerome Forissier &lt;jerome@forissier.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: replace might_sleep with cond_resched</title>
<updated>2021-02-03T22:25:58Z</updated>
<author>
<name>Rouven Czerwinski</name>
<email>r.czerwinski@pengutronix.de</email>
</author>
<published>2021-01-05T10:28:44Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=65543408f25750c0dbf46cd43c5866c7678d776e'/>
<id>urn:sha1:65543408f25750c0dbf46cd43c5866c7678d776e</id>
<content type='text'>
commit dcb3b06d9c34f33a249f65c08805461fb0c4325b upstream.

might_sleep() is a debugging aid and triggers rescheduling only for
certain kernel configurations. Replace with an explicit check and
reschedule to work for all kernel configurations. Fixes the following
trace:

  [  572.945146] rcu: INFO: rcu_sched self-detected stall on CPU
  [  572.949275] rcu:     0-....: (2099 ticks this GP) idle=572/1/0x40000002 softirq=7412/7412 fqs=974
  [  572.957964]  (t=2100 jiffies g=10393 q=21)
  [  572.962054] NMI backtrace for cpu 0
  [  572.965540] CPU: 0 PID: 165 Comm: xtest Not tainted 5.8.7 #1
  [  572.971188] Hardware name: STM32 (Device Tree Support)
  [  572.976354] [&lt;c011163c&gt;] (unwind_backtrace) from [&lt;c010b7f8&gt;] (show_stack+0x10/0x14)
  [  572.984080] [&lt;c010b7f8&gt;] (show_stack) from [&lt;c0511e4c&gt;] (dump_stack+0xc4/0xd8)
  [  572.991300] [&lt;c0511e4c&gt;] (dump_stack) from [&lt;c0519abc&gt;] (nmi_cpu_backtrace+0x90/0xc4)
  [  572.999130] [&lt;c0519abc&gt;] (nmi_cpu_backtrace) from [&lt;c0519bdc&gt;] (nmi_trigger_cpumask_backtrace+0xec/0x130)
  [  573.008706] [&lt;c0519bdc&gt;] (nmi_trigger_cpumask_backtrace) from [&lt;c01a5184&gt;] (rcu_dump_cpu_stacks+0xe8/0x110)
  [  573.018453] [&lt;c01a5184&gt;] (rcu_dump_cpu_stacks) from [&lt;c01a4234&gt;] (rcu_sched_clock_irq+0x7fc/0xa88)
  [  573.027416] [&lt;c01a4234&gt;] (rcu_sched_clock_irq) from [&lt;c01acdd0&gt;] (update_process_times+0x30/0x8c)
  [  573.036291] [&lt;c01acdd0&gt;] (update_process_times) from [&lt;c01bfb90&gt;] (tick_sched_timer+0x4c/0xa8)
  [  573.044905] [&lt;c01bfb90&gt;] (tick_sched_timer) from [&lt;c01adcc8&gt;] (__hrtimer_run_queues+0x174/0x358)
  [  573.053696] [&lt;c01adcc8&gt;] (__hrtimer_run_queues) from [&lt;c01aea2c&gt;] (hrtimer_interrupt+0x118/0x2bc)
  [  573.062573] [&lt;c01aea2c&gt;] (hrtimer_interrupt) from [&lt;c09ad664&gt;] (arch_timer_handler_virt+0x28/0x30)
  [  573.071536] [&lt;c09ad664&gt;] (arch_timer_handler_virt) from [&lt;c0190f50&gt;] (handle_percpu_devid_irq+0x8c/0x240)
  [  573.081109] [&lt;c0190f50&gt;] (handle_percpu_devid_irq) from [&lt;c018ab8c&gt;] (generic_handle_irq+0x34/0x44)
  [  573.090156] [&lt;c018ab8c&gt;] (generic_handle_irq) from [&lt;c018b194&gt;] (__handle_domain_irq+0x5c/0xb0)
  [  573.098857] [&lt;c018b194&gt;] (__handle_domain_irq) from [&lt;c052ac50&gt;] (gic_handle_irq+0x4c/0x90)
  [  573.107209] [&lt;c052ac50&gt;] (gic_handle_irq) from [&lt;c0100b0c&gt;] (__irq_svc+0x6c/0x90)
  [  573.114682] Exception stack(0xd90dfcf8 to 0xd90dfd40)
  [  573.119732] fce0:                                                       ffff0004 00000000
  [  573.127917] fd00: 00000000 00000000 00000000 00000000 00000000 00000000 d93493cc ffff0000
  [  573.136098] fd20: d2bc39c0 be926998 d90dfd58 d90dfd48 c09f3384 c01151f0 400d0013 ffffffff
  [  573.144281] [&lt;c0100b0c&gt;] (__irq_svc) from [&lt;c01151f0&gt;] (__arm_smccc_smc+0x10/0x20)
  [  573.151854] [&lt;c01151f0&gt;] (__arm_smccc_smc) from [&lt;c09f3384&gt;] (optee_smccc_smc+0x3c/0x44)
  [  573.159948] [&lt;c09f3384&gt;] (optee_smccc_smc) from [&lt;c09f4170&gt;] (optee_do_call_with_arg+0xb8/0x154)
  [  573.168735] [&lt;c09f4170&gt;] (optee_do_call_with_arg) from [&lt;c09f4638&gt;] (optee_invoke_func+0x110/0x190)
  [  573.177786] [&lt;c09f4638&gt;] (optee_invoke_func) from [&lt;c09f1ebc&gt;] (tee_ioctl+0x10b8/0x11c0)
  [  573.185879] [&lt;c09f1ebc&gt;] (tee_ioctl) from [&lt;c029f62c&gt;] (ksys_ioctl+0xe0/0xa4c)
  [  573.193101] [&lt;c029f62c&gt;] (ksys_ioctl) from [&lt;c0100060&gt;] (ret_fast_syscall+0x0/0x54)
  [  573.200750] Exception stack(0xd90dffa8 to 0xd90dfff0)
  [  573.205803] ffa0:                   be926bf4 be926a78 00000003 8010a403 be926908 004e3cf8
  [  573.213987] ffc0: be926bf4 be926a78 00000000 00000036 be926908 be926918 be9269b0 bffdf0f8
  [  573.222162] ffe0: b6d76fb0 be9268fc b6d66621 b6c7e0d8

seen on STM32 DK2 with CONFIG_PREEMPT_NONE.

Fixes: 9f02b8f61f29 ("tee: optee: add might_sleep for RPC requests")
Signed-off-by: Rouven Czerwinski &lt;r.czerwinski@pengutronix.de&gt;
Tested-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
[jw: added fixes tag + small adjustments in the code]
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>optee: add writeback to valid memory type</title>
<updated>2020-12-02T07:49:53Z</updated>
<author>
<name>Rui Miguel Silva</name>
<email>rui.silva@linaro.org</email>
</author>
<published>2020-11-13T15:06:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5c4c6b2be717f1bcec6f6b0373f93761a76375ba'/>
<id>urn:sha1:5c4c6b2be717f1bcec6f6b0373f93761a76375ba</id>
<content type='text'>
[ Upstream commit 853735e404244f5496cdb6188c5ed9a0f9627ee6 ]

Only in smp systems the cache policy is setup as write alloc, in
single cpu systems the cache policy is set as writeback and it is
normal memory, so, it should pass the is_normal_memory check in the
share memory registration.

Add the right condition to make it work in no smp systems.

Fixes: cdbcf83d29c1 ("tee: optee: check type of registered shared memory")
Signed-off-by: Rui Miguel Silva &lt;rui.silva@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: Fix compilation issue with nommu</title>
<updated>2020-02-05T21:22:49Z</updated>
<author>
<name>Vincenzo Frascino</name>
<email>vincenzo.frascino@arm.com</email>
</author>
<published>2020-01-10T12:28:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=281f32e343826e871a4cb795020335da263b22fc'/>
<id>urn:sha1:281f32e343826e871a4cb795020335da263b22fc</id>
<content type='text'>
[ Upstream commit 9e0caab8e0f96f0af7d1dd388e62f44184a75372 ]

The optee driver uses specific page table types to verify if a memory
region is normal. These types are not defined in nommu systems. Trying
to compile the driver in these systems results in a build error:

  linux/drivers/tee/optee/call.c: In function ‘is_normal_memory’:
  linux/drivers/tee/optee/call.c:533:26: error: ‘L_PTE_MT_MASK’ undeclared
     (first use in this function); did you mean ‘PREEMPT_MASK’?
     return (pgprot_val(p) &amp; L_PTE_MT_MASK) == L_PTE_MT_WRITEALLOC;
                             ^~~~~~~~~~~~~
                             PREEMPT_MASK
  linux/drivers/tee/optee/call.c:533:26: note: each undeclared identifier is
     reported only once for each function it appears in
  linux/drivers/tee/optee/call.c:533:44: error: ‘L_PTE_MT_WRITEALLOC’ undeclared
     (first use in this function)
     return (pgprot_val(p) &amp; L_PTE_MT_MASK) == L_PTE_MT_WRITEALLOC;
                                            ^~~~~~~~~~~~~~~~~~~

Make the optee driver depend on MMU to fix the compilation issue.

Signed-off-by: Vincenzo Frascino &lt;vincenzo.frascino@arm.com&gt;
[jw: update commit title]
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>optee: Fix multi page dynamic shm pool alloc</title>
<updated>2020-01-26T09:01:09Z</updated>
<author>
<name>Sumit Garg</name>
<email>sumit.garg@linaro.org</email>
</author>
<published>2019-12-30T13:22:40Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=15763f047ea2785a253d53edc91892ed7acb304f'/>
<id>urn:sha1:15763f047ea2785a253d53edc91892ed7acb304f</id>
<content type='text'>
[ Upstream commit 5a769f6ff439cedc547395a6dc78faa26108f741 ]

optee_shm_register() expected pages to be passed as an array of page
pointers rather than as an array of contiguous pages. So fix that via
correctly passing pages as per expectation.

Fixes: a249dd200d03 ("tee: optee: Fix dynamic shm pool allocations")
Reported-by: Vincent Cao &lt;vincent.t.cao@intel.com&gt;
Signed-off-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Tested-by: Vincent Cao &lt;vincent.t.cao@intel.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: fix device enumeration error handling</title>
<updated>2020-01-26T09:01:07Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2019-11-06T15:48:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b30a9b012a4e9b400a3e3caa0e4c83d77089ef7b'/>
<id>urn:sha1:b30a9b012a4e9b400a3e3caa0e4c83d77089ef7b</id>
<content type='text'>
[ Upstream commit 03212e347f9443e524d6383c6806ac08295c1fb0 ]

Prior to this patch in optee_probe() when optee_enumerate_devices() was
called the struct optee was fully initialized. If
optee_enumerate_devices() returns an error optee_probe() is supposed to
clean up and free the struct optee completely, but will at this late
stage need to call optee_remove() instead. This isn't done and thus
freeing the struct optee prematurely.

With this patch the call to optee_enumerate_devices() is done after
optee_probe() has returned successfully and in case
optee_enumerate_devices() fails everything is cleaned up with a call to
optee_remove().

Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
