Commit Graph

97 Commits

Author SHA1 Message Date
Tanwee Kausar c9f4b0f0ca crypto: Fix possible stack out of bound error
Adding fix to check the upper limit on the length
of the destination array while copying elements from
source address to avoid stack out of bound error.

Change-Id: Ieb24e8f9b4a2b53fbc9442b25d790b12f737d471
Signed-off-by: Tanwee Kausar <tkausar@codeaurora.org>
2020-11-15 20:27:32 +01:00
mohamed sunfeer 67f133de2a crypto: Change format specifier %p to %pK
Format specifier %p can leak kernel addresses while not valuing the
kptr_restrict system settings. When kptr_restrict is set to (1), kernel
pointers printed using the %pK format specifier will be replaced with 0's.

Change-Id: Iff8d82b12e958b938fc767bf3e8c3a3c8fc65c2a
Signed-off-by: mohamed sunfeer <msunfeer@codeaurora.org>
2017-11-13 19:03:17 -08:00
Brahmaji K e60411d53f crypto: msm: Fix several race condition issues in crypto drivers
Check areq before referencing, replace xchg to automic_xchg and
verify return values of set key during SHA operations.

Change-Id: Ife01372ba4990bfefe52b82db4ab33ef76190944
Signed-off-by: Brahmaji K <bkomma@codeaurora.org>
2017-09-04 16:18:20 +05:30
Zhen Kong 50cd2bf13b msm: crypto: set CLR_CNTXT bit for crypto operations
HLOS Crypto driver needs to set CLR_CNTXT bit for operations with
legacy software key registers

Change-Id: Iff482f726d106e99a4006f7077a171da3c7ca9c3
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2017-01-02 23:46:06 -08:00
Neeraj Soni 3feacd596d qcrypto: protect potential integer overflow.
Adding user passed parameters without check might
lead to Integer overflow and unpredictable system
behaviour.

Change-Id: Iaf8259e3c4a157e1790f1447b1b62a646988b7c4
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
Signed-off-by: Yang Guang <guyang@codeaurora.org>
2016-12-16 01:45:00 -08:00
Manish Kumar a758500713 Merge commit '831758491e32b1ecf11eaa6ad95abd3b6194e0a9' into private_redfox64_mbr.
Conflicts:
	drivers/platform/msm/ipa/ipa.c
	drivers/platform/msm/ipa/ipa_i.h
	sound/soc/codecs/msm8x16-wcd.c
	sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
	sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.h

Change-Id: Ifd9c90daff861461bf20c3d27ef061eeee2a5daf
Signed-off-by: Manish Kumar <manishku@codeaurora.org>
2015-09-22 17:42:38 +05:30
AnilKumar Chimata c1b874787d crypto: qce50: Update clock management
Update clock management details for all the crypto clocks to
fix the suspend resume issue.

Change-Id: I042b021e6737c71f6791dd4aa4f5c4f955b3ad84
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2015-09-18 17:16:24 +05:30
AnilKumar Chimata 95b8a763ac crypto: msm: qce50: Fix null pointer dereference
Fix null pointer dereferences in crypto core driver by
adding the proper changes to sg buffer pointers.

Change-Id: I07e1c2ce3115a7c1f97ad131b1afe58189070abe
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2015-09-01 16:58:37 +05:30
AnilKumar Chimata 1c677010dd crypto: msm: qce50 driver LAPE support for BAM descriptor setup
Add LAPE Support in qce50 driver for 36 bits physical address in BAM
descriptor.

Change-Id: I5500ff5cb3cce717da66075be984b1dfa846f796
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2015-08-18 19:41:14 +05:30
AnilKumar Chimata 05a68a40e9 crypto: msm: qce50 driver enhancement
For crypto device that supports NWD, do single transfer for BAM
consumer and producer pipe for each ciphering request.

Change-Id: I115ea2ea31b6cc6f0efc6c114413e71785c4cf33
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2015-05-12 10:40:48 -07:00
Zhen Kong 59881fb5ba crypto: msm: Add new parameter to pass BAM EE value
BAM apps EE value varies from target to target. So platform
specific data needs to provide the value.

