Gráfico de commits

50 Commits

Autor SHA1 Mensagem Data
Amirreza Zarrabi
eaa3b491d8 securemsm-kernel: smcinvoke: Add missing unlock on function return
Also reset the output buffer after processing.

Change-Id: Ib8d9b3ffe4c25c3c699df561d7f37776a8fcd538
Signed-off-by: Amirreza Zarrabi <quic_azarrabi@quicinc.com>
2023-09-11 22:00:23 +05:30
Anmolpreet Kaur
e2e161b34c securemsm-kernel: smcinvoke: Release map objs if invoke call fails
This change is a correction on top of commit: b1c6f1e9
which provided the fix for same issue but had a catch.
In the previous change, kref_put was being done on an
empty list. This change fixes that issue and deletes the
list after kref_put is done.

Root cause of original issue:
If invoke call fails due to some reason, map objects created
for memory objects should also be released. Failing to do so,
creates a memory leak as TZ is unaware of these objects and
no one calls release on these.

Change-Id: Ibad583f6c45fbed05539757eb50a39289d532328
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
2023-08-17 19:46:33 -07:00
Reut Zysman
41db658cfd securemsm-kernel: smcinvoke: Fix mapping requests log
Print the error log indicating that a mapping request
was received only in case the memory object async
support was enabled.

Change-Id: I1e02e4cb8501d539fdd6767152697a41033aa1d6
Signed-off-by: Reut Zysman <quic_rzysman@quicinc.com>
2023-07-26 22:02:32 -07:00
Vikas Kumar Sharma
5d325c58e1 securemsm-kernel:smcinvoke: Alt RoT signed TA fails to load.
Fix: The size of TA application name increaed, once it is alternate signed TA.

Change-Id: Ie66b870f04cdc4a8ed14fe5bc134f9ecaffa7fda
Signed-off-by: Vikas Kumar Sharma <quic_vksharma@quicinc.com>
2023-07-04 17:09:41 +05:30
Reut Zysman
ce2b7baa79 securemsm-kernel: smcinvoke: limit excessive logging
Use pr_err_ratelimited to limit logs that are
printed frequently.

Change-Id: If16646d244e963300be4cabc4250e9139014b3d6
Signed-off-by: Reut Zysman <quic_rzysman@quicinc.com>
2023-06-27 13:32:27 -07:00
Reut Zysman
780711b60c securemsm-kernel: smcinvoke: expand API
Expand SMCInvoke API to support possible
future requirements.

Change-Id: I9f6031751489c43a27afc2860a1cb9f87c7ebb87
Signed-off-by: Reut Zysman <quic_rzysman@quicinc.com>
2023-06-15 07:26:07 -07:00
Nitin LNU
cdef6720fe securemsm-kernel: Enable Qseecom driver by default
Enable qseecom driver by default to compile on all chipset
in parallel with Qseecom-compat enable.

Change-Id: I3dd3aa2864c41196197f0770020225fa36f088c1
Signed-off-by: Nitin LNU <quic_nlakra@quicinc.com>
2023-06-15 00:31:14 -07:00
Divisha Bisht
3983090d0e securemsm-kernel: Moving qseecom headers to securemsm-kernel
Move qseecom headers to securemsm-kernel. Also, cleanup and split
of qseecom header done based on usage.
These qseecom headers are now exposed to userspace as
qseecom_kernel_headers.
All the other changes are to take care of compilation dependencies
from the above.

Tests: Tested in device with local build with qseecom sampleclient
cmds.

Change-Id: I55442ce7380636a2630c2e372099735fec0756a8
Signed-off-by: Divisha Bisht <quic_divibish@quicinc.com>
2023-06-13 17:34:45 +05:30
Amirreza Zarrabi
11d07e1a50 securemsm-kernel: smcinvoke: Add argument to choose to retry the EBUSY
The synchronous release may happen in the path of callback response.
The retry may unnecessarily be resulted in callback response timeout.

Run concurrently to evaluate the test:
smcinvoke_vendor_client -i /data/smplap64.mbn 5 1
smcinvoke_vendor_client -c /data 1

Change-Id: Idefca46a34fd72c867e3cba616d30985af40ffe4
Signed-off-by: Amirreza Zarrabi <quic_azarrabi@quicinc.com>
2023-05-17 14:03:19 -07:00
Nitin LNU
f7797f7c04 securemsm-kernel: Limit frequency of log from tzcb
Limit the rate of logs from tzcb by printing one out of 5 logs
of retries.

