Commit Graph

247 Commits

Author SHA1 Message Date
Sumit Garg e5b5948c76 tee: optee: Fix kernel panic caused by incorrect error handling
commit 95915ba4b9 upstream.

The error path while failing to register devices on the TEE bus has a
bug leading to kernel panic as follows:

[   15.398930] Unable to handle kernel paging request at virtual address ffff07ed00626d7c
[   15.406913] Mem abort info:
[   15.409722]   ESR = 0x0000000096000005
[   15.413490]   EC = 0x25: DABT (current EL), IL = 32 bits
[   15.418814]   SET = 0, FnV = 0
[   15.421878]   EA = 0, S1PTW = 0
[   15.425031]   FSC = 0x05: level 1 translation fault
[   15.429922] Data abort info:
[   15.432813]   ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
[   15.438310]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[   15.443372]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[   15.448697] swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000d9e3e000
[   15.455413] [ffff07ed00626d7c] pgd=1800000bffdf9003, p4d=1800000bffdf9003, pud=0000000000000000
[   15.464146] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP

Commit 7269cba53d ("tee: optee: Fix supplicant based device enumeration")
lead to the introduction of this bug. So fix it appropriately.

Reported-by: Mikko Rapeli <mikko.rapeli@linaro.org>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218542
Fixes: 7269cba53d ("tee: optee: Fix supplicant based device enumeration")
Cc: stable@vger.kernel.org
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-03 15:19:42 +02:00
Sumit Garg 1c9561b438 tee: optee: Fix supplicant based device enumeration
[ Upstream commit 7269cba53d ]

Currently supplicant dependent optee device enumeration only registers
devices whenever tee-supplicant is invoked for the first time. But it
forgets to remove devices when tee-supplicant daemon stops running and
closes its context gracefully. This leads to following error for fTPM
driver during reboot/shutdown:

[   73.466791] tpm tpm0: ftpm_tee_tpm_op_send: SUBMIT_COMMAND invoke error: 0xffff3024

Fix this by adding an attribute for supplicant dependent devices so that
the user-space service can detect and detach supplicant devices before
closing the supplicant:

