Commit Graph

815 Commits

Author SHA1 Message Date
Venkatesh Yadav Abbarapu ee1f52a90a crypto: msm: ota: check potential integer overflow on ioctl
Integer addition and multiplication of two 16 bits integer may overflow.
Add overflow checking and prevention in the driver. The stats counters
are changed from 32 bits to 64 bits as well.

Change-Id: Icf243d8e5f375d19ce850c2b21664b74ce58612f
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Venkatesh Yadav Abbarapu <quicvenkat@codeaurora.org>
2014-05-28 18:11:52 +05:30
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
Zhen Kong 81512a464d crypto: msm: add dynamic engine assignment support
This patch provides dynamic engine assignment for better performance.

A platform may configure to support multiple crypto engines.
Crypto engine assignment to a tranformer(tfm) can be dynamic. Engine
assignment is deferred until a request of a tfm is served. In contrary,
for static assignment, a crypto engine is statically assigned to a
transformer.

This patch supports both schemes.  A transformer can issue multiple
asynchronous requests in parallel. In case of static assignment, requests
of the same tfm are served in sequence by the same engine. In case of
dynamic assignment, requests can be issued in parallel to different
hardware engines.

There is a requirement as such, "for any tfm, ablkcipher, aead, or ahash,
they must return results in the order they were given."
In case of dynamic assignment, the order of completion from different
hardware engines may not be in the same order as requests issued.
Driver needs to re-sequence the order of response for a tfm to meet
the requirement.

Change-Id: I26495c1df0e44a5276989c33a19fddb5b107cb13
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-03 12:07:13 -07:00
Linux Build Service Account b198cb9af1 Merge "Merge upstream linux-stable v3.10.28 into msm-3.10" 2014-03-26 23:36:07 -07:00
Ian Maund f1b32d4e47 Merge upstream linux-stable v3.10.28 into msm-3.10
The following commits have been reverted from this merge, as they are
known to introduce new bugs and are currently incompatible with our
audio implementation. Investigation of these commits is ongoing, and
they are expected to be brought in at a later time:

86e6de7 ALSA: compress: fix drain calls blocking other compress functions (v6)
16442d4 ALSA: compress: fix drain calls blocking other compress functions

This merge commit also includes a change in block, necessary for
compilation. Upstream has modified elevator_init_fn to prevent race
conditions, requring updates to row_init_queue and test_init_queue.

* commit 'v3.10.28': (1964 commits)
  Linux 3.10.28
  ARM: 7938/1: OMAP4/highbank: Flush L2 cache before disabling
  drm/i915: Don't grab crtc mutexes in intel_modeset_gem_init()
  serial: amba-pl011: use port lock to guard control register access
  mm: Make {,set}page_address() static inline if WANT_PAGE_VIRTUAL
  md/raid5: Fix possible confusion when multiple write errors occur.
  md/raid10: fix two bugs in handling of known-bad-blocks.
  md/raid10: fix bug when raid10 recovery fails to recover a block.
  md: fix problem when adding device to read-only array with bitmap.
  drm/i915: fix DDI PLLs HW state readout code
  nilfs2: fix segctor bug that causes file system corruption
  thp: fix copy_page_rep GPF by testing is_huge_zero_pmd once only
  ftrace/x86: Load ftrace_ops in parameter not the variable holding it
  SELinux: Fix possible NULL pointer dereference in selinux_inode_permission()
  writeback: Fix data corruption on NFS
  hwmon: (coretemp) Fix truncated name of alarm attributes
  vfs: In d_path don't call d_dname on a mount point
  staging: comedi: adl_pci9111: fix incorrect irq passed to request_irq()
  staging: comedi: addi_apci_1032: fix subdevice type/flags bug
  mm/memory-failure.c: recheck PageHuge() after hugetlb page migrate successfully
  GFS2: Increase i_writecount during gfs2_setattr_chown
  perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h
  perf scripting perl: Fix build error on Fedora 12
  ARM: 7815/1: kexec: offline non panic CPUs on Kdump panic
  Linux 3.10.27
  sched: Guarantee new group-entities always have weight
  sched: Fix hrtimer_cancel()/rq->lock deadlock
  sched: Fix cfs_bandwidth misuse of hrtimer_expires_remaining
  sched: Fix race on toggling cfs_bandwidth_used
  x86, fpu, amd: Clear exceptions in AMD FXSAVE workaround
  netfilter: nf_nat: fix access to uninitialized buffer in IRC NAT helper
  SCSI: sd: Reduce buffer size for vpd request
  intel_pstate: Add X86_FEATURE_APERFMPERF to cpu match parameters.
  mac80211: move "bufferable MMPDU" check to fix AP mode scan
  ACPI / Battery: Add a _BIX quirk for NEC LZ750/LS
  ACPI / TPM: fix memory leak when walking ACPI namespace
  mfd: rtsx_pcr: Disable interrupts before cancelling delayed works
  clk: exynos5250: fix sysmmu_mfc{l,r} gate clocks
  clk: samsung: exynos5250: Add CLK_IGNORE_UNUSED flag for the sysreg clock
  clk: samsung: exynos4: Correct SRC_MFC register
  clk: clk-divider: fix divisor > 255 bug
  ahci: add PCI ID for Marvell 88SE9170 SATA controller
  parisc: Ensure full cache coherency for kmap/kunmap
  drm/nouveau/bios: make jump conditional
  ARM: shmobile: mackerel: Fix coherent DMA mask
  ARM: shmobile: armadillo: Fix coherent DMA mask
  ARM: shmobile: kzm9g: Fix coherent DMA mask
  ARM: dts: exynos5250: Fix MDMA0 clock number
  ARM: fix "bad mode in ... handler" message for undefined instructions
  ARM: fix footbridge clockevent device
  net: Loosen constraints for recalculating checksum in skb_segment()
  bridge: use spin_lock_bh() in br_multicast_set_hash_max
  netpoll: Fix missing TXQ unlock and and OOPS.
  net: llc: fix use after free in llc_ui_recvmsg
  virtio-net: fix refill races during restore
  virtio_net: don't leak memory or block when too many frags
  virtio-net: make all RX paths handle errors consistently
  virtio_net: fix error handling for mergeable buffers
  vlan: Fix header ops passthru when doing TX VLAN offload.
  net: rose: restore old recvmsg behavior
  rds: prevent dereference of a NULL device
  ipv6: always set the new created dst's from in ip6_rt_copy
  net: fec: fix potential use after free
  hamradio/yam: fix info leak in ioctl
  drivers/net/hamradio: Integer overflow in hdlcdrv_ioctl()
  net: inet_diag: zero out uninitialized idiag_{src,dst} fields
  ip_gre: fix msg_name parsing for recvfrom/recvmsg
  net: unix: allow bind to fail on mutex lock
  ipv6: fix illegal mac_header comparison on 32bit
  netvsc: don't flush peers notifying work during setting mtu
  tg3: Initialize REG_BASE_ADDR at PCI config offset 120 to 0
  net: unix: allow set_peek_off to fail
  net: drop_monitor: fix the value of maxattr
  ipv6: don't count addrconf generated routes against gc limit
  packet: fix send path when running with proto == 0
  virtio: delete napi structures from netdev before releasing memory
  macvtap: signal truncated packets
  tun: update file current position
  macvtap: update file current position
  macvtap: Do not double-count received packets
  rds: prevent BUG_ON triggered on congestion update to loopback
  net: do not pretend FRAGLIST support
  IPv6: Fixed support for blackhole and prohibit routes
  HID: Revert "Revert "HID: Fix logitech-dj: missing Unifying device issue""
  gpio-rcar: R-Car GPIO IRQ share interrupt
  clocksource: em_sti: Set cpu_possible_mask to fix SMP broadcast
  irqchip: renesas-irqc: Fix irqc_probe error handling
  Linux 3.10.26
  sh: add EXPORT_SYMBOL(min_low_pfn) and EXPORT_SYMBOL(max_low_pfn) to sh_ksyms_32.c
  ext4: fix bigalloc regression
  arm64: Use Normal NonCacheable memory for writecombine
  arm64: Do not flush the D-cache for anonymous pages
  arm64: Avoid cache flushing in flush_dcache_page()
  ARM: KVM: arch_timers: zero CNTVOFF upon return to host
  ARM: hyp: initialize CNTVOFF to zero
  clocksource: arch_timer: use virtual counters
  arm64: Remove unused cpu_name ascii in arch/arm64/mm/proc.S
  arm64: dts: Reserve the memory used for secondary CPU release address
  arm64: check for number of arguments in syscall_get/set_arguments()
  arm64: fix possible invalid FPSIMD initialization state
  ...