Change-Id: I4138ab3c4a3d8fa92ef045e9e5c7e7919253823c
2023-05-16 10:34:39 -07:00
Amirreza Zarrabi
319ca50656 securemsm-kernel: smcinvoke: fix the duoble release for memobj.
If the server dies, the memobj would be released two times.
Assuming, one instance is already held by the server which
is not true.

Change-Id: I609b1e5f64648736d26c2e780aefcf7f2db64729
2023-05-14 14:57:54 -07:00
Anmolpreet Kaur
b1c6f1e933 securemsm-kernel: smcinvoke: Release map objs if invoke call fails
If invoke call fails due to some reason, map objects created
for memory objects should also be released. Failing to do so,
creates a memory leak as TZ is unaware of these objects and
no one calls release on these.

Change-Id: If5c48b810192553e3a216a0c3671f98a79bb2b59
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
2023-05-08 22:03:07 +05:30
Vikas Kumar Sharma
61a4a72db8 securemsm-kernel: smcinvoke: Fix KW Errors
Fix usage of un-initialized variables , dereferencing of pointer after NULL check

Change-Id: I36afeaefa7f7c524fd0165420140e80ee5580503
2023-04-06 08:40:23 -07:00
Nitin LNU
8083b9b690 smcinvoke: No need maintain bridge_created by others flag.
Ref_count should be with shmbridge and shmbridge should
maintain real owner and ref_count info as smcinvoke is a
client it should blindly do register and deregister.

Change-Id: Ib9400af0db1abafa7c6262e7cd80c8ae301a4ed1
Signed-off-by: Nitin LNU <quic_nlakra@quicinc.com>
2023-04-06 00:08:48 -07:00
Reut Zysman
8e63104cd2 SMCInvoke: memory object optimization for CB use case
Add support for map opjects to be written into the
async side channel also for the use case where memory
objects are created as a result of a CB request.

Change-Id: I63798d92e40127fe842c08b892d734134f792dd9
Signed-off-by: Reut Zysman <quic_rzysman@quicinc.com>
2023-03-19 07:03:32 -07:00
Anmolpreet Kaur
50fd822191 securemsm-kernel: smcinvoke: Move TZ min buf size to header file
Move SMCINVOKE_TZ_MIN_BUF_SIZE to header file so that it can
be used by userspace modules.

Change-Id: I1f690c2507c6694175c317fe14fcca21cc907714
2023-03-09 14:42:17 -08:00
Reut Zysman
b56eed703e SMCInvoke: limit excessive logging
Use printk_ratelimit() to limit the logs
indicating that secure side is busy,
that the sever state was set to defunct,
and other logs that may be printed frequently.

Change-Id: I93c64bfa65cc2f499cabff3fd26b74764269b6f6
Signed-off-by: Reut Zysman <quic_rzysman@quicinc.com>
2023-03-08 10:34:36 -08:00
Nitin LNU
b87455c99c securemsm-kernel: smcinvoke: Call object release sync once before adding to queue
call release tz object in sync manner
only in case of EBUSY add
object in to post process list, so that we can retry
and process it later in a seprate kthread.

Change-Id: I2158b3faa5c41d2f10ed532c50c9c6b113961c57
2023-02-28 03:11:03 -08:00
Pawan Rai
d0ede8a88c smcinvoke: ADCI methods call on rootEnv
Change adci methods call on rootEnv from clientEnv as per
QTEE implementation.

Change-Id: Ib1ca4312844f6f3dedbfb639e5b83f71d97ecc68
2023-02-22 10:49:11 +05:30
Pawan Rai
ca9f562c5a smcinvoke: adci interface adaptation as per QTEE
Adapted the latest IClientEnv adci and other
interface methods from QTEE.
Change-Id: I05730e56d656977fbc53a2d3dedb04426474be1c
2023-01-29 10:58:20 -08:00
Anmolpreet Kaur
1177b17bdb smcinvoke: Handle suspend and resume issues in smcinvoke driver
This change makes changes to smcinvoke driver to handle suspend and resume
scenarios. If the accept thread gets interrupted, do not set the server state
as defunct if the thread is in freezing state, i.e. if the thread is going in
suspend. In such cases, increase timeout of that server so that invoke thread
waits indefinitely for response from userspace until the system resumes back.