Change-Id: Ia66d622ac770a48acd95578adcd4f1564a17232f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2015-05-06 02:29:38 -07:00
Zhen Kong e2cba54072 crypto: msm: Change CRYPTO_CONFIG_RESET value
When the pipe software reset in NDP-BAM is set, the Crypto core
compares its current PIPE_SET_SELECT setting in the CRYPTO_CONFIG
register against the pipe number that is being reset. If the pipe
being reset is part of the currently selected pipe set, the Crypto
core resets as well. This can corrupt an ongoing high speed mode
operation on a different pipe set and cause a core hang. As no design
can have 16 pipe sets, we set PIPE_SET_SELECT value to 0xF, so no
conflict would happen. Besides, HIGH_SPD_DATA_EN_N is set to off to
enable high speed data transfer always. In this case, we change
CRYPTO_CONFIG_RESET value to 0xE01EF.

Change-Id: I9fd158a59b305e46909dbe0fdfd61e835662ca7d
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2015-04-13 10:06:14 -07:00
Matt Wagantall 73b59190b8 crypto: clean up sps_iovec.addr debug sps_event_notify prints
The sps_event_notify event debug prints are a somewhat misleading,
as the address printed is not actually the full physical address,
but rather the bottom 32-bits of the physical address.  The upper
bits are encoded within sps_iovec.flags, and can be extracted via
the DESC_FULL_ADDR() macro.  Use this to print the full address,
and also consolidate duplicated debug prints within a new
print_notify_debug() function.

Change-Id: I34328ff16835ac8f83738f11cade7d792b9807d0
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
2015-03-16 20:19:27 -07:00
Zhen Kong cdb95811f0 crypto: msm: Add mutex in qce_open and qce_close
Add mutex in qce_open and qce_close to prevent the situation where
iounmap was called by one thread while another one is accessing the
HW CE register with another ioremap.

Change-Id: Iba47834a950a213d8c2b982b3a988020a2ef3338
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-12-02 17:08:13 -08:00
Mona Hossain d00d19b139 crypto: msm: Fix clk initialization
Return clk_get error for core_src_clk
Remove enabling other clks for targets that need only core_src_clk

Change-Id: I4749b9f9fff1d6057dbc46aa1bd4c7e50a801ed8
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2014-11-25 14:35:56 -08:00
Mallikarjuna Reddy Amireddy daae47365c crypto: msm: Add new parameter to pass ce frequency
Crypto operating frequency varies from target to target. So platform
specific data needs to provide the value.

Change-Id: Icea908e958453444ba5a8e882664c8ca43e305e4
Signed-off-by: Mallikarjuna Reddy Amireddy <mamire@codeaurora.org>
2014-10-08 10:38:49 +05:30
AnilKumar Chimata 61bae48b4a crypto: msm: Fix clock disable warnings
One of the crypto clocks is not enabled during device open
path but disabled in the return/closed path results in clk
warnings. This patch fixes the issue with clock flags.

Change-Id: Ic602e93e38fc0242696c4b2d43c892daf7fd123b
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-09-26 20:22:08 +05:30
AnilKumar Chimata ce9093354d crypto: msm: Fix crypto core clock issue
Crypto core clock enablement is removed from the code to add the support
on msm8994 target as per the clock management, which results in crypto
driver init failure. This patch enables the crypto core clk based on the
flag passed by device tree data.

Change-Id: Ia32bfbc49de8adc5e54e835927c5bd53d7e2a208
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-09-23 21:02:34 +05:30
AnilKumar Chimata 103dc788c5 crypto: msm: Check the return value of cmdlistinfo
The functions _ce_get_cipher_cmdlistinfo() and _ce_get_hash_cmdlistinfo()
may return NULL and dereferencing it. This patch fixes the issue with the
proper checks in the driver.

Change-Id: I491d66b0c69347e2cc484160c20655bdd113d67b
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-09-05 16:23:50 -07:00
William Clark 249c33273d crypto: msm: Add multi-core crypto support
Add support for multiple crypto instances, new apis are added
to provide information on the crypto instances available.
Crypto uses RPM to enable clocks, this has the fix to rename
the clocks to use the npa node.

