Commit graph

370 commits

Author SHA1 Message Date
Kees Cook
189f164e57 Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses
Conversion performed via this Coccinelle script:

  // SPDX-License-Identifier: GPL-2.0-only
  // Options: --include-headers-for-types --all-includes --include-headers --keep-comments
  virtual patch

  @gfp depends on patch && !(file in "tools") && !(file in "samples")@
  identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,
 		    kzalloc_obj,kzalloc_objs,kzalloc_flex,
		    kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,
		    kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};
  @@

  	ALLOC(...
  -		, GFP_KERNEL
  	)

  $ make coccicheck MODE=patch COCCI=gfp.cocci

Build and boot tested x86_64 with Fedora 42's GCC and Clang:

Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01
Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01

Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-22 08:26:33 -08:00
Linus Torvalds
32a92f8c89 Convert more 'alloc_obj' cases to default GFP_KERNEL arguments
This converts some of the visually simpler cases that have been split
over multiple lines.  I only did the ones that are easy to verify the
resulting diff by having just that final GFP_KERNEL argument on the next
line.

Somebody should probably do a proper coccinelle script for this, but for
me the trivial script actually resulted in an assertion failure in the
middle of the script.  I probably had made it a bit _too_ trivial.

So after fighting that far a while I decided to just do some of the
syntactically simpler cases with variations of the previous 'sed'
scripts.

The more syntactically complex multi-line cases would mostly really want
whitespace cleanup anyway.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 20:03:00 -08:00
Linus Torvalds
bf4afc53b7 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
This was done entirely with mindless brute force, using

    git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' |
        xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/'

to convert the new alloc_obj() users that had a simple GFP_KERNEL
argument to just drop that argument.

Note that due to the extreme simplicity of the scripting, any slightly
more complex cases spread over multiple lines would not be triggered:
they definitely exist, but this covers the vast bulk of the cases, and
the resulting diff is also then easier to check automatically.

For the same reason the 'flex' versions will be done as a separate
conversion.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 17:09:51 -08:00
Kees Cook
69050f8d6d treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:

Single allocations:	kmalloc(sizeof(TYPE), ...)
are replaced with:	kmalloc_obj(TYPE, ...)

Array allocations:	kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with:	kmalloc_objs(TYPE, COUNT, ...)

Flex array allocations:	kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with:	kmalloc_flex(*PTR, FAM, COUNT, ...)

(where TYPE may also be *VAR)

The resulting allocations no longer return "void *", instead returning
"TYPE *".

Signed-off-by: Kees Cook <kees@kernel.org>
2026-02-21 01:02:28 -08:00
Arnd Bergmann
ee5dde7ed6 TEE sysfs for 6.20
- Add an optional generic sysfs attribute for TEE revision
 - Implement revision reporting for OP-TEE using both SMC and FF-A ABIs
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmlrgt0aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H7ieA/+LWgQ6n9yUUxZ4hnK2538
 lSg9vkBuGYeMcObNyKwtehB3+ivjtQB6ZTdV8OCVhduKFXLBb/6Iedf1zHrVrEi2
 qXTZutfzPNFD4wfD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aYtT69c3uGjV+1MnhsB7RVjqA+xfhK8LZajseb
 r0ZSReUJF+KpguHqJfNj+bVQQm1KFRsIqurB0Cn7J+fwRAiS5D9Mqku/OGYso2GE
 RGPavlndN8ytZWJiYKyzsBOkAiYR0jejJbwMH8OA72/mcDsxibLafSr5DSeYpmmS
 AfXPGkZEluNYW0UccrsFov+rZ6AHiGCuElNVZ2W1l1QKc641aS1y1Ar987ysq1PC
 KrpSHDihrzbBcIgTKCQoL19vaqusOyDk6RB263zOLrgEWnelxVSLcQWEDTPjX9dV
 4Ys/DE+O1dZIZ0Waq88InzpIZlUcLlVMJEEiXSRxIGskFYNgaZM=
 =lDdi
 -----END PGP SIGNATURE-----

Merge tag 'tee-sysfs-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

TEE sysfs for 6.20

- Add an optional generic sysfs attribute for TEE revision
- Implement revision reporting for OP-TEE using both SMC and FF-A ABIs

* tag 'tee-sysfs-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: optee: store OS revision for TEE core
  tee: add revision sysfs attribute

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-21 16:30:52 +01:00
Arnd Bergmann
4b45c2f3f8 AMDTEE update for 6.20
Remove unused return variables
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmlrgWoaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H7p3Q//boaLed/kX6xTiE4o23DY
 AvwjVD8lDjHWNkxuacJa2S/aW2Ocz4tspc/usQleoH69UKbsODiPddtbclM3Zp8N
 zT2ge9tl+6rzmmjmmO0y5k5GhxGfvtDfUwXoIfoHcoS+mes7Eo0SlXGp6QL25yT3
 bRh5ry+LVe5J6JnWkLZzV/YpEmw+7IFn94oeaZ2mZp6jHh2vYB5aYxlVCQUyQMpa
 17jc+Kj4gYeBgu7ct+CWC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CYF8b+IAGLT0cdwztnTkPMBCo2y3
 /vt2DRZi4Lm8Ip7eigylySHeCBBKf/irQekoAmXIGofBJQbmd+hXXO1jFSau+qv3
 EOOF8zvxvbiTjrazFBF79z/IGknU4bUaVg3cBBIA1ukogGLMGHhGQoDX/owpyXst
 51BevQuCdkSTFD+fkeePmhxqz5zuS48kELj7qgxcPpmstKOcSaQ=
 =6nWs
 -----END PGP SIGNATURE-----

Merge tag 'amdtee-update-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

AMDTEE update for 6.20

Remove unused return variables

* tag 'amdtee-update-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: amdtee: Remove unused return variables

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-21 16:29:54 +01:00
Arnd Bergmann
e6bea2f553 TEE bus callback for 6.20
- Move from generic device_driver to TEE bus-specific callbacks
 - Add module_tee_client_driver() and registration helpers to reduce
   boilerplate
 - Convert several client drivers (TPM, KEYS, firmware, EFI, hwrng,
   and RTC)
 - Update documentation and fix kernel-doc warnings
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmlrfQ0aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H6RShAAmh3/5z4pOV2i9zq6CAkY
 nbt8BLkf6BcNA06I+uAISpESuIaRBXd89pZBVKoh1axlncPSpG2rth7IViGqvB5w
 9KtZmzGvQbGZLYMtmctdaz10SqKNG0l3w/v3kN8wfjBAr9eP+Ztfp/R9SwLTQVik
 Y8xHBdHQf6zJoZmE5GDcPQIkLSYr/BnH4ksxdQSUPi6bVkJZQkw5IyVd2tPOqozT
 dsUBQlEBmgdogQ3ZGp/iKi4gMZ9ehU0ZW+hiLx1KXpbUqJHQoEhQc7ZKEggbzdP1
 kpETTcjTmqUejoodtBzOo9EiW3ji4HLkaiBru3ZL895w3IMj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9zdGNDkBHw2KUoIntPjD8FB7
 rLO3MOBT6gGCz3oEHb75LUEd0YvHtLIkRvkIUjPgENFZ7ejJ2Zoot9ISxNYje/Tv
 bEyV/IUvqV26Evj2F0I/85r+SQKVacTBngJkC2rr+lU3ayRTxrQ=
 =DwU/
 -----END PGP SIGNATURE-----