Change-Id: Ia0e5d71b536ab49ec3a1179d59238c05bdd03106
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2014-03-24 14:28:34 -07:00
Zhen Kong 3bbed21e10 crypto: msm: fix Off-by-one error in computation of length for strlcpy()
size + strlen("qcom-") is equal to the length of string not including the
null character. However, we are comparing it to the length of the buffer,
so we need to include the null character, and make a change to make sure
(size + strlen("qcom-")) is smaller than CRYPTO_MAX_ALG_NAME.

Change-Id: I882e2c3e761a4bd4344ce8820b26cf890f29bab3
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2014-03-20 13:43:36 -07:00
Linux Build Service Account 24e388b9fb Merge "crypto: msm: Add support for multiple qcrypto device" 2014-03-12 23:21:37 -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
Dan Sneddon b0da38f02c msm: msm_bus: Move bus scaling to platform drivers
Moves bus scaling code to architecture independant directory
for platform drivers.

Change-Id: Ie0d5b104882d1534fae262af85e99cc09a56ab04
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2014-03-11 18:00:53 -06:00
Niranjana Vishwanathapura 3c58438ef9 crypto: msm: fix memory leak during algorithm registration
During driver algorithm registration, if there are errors, the
dynamically allocated memory needs to be free on the error return.
Otherwise, there will be memory leak. This patch fixes memory leak
accordingly.

Change-Id: Ic3c65ebd3d6c7b0e88815e6750ec14990e375587
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Niranjana Vishwanathapura <nvishwan@codeaurora.org>
2014-02-26 13:42:16 -07:00
Niranjana Vishwanathapura 6753e2aa25 crypto: msm: enable rfc4309(ccm(aes)) algorithm
This patch enables rfc4309(ccm(aes)) algorithm. Further more, it fixes
an issues with ccm.  According to RFC3610, associate
data is optional. The assocaite data length can be 0 as shown in
testmgr ccm rfc4309 test vectors. The driver did not take this zero
length of  associate data situation into account. And the corresponding
test vectors in testmgr may fail.

Change-Id: I2f269a54ad269a8ba72c0e570a7859da223e2d9b
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Niranjana Vishwanathapura <nvishwan@codeaurora.org>
2014-02-26 13:42:02 -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
AnilKumar Chimata 53b076eef9 crypto: Kconfig: msm8916: Add Hardware crypto module
Add hardware crypto module for msm8916 target.

Change-Id: Ieca9c6aaa43ac662dbaa50dbbd45d6e5921afc02
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2014-02-05 09:33:57 -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
Vikram Mulukutla 1e635c644a msm: scm: Move the scm driver to drivers/soc/qcom
Architectural changes in the ARM Linux kernel tree mandate
the eventual removal of the mach-* directories. Move the
scm driver to drivers/soc/qcom and the scm header to
include/soc/qcom to support that removal.

Change-Id: Ie660d0566de35045c1ba73fcddeda99efacf057e
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
2014-01-24 11:49:11 -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
Linux Build Service Account aa2078492f Merge "crypto: msm: add pm wakeup support for qcrypto driver" 2013-12-23 15:42:26 -08:00
Zhen Kong 1ca995cee4 crypto: msm: add pm wakeup support for qcrypto driver
Add support for holding system from suspending while an operation
is in progress (when clks are enabled).  This is done by invoking
pm_stay_awake before enabling clks (when a crypto operation is
initiated) and invoking pm_relax when crypto operation is done.

Change-Id: I5c7ceb025f6cac1b7c985fc1c308e82f851fca72
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-12-23 12:35:23 -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
Kumar Gala c37b3a4042 msm: remove code, dts, and references to MSM9625
We no longer support MSM9625 so remove various files and code associated
with it.  This is not a complete removal of MSM9625, but just removing
dts files, any file with 9625 in name, and any code that was associated
with CONFIG_ARCH_MSM9625.

Change-Id: I3d5405bb71a529806797adc81dd628996000acdc
Signed-off-by: Kumar Gala <galak@codeaurora.org>
2013-12-09 16:31:05 -06:00
Ian Maund f06163e6d0 msm: reap unused kernel files
This change removes source files from the kernel tree that
were not being used during make. The list of used files
was generated using an annotated make log and was then
compared with new files added since the public release of
kernel version 3.10.00. New files which were added but
not used have been removed from the tree.

A diff was also run to determine the list of files that had
been modified since the release of kernel version 3.10.00.
These files were then scrubbed based on the current kernel
configuration, removing invalid and unused conditionals.

Some files which support planned functionality or are
useful in debugging have been excluded from this reap.

Change-Id: Ia44a224d3cea7bc78dd45e8a8279860d35d4b008
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2013-11-21 17:45:28 -08:00
Linux Build Service Account 77949f94d6 Merge "crypto: msm: ota: multiple variable size packet support" 2013-11-15 01:10:35 -08:00
Linux Build Service Account 437170c368 Merge "crypto: Fix memory leak in bam_release call" 2013-11-11 22:16:11 -08:00
Rohit Vaswani 2c7dc49733 crypto: msm: ota: multiple variable size packet support
This patch provides support of multiple variable size packet
API to the ota_crypto driver.

Furthermore, this patch replaces snprintf with scnprintf
to make pointer manipulation save when display stats.

Change-Id: I56aebd24557dccc547ff86cb8853ace0602b6e50
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-11-05 13:24:29 -08:00
Zhen Kong 4ddee896f7 crypto: Kconfig: select QCE50 for ARCH_APQ8084
select qce50 for APQ8084 architecture and then bring up crypto driver
on APO8084

Change-Id: I4235dbf88003203353c7d8b18093136bef1b62d1
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-10-29 16:25:33 -07: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
Linux Build Service Account 6ff9d7e0ab Merge "crypto: msm: Use scnprintf() instead of snprintf()" 2013-10-26 08:27:34 -07:00
Linux Build Service Account fd3a275e6d Merge " crypto: msm: fix hmac ahashing issues with simultaneous multiple requests." 2013-10-26 03:29:57 -07:00
Linux Build Service Account 9148e7eaa2 Merge "crypto: msm: fix hmac hashing issues with various key size" 2013-10-26 03:29:56 -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
AnilKumar Chimata f10d718047 crypto: msm: Use scnprintf() instead of snprintf()
snprintf can return more than the size of buffer, which is not
expected here, obviously. Use scnprintf instead.

Change-Id: I3b97a016df910728dfef5a0914ab8ad67c68e39c
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2013-10-25 12:54:58 -07:00
Linux Build Service Account ff585cbf30 Merge "crypto: msm: check potential integer overflow on AEAD req length" 2013-10-25 05:30:50 -07:00
Linux Build Service Account 05ab31fd11 Merge "crypto: msm: Fix null pointer exception in qcrypto_count_sg()" 2013-10-24 18:08:47 -07:00
Zhen Kong 5afcf33702 crypto: msm: check potential integer overflow on AEAD req length
According to the specification of AEAD, AEAD request cryptlen is
not a Fixed maximum and assoclen is also same. This could lead to
potential integer overflow, thus allocating less memory. So we
need to check potential integer overflow on AEAD request length.

