[PATCH v3 2/3] hwrng: stm32 - add support for STM32 HW RNG

2015-10-14 Thread Daniel Thompson
Add support for STMicroelectronics STM32 random number generator.

The config value defaults to N, reflecting the fact that STM32 is a
very low resource microcontroller platform and unlikely to be targeted
by any "grown up" defconfigs.

Signed-off-by: Daniel Thompson 
Reviewed-by: Linus Walleij 
---
 drivers/char/hw_random/Kconfig |  12 +++
 drivers/char/hw_random/Makefile|   1 +
 drivers/char/hw_random/stm32-rng.c | 202 +
 3 files changed, 215 insertions(+)
 create mode 100644 drivers/char/hw_random/stm32-rng.c

diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index f48cf11c655e..7930cc9b719c 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -359,6 +359,18 @@ config HW_RANDOM_XGENE
 
  If unsure, say Y.
 
+config HW_RANDOM_STM32
+   tristate "STMicroelectronics STM32 random number generator"
+   depends on HW_RANDOM && (ARCH_STM32 || COMPILE_TEST)
+   help
+ This driver provides kernel-side support for the Random Number
+ Generator hardware found on STM32 microcontrollers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called stm32-rng.
+
+ If unsure, say N.
+
 endif # HW_RANDOM
 
 config UML_RANDOM
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index 055bb01510ad..8b49c0f7abb1 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o
 obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o
 obj-$(CONFIG_HW_RANDOM_MSM) += msm-rng.o
 obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o
+obj-$(CONFIG_HW_RANDOM_STM32) += stm32-rng.o
diff --git a/drivers/char/hw_random/stm32-rng.c 
b/drivers/char/hw_random/stm32-rng.c
new file mode 100644
index ..92a810648bd0
--- /dev/null
+++ b/drivers/char/hw_random/stm32-rng.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2015, Daniel Thompson
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RNG_CR 0x00
+#define RNG_CR_RNGEN BIT(2)
+
+#define RNG_SR 0x04
+#define RNG_SR_SEIS BIT(6)
+#define RNG_SR_CEIS BIT(5)
+#define RNG_SR_DRDY BIT(0)
+
+#define RNG_DR 0x08
+
+/*
+ * It takes 40 cycles @ 48MHz to generate each random number (e.g. <1us).
+ * At the time of writing STM32 parts max out at ~200MHz meaning a timeout
+ * of 500 leaves us a very comfortable margin for error. The loop to which
+ * the timeout applies takes at least 4 instructions per iteration so the
+ * timeout is enough to take us up to multi-GHz parts!
+ */
+#define RNG_TIMEOUT 500
+
+struct stm32_rng_private {
+   struct hwrng rng;
+   void __iomem *base;
+   struct clk *clk;
+};
+
+static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
+{
+   struct stm32_rng_private *priv =
+   container_of(rng, struct stm32_rng_private, rng);
+   u32 sr;
+   int retval = 0;
+
+   pm_runtime_get_sync((struct device *) priv->rng.priv);
+
+   while (max > sizeof(u32)) {
+   sr = readl_relaxed(priv->base + RNG_SR);
+   if (!sr && wait) {
+   unsigned int timeout = RNG_TIMEOUT;
+
+   do {
+   cpu_relax();
+   sr = readl_relaxed(priv->base + RNG_SR);
+   } while (!sr && --timeout);
+   }
+
+   /* If error detected or data not ready... */
+   if (sr != RNG_SR_DRDY)
+   break;
+
+   *(u32 *)data = readl_relaxed(priv->base + RNG_DR);
+
+   retval += sizeof(u32);
+   data += sizeof(u32);
+   max -= sizeof(u32);
+   }
+
+   if (WARN_ONCE(sr & (RNG_SR_SEIS | RNG_SR_CEIS),
+ "bad RNG status - %x\n", sr))
+   writel_relaxed(0, priv->base + RNG_SR);
+
+   pm_runtime_mark_last_busy((struct device *) priv->rng.priv);
+   pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv);
+
+   return retval || !wait ? retval : -EIO;
+}
+
+static int stm32_rng_init(struct hwrng *rng)
+{
+   struct stm32_rng_private *priv =
+   container_of(rng, struct stm32_rng_private, rng);
+   int err;
+
+   err = 

Re: [PATCH] crypto: mxs-dcp is an stmp device

2015-10-14 Thread Herbert Xu
On Mon, Oct 12, 2015 at 03:52:34PM +0200, Arnd Bergmann wrote:
> The mxs-dcp driver relies on the stmp_reset_block() helper function, which
> is provided by CONFIG_STMP_DEVICE. This symbol is always set on MXS,
> but the driver can now also be built for MXC (i.MX6), which results
> in a built error if no other driver selects STMP_DEVICE:
> 
> drivers/built-in.o: In function `mxs_dcp_probe':
> vf610-ocotp.c:(.text+0x3df302): undefined reference to `stmp_reset_block'
> 
> This adds the 'select', like all other stmp drivers have it.
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: a2712e6c75f ("crypto: mxs-dcp - Allow MXS_DCP to be used on MX6SL")

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] crypto: atmel: use devm_xxx() managed function

2015-10-14 Thread Herbert Xu
On Mon, Oct 12, 2015 at 07:47:03PM +0200, LABBE Corentin wrote:
> Using the devm_xxx() managed function to stripdown the error and remove
> code.
> 
> Signed-off-by: LABBE Corentin 

Both applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/3] hwrng: stm32 - add support for STM32 HW RNG

2015-10-14 Thread Daniel Thompson
This patchset introduces a driver for the STM32 hardware random number
generator.

Herbert: I have assumed the v2 version is *so* badly broken (sorry
 again for that) that you would probably choose to remove v2
 completely and replace it with v3. In a moment I will also
 post a patch to fix the build without ripping out v2. Choose
 whichever suits you best.

v3:

 * Fixed build with CONFIG_PM (Fengguang Wu). Runtime tested as normal
   and also build tested on stm32 (which has CONFIG_PM set) and on
   x86/COMPILE_TEST with and without CONFIG_PM.

v2:

 * Moved binding docs from .../hwrng/ to .../rng/ and renamed to match
   convention in new directory (Rob Herring).
 * Adopted runtime PM and auto-suspend instead of managing the clocks
   from the read function (Linus Walleij). Increased bandwidth by ~30%.
 * Simplified error detection in main read loop (Linus Walleij, Maxime
   Coquelin).
 * Only WARN_ONCE() when hardware failure mechanisms trigger (Maxime
   Coquelin).
 * Simplify end of probe function after cocci warning (Fengguang Wu).
 * Switch to devm_hwrng_register.


Daniel Thompson (3):
  dt-bindings: Document the STM32 HW RNG bindings
  hwrng: stm32 - add support for STM32 HW RNG
  ARM: dts: stm32f429: Adopt STM32 RNG driver

 .../devicetree/bindings/rng/st,stm32-rng.txt   |  21 +++
 arch/arm/boot/dts/stm32f429.dtsi   |   7 +
 drivers/char/hw_random/Kconfig |  12 ++
 drivers/char/hw_random/Makefile|   1 +
 drivers/char/hw_random/stm32-rng.c | 202 +
 5 files changed, 243 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rng/st,stm32-rng.txt
 create mode 100644 drivers/char/hw_random/stm32-rng.c

--
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] dt-bindings: Document the STM32 HW RNG bindings

2015-10-14 Thread Daniel Thompson
This adds documentation of device tree bindings for the STM32 hardware
random number generator.

Signed-off-by: Daniel Thompson 
Acked-by: Maxime Coquelin 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/rng/st,stm32-rng.txt| 21 +
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rng/st,stm32-rng.txt

diff --git a/Documentation/devicetree/bindings/rng/st,stm32-rng.txt 
b/Documentation/devicetree/bindings/rng/st,stm32-rng.txt
new file mode 100644
index ..47f04176f93b
--- /dev/null
+++ b/Documentation/devicetree/bindings/rng/st,stm32-rng.txt
@@ -0,0 +1,21 @@
+STMicroelectronics STM32 HW RNG
+===
+
+The STM32 hardware random number generator is a simple fixed purpose IP and
+is fully separated from other crypto functions.
+
+Required properties:
+
+- compatible : Should be "st,stm32-rng"
+- reg : Should be register base and length as documented in the datasheet
+- interrupts : The designated IRQ line for the RNG
+- clocks : The clock needed to enable the RNG
+
+Example:
+
+   rng: rng@50060800 {
+   compatible = "st,stm32-rng";
+   reg = <0x50060800 0x400>;
+   interrupts = <80>;
+   clocks = < 0 38>;
+   };
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] ARM: dts: stm32f429: Adopt STM32 RNG driver

2015-10-14 Thread Daniel Thompson
New bindings and driver have been created for STM32 series parts. This
patch integrates this changes.

Signed-off-by: Daniel Thompson 
Acked-by: Maxime Coquelin 
---
 arch/arm/boot/dts/stm32f429.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index cb0613090243..90081fc22c6c 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -175,6 +175,13 @@
reg = <0x40023800 0x400>;
clocks = <_hse>;
};
+
+   rng: rng@50060800 {
+   compatible = "st,stm32-rng";
+   reg = <0x50060800 0x400>;
+   interrupts = <80>;
+   clocks = < 0 38>;
+   };
};
 };
 
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] crypto: keywrap - add testmgr support

2015-10-14 Thread Herbert Xu
On Mon, Sep 21, 2015 at 08:59:56PM +0200, Stephan Mueller wrote:
>
> + .iv_out = "\x03\x1f\x6b\xd7\xe6\x1e\x64\x3d",
> + },
> +};

This doesn't build.  Please fix and resubmit.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto/pkcs7_verify: Fix unaligned access in pkcs7_verify()

2015-10-14 Thread Herbert Xu
On Tue, Oct 13, 2015 at 10:54:01AM -0400, Sowmini Varadhan wrote:
> 
> On sparc, we see unaligned access messages on each modprobe[-r]:
> 
> Kernel unaligned access at TPC[6ad9b4] pkcs7_verify [..]
> Kernel unaligned access at TPC[6a5484] crypto_shash_finup [..]
> Kernel unaligned access at TPC[6a5390] crypto_shash_update [..]
> Kernel unaligned access at TPC[10150308] sha1_sparc64_update [..]
> Kernel unaligned access at TPC[101501ac] __sha1_sparc64_update [..]
> 
> These ware triggered by mod_verify_sig() invocations of pkcs_verify(), and
> are are being caused by an unaligned desc at (sha1, digest_size is 0x14)
> desc = digest + digest_size;
> 
> To fix this, pkcs7_verify needs to make sure that desc is pointing
> at an aligned value past the digest_size, and kzalloc appropriately,
> taking alignment values into consideration.
> 
> Signed-off-by: Sowmini Varadhan 

