Commit Graph

293 Commits

Author SHA1 Message Date
Gilad Ben-Yossef
2c8cdb6b5d staging: ccree: do not map bufs in ahash_init
hash_init was mapping DMA memory that were then being unmap in
hash_digest/final/finup callbacks, which is against the Crypto API
usage rules (see discussion at
https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg30077.html)

Fix it by moving all buffer mapping/unmapping or each Crypto API op.

This also properly deals with hash_import() not knowing if
hash_init was called or not as it now no longer matters.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
9b3044b88e staging: ccree: allocate hash bufs inside req ctx
Move to allocating the buffers needed for requests as part of
the request structure instead of malloc'ing each one on it's
own, making for simpler (and more efficient) code.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
89c2db889d staging: ccree: use array for double buffer
The ccree hash code is using a double buffer to hold data
for processing but manages the buffers and their associated
data count in two separate fields and uses a predicate to
chose which to use.

Move to using a proper 2 members array for a much cleaner code.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
46856e6cf2 staging: ccree: remove unused field
Remove unused struct field.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
327256908d staging: ccree: use Makefile to include PM code
Replace ugly ifdefs with some inline macros and Makefile magic
for optionally including power management related code for
better readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
6e92010b01 staging: ccree: handle end of sg list gracefully
If we are asked for number of entries of an offset bigger than the
sg list we should not crash.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
2f7caf6b02 staging: ccree: check DMA pool buf !NULL before free
If we ran out of DMA pool buffers, we get into the unmap
code path with a NULL before. Deal with this by checking
the virtual mapping is not NULL.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
5ced266469 staging: ccree: failing the suspend is not an error
PM suspend returning a none zero value is not an error. It simply
indicates a suspend is not advised right now so don't treat it as
an error.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
293edc27f8 stating: ccree: revert "staging: ccree: fix leak of import() after init()"
This reverts commit c5f39d0786 ("staging: ccree: fix leak of import()
after init()") and commit aece090244 ("staging: ccree: Uninitialized
return in ssi_ahash_import()").

This is the wrong solution and ends up relying on uninitialized memory,
although it was not obvious to me at the time.

Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:23 +01:00
Gilad Ben-Yossef
7345b14dea staging: ccree: add backlog processing
Crypto API tfm providers are required to provide a backlog
service, if so indicated, that queues up requests in the case
of the provider being busy and processing them later.

The ccree driver did not provide this facility. Add it now.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
0f70db7033 staging: ccree: break send_request and fix ret val
The send_request() function was handling both synchronous
and asynchronous invocations, but were not handling
the asynchronous case, which may be called in an atomic
context, properly as it was sleeping.

Start to fix the problem by breaking up the two use
cases to separate functions calling a common internal
service function and return error instead of sleeping
for the asynchronous case.

The next patch will complete the fix by implementing
proper backlog handling.

Fixes: abefd6741d ("staging: ccree: introduce CryptoCell HW driver").
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
266844f13e staging: ccree: remove unused leftover field
Remove the unused monitor_desc field.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
48520f8cfa staging: ccree: tag debugfs init/exit func properly
The debugfs global init and exit functions were missing
__init and __exit tags, potentially wasting memory.
Fix it by properly tagging them.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
b070ed04c3 staging: ccree: copy larval digest from RAM
The ccree driver was using a DMA operation to copy larval digest
from the ccree SRAM to RAM. Replace it with a simple memcpy.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
1b33fb7aed staging: ccree: pick alloc mem flags based on req flags
The ccree driver was allocating memory using GFP_KERNEL flag
always, ignoring the flags set in the crypto request. Fix it
by choosing gfp flags based on crypto request flags.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
ee70ad833a staging: ccree: remove GFP_DMA flag from mem allocs
Remove bogus GFP_DMA flag from memory allocations. ccree driver
does not operate over an ISA or similar limited bus.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
a3ddcf6604 staging: ccree: fold reg common defines into driver
Fold the 2 macro defined in dx_reg_common.h into the file they
are used in and delete the file.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
977cd76c2d staging: ccree: fold hash defs into queue defs
Fold the two remaining enum in hash defs into the queue defs
that are using them and delete the hash defs include file.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:27:22 +01:00
Gilad Ben-Yossef
70da8241af staging: ccree: SPDXify driver
Replace verbatim GPL v2 copy with SPDX tag.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:26:15 +01:00
Arnd Bergmann
c7fc46fd14 staging: ccree: mark debug_regs[] as static
The global array clashes with an existing symbol of the same name:

drivers/staging/ccree/cc_debugfs.o:(.data+0x0): multiple definition of `debug_regs'
drivers/mmc/host/s3cmci.o:(.data+0x70): first defined here

We should fix both, this one addresses the ccree driver by removing
the symbol from the global namespace.

Fixes: 9bdd203b4d ("s3cmci: add debugfs support for examining driver and hardware state")
Fixes: b3ec9a6736 ("staging: ccree: staging: ccree: replace sysfs by debugfs interface")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08 16:26:15 +01:00
Gilad Ben-Yossef
11cc84e708 staging: ccree: use size_t consistently
Fix declaration, implementation and wrapper function to use
the same size_t type we actually define the parameter to be.

Fixes: 3f268f5d66 ("staging: ccree: turn compile time debug log to params")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-20 08:41:16 +01:00
Kamal Heib
ac3c7776b1 Staging: ccree: Add blank line after declarations
This patch adds a blank line after declarations to
improve code readability.

Issue find by checkpatch.pl script.
WARNING: Missing a blank line after declarations

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
5cba3082ff staging: ccree: update TODO
Update TODO with handling on sysfs -> debugfs transition

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
dc5591dc9c staging: ccree: fix fips event irq handling build
When moving from internal for kernel FIPS infrastructure the FIPS event irq
handling code was left with the old ifdef by mistake. Fix it.

Fixes: b7e607bf33 ("staging: ccree: move FIPS support to kernel infrastructure")
Cc: stable@vger.kernel.org
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
a92d24a8bc staging: ccree: remove ssi_config.h
Now that the only thing left in ssi_config is the maximum
DMA mask length we get move that to ssi_driver.h and get
rid of the file.

All of ccree is now runtime configurable or under Kbuild control.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
3f268f5d66 staging: ccree: turn compile time debug log to params
The ccree driver has some support to dump runtime data
to kernel log to assist in debugging. The code used to be
enabled by a build time flag. Refactor to enable it via
module/kernel parameters.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
829def3312 staging: ccree: remove useless debug code
Remove a bunch of useless debug code ifdef'ed out

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:54 +01:00
Gilad Ben-Yossef
96e31ecc62 staging: ccree: remove CC_IRQ_DELAY dead code
Remove dead code from older version which is not supported in current
hardware.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
b3ec9a6736 staging: ccree: staging: ccree: replace sysfs by debugfs interface
The ccree driver has had a none standard sysfs interface for debugging.
Replace it with a proper debugfs interface.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
31aeaca4d2 staging: ccree: add explicit module init/exit func
We need to do a module global scope init/exit operation to support
the debugfs interface we are about to introduce in the next patch,
so wean the module of the boiler plate saving macro as it will no
longer be sufficient.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
4ba5895bd3 staging: ccree: clean up PM registration
Clean up power management registration.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Gilad Ben-Yossef
16bcccb774 staging: ccree: drop ifdef CONFIG_OF in code
As we already depend on CONFIG_OF via Kconfig no need to
support conditional build without it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-19 15:15:53 +01:00
Greg Kroah-Hartman
7f9d04bc56 Merge 4.15-rc4 into staging-next
We want the staging fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-18 09:12:51 +01:00
Gilad Ben-Yossef
6dc4d30252 staging: ccree: fix FIPS mgr naming convention
The FIPS manager files were using a naming convention which was
inconsistent (ssi vs. cc) and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
e24673641e staging: ccree: simplify freeing SRAM memory address
The code freeing the SRAM memory address was zeroing the address
on release although there is nothing secret about it. Simplify
the code by simply calling kfree directly.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
7358733a5c staging: ccree: fix sram mgr naming convention
The SRAM manager files were using a naming convention which was
inconsistent (ssi vs. cc) and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
84d39a90b8 staging: ccree: fix buf mgr naming convention
The buffer manager files were using a func naming convention which was
inconsistent (ssi vs. cc) and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
961559f317 staging: ccree: rename vars/structs/enums from ssi_ to cc_
Unify naming convention by renaming all ssi_ vars/structs/enums
and variables to cc_*

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
9021a014bd staging: ccree: rename all DX to CC
Unify naming convention by renaming all DX macros to CC.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
d79da0aad0 staging: ccree: rename all SSI to CC
Unify naming convention by renaming all SSI macros to CC.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
6fe633e909 staging: ccree: remove SSI_CC_HAS_ macros
Remove macro controlling build of various features. This
needs to happen dynamically in registration time.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
60c926321e staging: ccree: drop unsupported MULTI2 mode code
Remove the code support for MULTI2 mode which is not supported
by the current hardware.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
752145b57e staging: ccree: fix ivgen func def coding style
Fix ivgen functions definition indentation according to coding
style guide lines for better code readability

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
a6df50dc0b staging: ccree: fix ivgen naming convention
The ivgen files were using a func naming convention which was
inconsistent (ssi vs. cc), included a long prefix (ssi_ivgen)
and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
200f806475 staging: ccree: fix cipher func def coding style
Fix cipher functions definition indentation according to coding
style guide lines for better code readability

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:38 +01:00
Gilad Ben-Yossef
aebae88197 staging: ccree: fix cipher naming convention
The blkcipher files were using a func naming convention which was
inconsistent (ssi vs. cc), included a long prefix (ssi_ablkcipher)
and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:37 +01:00
Gilad Ben-Yossef
3d035ae090 staging: ccree: remove cipher sync blkcipher remains
Remove the remains of no longer existing support for running
blkcipher is sync mode.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:37 +01:00
Gilad Ben-Yossef
fc2a36c065 staging: ccree: fix req mgr func def coding style
Fix request manager functions definition indentation according to coding
style guide lines for better code readability

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:37 +01:00
Gilad Ben-Yossef
5af4f8349c staging: ccree: fix reg mgr naming convention
The request manager files were using a func naming convention which was
inconsistent (ssi vs. cc), included a useless prefix (ssi_request_mgr)
and often too long.

Make the code more readable by switching to a simpler, consistent naming
convention.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:37 +01:00
Gilad Ben-Yossef
51eef6c175 staging: ccree: fix func call param indentation
Fix function call parameter indentation according to coding
style guide lines.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-13 12:39:37 +01:00