Change-Id: Ia568b9ee82235aa686713b039725d27492f4a8e7
Signed-off-by: William Clark <wclark@codeaurora.org>
2014-08-19 13:48:36 -07:00
AnilKumar Chimata 8c65c916b6 crypto: msm: Fix SHA-1/256 zero length input data issue
Crypto module generating wrong hash value for zero length input data
using SHA1 and SHA256 functions. This patch fixes the issue to generate
proper hash value.

Change-Id: I795969cf2d3e3887064d56e35cbb488937051ac8
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-06-27 18:54:24 +05:30
AnilKumar Chimata 76a0b19319 crypto: msm: Add 64bit support to crypto drivers
Add 64bit support to crypto drivers.

Change-Id: I519ae5a79bf5df0ebbb5fbe810d8edcda87a2836
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-06-19 17:33:56 +05:30
AnilKumar Chimata 02a4f15149 crypto: msm: Move qcrypto.h header file
Move header file from architecture folder to include/linux
folder.

Change-Id: I20a653b272ec21419706cb02bc7c1beac20802eb
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-06-06 04:04:23 +05:30
AnilKumar Chimata fe7fb50508 crypto: msm: Fix Crypto BAM issue for 64bit
Fixes the crypto BAM issue while running the qcedev_test from usersapce.
BAM command descriptors opcode wrongly going to Crypto BAM hardware. This
patch corrects the issue by seting the opcode to zero.

Also fixes CMAC IOCTL definition with proper struct type.

Change-Id: Ie4195ccd128a8faa98f16ad5ca45ac9bcaef17b9
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-06-06 04:04:23 +05:30
Zhen Kong 51b091e9be crypto: msm: fix aes counter issue
Counter Mask registers are not initialized for 128 bits of counter.
As the result, some test vector of aes(ctr) may fail.

Change-Id: Iccf83aff737d253fa8f8110684e40491bcee7035
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-05-28 12:27:48 -07:00
Zhen Kong 4b17c6922b crypto: msm: Add aead hmac-sha256 support
Add support for authenc(hmac(sha256), cbc(des)) and authenc(hmac(sha256),
cbc(aes)) and authenc(hmac(sha256), cbc(des3_ede))

Remove dead code of #ifdef CRYPTO_AEAD_AES_CTR #endif
block in qcrypto and AEAD aes/des/3des ECB mode in qce50. They will
never happen for aead operations.

Stats are cleaned up. Three groups of stats for ABLK, AEAD, and AHASH
operations are managed, and displayed in each group.

Change-Id: I0797c6b3b6596e831b1fb61aa8d4342f19c2b095
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-04-29 14:12:53 -07:00
Zhen Kong 5b6885dc58 crypto: msm: re-work qcrypto driver clk and bus management
This patch re-works bus scaling and clk management to respond to
the actual crypto engine usage. The driver suspend/resume are
integrated with overall driver clk and bus management.

Furthermore, two functions are added to the low level crypto driver. Low
level crypto driver is informed to save and restored hardware context if
necessary across PM suspend/resume.

Change-Id: Ic906e0c7e96dee847253d6ef57341d1a38e294cf
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-04-22 13:41:47 -07:00
Hariprasad Dhalinarasimha 7c0c638ccf crypto:msm: Remove excess logging in qce50
During device probe, device tree is called & the
device tree details are logged - these logs
are now truncated.

Change-Id: I0a6f45cbd4717ded1ef515e3e76452397826d240
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2014-04-04 15:41:36 -07:00
Mona Hossain fe78c0cd72 crypto: msm: Add support for multiple qcrypto device
Expose APIs to enable qcrypto client to select any specific qcrypto
instance.

Change-Id: Ia96f7fa0f15216c0656aa6dc495db350b3c574a8
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2014-03-12 10:19:01 -07:00
Dipen Parmar 7f918cb5c7 msm: sps: remove sps header file
Remove the sps header file from older location as sps
driver and clients need to use new header file from
new location include/linux.

Resolve the warnings/errors from client drivers due to
new sps header changes.