Patch applied.  Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3] crypto/nx842: Add CRC and validation support

2015-10-14 Thread Herbert Xu
On Thu, Oct 08, 2015 at 01:45:51PM -0700, Haren Myneni wrote:
> 
> This patch adds CRC generation and validation support for nx-842.
> Add CRC flag so that nx842 coprocessor includes CRC during compression
> and validates during decompression.
> 
> Also changes in 842 SW compression to append CRC value at the end
> of template and checks during decompression.
> 
> Signed-off-by: Haren Myneni 

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] hwrng: stm32 - add support for STM32 HW RNG

2015-10-14 Thread Herbert Xu
On Mon, Oct 12, 2015 at 09:21:27AM +0100, Daniel Thompson wrote:
> This patchset introduces a driver for the STM32 hardware random number
> generator.
> 
> v2:
> 
>  * Moved binding docs from .../hwrng/ to .../rng/ and renamed to match
>convention in new directory (Rob Herring).
>  * Adopted runtime PM and auto-suspend instead of managing the clocks
>from the read function (Linus Walleij). Increased bandwidth by ~30%.
>  * Simplified error detection in main read loop (Linus Walleij, Maxime
>Coquelin).
>  * Only WARN_ONCE() when hardware failure mechanisms trigger (Maxime
>Coquelin).
>  * Simplify end of probe function after cocci warning (Fengguang Wu).
>  * Switch to devm_hwrng_register.

All applied.  Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] hwrng: stm32 - Fix build with CONFIG_PM

2015-10-14 Thread Daniel Thompson
Commit c6a97c42e399 ("hwrng: stm32 - add support for STM32 HW RNG")
was inadequately tested (actually it was tested quite hard so
incompetent would be a better description that inadequate) and does
not compile on platforms with CONFIG_PM set.

Fix this.

Signed-off-by: Daniel Thompson 
---

Notes:
Herbert: This is the diff between v2 and v3 of my STM32 HW RNG
 patch. This is partly reassurance of what has changed
 and also "just in case" you prefer to simply fix the
 problem.

 drivers/char/hw_random/stm32-rng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/stm32-rng.c 
b/drivers/char/hw_random/stm32-rng.c
index 7fa3656a5fc5..92a810648bd0 100644
--- a/drivers/char/hw_random/stm32-rng.c
+++ b/drivers/char/hw_random/stm32-rng.c
@@ -160,7 +160,7 @@ static int stm32_rng_probe(struct platform_device *ofdev)
 #ifdef CONFIG_PM
 static int stm32_rng_runtime_suspend(struct device *dev)
 {
-   struct stm32_rng_private *priv = dev_get_drvdata(pdev);
+   struct stm32_rng_private *priv = dev_get_drvdata(dev);

stm32_rng_cleanup(>rng);

@@ -169,7 +169,7 @@ static int stm32_rng_runtime_suspend(struct device *dev)

 static int stm32_rng_runtime_resume(struct device *dev)
 {
-   struct stm32_rng_private *priv = dev_get_drvdata(pdev);
+   struct stm32_rng_private *priv = dev_get_drvdata(dev);

return stm32_rng_init(>rng);
 }
--
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[cryptodev:master 62/67] drivers/char/hw_random/stm32-rng.c:163:51: error: 'pdev' undeclared

2015-10-14 Thread kbuild test robot
tree:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
head:   62f57d05e287e950c6e1246b1dba08e12985195a
commit: c6a97c42e399ad0d639f616e58e13f0b4ae87626 [62/67] hwrng: stm32 - add 
support for STM32 HW RNG
config: i386-allmodconfig (attached as .config)
reproduce:
git checkout c6a97c42e399ad0d639f616e58e13f0b4ae87626
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/char/hw_random/stm32-rng.c: In function 'stm32_rng_runtime_suspend':
>> drivers/char/hw_random/stm32-rng.c:163:51: error: 'pdev' undeclared (first 
>> use in this function)
 struct stm32_rng_private *priv = dev_get_drvdata(pdev);
  ^
   drivers/char/hw_random/stm32-rng.c:163:51: note: each undeclared identifier 
is reported only once for each function it appears in
   drivers/char/hw_random/stm32-rng.c: In function 'stm32_rng_runtime_resume':
   drivers/char/hw_random/stm32-rng.c:172:51: error: 'pdev' undeclared (first 
use in this function)
 struct stm32_rng_private *priv = dev_get_drvdata(pdev);
  ^

vim +/pdev +163 drivers/char/hw_random/stm32-rng.c

   157  return devm_hwrng_register(dev, >rng);
   158  }
   159  
   160  #ifdef CONFIG_PM
   161  static int stm32_rng_runtime_suspend(struct device *dev)
   162  {
 > 163  struct stm32_rng_private *priv = dev_get_drvdata(pdev);
   164  
   165  stm32_rng_cleanup(>rng);
   166  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH v4 0/8] zram: introduce contextless compression API and use it on zram

2015-10-14 Thread Joonsoo Kim
This patchset introduce contextless compression API and use it on zram in
order to support more compression algorithm without more overhead.

The reason we need to support vairous compression algorithms is that
zram's performance is highly depend on workload and compression algorithm
and architecture. Every compression algorithm has it's own strong point.
For example, zlib is the best for compression ratio, but, it's
(de)compression speed is rather slow. Against my expectation, in my kernel
build test with zram swap, in low-memory condition on x86, zlib shows best
performance than others. In this case, I guess that compression ratio is
the most important factor.

Kernel build elapsed time in QEMU 8 CPUs 448 MB with zram swap
lzo : deflate
188.3 s : 181.9 s
(3% improvement)

Unlike this situation, on ARM, maybe fast (de)compression speed is
the most important because it's computation speed is slower than x86.

Anyway, there is a concern from Sergey to use crypto API in zram. Current
crypto API has a limitation that always require tfm object to (de)compress
something because some of (de)compression function requires scratch buffer
embedded on tfm even if some of (de)compression function doesn't
require it. Due to above reason, using crypto API rather than calling
compression library directly causes more memory footprint and this is
why zram doesn't use crypto API before.

To solve this problem, this patchset introduce contextless compression API.
This new compression API doesn't require user to use tfm one by one.
Tfm is only used for distinguishing compression algorithm and maybe
keeping algorithm parameter so can be used concurrently. Context is now
separate from tfm and user needs to allocate and manage it separately.
With this separation, we can save memory in some cases and get the best
performance.

This patchset solves Sergey's concern perfectly and provides possibility
to use various compression algorithm in zram.

Thanks.

Joonsoo Kim (6):
  crypto/compress: introduce contextless compression and remove unused
pcomp
  crypto/lzo: support contextless compression API
  crypto/lz4: support contextless compressiona API
  crypto/deflate: support contextless compression API
  zram: use crypto contextless compression API to (de)compress
  zram: enable contextless compression alg in zram

Sergey Senozhatsky (2):
  zram: make stream find and release functions static
  zram: pass zstrm down to decompression path

 Documentation/blockdev/zram.txt|  29 ++-
 crypto/Kconfig |  18 +-
 crypto/Makefile|   3 +-
 crypto/ccompress.c |  95 +
 crypto/deflate.c   |  96 +-
 crypto/lz4.c   |  77 +++-
 crypto/lzo.c   |  81 ++--
 crypto/pcompress.c | 115 ---
 crypto/zlib.c  | 381 -
 drivers/block/zram/Kconfig |  13 +-
 drivers/block/zram/Makefile|   4 +-
 drivers/block/zram/zcomp.c | 104 ++
 drivers/block/zram/zcomp.h |  32 ++--
 drivers/block/zram/zram_drv.c  |  33 +++-
 include/crypto/compress.h  | 118 
 include/crypto/internal/compress.h |  28 ---
 include/linux/crypto.h |   2 +-
 17 files changed, 488 insertions(+), 741 deletions(-)
 create mode 100644 crypto/ccompress.c
 delete mode 100644 crypto/pcompress.c
 delete mode 100644 crypto/zlib.c
 delete mode 100644 include/crypto/internal/compress.h

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 4/8] crypto/deflate: support contextless compression API

2015-10-14 Thread kbuild test robot
Hi Joonsoo,