Change-Id: I58a0c5e1a6e890bad30f7865e96b7db46337158c
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-10-24 14:25:12 -07:00
Rohit Vaswani 9c23b09c59 crypto: msm: fix hmac ahashing issues with simultaneous multiple requests.
This patch fixes two issues. One issue is to do with simultaneous requests
 of a ahash tfm. The other issue is to do with ahash import, and export
 functions.

 Agent issues chain of requests in sequence of init, followed
 by multiple updates, and final to the crypto driver for the hashing of a
 buffer. Each request can be asynchrounous. After a request is complete,
 the next one in the sequence is issued.

 Multiple simultaneous async requests can be issued to the driver
 for the same tfm if they are for independent hashing.

 In the driver, the state variables such as trailing buffer, first
 block, last block are maintained in the driver. The
 state variables are maintained in the request context, instead of
 tfm context. Otherwise, simultaneous async requests can
 confuse each other. This patch moves those variables out of
 tfm context to request context to fix this issue.

 Agent above the driver can import/export ahash state of a request. This
 patch fixes a few issues in the driver to support import/export.
 First issue, the byte count returned from hw for hmac has 64 bytes of
 padding on the first request to the hardware. In the import/export this
 special case needs to be accomodated.

 The 2nd issue is the state buffer is only updated after hardware operation
 complete. For the first, data being accumulated in the trailing buffer,
 and if request has not ever issued to the hw, when import function comes,
 the trailing data needs to be exported. This patch uses trailing
 buffer directly as state buffer variable for import and export.
 The context update functions after hareware request complete are not
 necessary and they are removed. The last issue is to do with state
 variable count. It was not initialized. That may cause hashing generated
 wrong  digest after export and import.

Change-Id: I608c2322b120825b9ca12c3794e0b0a4628ef693
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-10-22 14:22:19 -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
AnilKumar Chimata 12ed3c0a21 crypto: msm: Fix null pointer exception in qcrypto_count_sg()
Fixes null pointer exception in count scatter gather function. Scatter
gather list pointer become NULL if the sg pointer reaches last but one
node, which results in NULL pointer exception.

Change-Id: I634baf30074e6e53ffa22635565da54e9ae43150
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2013-10-19 19:27:11 +05:30
Linux Build Service Account 8fbc221127 Merge "crypto: msm: Fix issues related to non-zero byteoffset input" 2013-10-19 01:51:54 -07:00
AnilKumar Chimata 3e88ed60f1 crypto: msm: Fix issues related to non-zero byteoffset input
Fix buffer overflow for a non-zero byteoffset value.

Also fixes memory leak issue by adding data_len check in check_params.
One of the scenarios data_len can be less than byteoffset which results
in memory leak with huge data length, which might cause the kernel panic.

Change-Id: I3f773673219f45dad4f17499b1ee0feda2aff1f7
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2013-10-18 14:31:08 +05:30
Linux Build Service Account 778a075f67 Merge "crypto: msm: Remove invalid check in qcedev driver" 2013-10-18 00:46:53 -07:00
AnilKumar Chimata c4f6f05339 crypto: msm: Remove invalid check in qcedev driver
Unsigned int variable is compared for < 0, which is an invalid if
condition. This patch removes the check.

Change-Id: I76c10223672db2c387e025697dd8bd921e5ddc1b
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
2013-10-08 13:42:56 +05:30
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 86a4b16507 crypto: msm: Ensure sha_init is called for HASH operation
Validate that the sha_ctx is initialized before any SHA operation
(update, final) requests is issued by client.

Change-Id: I83ac2000d860dfef5532910a2a73cd927b68e95f
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-10-02 15:57:50 -07:00
Linux Build Service Account 2b66895b6e Merge "crypto: msm: Validate total data length" 2013-09-25 01:06:53 -07:00
Linux Build Service Account 11fd1c9aca Merge "crypto: msm: multiple qcrypto support" 2013-09-24 20:53:16 -07:00
Mona Hossain 5c79bd9af2 crypto: msm: Validate total data length
Verify sum of all data segments equals the total data length.

Change-Id: I0fb9d856281d52c58536e77512f8cae75544d1bc
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-24 11:31:03 -07:00
Linux Build Service Account c2403d1836 Merge "crypto: msm: Verify source and destination data lengths" 2013-09-23 16:06:58 -07:00
Mona Hossain fe0ab0ccc9 crypto: msm: Verify source and destination data lengths
Check to confirm the sum of length of the source
and destination segments is equal to the total length
sent by client.

Change-Id: Ib10b8f792591631060135022d81f1f08c424ee66
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-23 10:56:29 -07:00
Mona Hossain fc804beeb7 crypto: msm: Check destination buffer write access
Use VERIFY_WRITE to check write access to destination buffers
before writing to them.

Change-Id: If9708695e85659bb25e13762c54dd50abd9577c7
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-23 10:27:44 -07:00
Linux Build Service Account b8b19e0caf Merge "crypto: Kconfig: fsm9900: Add Hardware crypto module." 2013-09-19 07:07:50 -07:00
Rohit Vaswani aaa958ef05 crypto: Kconfig: fsm9900: Add Hardware crypto module.
Add hardware crypto module for fsm9900 target.

Change-Id: I60c922bbf9156df96232d789d771d3433c85aefe
Acked-by: Kaushik Sikdar <ksikdar@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-09-18 14:57:34 -07:00
Zhen Kong 87a63da5d9 crypto: msm: multiple qcrypto support
This patch provides support for multiple qcrypto devices
with the qcrypto driver.

Change-Id: I36b0a802dcf92a438353f5961fab0bfddc53268a
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-09-12 14:48:54 -07:00
Zhen Kong b2b91ba5d5 crypto: msm: fix issues in ce clock disable processing
In the situation of more than one requests, the ce clock may get
errorneously disabled even when there are active requests. The
scaling operation is then modified to fix the problem and ensure
all requests are completed when disable the clock. We also clean
up the related codes.

Change-Id: Icc4675fa7b3818f6f8befb513b56d9ae051b98de
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-09-12 14:48:22 -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
Mona Hossain e76994652b crypto: msm: Fix Uninitialized flags
Due to uninitialized "flags" field in the request structure,
incorrect choices are made in the qce driver layer with
regards to setting crypto hardware registers.

Initializing the flags fixes this incorrect setting of the
registers.

Change-Id: Ic40319ea5e15e66cbafd28f727a9bcc6ea41b1ca
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 17:19:27 -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
Zhen Kong 87b049525f crypto: msm: optimize ce bandwith scaling
Encryption processing at qcrypto driver includes three main steps:
set ce high bandwidth and enable ce clock in cra_init, then send
encrytion request, and at last set ce low bandwidth and disable
clock in cra_exit. This process is fine for the use case where
there are lots of requests between cra_init and cra_exit, but will
introduce large overhead for mmc layer disk encryption as it calls
cra_init, queue request and cra_exit for every encryption request.

It is not necessary to set low bandwidth and disable clock for every
encrypt request when it is completed. So we delay these scaling down
tasks for a while, and just scale down the last request when timer
expires so as to amortize and decrease the overhead.

Change-Id: I6a59066343f01950b66f4e886d40a9f27ce211c3
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-09-04 17:17:20 -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
Rohit Vaswani 87cbf16b0c crypto: msm: fix aead combined mode decipher problem
Fix -EBADMSG error for crypto 5.1 and above for aead decipher.
bam dma input/output length should include asso data plus iv plus crypto
data, and excluding MAC result for deciphering.

