Commit graph

21 commits

Author SHA1 Message Date
Isaac J. Manjarres
94b0437277 soc: qcom: secure_buffer: Process large SG tables in batches
Currently, if processing an SG table consumes more memory
than can fit in the pre-allocated buffer, then calls to
hyp_assign_table() will fail as if there were not enough
memory available to process the request.

Instead, for every call to hyp assign, allocate enough
memory to process the maximum batch size, and process large
SG tables in pieces, using this memory. This avoids failures
due to large SG tables. Also, since the memory for handling
these requests is now allocated per hyp_assign_table() call,
we can drop the pre-allocated buffer, as it is no longer in
use.

Change-Id: Ie9899a5e2c8de6127707609101f5fb557e3f0533
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2019-05-02 23:04:15 -07:00
Zhenhua Huang
371698455c soc: qcom: secure_buffer: Fix the parameter passing to dmac_flush_range
For "chunk_list + chunk_list_len", if the chunk_list is type of u32*,
the chunk_list_len will be 4 * of original size. So we flushed a wrong
area size. In some condition like we enabled CONFIG_DEBUG_PAGEALLOC, it
may flush out of page bound of the invalid pte page.

Fix it by manually convert it as void* when doing the addition.

CRs-Fixed: 2309993
Change-Id: I2b88d78ba73d9904fa2bf6106937001715b6037f
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>
2018-09-13 19:43:51 -07:00
Sudarshan Rajagopalan
b07c54bfd1 msm: secure_buffer: Add SPSS_SP_SHARED vmid
Add support for SPSS_SP_SHARED vmid. This vmid is equivalent
to TZ VM, which can be used for sharing memory with TZ with
the assign call.

Change-Id: I10b98820796e8bab7b8275f5ddf44e8814dc0fb0
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
2018-02-16 01:35:43 -08:00
Mohammed Khajapasha
18ae33111d qcom: scm: update function return value and input parameter type
Update the function return value and input scm_ret variable
type for restore secure configuration in scm_restore_sec_cfg() fn.
Adding scm_ret input variable for scm_get_feat_version() fn.  

Change-Id: Ideef914ded8dfdb4c780fd27d7273986eeb41f5c
Signed-off-by: Mohammed Khajapasha <mkhaja@codeaurora.org>
2017-07-19 14:22:44 +05:30
Sarada Prasanna Garnayak
3e0f2da3ea soc: qcom: secure_buffer: add export symbol hyp_assign_phys
Fix the symbol linking error for loadable kernel modules
which is using secure buffer hypervisor api for smmu configuration.

CRs-Fixed: 2019262
Change-Id: I3d83fd4b1854298c1283e03f220de8c673195492
Signed-off-by: Sarada Prasanna Garnayak <sgarna@codeaurora.org>
2017-03-17 09:34:51 -07:00
Patrick Daly
95042a43bf soc: qcom: secure_buffer: Fix memory leak
Free the sg_table properly.

Change-Id: Idae945d17803e10756bf3a20426e57837d185067
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-12-20 15:32:52 -08:00
Linux Build Service Account
61f26e3aa5 Merge "soc: qcom: secure_buffer: Fix an uninitialized variable" 2016-11-15 23:39:31 -08:00
Patrick Daly
2d083baf33 soc: qcom: secure_buffer: Fix an uninitialized variable
Ensure variables are set before the are used to prevent random behavior.

Change-Id: Ib31e5aca648c0f442afe4cbe576ad79786fe6427
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-11-14 15:00:09 -08:00
Shiraz Hashim
fcca61799a msm: secure_buffer: fix scm call argument layout
For hyp_assign calls, dest_vm_and_perm_info wrongly
defines ctx as u32 * type, while TZ expects it as u64.
This creates an inconsistency on 32bit system. Fix it.

Change-Id: I31e8e0b5e9ae240ca031f625cf7c49f1bfe165d4
Signed-off-by: Shiraz Hashim <shashim@codeaurora.org>
2016-11-01 16:43:02 +05:30
Liam Mark
c156aa8e2a msm: secure_buffer: Add VMID_CP_CAMERA_PREVIEW
Add support for VMID_CP_CAMERA_PREVIEW

Change-Id: Ifacc1ff95262c6240283d19cf02dcac37933c141
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2016-09-30 10:25:26 -07:00
Patrick Daly
641a99ef2f msm: secure_buffer: Limit continuous time spent in hypervisor
hyp_assign_table() is a costly operation during which nonsecure interrupts
are disabled. Split this operation into multiple parts for better
real-time behavior.

Splitting is done by the following criteria:
maximum number of physically contiguous memory regions
maximum total memory size.