[auto build test ERROR on next-20151013 -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Joonsoo-Kim/zram-introduce-contextless-compression-API-and-use-it-on-zram/20151014-154649
config: i386-randconfig-i0-201541 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   crypto/built-in.o: In function `deflate_mod_fini':
>> deflate.c:(.exit.text+0x2a0): undefined reference to 
>> `crypto_unregister_ccomp'
   crypto/built-in.o: In function `deflate_mod_init':
>> deflate.c:(.init.text+0x525): undefined reference to `crypto_register_ccomp'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v3 1/3] crypto: add key wrapping block chaining mode

2015-10-14 Thread Herbert Xu
On Mon, Sep 21, 2015 at 08:58:23PM +0200, Stephan Mueller wrote:
>
> +/*
> + * Fast forward the SGL to the "end" length minus SEMIBSIZE.
> + * The start in the SGL defined by the fast-forward is returned with
> + * the walk variable
> + */
> +static void crypto_kw_scatterlist_ff(struct scatter_walk *walk,
> +  struct scatterlist *sg,
> +  unsigned int end)
> +{
> + unsigned int skip = 0;
> +
> + /* The caller should only operate on full SEMIBLOCKs. */
> + BUG_ON(end < SEMIBSIZE);
> +
> + skip = end - SEMIBSIZE;
> + while (sg) {
> + if (sg->length > skip) {
> + scatterwalk_start(walk, sg);
> + scatterwalk_advance(walk, skip);
> + break;
> + } else
> + skip -= sg->length;
> +
> + sg = sg_next(sg);
> + }
> +}

This looks very slow but it's conceptually nice and I like it :)
I'll apply this today.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/8] crypto/lz4: support contextless compressiona API

2015-10-14 Thread Joonsoo Kim
Now, contextless compression API is introduced and it can reduce
memory overhead in some cases. All compression algorithm will
support it.

Signed-off-by: Joonsoo Kim 
---
 crypto/lz4.c | 77 
 1 file changed, 67 insertions(+), 10 deletions(-)

diff --git a/crypto/lz4.c b/crypto/lz4.c
index aefbcea..9720409 100644
--- a/crypto/lz4.c
+++ b/crypto/lz4.c
@@ -23,36 +23,53 @@
 #include 
 #include 
 #include 
+#include 
 
 struct lz4_ctx {
void *lz4_comp_mem;
 };
 
+static void *lz4_alloc_context(struct crypto_ccomp *tfm)
+{
+   void *ctx;
+
+   ctx = vmalloc(LZ4_MEM_COMPRESS);
+   if (!ctx)
+   return ERR_PTR(-ENOMEM);
+
+   return ctx;
+}
+
 static int lz4_init(struct crypto_tfm *tfm)
 {
struct lz4_ctx *ctx = crypto_tfm_ctx(tfm);
 
-   ctx->lz4_comp_mem = vmalloc(LZ4_MEM_COMPRESS);
-   if (!ctx->lz4_comp_mem)
+   ctx->lz4_comp_mem = lz4_alloc_context(NULL);
+   if (IS_ERR(ctx->lz4_comp_mem))
return -ENOMEM;
 
return 0;
 }
 
+static void lz4_free_context(struct crypto_ccomp *tfm, void *ctx)
+{
+   vfree(ctx);
+}
+
 static void lz4_exit(struct crypto_tfm *tfm)
 {
struct lz4_ctx *ctx = crypto_tfm_ctx(tfm);
-   vfree(ctx->lz4_comp_mem);
+
+   lz4_free_context(NULL, ctx->lz4_comp_mem);
 }
 
-static int lz4_compress_crypto(struct crypto_tfm *tfm, const u8 *src,
-   unsigned int slen, u8 *dst, unsigned int *dlen)
+static int __lz4_compress_crypto(const u8 *src, unsigned int slen,
+   u8 *dst, unsigned int *dlen, void *ctx)
 {
-   struct lz4_ctx *ctx = crypto_tfm_ctx(tfm);
size_t tmp_len = *dlen;
int err;
 
-   err = lz4_compress(src, slen, dst, _len, ctx->lz4_comp_mem);
+   err = lz4_compress(src, slen, dst, _len, ctx);
 
if (err < 0)
return -EINVAL;
@@ -61,8 +78,16 @@ static int lz4_compress_crypto(struct crypto_tfm *tfm, const 
u8 *src,
return 0;
 }
 
-static int lz4_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
- unsigned int slen, u8 *dst, unsigned int *dlen)
+static int lz4_compress_crypto(struct crypto_tfm *tfm, const u8 *src,
+   unsigned int slen, u8 *dst, unsigned int *dlen)
+{
+   struct lz4_ctx *ctx = crypto_tfm_ctx(tfm);
+
+   return __lz4_compress_crypto(src, slen, dst, dlen, ctx->lz4_comp_mem);
+}
+
+static int __lz4_decompress_crypto(const u8 *src, unsigned int slen,
+   u8 *dst, unsigned int *dlen, void *ctx)
 {
int err;
size_t tmp_len = *dlen;
@@ -76,6 +101,12 @@ static int lz4_decompress_crypto(struct crypto_tfm *tfm, 
const u8 *src,
return err;
 }
 
+static int lz4_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
+ unsigned int slen, u8 *dst, unsigned int *dlen)
+{
+   return __lz4_decompress_crypto(src, slen, dst, dlen, NULL);
+}
+
 static struct crypto_alg alg_lz4 = {
.cra_name   = "lz4",
.cra_flags  = CRYPTO_ALG_TYPE_COMPRESS,
@@ -89,14 +120,40 @@ static struct crypto_alg alg_lz4 = {
.coa_decompress = lz4_decompress_crypto } }
 };
 
+static struct ccomp_alg ccomp = {
+   .alloc_context  = lz4_alloc_context,
+   .free_context   = lz4_free_context,
+   .compress   = __lz4_compress_crypto,
+   .decompress = __lz4_decompress_crypto,
+   .flags  = CCOMP_TYPE_DECOMP_NOCTX,
+   .base   = {
+   .cra_name   = "lz4",
+   .cra_flags  = CRYPTO_ALG_TYPE_CCOMPRESS,
+   .cra_module = THIS_MODULE,
+   }
+};
+
 static int __init lz4_mod_init(void)
 {
-   return crypto_register_alg(_lz4);
+   int ret;
+
+   ret = crypto_register_alg(_lz4);
+   if (ret)
+   return ret;
+
+   ret = crypto_register_ccomp();
+   if (ret) {
+   crypto_unregister_alg(_lz4);
+   return ret;
+   }
+
+   return ret;
 }
 
 static void __exit lz4_mod_fini(void)
 {
crypto_unregister_alg(_lz4);
+   crypto_unregister_ccomp();
 }
 
 module_init(lz4_mod_init);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 3/8] crypto/lz4: support contextless compressiona API

2015-10-14 Thread kbuild test robot
Hi Joonsoo,

[auto build test ERROR on next-20151013 -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Joonsoo-Kim/zram-introduce-contextless-compression-API-and-use-it-on-zram/20151014-154649
config: i386-randconfig-s1-201541 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   crypto/built-in.o: In function `lz4_mod_fini':
>> lz4.c:(.exit.text+0x249): undefined reference to `crypto_unregister_ccomp'
   crypto/built-in.o: In function `lz4_mod_init':
>> lz4.c:(.init.text+0x2f5): undefined reference to `crypto_register_ccomp'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH v4 4/8] crypto/deflate: support contextless compression API

2015-10-14 Thread Joonsoo Kim
Now, contextless compression API is introduced and it can reduce
memory overhead in some cases. All compression algorithm will
support it.

Signed-off-by: Joonsoo Kim 
---
 crypto/deflate.c | 96 ++--
 1 file changed, 86 insertions(+), 10 deletions(-)

diff --git a/crypto/deflate.c b/crypto/deflate.c
index 95d8d37..7070438 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DEFLATE_DEF_LEVEL  Z_DEFAULT_COMPRESSION
 #define DEFLATE_DEF_WINBITS11
@@ -101,9 +102,8 @@ static void deflate_decomp_exit(struct deflate_ctx *ctx)
vfree(ctx->decomp_stream.workspace);
 }
 
-static int deflate_init(struct crypto_tfm *tfm)
+static int __deflate_init(void *ctx)
 {
-   struct deflate_ctx *ctx = crypto_tfm_ctx(tfm);
int ret;
 
ret = deflate_comp_init(ctx);
@@ -116,19 +116,54 @@ out:
return ret;
 }
 
-static void deflate_exit(struct crypto_tfm *tfm)
+static void *deflate_alloc_context(struct crypto_ccomp *tfm)
+{
+   void *ctx;
+   int ret;
+
+   ctx = kzalloc(sizeof(struct deflate_ctx), GFP_KERNEL);
+   if (!ctx)
+   return ERR_PTR(-ENOMEM);
+
+   ret = __deflate_init(ctx);
+   if (ret) {
+   kfree(ctx);
+   return ERR_PTR(ret);
+   }
+
+   return ctx;
+}
+
+static int deflate_init(struct crypto_tfm *tfm)
 {
struct deflate_ctx *ctx = crypto_tfm_ctx(tfm);
 
+   return __deflate_init(ctx);
+}
+
+static void __deflate_exit(void *ctx)
+{
deflate_comp_exit(ctx);
deflate_decomp_exit(ctx);
 }
 
-static int deflate_compress(struct crypto_tfm *tfm, const u8 *src,
-   unsigned int slen, u8 *dst, unsigned int *dlen)
+static void deflate_free_context(struct crypto_ccomp *tfm, void *ctx)
+{
+   __deflate_exit(ctx);
+}
+
+static void deflate_exit(struct crypto_tfm *tfm)
+{
+   struct deflate_ctx *ctx = crypto_tfm_ctx(tfm);
+
+   __deflate_exit(ctx);
+}
+
+static int __deflate_compress(const u8 *src, unsigned int slen,
+   u8 *dst, unsigned int *dlen, void *ctx)
 {
int ret = 0;
-   struct deflate_ctx *dctx = crypto_tfm_ctx(tfm);
+   struct deflate_ctx *dctx = ctx;
struct z_stream_s *stream = >comp_stream;
 
ret = zlib_deflateReset(stream);
@@ -153,12 +188,20 @@ out:
return ret;
 }
 
-static int deflate_decompress(struct crypto_tfm *tfm, const u8 *src,
- unsigned int slen, u8 *dst, unsigned int *dlen)
+static int deflate_compress(struct crypto_tfm *tfm, const u8 *src,
+   unsigned int slen, u8 *dst, unsigned int *dlen)
+{
+   struct deflate_ctx *dctx = crypto_tfm_ctx(tfm);
+
+   return __deflate_compress(src, slen, dst, dlen, dctx);
+}
+
+static int __deflate_decompress(const u8 *src, unsigned int slen,
+   u8 *dst, unsigned int *dlen, void *ctx)
 {
 
int ret = 0;
-   struct deflate_ctx *dctx = crypto_tfm_ctx(tfm);
+   struct deflate_ctx *dctx = ctx;
struct z_stream_s *stream = >decomp_stream;
 
ret = zlib_inflateReset(stream);
@@ -194,6 +237,14 @@ out:
return ret;
 }
 
+static int deflate_decompress(struct crypto_tfm *tfm, const u8 *src,
+ unsigned int slen, u8 *dst, unsigned int *dlen)
+{
+   struct deflate_ctx *dctx = crypto_tfm_ctx(tfm);
+
+   return __deflate_compress(src, slen, dst, dlen, dctx);
+}
+
 static struct crypto_alg alg = {
.cra_name   = "deflate",
.cra_flags  = CRYPTO_ALG_TYPE_COMPRESS,
@@ -206,14 +257,39 @@ static struct crypto_alg alg = {
.coa_decompress = deflate_decompress } }
 };
 
+static struct ccomp_alg ccomp = {
+   .alloc_context  = deflate_alloc_context,
+   .free_context   = deflate_free_context,
+   .compress   = __deflate_compress,
+   .decompress = __deflate_decompress,
+   .base   = {
+   .cra_name   = "deflate",
+   .cra_flags  = CRYPTO_ALG_TYPE_CCOMPRESS,
+   .cra_module = THIS_MODULE,
+   }
+};
+
 static int __init deflate_mod_init(void)
 {
-   return crypto_register_alg();
+   int ret;
+
+   ret = crypto_register_alg();
+   if (ret)
+   return ret;
+
+   ret = crypto_register_ccomp();
+   if (ret) {
+   crypto_unregister_alg();
+   return ret;
+   }
+
+   return ret;
 }
 
 static void __exit deflate_mod_fini(void)
 {
crypto_unregister_alg();
+   crypto_unregister_ccomp();
 }
 
 module_init(deflate_mod_init);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[PATCH v4 1/8] crypto/compress: introduce contextless compression and remove unused pcomp

2015-10-14 Thread Joonsoo Kim
Until now, tfm for crypto compression embeds (de)compression context.
According to (de)compression algorithm, requirement on context varys but
to be safe to use (de)compression API, tfm should be passed to
(de)compression API one by one.

This causes unbearable overhead in some cases. For example, if someone
want to decompress 100 data in parallel with LZO, 100 tfms are needed and
it causes large memory overhead. But, LZO algorithm doesn't require
context in decompress so if we directly use decompress on LZO lib we don't
need 100 contexts in tfms thus there is no memory overhead.