Merge tag 'tee-bus-callback-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

TEE bus callback for 6.20

- Move from generic device_driver to TEE bus-specific callbacks
- Add module_tee_client_driver() and registration helpers to reduce
  boilerplate
- Convert several client drivers (TPM, KEYS, firmware, EFI, hwrng,
  and RTC)
- Update documentation and fix kernel-doc warnings

* tag 'tee-bus-callback-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tpm/tpm_ftpm_tee: Fix kdoc after function renames
  tpm/tpm_ftpm_tee: Make use of tee bus methods
  tpm/tpm_ftpm_tee: Make use of tee specific driver registration
  KEYS: trusted: Make use of tee bus methods
  KEYS: trusted: Migrate to use tee specific driver registration function
  firmware: tee_bnxt: Make use of tee bus methods
  firmware: tee_bnxt: Make use of module_tee_client_driver()
  firmware: arm_scmi: Make use of tee bus methods
  firmware: arm_scmi: optee: Make use of module_tee_client_driver()
  efi: stmm: Make use of tee bus methods
  efi: stmm: Make use of module_tee_client_driver()
  hwrng: optee - Make use of tee bus methods
  hwrng: optee - Make use of module_tee_client_driver()
  rtc: optee: Make use of tee bus methods
  rtc: optee: Migrate to use tee specific driver registration function
  tee: Adapt documentation to cover recent additions
  tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
  tee: Add some helpers to reduce boilerplate for tee client drivers

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-21 16:28:23 +01:00
Arnd Bergmann
08b67ff20f OP-TEE update for 6.20
- A micro optimization by making a local array static const
 - Update OP-TEE mailing list as moderated
 - Update an outdated comment for cmd_alloc_suppl()
 -----BEGIN PGP SIGNATURE-----
 
 iQJO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uxVjrHnBoT/CVxVu9gRdHkV8JUoFL5iE7+5lrbzKIKE
 QpOFhCNiOq+xmNl1oUcsP2V+F30XpOrrZ48HBjWhUz3jbweXHvKVWlB5oQweIsdV
 QznvdMymtALncJy/KvYnA5bXT2zE3Dox1h6ExgBGuvRHTEcOUuR7BaM06efMbCN1
 7iENA5evIpSSMcw9NMXdN4Dkbr3Y3505HbPQrmFZyuVJdfMuCgPy6AJe3jb0qxr1
 EYmqU3NibvH6rLidI/k/eCpGdzyASM9hN3Z7A2hTvlKRzL0ms3C8R1YBG08Jthg8
 89Lexux9Cask7+HHYJ/ZM5tIJ6/vkIwda9UTbng4BTaVc+J6LqFqadgQcWSd8fGb
 kbXJ3+4CeqV2V+/1LXj2is/HfXvPFBU1xpE93p6xXo554yKrNIoA5xueWpVKKI4B
 8gqBRbvrVpvgryj0oGtdb3zBPs8YBmhXpU48bRoihYyR5dKJOPkTEB7X6Nf4lG3Y
 nRHr/Ghg71nIyrPX+jJMrZllnp6PTEKzayJyCZTomf8t5STaB78=
 =diWz
 -----END PGP SIGNATURE-----

Merge tag 'optee-update-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

OP-TEE update for 6.20

- A micro optimization by making a local array static const
- Update OP-TEE mailing list as moderated
- Update an outdated comment for cmd_alloc_suppl()

* tag 'optee-update-for-6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  optee: make read-only array attr static const
  MAINTAINERS: Mark the OP-TEE mailing list moderated
  optee: update outdated comment

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2026-01-21 16:27:27 +01:00
Colin Ian King
94ea7063fa optee: make read-only array attr static const
Don't populate the read-only array attr on the stack at run
time, instead make it static const.

Signed-off-by: Colin Ian King <coking@nvidia.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-16 10:35:05 +01:00
Aristo Chen
c19faf5a62 tee: optee: store OS revision for TEE core
Collect OP-TEE OS revision from secure world for both SMC and FF-A
ABIs, store it in the OP-TEE driver, and expose it through the
generic get_tee_revision() callback.

Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
2026-01-15 10:35:14 +01:00
Aristo Chen
241bdf7253 tee: add revision sysfs attribute
Add a generic TEE revision sysfs attribute backed by a new
optional get_tee_revision() callback. The revision string is
diagnostic-only and must not be used to infer feature support.

Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-14 12:04:34 +01:00
Thorsten Blum
a0db08f47c tee: amdtee: Remove unused return variables
In tee_params_to_amd_params() and amd_params_to_tee_params(), return 0
directly and remove the unused return variables.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-14 10:20:51 +01:00
Julia Lawall
499ea377ed optee: update outdated comment
The function cmd_alloc_suppl() was renamed as
optee_rpc_cmd_alloc_suppl() in commit c51a564a5b
("optee: isolate smc abi").  Update the comment
accordingly.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-05 10:34:28 +01:00
Krzysztof Kozlowski
1c05d9a4ca tee: qcomtee: user: Fix confusing cleanup.h syntax
Initializing automatic __free variables to NULL without need (e.g.
branches with different allocations), followed by actual allocation is
in contrary to explicit coding rules guiding cleanup.h:

"Given that the "__free(...) = NULL" pattern for variables defined at
the top of the function poses this potential interdependency problem the
recommendation is to always define and assign variables in one statement
and not group variable definitions at the top of the function when
__free() is used."

Code does not have a bug, but is less readable and uses discouraged
coding practice, so fix that by moving declaration to the place of
assignment.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-05 10:21:09 +01:00
Krzysztof Kozlowski
7c4c14ad3d tee: qcomtee: mem: Fix confusing cleanup.h syntax
Initializing automatic __free variables to NULL without need (e.g.
branches with different allocations), followed by actual allocation is
in contrary to explicit coding rules guiding cleanup.h:

"Given that the "__free(...) = NULL" pattern for variables defined at
the top of the function poses this potential interdependency problem the
recommendation is to always define and assign variables in one statement
and not group variable definitions at the top of the function when
__free() is used."