Change-Id: I1cdb87756abf3425a9bb5d8bf89cd1aa03a01716
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
2014-02-05 15:31:11 -08:00
Xiaocheng Li 5f441c883e msm: socinfo: Support multiplatform
Upstream prefers existing drivers be converted to support multiplatform
kernels.  This requires drivers to be located in directories that
contain generic functionality instead of specific mach directories.
Move the socinfo driver into drivers/soc/qcom and update the initcall
levels to satisfy dependencies.

Change-Id: If195cd793d84867d371f25136a88f2a7ce239500
Signed-off-by: Xiaocheng Li <lix@codeaurora.org>
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
2014-01-30 19:08:34 -08:00
Zhen Kong 00fa0d8c21 crypto: msm: Add basic suspend resume functionality
If ce clock is not disabled in suspend state, memory may be corrupted
and device can not wake up. We add an optional flag "clk_mgmt_sus_res"
for qcrypto driver. This flag indicates if the ce clocks need to be
disabled in suspend function and enabled in resume function of qcrypto
driver. When the flag is set, we disable the clocks that are not disabled
in suspend function and re-enable them again in resume function.

Change-Id: I23be38b2765c0cc5f3ed41d65f8e4ae8a9372d18
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-01-27 19:59:06 -08:00
Zhen Kong fe560bd4dd crypto: msm: Rename and register crypto algorithms
Add optional crypto algorithm flags to indicates if to use SW crypto
algorithms instead of HW algorithms. Based on it, we then rename and
register crypto algorithms to be qualcomm specific to prevent clashing
with the default SW implementation of the algorithms used by dm_crypt
module. (used for disk encryption).

Change-Id: I39badf22581791c502a247f8f37123f513b8c77e
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-01-23 23:41:00 -08:00
Linux Build Service Account 35f90d26b1 Merge "crypto: msm: Add debug log" 2014-01-23 03:21:48 -08:00
Linux Build Service Account 787a183b61 Merge "crypto: msm: Fix key length setting" 2014-01-17 16:42:21 -08:00
Zhen Kong e849a34af4 crypto: msm: Fix a bug when writing xts du size
The break is missing in the switch-case branch of writing xts du size,
this leads to incorrect xts du size setting.

Change-Id: I288c3d30cc3d59eb28672be32aa57819971ca97f
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-01-16 10:43:25 -08:00
Zhen Kong 83c570e1b6 crypto: msm: Fix key length setting
Hardcoding key length to a constant value results in overwriting
command element information in the command descriptor beyond what
is allocate for the key information in the command element list.
This results in corruption of the command list in the case where
command descriptors are used for configuring crypto registers and
needlessly writing to key registers that are not relevant to the
operation (when writing to registers directly), and thus leads to
crypto operation failures. Fix is to use the key length based on
what is requested by the client.

Change-Id: Ibd625dc7a438fac84b13588700bf472004e246d5
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-01-15 18:18:48 -08:00
Mona Hossain e2bd6519fc crypto: msm: Add debug log
Add MACRO for writel_relaxed that output register
settings.

Change-Id: Iffb76acbe2c0c389a6c79ac4b72a1aaa2a9af531
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2014-01-15 17:40:53 -08:00
Linux Build Service Account 8609c30843 Merge "Revert "crypto: Fix memory leak in bam_release call"" 2013-12-30 15:12:09 -08:00
Zhen Kong ea5ec1f1ab Revert "crypto: Fix memory leak in bam_release call"
This reverts commit 8d175c9d77, which
release pbam memory when an error occurs. However, on a device with
multiple ce, pbam memory is shared by multiple pce_dev, it can only
be freed when the reference count goes to zero, and can not be
released it if reference count is not zero when an error occurs.
The previous implementation on bam_release was correct, so we
revert commit 8d175c9d77.

Change-Id: Ibc3b83dd46ea087c7a0084d032d96a2848f6baf5
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-12-30 11:11:47 -08:00
Vikram Mulukutla 6918831f31 msm: clk-provider: Move clock headers to include/linux/clk
Architecutural changes in the ARM Linux kernel tree mandate the
eventual removal of the mach-* directories. Move the
mach/clk-provider and mach/clk header to include/linux/clk.