This patch tries to fix this problem by introducing new compression API,
contextless compression. Although above problem can be solved by some
modifications on existing compression API, but, crypto maintainer, Herbert
recommends introducing new API because existing compression API
is obsolete.

This new compression API doesn't require user to use tfm one by one.
Tfm is only used for distinguish compression algorithm and maybe keeping
algorithm parameter so can be used concurrently. Context is now separate
from tfm and user needs to allocate and manage it separately.

crypto_ccomp_decomp_noctx() is provided to distinguish compression
algorithm which doesn't require context in decompression. If context isn't
needed, user can decompress something without passing allocated context
and can get maximum performance without additional memory overhead.

This API will be used in zram in following patches.

Signed-off-by: Joonsoo Kim 
---
 crypto/Kconfig |  17 +-
 crypto/Makefile|   3 +-
 crypto/ccompress.c |  95 +
 crypto/pcompress.c | 115 ---
 crypto/zlib.c  | 381 -
 include/crypto/compress.h  | 118 
 include/crypto/internal/compress.h |  28 ---
 include/linux/crypto.h |   2 +-
 8 files changed, 134 insertions(+), 625 deletions(-)
 create mode 100644 crypto/ccompress.c
 delete mode 100644 crypto/pcompress.c
 delete mode 100644 crypto/zlib.c
 delete mode 100644 include/crypto/internal/compress.h

diff --git a/crypto/Kconfig b/crypto/Kconfig
index fc93444..cfc42e6 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -84,14 +84,8 @@ config CRYPTO_RNG_DEFAULT
tristate
select CRYPTO_DRBG_MENU
 
-config CRYPTO_PCOMP
+config CRYPTO_CCOMPRESS
tristate
-   select CRYPTO_PCOMP2
-   select CRYPTO_ALGAPI
-
-config CRYPTO_PCOMP2
-   tristate
-   select CRYPTO_ALGAPI2
 
 config CRYPTO_AKCIPHER2
tristate
@@ -1497,15 +1491,6 @@ config CRYPTO_DEFLATE
 
  You will most probably want this if using IPSec.
 
-config CRYPTO_ZLIB
-   tristate "Zlib compression algorithm"
-   select CRYPTO_PCOMP
-   select ZLIB_INFLATE
-   select ZLIB_DEFLATE
-   select NLATTR
-   help
- This is the zlib algorithm.
-
 config CRYPTO_LZO
tristate "LZO compression algorithm"
select CRYPTO_ALGAPI
diff --git a/crypto/Makefile b/crypto/Makefile
index e2c5981..93adbfe 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -28,7 +28,7 @@ crypto_hash-y += ahash.o
 crypto_hash-y += shash.o
 obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o
 
-obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o
+obj-$(CONFIG_CRYPTO_CCOMPRESS) += ccompress.o
 obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o
 
 $(obj)/rsakey-asn1.o: $(obj)/rsakey-asn1.c $(obj)/rsakey-asn1.h
@@ -94,7 +94,6 @@ obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o
 obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o
 obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
-obj-$(CONFIG_CRYPTO_ZLIB) += zlib.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c_generic.o
 obj-$(CONFIG_CRYPTO_CRC32) += crc32.o
diff --git a/crypto/ccompress.c b/crypto/ccompress.c
new file mode 100644
index 000..1983372
--- /dev/null
+++ b/crypto/ccompress.c
@@ -0,0 +1,95 @@
+/*
+ * Cryptographic API.
+ *
+ * Contextless (de)compression operations.
+ *
+ * Copyright 2015 LG Electronics Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
+ * If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "internal.h"
+
+
+static int crypto_ccomp_init(struct crypto_tfm *tfm, u32 type, u32 mask)
+{
+   return 0;
+}
+
+static int 

[PATCH v4 2/8] crypto/lzo: support contextless compression API

2015-10-14 Thread Joonsoo Kim
Now, contextless compression API is introduced and it can reduce
memory overhead in some cases. All compression algorithm will
support it.

Signed-off-by: Joonsoo Kim 
---
 crypto/Kconfig |  1 +
 crypto/lzo.c   | 81 --
 2 files changed, 69 insertions(+), 13 deletions(-)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index cfc42e6..d25746f 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1494,6 +1494,7 @@ config CRYPTO_DEFLATE
 config CRYPTO_LZO
tristate "LZO compression algorithm"
select CRYPTO_ALGAPI
+   select CRYPTO_CCOMPRESS
select LZO_COMPRESS
select LZO_DECOMPRESS
help
diff --git a/crypto/lzo.c b/crypto/lzo.c
index 4b3e925..a6ae752 100644
--- a/crypto/lzo.c
+++ b/crypto/lzo.c
@@ -22,40 +22,56 @@
 #include 
 #include 
 #include 
+#include 
 
 struct lzo_ctx {
void *lzo_comp_mem;
 };
 
+static void *lzo_alloc_context(struct crypto_ccomp *tfm)
+{
+   void *ctx;
+
+   ctx = kmalloc(LZO1X_MEM_COMPRESS,
+   GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
+   if (!ctx)
+   ctx = vmalloc(LZO1X_MEM_COMPRESS);
+   if (!ctx)
+   return ERR_PTR(-ENOMEM);
+
+   return ctx;
+}
+
 static int lzo_init(struct crypto_tfm *tfm)
 {
struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
 
-   ctx->lzo_comp_mem = kmalloc(LZO1X_MEM_COMPRESS,
-   GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
-   if (!ctx->lzo_comp_mem)
-   ctx->lzo_comp_mem = vmalloc(LZO1X_MEM_COMPRESS);
-   if (!ctx->lzo_comp_mem)
+   ctx->lzo_comp_mem = lzo_alloc_context(NULL);
+   if (IS_ERR(ctx->lzo_comp_mem))
return -ENOMEM;
 
return 0;
 }
 
+static void lzo_free_context(struct crypto_ccomp *tfm, void *ctx)
+{
+   kvfree(ctx);
+}
+
 static void lzo_exit(struct crypto_tfm *tfm)
 {
struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
 
-   kvfree(ctx->lzo_comp_mem);
+   lzo_free_context(NULL, ctx->lzo_comp_mem);
 }
 
-static int lzo_compress(struct crypto_tfm *tfm, const u8 *src,
-   unsigned int slen, u8 *dst, unsigned int *dlen)
+static int __lzo_compress(const u8 *src, unsigned int slen,
+   u8 *dst, unsigned int *dlen, void *ctx)
 {
-   struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
int err;
 
-   err = lzo1x_1_compress(src, slen, dst, _len, ctx->lzo_comp_mem);
+   err = lzo1x_1_compress(src, slen, dst, _len, ctx);
 
if (err != LZO_E_OK)
return -EINVAL;
@@ -64,8 +80,16 @@ static int lzo_compress(struct crypto_tfm *tfm, const u8 
*src,
return 0;
 }
 
-static int lzo_decompress(struct crypto_tfm *tfm, const u8 *src,
- unsigned int slen, u8 *dst, unsigned int *dlen)
+static int lzo_compress(struct crypto_tfm *tfm, const u8 *src,
+   unsigned int slen, u8 *dst, unsigned int *dlen)
+{
+   struct lzo_ctx *ctx = crypto_tfm_ctx(tfm);
+
+   return __lzo_compress(src, slen, dst, dlen, ctx->lzo_comp_mem);
+}
+
+static int __lzo_decompress(const u8 *src, unsigned int slen,
+   u8 *dst, unsigned int *dlen, void *ctx)
 {
int err;
size_t tmp_len = *dlen; /* size_t(ulong) <-> uint on 64 bit */
@@ -77,7 +101,12 @@ static int lzo_decompress(struct crypto_tfm *tfm, const u8 
*src,
 
*dlen = tmp_len;
return 0;
+}
 
+static int lzo_decompress(struct crypto_tfm *tfm, const u8 *src,
+ unsigned int slen, u8 *dst, unsigned int *dlen)
+{
+   return __lzo_decompress(src, slen, dst, dlen, NULL);
 }
 
 static struct crypto_alg alg = {
@@ -92,14 +121,40 @@ static struct crypto_alg alg = {
.coa_decompress = lzo_decompress } }
 };
 
+static struct ccomp_alg ccomp = {
+   .alloc_context  = lzo_alloc_context,
+   .free_context   = lzo_free_context,
+   .compress   = __lzo_compress,
+   .decompress = __lzo_decompress,
+   .flags  = CCOMP_TYPE_DECOMP_NOCTX,
+   .base   = {
+   .cra_name   = "lzo",
+   .cra_flags  = CRYPTO_ALG_TYPE_CCOMPRESS,
+   .cra_module = THIS_MODULE,
+   }
+};
+
 static int __init lzo_mod_init(void)
 {
-   return crypto_register_alg();
+   int ret;
+
+   ret = crypto_register_alg();
+   if (ret)
+   return ret;
+
+   ret = crypto_register_ccomp();
+   if (ret) {
+   crypto_unregister_alg();
+   return ret;
+   }
+
+   return ret;
 }
 
 static void __exit lzo_mod_fini(void)
 {
crypto_unregister_alg();
+   crypto_unregister_ccomp();
 }
 
 module_init(lzo_mod_init);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe 

[PATCH v4 7/8] zram: use crypto contextless compression API to (de)compress

2015-10-14 Thread Joonsoo Kim
Until now, zram uses compression algorithm through direct call
to core algorithm function, but, it has drawback that we need to add
compression algorithm manually to zram if needed. Without this work,
we cannot utilize various compression algorithms in the system.
Moreover, to add new compression algorithm, we need to know how to use it
and this is somewhat time-consuming.

When I tested new algorithms such as zlib, these problems make me hard
to test them. To prevent these problem in the future, I think that
using crypto API for compression is better approach and this patch
implements it.

The reason we need to support vairous compression algorithms is that
zram's performance is highly depend on workload and compression algorithm
and architecture. Every compression algorithm has it's own strong point.
For example, zlib is the best for compression ratio, but, it's
(de)compression speed is rather slow. Against my expectation, in my kernel
build test with zram swap, in low-memory condition on x86, zlib shows best
performance than others. In this case, I guess that compression ratio is
the most important factor.

Kernel build elapsed time in QEMU 8 CPUs 448 MB with zram swap
lzo : deflate
188.3 s : 181.9 s
(3% improvement)

Unlike this situation, on ARM, maybe fast (de)compression speed is
the most important because it's computation speed is slower than x86.

We can't expect what algorithm is the best fit for one's system, because
it needs too complex calculation. We need to test it in case by case and
easy to use new compression algorithm by this patch will help
that situation.

Note that this patch just convert zram to use crypto contextless
compression API but doesn't change compression algorithm selection
interface in zram. So it doesn't support zlib yet. Following patch
will change this interface and enable various compression algorithm.