Code does not have a bug, but is less readable and uses discouraged
coding practice, so fix that by moving declaration to the place of
assignment.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-05 10:21:09 +01:00
Krzysztof Kozlowski
4cc19518da tee: qcomtee: call: Fix confusing cleanup.h syntax
Initializing automatic __free variables to NULL without need (e.g.
branches with different allocations), followed by actual allocation is
in contrary to explicit coding rules guiding cleanup.h:

"Given that the "__free(...) = NULL" pattern for variables defined at
the top of the function poses this potential interdependency problem the
recommendation is to always define and assign variables in one statement
and not group variable definitions at the top of the function when
__free() is used."

Code does not have a bug, but is less readable and uses discouraged
coding practice, so fix that by moving declaration to the place of
assignment.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2026-01-05 10:21:09 +01:00
Uwe Kleine-König
71a3346572 tee: Add probe, remove and shutdown bus callbacks to tee_client_driver
Introduce a bus specific probe, remove and shutdown function. For now
this only allows to get rid of a cast of the generic device to a
tee_client device in the drivers and changes the remove prototype to
return void---a non-zero return value is ignored anyhow.

The objective is to get rid of users of struct device_driver callbacks
.probe(), .remove() and .shutdown() to eventually remove these. Until
all tee_client drivers are converted this results in a runtime warning
about the drivers needing an update because there is a bus probe
function and a driver probe function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-12-17 18:28:28 +01:00
Uwe Kleine-König
a707eda330 tee: Add some helpers to reduce boilerplate for tee client drivers
Similar to platform drivers (and others) create dedicated register and
unregister functions and a macro to simplify modules that only need to
handle driver registration in their init and exit handlers.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-12-17 18:28:27 +01:00
Arnd Bergmann
fe7cdcd1ba QCOMTEE fixes2 for v6.18
- initialize result before use in in error path
 - fix uninitialized pointers with free attribute
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmka6uoaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H625hAAkeOfInc+UE3Y7KAuQ/o4
 hbZE1wEQVJmCu1X7ugMowR7PWkntgOotUQPvGzgo8041UFpHCKSX+0y3yKud92yh
 imiy7Gx9OxKYHUEC8J7SIuZpqJ2x87NPpLafA3+qLcYBAguY/aibpfhbDi9oi2qk
 VZwisQuz5Gc5K2WJ5WUgj9Hxh9AlQQ6K8/oFl9QDZZv1H3GSYgiQJbVOJDVwjGir
 4Ttm5b1NKMd8Jpa+sFkHOwQgOSvWujcUBRA+osopkz3JRRohgUrFQ+ShDc4/+ioe
 NaQr6tJEiuBHihkSexPVyKRO7WyrIB/g33K5vB1GVwx/9MD8rWm/gU69jIMQn9PL
 sNt6AMZx4A8MTL56slM9d9GYHQelFSS4alXgQW4C+i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NOeWFPlnxr7BBASVSZjI
 oiCcLW8GqCqJubMBjydso3q85AW8ig5phRCxuTP3kEbZPb71hMU=
 =r+Hg
 -----END PGP SIGNATURE-----

Merge tag 'qcomtee-fixes2-for-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into arm/fixes

QCOMTEE fixes2 for v6.18

- initialize result before use in in error path
- fix uninitialized pointers with free attribute

* tag 'qcomtee-fixes2-for-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: qcomtee: initialize result before use in release worker
  tee: qcomtee: fix uninitialized pointers with free attribute

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2025-11-21 21:27:20 +01:00
Amirreza Zarrabi
e19d7f7e92 tee: qcomtee: initialize result before use in release worker
Initialize result to 0 so the error path doesn't read it
uninitialized when the invoke fails. Fixes a Smatch warning.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/op-tee/7c1e0de2-7d42-4c6b-92fe-0e4fe5d650b5@oss.qualcomm.com/
Fixes: d6e290837e ("tee: add Qualcomm TEE driver")
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-11-17 10:19:29 +01:00
Ally Heev
ac5ae0a5ce tee: qcomtee: fix uninitialized pointers with free attribute
Uninitialized pointers with `__free` attribute can cause undefined
behavior as the memory assigned randomly to the pointer is freed
automatically when the pointer goes out of scope.

qcomtee doesn't have any bugs related to this as of now, but
it is better to initialize and assign pointers with `__free`
attribute in one statement to ensure proper scope-based cleanup

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
Signed-off-by: Ally Heev <allyheev@gmail.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-11-14 08:42:07 +01:00
Arnd Bergmann
1d4e7d9f6b TEE QTEE fixes for v6.18
- Adds ARCH_QCOM dependency for the QTEE driver
 - Fixing return values for copy_from_user() failures
 - Guarding against potential off by one read
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmjfv58aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H6uxA/+NFregDoinXbAYFzEjoTM
 g2tVAEe/6+1XWN37DngvWvV4ndnbq49n9EYqR4mWRz1KH5sCmTjpzolOpLvLmKd3
 woZeqPP6gpbmiKQQ08cK34axhfi0xAPAK9B9qiat5ARBN1CoT0E+OLp4u9B4RX7/
 zf2jU8PI2JrqqbABmUIkfqbHgP5Hh9TIzE3RH4oI/wLQl+F2goKBx+p2X8BEqmlw
 xRpD4nKMk8Hui/oIDwe9BJ5AzVb4hG/PY9O9UQRaW/WCifcIyWYWbE3cnnN1YtmO
 yRcGlalBa/wpRQR94pUUyrb1qhbb/PcdSa46SQ2nL8yQ1C11+kr6BEW1KTV6RRBU
 guKK8D41ZLSUKDVvtiJD7nszhwrGdHafw/V9Kqu9KGbhba3gUJhClpDRS/1boyZ8
 UlDpWz4GAQ6Ky1QZrq7yPJ2qrrTq6GVDPVRt7DLqnupkF9ASa5Ii96IEqK4IZZB5
 5VRlpFLTKdPjmxvBvAtcvBp3ryOG2JOlwCkUlzfAmjeHdNY7duaNHy+XxwqzhiLY
 KREZD7c3H3ghJbrC6UY+anBRsP0uIAn1C3wDTNgprVTsjF6IZOy82ZJmUqxT+yU5
 QEgXjGj9g1LvydujhPfQ0O+t8D5h0guEbw4iHSHCAL7fYL0iK1ua3+52sQXbs79L
 vJu6+0DSqUdju5wlgta0kao=
 =z/ma
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmjyRB0ACgkQmmx57+YA
 GNmszQ/7BEPFQZmUCW26t8krpaE4MBJpJNsXT3GG3CMK2fmu/rdUf2iB0cXbEi9S
 XYwNng5qYPw1BcqbJR4PbUDpOa6td5Byucq6h+A2dDnBqiguOwtC8rpi1kz2y6Gx
 N0laWR8UUYd7Oh9aFZheX0ye01GzHXsNYZTuCqSE1XIpzVLFJFYHYSVFE/YEhQ+5
 YjDQebJVpgGlacdHZy/UywwPQqUiL67WrGFhwyvep1iAxQh8gltVPfBNqnD9QzdC
 zKIWL/XmlPHXxDsbB1ZvD8pYkPIZh3pqd+8kpkQzElEErJYLHpHTcHbNQxGzsUxC
 9A5mlexBIQUg5hyFMzoulFwb44JCEa59SoSbXKDzbHZAkQwKPztg4TGTMdsbuXQv
 Lyr+3fJ1fO1O44OXFcLh6WpKmaFna9kyVcbsW9FSRU5RWYOerfBgyk6NlQ8vSn6U
 IDPXccpxbvG2jWMWdW/H5YtJ3WJjue5gm/wKN3K2Mzwimj57AHQEHvTxc9zzSYD4
 A3yNdgcfwIipLVWFNqY+HDpKDzjaay0GEaGgNLEj/syuK0GfaRm9sKeS05B3weOb
 kipNi6jf/0ZEg3vl5tMBA687Y+cx0J4VuS5cCMwoExpl0RzZCriXA0uMfOE7ovdp
 b8134JCTLxhSdONUX2jK9mAXNOK0ovmwjuWqaVvlNb4w0YCQPAw=
 =G+xF
 -----END PGP SIGNATURE-----