Change-Id: I0aaa666dbe96185cf0a81a542b3df02d4f6ebf88
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-09-04 17:10:46 -07:00
Zhen Kong 4a634b9473 crypto: msm: set ce_shared flag as zero when using BAM HW
CE HW sharing is not supported when BAM hardware is used, so
we need to set the corresponding ce_shared flag as zero in
qcedev_probe().

Change-Id: I28f0cb9c453a473970742f80fc16379ec7183771
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-09-04 17:09:42 -07:00
Hariprasad Dhalinarasimha 0e52a88e4f crypto: msm: Add support for aead
Add support for aead mode algorithms (simultaneous auth
and cipher operations)

Change-Id: I22cc530f8fe822504649cb3c60030a729e1305c2
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 17:00:12 -07:00
Zhen Kong fa24bfa7b5 crypto: msm: check NULL pointer in _qcrypto_setkey_des()
add NULL pointer check before des_ekey()

Change-Id: I57c40b82fc5141c1666c3fd493b43e962f0d1ae9
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2013-09-04 16:59:06 -07:00
Mona Hossain 53fc568f48 crypto: msm: Designate memory chunk for ignore_buffer
Memory was not assigned to ignore_buffer pointer and uninitialized
pointer was being used.

Change-Id: Ie7c372aeafdfe17b9bb70d38666fa81c3df1e043
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:53:29 -07:00
Mona Hossain cb825b4508 crypto: msm: Process keydata for HW/PIPE key use case
When client sets HW_KEY flag, driver should ignore key data
and length when client issues set_key request.
When client sets PIPE_KEY flag, driver should ignore key data.

Change-Id: I550d1d2a217e6b9c9de50064bfafe72f9f32e6e1
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:50:03 -07:00
Mona Hossain 040b3e2b8d crypto: msm: Add support for setting ctx flags
Currently there is no way of instructing the crypto driver
to use HW specific capabilities. The kernel crypto framework
does not expose any API to set any specific HW feature flags:
ex: use of HW key,  use of PIPE keys, setting XTS data unit
size.