Tests:
1. Stability testing has been done on kalama.
2. smcinvoke vendor client testing is done on pineapple.

Change-Id: Iaa7b91d6ed484305349c04468263919e26a3316d
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
2023-01-18 17:10:02 +05:30
Reut Zysman
a7350ce560 SMCInvoke: memory object optimization
Add support for map objects to be written into the async
side channel rather than have to be explicitly asked for
by QTEE.

Change-Id: Ia1c56555dc3a6422f4fb448f94f73fef661ac89d
Signed-off-by: Reut Zysman <quic_rzysman@quicinc.com>
2023-01-12 08:48:09 -08:00
Amirreza Zarrabi
e354297278 smcinvoke: remove global lock around the call to QTEE.
Change-Id: I741c44fce96e168e69eb4ee9d3ca5081ee6af89b
Signed-off-by: Amirreza Zarrabi <quic_azarrabi@quicinc.com>
2023-01-10 16:04:51 -08:00
Pawan Rai
ef2c3ba718 smcinvoke: ADCI changes for SMCInvoke Driver
Change consists creation of ADCI thread at SMCInvoke
driver initialization

 Change consists creation of ADCI thread at SMCInvoke driver initialization
 Following scenario have been tested for this change
  (1) ADCI thread creation and QTEE invocation during driver initialization
  (2) Backward Compatibility - IF ADCI feature is not supported (OBJECT_ERROR_INVALID)
        then exit the ADCI thread gracefully after cleaning up all the resources
  (3) Leak Test: All the resources held by ADCI thread should be released if ADCI feature
      is not supported by QTEE
      (i) adci task_struct state and exit state:
            state =  TASK_RUNNING , exit_state = 0 (While ADCI thread execution)
            state =  TASK_DEAD , exit_state = EXIT_DEAD (During ADCI thread termination)
     (ii) adci task_struct = NULL (fetched based on adci thread_id) which make sure
             task_struct has been deallocated
  (4) SMCInvoke related Test: All the internal(suuported),memobj and cbo testing has been performed.

Change-Id: I2916ce260fae293b88fbc8b9d24baccdee1ea89f
Signed-off-by: Pawan Rai <quic_pawarai@quicinc.com>
2023-01-09 00:50:26 -08:00
Ashish Pratap Singh Bhadoria
4ed6950035 smcinvoke: Avoid marshalling user args if Callback invocation fails.
Avoid marshalling user args in kernel driver if the corresponding CallBack
invocation fails in userspace.

Change-Id: I1dc5ca562c5a67e1ac2273a1ff2a854f2010c1d3
2023-01-08 22:10:20 -08:00
Ashish Pratap Singh Bhadoria
6d3f76fb88 smcinvoke: Flush cache contents before invalidating
during smcinvoke callback response handling.

Add Cache flush before invalidating out_buf during cb
response handling in smcinvoke driver.

Change-Id: I68b70c078675f1841690c93048cbba3589a388f3
2022-12-23 02:28:27 -08:00
Anmolpreet Kaur
d5c0b30e00 smcinvoke: Wait for new requests in case of invalid cbtxn
In case the accept thread has invalid cbtxn, start waiting
for new requests instead of going to userspace and then coming
back.

Change-Id: I2cce16ebb0481d184fed636a559e73adaacdcf0f
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
2022-12-22 10:32:17 -08:00
Anmolpreet Kaur
8456ddc256 securemsm-kernel: Add support for qseecom proxy module
A new module named qseecom_proxy has been defined in kernel
which acts as a forwarder for calls received from kernel clients
of qseecom and smcinvoke. This change adds the support for calling
that module from the vendor dlkm modules smcinvoke and qseecom.

Change-Id: I0d1aa93b9cea9e6a6e1fee17c33c78e14deb8ecf
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
2022-12-09 03:56:15 +05:30
Anmolpreet Kaur
b38291450d smcinvoke: Make memory objects release inline with callback objects
Release memory object from userspace when a call to release comes in
kernel to prevent the memory leaks in the cases where mem objects
are passed as a response inside a callback call.