Signed-off-by: Joonsoo Kim 
---
 drivers/block/zram/Kconfig|  8 +++---
 drivers/block/zram/Makefile   |  4 +--
 drivers/block/zram/zcomp.c| 63 ---
 drivers/block/zram/zcomp.h| 21 +++
 drivers/block/zram/zram_drv.c |  6 ++---
 5 files changed, 52 insertions(+), 50 deletions(-)

diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
index 386ba3d..7619bed 100644
--- a/drivers/block/zram/Kconfig
+++ b/drivers/block/zram/Kconfig
@@ -1,8 +1,7 @@
 config ZRAM
tristate "Compressed RAM block device support"
depends on BLOCK && SYSFS && ZSMALLOC
-   select LZO_COMPRESS
-   select LZO_DECOMPRESS
+   select CRYPTO_LZO
default n
help
  Creates virtual block devices called /dev/zramX (X = 0, 1, ...).
@@ -18,9 +17,8 @@ config ZRAM
 config ZRAM_LZ4_COMPRESS
bool "Enable LZ4 algorithm support"
depends on ZRAM
-   select LZ4_COMPRESS
-   select LZ4_DECOMPRESS
+   select CRYPTO_LZ4
default n
help
  This option enables LZ4 compression algorithm support. Compression
- algorithm can be changed using `comp_algorithm' device attribute.
\ No newline at end of file
+ algorithm can be changed using `comp_algorithm' device attribute.
diff --git a/drivers/block/zram/Makefile b/drivers/block/zram/Makefile
index be0763f..9e2b79e 100644
--- a/drivers/block/zram/Makefile
+++ b/drivers/block/zram/Makefile
@@ -1,5 +1,3 @@
-zram-y :=  zcomp_lzo.o zcomp.o zram_drv.o
-
-zram-$(CONFIG_ZRAM_LZ4_COMPRESS) += zcomp_lz4.o
+zram-y :=  zcomp.o zram_drv.o
 
 obj-$(CONFIG_ZRAM) +=  zram.o
diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index e3016da..9be83db 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -15,10 +15,6 @@
 #include 
 
 #include "zcomp.h"