Here is a chart showing the average performance of hyp_assign_table() with
N physically contiguous chunks each with size X.

 #chunks    chunk_size(pages) total_memory(pages)    time(ms)
       2                   1                   2       3.354
       2                   4                   8      12.979
       2                 512                1024       4.349
       8                   1                   8       4.714
       8                   4                  32      26.781
       8                 512                4096       8.724
      32                   1                  32      17.093
      32                   4                 128      50.700
      32                 512               16384      26.717
     128                   1                 128      71.076
     128                   4                 512     126.305

Based on the above, select a maximum of 32 chunks or 512 total pages
as the limits.

Change-Id: I530cfdce76c8a2c38f60d6118647eaefd269e693
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-08-17 12:47:21 -07:00
Patrick Daly
ff15045bed secure_buffer: Remove all-in-one buffer usage
Allocate objects via kzalloc() when possible. For the case where a large
chunk (512 Kb) of physically contiguous memory is required, continue to use
a special purpose buffer reserved at boot. Since this special purpose
buffer is no longer used for random metadata, the associated code is
simpler to understand.

Change-Id: I85078f351293b556a501e9aca075ef87e2e86afd
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2016-08-17 12:47:21 -07:00
Susheel Khiani
3b2e2a3ded msm: secure_buffer: Fix possible NULL pointer dereference
Presently we were passing NULL dma_handle while
making dma_alloc_coherent call. This is an issue
as alloc function would try to populate handle
value with dma address and would end up getting
NULL pointer error. Fix this.

Change-Id: I38ebb9bbae2d6e1e1311fe438b3c8fc3f65e5692
Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
2016-06-01 15:26:08 -07:00
Sameer Thalappil
5f181ee0dd msm: secure_buffer: Add WLAN support
Add support for WLAN Adrastea hardware.

Change-Id: I99868cf456c5b4641731dcea884b67627780477d
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
2016-03-25 16:03:03 -07:00
Rohit Vaswani
e74ab64475 drivers: qcom: secure_buffer: Optimize by re-using the same buffer
Re-use the same buffer for the hyp assign calls rather than allocating
a new one for every single call.

Change-Id: Ia76f9743c7eb83d3432ac19cc98be243434c2aa8
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2016-03-23 21:17:16 -07:00
Mitchel Humpherys
51adc0956b msm: secure_buffer: Ensure shared buffers are cache-aligned
Buffers shared with hypervisor might undergo some cache maintenance on
the hypervisor side.  Currently, we're passing a buffer that might not
be cache-aligned (source_vm_list), so when the hypervisor does some
cache maintenance on it they might be corrupting data.  Fix this by
ensuring that all buffers being shared with the hypervisor are
cache-aligned by kmalloc'ing and memcpy'ing the source_vm_list before
sending it across.

Change-Id: I661f8ca852ade159e3432904086b060be8bfb806
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:04:50 -07:00
Mitchel Humpherys
8a9d07bc98 msm: secure_buffer: Add helper function to convert VMIDs into strings
It can be useful to convert secure VMID values into strings.  Provide a
helper function to do so.

Change-Id: If907a0bac92c5d164154c0e5dfe67933115163c8
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
2016-03-22 11:04:49 -07:00
Neeti Desai
a04defd9b7 msm: secure_buffer: Update the hyp_assign_phys() api
The hyp_assign_phys() api can be called by different
usecases where it is not guaranteed that the source vm is
always VMID_HLOS.

Pass the responsibility of setting the source_vm to
caller of the function.

Change-Id: I3851a6681f49d4bb6fa5b7a889a16a158497e9e6
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
2016-03-22 11:04:48 -07:00
Neeti Desai
5cd0d2091e msm: Update the assign api to secure buffers
The assign call apis have been updated by TZ to
include more usecases. Update the secure_buffer
api files with the same. The system secure heap
needs to be updated to reflect the change in
the api calls.

Change-Id: Idc784ddac222e6ad9f5defafc422e6e3fb88aa0c
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
2016-03-22 11:04:32 -07:00
Neeti Desai
aa786020de msm: move types and declarations to header file
Move all function declarations and types to the header
file to make the macros and definitions available even
when the CONFIG_MSM_SECURE_BUFFER is not enabled. Rename
rid of the msm_ion_secure_table and msm_ion_unsecure_table
to something more generic.

Change-Id: Ia5ca0c52f971a67c7936c64b42cd2522aa1773fa
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
2016-03-22 11:04:32 -07:00
Neeti Desai
44c62ba199 msm: Move the secure_buffer.c file to a new location
The secure_buffer.c files does not have anything specific
to ion. The functions defined here might be needed by other
drivers as well. If the ion driver is disabled that might
not work. So move the file to a new location.

Change-Id: I3498de791c01019b7933feb65d196152887fcf24
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
2016-03-22 11:04:31 -07:00
Renamed from drivers/staging/android/ion/msm/secure_buffer.c (Browse further)