Change-Id: I5ce57b6be90e71e255a890895d5f2859312ba1e4
Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com>
2022-11-29 12:51:24 -08:00
Smita Ghosh
111af59f67 smcinvoke: update process_tzcb_req to be more responsive
1. While waiting for callback response instead of waiting uninterruptibly for
  1sec split wait timeout to 100ms and increase number of retries to 50.

2. If a wait is interrupted due to signal, continue to wait if callback server
   is in a good state.

Change-Id: I15faf27ebdb98e2df4a0c75695643a611ad9889d
2022-11-23 09:09:12 -08:00
Smita Ghosh
81cf72e4ab smcinvoke: Print retry_count value
This is important to estimate how long each clients are waiting
for secure side.

Signed-off-by: Smita Ghosh <quic_smitag@quicinc.com>
2022-11-04 09:18:12 -07:00
Smita Ghosh
0f28e48cbc secure-kernel: Add support for 5.15 kernel
Add following changes.

Fix switch case
  latest compiler throwing error where CASE statement does
  not have break or return under all the execution paths.

Rename size_add to size_add_
  There is a name collision between this one and one coming from
  overflow.h. Hence renaming it.

Modify IRQ handling for qce50 module

Change PDE_DATA to pde_data

Signed-off-by: Smita Ghosh <quic_smitag@quicinc.com>

Change-Id: I4226fb41df12273b45d2e114f1aad2709dc36eb7
Signed-off-by: Smita Ghosh <quic_smitag@quicinc.com>
2022-10-07 14:33:11 -07:00
Smita Ghosh
efd4a5f0bd smcinvoke: Increase MAX_RETRY
Change-Id: Ibcc7bd8614246e44938aac338ac2c06414d3ce63
2022-09-09 13:25:47 -07:00
wenji
20f8c5a846 securemsm-kernel: Remove interruptable signal
1. When invoke thread have resumed from freezing to running or is
   killed, the interruption signals will always interrupt the
   smcinvoke callback calls. this will lead the QTEE and listener
   to be out of sync.
2. To fix this issue, we remove the signal interruption, this solution
   will prevent the smcinvoke from being out of sync.

Change-Id: I8f0cd7342784564ce12e617dc4076638f365aba9
Signed-off-by: wenji <quic_wenji@quicinc.com>
2022-08-17 06:25:20 -07:00
basant kumar
200b12bb33 securemsm-kernel: smcinvoke: Add explicit cache flush during callback req from TZ
During Callback request from TZ, smcinvoke in and out buffers need
explicit cache operation with legacy smcinvoke.

Change-Id: I3eacd69901c1ce117017b2d59a28dfab83b5f3f9
2022-08-11 14:43:05 +05:30
Nicholas Pelham
a4a925db92 securemsm-kernel: Add IClientEnv_registerWithCredentials
Use new ClientEnv register method for kernel clients