Change-Id: I495f8332bf5d0d09ccfb236c819dea2bacb13542
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2013-12-12 11:29:09 -08:00
Linux Build Service Account 437170c368 Merge "crypto: Fix memory leak in bam_release call" 2013-11-11 22:16:11 -08:00
Zhen Kong 07642fbca1 crypto: msm: Add support for LPAE in crypto drivers for APQ8084
change physical address type to support LPAE for crypro drivers on
APQ8084

Change-Id: I2a85c5db9d131c3be469a5f6b322bc3c4a317400
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-10-29 16:25:20 -07:00
Mona Hossain 8d175c9d77 crypto: Fix memory leak in bam_release call
Release pmab memory when an error occurs as well.

Change-Id: I7aa13d5a03edbdfa806345039459feaeac6e7a11
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-10-25 14:31:39 -07:00
Rohit Vaswani dc1af015b7 crypto: msm: fix hmac hashing issues with various key size
hmac-sha1 and hamc-sha256 have variable mac key up to a block size.
If user provides a key that is less than the block size, the
key should be padded with zero to the block size before it is
given to the hw.

This padding was not done properly in the driver.
When switch engine between ahash hmac(sha1), hmac(sha256),
and ipsec, problem may happen. ipsec takes 20 bytes of key.
The generated digested data is wrong, even though everything looks
fine from driver. ipsec may fail.

Furthermore, this patch cleanup the driver to do proper setup of
hardware to use hw key or pipe key.

Change-Id: I128eca5a1ac4df326ea1ca9aef2bf27323c1c82f
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-10-22 14:15:05 -07:00
Rohit Vaswani 77857e43bc crypto: msm: qce50 ota crypto support
Kasumi/snow-3g f8/f9 are defined by 3gpp, as the algorithms for
UMTS, and LTE for over the air ciphering and integrity. The
algorithms are supported by crypto 5 hardware. This patch
enables qce50 driver to provide Kasumi/snow-3g f8/f9
ciphering and integrity services.

Change-Id: I7b157e7f178cbe869dcb686a417ac8a5cd4a648a
Acked-by: hemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-10-07 11:37:30 -07:00
Mona Hossain 1152424d0e crypto: msm: Add support for setting XTS data unit size
Based on the context flags set by client, set XTS_DU_SIZE
register to sector size of 1KB, or the actual total length
of the packet.

Change-Id: Id461a27013f99301c3ca9e714f397f33c3f6ba03
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 17:28:15 -07:00
Mona Hossain ac940280b2 crypto: msm: Handle error case
Release memory and disable clk when sps_init fails.

Change-Id: I3bfb11e7b7d7584e7d64afbbd3475d809fa720ad
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 17:21:03 -07:00
Rohit Vaswani 6c443b0101 crypto: msm: multiple qce50 support
In some platforms such as fsm9900, multiple instances of qce50 hw
may be supported.  Each qce50 HW has an ndp-bam. Each qce50 HW
can support multiple instances of qce_dev platform device.
Each qce_dev has its own configured pipe set and associated qce50 HW,
defined by crypto-base and bam-pipe-pair fields in the device tree files.
This patch based on io address, it decides to create a new qce50 hw
instance or use the existing known instance at device probe time.

Furthermore, this patch does iomap for only once for each HW BAM instance
to avoid issue with bam driver. If modprobe, and rmmod of qcedev,
and qcrypto are not in first in last out order, kernel may crash in
bam driver in the last rmmod.
This saves virtual space for IO if multiple instances of qcedev
share the same instance of HW BAM.

Change-Id: I1565b1976981b0512832ff793e0adb29c4be3ccc
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-09-04 17:19:07 -07:00
Mona Hossain 80c42643a4 crypto: msm: Remove check for minor and step version
The only version that needs verifiation is major version to ensure
HW CE 5.0 is being used.  Minor and step versions checks are not
needed to gate driver loading.

Change-Id: I2052f511f3f2286da78a9c8d4ccf9803fbd6f204
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 17:12:15 -07:00