Merge tag 'tee-qcomtee-fixes-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into arm/fixes

TEE QTEE fixes for v6.18

- Adds ARCH_QCOM dependency for the QTEE driver
- Fixing return values for copy_from_user() failures
- Guarding against potential off by one read

* tag 'tee-qcomtee-fixes-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: QCOMTEE should depend on ARCH_QCOM
  tee: qcom: return -EFAULT instead of -EINVAL if copy_from_user() fails
  tee: qcom: prevent potential off by one read
2025-10-17 15:26:52 +02:00
Geert Uytterhoeven
3b63efa21b tee: QCOMTEE should depend on ARCH_QCOM
The Qualcomm Trusted Execution Environment (QTEE) is only available on
Qualcomm SoCs.  Hence add a dependency on ARCH_QCOM, to prevent asking
the user about this driver when configuring a kernel without Qualcomm
platform support.

Fixes: d6e290837e ("tee: add Qualcomm TEE driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-10-02 08:31:10 +02:00
Linus Torvalds
38057e3236 soc: driver updates for 6.18
Lots of platform specific updates for Qualcomm SoCs, including a
 new TEE subsystem driver for the Qualcomm QTEE firmware interface.
 
 Added support for the Apple A11 SoC in drivers that are shared with the
 M1/M2 series, among more updates for those.
 
 Smaller platform specific driver updates for Renesas, ASpeed, Broadcom,
 Nvidia, Mediatek, Amlogic, TI, Allwinner, and Freescale SoCs.
 
 Driver updates in the cache controller, memory controller and reset
 controller subsystems.
 
 SCMI firmware updates to add more features and improve robustness.
 This includes support for having multiple SCMI providers in a single
 system.
 
 TEE subsystem support for protected DMA-bufs, allowing hardware to
 access memory areas that managed by the kernel but remain inaccessible
 from the CPU in EL1/EL0.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmjdpaoACgkQmmx57+YA
 GNnBXA//QgmFXYGG7QfB825mt0orKZxpfpLcwvqO7hkWgbXtl7Gokw2lGYN6bwLu
 zvY4MQ/bVoZ8R5uTVmuaSHBRsttSen8mBf+V0vzsBM/DRRVxvIN/7TESrY3J7Dtx
 J5syHKIBiUtdkDebWWC6jIElczIBItsd03Ln4Xjjt8Vas5YOO4n44zFrPo+FwlN/
 I6D2K86AiNZTtUCDMtB6VfJ6YtjYBWcWnJm7FXw/vE8FAXdZUnNWnZ8hbdQ5GaME
 JZGepUhONaOMUoGNZNaDGw511RdPhYzPjj9rCsIx2qdsRO9/4tJ8ccpW2aUMYh8c
 nA6w8Hj8jCwco6aYYrDUDV9uRtURDrmyJgTJBNLU05e/L+MuJ3IZNlzHFWlsxIAE
 vhyTdmg/P04ClQyixCl67IH/66F/0smX9C+1761LrD7GTdfR92KPl5W6q+DPBg/x
 yf+s2p3+f7ItV5XobKOrbf3w0xazeDb5o/EK8BufMx9vSe9bpzJ0gOf0CmNXEpyZ
 owAhbh6wXX1YwPcyA9LHv6gthyJwc/3fLu49ggMZP2rU01ccKOYn9H0cr7C8NVmy
 wEpJR0lp5aSw2oRkPkxB6sFmUohcpr8/OXGGJuvCXkYsUY1BEup4lewvbIWK4WoE
 c84kbbaHsjgFhe3IRlQw3G4KLYQT3jRtF7fH+gPx556BcI6K+lg=
 =mcZR
 -----END PGP SIGNATURE-----

Merge tag 'soc-drivers-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull SoC driver updates from Arnd Bergmann:
 "Lots of platform specific updates for Qualcomm SoCs, including a new
  TEE subsystem driver for the Qualcomm QTEE firmware interface.

  Added support for the Apple A11 SoC in drivers that are shared with
  the M1/M2 series, among more updates for those.

  Smaller platform specific driver updates for Renesas, ASpeed,
  Broadcom, Nvidia, Mediatek, Amlogic, TI, Allwinner, and Freescale
  SoCs.

  Driver updates in the cache controller, memory controller and reset
  controller subsystems.

  SCMI firmware updates to add more features and improve robustness.
  This includes support for having multiple SCMI providers in a single
  system.

  TEE subsystem support for protected DMA-bufs, allowing hardware to
  access memory areas that managed by the kernel but remain inaccessible
  from the CPU in EL1/EL0"

* tag 'soc-drivers-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (139 commits)
  soc/fsl/qbman: Use for_each_online_cpu() instead of for_each_cpu()
  soc: fsl: qe: Drop legacy-of-mm-gpiochip.h header from GPIO driver
  soc: fsl: qe: Change GPIO driver to a proper platform driver
  tee: fix register_shm_helper()
  pmdomain: apple: Add "apple,t8103-pmgr-pwrstate"
  dt-bindings: spmi: Add Apple A11 and T2 compatible
  serial: qcom-geni: Load UART qup Firmware from linux side
  spi: geni-qcom: Load spi qup Firmware from linux side
  i2c: qcom-geni: Load i2c qup Firmware from linux side
  soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem
  soc: qcom: geni-se: Cleanup register defines and update copyright
  dt-bindings: qcom: se-common: Add QUP Peripheral-specific properties for I2C, SPI, and SERIAL bus
  Documentation: tee: Add Qualcomm TEE driver
  tee: qcom: enable TEE_IOC_SHM_ALLOC ioctl
  tee: qcom: add primordial object
  tee: add Qualcomm TEE driver
  tee: increase TEE_MAX_ARG_SIZE to 4096
  tee: add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF
  tee: add TEE_IOCTL_PARAM_ATTR_TYPE_UBUF
  tee: add close_context to TEE driver operation
  ...
2025-10-01 17:32:51 -07:00
Arnd Bergmann
0a8c310491 TEE fix2 for v6.17
Fixing incorrect error handling for a call to iov_iter_extract_pages().
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmjTqXAaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H66iBAAiicxlbMnJ6xKMb2OwucX
 1KeS5BgskLj87ah3JThRiftAteEFRsq59hGwfqJ55fk2RY26e1qFxf5tj/54eKhb
 gyUj1xgqGhufgpmHptD/nmt6geX2uMU/XPAWj+jYTYHBsrnyFoukOGs4EAp15EKn
 /LWFKAq5GEZtFDZjnTIP3xZ+HfVL2PQovCXScCB8qxIqf/xYsixaqu/AoronRJZi
 VyMjt9cU/WfvYRstZODf3pb8mkmttAZXgp+9oyvCMGi0CRYC0imRuuiw0f8CwlJE
 CwG2h/K8WW6Wq2rxpCVs6FlwYJxmFNIyPS5SM9rugBTETIo8K+aBsMwoKBToEF2v
 9a/Ea+pFa5Z6dXPRPGl37O6HHcnOsAFhNh1FTooNL7rrnB3naq+CLsHqaw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Cs34aEcx2XnM
 pUk6K4KyzsUeXP4rxMW18m1ycKfhkrR7bmZDurJTroWyqnL25CE=
 =WKuv
 -----END PGP SIGNATURE-----

Merge tag 'tee-shm-register-fix-for-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

TEE fix2 for v6.17

Fixing incorrect error handling for a call to iov_iter_extract_pages().

* tag 'tee-shm-register-fix-for-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: fix register_shm_helper()

Link: https://lore.kernel.org/r/20250924083404.GA3747732@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2025-09-24 23:12:20 +02:00
Arnd Bergmann
ff0bebab77 Add Qualcomm TEE driver (QTEE)
This introduces a Trusted Execution Environment (TEE) driver for
 Qualcomm TEE (QTEE).
 
 QTEE enables Trusted Applications (TAs) and services to run securely. It
 uses an object-based interface, where each service is an object with
 sets of operations.
 
 Kernel and userspace services are also available to QTEE through a
 similar approach. QTEE makes callback requests that are converted into
 object invocations. These objects can represent services within the
 kernel or userspace process.
 
 We extend the TEE subsystem to understand object parameters and an ioctl
 call so client can invoke objects in QTEE:
   - TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_*
   - TEE_IOC_OBJECT_INVOKE
 
 The existing ioctl calls TEE_IOC_SUPPL_RECV and TEE_IOC_SUPPL_SEND are
 used for invoking services in the userspace process by QTEE.
 
 The TEE backend driver uses the QTEE Transport Message to communicate
 with QTEE. Interactions through the object INVOKE interface are
 translated into QTEE messages. Likewise, object invocations from QTEE
 for userspace objects are converted into SEND/RECV ioctl calls to
 supplicants.
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmjIS8AaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H4Wzg/+KnIx5XCYpj1QmL2H8vz5
 dkqB5+QEHfaUIKxUrbk7X/Gow7ZTO8IuDPai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HJKRtax8N/8M6UVVkdfshes5+
 reg0CIsOEQ9FqevyabEkirtiwvCF61knmhkKJjCnysd+18PCzLjxnNEVtY+tUomH
 sFI++U5MLuybfCAx4jqjW9dEUrLNiGF8sbJTkQ4ToBjRJR1YihT9aBHeoH7OCKfb
 izS03PlJqDAK7qGH7PTjabi/YmYujizxVrh29CsP3Lk0FfB5m2h2dsX1gr9Z9V5d
 hq0z8nAsh6UJt26Nfq2+hhMaC4AiBn4foc+YaCx/Z8pf9pejzEu/NxRNox05LZem
 EThVNRF1zTtI+0SCHGDAwV3Tuj/uuvrOl9FkcdPbP0kFErsW8b5zwZWIDvzqc2FT
 L39E/C91Ptoe9ZpmCAfnyzKcfI6FeEfXwtMsLcagHsm6pcVbfyc=
 =BBL5
 -----END PGP SIGNATURE-----

Merge tag 'tee-qcomtee-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

Add Qualcomm TEE driver (QTEE)

This introduces a Trusted Execution Environment (TEE) driver for
Qualcomm TEE (QTEE).

QTEE enables Trusted Applications (TAs) and services to run securely. It
uses an object-based interface, where each service is an object with
sets of operations.

Kernel and userspace services are also available to QTEE through a
similar approach. QTEE makes callback requests that are converted into
object invocations. These objects can represent services within the
kernel or userspace process.

We extend the TEE subsystem to understand object parameters and an ioctl
call so client can invoke objects in QTEE:
  - TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_*
  - TEE_IOC_OBJECT_INVOKE

The existing ioctl calls TEE_IOC_SUPPL_RECV and TEE_IOC_SUPPL_SEND are
used for invoking services in the userspace process by QTEE.

The TEE backend driver uses the QTEE Transport Message to communicate
with QTEE. Interactions through the object INVOKE interface are
translated into QTEE messages. Likewise, object invocations from QTEE
for userspace objects are converted into SEND/RECV ioctl calls to
supplicants.

* tag 'tee-qcomtee-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  Documentation: tee: Add Qualcomm TEE driver
  tee: qcom: enable TEE_IOC_SHM_ALLOC ioctl
  tee: qcom: add primordial object
  tee: add Qualcomm TEE driver
  tee: increase TEE_MAX_ARG_SIZE to 4096
  tee: add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF
  tee: add TEE_IOCTL_PARAM_ATTR_TYPE_UBUF
  tee: add close_context to TEE driver operation
  tee: allow a driver to allocate a tee_device without a pool

Link: https://lore.kernel.org/r/20250915174957.GA2040478@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2025-09-23 23:08:25 +02:00
Jens Wiklander
d5cf5b3706 tee: fix register_shm_helper()
In register_shm_helper(), fix incorrect error handling for a call to
iov_iter_extract_pages(). A case is missing for when
iov_iter_extract_pages() only got some pages and return a number larger
than 0, but not the requested amount.

This fixes a possible NULL pointer dereference following a bad input from
ioctl(TEE_IOC_SHM_REGISTER) where parts of the buffer isn't mapped.

Cc: stable@vger.kernel.org
Reported-by: Masami Ichikawa <masami256@gmail.com>
Closes: https://lore.kernel.org/op-tee/CACOXgS-Bo2W72Nj1_44c7bntyNYOavnTjJAvUbEiQfq=u9W+-g@mail.gmail.com/
Tested-by: Masami Ichikawa <masami256@gmail.com>
Fixes: 7bdee41575 ("tee: Use iov_iter to better support shared buffer registration")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-22 08:47:00 +02:00
Dan Carpenter
a9ee2c461e tee: qcom: return -EFAULT instead of -EINVAL if copy_from_user() fails
If copy_from_user() fails, the correct error code is -EFAULT, not
-EINVAL.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-19 08:46:57 +02:00
Dan Carpenter
b14bb2e782 tee: qcom: prevent potential off by one read
Re-order these checks to check if "i" is a valid array index before using
it.  This prevents a potential off by one read access.

Fixes: d6e290837e ("tee: add Qualcomm TEE driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-19 08:45:59 +02:00
Amirreza Zarrabi
87ab676d90 tee: qcom: enable TEE_IOC_SHM_ALLOC ioctl
Enable userspace to allocate shared memory with QTEE. Since
QTEE handles shared memory as object, a wrapper is implemented
to represent tee_shm as an object. The shared memory identifier,
obtained through TEE_IOC_SHM_ALLOC, is transferred to the driver using
TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INPUT/OUTPUT.

Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Acked-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Tested-by: Harshal Dev <quic_hdev@quicinc.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Amirreza Zarrabi
0f7bfdcb7c tee: qcom: add primordial object
After booting, the kernel provides a static object known as the
primordial object. This object is utilized by QTEE for native
kernel services such as yield or privileged operations.

Acked-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Harshal Dev <quic_hdev@quicinc.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Amirreza Zarrabi
d6e290837e tee: add Qualcomm TEE driver
Introduce qcomtee_object, which represents an object in both QTEE and
the kernel. QTEE clients can invoke an instance of qcomtee_object to
access QTEE services. If this invocation produces a new object in QTEE,
an instance of qcomtee_object will be returned.

Similarly, QTEE can request services from by issuing a callback
request, which invokes an instance of qcomtee_object.

Implement initial support for exporting qcomtee_object to userspace
and QTEE, enabling the invocation of objects hosted in QTEE and userspace
through the TEE subsystem.

Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Harshal Dev <quic_hdev@quicinc.com>
Acked-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Amirreza Zarrabi
d5b8b0fa17 tee: add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF
The TEE subsystem allows session-based access to trusted services,
requiring a session to be established to receive a service. This
is not suitable for an environment that represents services as objects.
An object supports various operations that a client can invoke,
potentially generating a result or a new object that can be invoked
independently of the original object.

Add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INPUT/OUTPUT/INOUT to represent an
object. Objects may reside in either TEE or userspace. To invoke an
object in TEE, introduce a new ioctl. Use the existing SUPPL_RECV and
SUPPL_SEND to invoke an object in userspace.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Harshal Dev <quic_hdev@quicinc.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Amirreza Zarrabi
54a53e95a9 tee: add TEE_IOCTL_PARAM_ATTR_TYPE_UBUF
For drivers that can transfer data to the TEE without using shared
memory from client, it is necessary to receive the user address
directly, bypassing any processing by the TEE subsystem. Introduce
TEE_IOCTL_PARAM_ATTR_TYPE_UBUF_INPUT/OUTPUT/INOUT to represent
userspace buffers.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Harshal Dev <quic_hdev@quicinc.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Amirreza Zarrabi
0cbaf65c91 tee: add close_context to TEE driver operation
The tee_context can be used to manage TEE user resources, including
those allocated by the driver for the TEE on behalf of the user.
The release() callback is invoked only when all resources, such as
tee_shm, are released and there are no references to the tee_context.

When a user closes the device file, the driver should notify the
TEE to release any resources it may hold and drop the context
references. To achieve this, a close_context() callback is
introduced to initiate resource release in the TEE driver when
the device file is closed.

Relocate teedev_ctx_get, teedev_ctx_put, tee_device_get, and
tee_device_get functions to tee_core.h to make them accessible
outside the TEE subsystem.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Harshal Dev <quic_hdev@quicinc.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Amirreza Zarrabi
6dbcd5a9ab tee: allow a driver to allocate a tee_device without a pool
A TEE driver doesn't always need to provide a pool if it doesn't
support memory sharing ioctls and can allocate memory for TEE
messages in another way. Although this is mentioned in the
documentation for tee_device_alloc(), it is not handled correctly.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-15 17:34:06 +02:00
Arnd Bergmann
820429d53b TEE protected DMA-bufs for v6.18
- Allocates protected DMA-bufs from a DMA-heap instantiated from the TEE
   subsystem.
 - The DMA-heap uses a protected memory pool provided by the backend TEE
   driver, allowing it to choose how to allocate the protected physical
   memory.
 - Three use-cases (Secure Video Playback, Trusted UI, and Secure Video
   Recording) have been identified so far to serve as examples of what
   can be expected.
 - The use-cases have predefined DMA-heap names,
   "protected,secure-video", "protected,trusted-ui", and
   "protected,secure-video-record". The backend driver registers protected
   memory pools for the use-cases it supports.
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmjD5vIaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H7nMQ//af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Su0EIDYNVaT3dZiG0M+
 M1N7C2Hxe0RMWd95+xotnz+o/3ifuqkK5BdsuomZT5X4A2oR7rxYb3En+Wsq7/aq
 7x4Gdn+8W4eULKepr3l0wLQYVKCYKxbm1R7rKnfYFDOJFZwOyH/h9H56ouO2bekE
 h2MsgV7lhKmMhrcAGIN9OsIz9DdPqj4n+z6lqyrCvSsWXGcKtTyTONsrzS3eKTv9
 GdfpIkG9pPSlJFH1sO8OegRsolAkxUOx5P/PgdSmiGazKhnBtmFHlXXn+X56fcia
 kdwNEBZxiynOkGZjgvqtQWYYr2yXD2YOp00eQHI9rzj8tL38zM49aSO8DlG41rhT
 BK5Q1Qsr+dyCpb0/AUdz71LCAz4cKfIYGRavOpZXoNMi+9/+k+2/natLBOA4jetr
 wDp3LH8av435LRj/g87zI8n9d7G1NMHaRWJZzOfXquFdTlH3kYk=
 =z4o4
 -----END PGP SIGNATURE-----

Merge tag 'tee-prot-dma-buf-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

TEE protected DMA-bufs for v6.18

- Allocates protected DMA-bufs from a DMA-heap instantiated from the TEE
  subsystem.
- The DMA-heap uses a protected memory pool provided by the backend TEE
  driver, allowing it to choose how to allocate the protected physical
  memory.
- Three use-cases (Secure Video Playback, Trusted UI, and Secure Video
  Recording) have been identified so far to serve as examples of what
  can be expected.
- The use-cases have predefined DMA-heap names,
  "protected,secure-video", "protected,trusted-ui", and
  "protected,secure-video-record". The backend driver registers protected
  memory pools for the use-cases it supports.

* tag 'tee-prot-dma-buf-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  optee: smc abi: dynamic protected memory allocation
  optee: FF-A: dynamic protected memory allocation
  optee: support protected memory allocation
  tee: add tee_shm_alloc_dma_mem()
  tee: new ioctl to a register tee_shm from a dmabuf file descriptor
  tee: refactor params_from_user()
  tee: implement protected DMA-heap
  dma-buf: dma-heap: export declared functions
  optee: sync secure world ABI headers

Link: https://lore.kernel.org/r/20250912101752.GA1453408@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2025-09-15 16:16:25 +02:00
Arnd Bergmann
15550d05c5 Use SHA-1 library instead of crypto_shash
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmjD48YaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H6ZcQ//fo3xPD4L9qB7ukg1dlXh
 8Knfht3XnCFLgPO9RwBfNjDhq5WGdSZ8+1vZarCLhlbh9+INNdVBinRvLBsDvMG5
 eoTLkAD3Qtzd9BxjFZ+mbYs8YnZi2lXxN5vB/bC6NL2BlW+Dxloy7wm9v8eoz/L4
 ggQ8rcv0QXdttODmmb6M308fP8hpgJb38qRjeB83e+cixjHIhBDbQZYzgZJ7nbn4
 oJr3TKQ2/2vBMIspyeS+BqJ7qsBswdE01wuvwwNV0c/YoWeP5nEbwtewhxk7acvY
 DDoyY9blXvgaA67PL/J7xR9cCNSvu1cvf3xhc2rlQRZP1xFtipBYH4bJ7q4kp67D
 D8dlNhVgnbMKkbXWU1xlu2grvxEjgEDbqn4YnPlWpV39PBVBmF2s/uj5aMkZW7qv
 YXLVbxJg/KMNgg5aogLodJewBXJ7J2HaMmFKVkKgytjDACTBNG6mwDNlChDEbjzM
 7weE/4hRar+sESElQV9sPuHPA1cMBBJMMId7Ya0UctT3OXF1o3WacuPmRxGZpjaM
 vpc5LiXrYlJHTqJ/Mk7yHQNF2I9tvnalPNvk5T1bMYeo4ipJLYu5Qf00HmjUoQpr
 ylKOIuuFcN5FAHfl2omWJtkkHkG42xF6M3B/yhW2DcYoHEV7wel27tOxFxwsOydf
 O3a0ZZxgW9fplZy7p440dTE=
 =S4jT
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmjIHEAACgkQmmx57+YA
 GNnITw//Xh6l+Geozp6Nd97t/b4fGt7bQPVAJ0Q8aI1ERkZmLkaqN0vBlQc7zhfK
 TiUXcdooeIz3NI3AaVh8FcFYKxv8gD5jT1Ro2GQKFHP6R3N4G8TwFyAPjEsiSvGG
 A3WXZ4qCQSoWNibHWgoeuCV4SsV2RgsmoMrH7CYZ5JSOsthduZqaS7QsRz73wQok
 oDEy2aHEFVzd4R36GKvIjvQBI52lzkzn9PGYUat9g72OxNTuvAYbKfEIgH5cHMhO
 5dyIxgCjrte6YeSmE54r6YxXae5eW83BJpU5in65pGsK0eti8B9LbiQewadiDqUQ
 taV7k6mDA2vYfyztd+mxCZJEZnDOVqKwV3sCflbF99aNRVgxTBGBDnANposEq9bE
 PnuPHvhMPRNF+JO93EqfTfUddzx6ssd1pZFB8Q4e4GqpRJh010iUSEMW6Cxl79wG
 sRrLbQAejMtjjS7RXJUCUIiJR23ieJW3bB6jcDoXkTLbsK9D7jGwe15WoFhkjEqj
 PE1fQWb/2CPytSELaRTyVnKuCHMb2FrlneQMAaz9t1HpbzUomvgxY27LpysWu80f
 oFekUjLjd6bXv6t7FTCfhaBiz9shcyMdGonkRPEJA4acP1LFPiEcIq5tnfk62Q+K
 SPb7YQSXSGzhK3Ij7RtIm4BLcaVabbxSzLxdzKHnisnK91aPyMo=
 =8yQu
 -----END PGP SIGNATURE-----

Merge tag 'tee-sha1-lib-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers

Use SHA-1 library instead of crypto_shash

* tag 'tee-sha1-lib-for-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: Use SHA-1 library instead of crypto_shash

Link: https://lore.kernel.org/r/20250912091611.GA1442659@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2025-09-15 16:01:36 +02:00
Jens Wiklander
dbc2868b7b optee: smc abi: dynamic protected memory allocation
Add support in the OP-TEE backend driver for dynamic protected memory
allocation using the SMC ABI.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:43 +02:00
Jens Wiklander
2b78d79cdf optee: FF-A: dynamic protected memory allocation
Add support in the OP-TEE backend driver dynamic protected memory
allocation with FF-A.

The protected memory pools for dynamically allocated protected memory
are instantiated when requested by user-space. This instantiation can
fail if OP-TEE doesn't support the requested use-case of protected
memory.

Restricted memory pools based on a static carveout or dynamic allocation
can coexist for different use-cases. We use only dynamic allocation with
FF-A.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:40 +02:00
Jens Wiklander
0e32abef9f optee: support protected memory allocation
Add support in the OP-TEE backend driver for protected memory
allocation. The support is limited to only the SMC ABI and for secure
video buffers.

OP-TEE is probed for the range of protected physical memory and a
memory pool allocator is initialized if OP-TEE have support for such
memory.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:36 +02:00
Jens Wiklander
ab09dd6d92 tee: add tee_shm_alloc_dma_mem()
Add tee_shm_alloc_dma_mem() to allocate DMA memory. The memory is
represented by a tee_shm object using the new flag TEE_SHM_DMA_MEM to
identify it as DMA memory. The allocated memory will later be lent to
the TEE to be used as protected memory.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:33 +02:00
Etienne Carriere
146bf4e75e tee: new ioctl to a register tee_shm from a dmabuf file descriptor
Add a userspace API to create a tee_shm object that refers to a dmabuf
reference.

Userspace registers the dmabuf file descriptor as in a tee_shm object.
The registration is completed with a tee_shm returned file descriptor.

Userspace is free to close the dmabuf file descriptor after it has been
registered since all the resources are now held via the new tee_shm
object.

Closing the tee_shm file descriptor will eventually release all
resources used by the tee_shm object when all references are released.

The new IOCTL, TEE_IOC_SHM_REGISTER_FD, supports dmabuf references to
physically contiguous memory buffers. Dmabuf references acquired from
the TEE DMA-heap can be used as protected memory for Secure Video Path
and such use cases. It depends on the TEE and the TEE driver if dmabuf
references acquired by other means can be used.

A new tee_shm flag is added to identify tee_shm objects built from a
registered dmabuf, TEE_SHM_DMA_BUF.

Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Signed-off-by: Olivier Masse <olivier.masse@nxp.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:29 +02:00
Jens Wiklander
fdf631ac9e tee: refactor params_from_user()
Break out the memref handling into a separate helper function.
No change in behavior.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:26 +02:00
Jens Wiklander
c924c65f52 tee: implement protected DMA-heap
Implement DMA heap for protected DMA-buf allocation in the TEE
subsystem.

Protected memory refers to memory buffers behind a hardware enforced
firewall. It is not accessible to the kernel during normal circumstances
but rather only accessible to certain hardware IPs or CPUs executing in
higher or differently privileged mode than the kernel itself. This
interface allows to allocate and manage such protected memory buffers
via interaction with a TEE implementation.

The protected memory is allocated for a specific use-case, like Secure
Video Playback, Trusted UI, or Secure Video Recording where certain
hardware devices can access the memory.

The DMA-heaps are enabled explicitly by the TEE backend driver. The TEE
backend drivers needs to implement protected memory pool to manage the
protected memory.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:20 +02:00
Jens Wiklander
15003d9cc6 optee: sync secure world ABI headers
Update the header files describing the secure world ABI, both with and
without FF-A. The ABI is extended to deal with protected memory, but as
usual backward compatible.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-09-11 11:22:12 +02:00
Arnd Bergmann
2050458610 OP-TEE driver fix for v6.17
Fixing a typo in a function name.
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEE0qerISgy2SKkqO79Wr/6JGat8H4FAmikTOQaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQWr/6JGat8H7DYBAAxaF20ZnzuhpWgp3sDpfB
 KC9IvYCzERhP5gPouVCatPB1jBgOcPqSYyCVft1Y6ZmB8EHxZ0eEwkgb8UJg3o00
 KtYw8kEatOavjTvm9YRjFRTNuGdBvfKpBpfipP1g95uo2n2wDL7c8akQP8YJZQwQ
 oVHtILhNFBg9xPDLB/wme94I42EQdtJHopd+3MYLyraMkjcIJd+8EnBka8Fe+v9U
 d/Y7aJIJcR3+CuyAOLcmlcg+f0hXguJtGB62jhBsNPQIZR1eKuIL3/M3/WZs7lz9
 sPLgZD9QMAixomXerJAX3MOSbvrAzwUHoHPAevCxdxj5U2B1y7JHJ/9t+09XEx6s
 qRvRSR9cUf6IFply06U8/xElpJP+e+FYyD8D8OCkTJdineV8ifOmdO4ctzA0ANti
 9ADstF1coSpRY0Xp5Mo8KBSuW9fNTKditozPXCykQ7T3nMr3ztkWebbyFbcn+omz
 Ok1S+1s5l1vgk2SqJgezsi40peZuFC08wlaKUbGN50f7aWLtMJWIglTGGaA7Vc/2
 mfT7qVwHlc3DXVH7LQmiYqoSg8lE1sH7ORBZf3p5kGNJSD3Cxj6kecsSggK0hzM8
 VioJW/6IG/rQLZtk/PSkG02odrwN7FMFT/uZ7MD7JRDqwxr4twvycrXp07Tct0TA
 FwKm+No0Xr3xhrxqcFKGtpg=
 =dTsR
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmi1WrgACgkQmmx57+YA
 GNmmsg//Wm6kKXMe9tUSDmM3cGmFg4ySBLy1nWCKGWnjxx/gFJ4LBeks47nyRXDv
 5l11uv0vJNtIQH9X5JGBg8AB2PH9hVO60i21dDWkxlJEKp2RAuPVZvFl51Wi39kP
 jcD09SPh+40KWshM2BhK8ntnWnfTZKXBJw0eTMi6CJUKWjbKm01TiqsNKrOJL9gz
 TQcutpKJTfRusTwJwrsNmEMldJQeiWAejtvQMoS0y1aI1AFCL4HLvMU0n3JS03re
 gBOqHdmhkADnrI05ItQ4hwsgO244xA+X/QPwyPRT/N8WOtb+ZR39jnW2HWGVi9w3
 M3LSMLWCtkL82l1s4NjPigBCvOXM3ARDyAqVmhHnq+Zh/EEFR2BBDOSbYKjvJlWJ
 E/4buogg/MSF+bZU8l+n2LvxhGr//SGsg33gQeFxBk62qv5wdL0DA/9FS4vEMfW9
 RQRZUnzIftlDcOc60Z+FcOXIb+FT9mO0k74BQA6Hwv2HTYvFAY4qnrg0CW+tigyl
 YN6pZSpdgVX2H6DqK0DAmqJ0RLgtqFOJ+fobmIfPXhlkKKFRbFX2c61KFuUO9Mx8
 3PNMFMXazqhoD0juFBz0Weprwaz9bwbZm8aEfO/6DdO1zDKu0XXH40Wtec825xzE
 qyLT72eBlYFnuJfXJjv22eaH8hdHK8MmcDYxKEtredVaLTjhpiA=
 =oap8
 -----END PGP SIGNATURE-----

Merge tag 'optee-typo-fix-for-v6.17' of https://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into arm/fixes

OP-TEE driver fix for v6.17

Fixing a typo in a function name.

* tag 'optee-typo-fix-for-v6.17' of https://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee:
  tee: optee: ffa: fix a typo of "optee_ffa_api_is_compatible"

Link: https://lore.kernel.org/r/20250819122917.GB3486750@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2025-09-01 10:35:03 +02:00
Sungbae Yoo
75dbd4304a tee: optee: ffa: fix a typo of "optee_ffa_api_is_compatible"
Fixes optee_ffa_api_is_compatbile() to optee_ffa_api_is_compatible()
because compatbile is a typo of compatible.

Fixes: 4615e5a34b ("optee: add FF-A support")
Signed-off-by: Sungbae Yoo <sungbaey@nvidia.com>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-08-18 15:05:49 +02:00
Eric Biggers
dfb2a4f76f tee: Use SHA-1 library instead of crypto_shash
Use the SHA-1 library functions instead of crypto_shash.  This is
simpler and faster.

Change uuid_v5() to return void, since it can no longer fail.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-08-13 14:29:49 +02:00
Pei Xiao
50a74d0095 tee: fix memory leak in tee_dyn_shm_alloc_helper
When shm_register() fails in tee_dyn_shm_alloc_helper(), the pre-allocated
pages array is not freed, resulting in a memory leak.

Fixes: cf4441503e ("tee: optee: Move pool_op helper functions")
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2025-08-04 14:28:04 +02:00