-#include "zcomp_lzo.h"
-#ifdef CONFIG_ZRAM_LZ4_COMPRESS
-#include "zcomp_lz4.h"
-#endif
 
 /*
  * single zcomp_strm backend
@@ -43,19 +39,20 @@ struct zcomp_strm_multi {
wait_queue_head_t strm_wait;
 };
 
-static struct zcomp_backend *backends[] = {
-   _lzo,
+static const char * const backends[] = {
+   "lzo",
 #ifdef CONFIG_ZRAM_LZ4_COMPRESS
-   _lz4,
+   "lz4",
 #endif
NULL
 };
 
-static struct zcomp_backend *find_backend(const char *compress)
+static const char *find_backend(const char *compress)
 {
int i = 0;
while (backends[i]) {
-   if (sysfs_streq(compress, backends[i]->name))
+   if (sysfs_streq(compress, backends[i]) &&
+   crypto_has_comp(backends[i], 0, 0))
break;
i++;
}
@@ -65,7 +62,7 @@ static struct zcomp_backend *find_backend(const char 
*compress)
 static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
 {
if (zstrm->private)
-   comp->backend->destroy(zstrm->private);
+   crypto_ccomp_free_context(comp->tfm, zstrm->private);
free_pages((unsigned long)zstrm->buffer, 1);
  

[PATCH v4 8/8] zram: enable contextless compression alg in zram

2015-10-14 Thread Joonsoo Kim
Now, zram uses contextless compression API and there is no reason
to limit compression algorithm through hard-wired string. This patch
remove it so enable all contextless compression algorithm in the
system.

After this patch, available compression algorithm for zram can be
retrieved by searching contextless compression in /proc/crypto.

cat /proc/crypto | grep ccomp -B 7
name : lz4
[snip...]
type : ccomp

Previous interface comp_algorithm attr will remain to set new algorithm.
Read from previous interface also works for compatibility but it will
be wrong.

Note that after this patch is applied, there is no way to know current
compression algorithm so it's really bad thing. Please let me know proper
solution if someone have better idea.

Signed-off-by: Joonsoo Kim 
---
 Documentation/blockdev/zram.txt | 29 +++--
 drivers/block/zram/Kconfig  |  9 -
 drivers/block/zram/zcomp.c  | 17 +++--
 drivers/block/zram/zram_drv.c   |  1 +
 4 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/Documentation/blockdev/zram.txt b/Documentation/blockdev/zram.txt
index 5bda503..7a165c2 100644
--- a/Documentation/blockdev/zram.txt
+++ b/Documentation/blockdev/zram.txt
@@ -81,15 +81,32 @@ dynamic max_comp_streams. Only multi stream backend 
supports dynamic
 max_comp_streams adjustment.
 
 3) Select compression algorithm
-   Using comp_algorithm device attribute one can see available and
-   currently selected (shown in square brackets) compression algorithms,
-   change selected compression algorithm (once the device is initialised
-   there is no way to change compression algorithm).
+   You can find available compression algorithms by searching contextless
+   compression algorithm (type: ccomp) in /proc/crypto.
+   Using comp_algorithm device attribute one can change selected
+   compression algorithm (once the device is initialised there is no way
+   to change compression algorithm).
 
Examples:
#show supported compression algorithms
-   cat /sys/block/zram0/comp_algorithm
-   lzo [lz4]
+   cat /proc/crypto | grep ccomp -B 7
+   name : lz4
+   driver   : lz4-generic
+   module   : kernel
+   priority : 0
+   refcnt   : 1
+   selftest : passed
+   internal : no
+   type : ccomp
+   --
+   name : lzo
+   driver   : lzo-generic
+   module   : kernel
+   priority : 0
+   refcnt   : 1
+   selftest : passed
+   internal : no
+   type : ccomp
 
#select lzo compression algorithm
echo lzo > /sys/block/zram0/comp_algorithm
diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig
index 7619bed..36ec96f 100644
--- a/drivers/block/zram/Kconfig
+++ b/drivers/block/zram/Kconfig
@@ -13,12 +13,3 @@ config ZRAM
  disks and maybe many more.
 
  See zram.txt for more information.
-
-config ZRAM_LZ4_COMPRESS
-   bool "Enable LZ4 algorithm support"
-   depends on ZRAM
-   select CRYPTO_LZ4
-   default n
-   help
- This option enables LZ4 compression algorithm support. Compression
- algorithm can be changed using `comp_algorithm' device attribute.
diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index 9be83db..f91c0659 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -41,22 +41,16 @@ struct zcomp_strm_multi {
 
 static const char * const backends[] = {
"lzo",
-#ifdef CONFIG_ZRAM_LZ4_COMPRESS
"lz4",
-#endif
NULL
 };
 
 static const char *find_backend(const char *compress)
 {
-   int i = 0;
-   while (backends[i]) {
-   if (sysfs_streq(compress, backends[i]) &&
-   crypto_has_comp(backends[i], 0, 0))
-   break;
-   i++;
-   }
-   return backends[i];
+   if (crypto_has_comp(compress, 0, 0))
+   return compress;
+
+   return NULL;
 }
 
 static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
@@ -277,6 +271,9 @@ ssize_t zcomp_available_show(const char *comp, char *buf)
int i = 0;
 
while (backends[i]) {
+   if (!crypto_has_comp(backends[i], 0, 0))
+   continue;
+
if (!strcmp(comp, backends[i]))
sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
"[%s] ", backends[i]);
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 6f04fb2..6b4cf85 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -352,6 +352,7 @@ static ssize_t comp_algorithm_show(struct device *dev,
size_t sz;
struct zram *zram = dev_to_zram(dev);
 
+   deprecated_attr_warn("comp_algorithm");

Re: [PATCH 2/3] hwrng: stm32 - add support for STM32 HW RNG

2015-10-14 Thread Linus Walleij
On Mon, Oct 12, 2015 at 10:21 AM, Daniel Thompson
 wrote:

> Add support for STMicroelectronics STM32 random number generator.
>
> The config value defaults to N, reflecting the fact that STM32 is a
> very low resource microcontroller platform and unlikely to be targeted
> by any "grown up" defconfigs.
>
> Signed-off-by: Daniel Thompson 

This is a fine driver, love the performance boost you reported
and stand corrected on the likeness of the other Nomadik driver.
Reviewed-by: Linus Walleij 

> +static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool 
> wait)

Now this read() function is so nice that I feel obliged to
go in and tidy up the Nomadik driver to be as nice.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 5/8] zram: make stream find and release functions static

2015-10-14 Thread Joonsoo Kim
From: Sergey Senozhatsky 

Hide (make static) zstrm find and release function and introduce
zcomp_compress_begin()/zcomp_compress_end(). We will have begin
and end functions around compression (this patch) and decompression
(next patch). So the work flow is evolving to:

zstrm = foo_begin();
foo(zstrm);
foo_end(zstrm);

where foo is compress or decompress zcomp functions.

This patch is a preparation to make crypto API-powered zcomp
possible. The reasoning is that some crypto compression backends
require zstrm for decompression.

Acked-by: Minchan Kim 
Signed-off-by: Sergey Senozhatsky 
Signed-off-by: Joonsoo Kim 
---
 drivers/block/zram/zcomp.c| 27 +--
 drivers/block/zram/zcomp.h|  8 ++--
 drivers/block/zram/zram_drv.c |  6 +++---
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index 5cb13ca..52d5b04 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -296,16 +296,39 @@ bool zcomp_set_max_streams(struct zcomp *comp, int 
num_strm)
return comp->set_max_streams(comp, num_strm);
 }
 
-struct zcomp_strm *zcomp_strm_find(struct zcomp *comp)
+static struct zcomp_strm *zcomp_strm_find(struct zcomp *comp)
 {
return comp->strm_find(comp);
 }
 
-void zcomp_strm_release(struct zcomp *comp, struct zcomp_strm *zstrm)
+static void zcomp_strm_release(struct zcomp *comp, struct zcomp_strm *zstrm)
 {
comp->strm_release(comp, zstrm);
 }
 
+/* Never return NULL, may sleep */
+struct zcomp_strm *zcomp_compress_begin(struct zcomp *comp)
+{
+   return zcomp_strm_find(comp);
+}
+
+void zcomp_compress_end(struct zcomp *comp, struct zcomp_strm *zstrm)
+{
+   zcomp_strm_release(comp, zstrm);
+}
+
+/* May return NULL, may sleep */
+struct zcomp_strm *zcomp_decompress_begin(struct zcomp *comp)
+{
+   return NULL;
+}
+
+void zcomp_decompress_end(struct zcomp *comp, struct zcomp_strm *zstrm)
+{
+   if (zstrm)
+   zcomp_strm_release(comp, zstrm);
+}
+
 int zcomp_compress(struct zcomp *comp, struct zcomp_strm *zstrm,
const unsigned char *src, size_t *dst_len)
 {
diff --git a/drivers/block/zram/zcomp.h b/drivers/block/zram/zcomp.h
index 46e2b9f..616e013 100644
--- a/drivers/block/zram/zcomp.h
+++ b/drivers/block/zram/zcomp.h
@@ -56,12 +56,16 @@ bool zcomp_available_algorithm(const char *comp);
 struct zcomp *zcomp_create(const char *comp, int max_strm);
 void zcomp_destroy(struct zcomp *comp);
 
-struct zcomp_strm *zcomp_strm_find(struct zcomp *comp);
-void zcomp_strm_release(struct zcomp *comp, struct zcomp_strm *zstrm);
+
+struct zcomp_strm *zcomp_compress_begin(struct zcomp *comp);
+void zcomp_compress_end(struct zcomp *comp, struct zcomp_strm *zstrm);
 
 int zcomp_compress(struct zcomp *comp, struct zcomp_strm *zstrm,
const unsigned char *src, size_t *dst_len);
 
+struct zcomp_strm *zcomp_decompress_begin(struct zcomp *comp);
+void zcomp_decompress_end(struct zcomp *comp, struct zcomp_strm *zstrm);
+
 int zcomp_decompress(struct zcomp *comp, const unsigned char *src,
size_t src_len, unsigned char *dst);
 
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 3e8d8ff..83a06f2 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -673,7 +673,7 @@ static int zram_bvec_write(struct zram *zram, struct 
bio_vec *bvec, u32 index,
goto out;
}
 
-   zstrm = zcomp_strm_find(zram->comp);
+   zstrm = zcomp_compress_begin(zram->comp);
user_mem = kmap_atomic(page);
 
if (is_partial_io(bvec)) {
@@ -744,7 +744,7 @@ static int zram_bvec_write(struct zram *zram, struct 
bio_vec *bvec, u32 index,
memcpy(cmem, src, clen);
}
 
-   zcomp_strm_release(zram->comp, zstrm);
+   zcomp_compress_end(zram->comp, zstrm);
zstrm = NULL;
zs_unmap_object(meta->mem_pool, handle);
 
@@ -764,7 +764,7 @@ static int zram_bvec_write(struct zram *zram, struct 
bio_vec *bvec, u32 index,
atomic64_inc(>stats.pages_stored);
 out:
if (zstrm)
-   zcomp_strm_release(zram->comp, zstrm);
+   zcomp_compress_end(zram->comp, zstrm);
if (is_partial_io(bvec))
kfree(uncmem);
return ret;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: sahara: set array of const as const

2015-10-14 Thread LABBE Corentin
Some array of const char are not set as const.
This patch fix that.

Signed-off-by: LABBE Corentin 
---
 drivers/crypto/sahara.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
index 804c0f5..f68c24a 100644
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -272,7 +272,7 @@ static u32 sahara_aes_data_link_hdr(struct sahara_dev *dev)
SAHARA_HDR_CHA_SKHA | SAHARA_HDR_PARITY_BIT;
 }
 
-static char *sahara_err_src[16] = {
+static const char *sahara_err_src[16] = {
"No error",
"Header error",
"Descriptor length error",
@@ -291,14 +291,14 @@ static char *sahara_err_src[16] = {
"DMA error"
 };
 
-static char *sahara_err_dmasize[4] = {
+static const char *sahara_err_dmasize[4] = {
"Byte transfer",
"Half-word transfer",
"Word transfer",
"Reserved"
 };
 
-static char *sahara_err_dmasrc[8] = {
+static const char *sahara_err_dmasrc[8] = {
"No error",
"AHB bus error",
"Internal IP bus error",
@@ -309,7 +309,7 @@ static char *sahara_err_dmasrc[8] = {
"DMA HW error"
 };
 
-static char *sahara_cha_errsrc[12] = {
+static const char *sahara_cha_errsrc[12] = {
"Input buffer non-empty",
"Illegal address",
"Illegal mode",
@@ -324,7 +324,7 @@ static char *sahara_cha_errsrc[12] = {
"Reserved"
 };
 
-static char *sahara_cha_err[4] = { "No error", "SKHA", "MDHA", "RNG" };
+static const char *sahara_cha_err[4] = { "No error", "SKHA", "MDHA", "RNG" };
 
 static void sahara_decode_error(struct sahara_dev *dev, unsigned int error)
 {
@@ -354,7 +354,7 @@ static void sahara_decode_error(struct sahara_dev *dev, 
unsigned int error)
dev_err(dev->device, "\n");
 }
 
-static char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
+static const char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
 
 static void sahara_decode_status(struct sahara_dev *dev, unsigned int status)
 {
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] s390: crypto: replace raw value by their coresponding define

2015-10-14 Thread LABBE Corentin
SHA_MAX_STATE_SIZE is just the number of u32 word for SHA512.
So replace the raw value "16" by their meaning (SHA512_DIGEST_SIZE / 4)

Signed-off-by: LABBE Corentin 
---
 arch/s390/crypto/sha.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/crypto/sha.h b/arch/s390/crypto/sha.h
index f4e9dc7..10f2007 100644
--- a/arch/s390/crypto/sha.h
+++ b/arch/s390/crypto/sha.h
@@ -19,7 +19,7 @@
 #include 
 
 /* must be big enough for the largest SHA variant */
-#define SHA_MAX_STATE_SIZE 16
+#define SHA_MAX_STATE_SIZE (SHA512_DIGEST_SIZE / 4)
 #define SHA_MAX_BLOCK_SIZE  SHA512_BLOCK_SIZE
 
 struct s390_sha_ctx {
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE

2015-10-14 Thread LABBE Corentin
The sha x86 crypto code use two define for the same thing:
NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
Replace them by SHA1_DIGEST_SIZE/4

Signed-off-by: LABBE Corentin 
---
 arch/x86/crypto/sha-mb/sha1_mb.c| 2 +-
 arch/x86/crypto/sha-mb/sha_mb_ctx.h | 1 -
 arch/x86/crypto/sha-mb/sha_mb_mgr.h | 6 ++
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c
index a841e97..791cbfa 100644
--- a/arch/x86/crypto/sha-mb/sha1_mb.c
+++ b/arch/x86/crypto/sha-mb/sha1_mb.c
@@ -104,7 +104,7 @@ static asmlinkage struct job_sha1* 
(*sha1_job_mgr_get_comp_job)(struct sha1_mb_m
 
 inline void sha1_init_digest(uint32_t *digest)
 {
-   static const uint32_t initial_digest[SHA1_DIGEST_LENGTH] = {SHA1_H0,
+   static const uint32_t initial_digest[SHA1_DIGEST_SIZE / 4] = {SHA1_H0,
SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
memcpy(digest, initial_digest, sizeof(initial_digest));
 }
diff --git a/arch/x86/crypto/sha-mb/sha_mb_ctx.h 
b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
index e36069d..9fd36eb5 100644
--- a/arch/x86/crypto/sha-mb/sha_mb_ctx.h
+++ b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
@@ -94,7 +94,6 @@ enum hash_ctx_error {
 
 
 /* Hash Constants and Typedefs */
-#define SHA1_DIGEST_LENGTH  5
 #define SHA1_LOG2_BLOCK_SIZE6
 
 #define SHA1_PADLENGTHFIELD_SIZE8
diff --git a/arch/x86/crypto/sha-mb/sha_mb_mgr.h 
b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
index 08ad1a9..3ff337c 100644
--- a/arch/x86/crypto/sha-mb/sha_mb_mgr.h
+++ b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
@@ -54,11 +54,9 @@
 #ifndef __SHA_MB_MGR_H
 #define __SHA_MB_MGR_H
 
-
+#include 
 #include 
 
-#define NUM_SHA1_DIGEST_WORDS 5
-
 enum job_sts { STS_UNKNOWN = 0,
STS_BEING_PROCESSED = 1,
STS_COMPLETED = 2,
@@ -69,7 +67,7 @@ enum job_sts {STS_UNKNOWN = 0,
 struct job_sha1 {
u8  *buffer;
u32 len;
-   u32 result_digest[NUM_SHA1_DIGEST_WORDS] __aligned(32);
+   u32 result_digest[SHA1_DIGEST_SIZE / 4] __aligned(32);
enumjob_sts status;
void*user_data;
 };
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: n2: set array of const as const

2015-10-14 Thread LABBE Corentin
Some array of const char are not set as const.
This patch fix that.

Signed-off-by: LABBE Corentin 
---
 drivers/crypto/n2_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c
index 8ea6c32..febbd5e 100644
--- a/drivers/crypto/n2_core.c
+++ b/drivers/crypto/n2_core.c
@@ -34,7 +34,7 @@
 #define DRV_MODULE_VERSION "0.2"
 #define DRV_MODULE_RELDATE "July 28, 2011"
 
-static char version[] =
+static const char version[] =
DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
 
 MODULE_AUTHOR("David S. Miller (da...@davemloft.net)");
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3] crypto/nx842: Add CRC and validation support

2015-10-14 Thread Haren Myneni
On 10/14/2015 07:30 AM, Dan Streetman wrote:
> On Wed, Oct 14, 2015 at 10:27 AM, Herbert Xu
>  wrote:
>> On Thu, Oct 08, 2015 at 01:45:51PM -0700, Haren Myneni wrote:
>>>
>>> This patch adds CRC generation and validation support for nx-842.
>>> Add CRC flag so that nx842 coprocessor includes CRC during compression
>>> and validates during decompression.
>>>
>>> Also changes in 842 SW compression to append CRC value at the end
>>> of template and checks during decompression.
>>>
>>> Signed-off-by: Haren Myneni 
>>
>> Patch applied.  Thanks.
> 
> Thanks Herbert, sorry I didn't have a chance to ack it :)
> 
> Haren, as I don't have access to the NX PowerPC hardware anymore and
> you've taken this over for IBM, can you change the maintainer to
> yourself?

Dan, OK, I will send the patch. 

> 
>> --
>> Email: Herbert Xu 
>> Home Page: http://gondor.apana.org.au/~herbert/
>> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 4/8] crypto/deflate: support contextless compression API

2015-10-14 Thread kbuild test robot
Hi Joonsoo,

[auto build test ERROR on next-20151013 -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Joonsoo-Kim/zram-introduce-contextless-compression-API-and-use-it-on-zram/20151014-154649
config: parisc-defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=parisc 

All errors (new ones prefixed by >>):

   crypto/built-in.o: In function `deflate_mod_fini':
>> crypto/deflate.o:(.exit.text+0x278): undefined reference to 
>> `crypto_unregister_ccomp'
   crypto/built-in.o: In function `deflate_mod_init':
>> crypto/deflate.o:(.init.text+0x31c): undefined reference to 
>> `crypto_register_ccomp'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v4 4/8] crypto/deflate: support contextless compression API

2015-10-14 Thread kbuild test robot
Hi Joonsoo,

[auto build test ERROR on next-20151013 -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Joonsoo-Kim/zram-introduce-contextless-compression-API-and-use-it-on-zram/20151014-154649
config: m32r-usrv_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m32r 

All errors (new ones prefixed by >>):

   crypto/built-in.o: In function `deflate_mod_init':
>> crypto/deflate.c:280: undefined reference to `crypto_register_ccomp'
   crypto/deflate.c:280:(.init.text+0x244): relocation truncated to fit: 
R_M32R_26_PCREL_RELA against undefined symbol `crypto_register_ccomp'

vim +280 crypto/deflate.c

   274  int ret;
   275  
   276  ret = crypto_register_alg();
   277  if (ret)
   278  return ret;
   279  
 > 280  ret = crypto_register_ccomp();
   281  if (ret) {
   282  crypto_unregister_alg();
   283  return ret;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v4 7/8] zram: use crypto contextless compression API to (de)compress

2015-10-14 Thread Sergey Senozhatsky
Hi,

On (10/14/15 16:38), Joonsoo Kim wrote:
[..]
> Creates virtual block devices called /dev/zramX (X = 0, 1, ...).
> @@ -18,9 +17,8 @@ config ZRAM
>  config ZRAM_LZ4_COMPRESS
>   bool "Enable LZ4 algorithm support"
>   depends on ZRAM
> - select LZ4_COMPRESS
> - select LZ4_DECOMPRESS
> + select CRYPTO_LZ4
>   default n
>   help
> This option enables LZ4 compression algorithm support. Compression
> -   algorithm can be changed using `comp_algorithm' device attribute.
> \ No newline at end of file
> +   algorithm can be changed using `comp_algorithm' device attribute.
> diff --git a/drivers/block/zram/Makefile b/drivers/block/zram/Makefile
> index be0763f..9e2b79e 100644
> --- a/drivers/block/zram/Makefile
> +++ b/drivers/block/zram/Makefile
> @@ -1,5 +1,3 @@
> -zram-y   :=  zcomp_lzo.o zcomp.o zram_drv.o
> -
> -zram-$(CONFIG_ZRAM_LZ4_COMPRESS) += zcomp_lz4.o
> +zram-y   :=  zcomp.o zram_drv.o

+ git rm zcomp_lzo.* zcomp_lz4.*:)


>  obj-$(CONFIG_ZRAM)   +=  zram.o
> diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> index e3016da..9be83db 100644
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -15,10 +15,6 @@
>  #include 
>  
>  #include "zcomp.h"
> -#include "zcomp_lzo.h"
> -#ifdef CONFIG_ZRAM_LZ4_COMPRESS
> -#include "zcomp_lz4.h"
> -#endif
>  
>  /*
>   * single zcomp_strm backend
> @@ -43,19 +39,20 @@ struct zcomp_strm_multi {
>   wait_queue_head_t strm_wait;
>  };
>  
> -static struct zcomp_backend *backends[] = {
> - _lzo,
> +static const char * const backends[] = {
> + "lzo",
>  #ifdef CONFIG_ZRAM_LZ4_COMPRESS

a nitpick -- this CONFIG option does not exist at this point.

> - _lz4,
> + "lz4",
>  #endif
>   NULL
>  };
>  
> -static struct zcomp_backend *find_backend(const char *compress)
> +static const char *find_backend(const char *compress)
>  {
>   int i = 0;
>   while (backends[i]) {
> - if (sysfs_streq(compress, backends[i]->name))
> + if (sysfs_streq(compress, backends[i]) &&
> + crypto_has_comp(backends[i], 0, 0))

again (the same as in my previous email). I'd rather prefer to have
FOO backends in ` const char * const backends[]' array only when the
corresponding CONFIG_CRYPTO_FOO option has been selected. otherwise you
have to find an intersection of two independent sets. sort of unreasonable
to me.


>   break;
>   i++;
>   }
> @@ -65,7 +62,7 @@ static struct zcomp_backend *find_backend(const char 
> *compress)
>  static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
>  {
>   if (zstrm->private)
> - comp->backend->destroy(zstrm->private);
> + crypto_ccomp_free_context(comp->tfm, zstrm->private);
>   free_pages((unsigned long)zstrm->buffer, 1);
>   kfree(zstrm);
>  }
> @@ -80,7 +77,13 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp 
> *comp)
>   if (!zstrm)
>   return NULL;
>  
> - zstrm->private = comp->backend->create();
> + zstrm->private = crypto_ccomp_alloc_context(comp->tfm);
> + if (IS_ERR(zstrm->private)) {
> + zstrm->private = NULL;
> + zcomp_strm_free(comp, zstrm);
> + return NULL;
> + }
> +
>   /*
>* allocate 2 pages. 1 for compressed data, plus 1 extra for the
>* case when compressed size is larger than the original one
> @@ -274,12 +277,12 @@ ssize_t zcomp_available_show(const char *comp, char 
> *buf)
>   int i = 0;
>  
>   while (backends[i]) {
> - if (!strcmp(comp, backends[i]->name))
> + if (!strcmp(comp, backends[i]))
>   sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
> - "[%s] ", backends[i]->name);
> + "[%s] ", backends[i]);
>   else
>   sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
> - "%s ", backends[i]->name);
> + "%s ", backends[i]);
>   i++;
>   }
>   sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
> @@ -320,7 +323,10 @@ void zcomp_compress_end(struct zcomp *comp, struct 
> zcomp_strm *zstrm)
>  /* May return NULL, may sleep */
>  struct zcomp_strm *zcomp_decompress_begin(struct zcomp *comp)
>  {
> - return NULL;
> + if (crypto_ccomp_decomp_noctx(comp->tfm))
> + return NULL;
> +
> + return zcomp_strm_find(comp);
>  }
>  
>  void zcomp_decompress_end(struct zcomp *comp, struct zcomp_strm *zstrm)
> @@ -330,22 +336,29 @@ void zcomp_decompress_end(struct zcomp *comp, struct 
> zcomp_strm *zstrm)
>  }
>  
>  int zcomp_compress(struct zcomp *comp, struct zcomp_strm *zstrm,
> - const unsigned char *src, size_t *dst_len)
> + const unsigned char *src, unsigned int *dst_len)
>  {
> - return 

Re: [PATCH v4 8/8] zram: enable contextless compression alg in zram

2015-10-14 Thread Joonsoo Kim
On Thu, Oct 15, 2015 at 09:29:03AM +0900, Sergey Senozhatsky wrote:
> Hi,
> 
> On (10/14/15 16:38), Joonsoo Kim wrote:
> [..]
> >  static const char * const backends[] = {
> > "lzo",
> > -#ifdef CONFIG_ZRAM_LZ4_COMPRESS
> > "lz4",
> > -#endif
> > NULL
> >  };
> >  
> >  static const char *find_backend(const char *compress)
> >  {
> > -   int i = 0;
> > -   while (backends[i]) {
> > -   if (sysfs_streq(compress, backends[i]) &&
> > -   crypto_has_comp(backends[i], 0, 0))
> > -   break;
> > -   i++;
> > -   }
> > -   return backends[i];
> > +   if (crypto_has_comp(compress, 0, 0))
> > +   return compress;
> > +
> > +   return NULL;
> >  }
> >  
> >  static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
> > @@ -277,6 +271,9 @@ ssize_t zcomp_available_show(const char *comp, char 
> > *buf)
> > int i = 0;
> >  
> > while (backends[i]) {
> > +   if (!crypto_has_comp(backends[i], 0, 0))
> > +   continue;
> > +
> 
> hm... this sort of looks a bit `unnatural' to me. we have two _independent_
> sets -- what zram supports and what crypto supports. that's why you have
> to do extra work and consult crypto. can we return back the old scheme:
> use ifdef CONFIG in backends, but replace CONFIG_ZRAM with CONFIG_CRYPTO?
> 
> e.g.
> 
>   static const char * const backends[] = {
>   "lzo",
>   #ifdef CONFIG_CRYPTO_LZ4
>   "lz4",
>   #endif
>   NULL
>   };
> 
> 
> so you can remove `crypto_has_comp(backends[i], 0, 0)' from
> zcomp_available_show(), because zram will support *only* what
> crypto supports.

Hello, Sergey.

Okay. I will change it in next spin.

Anyway, now I noticed that crypto_has_comp() is not proper API to
check contextless compression algorithm. I will change it, too.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] crypto: keywrap - add testmgr support

2015-10-14 Thread Herbert Xu
On Wed, Oct 14, 2015 at 08:44:53PM +0200, Stephan Mueller wrote:
>
> Did you apply the depending patch referenced in the beginning?
> 
> https://lkml.org/lkml/2015/6/16/342
> 
> I thought I understood you wanted to pull it. If not, I will add the 
> necessary 
> code and resubmit.

Yes but I want to finish the skcipher conversion before applying
these patches so please don't depend on them just yet.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 7/8] zram: use crypto contextless compression API to (de)compress

2015-10-14 Thread Joonsoo Kim
On Thu, Oct 15, 2015 at 09:38:41AM +0900, Sergey Senozhatsky wrote:
> Hi,
> 
> On (10/14/15 16:38), Joonsoo Kim wrote:
> [..]
> >   Creates virtual block devices called /dev/zramX (X = 0, 1, ...).
> > @@ -18,9 +17,8 @@ config ZRAM
> >  config ZRAM_LZ4_COMPRESS
> > bool "Enable LZ4 algorithm support"
> > depends on ZRAM
> > -   select LZ4_COMPRESS
> > -   select LZ4_DECOMPRESS
> > +   select CRYPTO_LZ4
> > default n
> > help
> >   This option enables LZ4 compression algorithm support. Compression
> > - algorithm can be changed using `comp_algorithm' device attribute.
> > \ No newline at end of file
> > + algorithm can be changed using `comp_algorithm' device attribute.
> > diff --git a/drivers/block/zram/Makefile b/drivers/block/zram/Makefile
> > index be0763f..9e2b79e 100644
> > --- a/drivers/block/zram/Makefile
> > +++ b/drivers/block/zram/Makefile
> > @@ -1,5 +1,3 @@
> > -zram-y :=  zcomp_lzo.o zcomp.o zram_drv.o
> > -
> > -zram-$(CONFIG_ZRAM_LZ4_COMPRESS) += zcomp_lz4.o
> > +zram-y :=  zcomp.o zram_drv.o
> 
> + git rm zcomp_lzo.* zcomp_lz4.*:)

Will do. :)

> 
> 
> >  obj-$(CONFIG_ZRAM) +=  zram.o
> > diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> > index e3016da..9be83db 100644
> > --- a/drivers/block/zram/zcomp.c
> > +++ b/drivers/block/zram/zcomp.c
> > @@ -15,10 +15,6 @@
> >  #include 
> >  
> >  #include "zcomp.h"
> > -#include "zcomp_lzo.h"
> > -#ifdef CONFIG_ZRAM_LZ4_COMPRESS
> > -#include "zcomp_lz4.h"
> > -#endif
> >  
> >  /*
> >   * single zcomp_strm backend
> > @@ -43,19 +39,20 @@ struct zcomp_strm_multi {
> > wait_queue_head_t strm_wait;
> >  };
> >  
> > -static struct zcomp_backend *backends[] = {
> > -   _lzo,
> > +static const char * const backends[] = {
> > +   "lzo",
> >  #ifdef CONFIG_ZRAM_LZ4_COMPRESS
> 
> a nitpick -- this CONFIG option does not exist at this point.

Will fix.

> 
> > -   _lz4,
> > +   "lz4",
> >  #endif
> > NULL
> >  };
> >  
> > -static struct zcomp_backend *find_backend(const char *compress)
> > +static const char *find_backend(const char *compress)
> >  {
> > int i = 0;
> > while (backends[i]) {
> > -   if (sysfs_streq(compress, backends[i]->name))
> > +   if (sysfs_streq(compress, backends[i]) &&
> > +   crypto_has_comp(backends[i], 0, 0))
> 
> again (the same as in my previous email). I'd rather prefer to have
> FOO backends in ` const char * const backends[]' array only when the
> corresponding CONFIG_CRYPTO_FOO option has been selected. otherwise you
> have to find an intersection of two independent sets. sort of unreasonable
> to me.

Okay.

> 
> > break;
> > i++;
> > }
> > @@ -65,7 +62,7 @@ static struct zcomp_backend *find_backend(const char 
> > *compress)
> >  static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
> >  {
> > if (zstrm->private)
> > -   comp->backend->destroy(zstrm->private);
> > +   crypto_ccomp_free_context(comp->tfm, zstrm->private);
> > free_pages((unsigned long)zstrm->buffer, 1);
> > kfree(zstrm);
> >  }
> > @@ -80,7 +77,13 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp 
> > *comp)
> > if (!zstrm)
> > return NULL;
> >  
> > -   zstrm->private = comp->backend->create();
> > +   zstrm->private = crypto_ccomp_alloc_context(comp->tfm);
> > +   if (IS_ERR(zstrm->private)) {
> > +   zstrm->private = NULL;
> > +   zcomp_strm_free(comp, zstrm);
> > +   return NULL;
> > +   }
> > +
> > /*
> >  * allocate 2 pages. 1 for compressed data, plus 1 extra for the
> >  * case when compressed size is larger than the original one
> > @@ -274,12 +277,12 @@ ssize_t zcomp_available_show(const char *comp, char 
> > *buf)
> > int i = 0;
> >  
> > while (backends[i]) {
> > -   if (!strcmp(comp, backends[i]->name))
> > +   if (!strcmp(comp, backends[i]))
> > sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
> > -   "[%s] ", backends[i]->name);
> > +   "[%s] ", backends[i]);
> > else
> > sz += scnprintf(buf + sz, PAGE_SIZE - sz - 2,
> > -   "%s ", backends[i]->name);
> > +   "%s ", backends[i]);
> > i++;
> > }
> > sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
> > @@ -320,7 +323,10 @@ void zcomp_compress_end(struct zcomp *comp, struct 
> > zcomp_strm *zstrm)
> >  /* May return NULL, may sleep */
> >  struct zcomp_strm *zcomp_decompress_begin(struct zcomp *comp)
> >  {
> > -   return NULL;
> > +   if (crypto_ccomp_decomp_noctx(comp->tfm))
> > +   return NULL;
> > +
> > +   return zcomp_strm_find(comp);
> >  }
> >  
> >  void zcomp_decompress_end(struct zcomp *comp, struct zcomp_strm *zstrm)
> > @@ -330,22 +336,29 @@ void zcomp_decompress_end(struct zcomp *comp, 

Re: [PATCH 1/8] crypto: hash: add zero length message hash for shax and md5

2015-10-14 Thread Herbert Xu
On Mon, Oct 12, 2015 at 06:53:39PM +0200, LABBE Corentin wrote:
> Some crypto drivers cannot process empty data message and return a
> precalculated hash for md5/sha1/sha224/sha256.
> 
> This patch add thoses precalculated hash in include/crypto.
> 
> Signed-off-by: LABBE Corentin 
> ---
>  include/crypto/md5.h |  5 +
>  include/crypto/sha.h | 20 
>  2 files changed, 25 insertions(+)
> 
> diff --git a/include/crypto/md5.h b/include/crypto/md5.h
> index 146af82..6496ee0 100644
> --- a/include/crypto/md5.h
> +++ b/include/crypto/md5.h
> @@ -13,6 +13,11 @@
>  #define MD5_H2   0x98badcfeUL
>  #define MD5_H3   0x10325476UL
>  
> +static const u8 md5_zero_message_hash[MD5_DIGEST_SIZE] = {
> + 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
> + 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e,
> +};
> +

This potentially creates this structure in every file that includes
md5.h.  How about putting it into md5_generic and exporting it?

> diff --git a/include/crypto/sha.h b/include/crypto/sha.h
> index dd7905a..02d7ffb 100644
> --- a/include/crypto/sha.h
> +++ b/include/crypto/sha.h
> @@ -64,6 +64,26 @@
>  #define SHA512_H60x1f83d9abfb41bd6bULL
>  #define SHA512_H70x5be0cd19137e2179ULL
>  
> +static const u8 sha1_zero_message_hash[SHA1_DIGEST_SIZE] = {
> + 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d,
> + 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90,
> + 0xaf, 0xd8, 0x07, 0x09
> +};

Ditto.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 7/8] zram: use crypto contextless compression API to (de)compress

2015-10-14 Thread Sergey Senozhatsky
On (10/15/15 10:07), Joonsoo Kim wrote:
[..]
> > >   if (error) {
> > > + crypto_free_ccomp(comp->tfm);
> > >   kfree(comp);
> > 
> > hm... zcomp_destroy(comp) ?
> 
> It's not possible to use zcomp_destroy() here. It tries to access
> field of comp->stream which could be NULL.

ah, yep. my bad.

-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 8/8] zram: enable contextless compression alg in zram

2015-10-14 Thread Sergey Senozhatsky
On (10/14/15 16:38), Joonsoo Kim wrote:
[..]
> @@ -352,6 +352,7 @@ static ssize_t comp_algorithm_show(struct device *dev,
>   size_t sz;
>   struct zram *zram = dev_to_zram(dev);
>  
> + deprecated_attr_warn("comp_algorithm");
>   down_read(>init_lock);
>   sz = zcomp_available_show(zram->compressor, buf);
>   up_read(>init_lock);

oh, one more thing.

deprecated_attr_warn() should come with 
`Documentation/ABI/obsolete/sysfs-block-zram' update.
something like:

diff --git a/Documentation/ABI/obsolete/sysfs-block-zram 
b/Documentation/ABI/obsolete/sysfs-block-zram
index 720ea92..ad5b59d 100644
--- a/Documentation/ABI/obsolete/sysfs-block-zram
+++ b/Documentation/ABI/obsolete/sysfs-block-zram
@@ -117,3 +117,14 @@ Description:
Downgraded to write-only node: so it's possible to set new
value only; its current value is stored in zram/mm_stat
node.
+
+What:  /sys/block/zram/comp_algorithm
+Date:  XXX
+Contact:   XXX
+Description:
+   The comp_algorithm file is read/write and provides information
+   on available, currently selected compression algorithm (read
+   operation) and lets one to change the compression algorithm
+   (write operation).
+   Downgraded to write-only node: use `/proc/crypto' to get the
+   list of supported compression algorithms.


---


And I guess Cc `Jonathan Corbet ' (doc maintainer) and
'linux-...@vger.kernel.org' will be the right thing to do here.

-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] hwrng: stm32 - Fix build with CONFIG_PM

2015-10-14 Thread Herbert Xu
On Wed, Oct 14, 2015 at 05:04:55PM +0100, Daniel Thompson wrote:
> Commit c6a97c42e399 ("hwrng: stm32 - add support for STM32 HW RNG")
> was inadequately tested (actually it was tested quite hard so
> incompetent would be a better description that inadequate) and does
> not compile on platforms with CONFIG_PM set.
> 
> Fix this.
> 
> Signed-off-by: Daniel Thompson 

Patch applied.  Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 8/8] zram: enable contextless compression alg in zram

2015-10-14 Thread Joonsoo Kim
On Thu, Oct 15, 2015 at 11:05:49AM +0900, Sergey Senozhatsky wrote:
> On (10/14/15 16:38), Joonsoo Kim wrote:
> [..]
> > @@ -352,6 +352,7 @@ static ssize_t comp_algorithm_show(struct device *dev,
> > size_t sz;
> > struct zram *zram = dev_to_zram(dev);
> >  
> > +   deprecated_attr_warn("comp_algorithm");
> > down_read(>init_lock);
> > sz = zcomp_available_show(zram->compressor, buf);
> > up_read(>init_lock);
> 
> oh, one more thing.
> 
> deprecated_attr_warn() should come with 
> `Documentation/ABI/obsolete/sysfs-block-zram' update.
> something like:
> 
> diff --git a/Documentation/ABI/obsolete/sysfs-block-zram 
> b/Documentation/ABI/obsolete/sysfs-block-zram
> index 720ea92..ad5b59d 100644
> --- a/Documentation/ABI/obsolete/sysfs-block-zram
> +++ b/Documentation/ABI/obsolete/sysfs-block-zram
> @@ -117,3 +117,14 @@ Description:
> Downgraded to write-only node: so it's possible to set new
> value only; its current value is stored in zram/mm_stat
> node.
> +
> +What:  /sys/block/zram/comp_algorithm
> +Date:  XXX
> +Contact:   XXX
> +Description:
> +   The comp_algorithm file is read/write and provides information
> +   on available, currently selected compression algorithm (read
> +   operation) and lets one to change the compression algorithm
> +   (write operation).
> +   Downgraded to write-only node: use `/proc/crypto' to get the
> +   list of supported compression algorithms.
> 
> 
> ---
> 
> 
> And I guess Cc `Jonathan Corbet ' (doc maintainer) and
> 'linux-...@vger.kernel.org' will be the right thing to do here.

Okay. I will do it in next spin.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: Allow drivers to build if COMPILE_TEST is enabled

2015-10-14 Thread Herbert Xu
On Wed, Oct 14, 2015 at 05:03:30AM +0800, kbuild test robot wrote:
> Hi Javier,
> 
> [auto build test WARNING on cryptodev/master -- if it's inappropriate base, 
> please suggest rules for selecting the more suitable base]

Javier, please make sure these warnings are fixed before you enable
COMPILE_TEST.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html