Change-Id: I3ce32788c5c7658dcaf808c00d52c32df226fec6
2022-08-01 17:24:07 -07:00
Patrick Daly
3c241f3b30 securemsm-kernel: Fix compilation errors with CONFIG_FTRACE=n
smcinvoke.c:578:10: error: implicit declaration of function 'kthread_should_stop'
while (!kthread_should_stop()) {

smcinvoke.c:617:43: error: implicit declaration of function 'kthread_run'
smcinvoke[i].postprocess_kthread_task = kthread_run(

Change-Id: Id6a8b6844ec7ae00b55c81d3760a91da9d49a9ad
Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com>
2022-07-29 20:56:57 -07:00
wenji
0841f5d4c3 securemsm-kernel: Create device node of smcinvoke later
Because the device node of smcinvoke is published at the
beginning of the smcinvoke_probe(), the device node will
be ready while the smcinvoke is not initialized completely.
Hence the smcinvoke_release probably is called when the
smcinvoke driver is not ready. this case will lead to
smcinvoke crash issue.

To avoid this concurrency issue, we create the device node
at the end of the smcinvoke_probe.

Change-Id: I930685a24fb744893017c90c1881f13e2f2c3d7c
Signed-off-by: wenji <quic_wenji@quicinc.com>
2022-07-26 10:38:18 +08:00
wenji
1bdcb08f83 securemsm-kernel: Postpone the shambridge created by smcinvoke
1. When there is a large shambridge memory which is not
   deleted in time, The shambridge in QTEE might be out of
   memory. we met this issue in the TVM TUI unit test.

  TrustedUISampleTest -vm  --gtest_filter=*Basic_TUIStartStop*

2. To avoid being out of shambridge memory, we should postpone
   the deletion of shambridge created by smcinvoke itself.

Change-Id: I2ef837339881c1dcd78a0da10fc848488c9819ca
Signed-off-by: wenji <quic_wenji@quicinc.com>
2022-07-18 11:56:34 +08:00
Nitin LNU
e2231d0fe2 securemsm-kernel: Post process shmbridge delete and object release
1.When the QTEE is busy with a high concurrency, the objects and shared
memory bridge will not be released and deleted in time, this will lead
to memory leakage issues in the QTEE.
2.To avoid the memory leakage in case of EBUSY, we add 2 exclusive worker
threads to postprocess the object release and shmbridge deletion
separately.

Change-Id: I94c656d191d5098f1c093650e4321e6b5353e45e
Signed-off-by: Nitin LNU <quic_nlakra@quicinc.com>
2022-06-23 22:32:26 -07:00
Bruce Levy
995c3731b7 smcinvoke: Fix mutex lock and unlock
Acquire lock before delete_cb_txn_locked.
This API expects the lock is aquired before calling it
release the lock afterwards.

Also rename the api with_locked to state that api
needs to be called on locked mutex.

Change-Id: I6384ff60004da90b46904823e399c62c55ea4273
2022-06-07 08:26:27 -07:00
Pavan Bobba
d577197ff2 smcinvoke : file private data validation which is sent by userspace
a validation added to check  whether retrieved struct smcinvoke_file_data
inside the function get_server_id belongs to g_smcinvoke_fops or not.

Change-Id: I50bce93ab89759b4fdcb76e41f699d8199771fbd
Signed-off-by: Pavan Bobba <quic_pav@quicinc.com>
2022-05-23 00:03:42 -07:00
Pavan Bobba
828d87565b smcinvoke: SHM create/delete handling in memory objects
simplify handling of shm bridge create and delete
Signed-off-by: Pavan Bobba <quic_pav@quicinc.com>

Change-Id: I231d982ff27725bd20efc0080c6871f079e1be2a
2022-05-17 14:19:00 +05:30
Jeevan Shriram
ce09152acc smcinvoke: Add MODULE_IMPORT_NS for smcinvoke driver
Add MODULE_IMPORT_NS for smcinvoke driver to ignore consider it as as
filesystem and not a driver.

Change-Id: I839b972f68f45f184f6a46de6779ac6adace9d38
2022-05-10 14:24:28 -07:00
Sonal Aggarwal
4f96dd41ec securemsm-kernel : Add new functionality in HLOS for TZ to sleep for certain
amount of time.

Change-Id: I6352bbe201ffcf81fde6ac7fc65e6f8eaeb0c64e
2022-05-06 23:28:07 +05:30
Nitin LNU
d1d7d597d6 smcinvoke: take lock again in free_mem_obj_locked
insted of premature unlock return with lock in free_mem_obj_locked
api.

Signed-off-by: Nitin LNU <quic_nlakra@quicinc.com>
2022-04-14 11:06:50 -07:00
Bruce Levy
5387ff0884 smcinvoke: Upgrade smcinvoke to latest
pull commits

smcinvoke: Release lock for non critical region

When entering into non critical region make sure to release the lock and
increase reference for memobj instead of holding the lock and causing
memobj not to be released when third party module using it.

smcinvoke: Add support for splitbin

Remove hard limit on the number of splitbins available.
Let the TZ decide if the reassembled binary is good for usage.
cherrypicked from I6d7b5c3154c8c362be0a6bad2da1c4687191536d

Change-Id: Ibb12bc906fb3e995928a0b51b742e8193d737ba3
2022-04-11 12:35:03 -07:00
Ashish Pratap Singh Bhadoria
5f29ef701b securemsm-kernel: Correction in LF Copyright 2022-03-09 12:35:31 +05:30
Sonal Aggarwal
c1f17b2adc securemsm-kernel : Add new functionality in HLOS for TZ to sleep for certain
amount of time.
2022-02-21 15:45:54 +05:30
Smita Ghosh
e190b86556 secuemsm-kernel : Enable DLKM's from vendor
SSG's kernel modules will be loaded through userspace
init instead of kernel.

Change-Id: Ibf88a6a56df65a933d451d39136060967595e5b7
2021-12-14 12:52:18 -08:00