$ for dev in /sys/bus/tee/devices/*; do if [[ -f "$dev/need_supplicant" && -f "$dev/driver/unbind" ]]; \
      then echo $(basename "$dev") > $dev/driver/unbind; fi done

Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Closes: https://github.com/OP-TEE/optee_os/issues/6094
Fixes: 5f178bb71e ("optee: enable support for multi-stage bus enumeration")
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
[jw: fixed up Date documentation]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-12-13 18:39:12 +01:00
Rijo Thomas 60c3e7a00d tee: amdtee: fix use-after-free vulnerability in amdtee_close_session
commit f4384b3e54 upstream.

There is a potential race condition in amdtee_close_session that may
cause use-after-free in amdtee_open_session. For instance, if a session
has refcount == 1, and one thread tries to free this session via:

    kref_put(&sess->refcount, destroy_session);

the reference count will get decremented, and the next step would be to
call destroy_session(). However, if in another thread,
amdtee_open_session() is called before destroy_session() has completed
execution, alloc_session() may return 'sess' that will be freed up
later in destroy_session() leading to use-after-free in
amdtee_open_session.

To fix this issue, treat decrement of sess->refcount and removal of
'sess' from session list in destroy_session() as a critical section, so
that it is executed atomically.

Fixes: 757cc3e9ff ("tee: add AMD-TEE driver")
Cc: stable@vger.kernel.org
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-19 23:08:57 +02:00
Rijo Thomas 939f00e482 tee: amdtee: Add return_origin to 'struct tee_cmd_load_ta'
commit 436eeae041 upstream.

After TEE has completed processing of TEE_CMD_ID_LOAD_TA, set proper
value in 'return_origin' argument passed by open_session() call. To do
so, add 'return_origin' field to the structure tee_cmd_load_ta. The
Trusted OS shall update return_origin as part of TEE processing.

This change to 'struct tee_cmd_load_ta' interface requires a similar update
in AMD-TEE Trusted OS's TEE_CMD_ID_LOAD_TA interface.

This patch has been verified on Phoenix Birman setup. On older APUs,
return_origin value will be 0.

Cc: stable@vger.kernel.org
Fixes: 757cc3e9ff ("tee: add AMD-TEE driver")
Tested-by: Sourabh Das <sourabh.das@amd.com>
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-14 11:15:28 +02:00
Etienne Carriere 06ec5be891 optee: fix uninited async notif value
commit 654d031000 upstream.

Fixes an uninitialized variable in irq_handler() that could lead to
unpredictable behavior in case OP-TEE fails to handle SMC function ID
OPTEE_SMC_GET_ASYNC_NOTIF_VALUE. This change ensures that in that case
get_async_notif_value() properly reports there are no notification
event.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/202304200755.OoiuclDZ-lkp@intel.com/
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/all/d9b7f69b-c737-4cb3-8e74-79fe00c934f9@kili.mountain/
Fixes: 6749e69c4d ("optee: add asynchronous notifications")
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-30 14:03:22 +01:00
Rijo Thomas a63cce9393 tee: amdtee: fix race condition in amdtee_open_session
commit f8502fba45 upstream.

There is a potential race condition in amdtee_open_session that may
lead to use-after-free. For instance, in amdtee_open_session() after
sess->sess_mask is set, and before setting:

    sess->session_info[i] = session_info;

if amdtee_close_session() closes this same session, then 'sess' data
structure will be released, causing kernel panic when 'sess' is
accessed within amdtee_open_session().

The solution is to set the bit sess->sess_mask as the last step in
amdtee_open_session().

Fixes: 757cc3e9ff ("tee: add AMD-TEE driver")
Cc: stable@vger.kernel.org
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-30 12:49:29 +02:00
Yang Yingliang cce616e012 tee: optee: fix possible memory leak in optee_register_device()
If device_register() returns error in optee_register_device(),
the name allocated by dev_set_name() need be freed. As comment
of device_register() says, it should use put_device() to give
up the reference in the error path. So fix this by calling
put_device(), then the name can be freed in kobject_cleanup(),
and optee_device is freed in optee_release_device().

Fixes: c3fa24af92 ("tee: optee: add TEE bus device enumeration support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-11-17 09:22:12 +01:00
Linus Torvalds 27bc50fc90 - Yu Zhao's Multi-Gen LRU patches are here. They've been under test in
linux-next for a couple of months without, to my knowledge, any negative
   reports (or any positive ones, come to that).
 
 - Also the Maple Tree from Liam R.  Howlett.  An overlapping range-based
   tree for vmas.  It it apparently slight more efficient in its own right,
   but is mainly targeted at enabling work to reduce mmap_lock contention.
 
   Liam has identified a number of other tree users in the kernel which
   could be beneficially onverted to mapletrees.
 
   Yu Zhao has identified a hard-to-hit but "easy to fix" lockdep splat
   (https://lkml.kernel.org/r/CAOUHufZabH85CeUN-MEMgL8gJGzJEWUrkiM58JkTbBhh-jew0Q@mail.gmail.com).
   This has yet to be addressed due to Liam's unfortunately timed
   vacation.  He is now back and we'll get this fixed up.
 
 - Dmitry Vyukov introduces KMSAN: the Kernel Memory Sanitizer.  It uses
   clang-generated instrumentation to detect used-unintialized bugs down to
   the single bit level.
 
   KMSAN keeps finding bugs.  New ones, as well as the legacy ones.
 
 - Yang Shi adds a userspace mechanism (madvise) to induce a collapse of
   memory into THPs.
 
 - Zach O'Keefe has expanded Yang Shi's madvise(MADV_COLLAPSE) to support
   file/shmem-backed pages.
 
 - userfaultfd updates from Axel Rasmussen
 
 - zsmalloc cleanups from Alexey Romanov
 
 - cleanups from Miaohe Lin: vmscan, hugetlb_cgroup, hugetlb and memory-failure
 
 - Huang Ying adds enhancements to NUMA balancing memory tiering mode's
   page promotion, with a new way of detecting hot pages.
 
 - memcg updates from Shakeel Butt: charging optimizations and reduced
   memory consumption.
 
 - memcg cleanups from Kairui Song.
 
 - memcg fixes and cleanups from Johannes Weiner.
 
 - Vishal Moola provides more folio conversions
 
 - Zhang Yi removed ll_rw_block() :(
 
 - migration enhancements from Peter Xu
 
 - migration error-path bugfixes from Huang Ying
 
 - Aneesh Kumar added ability for a device driver to alter the memory
   tiering promotion paths.  For optimizations by PMEM drivers, DRM
   drivers, etc.
 
 - vma merging improvements from Jakub Matěn.
 
 - NUMA hinting cleanups from David Hildenbrand.
 
 - xu xin added aditional userspace visibility into KSM merging activity.
 
 - THP & KSM code consolidation from Qi Zheng.
 
 - more folio work from Matthew Wilcox.
 
 - KASAN updates from Andrey Konovalov.
 
 - DAMON cleanups from Kaixu Xia.
 
 - DAMON work from SeongJae Park: fixes, cleanups.
 
 - hugetlb sysfs cleanups from Muchun Song.
 
 - Mike Kravetz fixes locking issues in hugetlbfs and in hugetlb core.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCY0HaPgAKCRDdBJ7gKXxA
 joPjAQDZ5LlRCMWZ1oxLP2NOTp6nm63q9PWcGnmY50FjD/dNlwEAnx7OejCLWGWf
 bbTuk6U2+TKgJa4X7+pbbejeoqnt5QU=
 =xfWx
 -----END PGP SIGNATURE-----

Merge tag 'mm-stable-2022-10-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull MM updates from Andrew Morton:

 - Yu Zhao's Multi-Gen LRU patches are here. They've been under test in
   linux-next for a couple of months without, to my knowledge, any
   negative reports (or any positive ones, come to that).

 - Also the Maple Tree from Liam Howlett. An overlapping range-based
   tree for vmas. It it apparently slightly more efficient in its own
   right, but is mainly targeted at enabling work to reduce mmap_lock
   contention.

   Liam has identified a number of other tree users in the kernel which
   could be beneficially onverted to mapletrees.

   Yu Zhao has identified a hard-to-hit but "easy to fix" lockdep splat
   at [1]. This has yet to be addressed due to Liam's unfortunately
   timed vacation. He is now back and we'll get this fixed up.

 - Dmitry Vyukov introduces KMSAN: the Kernel Memory Sanitizer. It uses
   clang-generated instrumentation to detect used-unintialized bugs down
   to the single bit level.

   KMSAN keeps finding bugs. New ones, as well as the legacy ones.

 - Yang Shi adds a userspace mechanism (madvise) to induce a collapse of
   memory into THPs.

 - Zach O'Keefe has expanded Yang Shi's madvise(MADV_COLLAPSE) to
   support file/shmem-backed pages.

 - userfaultfd updates from Axel Rasmussen

 - zsmalloc cleanups from Alexey Romanov

 - cleanups from Miaohe Lin: vmscan, hugetlb_cgroup, hugetlb and
   memory-failure

 - Huang Ying adds enhancements to NUMA balancing memory tiering mode's
   page promotion, with a new way of detecting hot pages.

 - memcg updates from Shakeel Butt: charging optimizations and reduced
   memory consumption.

 - memcg cleanups from Kairui Song.

 - memcg fixes and cleanups from Johannes Weiner.

 - Vishal Moola provides more folio conversions

 - Zhang Yi removed ll_rw_block() :(

 - migration enhancements from Peter Xu

 - migration error-path bugfixes from Huang Ying

 - Aneesh Kumar added ability for a device driver to alter the memory
   tiering promotion paths. For optimizations by PMEM drivers, DRM
   drivers, etc.

 - vma merging improvements from Jakub Matěn.

 - NUMA hinting cleanups from David Hildenbrand.

 - xu xin added aditional userspace visibility into KSM merging
   activity.

 - THP & KSM code consolidation from Qi Zheng.

 - more folio work from Matthew Wilcox.

 - KASAN updates from Andrey Konovalov.

 - DAMON cleanups from Kaixu Xia.

 - DAMON work from SeongJae Park: fixes, cleanups.

 - hugetlb sysfs cleanups from Muchun Song.

 - Mike Kravetz fixes locking issues in hugetlbfs and in hugetlb core.

Link: https://lkml.kernel.org/r/CAOUHufZabH85CeUN-MEMgL8gJGzJEWUrkiM58JkTbBhh-jew0Q@mail.gmail.com [1]

* tag 'mm-stable-2022-10-08' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (555 commits)
  hugetlb: allocate vma lock for all sharable vmas
  hugetlb: take hugetlb vma_lock when clearing vma_lock->vma pointer
  hugetlb: fix vma lock handling during split vma and range unmapping
  mglru: mm/vmscan.c: fix imprecise comments
  mm/mglru: don't sync disk for each aging cycle
  mm: memcontrol: drop dead CONFIG_MEMCG_SWAP config symbol
  mm: memcontrol: use do_memsw_account() in a few more places
  mm: memcontrol: deprecate swapaccounting=0 mode
  mm: memcontrol: don't allocate cgroup swap arrays when memcg is disabled
  mm/secretmem: remove reduntant return value
  mm/hugetlb: add available_huge_pages() func
  mm: remove unused inline functions from include/linux/mm_inline.h
  selftests/vm: add selftest for MADV_COLLAPSE of uffd-minor memory
  selftests/vm: add file/shmem MADV_COLLAPSE selftest for cleared pmd
  selftests/vm: add thp collapse shmem testing
  selftests/vm: add thp collapse file and tmpfs testing
  selftests/vm: modularize thp collapse memory operations
  selftests/vm: dedup THP helpers
  mm/khugepaged: add tracepoint to hpage_collapse_scan_file()
  mm/madvise: add file and shmem support to MADV_COLLAPSE
  ...
2022-10-10 17:53:04 -07:00
Linus Torvalds ff6862c23d ARM: driver updates for 6.1
The drivers branch for 6.1 is a bit larger than for most releases.  Most
 of the changes come from SoC maintainers for the drivers/soc subsystem:
 
  - A new driver for error handling on the NVIDIA Tegra
    'control backbone' bus.
 
  - A new driver for Qualcomm LLCC/DDR bandwidth measurement
 
  - New Rockchip rv1126 and rk3588 power domain drivers
 
  - DT binding updates for memory controllers, older Rockchip
    SoCs, various Mediatek devices, Qualcomm SCM firmware
 
  - Minor updates to Hisilicon LPC bus, the Allwinner SRAM
    driver, the Apple rtkit firmware driver, Tegra firmware
 
  - Minor updates for SoC drivers (Samsung, Mediatek, Renesas,
    Tegra, Qualcomm, Broadcom, NXP, ...)
 
 There are also some separate subsystem with downstream maintainers that
 merge updates this way:
 
  - Various updates and new drivers in the memory controller
    subsystem for Mediatek and Broadcom SoCs
 
  - Small set of changes in preparation to add support for FF-A
    v1.1 specification later, in the Arm FF-A firmware subsystem
 
  - debugfs support in the PSCI firmware subsystem
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmM+j54ACgkQmmx57+YA
 GNkK1Q//fSzCHUPNTrZKJi8mRtp/32Nrpav3eorMZWltKnYbYQyhqH/LCuSZJfe/
 rmGYFxsH6DHEgfHqqyzm6PNC0S4Hle6KiB5xnqXrTgqciPuSg4Fa9OMQgkbiQF6x
 uB2KR+TouQA3MssQh6NW4wy5XAkEqudZCSnEyOTJTmdpepZd/1Eu2Rhn8kx5AYQN
 pzYNGURRoirgYbO9vHMssCcpqyGNdR9SWXcOkROyd65L4LCHQ9JRh4etg7fSXP5j
 abWtTHSOwD8MTXOENOiNw/vyCfBX7wUoJkY2v8OUo3G/20qbOXKWPWi056gyDjVQ
 kJdlnnK4APtiluyBg2alEEZmJOd1iCaVP2j84EO1N4FEek2UGd/lMNOtAOJa+wbh
 eiE6KC5gswe+99//PdY4gB+7dRM3I0gU7FDMl9G5A4DPMEE/0bMKLKk1jR5vyYXl
 6QpN2N0OlU7d16MJiP9RvWf2/xJrcQrLQcy8FKvFVWClJ9wMvBXozKrvXgji9l3I
 ZTW+EViQiyWmj6KbFlDZkYT+Q6YosxaogJUNrZeIaAwmwJj1oTa+M6jYRnFU6uha
 XxG5TrybC9JQ/BpYCTYEqb16LOYALwEm7NWmylWASUCCZclC1u35qmmVEhDyBcS9
 98ePumkAwrcjmW0TZsiYXOCQWNOITuvU/Ku2t/+6Mhg+Xl44zX4=
 =WX9J
 -----END PGP SIGNATURE-----

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

Pull ARM driver updates from Arnd Bergmann:
 "The drivers branch for 6.1 is a bit larger than for most releases.

  Most of the changes come from SoC maintainers for the drivers/soc
  subsystem:

   - A new driver for error handling on the NVIDIA Tegra 'control
     backbone' bus.

   - A new driver for Qualcomm LLCC/DDR bandwidth measurement

   - New Rockchip rv1126 and rk3588 power domain drivers

   - DT binding updates for memory controllers, older Rockchip SoCs,
     various Mediatek devices, Qualcomm SCM firmware

   - Minor updates to Hisilicon LPC bus, the Allwinner SRAM driver, the
     Apple rtkit firmware driver, Tegra firmware

   - Minor updates for SoC drivers (Samsung, Mediatek, Renesas, Tegra,
     Qualcomm, Broadcom, NXP, ...)

  There are also some separate subsystem with downstream maintainers
  that merge updates this way:

   - Various updates and new drivers in the memory controller subsystem
     for Mediatek and Broadcom SoCs

   - Small set of changes in preparation to add support for FF-A v1.1
     specification later, in the Arm FF-A firmware subsystem

   - debugfs support in the PSCI firmware subsystem"

* tag 'arm-drivers-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (149 commits)
  ARM: remove check for CONFIG_DEBUG_LL_SER3
  firmware/psci: Add debugfs support to ease debugging
  firmware/psci: Print a warning if PSCI doesn't accept PC mode
  dt-bindings: memory: snps,dw-umctl2-ddrc: Extend schema with IRQs/resets/clocks props
  dt-bindings: memory: snps,dw-umctl2-ddrc: Replace opencoded numbers with macros
  dt-bindings: memory: snps,dw-umctl2-ddrc: Use more descriptive device name
  dt-bindings: memory: synopsys,ddrc-ecc: Detach Zynq DDRC controller support
  soc: sunxi: sram: Add support for the D1 system control
  soc: sunxi: sram: Export the LDO control register
  soc: sunxi: sram: Save a pointer to the OF match data
  soc: sunxi: sram: Return void from the release function
  soc: apple: rtkit: Add apple_rtkit_poll
  soc: imx: add i.MX93 media blk ctrl driver
  soc: imx: add i.MX93 SRC power domain driver
  soc: imx: imx8m-blk-ctrl: Use genpd_xlate_onecell
  soc: imx: imx8mp-blk-ctrl: handle PCIe PHY resets
  soc: imx: imx8m-blk-ctrl: add i.MX8MP VPU blk ctrl
  soc: imx: add i.MX8MP HDMI blk ctrl HDCP/HRV_MWR
  soc: imx: add icc paths for i.MX8MP hsio/hdmi blk ctrl
  soc: imx: add icc paths for i.MX8MP media blk ctrl
  ...
2022-10-06 11:04:57 -07:00
Matthew Wilcox (Oracle) df724cedcf optee: remove vma linked list walk
Use the VMA iterator instead.  Change the calling convention of
__check_mem_type() to pass in the mm instead of the first vma in the
range.

Link: https://lkml.kernel.org/r/20220906194824.2110408-39-Liam.Howlett@oracle.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Tested-by: Yu Zhao <yuzhao@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-09-26 19:46:20 -07:00
Arnd Bergmann 387969b7ab Arm FF-A firmware driver updates for v6.1
Small set of changes in preparation to add support for FF-A v1.1
 specification later. It mainly contains:
 
 1. Splitting up ffa_ops into different categories namely information,
    message and memory. It helps to make info and memory operations
    independent from ffa_device so thata generic memory management
    module can use it without specific ffa_dev.
 2. Adds support for querying FF-A features and use the same to detect
    the support for 64-bit operations.
 3. Adds v1.1 get_partition_info support and use the same to set up
    32-bit execution mode flag automatically.
 4. Adds pointer to the ffa_dev_ops in struct ffa_dev and drop
    ffa_dev_ops_get() which enables to drop ffa_ops in optee_ffa
    structure using ffa_dev->ops directly. Additionally ffa_dev_ops is
    renamed as ffa_ops.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmMgVOEACgkQAEG6vDF+
 4phosQ//Q6tnJtcxgw7AeioIeGrXEAQy9Psyt8JrGixTHWSgq42G8Z0PKPO7MwFn
 F5RxVSE85E4wLBLu3xiuR1mlAglBOvec3cY4/4XBfN8nxzYUBiaOn8U7Jjnh3QYk
 vp0MTzECsi9a2T9T4zr0hLAdO/5uZBG16nf45iKOo9qEF6KS7WZWhdPHcyG4MpCH
 u6L2aKGb0XzfzT0YAHxvOipVTdYg4smtmhtOj5vvuD1XEve4ARh8WjhNFwE2L6zt
 6RH/CgzhEJFOJkR/WjNdlcD9b/9QuwvmIORXFUP7jTIR/SYHB4k7xutz/DD2L4/P
 Xp/qiNrlrQnXpdMbYbr5S9e1jlPfjwbsiG5CNf620gS+Up5ZLD+Vnhu64A+Bfml2
 8YSjJHNurkiCzTzpawGiRl0uGEwvvOhZBnlGaaeJP9ga98dQc5eom+qLbeDyT/dK
 ESILyaetQniHCUU+hIbZ9jnfj0sdlgd5gF6Lbsnqdy25KktIiVzscL0Wkwl5jY6C
 JiCv++6ieH44NrDTNaFzF/MjpBcBxXmp/qposT2wuPHxdY+OPnbjorGoLZP1F2Ns
 i/+1l724sm1ETdwm/eVn9aWoH681G1APd45xYE2khLme7o9V+xapJD5khQN0nSet
 gJ20gstIDjHBhOGYCFg/Q2l7HlrvrFYXLgN/4GI8z6CJUuUCpj0=
 =u/KH
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmMjhesACgkQmmx57+YA
 GNlVfBAAk3s11gubrUNcY1HLhZXkAY/QmNVt8yEnP6CjMkOc3nIAVqtjklXJ6+dp
 WtMsJUx993DH8wmGvid4IF2BWPTSeQ6xMfx5dqKgFLg1fIPRejomD2g+JtPlKyFO
 UeOzg0T7H3Fht3UnYH3D7muc1zkFXumwZPATqVJY8vFF8jJTnQEfoy0iN1qYBM4Y
 ex1EXteXDbhA0jezmqGlTMcDGNgZs1JeYBciaZl4U/pH2dF79tTUDeQh/l4ZbtTd
 Z1V8mvbZHwFuWax2frPeVFnVGYD3VP5c28/qxLYrueYEaSEbOtYFDSkbP0U2D4GG
 jhYO2PPCPw/qxjx8PGfjciAK1y4WKwTXs+D4KfdY+IyhuoTSi+VN0stCFQGoOf06
 eMy/eUTCA02ICe3IKcO3KqZbAH3mBpiw7AgmMAkSRSdOadFKfZ4PauTdmR/a7gJL
 E4MyMwfY1yJ3oJeHx/WvFPL4Iwl26QTx2q/srjDlTJ9laHQv/D1RBi51zwnEC8bp
 kxuP69hqapiroiKAJcnHGpJX4icm2vV7YUBGqF03Sw+SByiJYGt47ojEcbA/kEDk
 Cis383/TN2xNFSZ+uu5MWj2vkbus5m8OQ2OvDgJ7lUoPVgjBpzd7kBuyT5bpY+aU
 m//viWe28xjOQz0KmB4pnitBO2xmYdo2G94Xak/xgu7ksAVItnY=
 =aIAe
 -----END PGP SIGNATURE-----

Merge tag 'ffa-updates-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/drivers

Arm FF-A firmware driver updates for v6.1

Small set of changes in preparation to add support for FF-A v1.1
specification later. It mainly contains:

1. Splitting up ffa_ops into different categories namely information,
   message and memory. It helps to make info and memory operations
   independent from ffa_device so thata generic memory management
   module can use it without specific ffa_dev.
2. Adds support for querying FF-A features and use the same to detect
   the support for 64-bit operations.
3. Adds v1.1 get_partition_info support and use the same to set up
   32-bit execution mode flag automatically.
4. Adds pointer to the ffa_dev_ops in struct ffa_dev and drop
   ffa_dev_ops_get() which enables to drop ffa_ops in optee_ffa
   structure using ffa_dev->ops directly. Additionally ffa_dev_ops is
   renamed as ffa_ops.

* tag 'ffa-updates-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
  firmware: arm_ffa: Set up 32bit execution mode flag using partiion property
  firmware: arm_ffa: Add v1.1 get_partition_info support
  firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
  firmware: arm_ffa: Make memory apis ffa_device independent
  firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported
  firmware: arm_ffa: Add support for querying FF-A features
  firmware: arm_ffa: Remove ffa_dev_ops_get()
  tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
  firmware: arm_ffa: Add pointer to the ffa_dev_ops in struct ffa_dev

Link: https://lore.kernel.org/r/20220913100612.2924643-1-sudeep.holla@arm.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-09-15 22:07:07 +02:00
Sudeep Holla 5b0c6328e4 firmware: arm_ffa: Split up ffa_ops into info, message and memory operations
In preparation to make memory operations accessible for a non
ffa_driver/device, it is better to split the ffa_ops into different
categories of operations: info, message and memory. The info and memory
are ffa_device independent and can be used without any associated
ffa_device from a non ffa_driver.

However, we don't export these info and memory APIs yet without the user.
The first users of these APIs can export them.

Link: https://lore.kernel.org/r/20220907145240.1683088-11-sudeep.holla@arm.com
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:34:04 +01:00
Sudeep Holla 7aa7a97989 firmware: arm_ffa: Rename ffa_dev_ops as ffa_ops
Except the message APIs, all other APIs are ffa_device independent and can
be used without any associated ffa_device from a non ffa_driver.

In order to reflect the same, just rename ffa_dev_ops as ffa_ops to
avoid any confusion or to keep it simple.

Link: https://lore.kernel.org/r/20220907145240.1683088-8-sudeep.holla@arm.com
Suggested-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:30:34 +01:00
Sudeep Holla 8c3812c8f7 firmware: arm_ffa: Make memory apis ffa_device independent
There is a requirement to make memory APIs independent of the ffa_device.
One of the use-case is to have a common memory driver that manages the
memory for all the ffa_devices. That common memory driver won't be a
ffa_driver or won't have any ffa_device associated with it. So having
these memory APIs accessible without a ffa_device is needed and should
be possible as most of these are handled by the partition manager(SPM
or hypervisor).

Drop the ffa_device argument to the memory APIs and make them ffa_device
independent.

Link: https://lore.kernel.org/r/20220907145240.1683088-7-sudeep.holla@arm.com
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:30:34 +01:00
Sudeep Holla 320c3fa38c tee: optee: Drop ffa_ops in optee_ffa structure using ffa_dev->ops directly
Now that the ffa_device structure holds the pointer to ffa_dev_ops,
there is no need to obtain the same through ffa_dev_ops_get().

Just use the ffa_dev->ops directly. Since the ffa_device itself carries
ffa_dev_ops now, there is no need to keep a copy in optee_ffa structure.

Drop ffa_ops in the optee_ffa structure as it is not needed anymore.

Link: https://lore.kernel.org/r/20220907145240.1683088-3-sudeep.holla@arm.com
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-09-08 11:30:34 +01:00
Jens Wiklander eccd743970 tee: fix compiler warning in tee_shm_register()
Include <linux/uaccess.h> to avoid the warning:
   drivers/tee/tee_shm.c: In function 'tee_shm_register':
>> drivers/tee/tee_shm.c:242:14: error: implicit declaration of function 'access_ok' [-Werror=implicit-function-declaration]
     242 |         if (!access_ok((void __user *)addr, length))
         |              ^~~~~~~~~
   cc1: some warnings being treated as errors

Fixes: 573ae4f13f ("tee: add overflow check in register_shm_helper()")
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-08-25 11:40:06 +02:00
Jens Wiklander 573ae4f13f tee: add overflow check in register_shm_helper()
With special lengths supplied by user space, register_shm_helper() has
an integer overflow when calculating the number of pages covered by a
supplied user space memory region.

This causes internal_get_user_pages_fast() a helper function of
pin_user_pages_fast() to do a NULL pointer dereference:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
  Modules linked in:
  CPU: 1 PID: 173 Comm: optee_example_a Not tainted 5.19.0 #11
  Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
  pc : internal_get_user_pages_fast+0x474/0xa80
  Call trace:
   internal_get_user_pages_fast+0x474/0xa80
   pin_user_pages_fast+0x24/0x4c
   register_shm_helper+0x194/0x330
   tee_shm_register_user_buf+0x78/0x120
   tee_ioctl+0xd0/0x11a0
   __arm64_sys_ioctl+0xa8/0xec
   invoke_syscall+0x48/0x114

Fix this by adding an an explicit call to access_ok() in
tee_shm_register_user_buf() to catch an invalid user space address
early.

Fixes: 033ddf12bc ("tee: add register user memory")
Cc: stable@vger.kernel.org
Reported-by: Nimish Mishra <neelam.nimish@gmail.com>
Reported-by: Anirban Chakraborty <ch.anirban00727@gmail.com>
Reported-by: Debdeep Mukhopadhyay <debdeep.mukhopadhyay@gmail.com>
Suggested-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-08-18 09:20:27 -07:00
Marc Kleine-Budde e5ce073c8a tee: tee_get_drvdata(): fix description of return value
This patch fixes the description of tee_get_drvdata()'s return value.
It actually returns the driver_data pointer supplied to
tee_device_alloc() since the TEE subsystem was added to the kernel.

Fixes: 967c9cca2c ("tee: generic TEE subsystem")
Cc: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-07-08 10:51:24 +02:00
Jiang Jian b66527ee98 optee: Remove duplicate 'of' in two places.
file: ./drivers/tee/optee/optee_smc.h
line: 192
 * a2   Size of of SHM
chanegd to
 * a2   Size of SHM

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-07-08 10:51:24 +02:00
Yang Yingliang d4fac258d9 optee: smc_abi.c: fix wrong pointer passed to IS_ERR/PTR_ERR()
In optee_smc_do_call_with_arg() there is a code path when the argument
struct for RPC is passed appended to the primary argument struct. When
the address of the RPC struct is retrieved there's an invalid check for
success. It should be 'rpc_arg' pass to IS_ERR/PTR_ERR().

Fixes: ed8faf6c8f ("optee: add OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
[jw: added background to the problem]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-07-08 09:56:38 +02:00
Arnd Bergmann 9c76d723ed Fix a compiler warning in OP-TEE driver
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmKUp88aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJfo1hAAgxWuH8xhuMdvuLOt2mCD
 MyaahZ5Tf7VwyydCBPZvQXEyQqflfuDMSaDRQrrJd9RXTBI8FaGGrvdmJaqr65rD
 t08CopIyaJzDcIl+uwQ0BnWRpPW974ARzd1HylDXyaK4/BroKujpjLS+RnwOLzmS
 fdUANXOKw2tTQUamQRo6/ZQ1bA2CZj6QJqbTqBEifCozEG+ZNx8MCw1au6zf9LUb
 LyjdA0J/Uo8qUp2bBWHHPRe2ieIL9JKD7uBVhGJAP5/qqBpbZCwhDrOUk34qwOmR
 Y9FZv+wY6PYV0t0H2leOd8dx6fZ6K4lxffmwy40zj5vq3OsomrfozYK+GHG6Gw5m
 RBSxBVxnfD4q2FIcIRmJiSbkK/m9dKeW0b3K27huIElVi1l00YJalEc4dOzpVjTK
 LiOlBd4eY8pcNIRCoMwqoYtOLNynpTDoBJmdQFjrs3RdmyIUwLP4PBEuuSy9TV2d
 Od/pB4eBnzFol83G6IKw0zqaLcaJtchdG50EE5DUwf+PbVmuQikWjkNun8oWxH1a
 3qEltbfhvBSVwh/KXgQlEwsiK6mE4yr3pL+5Q6UR+/TbU8Nm5fAFmuJAmQnoLgYI
 Mn86aFiX1GimjdTZ/r0U3bLSGG1vVowoGUayPiQFonuh+Rc+J51PFJHtoZ2ImfzT
 5Tjj4MwjvqpGnPryyDh6+5c=
 =5e2L
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmKUvCsACgkQmmx57+YA
 GNkgBA/+Lsu6hJYfjUmbHWdQl052F8ByXNMpec9UOzjdT4l62B7OPs+ynfuUNs+K
 JEWd8mrlyoBLlJkSP561IlEe1oa3yDLuuzMXnoIOFsYoxSjNZXVSSerRrlHUuqWd
 JTaH3MJ3sScjrwnnBZw5XJvKPv+rG4zSfgsTQnt/JtRwy8Oot1TaaDy9SqRDVkaA
 9Ieb7ZUgfXq2TJRPNCWSHQtVn6bQo73Rn8WTDHJE+u1p78Vm2fAGSU8UMitD363B
 nG2uxHZPQqx5dGqSkSP9XWc+EwOA7DOkYfNhxg7opgKMn7Fxu8D4MmyapymL/ULn
 OxqEzuLHfveanpv2r5i0PRKwCasj3tMRrUBp2FLaGocaww8RuYA92yowy7zRHM67
 UrX3TukIWImdSE43rpw3OZ7Kj4Ymc6YeW0qg0fIfn53rk/morXbJwiGe94bLkFrS
 q0782JkLGlSLm+QUkXK+vdX6NQNkobmGIaVyu2HTpE7IyRhukwITJ6oMf/xN1PcG
 5PmcWXeODYooUKya6Pay4EzYkB11bPuSBiFz8gCydKMKil4gyzd80zSg7cx1XrCO
 5NWXvgLoy7Blj2zqwB9fkZJJT3cLHa8ZlJ3Qx+7fXbTSBdGgZz+qNstXqMhx+HiY
 HDzohlPAr7b9P4/JYgD4WRwkzvcgLhnQQFq0Gg/kAs/avqoFCig=
 =5+PP
 -----END PGP SIGNATURE-----

Merge tag 'optee-warning-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/late

Fix a compiler warning in OP-TEE driver

* tag 'optee-warning-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: optee: Pass a pointer to virt_addr_valid()

Link: https://lore.kernel.org/r/20220530112612.GA1511426@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-30 14:44:27 +02:00
Linus Walleij a3b9ecc805 tee: optee: Pass a pointer to virt_addr_valid()
A pointer into virtual memory is represented by a (void *)
not an u32, so the compiler warns:

drivers/tee/optee/call.c:365:29: warning: passing argument 1
  of 'virt_to_pfn' makes pointer from integer without a
  cast [-Wint-conversion]

Fix this with an explicit cast.

Cc: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
[jw: fixed merge conflict]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-05-30 08:06:45 +02:00
Linus Torvalds cc3c470ae4 ARM: driver changes for 5.19
There are minor updates to SoC specific drivers for chips by Rockchip,
 Samsung, NVIDIA, TI, NXP, i.MX, Qualcomm, and Broadcom. Noteworthy
 driver changes include:
 
 - Several conversions of DT bindings to yaml format.
 
 - Renesas adds driver support for R-Car V4H, RZ/V2M and RZ/G2UL SoCs.
 
 - Qualcomm adds a bus driver for the SSC (Snapdragon Sensor Core),
   and support for more chips in the RPMh power domains and the soc-id.
 
 - NXP has a new driver for the HDMI blk-ctrl on i.MX8MP.
 
 - Apple M1 gains support for the on-chip NVMe controller, making it
   possible to finally use the internal disks. This also includes SoC
   drivers for their RTKit IPC and for the SART DMA address filter.
 
 For other subsystems that merge their drivers through the SoC tree,
 we have
 
 - Firmware drivers for the ARM firmware stack including TEE, OP-TEE,
   SCMI and FF-A get a number of smaller updates and cleanups. OP-TEE
   now has a cache for firmware argument structures as an optimization,
   and SCMI now supports the 3.1 version of the specification.
 
 - Reset controller updates to Amlogic, ASpeed, Renesas and ACPI drivers
 
 - Memory controller updates for Tegra, and a few updates for other
   platforms.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmKOXOoACgkQmmx57+YA
 GNlpVQ//eQGfL0WktE5G/y0mCVuVHtXT5nSjHMgjTOdb9+QvaATCfxnLXvP7Gq7C
 7YzJd68G+2ZC4rUkkjTxyMICT7eIrJSAIAFn4PWee4EQ5DfbHgG+1tToTjxqb+QQ
 6wGB5MVaYUhjZE30kY2E8a+OKxHtEnkt9wcch6ei0vzsMZquQJF6byfHd5+I4Knd
 CyDmXX8ZGXK3FnhvuBLr3Rgwyhs0X4Ju7UaONLZxBYxdnh8WmymRszmMnv5qEkub
 KDe8fbhFamOT3Z55JdCA5xq7LvUzjsKpTGFxFcS0ptbkTmtAsuyYqqiWvAPx3D5u
 5TxVGSx9QKid6fpIsITZ2ptO6fgljh1W9b/3Y3/eltudXsM1qqSxyN2Hre+M9egf
 WEDADqbNR5Y5+bq1iZWI348jXkNHVPpsLHI9Ihqf4yyrKwFkmRmNLnws53XTAPH2
 FPXZvJjwFDBDHGfewSoLFePXUPNytVLXbr6Mq72ZyTDIBDU8Mxh666Wd8bu4tgbG
 1Y2pMjDIdXDOsljM6Of5D3XjM1kuDwEmFxWGy+cKLgoEbHLeE1xIbTjUir4687+d
 VNHdtsIRFPRZzz2lUSmI8vlA2aewMWrkOF/Ulz8xh6gG8uitMSfOxghg4IWOfRVM
 mlvgFP5eqTInmQcbWRxaRO9JzP+rPp1sAcEpsBmuEHw5Akflbc8=
 =XoLF
 -----END PGP SIGNATURE-----

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

Pull ARM driver updates from Arnd Bergmann:
 "There are minor updates to SoC specific drivers for chips by Rockchip,
  Samsung, NVIDIA, TI, NXP, i.MX, Qualcomm, and Broadcom.

  Noteworthy driver changes include:

   - Several conversions of DT bindings to yaml format.

   - Renesas adds driver support for R-Car V4H, RZ/V2M and RZ/G2UL SoCs.

   - Qualcomm adds a bus driver for the SSC (Snapdragon Sensor Core),
     and support for more chips in the RPMh power domains and the
     soc-id.

   - NXP has a new driver for the HDMI blk-ctrl on i.MX8MP.

   - Apple M1 gains support for the on-chip NVMe controller, making it
     possible to finally use the internal disks. This also includes SoC
     drivers for their RTKit IPC and for the SART DMA address filter.

  For other subsystems that merge their drivers through the SoC tree, we
  have

   - Firmware drivers for the ARM firmware stack including TEE, OP-TEE,
     SCMI and FF-A get a number of smaller updates and cleanups. OP-TEE
     now has a cache for firmware argument structures as an
     optimization, and SCMI now supports the 3.1 version of the
     specification.

   - Reset controller updates to Amlogic, ASpeed, Renesas and ACPI
     drivers

   - Memory controller updates for Tegra, and a few updates for other
     platforms"

* tag 'arm-drivers-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (159 commits)
  memory: tegra: Add MC error logging on Tegra186 onward
  memory: tegra: Add memory controller channels support
  memory: tegra: Add APE memory clients for Tegra234
  memory: tegra: Add Tegra234 support
  nvme-apple: fix sparse endianess warnings
  soc/tegra: pmc: Document core domain fields
  soc: qcom: pdr: use static for servreg_* variables
  soc: imx: fix semicolon.cocci warnings
  soc: renesas: R-Car V3U is R-Car Gen4
  soc: imx: add i.MX8MP HDMI blk-ctrl
  soc: imx: imx8m-blk-ctrl: Add i.MX8MP media blk-ctrl
  soc: imx: add i.MX8MP HSIO blk-ctrl
  soc: imx: imx8m-blk-ctrl: set power device name
  soc: qcom: llcc: Add sc8180x and sc8280xp configurations
  dt-bindings: arm: msm: Add sc8180x and sc8280xp LLCC compatibles
  soc/tegra: pmc: Select REGMAP
  dt-bindings: reset: st,sti-powerdown: Convert to yaml
  dt-bindings: reset: st,sti-picophyreset: Convert to yaml
  dt-bindings: reset: socfpga: Convert to yaml
  dt-bindings: reset: snps,axs10x-reset: Convert to yaml
  ...
2022-05-26 10:32:47 -07:00
Arnd Bergmann 728c0d2941 TEE cleanup
Removes the old and unused TEE_IOCTL_SHM_* flags
 Removes unused the unused tee_shm_va2pa() and tee_shm_pa2va() functions
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmJ0xD4aHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJfWjA/+PG699Ct5WRnorEtCliYU
 NY2YCt5HhKgIMqLbglNLXvWZ5DW/xE8JTfUsBJt7WRG9arha+AZVhJ8wwuoK+MaW
 mEj0NxQLjPCFsxaCtu1fSX8ZJUQKRyqZzNtU91S1/qTz9YBOcmS5shFXT/+EOEwG
 i6B5Y4bXzAsB8h7Lznt9/IyP5VSLHtdgl1auCTdv57m5bwNjsMQBqKJZsR/rgoAo
 4pBAEd1YhDGOuFN2bSONfJx2618753jCA1oxpj5/FLKG93R5Iypu36yRvzu+ujO5
 O1cY4kYNsGCZLHeVgqDkJwDQglfU5GcwSBnGHo+SeJxi8Zj8VRPbm5QECaRASTk9
 y1QSlgBLITxKYJBMjO7HuZ3RrA1wjcCgUrJvXg5KKbkQwttmciFuSewh7/ubRp3V
 tGvEnIH6bjiYMkb4Aiolc9CBhQfg3yCtiJk9VUpK0KiV3Cs1C8cBjATvYQoDCXQX
 OjxcgIXcFnkVzEHb6px7/kAuZghUPSr1A+qJDKIFeaEk9csrYhP+Gmi0XFDMV6Ws
 wuSMUJ9bWg0xw1xo+TVyYy8AQcwWBeSIUC/yq0djW54hPJmTQY9PNdSdYUK/dIN4
 ERN9ncf+BQXd9rr9q0+af2oNOG9Ee3D6jqVNBxMfn1p9ntI5W7jjIKhVDJxOM4R6
 x++gc+FREDet86HKOvOjhhY=
 =7v+l
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmJ1fsQACgkQmmx57+YA
 GNlmThAAvxZ+sXy1ZzpGnn3R04DlD/rCt7whxYfvcuHMRhV4uPc0cPdrFaVFnoh7
 3uGpG+A9TCK9/g77p+pZ4yKpDPUO8HXWci5ptV8TMeUaZDXf+UaXM6y2qpsxBYuF
 wB5aAa0vUZ8ljqbn6KskaiLVvRmYaSSNaEAh8M1cO1dbQHY6D8vtKjkBtmh2zDMZ
 dblGYhaiPEUAyCMOUdVuR0RTQWTQ+AbtGI+n88DnhgnREnuYo1qQMRwrIerTDetn
 f+hMqU6u8dfoo/GeK732YA0DU3Y2PXfE3hRgWlBTYYKClA50O35rHYlYtoOYTmCC
 i1BdgAWeR+oiMJYxaWasIr4gxfFbWfdNSBchVqr/byiLOwhnL0++Jp4YO8ESbery
 T0cDyvG784CagRABw+Yxe0mSMsz6BznQqYGBh+L5vkNXHsEj0KSoj4l/zzL9e0bj
 anqYYxf8glwT13yeWsvHQufOl7XWoLhZVrwB7nUJFt2gJH6CHITyFiFRKw8/PkWb
 lf6KJ7z8gzGeNM7euDEcGUV3emADV/yN1OHohWMI4CjfeKxLfAAkIweKJAHg9/2S
 SZEoa/68LW1+Dp76QMC+ZZBxqIgWzjZcYfZMEuwP6iYwU2EtFSn0OZZ3XUOb7ngm
 fY2MV9ZE03NDXRdP1u4jgLtHKMIOW/c4RXC938WCPHzCQfXgyvo=
 =khay
 -----END PGP SIGNATURE-----

Merge tag 'tee-cleanup-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/drivers

TEE cleanup

Removes the old and unused TEE_IOCTL_SHM_* flags
Removes unused the unused tee_shm_va2pa() and tee_shm_pa2va() functions

* tag 'tee-cleanup-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: remove flags TEE_IOCTL_SHM_MAPPED and TEE_IOCTL_SHM_DMA_BUF
  tee: remove tee_shm_va2pa() and tee_shm_pa2va()

Link: https://lore.kernel.org/r/20220506070328.GA1344495@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-06 22:02:12 +02:00
Arnd Bergmann 6c6012ab96 OP-TEE RPC argument cache
Adds caching of the OP-TEE argument structure used to pass request to
 secure world. This reduces quite a bit of unnecessary alloc/free and
 possibly switching back and forth to secure work in order to register
 the buffers in some configurations, most notably FF-A.
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmJy2qcaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJfGvRAAwWWyMSRRxFGlaiENphwg
 vLKP0faPgW4kBPLI7bd6ItpWlMNNx6ixtqZo8Icz0yke7yb/5m1wi3jC1rz2FuvU
 JZXdepakJ3TGDpXWX6wVSpZFGfq/l41OTmFh3BV3DvUCMTfjXzcUJqv9zHpWwgU/
 qPY/hhWzrJcJ8fTi6tXtExAhUsGxAmSJ/s+ShvNYXbNa8hrgyU3Nq15HODGR1BXS
 +2mos1F4KlGRxhPu+hCRqyyD5l3Tkzk4HFoSt6AOfBQ9voSCcw8XVtL9/4Jx3592
 +99Y+VqsnJJNEHiSD6ESRyKadRIZvH4zwKBh92J3z/NhhxmeC1isDFYkmlgoxCaq
 OgPdFUa0Nq3JlIY4W+0c3TS0N/CGXrRFkDChEbn4sdQOKeIUy70yX/Eml5d+xhAC
 JDnSzz/B6i8qYgXwK6srSiY2uKi75L4qhGQmemp1x4HToRjEjTfWaKX2rBjfspiQ
 8/9HQBG7Xk1PYiAN0z4xIjpoYqMRLwrtGm7J0Ep8/PKFyr+yzIHkYLFtoWGv9PZa
 F23/muMZALUxCLwm03/WmlFqmEeY2cFh/dB6UBIVpBmTM3X7QPdrTwVpamLgmtyT
 hwONAOpmUGF6du0a84Gz2D3unUaGXGI8Ccyam2MsYYQF9vwxp0HU/Q08zR69vMJA
 BmVbSlUfIPcMLOP0xamfrx4=
 =vq/I
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmJz2LIACgkQmmx57+YA
 GNltcBAAws2PU8EbtUoyYsJlClc1lxj+pUfT9snyv8CJVSLV6a+c94EUrxApJiZv
 HWyNrGfjRCY0otXzI+uFz9VbRC7sOWZNygdK0oDu+P9kkRNqzqdzfD366ms/VOGJ
 cswKla5iqKWThkBM4jA2aZA6YdXg4yHjU5h529K5kd/MlW4FyPrN11Bj3ELMeqH5
 XaPkbGMoUgOTkk2CA/9VxVJz2n3fIvXXPYox2fsaDeNJIv3Y0GLEZSC0qE79lve5
 kALRxoHfawyTkHtmVu+3btaUDyjoopRXP0oxo2e3kssGoOUpCJ5OJ8FQhiCiTWXi
 dXE0U7HdM1NNfUSwo87BaE64oMaAULd1OJsOsPkTzzJwvHlcSewAip2y0dd5N7N9
 ngcfBKWo+D17dVNKCVgA7rATMP5se2wtx2/u2TGsyOTmqhteR3hXznHVRm8ZrHCy
 yjtj/5SCqQL9/0/jRGLUR0BwhL0K8+zpW56uQ28cy1a9j7E5iROnrHRmqE6fYaaF
 /sD08lGaeqRKRuIJxFe0OVpQlgVN4ZL75dkujS7OUCrtI++No3QzCjlkSnLdNKdk
 +UB8r3NNPrZSWqdz87Otd+8T6nt7NBbGK/R2yZMtYy1l532VFLguJvRzuY75J8ks
 8LgvZ0AumWRJbig+WdTulanXneAKgugpdwLGfDzNUt8P1nnjVE4=
 =XEqq
 -----END PGP SIGNATURE-----

Merge tag 'optee-rpc-arg-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/drivers

OP-TEE RPC argument cache

Adds caching of the OP-TEE argument structure used to pass request to
secure world. This reduces quite a bit of unnecessary alloc/free and
possibly switching back and forth to secure work in order to register
the buffers in some configurations, most notably FF-A.

* tag 'optee-rpc-arg-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  optee: cache argument shared memory structs
  optee: add FF-A capability OPTEE_FFA_SEC_CAP_ARG_OFFSET
  optee: add OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG
  optee: rename rpc_arg_count to rpc_param_count

Link: https://lore.kernel.org/r/20220504201759.GA180315@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-05 16:01:22 +02:00
Arnd Bergmann 91f92d7038 Arm FF-A firmware driver updates/fixes for v5.19
Couple of fixes to handle fragmented memory descriptors and incorrect
 UUID parameter passed to ffa_partition_probe. Another fix deals with
 the incorrect use of ffa_device's driver_data by the core driver.
 Apart from these fixes, there is an addition of ffa_dev_get_drvdata helper
 function and its use in optee driver.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmJyPeUACgkQAEG6vDF+
 4piw1A//Y/LGEj9+4yv/NWt26M3DujFmQzHdjjJbIMZmy/iV+GJqfl/6uNH49pZZ
 6lNl7N3ZJC/hPakpDPOZUkDwmivlQWiKGbpdtiAXA6qNp5X+bpUk0N2DZTifhl1a
 0M9/iY/77N9CBTe0n0VcY24alm4++94ccMcpleGLYzf1sYU7sy8wZKV+++GDDJld
 TkD1wZ6GQaYQMdQTh+Il92jQbOOnMOfGqPrdRIHDS3R9g099GvFeB34QZfUOJL2d
 3ikKdj+Pe7BUD68FZZ8UQo1irudCi66577ufnN6dgV7Gf0wgqt+f0C+nawmErQCT
 yuYtUd1fOSTLlQCKXKsgF/+VgxwjcGHG1is7jCsBKJRFv3oSYzmaUWTifpxx2HVx
 XfCmrz4N46OmXUkQ1J12qo8F7Swo+VeIYZWIB+PrsUdqFHKK0lOX7mgU1dPZV3wx
 iiwzeexfVk2MCidaE0xqkuP9fQun39/3sZhtMvap6W9A3+jHKJhbz+yWP/AwlEtP
 pTjElKmMHgP1Md6G2kFcHuooPvAe8BPvudGD49U56nenz4uP0o6OnAub6Ay/1GVB
 dmYSdm33BmLM9bxiJqZHb/I3HtYO5suQum4DWQhfcrQX4BtqSu9fjLhkIAuznp2g
 YiBhF0Xdp4XF760JmePZiqCGH7Y8rqyNZHwxWnKunxCb+3uaJiQ=
 =IOMn
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmJz2EAACgkQmmx57+YA
 GNlnvBAAqHkiCC9z0WW4I7qGQ/uNbsYeX4EU856CXXyI5I9Lz8huJBiXoZwcuJMg
 3WBx8aF1m6xIUORM3NbuI/MLkVZyHI6z6Xfndcd+w8U1mI2CLg7/B+djr0jLyx78
 ckXRhua1g8DGoXdFwDao3ndsAAkMtWFJhNHpOMf2jqGdY1xEAIOfHb7YAeyNf7SZ
 1ygoSAhpys5rcek5r6GQzate4QqiwL2YTnC5vDkOWA1OFsX33d5WVEbrM4KmuLSO
 TdEcBWMxQX52pVZkrBZ1F+tZqgGqyDhf3bJ64zNleycV5U81abndTjkadpZflr1R
 4JgUkzHNkb0Xh3TkcyFBqwerq5FmeCkF6Um0vStngNpsa9fiQ8L5dC1T/NNTl6y5
 pZJhXWMPPgN7GDqLRnTnqdk9t3YS5lbU5BuNU33M1X2y0jMikn2V61WKkejhiXK4
 ZYcs5z31zXkDWXuO149FT38ZUXzf14rolrLx7zc3GVhk6oGp0R7kz+7SKW65P0z5
 NAWLFUmwPYAYgOsFaSY7P+i6UhBtpEk3YixjdYjjU3RvwqAp+YkARQKPApUTXido
 zVB4PRSgf1owEhnlnBzKKwM9ORkL+lrqxpGnB7fvr9UU3LvlI2QxoU+4LGlGmvMh
 cutmev2PBmC6QYmPMwLTvOziyP100riiI5ORb2zJPQVIplzn2EM=
 =MDJg
 -----END PGP SIGNATURE-----

Merge tag 'ffa-updates-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/drivers

Arm FF-A firmware driver updates/fixes for v5.19

Couple of fixes to handle fragmented memory descriptors and incorrect
UUID parameter passed to ffa_partition_probe. Another fix deals with
the incorrect use of ffa_device's driver_data by the core driver.
Apart from these fixes, there is an addition of ffa_dev_get_drvdata helper
function and its use in optee driver.

* tag 'ffa-updates-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  tee: optee: Use ffa_dev_get_drvdata to fetch driver_data
  firmware: arm_ffa: Add ffa_dev_get_drvdata helper function
  firmware: arm_ffa: Remove incorrect assignment of driver_data
  firmware: arm_ffa: Fix uuid parameter to ffa_partition_probe
  firmware: arm_ffa: Fix handling of fragmented memory descriptors

Link: https://lore.kernel.org/r/20220504112853.3491961-1-sudeep.holla@arm.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-05 15:59:28 +02:00
Arnd Bergmann a37de2ad8e TEE accept vmalloc()ed buffers for tee_shm_register_kernel_buf()
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmJxgEYaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJfRmBAAqqqcACLZe0kaV5ngiVm6
 JEpBjlKHdArifWg9wH3D/xpV6huJLve2aut9ppZXA6lm2r+Gt9JLkSygGfpBeHiO
 CdzNvUeY2rGAMNROGUNE5aeXOF5Sul32Otey8co9p55GCi7WQEIdZ0DDmGrywcSV
 BPdsaqaw+hAo1PbOHk592NK455lO/WQDkEDYr/ySI8RyKhfys1aa/x0Eq3mJOiCv
 10rOP1sSZlR9WmEqnOh+9YMzsPoctrajhCfJgvKLzyWZl3nkNd3KfjI/6on4TAGp
 huX408otz06UTGTb+IxXAhm2PKXHBewWUOeiEHN/AptDgrWVKN4oL9/Z4RFXULfr
 rMohHkxqMeJ39pzBsHVY8fSuQgu9eNkuImncLXBJbBwU8TKU6eXIqWxXAC/PGoso
 pJEG16E1TM6v7Ld0TzMAEqiWMcDahA27A4NNhEtZUA9yR8AiiwdpnKXmFHmBaKfV
 kSxcvK1xUrEP19AU7Jf+zLRMx44pQ8X9dIoh5mSMjIkwhvsu0CV0xCXJSv/LOznb
 6P0hlyi/lbfb73pFe93a/fW8NwplArIFK77j8WugIZ9V1AwgACi4YGNJs/zqgy+A
 zwuoRgVAWvu8hPpNodMZl2LYPYF8pBOl2jTPtdhqZY75ulxjaYuH7V/H9DE/zQ4L
 GbMMpLS0joTkVx3cM0CFzxE=
 =30Ow
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmJz16YACgkQmmx57+YA
 GNlSnA//dzoavHz1PMVA3iMLAk4u9Lm+UKDGrB2vgSzldaEDhged8mVM+//ihU69
 wlMLf8tujiYEcqt63ceFYGNUVtBzollXu/k58U2AnUCheQA5CaACvuroDOlxRpOA
 gdwDCmOfl/fom0evoYuGO/E6J+ICBda5t1lYCxer4w1h8Znl9NlE3M9KJOOiiZXv
 SXVZ4fgp3cdcXIdyEeuMsM+2dv8FnPjT4eHR840lVJ0Gjv8sZGXB79OviX6yyG4D
 Z0QmvtVzRse1qUCBZbyqTDdvSWLlijSjxW7v6GPSAvT7vULYeeZtbv7PwdTCQhEt
 PyqUQd/qGW4LQfferDXsXYykPFTDL9jRia54k54o6e+VNQlpepFMI7isQxRj8EIK
 Qt7Yuri8lZzOFB91BIGWM8h3ZD3rP0f/WR4DESnYOLFlEVRc9cMR4HooXdSg9bhb
 0O8zkuE6XfZwixnXgafoaO/RWJ1VacZSusTM/cCYWk6F7hj1DYewbXE+wxAOmYiu
 S9NerFvu/89o2iIBHC7acoigBC7Uw0Yw+aoZiZU47iHbNwGgjrWkUPZfYOeVB6e9
 p0Khq6jkeuw/K0r/aQ9Gq2Jp9JprBmzhTJs/GCmMlRq6kq14HqyZZZ/PJZbcJQkA
 tfSYeQO6gxYs9fvuB3HFDlyVUuuNf7MgEEnMZoQJsQkUPKSj0m0=
 =pqsk
 -----END PGP SIGNATURE-----

Merge tag 'tee-shm-vmalloc-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/drivers

TEE accept vmalloc()ed buffers for tee_shm_register_kernel_buf()

* tag 'tee-shm-vmalloc-for-v5.19' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: make tee_shm_register_kernel_buf vmalloc supported

Link: https://lore.kernel.org/r/20220503192916.GA3288817@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-05-05 15:56:54 +02:00
Sudeep Holla f3f3bdbd58 tee: optee: Use ffa_dev_get_drvdata to fetch driver_data
Due to lack of an helper like ffa_dev_get_drvdata, this driver was
fetching driver_data directly accessing the structure member. Now that
we have added an helper, just use the same instead.

Link: https://lore.kernel.org/r/20220429113946.2087145-4-sudeep.holla@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2022-04-29 14:51:46 +01:00
Andrew Davis d8fc1c7c4c tee: remove flags TEE_IOCTL_SHM_MAPPED and TEE_IOCTL_SHM_DMA_BUF
These look to be leftover from an early edition of this driver. Userspace
does not need this information. Checking all users of this that I have
access to I have verified no one is using them.

They leak internal use flags out to userspace. Even more they are not
correct anymore after a45ea4efa3. Lets drop these flags before
someone does try to use them for something and they become ABI.

Signed-off-by: Andrew Davis <afd@ti.com>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-26 10:17:03 +02:00
Andrew Davis 66eb6df79a tee: remove tee_shm_va2pa() and tee_shm_pa2va()
We should not need to index into SHMs based on absolute VA/PA.
These functions are not used and this kind of usage should not be
encouraged anyway. Remove these functions.

Signed-off-by: Andrew Davis <afd@ti.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-26 10:16:48 +02:00
Jens Wiklander 5b4018b959 optee: cache argument shared memory structs
Implements a cache to handle shared memory used to pass the argument
struct needed when doing a normal yielding call into secure world.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-25 21:13:05 +02:00
Jens Wiklander a639b2b18a optee: add FF-A capability OPTEE_FFA_SEC_CAP_ARG_OFFSET
Adds the secure capability OPTEE_FFA_SEC_CAP_ARG_OFFSET to indicate that
OP-TEE with FF-A can support an argument struct at a non-zero offset into
a passed shared memory object.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-13 07:37:48 +02:00
Jens Wiklander ed8faf6c8f optee: add OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG
Adds OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_REGD_ARG where
the struct optee_msg_arg to be used for RPC is appended in the memory
following the normal argument struct optee_msg_arg. This is an
optimization to avoid caching the RPC argument struct while still
maintaining similar performance as if it was cached.

OPTEE_SMC_CALL_WITH_REGD_ARG optimized one step further by using a
registered shared memory object instead. It's in other aspects identical
to OPTEE_SMC_CALL_WITH_RPC_ARG.

The presence of OPTEE_SMC_CALL_WITH_RPC_ARG and
OPTEE_SMC_CALL_WITH_REGD_ARG is indicated by the new
OPTEE_SMC_SEC_CAP_RPC_ARG bit returned by
OPTEE_SMC_EXCHANGE_CAPABILITIES. OPTEE_SMC_EXCHANGE_CAPABILITIES also
reports the number of arguments that the RPC argument struct must have
room for.

OPTEE_SMC_CALL_WITH_RPC_ARG and OPTEE_SMC_CALL_WITH_ARG can be used
interleaved with difference that when OPTEE_SMC_CALL_WITH_RPC_ARG is
used the RPC argument struct to be used is the one appended to the
normal argument struct. The same is true for
OPTEE_SMC_CALL_WITH_REGD_ARG.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-13 07:37:20 +02:00
Jens Wiklander 30c375a7f6 optee: rename rpc_arg_count to rpc_param_count
Renames the field rpc_arg_count in struct optee to rpc_param_count.
Function parameter names and local variables are also renamed to match.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-13 07:33:59 +02:00
Dongliang Mu b5e2288683 tee: optee: add missing mutext_destroy in optee_ffa_probe
The error handling code of optee_ffa_probe misses the mutex_destroy of
ffa.mutex when mutext_init succeeds.

Fix this by adding mutex_destory of ffa.mutex at the error handling part

Fixes: aceeafefff ("optee: use driver internal tee_context for some rpc")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-05 08:56:26 +02:00
Phil Chang 3e47235eae tee: make tee_shm_register_kernel_buf vmalloc supported
In some low-memory devices, it's hard to aquire large-orders pages,
this patch allowed user using scatter pages to register shm.

Signed-off-by: Phil Chang <phil.chang@mediatek.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-05 08:04:16 +02:00
Jan Engelhardt a4b75fe8e1 tee: combine "config" and "menu" for TEE's menuconfig
Don't let TEE occupy two lines in menuconfig when practically no
other (sub)menu does either.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-04-05 07:32:23 +02:00
Linus Torvalds b4bc93bd76 ARM driver updates for 5.18
There are a few separately maintained driver subsystems that we merge through
 the SoC tree, notable changes are:
 
  - Memory controller updates, mainly for Tegra and Mediatek SoCs,
    and clarifications for the memory controller DT bindings
 
  - SCMI firmware interface updates, in particular a new transport based
    on OPTEE and support for atomic operations.
 
  - Cleanups to the TEE subsystem, refactoring its memory management
 
 For SoC specific drivers without a separate subsystem, changes include
 
  - Smaller updates and fixes for TI, AT91/SAMA5, Qualcomm and NXP
    Layerscape SoCs.
 
  - Driver support for Microchip SAMA5D29, Tesla FSD, Renesas RZ/G2L,
    and Qualcomm SM8450.
 
  - Better power management on Mediatek MT81xx, NXP i.MX8MQ
    and older NVIDIA Tegra chips
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmI4nOUACgkQmmx57+YA
 GNlNNhAApPQw+FKQ6yVj2EZYcaAgik8PJAJoNQWYED52iQfm5uXgjt3aQewvrPNW
 nkKx5Mx+fPUfaKx5mkVOFMhME5Bw9tYbXHm2/RpRp+n8jOdUlQpAhzIPOyWPHOJS
 QX6qu4t+agrQzjbOCGouAJXgyxhTJFUMviM2EgVHbQHXPtdF8i2kyanfCP7Rw8cx
 sVtLwpvhbLm849+deYRXuv2Xw9I3M1Np7018s5QciimI2eLLEb+lJ/C5XWz5pMYn
 M1nZ7uwCLKPCewpMETTuhKOv0ioOXyY9C1ghyiGZFhHQfoCYTu94Hrx9t8x5gQmL
 qWDinXWXVk8LBegyrs8Bp4wcjtmvMMLnfWtsGSfT5uq24JOGg22OmtUNhNJbS9+p
 VjEvBgkXYD7UEl5npI9v9/KQWr3/UDir0zvkuV40gJyeBWNEZ/PB8olXAxgL7wZv
 cXRYSaUYYt3DKQf1k5I4GUyQtkP/4RaBy6AqvH5Sx0lCwuY6G6ISK+kCPaaSRKnX
 WR+nFw84dKCu7miehmW9qSzMQ4kiSCKIDqk7ilHcwv0J2oXDrlqVPKGGGTzZjUc8
 +feqM/eSoYvDDEDemuXNSnl3hc1Zlvm7Apd5AN6kdTaNgoACDYdyvGuJ3CvzcA+K
 1gBHUBvGS/ODA25KnYabr7wCMgxYqf7dXfkyKIBwFHwxOnRHtgs=
 =Cfbk
 -----END PGP SIGNATURE-----

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

Pull ARM driver updates from Arnd Bergmann:
 "There are a few separately maintained driver subsystems that we merge
  through the SoC tree, notable changes are:

   - Memory controller updates, mainly for Tegra and Mediatek SoCs, and
     clarifications for the memory controller DT bindings

   - SCMI firmware interface updates, in particular a new transport
     based on OPTEE and support for atomic operations.

   - Cleanups to the TEE subsystem, refactoring its memory management

  For SoC specific drivers without a separate subsystem, changes include

   - Smaller updates and fixes for TI, AT91/SAMA5, Qualcomm and NXP
     Layerscape SoCs.

   - Driver support for Microchip SAMA5D29, Tesla FSD, Renesas RZ/G2L,
     and Qualcomm SM8450.

   - Better power management on Mediatek MT81xx, NXP i.MX8MQ and older
     NVIDIA Tegra chips"

* tag 'arm-drivers-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (154 commits)
  ARM: spear: fix typos in comments
  soc/microchip: fix invalid free in mpfs_sys_controller_delete
  soc: s4: Add support for power domains controller
  dt-bindings: power: add Amlogic s4 power domains bindings
  ARM: at91: add support in soc driver for new SAMA5D29
  soc: mediatek: mmsys: add sw0_rst_offset in mmsys driver data
  dt-bindings: memory: renesas,rpc-if: Document RZ/V2L SoC
  memory: emif: check the pointer temp in get_device_details()
  memory: emif: Add check for setup_interrupts
  dt-bindings: arm: mediatek: mmsys: add support for MT8186
  dt-bindings: mediatek: add compatible for MT8186 pwrap
  soc: mediatek: pwrap: add pwrap driver for MT8186 SoC
  soc: mediatek: mmsys: add mmsys reset control for MT8186
  soc: mediatek: mtk-infracfg: Disable ACP on MT8192
  soc: ti: k3-socinfo: Add AM62x JTAG ID
  soc: mediatek: add MTK mutex support for MT8186
  soc: mediatek: mmsys: add mt8186 mmsys routing table
  soc: mediatek: pm-domains: Add support for mt8186
  dt-bindings: power: Add MT8186 power domains
  soc: mediatek: pm-domains: Add support for mt8195
  ...
2022-03-23 18:23:13 -07:00
Arnd Bergmann 25b67f373b TEE shared memory cleanup for v5.18
- The TEE shared memory pool based on two pools is replaced with a single
   somewhat more capable pool.
 - Replaces tee_shm_alloc() and tee_shm_register() with new functions
   easier to use and maintain.  The TEE subsystem and the TEE drivers are
   updated to use the new functions instead.
 - The TEE based Trusted keys routines are updated to use the new
   simplified functions above.
 - The OP-TEE based rng driver is updated to use the new simplified
   functions above.
 - The TEE_SHM-flags are refactored to better match their usage
 -----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmIP5coaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJdLQg/9F+9wtUsM3sJAitaB0DN1
 tTd8Iwt0Ir8khuac56/pMcVlFF1dwBAFy5vnAKKSGF0nzToyEhOc4uRsOA0vvQ4s
 EtTX7ONuHjPR18faxJbtLHPl3tSjGxkwtrBo5IvCapxaYsJK8x2XEamr9ih7r5nZ
 KwSTNgiGZ+WM+IgwgZIFfOoB4pXnkQZAf2UBAdK2W1dVpIOoJzLpiS28DNgA08C5
 sUduKi2GvmaieTqu6QHY2FJNRAVgYrzuyXIgfQ+Kjsa/GDMZ6CS9DB3BBt1D4xyM
 OzIl4/Y2nZqJ6EFhuFtWIQIuMLlw0HiM08d/PC4vW05EwKmeJ5zTs+I9nJQEnPKN
 n4SfwqKIIq5KeYeT0ByVuGwm/JET4YXvL3d9EqkDtFAwnkT0Jx7o5GgFQbj1+0Z9
 RvmWWy7VFPRhvLGsPpkuJnGc9rD4XVtzFw92K1VRmarQnjQFmD2y7DvNEEXokLCv
 Z4GV3bz7ntmURJsOoMpt56i9WboXkjFmsaIqg09ShPRC9EB+9RMvRNEwE72FZmlH
 RIMl5Vx4SkYbY1FlaiJ9BSctcdQD9HES17D5z5l6Im3JjMbFeKvLLQCJ/Ch3vxNj
 OujRhXsEO2g9uUXwh0OveK8mEh3bz+GE/uj+c7xZXb95ImswyK9fo9uLvG+Z6JVk
 n9+xgsKUZlHwHkoofuXor4k=
 =xOBv
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmIY/jcACgkQmmx57+YA
 GNk94w//VHkLJADLSqwh8AZXUwpBN3nCKtsEay7HbRmC9Nh4Zm/TQyYx79QmRnnK
 kDxLVAFTapFLxQVo441jPfnjp2cSW0Oomhv3zLIPNE44Gb0jF+hqfbN3sLJLk5hZ
 EiiRxnMEJ6KCbvLEXaSUqRfGoYkU98HF6vNzN0nme6Zq9f11GO7RsUGL1nLNrU7R
 mGj4O1hr6QVWMCY5vvEYLkGZFj54jVb64UVYzmyw8Nt5IIbY2upCQFoeQYHtiIle
 h354Wn3PgE+txzSKGGH0dw9hq2JPNFSwmx3psvw+9HUjYXGC8rfaJeRNTEC9oIaC
 ALXqNnnu/kkhKt6rfkVaVuJFjefn/WjTCfEFyCRblwmNdi+DZfkcCkDh0Tj/4F6X
 /hoLYC4XXt+bxvdi8I6+xH8ho+Zwsh3F9WXWAU+p1fR5/kOTpvYe10k+59lK+AUK
 bbPCN2WQ+IB66Mt8OXAVRycXKrbGU32QTioWF7Jv5/ZgF1aTeAnzyoRnT9OI8FMz
 sxqSNd/Lasc8czP+xdTrfisOy+7vRfSOPDgZ4BUVQLAZIDmuqiJo3Rtu4J72aZx2
 Pyk680b3iGKORBGVFznF8DOWxNdbUbuQFxUzIGGKHtsy9++fyZzrwtjASmT9Bzef
 ec6FVInEKt+f6nuMUZrMWRaWIZw3KGqWRnkX47k86PsCAh3HDvo=
 =0vIF
 -----END PGP SIGNATURE-----

Merge tag 'tee-shm-for-v5.18' of git://git.linaro.org:/people/jens.wiklander/linux-tee into arm/drivers

TEE shared memory cleanup for v5.18

- The TEE shared memory pool based on two pools is replaced with a single
  somewhat more capable pool.
- Replaces tee_shm_alloc() and tee_shm_register() with new functions
  easier to use and maintain.  The TEE subsystem and the TEE drivers are
  updated to use the new functions instead.
- The TEE based Trusted keys routines are updated to use the new
  simplified functions above.
- The OP-TEE based rng driver is updated to use the new simplified
  functions above.
- The TEE_SHM-flags are refactored to better match their usage

* tag 'tee-shm-for-v5.18' of git://git.linaro.org:/people/jens.wiklander/linux-tee:
  tee: refactor TEE_SHM_* flags
  tee: replace tee_shm_register()
  KEYS: trusted: tee: use tee_shm_register_kernel_buf()
  tee: add tee_shm_register_{user,kernel}_buf()
  optee: add optee_pool_op_free_helper()
  tee: replace tee_shm_alloc()
  tee: simplify shm pool handling
  tee: add tee_shm_alloc_user_buf()
  tee: remove unused tee_shm_pool_alloc_res_mem()
  hwrng: optee-rng: use tee_shm_alloc_kernel_buf()
  optee: use driver internal tee_context for some rpc

Link: https://lore.kernel.org/r/20220218184802.GA968155@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-02-25 17:05:11 +01:00
Arnd Bergmann 4f6668f052 OP-TEE fix error return code in probe functions
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmIKQNIaHGplbnMud2lr
 bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJc28A/9G+hOvPLhDF+nM6bJJzYU
 rAwsKgT7CMGCxWiwH9U06ggl8uo6ItSJyMhnvmp1mVM41UUNTTZUXIotkSHpdP2U
 ezH0MJVO3Ez5q2fSUs6Be7Wz2cdcMMrZgavbBTymiEAkTJVohOrW7Wbk+NK4ATUG
 P894Jt0giH4oIAZZg56UGITs2nhcUPTheuUTrLx4xy2Lq6CWw3+yTkarzyU5hCwJ
 tc4UMsGfNVVccw/sziHioSXC6gIjVezufggsQyrMl5tUSQQRi0TxgxbAXEucefNj
 EChxOxosSp9ZXdQDB8ufu9bIi4zF1UxhFi9b8u1jse8LhchD3UvbSAXkykUbvlyZ
 tCjMP2alacc8RMMcSGw7fFZhTTlkJTja/2H3IiLgfszdZjSJV7nrX290maxRiKBd
 WMCegMTBtSl5tBRnW5LH6gIJ9O0U5oqONI/B1YZ9kRuBD7vlkqb8U3LgvqzoR8H8
 AFVs00nb7SDzlXnmTLjIqcpnM0Ovp8QH/dUEQZk1b9tN+oYG+kfLSu+LB5Okzwum
 fgnxscN66lU8wdwLIhdyIU83YdYpBzTY2y6OxGYril798dwoMFL86fg8c5/zfP5O
 /Q8Tb+IGyLsApPbcU3Yct6ZtpyE4bdzvHLZjxZXq6JCsrKN+sLMAmizJIbEAfzdo
 dfhIGT0uKwEI3km8DwbgEPU=
 =88/o
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmIPyYkACgkQmmx57+YA
 GNl0Bg//dvU6bjJsEfAJYhVt+ByPT/EvU9Q8umlTxo10CsbLhM3WZperPWivfP59
 xt19FmqN9M5BZkC3VSRxxPCLsLJ+IE+r6VyO4+EHAaB/1DBOKnRD5T6iqQm6QW0o
 1oI5OuAQGoeP7fqFJfd8KFjCqYQAUcGTT7wuUl7foIsGNR7Sw+xgE2DkOw0ol7BQ
 /Fll1vlP2mls6RRAnKQUqlA7se6VGvp5tVxlue4v3J/v5FMAXhGNzaa9wrHJEjld
 N6jYnd9/5Muxea31SBjYt1P6ZaOEeDG54UDFGoLdVhLLtFBVopJVuGthyCZx7UNy
 qwfIuZWYaPMXFMxFWmz3d/pAQxM+ZGo+EjwrBTM2JeFhenTZn8HefTpcN3G8Dg+P
 6led6sJn4TCdvD8ZpkRLhWbNHUX+SoRx17vFs5k6GEP4UIVfsGu4mak18yxpDOYT
 LwCEqGqIjc6uIWEkzwkVITyJiwSK63NNHuHZhbm6fYCsOVE4gj42yLXmt8gx+SV+
 LtPDI9CS/3O3HEMd/+hO0I6BQx9bB3Vx44s/4JxVYCDAKSDwSwuMGI1ZHadGIfYI
 YAkNhDQOs82tqXAivh+Hp/0of7F7GSwyHzCZWbHsd0/aPZC7m+gOxy2WUXAUOCt4
 rRSjF85PLhxRHksyh0N7bCujUgx4dctJAtG3mQ46BuaumfbNWuc=
 =4P5l
 -----END PGP SIGNATURE-----

Merge tag 'optee-fix2-for-v5.17' of git://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes

OP-TEE fix error return code in probe functions

* tag 'optee-fix2-for-v5.17' of git://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: optee: fix error return code in probe function

Link: https://lore.kernel.org/r/20220214125931.GA1332792@jade
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-02-18 17:30:01 +01:00
Jens Wiklander a45ea4efa3 tee: refactor TEE_SHM_* flags
Removes the redundant TEE_SHM_DMA_BUF, TEE_SHM_EXT_DMA_BUF,
TEE_SHM_MAPPED and TEE_SHM_KERNEL_MAPPED flags.

TEE_SHM_REGISTER is renamed to TEE_SHM_DYNAMIC in order to better
match its usage.

Assigns new values to the remaining flags to void gaps.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander 53e16519c2 tee: replace tee_shm_register()
tee_shm_register() is replaced by the previously introduced functions
tee_shm_register_user_buf() and tee_shm_register_kernel_buf().

Since there are not external callers left we can remove tee_shm_register()
and refactor the remains.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander 056d3fed3d tee: add tee_shm_register_{user,kernel}_buf()
Adds the two new functions tee_shm_register_user_buf() and
tee_shm_register_kernel_buf() which should be used instead of the old
tee_shm_register().

This avoids having the caller supplying the flags parameter which
exposes a bit more than desired of the internals of the TEE subsystem.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander 924e322692 optee: add optee_pool_op_free_helper()
Adds a common helper function to free a tee_shm allocated using the
helper function optee_pool_op_alloc_helper().

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander 5d41f1b3e3 tee: replace tee_shm_alloc()
tee_shm_alloc() is replaced by three new functions,

tee_shm_alloc_user_buf() - for user mode allocations, replacing passing
the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF

tee_shm_alloc_kernel_buf() - for kernel mode allocations, slightly
optimized compared to using the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF.

tee_shm_alloc_priv_buf() - primarily for TEE driver internal use.

This also makes the interface easier to use as we can get rid of the
somewhat hard to use flags parameter.

The TEE subsystem and the TEE drivers are updated to use the new
functions instead.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander d88e0493a0 tee: simplify shm pool handling
Replaces the shared memory pool based on two pools with a single pool.
The alloc() function pointer in struct tee_shm_pool_ops gets another
parameter, align. This makes it possible to make less than page aligned
allocations from the optional reserved shared memory pool while still
making user space allocations page aligned. With in practice unchanged
behaviour using only a single pool for bookkeeping.

The allocation algorithm in the static OP-TEE shared memory pool is
changed from best-fit to first-fit since only the latter supports an
alignment parameter. The best-fit algorithm was previously the default
choice and not a conscious one.

The optee and amdtee drivers are updated as needed to work with this
changed pool handling.

This also removes OPTEE_SHM_NUM_PRIV_PAGES which becomes obsolete with
this change as the private pages can be mixed with the payload pages.

The OP-TEE driver changes minimum alignment for argument struct from 8
bytes to 512 bytes. A typical OP-TEE private shm allocation is 224 bytes
(argument struct with 6 parameters, needed for open session). So with an
alignment of 512 well waste a bit more than 50%. Before this we had a
single page reserved for this so worst case usage compared to that would
be 3 pages instead of 1 page. However, this worst case only occurs if
there is a high pressure from multiple threads on secure world. All in
all this should scale up and down better than fixed boundaries.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander 71cc47d4cc tee: add tee_shm_alloc_user_buf()
Adds a new function tee_shm_alloc_user_buf() for user mode allocations,
replacing passing the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF to
tee_shm_alloc().

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Jens Wiklander f41b6be1eb tee: remove unused tee_shm_pool_alloc_res_mem()
None of the drivers in the TEE subsystem uses
tee_shm_pool_alloc_res_mem() so remove the function.

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-16 07:49:41 +01:00
Yang Yingliang 40eb0dcf41 tee: optee: fix error return code in probe function
If teedev_open() fails, probe function need return
error code.

Fixes: aceeafefff ("optee: use driver internal tee_context for some rpc")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-14 12:36:48 +01:00
Cai Huoqing f7b67642dd tee: amdtee: Make use of the helper macro LIST_HEAD()
Replace "struct list_head head = LIST_HEAD_INIT(head)" with
"LIST_HEAD(head)" to simplify the code.

Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev>
Reviewed-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2022-02-14 10:57:55 +01:00