The driver currently uses a specific key pattern to decide
when to instruct HW to use HW_KEY (uses key pattern of all
zeros) and when to use PIPE_KEY (uses key pattern of all 0xF's).
This limits the use of the specific key pattern from ever being
used for any crypto operation.

Adding support for crypto client to set flags to indicate when
to use HW KEY, PIPE KEY, size removes the limitation on the key
patterns that can be used by the driver.

Adding XTS data unit size flags allows the client to take
advantage of the hardware capability to set data unit size
for XTS operations.

Change-Id: I0d1417a6d3c990e0750dbd90e3816f45fec8d693
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:48:53 -07:00
Hariprasad Dhalinarasimha e1ecd2afa4 crypto: msm: Add support to register BAM in satellite mode.
There exist scenarios on some platforms where the same CE HW used in
crypto driver is shared with the crypto driver in secure execution
environment. In these case, crypto BAM is set to operate in master
mode by secure EE. Hence it needs to be registered to operate in
satellite mode by HLOS crypto driver.

Change-Id: Ibc5e06aac09c53dd6e1b419b871d9da3f82ab63d
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:47:58 -07:00
Mona Hossain ce0509bb16 crypto: msm: Add support_hw_key flag
Add support_hw_key, hw_key flag to indicate if use of
HW KEY is supported by the driver.

Change-Id: If7976f5891afa211631597b8dab93ff17f0fa5c5
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:47:09 -07:00
Rohit Vaswani fe953c98bb crypto: msm: ota: multiple ota devices support.
This patch provides multiple hw devices support for ota crypto driver.
The driver dynamically allocates hardware resources for each ota crypto
operations. Further more, the stat structure in the driver
is changed to support device tree.

Change-Id: I701fe08ecc51f53ddbe6e2b76b2fb65ab79190d2
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-09-04 16:45:45 -07:00
Hariprasad Dhalinarasimha 42b3dedd9d crypto: Kconfig: 8610: Add Hardware crypto module.
Add hardware crypto module for 8610 target.

Change-Id: I15733e6569c78c20ec629a5031f9744286349811
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:42:37 -07:00
Hariprasad Dhalinarasimha 0abb17a850 crypto:msm: Remove hardware sharing check.
CRYPTO clocks has to be enabled regardless of hardware sharing,
hence remove the hardware sharing check.

Change-Id: I551e8a97768e0526783a6ccfe9a214f1a9de148e
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:41:22 -07:00
Mona Hossain 556f5e9d5f crypto: msm: Add failure logs
When SPS driver reports a failure to process a request,
we need to output the sps_iovec_contents that was issued
to the SPS driver.

Change-Id: I84d48880cade41e5b9ce652f4dba1a84b857fb72
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:40:27 -07:00
Mona Hossain b33fe9a9c7 crypto: msm: Check for invalid byte offset field
There is potential for HEAP corruption when the
byte offset field is set to a huge value.

Change-Id: Idd851cf3ec57627aba7d8250914cd18ccdd697ec
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:40:13 -07:00
Hariprasad Dhalinarasimha d42142435a crypto:msm: Fix crypto 5 aes(ccm) issue.
This patch handles the operation completion status
during the completion of a crypto operation properly.
The crypto device status register is clear at the beginning of
each operation.

Change-Id: I54e38160c939c17fe58ebdce44f8080b3837e3e7
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:36:32 -07:00
Hariprasad Dhalinarasimha 4397fb00d2 crypto: msm: Fix handling of AES CCM error
AES-CCM error does not report proper status to qcrypto driver.
If prior operation AES CCM operation has an error, (ex: MAC_FAILED),
it never gets cleared. Subsequent operation will report the same bit
error. Fix is to clear the status register before firing off an
operation

Further more, any AES-CCM error due to MAC failed is not logged
properly. Add aead_msg_fail if aead opearation is fine, but MAC
comparison fails the integrity checking.

Change-Id: Id9057a0f3fdf0be0b4e09185ae3a31d52ffd9c01
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:34:11 -07:00
Mona Hossain 450a3e95d1 crypto: msm: Fix AES-CCM failure
For decrypt operation AUTH_POS bit is set incorrectly to 0x02
resulting in the authentication being done before decryption.
For decryption, the AUTH_POS field should be configured to 0x1
(or 0x3) to ensure authentication is occurring after decryption.

Change-Id: Ieaf10a653c6e77994c285e573d7fd787634631a2
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:30:41 -07:00
Mona Hossain 55e1694921 crypto: msm: Fix issue of crypto driver referencing pdev->id
On platform that use device tree to pass board or architecture
specific information rather than via platform device structure,
the id field of platform_device structure is no longer valid.
It was used to identify different instance of Crypto engine.
With device tree, this is set to -1.

The crypto driver modules (qcrypto and qcedev) refers to pdev->id
mostly to update statistics counters. With invalid pdev->id,
the counter does not increment, and would corrupt memory as it
update counters in _qcrypto_stat[-1] and _qcedev_stat[-1].

This patch removes all reference to pdev->id.

Change-Id: Ia8723c6eb5e91806223696efb1bf1a480ff2d831
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:29:59 -07:00
Mona Hossain ad72a7116b crypto: msm: Replace sg API with scatterwalk_sg_ API
replace  sg_copy_to_buffer(), and sg_copy_from_buffer()
in crypto driver with version that uses scatterwalk_sg_next
to traverse the sg list.

After setting up an IPsec tunnel with DES-CBC encryption and HMAC-SHA1
authentication, following messages were displayed while running a few ping
packets.

[ 121.773780] bytes copied=0x8 bytes to copy= 0x58
[ 122.781008] bytes copied=0x8 bytes to copy= 0x58
[ 123.781113] bytes copied=0x8 bytes to copy= 0x58
[ 124.781175] bytes copied=0x8 bytes to copy= 0x58

This kind of messages are displayed when sg_copy_to_buffer() or
sg_copy_from_buffer() fail to copy entire data. They were able to
copy only part of it.

This happens because sg_copy_to_buffer() and sg_copy_from_buffer()
do not recognize scatter-buffer buffer used in Crypto. It needs to
use scatterwalk APIs to traverse the scatter-buffer list.

To address this issue, qcrypto_copy_from_buffer() and
qcrypto_copy_to_buffer() functions are newly added. These are similar
to sg_copy_to_buffer() and sg_copy_from_buffer(), but they understand
the scatter-gather list used in Linux crypto subsystem.

Change-Id: I71167e7e56aee8ddaa405f30a3f9f5dab426e6c8
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:29:57 -07:00
Mona Hossain 231e9eb3eb crypto: msm: Fix failure in qce_close
CE clk needs to be enabled when invoking sps_exit.  Further
more, memory allocated for pipe FIFOs should not be de-allocated
before calling sps_exit, as it is still referenced in sps_exit.

Change-Id: I66cbd7d92ed7ad74d5b4eca23fe3a327501b2e1b
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:29:56 -07:00
Mona Hossain f045b5a904 crypto: msm: Fix kmalloc() with GFP_KERNEL flag issue in irq.
There exists scenarios where packet processing is done in softirq
which runs in interrupt context. Blocking call is not allowed in
interrupt context. The qcrypto driver tries to allocate memory in
several places, and some of them were done in interrupt context.

In some cases, to meet the alignment requirement of some versions
of Crypto5 engine, _copy_source() is called that  make a copy of
the data. This calls kmalloc() with GFP_KERNEL flag. This flag cannot
be used in interrupt context since the caller may get blocked until
the kernel finds requested memory.

To avoid this, all the memory allocation requests in interrupt context
were changed to use GFP_ATOMIC flag instead.

Change-Id: I3b86af00f3d7737c38b94e748ae083f58576dda5
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:29:13 -07:00
Mona Hossain 72701916bb crypto: msm: Fix HW register addresses
Mismatch of qce50 HW definitions in include file and SWI.

Change-Id: Ic5a01588841b8d245ac9fbea333d019b3ed1e937
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:28:48 -07:00
Mona Hossain a189f170b5 crypto: msm: Fix driver crash when running AES-CBC decryption
The cause of the crash is due to uninitialized variable "areq" used in
ablk_cipher_req().

When the areq is pulled from pce_dev->areq, it is not valid and is
uninitialized. Since we already have the valid pointer to areq from
qce_req structure, we do not need to redefine areq.

Change-Id: Ib63ec65dc9df5f87ff470c04cfe5fbb66c19199a
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:28:46 -07:00
Mona Hossain c885b8f48b crypto: msm: Fix configuration when using CD
Add support to determine when to use command descriptor (CD)
based on register settings and set flag to indicate BAM
global device control is managed remotely. This configuration
is used when the device does not support accessing CE HW
registers using BAM command descriptors (HW registers are
not managed locally by BAM).

Change-Id: Ic3195db03ecc73e98b7dd3407ccc5402e703b362
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:27:40 -07:00
Mona Hossain 02643c8fa2 crypto: msm: Add checks for input parameters
Add checks for incorrect inputs for hash and cipher
operation.  Add error logs for incorrect input parameters.

Change-Id: Ifced6a3388621fd2b051e06de8f02d36636f2ebb
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:26:54 -07:00
Mona Hossain 6c22ed0626 crypto: msm: Optimize CE setup
Use previously configured register setting instead of
determining what bits needs to be set per operation.

Change-Id: Ie22c0ce4dd5ca14b030ec8ad6feaaf511535b145
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:26:53 -07:00
Mona Hossain 40e0b67640 crypto: msm: Configure CE HW register directly
Some chipsets that support CE 5.0 HW does not support
setting CE HW registers via BAM command element/descriptors.
These registers need to be set directly.

This patch adds support to configure CE HW registers directly
without using BAM consumer pipe.

Change-Id: I0707fcd5bf132c9462b8c6a30f6f7d8f8dd6fd86
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:26:52 -07:00
Hariprasad Dhalinarasimha 4a20000f7b crypto: Kconfig: 8x26: Add Hardware crypto module.
Add hardware crypto module for 8x26 target.

Change-Id: If42de3968d4fbe8920f1334e4d633c942118a000
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:25:24 -07:00
Mona Hossain ae3ff92b6a crypto: msm: Remove consumer pipe callback
Remove registration of call back function and the call back
function for consumer pipe operation.

The callback  does not do anything significant but
add to the latency per operation.

Change-Id: Id272a1311e2c3e2872091b599ac40f590fb9b0f7
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:23:30 -07:00
Mona Hossain d89cf413e5 crypto: msm: Increase max num of descriptors
There exist scenarios where memory gets corrupted due
to the limitation on the number of descriptors that
can fit into the PIPE descriptor FIFO.

The fix is to increase the max number of descriptor by
128 (to 0x500).

Change-Id: I770374043ad11cf320ca1bec1f00840b10b86218
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:22:37 -07:00
Mona Hossain 1a8cd7ed5e crypto: msm: Add support for clk scaling and gating
Add support for enabling clk before initiating crypto
operation and disabling clk after all crypto operations
are complete.
Expose qce_clk_enable() and qce_clk_disable() APIs for
qce clients (qcedev and qcrypto).
Add clk scaling and gating in the qcedev and qcrypto
driver modules.

Change-Id: I6ab96f6b62f2401bf721483448601d52af1be19e
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:22:34 -07:00
Mona Hossain 4b8ba2de84 crypto: msm: Check for valid key length for HMAC operation
Check to ensure keylength is valid for HMAC operation.

Change-Id: I7f0075cad2dc1f011e32309b3e96641cfc4dcd9e
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:20:22 -07:00
Mona Hossain 8a5b4b483a crypto: msm: Fix failure to process AES-XTS 256 key
For AES-XTS 256 mode, key size is 64 bytes (twice the
AES key size of 32 bytes).  The driver  only checks for
AES key size and not specifically for xts key size.
The driver checks for AES key size and return a failure
for AES XTS 256 where key size is 64 bytes

Fix is to check for valid keys for XTS algorithm.

Change-Id: Ia7bafa5b5c13eab018a2e1d729a82c8d329a092e
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:19:52 -07:00
Mona Hossain 37fa11ad93 crypto: msm: Fix failure in XTS operation
When using PIPE keys, the XTS_DU_SIZE register is hardcoded to
512 Bytes.  For transfers that are smaller than 512 bytes,
the crypto operation hangs waiting for more data.

The fix is to set XTS_DU_SIZE to minimum of packet size and 512
bytes.

Change-Id: I0dea9fadc71c599df700c1431f793e7cbb9997b0
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:18:56 -07:00
Mona Hossain c98741cca8 crypto: msm: Fix size of descriptor buffer
When the number of entries in the scatter gather list is larger
than 64, crypto operation fail.  This is due to incorrect use
of macro to allocate memory for the descriptor size.

Fix is to replace use of QCE_SIZE_BAM_DSCR with the size of the
sps_iovec data structure. Further, more use the correct macro when
reporting the size of the descriptor to BAM.

Change-Id: I4396ad8407b6b91d7a34367a2777cb920f81457b
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:18:11 -07:00
Mona Hossain c4b665b6b8 crypto: msm: Fix XO shutdown issues
ce-core_src clk is being left on preventing device from going
into low power mode. Furthere more, clks are enabled without
checking if the handle is valid.
This fix removes enabling of ce_crore_src_clk. Also checks if
clk handle is valid before enabling them.

Change-Id: Ieb64b4b11385838ba18dd05d47ccc978e5b1bdf1
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:14:05 -07:00
Mona Hossain 003d24ff32 crypto: msm: Refactor/clean-up clock code
Add clk enable/disable and init/deinit APIs.
These APIs will be used in future to allow clk scaling and
gating by clients.

Change-Id: I08503972b9ed77633e14d81711aa92c61df7a0ad
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:13:19 -07:00
Mona Hossain 9fea93c8bd crypto: msm: Add support for using PIPE keys
Based on the encryption key value, check if the request
requires using the PIPE keys. If so, set appropriate
configuration registers to indicate to HW to use PIPE keys.

Change-Id: I8ddf6c7b372dc63479e1bd105bbcb8c127ff1513
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:12:24 -07:00
Mona Hossain 417243db5d crypto: msm: Fix stress test failure
Stress test case scenarios involving a cipher operation for a large
packet (> 32KB) followed by a hash operation (of any data packet size)
fails, with the hash operation hanging.

The failure is due to the sps driver invoking the incorrect callback
for the subsequent hash operation. Instead of invoking the registered
hash operation callback,  it  invokes the previously registered cipher
operation callback.

The fix is to set the correct flag bits for the event when registering
the callback before invoking sps_register_event() and also removing
the SPS_EOT_EVENT flag when registering the sps_connect pipe information.

Change-Id: Ia9ef774e2900df61f18298349fb4b5f4dc4d34b2
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:11:42 -07:00
Mona Hossain ec1787b46a crypto: msm: Set the shared field of ce_hw_support data structure
Add the "shared" field in the ce_hw_support data structure.
This field indicates if the crypto HW used by the HLOS crypto
driver is being shared across multiple execution environment(s).

Change-Id: Ie8038c6bc7268dab2353f3a7f24b59d37aad2bb8
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:11:16 -07:00
Mona Hossain c914a25f88 crypto: msm: Remove incorrect flag settings for producer pipe
Remove EOT flag set on the data descriptor issued on the producer
PIPE. As per the hardware documentation EOT flag does not need
to bet set for producer pipe descriptors.

Change-Id: Iec05ff6b7db1b9a1c94bc8a23f8ba8c9bc45b446
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:08:53 -07:00
Mona Hossain 1cc04c9125 crypto: msm: Reset encr_cfg before auth operation
Before starting any  authentication operation we need to
ensure all encryption related configurations are invalid.
This is done by setting the encryption config register to 0.

Change-Id: I294834c78a46063bb3c564cdebcaafbc5f846952
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:08:44 -07:00
Laura Abbott 1f72e99245 crypto: msm: Remove use of PMEM
PMEM functionality is deprecated.
Remove all references to CONFIG_ANDROID_PMEM.
Remove all pmem related functionalities.

Change-Id: I70e5e308e37d25f8b0e788dbad6617925e4331bd
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 16:07:43 -07:00
Hariprasad Dhalinarasimha 9ac8304ebe crypto: msm: Add validation checks for memory cleanup
Add validation checks to handle memory freeing &
prevent NULL pointer access.

Change-Id: I6e82ea56754fb12b467d5ecb642411017c1e18c6
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 16:05:34 -07:00
Mona Hossain 48c89d5c07 crypto: msm: Remove use of index to address sg entry
Treating scatter gather list as an array is and referencing
entries with indexes results in incorrect sg entries.
Tnis is because the sg entries are not contiguous in some
scenarios.

Fix is to use scatterwalk_sg_next() to traverse the sg list.

Change-Id: I1d7ebec779fa18c3ab5f0a6f357ef7fb53d3e9ab
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:58:14 -07:00
Hariprasad Dhalinarasimha 09abedd1af crypto: Fix potential crash due to unbound array & null pointer access.
Fix the null pointer errors and valid index checking for arrays to
fix potential kernel crash.

Change-Id: Iabf7f73dcfe5a544e3fe83f1e67ec1161f989fac
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 15:57:58 -07:00
Mona Hossain e933044389 crypto: msm: Remove use of sg_virt
Using sg_virt() on scatter list entries, that is designated
for buffers in high memory pages, results in returning a 0
address; NULL pointer is returned.  This is due to the fact
that high memory pages are by definition unmapped. Hence
sg_virt() does not work for such pages.  Dereferencing this
NULL pointer to copy data from/to results in kernel panic.

Remove all cases of sg_virt() API use case.

Change-Id: I5a007f5d198dff8265f0247aa83adf04b9511f5d
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:56:24 -07:00
Mona Hossain 9434fcaf03 crypto: msm: Fix kernel panic in sg_virt() call
There exists scenarios, where data is copied from client's
scatter gather list (sglist) to a locally allocated buffer.
In these cases, the driver uses sg_virt() API to retrieve
the virtual address of the buffer for each of the sglist
entry.

Using sg_virt() on scatter list entries, that is designated
for buffers in high memory pages, results in returning a 0
address; NULL pointer is returned.  This is due to the fact
that high memory pages are by definition unmapped. Hence
sg_virt() does not work for such pages.  Dereferencing this
NULL pointer to copy data from/to results in kernel panic.

Fix is to use sg_copy_from_buffer()/sg_copy_to_buffer() to
copy data between a local buffer and the buffer pointed to by
the sglist. These APIs temporarily  maps the memory addresed
by each of the sglist entries using kmap() and copies data
from this mapped segments to the requested local buffer.

Change-Id: Ibaaf218f3f86a35c67368c7b2ee57189db207bca
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:56:09 -07:00
Mona Hossain 3b632e5b3b crypto: msm: Add checks for memalloc failure
Add error logs when memory allocation fails.  Return
error if memory allocation fails.

Change-Id: I64e1223b34d976220e8ab56690b38312822532fd
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:56:08 -07:00
Mona Hossain a727e3b2d1 crypto: msm: Fix kernel crash due to use of sg_next
sg_next() may find wrong scatter-gather buffer in crypto subsystem,
and this causes a kernel crash. scatterwalk_sg_next() should be used
instead in crypto related drivers.

Change-Id: Ia8b87a91165e915d3b0709331a83e3b40bd02493
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:56:06 -07:00
Mona Hossain 2304d05a25 crypto:msm: Increase descriptor FIFO size
The Current BAM descriptor FIFO is set to 512 bytes and
can accomodate 32 descriptor entries (each entry being 8 bytes
and pointing to a unique sg entry from the sg list). There
exists clienta that can issue a scatter gather list with
more than 32 entries.

Increasing the size to accomodate a max of 1024  entries
allows driver to process all clients request successfully.

Change-Id: Ide111de0ef001642543c503574b7f080185f9c8b
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:55:57 -07:00
Mona Hossain 80cef55ba8 crypto: msm: Fix address for PIPE KEYs
PIPE KEY address are incorrect. This patch fixes these
incorrrect addresses.

Change-Id: I3e5069da6e2c99f24f706bef8a53e605b95d707b
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:51:07 -07:00
Mona Hossain d7d73fcba7 crypto: msm: Fix failure to process large packets
When performing a crypto operation of packet size larger
than 32KB -1 Bytes (max supported by BAM HW), the operation hangs.

The root casue was identified to be in one of the accumulators of
NDP_BAM not being given enough time to clear prior to when the EOT is
seen from the crypto core.

The workaround to the above issue in NDP_BAM is to precess the data
descriptors in in the producer PIPE in 2 steps.
- Enable INT for the second last descriptor prior to sending the last
  results dump data descriptor to BAM
- Once the interrupt is fired,  then only issue the result dump data
  descriptor to be process by BAM

The above changes results in allowing enough time for the accumulators
to clear before the last results dump data descriptor is processed by
BAM.

Change-Id: I46be19857fc22bae7aec2b2798ca487ee49fafd1
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:50:21 -07:00
Rohit Vaswani e884bf71ca crypto: Use scatterwalk APIs in crypto
sg_next() may find wrong scatter-gather buffer in crypto subsystem,
and this causes a kernel crash. scatterwalk_sg_next() should be used
instead in crypto related drivers.

Change-Id: Ibb454bc8a8b2c0318e55cd12ba3e4ca2f3647e36
Acked-by: Ho Lee <holee@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-09-04 15:48:31 -07:00
Hariprasad Dhalinarasimha 4128cd3f6f msm: crypto: Enable crypto driver on msm9625
Enable the qce50 crypto driver for msm9625 target.

Change-Id: Id2f490e80df17b1257c8296022d20cdc69e86335
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 15:44:53 -07:00
Mona Hossain 3cc48333a5 crypto: msm: Add support for HW key
OEM specific HW key (primary  hardware key) is XPU protected by
trustzone and is not accessible by HLOS.

Only the Qualcomm specific HW key (secondary key) is made
available to HLOS. This patch removes access to OEM specific HW
key and replaces with the QC HW KEY.

Change-Id: I7a22218c4673c57d385eaaa8d445a93e7bc300f6
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:38:59 -07:00
Mona Hossain 7171e8ce9c crypto: msm: Fix failure to load both crypto modules
When the crypto driver modules, qcedev and qcrypto are both
configured to be built-in (not loadable), one of the probe
call fails.

This is due to both of them trying to register the same
CE BAM device to sps driver: both invokes "sps_register_bam_device".
BAM devices need to be registered only once.

Fix is to use a flag to indicate if the BAM device is already
registered and maintain a bam_register count for the number of
request made for this registration.

Also since we dont need to initialize the bam_register count in
the init function, the module_init/module_exit are removed

Change-Id: I1ba9a0320f049d605b4aecf013a46997f5bccfda
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:38:36 -07:00
Mona Hossain 0e6005094c crypto: msm: Unlock mutex before exiting function
When an error is encountered while trying to register a BAM
device, unlock the mutex before returning with an error.

Change-Id: I71fd8c3e69cee23406992ec61aeab0191d26fb71
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:38:36 -07:00
Mona Hossain b79c5c3c41 crypto: Add wait states for hash/hmac operations
Currently, hash (SHA1/256/hmac) operation occasionally results
in an incorrect hash value. This is due to the premature reading
of the AUTH_IV register done before the last SHA block is processed.
There needs to be enough delay (wait states) before the AUTH_IV
register is read to extract the hash value.

The current implementation has 2 wait states. Adding 2 more wait states
for hash operations, resolves the issue.

The wait states are calculated based on the inputs from the hardware
team with regards to the time taken to process the last block of 16
bytes of the data packet.

Change-Id: I4f9e784fbfca62d6636d87dc44c1bf9992e3b3e4
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:34:38 -07:00
Mona Hossain 280c64167f crypto: msm: Add support for AES-CCM algorithm
AES-CCM  mode is currently failing due to numerous issues.
Following fixes have been made to make AES CCM  mode operations
pass:
- Initialize the hash commandlist
- Set LAST bit in ENCR_CFG register to indicate single operation
- Set AUTH_SEC_CFG register correctly  for decryption

Change-Id: I15d1e48046246e9ca7441a6214869abfa9f62edf
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:34:35 -07:00
Mona Hossain de6be594ae crypto: msm: Set command descriptor size to burst size multiple
Remove dummy command elements added for the DES/DES3 CBC algorithm.
In order for proved perfromance, the  descriptor (data and command)
size sent to the BAM needs to be multiple of burst size (set to 64B).

Change-Id: If9b0cef79f15da73b18d55c24c32f4c0b7b1216a
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:30:53 -07:00
Mona Hossain a25ba454fe crypto: msm: Fix failure on XTS mode
XTs mode of operation fails with a crash or hangs in some cases.
This failure is due to numerous reason:
- CRYPTO_XTS_DU_SIZE address is incorrect resulting
  in not setting the register correctly
- xts_du_size command list pointer was NULL. This results in
  the operation crashing due to dereferenciong of a NULL pointer
- XTS KEY register was not set correctly, resulting in
  incorrect results for encrypt/decrypt operation

After fixing the above XTS mode of operation is passing.

Change-Id: I1cfcfaf0ecae61510d3d4372c49a412d65d7bc40
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:30:52 -07:00
Mona Hossain cbc3d42bdf crypto: msm: Fix counter IV calculation
CTR mode operation fails due to incorrect CNTR IV  returned
for large size packets.  For large packets, adding the number
of crypto blocks (16 byte chunks) to the CNTR_IV3 register
sometimes results in oevrflowing the register and hence an
incorrect value is reported back.

The counter IV for CTR/XTS mode is calculated incorrectly.
Th fix is to account for roll over scenarios. when the updated
counter value exceeds 0xFFFFFFFF.

Change-Id: I9343c520ce17871145eb9678d5fed9d718ddc089
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:30:52 -07:00
Mona Hossain 0fb0ea2fe6 crypto: Fix CBC mode failure
Multiple back to back CBC packets encryption followed by
decryption operation is failing.  This failure is due to
incorrect CNTR IV  calculated at the end of the operation
that is used in the subsequent operation.

Fixed the value of the cntr iv for decryption mode.
The CNTR IV should point to the last  16 bytes of the
encrypted data packet.

Change-Id: Ibca400a3a34ab448e54508f4019410edaaca4977
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:29:02 -07:00
Mona Hossain c9a9f9ce44 crypto: Fix HMAC failure
HMAC operation for small and large packets are failing.
This is due to 2 reason:
- Packet size set for each operation is larger than what is
  supported by the BAM hardware.
- Byte count value read after the end of the operation is of
  incorrect  byte order.
Fix is to decrease the max packet to the  max of (32KB-64) and
fix byte order when storing the byte count value from the register
dump of the results at the end of the operation.

Change-Id: Ieb91ab2ad22cb8a08a575c058b7178e532bea7d7
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:29:01 -07:00
Mona Hossain 5ca4d664e6 crypto: Add support for sharing CE
Add pipe locking logic. Before accessing the CE HW,
lock all other pipes from accessing the same CE HW.
After the operation is complete, unblock the pipes.
The pipe pairs should also belong to the same group.

Change-Id: Ie696ad0efcb4b38c1fd43b315d468067bb3b8a1a
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:18:00 -07:00
Ramesh Masavarapu a7654bde87 crypto: Set the BAM execution enviornment parameter.
Currently the BAM's execution enviornment parameter is not set.
Without setting this parameter, there would be no interrupts handled
on HLOS.

Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
2013-09-04 15:16:54 -07:00
Ramesh Masavarapu 483fc8134b crypto: Enable AXI clock for Crypto Engine.
Currently the AXI clock is not enabled for the crypto driver.
Without this clock enabled, data will not be transferred
between the DDR and the Crypto Engine.This fix enables the
AXI clock.

Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
2013-09-04 15:16:11 -07:00
Ramesh Masavarapu f0a44bbf20 crypto: Set INT flag on producer pipe.
The Crypto Engine hardware does not generate an End of Transfer (EOT)
interrupt for SHA algorithms. This issue is solved by:

 -Adding an INT flag for the last descriptor on the producer pipe.

Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
2013-09-04 15:16:10 -07:00
Ramesh Masavarapu e52918a8df crypto: Removed NWD flag from intermediate descriptors.
The NWD flag had to be enabled only on the last data descriptor
and not in intermediate descriptors.

Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
2013-09-04 15:16:09 -07:00
Ramesh Masavarapu bc20bd1cb0 crypto: Align command descriptors to burst size.
According to the hardware design, Crypto Engine 5.0
hardware expects all descriptors to be burst-size
aligned for performance reasons. In the case of using
descriptors, unaligned addresses have a huge performance
impact. In this case it might cause h/w to take longer
processing times when compared to the crypto driver directly
setting the registers via processor.

Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
2013-09-04 15:16:09 -07:00
Ramesh Masavarapu 56d90aea83 crypto: Fix byte order alignment on data packets.
Crypto cipher/authentication operation yields incorrect results.
Although the operation is succesfull, the resulting data bytes
seems to be incorrect. The data input/outout needs to be
configured to be in little endian format.

The fix is to set the LITTLE ENDIAN flag in the CRYPTO_CONFIG
register, after configuring the crypto hardware registers and
prior to setting the GO_PROC register. This way, the little
endian format kicks in for the the data descriptor transfer
only, resulting in correct order in which bytes are input and
output.

Signed-off-by: Ramesh Masavarapu <rameshm@codeaurora.org>
2013-09-04 15:16:08 -07:00
Hariprasad Dhalinarasimha 2ab358ab31 crypto: Fix QCEDEV platform data initialization.
Initialize the platform data before it is being used for bus scaling.

Change-Id: Ie41ddec08b52b44ae735469dd8f3052e3469eeff
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2013-09-04 15:11:38 -07:00
Mona Hossain 43cbd0c3a0 crypto: Add support for crypto engine 5.0
Add new register definitions for QCE5.0 Hardware
Add new HAL (qce50.c) for interfacing with CE 5.0 hardware:
-- Implement the new interface to BAM (instead of data mover).
-- Add support for multiple Pipes.
-- Add support for use of HW key.

Change-Id: I69dc3993f607553d4752f9f9fb4fdfe1a09a6345
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:05:18 -07:00
Mona Hossain 19cd301779 crypto: Fix HMAC failure
Incorrect HMAC values are generated in following scenarios.

- In case of a single transfer with a packet shorter than the
block size, the HMAC generated is incorrect. This is due to
the "FIRST" bit in AUTH_CFG register not being set.  When calling
HMAC_final for a transfer with a single packet (with no prior HMAC
updates), the "FIRST" and "LAST" bit in AUTH_CFG register needs to
be set. Currently FIRST bit is being cleared incorrectly for all
scenarios.

- In a scenario of a mac key input larger than block size, the key
needs to be hashed. The key hashing operation is crashing. This is
due to a NULL, unintialized pointer to the device handle. This is
fixed by intializing the pointer correctly. Further more, key size
is uninitialized, resulting in corruption of buffer.

Change-Id: Iec736f2130e509fcaf631a2c71c5483514666617
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:02:18 -07:00
Mona Hossain 39569d9e4e crypto: Add device tree support for crypto drivers
Add device tree support for qcedev and qcrypto device drivers.
Add documentations for associated bindings.

Change-Id: Ib76986af5d9e30263a559329acbca401ec3304d2
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2013-09-04 15:01:39 -07:00
Stephen Boyd ee3406fe69 crypto: Add MSM crypto drivers
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
2013-09-04 14:47:05 -07:00
Vakul Garg 85acabeb3c crypto: caam - Fixed the memory out of bound overwrite issue
commit 9c23b7d3d6bda41e2a27375df705485523a96dc8 upstream.

When kernel is compiled with CONFIG_SLUB_DEBUG=y and
CRYPTO_MANAGER_DISABLE_TESTS=n, during kernel bootup, the kernel
reports error given below. The root cause is that in function
hash_digest_key(), for allocating descriptor, insufficient memory was
being allocated. The required number of descriptor words apart from
input and output pointers are 8 (instead of 6).

=============================================================================
BUG dma-kmalloc-32 (Not tainted): Redzone overwritten
-----------------------------------------------------------------------------

Disabling lock debugging due to kernel taint
INFO: 0xdec5dec0-0xdec5dec3. First byte 0x0 instead of 0xcc
INFO: Allocated in ahash_setkey+0x60/0x594 age=7 cpu=1 pid=1257
        __kmalloc+0x154/0x1b4
        ahash_setkey+0x60/0x594
        test_hash+0x260/0x5a0
        alg_test_hash+0x48/0xb0
        alg_test+0x84/0x228
        cryptomgr_test+0x4c/0x54
        kthread+0x98/0x9c
        ret_from_kernel_thread+0x64/0x6c
INFO: Slab 0xc0bd0ba0 objects=19 used=2 fp=0xdec5d0d0 flags=0x0081
INFO: Object 0xdec5dea0 @offset=3744 fp=0x5c200014

Bytes b4 dec5de90: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a
........ZZZZZZZZ
Object dec5dea0: b0 80 00 0a 84 41 00 0d f0 40 00 00 00 67 3f c0
.....A...@...g?.
Object dec5deb0: 00 00 00 50 2c 14 00 50 f8 40 00 00 1e c5 d0 00
...P,..P.@......
Redzone dec5dec0: 00 00 00 14                                      ....
Padding dec5df68: 5a 5a 5a 5a 5a 5a 5a 5a
ZZZZZZZZ
Call Trace:
[dec65b60] [c00071b4] show_stack+0x4c/0x168 (unreliable)
[dec65ba0] [c00d4ec8] check_bytes_and_report+0xe4/0x11c
[dec65bd0] [c00d507c] check_object+0x17c/0x23c
[dec65bf0] [c0550a00] free_debug_processing+0xf4/0x294
[dec65c20] [c0550bdc] __slab_free+0x3c/0x294
[dec65c80] [c03f0744] ahash_setkey+0x4e0/0x594
[dec65cd0] [c01ef138] test_hash+0x260/0x5a0
[dec65e50] [c01ef4c0] alg_test_hash+0x48/0xb0
[dec65e70] [c01eecc4] alg_test+0x84/0x228
[dec65ee0] [c01ec640] cryptomgr_test+0x4c/0x54
[dec65ef0] [c005adc0] kthread+0x98/0x9c
[dec65f40] [c000e1ac] ret_from_kernel_thread+0x64/0x6c
FIX dma-kmalloc-32: Restoring 0xdec5dec0-0xdec5dec3=0xcc

Change-Id: I0c7a1048053e811025d1c3b487940f87345c8f5d
Signed-off-by: Vakul Garg <vakul@freescale.com>
Reviewed-by: Geanta Neag Horia Ioan-B05471 <horia.geanta@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-08-04 16:50:57 +08:00
Linus Torvalds 822b4b6fe3 Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
 "This fixes a build problem in sahara and temporarily disables two new
  optimisations because of performance regressions until a permanent fix
  is ready"

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: sahara - fix building as module
  crypto: blowfish - disable AVX2 implementation
  crypto: twofish - disable AVX2 implementation
2013-06-10 13:25:50 -07:00
Arnd Bergmann 68be0b1ae3 crypto: sahara - fix building as module
The sahara crypto driver has an incorrect MODULE_DEVICE_TABLE, which
prevents us from actually building this driver as a loadable module.

sahara_dt_ids is a of_device_id array, so we have to use
MODULE_DEVICE_TABLE(of, ...).

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Javier Martin <javier.martin@vista-silicon.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2013-06-05 16:36:20 +08:00
Linus Torvalds 30a9e50143 Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
 "This push fixes a crash in the new sha256_ssse3 driver as well as a
  DMA setup/teardown bug in caam"

* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: sha256_ssse3 - fix stack corruption with SSSE3 and AVX implementations
  crypto: caam - fix inconsistent assoc dma mapping direction
2013-05-28 10:09:38 -07:00