Re: [PATCH v2 14/17] powerpc: crypto: nx driver code supporting nx encryption

2012-04-10 Thread Kent Yoder
Hi Dave,

On Tue, 2012-04-10 at 14:41 -0400, David Miller wrote:
> From: Kent Yoder 
> Date: Tue, 10 Apr 2012 10:10:57 -0500
> 
> > These routines add the base device driver code supporting the Power7+
> > in-Nest encryption accelerator (nx) device.
> > 
> > Signed-off-by: Kent Yoder 
> 
> This patch should be earlier in the series, so it can
> appear before the drivers which use the helper routines
> in here.

  I wasn't sure which order to post these in since the structures I
register with the crypto api in this patch live in the earlier .c files,
so there's a circular dependency.  I can reorder if you want though.

Kent

> 


--
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 v2 14/17] powerpc: crypto: nx driver code supporting nx encryption

2012-04-10 Thread David Miller
From: Kent Yoder 
Date: Tue, 10 Apr 2012 10:10:57 -0500

> These routines add the base device driver code supporting the Power7+
> in-Nest encryption accelerator (nx) device.
> 
> Signed-off-by: Kent Yoder 

This patch should be earlier in the series, so it can
appear before the drivers which use the helper routines
in here.
--
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 v2 17/17] powerpc: crypto: enable the PFO-based encryption device

2012-04-10 Thread Kent Yoder
This patch adds the cas bits to advertise support for the Platform
Facilities Option (PFO) based encryption accelerator device. The nx
device driver provides support for this hardware feature.

Signed-off-by: Kent Yoder 
---
 arch/powerpc/kernel/prom_init.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 26f6317..604b4c4 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -702,6 +702,7 @@ static void __init early_cmdline_parse(void)
 #endif
 #define OV5_TYPE1_AFFINITY 0x80/* Type 1 NUMA affinity */
 #define OV5_PFO_HW_RNG 0x80/* PFO Random Number Generator */
+#define OV5_PFO_HW_ENCR0x20/* PFO Encryption Accelerator */
 
 /* Option Vector 6: IBM PAPR hints */
 #define OV6_LINUX  0x02/* Linux is our OS */
@@ -769,7 +770,7 @@ static unsigned char ibm_architecture_vec[] = {
0,
0,
0,
-   OV5_PFO_HW_RNG,
+   OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR,
 
/* option vector 6: IBM PAPR hints */
4 - 2,  /* length */
-- 
1.7.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 v2 02/17] powerpc: Add pseries update notifier for OFDT prop changes

2012-04-10 Thread Kent Yoder
This adds an update notifier mechanism for changes to properties in the
device tree.  One use of this would be a device driver that needs to act
on changes to it's properties in the device tree after a live migration
or a dynamic activation that is triggered by updates to ofdt properties.

Signed-off-by: Robert Jennings 
Signed-off-by: Kent Yoder 
---
 arch/powerpc/include/asm/pSeries_reconfig.h |   12 
 arch/powerpc/platforms/pseries/reconfig.c   |7 +++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/pSeries_reconfig.h 
b/arch/powerpc/include/asm/pSeries_reconfig.h
index 23cd6cc..c07edfe 100644
--- a/arch/powerpc/include/asm/pSeries_reconfig.h
+++ b/arch/powerpc/include/asm/pSeries_reconfig.h
@@ -13,6 +13,18 @@
 #define PSERIES_RECONFIG_REMOVE0x0002
 #define PSERIES_DRCONF_MEM_ADD 0x0003
 #define PSERIES_DRCONF_MEM_REMOVE  0x0004
+#define PSERIES_UPDATE_PROPERTY0x0005
+
+/**
+ * pSeries_reconfig_notify - Notifier value structure for OFDT property updates
+ *
+ * @node: Device tree node which owns the property being updated
+ * @property: Updated property
+ */
+struct pSeries_reconfig_prop_update {
+   struct device_node *node;
+   struct property *property;
+};
 
 #ifdef CONFIG_PPC_PSERIES
 extern int pSeries_reconfig_notifier_register(struct notifier_block *);
diff --git a/arch/powerpc/platforms/pseries/reconfig.c 
b/arch/powerpc/platforms/pseries/reconfig.c
index 168651a..7b3bf76 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -103,11 +103,13 @@ int pSeries_reconfig_notifier_register(struct 
notifier_block *nb)
 {
return blocking_notifier_chain_register(&pSeries_reconfig_chain, nb);
 }
+EXPORT_SYMBOL_GPL(pSeries_reconfig_notifier_register);
 
 void pSeries_reconfig_notifier_unregister(struct notifier_block *nb)
 {
blocking_notifier_chain_unregister(&pSeries_reconfig_chain, nb);
 }
+EXPORT_SYMBOL_GPL(pSeries_reconfig_notifier_unregister);
 
 int pSeries_reconfig_notify(unsigned long action, void *p)
 {
@@ -426,6 +428,7 @@ static int do_remove_property(char *buf, size_t bufsize)
 static int do_update_property(char *buf, size_t bufsize)
 {
struct device_node *np;
+   struct pSeries_reconfig_prop_update upd_value;
unsigned char *value;
char *name, *end, *next_prop;
int rc, length;
@@ -454,6 +457,10 @@ static int do_update_property(char *buf, size_t bufsize)
return -ENODEV;
}
 
+   upd_value.node = np;
+   upd_value.property = newprop;
+   pSeries_reconfig_notify(PSERIES_UPDATE_PROPERTY, &upd_value);
+
rc = prom_update_property(np, newprop, oldprop);
if (rc)
return rc;
-- 
1.7.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 v2 01/17] powerpc: Add new hvcall constants to support PFO

2012-04-10 Thread Kent Yoder
The Platform Facilities Option (PFO) adds several new h_calls and
more return codes.

Signed-off-by: Robert Jennings 
Signed-off-by: Kent Yoder 
---
 arch/powerpc/include/asm/hvcall.h |   25 +++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/hvcall.h 
b/arch/powerpc/include/asm/hvcall.h
index 1c324ff..6122523 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -77,8 +77,27 @@
 #define H_MR_CONDITION  -43
 #define H_NOT_ENOUGH_RESOURCES -44
 #define H_R_STATE   -45
-#define H_RESCINDEND-46
-#define H_MULTI_THREADS_ACTIVE -9005
+#define H_RESCINDED -46
+#define H_P2   -55
+#define H_P3   -56
+#define H_P4   -57
+#define H_P5   -58
+#define H_P6   -59
+#define H_P7   -60
+#define H_P8   -61
+#define H_P9   -62
+#define H_TOO_BIG  -64
+#define H_OVERLAP  -68
+#define H_INTERRUPT-69
+#define H_BAD_DATA -70
+#define H_NOT_ACTIVE   -71
+#define H_SG_LIST  -72
+#define H_OP_MODE  -73
+#define H_COP_HW   -74
+#define H_UNSUPPORTED_FLAG_START   -256
+#define H_UNSUPPORTED_FLAG_END -511
+#define H_MULTI_THREADS_ACTIVE -9005
+#define H_OUTSTANDING_COP_OPS  -9006
 

 /* Long Busy is a condition that can be returned by the firmware
@@ -240,6 +259,8 @@
 #define H_GET_MPP  0x2D4
 #define H_HOME_NODE_ASSOCIATIVITY 0x2EC
 #define H_BEST_ENERGY  0x2F4
+#define H_RANDOM   0x300
+#define H_COP  0x304
 #define H_GET_MPP_X0x314
 #define MAX_HCALL_OPCODE   H_GET_MPP_X
 
-- 
1.7.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 v2 14/17] powerpc: crypto: nx driver code supporting nx encryption

2012-04-10 Thread Kent Yoder
These routines add the base device driver code supporting the Power7+
in-Nest encryption accelerator (nx) device.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx.c|  711 +
 drivers/crypto/nx/nx.h|  192 +++
 drivers/crypto/nx/nx_csbcpb.h |  205 
 3 files changed, 1108 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx.c
 create mode 100644 drivers/crypto/nx/nx.h
 create mode 100644 drivers/crypto/nx/nx_csbcpb.h

diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
new file mode 100644
index 000..9371272
--- /dev/null
+++ b/drivers/crypto/nx/nx.c
@@ -0,0 +1,711 @@
+/**
+ * Routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+/**
+ * nx_hcall_sync - make an H_COP_OP hcall for the passed in op structure
+ *
+ * @nx_ctx: the crypto context handle
+ * @op: PFO operation struct to pass in
+ *
+ * Make the hcall, retrying while the hardware is busy
+ */
+int nx_hcall_sync(struct nx_crypto_ctx *nx_ctx, struct vio_pfo_op *op)
+{
+   int rc;
+   struct vio_dev *viodev = nx_driver.viodev;
+
+   atomic_inc(&(nx_ctx->stats->sync_ops));
+
+   do {
+   rc = vio_h_cop_sync(viodev, op);
+   } while (rc == -EBUSY);
+
+   if (rc) {
+   dev_dbg(&viodev->dev, "vio_h_cop_sync failed: rc: %d "
+   "hcall rc: %ld\n", rc, op->hcall_err);
+   atomic_inc(&(nx_ctx->stats->errors));
+   atomic_set(&(nx_ctx->stats->last_error), op->hcall_err);
+   atomic_set(&(nx_ctx->stats->last_error_pid), current->pid);
+   }
+
+   return rc;
+}
+
+/**
+ * nx_build_sg_list - build an NX scatter list describing a single  buffer
+ *
+ * @sg_head: pointer to the first scatter list element to build
+ * @start_addr: pointer to the linear buffer
+ * @len: length of the data at @start_addr
+ * @sgmax: the largest number of scatter list elements we're allowed to create
+ *
+ * This function will start writing nx_sg elements at @sg_head and keep
+ * writing them until all of the data from @start_addr is described or
+ * until sgmax elements have been written. Scatter list elements will be
+ * created such that none of the elements describes a buffer that crosses a 4K
+ * boundary.
+ */
+struct nx_sg *nx_build_sg_list(struct nx_sg *sg_head,
+  u8   *start_addr,
+  unsigned int  len,
+  u32   sgmax)
+{
+   unsigned int sg_len = 0;
+   struct nx_sg *sg;
+   u64 sg_addr = (u64)start_addr;
+   u64 end_addr;
+
+   /* determine the start and end for this address range - slightly
+* different if this is in VMALLOC_REGION */
+   if (is_vmalloc_addr(start_addr))
+   sg_addr = phys_to_abs(page_to_phys(vmalloc_to_page(start_addr)))
+ + offset_in_page(sg_addr);
+   else
+   sg_addr = virt_to_abs(sg_addr);
+
+   end_addr = sg_addr + len;
+
+   /* each iteration will write one struct nx_sg element and add the
+* length of data described by that element to sg_len. Once @len bytes
+* have been described (or @sgmax elements have been written), the
+* loop ends. min_t is used to ensure @end_addr falls on the same page
+* as sg_addr, if not, we need to create another nx_sg element for the
+* data on the next page */
+   for (sg = sg_head; sg_len < len; sg++) {
+   sg->addr = sg_addr;
+   sg_addr = min_t(u64, NX_PAGE_NUM(sg_addr + NX_PAGE_SIZE), 
end_addr);
+   sg->len = sg_addr - sg->addr;
+   sg_len += sg->len;
+
+   if ((sg - sg_head) == sgmax) {
+   pr_err("nx: scatter/gather list overflow, pid: %d\n",
+  current->pid);
+   return NULL;
+   }
+   }
+
+   /* return the moved sg_head pointe

[PATCH v2 10/17] powerpc: crypto: AES-GCM mode routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for AES in GCM mode on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-aes-gcm.c |  353 
 1 files changed, 353 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-aes-gcm.c

diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c
new file mode 100644
index 000..3c80b81
--- /dev/null
+++ b/drivers/crypto/nx/nx-aes-gcm.c
@@ -0,0 +1,353 @@
+/**
+ * AES GCM routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int gcm_aes_nx_set_key(struct crypto_aead *tfm,
+ const u8   *in_key,
+ unsigned intkey_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&tfm->base);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   struct nx_csbcpb *csbcpb_aead = nx_ctx->csbcpb_aead;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_AES);
+
+   switch (key_len) {
+   case AES_KEYSIZE_128:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_128);
+   NX_CPB_SET_KEY_SIZE(csbcpb_aead, NX_KS_AES_128);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_128];
+   break;
+   case AES_KEYSIZE_192:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_192);
+   NX_CPB_SET_KEY_SIZE(csbcpb_aead, NX_KS_AES_192);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_192];
+   break;
+   case AES_KEYSIZE_256:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_256);
+   NX_CPB_SET_KEY_SIZE(csbcpb_aead, NX_KS_AES_256);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_256];
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   csbcpb->cpb.hdr.mode = NX_MODE_AES_GCM;
+   memcpy(csbcpb->cpb.aes_gcm.key, in_key, key_len);
+
+   csbcpb_aead->cpb.hdr.mode = NX_MODE_AES_GCA;
+   memcpy(csbcpb_aead->cpb.aes_gca.key, in_key, key_len);
+
+   return 0;
+}
+
+static int gcm4106_aes_nx_set_key(struct crypto_aead *tfm,
+ const u8   *in_key,
+ unsigned intkey_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&tfm->base);
+   char *nonce = nx_ctx->priv.gcm.nonce;
+   int rc;
+
+   if (key_len < 4)
+   return -EINVAL;
+
+   key_len -= 4;
+
+   rc = gcm_aes_nx_set_key(tfm, in_key, key_len);
+   if (rc)
+   goto out;
+
+   memcpy(nonce, in_key + key_len, 4);
+out:
+   return rc;
+}
+
+static int gcm_aes_nx_setauthsize(struct crypto_aead *tfm,
+ unsigned int authsize)
+{
+   if (authsize > crypto_aead_alg(tfm)->maxauthsize)
+   return -EINVAL;
+
+   crypto_aead_crt(tfm)->authsize = authsize;
+
+   return 0;
+}
+
+static int gcm4106_aes_nx_setauthsize(struct crypto_aead *tfm,
+ unsigned int authsize)
+{
+   switch (authsize) {
+   case 8:
+   case 12:
+   case 16:
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   crypto_aead_crt(tfm)->authsize = authsize;
+
+   return 0;
+}
+
+static int nx_gca(struct nx_crypto_ctx  *nx_ctx,
+ struct scatterlist*assoc,
+ unsigned int   assoclen,
+ u8*out)
+{
+   struct nx_csbcpb *csbcpb_aead = nx_ctx->csbcpb_aead;
+   int rc = -EINVAL;
+   struct scatter_walk walk;
+   struct nx_sg *nx_sg = nx_ctx->in_sg;
+
+   if (assoclen > nx_ctx->ap->databytelen)
+   goto out;
+
+   if (assoclen <= AES_BLOCK_SIZE) {
+   scatterwalk_start(&walk, assoc);
+   scatterwalk_copychunks(out, &walk, assoclen,
+  SCATTERWALK_FROM_SG);
+   scatterwalk_done(&walk, SCATTERWALK_FROM_SG, 0);
+
+   rc = 0;
+   goto out;
+   }
+
+   nx_sg = nx_walk_and_build(nx_sg, nx_ctx->ap->sglen, 

[PATCH v2 09/17] powerpc: crypto: AES-ECB mode routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for AES in ECB mode on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-aes-ecb.c |  138 
 1 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-aes-ecb.c

diff --git a/drivers/crypto/nx/nx-aes-ecb.c b/drivers/crypto/nx/nx-aes-ecb.c
new file mode 100644
index 000..6db5a71
--- /dev/null
+++ b/drivers/crypto/nx/nx-aes-ecb.c
@@ -0,0 +1,138 @@
+/**
+ * AES ECB routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int ecb_aes_nx_set_key(struct crypto_tfm *tfm,
+ const u8  *in_key,
+ unsigned int   key_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(tfm);
+   struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_AES);
+
+   switch (key_len) {
+   case AES_KEYSIZE_128:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_128);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_128];
+   break;
+   case AES_KEYSIZE_192:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_192);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_192];
+   break;
+   case AES_KEYSIZE_256:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_256);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_256];
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   csbcpb->cpb.hdr.mode = NX_MODE_AES_ECB;
+   memcpy(csbcpb->cpb.aes_ecb.key, in_key, key_len);
+
+   return 0;
+}
+
+static int ecb_aes_nx_crypt(struct blkcipher_desc *desc,
+   struct scatterlist*dst,
+   struct scatterlist*src,
+   unsigned int   nbytes,
+   intenc)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_blkcipher_ctx(desc->tfm);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   int rc;
+
+   if (nbytes > nx_ctx->ap->databytelen)
+   return -EINVAL;
+
+   if (enc)
+   NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT;
+   else
+   NX_CPB_FDM(csbcpb) &= ~NX_FDM_ENDE_ENCRYPT;
+
+   rc = nx_build_sg_lists(nx_ctx, desc, dst, src, nbytes, NULL);
+   if (rc)
+   goto out;
+
+   if (!nx_ctx->op.inlen || !nx_ctx->op.outlen) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   rc = nx_hcall_sync(nx_ctx, &nx_ctx->op);
+   if (rc)
+   goto out;
+
+   atomic_inc(&(nx_ctx->stats->aes_ops));
+   atomic64_add(csbcpb->csb.processed_byte_count,
+&(nx_ctx->stats->aes_bytes));
+out:
+   return rc;
+}
+
+static int ecb_aes_nx_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist*dst,
+ struct scatterlist*src,
+ unsigned int   nbytes)
+{
+   return ecb_aes_nx_crypt(desc, dst, src, nbytes, 1);
+}
+
+static int ecb_aes_nx_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist*dst,
+ struct scatterlist*src,
+ unsigned int   nbytes)
+{
+   return ecb_aes_nx_crypt(desc, dst, src, nbytes, 0);
+}
+
+struct crypto_alg nx_ecb_aes_alg = {
+   .cra_name= "ecb(aes)",
+   .cra_driver_name = "ecb-aes-nx",
+   .cra_priority= 300,
+   .cra_flags   = CRYPTO_ALG_TYPE_BLKCIPHER,
+   .cra_blocksize   = AES_BLOCK_SIZE,
+   .cra_ctxsize = sizeof(struct nx_crypto_ctx),
+   .cra_type= &crypto_blkcipher_type,
+   .cra_module  = THIS_MODULE,
+   .cra_list= LIST_HEAD_INIT(nx_ecb_aes_alg.cra_list),
+   .cra_init= nx_crypto_ctx_aes_ecb_init,
+   .cra_exit= nx_crypto_ctx_exit,
+   .cra_blkcipher = {
+   .min_keysize = AES_MIN_KEY_SIZE,
+   .max_keysize =

[PATCH v2 16/17] powerpc: crypto: Build files for the nx device driver

2012-04-10 Thread Kent Yoder
These files support configuring and building the nx device driver.

Signed-off-by: Kent Yoder 
---
 arch/powerpc/Makefile  |1 +
 drivers/crypto/Kconfig |   17 +
 drivers/crypto/nx/Makefile |   11 +++
 3 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/Makefile

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 6524c6e..16e1bd7 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -160,6 +160,7 @@ core-$(CONFIG_KVM)  += arch/powerpc/kvm/
 core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/
 
 drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
+drivers-$(CONFIG_CRYPTO_DEV_NX) += drivers/crypto/nx/
 
 # Default to zImage, override when needed
 all: zImage
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index ab9abb4..4319248 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -295,4 +295,21 @@ config CRYPTO_DEV_TEGRA_AES
  To compile this driver as a module, choose M here: the module
  will be called tegra-aes.
 
+config CRYPTO_DEV_NX
+   tristate "Support for Power7+ in-Nest cryptographic accleration"
+   depends on PPC64 && IBMVIO
+   select CRYPTO_AES
+   select CRYPTO_CBC
+   select CRYPTO_ECB
+   select CRYPTO_CCM
+   select CRYPTO_GCM
+   select CRYPTO_AUTHENC
+   select CRYPTO_XCBC
+   select CRYPTO_SHA256
+   select CRYPTO_SHA512
+   help
+ Support for Power7+ in-Nest cryptographic acceleration. This
+ module supports acceleration for AES and SHA2 algorithms. If you
+ choose 'M' here, this module will be called nx_crypto.
+
 endif # CRYPTO_HW
diff --git a/drivers/crypto/nx/Makefile b/drivers/crypto/nx/Makefile
new file mode 100644
index 000..411ce59
--- /dev/null
+++ b/drivers/crypto/nx/Makefile
@@ -0,0 +1,11 @@
+obj-$(CONFIG_CRYPTO_DEV_NX) += nx-crypto.o
+nx-crypto-objs := nx.o \
+ nx_debugfs.o \
+ nx-aes-cbc.o \
+ nx-aes-ecb.o \
+ nx-aes-gcm.o \
+ nx-aes-ccm.o \
+ nx-aes-ctr.o \
+ nx-aes-xcbc.o \
+ nx-sha256.o \
+ nx-sha512.o
-- 
1.7.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 v2 06/17] powerpc: crypto: AES-CBC mode routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for AES in CBC mode on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-aes-cbc.c |  140 
 1 files changed, 140 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-aes-cbc.c

diff --git a/drivers/crypto/nx/nx-aes-cbc.c b/drivers/crypto/nx/nx-aes-cbc.c
new file mode 100644
index 000..dc3ea12
--- /dev/null
+++ b/drivers/crypto/nx/nx-aes-cbc.c
@@ -0,0 +1,140 @@
+/**
+ * AES CBC routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int cbc_aes_nx_set_key(struct crypto_tfm *tfm,
+ const u8  *in_key,
+ unsigned int   key_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(tfm);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_AES);
+
+   switch (key_len) {
+   case AES_KEYSIZE_128:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_128);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_128];
+   break;
+   case AES_KEYSIZE_192:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_192);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_192];
+   break;
+   case AES_KEYSIZE_256:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_256);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_256];
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   csbcpb->cpb.hdr.mode = NX_MODE_AES_CBC;
+   memcpy(csbcpb->cpb.aes_cbc.key, in_key, key_len);
+
+   return 0;
+}
+
+static int cbc_aes_nx_crypt(struct blkcipher_desc *desc,
+   struct scatterlist*dst,
+   struct scatterlist*src,
+   unsigned int   nbytes,
+   intenc)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_blkcipher_ctx(desc->tfm);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   int rc;
+
+   if (nbytes > nx_ctx->ap->databytelen)
+   return -EINVAL;
+
+   if (enc)
+   NX_CPB_FDM(csbcpb) |= NX_FDM_ENDE_ENCRYPT;
+   else
+   NX_CPB_FDM(csbcpb) &= ~NX_FDM_ENDE_ENCRYPT;
+
+   rc = nx_build_sg_lists(nx_ctx, desc, dst, src, nbytes,
+  csbcpb->cpb.aes_cbc.iv);
+   if (rc)
+   goto out;
+
+   if (!nx_ctx->op.inlen || !nx_ctx->op.outlen) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   rc = nx_hcall_sync(nx_ctx, &nx_ctx->op);
+   if (rc)
+   goto out;
+
+   atomic_inc(&(nx_ctx->stats->aes_ops));
+   atomic64_add(csbcpb->csb.processed_byte_count,
+&(nx_ctx->stats->aes_bytes));
+out:
+   return rc;
+}
+
+static int cbc_aes_nx_encrypt(struct blkcipher_desc *desc,
+ struct scatterlist*dst,
+ struct scatterlist*src,
+ unsigned int   nbytes)
+{
+   return cbc_aes_nx_crypt(desc, dst, src, nbytes, 1);
+}
+
+static int cbc_aes_nx_decrypt(struct blkcipher_desc *desc,
+ struct scatterlist*dst,
+ struct scatterlist*src,
+ unsigned int   nbytes)
+{
+   return cbc_aes_nx_crypt(desc, dst, src, nbytes, 0);
+}
+
+struct crypto_alg nx_cbc_aes_alg = {
+   .cra_name= "cbc(aes)",
+   .cra_driver_name = "cbc-aes-nx",
+   .cra_priority= 300,
+   .cra_flags   = CRYPTO_ALG_TYPE_BLKCIPHER,
+   .cra_blocksize   = AES_BLOCK_SIZE,
+   .cra_ctxsize = sizeof(struct nx_crypto_ctx),
+   .cra_type= &crypto_blkcipher_type,
+   .cra_module  = THIS_MODULE,
+   .cra_list= LIST_HEAD_INIT(nx_cbc_aes_alg.cra_list),
+   .cra_init= nx_crypto_ctx_aes_cbc_init,
+   .cra_exit= nx_crypto_ctx_exit,
+   .cra_blkcipher = {
+   .min_keysize = AES_MIN_KEY_SIZE,
+

[PATCH v2 15/17] powerpc: crypto: debugfs routines and docs for the nx device driver

2012-04-10 Thread Kent Yoder
These routines add debugfs files supporting the Power7+ in-Nest encryption
accelerator driver.

Signed-off-by: Kent Yoder 
---
 Documentation/ABI/testing/debugfs-pfo-nx-crypto |   45 ++
 drivers/crypto/nx/nx_debugfs.c  |  103 +++
 2 files changed, 148 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/debugfs-pfo-nx-crypto
 create mode 100644 drivers/crypto/nx/nx_debugfs.c

diff --git a/Documentation/ABI/testing/debugfs-pfo-nx-crypto 
b/Documentation/ABI/testing/debugfs-pfo-nx-crypto
new file mode 100644
index 000..685d5a4
--- /dev/null
+++ b/Documentation/ABI/testing/debugfs-pfo-nx-crypto
@@ -0,0 +1,45 @@
+What:  /sys/kernel/debug/nx-crypto/*
+Date:  March 2012
+KernelVersion: 3.4
+Contact:   Kent Yoder 
+Description:
+
+  These debugfs interfaces are built by the nx-crypto driver, built in
+arch/powerpc/crypto/nx.
+
+Error Detection
+===
+
+errors:
+- A u32 providing a total count of errors since the driver was loaded. The
+only errors counted here are those returned from the hcall, H_COP_OP.
+
+last_error:
+- The most recent non-zero return code from the H_COP_OP hcall. -EBUSY is not
+recorded here (the hcall will retry until -EBUSY goes away).
+
+last_error_pid:
+- The process ID of the process who received the most recent error from the
+hcall.
+
+Device Use
+==
+
+aes_bytes:
+- The total number of bytes encrypted using AES in any of the driver's
+supported modes.
+
+aes_ops:
+- The total number of AES operations submitted to the hardware.
+
+sha256_bytes:
+- The total number of bytes hashed by the hardware using SHA-256.
+
+sha256_ops:
+- The total number of SHA-256 operations submitted to the hardware.
+
+sha512_bytes:
+- The total number of bytes hashed by the hardware using SHA-512.
+
+sha512_ops:
+- The total number of SHA-512 operations submitted to the hardware.
diff --git a/drivers/crypto/nx/nx_debugfs.c b/drivers/crypto/nx/nx_debugfs.c
new file mode 100644
index 000..7ab2e8d
--- /dev/null
+++ b/drivers/crypto/nx/nx_debugfs.c
@@ -0,0 +1,103 @@
+/**
+ * debugfs routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+#ifdef CONFIG_DEBUG_FS
+
+/*
+ * debugfs
+ *
+ * For documentation on these attributes, please see:
+ *
+ * Documentation/ABI/testing/debugfs-pfo-nx-crypto
+ */
+
+int nx_debugfs_init(struct nx_crypto_driver *drv)
+{
+   struct nx_debugfs *dfs = &drv->dfs;
+
+   dfs->dfs_root = debugfs_create_dir(NX_NAME, NULL);
+
+   dfs->dfs_aes_ops =
+   debugfs_create_u32("aes_ops",
+  S_IRUSR | S_IRGRP | S_IROTH,
+  dfs->dfs_root, (u32 *)&drv->stats.aes_ops);
+   dfs->dfs_sha256_ops =
+   debugfs_create_u32("sha256_ops",
+  S_IRUSR | S_IRGRP | S_IROTH,
+  dfs->dfs_root,
+  (u32 *)&drv->stats.sha256_ops);
+   dfs->dfs_sha512_ops =
+   debugfs_create_u32("sha512_ops",
+  S_IRUSR | S_IRGRP | S_IROTH,
+  dfs->dfs_root,
+  (u32 *)&drv->stats.sha512_ops);
+   dfs->dfs_aes_bytes =
+   debugfs_create_u64("aes_bytes",
+  S_IRUSR | S_IRGRP | S_IROTH,
+  dfs->dfs_root,
+  (u64 *)&drv->stats.aes_bytes);
+   dfs->dfs_sha256_bytes =
+   debugfs_create_u64("sha256_bytes",
+  S_IRUSR | S_IRGRP | S_IROTH,
+  dfs->dfs_root,
+  (u64 *)&drv->stats.sha256_bytes);
+   dfs->dfs_sha512_bytes =
+   debugfs_create_u64("sha512_bytes",
+  S_IRUSR | S_IRGRP | S_IROTH,
+  dfs->dfs_root,
+  (u64 *)&drv->stats.sha512_bytes);
+   dfs->dfs_errors =
+   debugfs_create_u32("er

[PATCH v2 13/17] powerpc: crypto: SHA512 hash routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for SHA-512 hashing on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-sha512.c |  263 +
 1 files changed, 263 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-sha512.c

diff --git a/drivers/crypto/nx/nx-sha512.c b/drivers/crypto/nx/nx-sha512.c
new file mode 100644
index 000..2de839a
--- /dev/null
+++ b/drivers/crypto/nx/nx-sha512.c
@@ -0,0 +1,263 @@
+/**
+ * SHA-512 routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int nx_sha512_init(struct shash_desc *desc)
+{
+   struct sha512_state *sctx = shash_desc_ctx(desc);
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
+   struct nx_sg *out_sg;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_SHA);
+
+   memset(sctx, 0, sizeof *sctx);
+
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_SHA512];
+
+   NX_CPB_SET_DIGEST_SIZE(nx_ctx->csbcpb, NX_DS_SHA512);
+   out_sg = nx_build_sg_list(nx_ctx->out_sg, (u8 *)sctx->state,
+ SHA512_DIGEST_SIZE, nx_ctx->ap->sglen);
+   nx_ctx->op.outlen = (nx_ctx->out_sg - out_sg) * sizeof(struct nx_sg);
+
+   return 0;
+}
+
+static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   struct sha512_state *sctx = shash_desc_ctx(desc);
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
+   struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
+   struct nx_sg *in_sg;
+   u64 to_process, leftover, spbc_bits;
+   int rc = 0;
+
+   if (NX_CPB_FDM(csbcpb) & NX_FDM_CONTINUATION) {
+   /* we've hit the nx chip previously and we're updating again,
+* so copy over the partial digest */
+   memcpy(csbcpb->cpb.sha512.input_partial_digest,
+  csbcpb->cpb.sha512.message_digest, SHA512_DIGEST_SIZE);
+   }
+
+   /* 2 cases for total data len:
+*  1: <= SHA512_BLOCK_SIZE: copy into state, return 0
+*  2: > SHA512_BLOCK_SIZE: process X blocks, copy in leftover
+*/
+   if ((u64)len + sctx->count[0] <= SHA512_BLOCK_SIZE) {
+   memcpy(sctx->buf + sctx->count[0], data, len);
+   sctx->count[0] += len;
+   goto out;
+   }
+
+   /* to_process: the SHA512_BLOCK_SIZE data chunk to process in this
+* update */
+   to_process = (sctx->count[0] + len) & ~(SHA512_BLOCK_SIZE - 1);
+   leftover = (sctx->count[0] + len) & (SHA512_BLOCK_SIZE - 1);
+
+   if (sctx->count[0]) {
+   in_sg = nx_build_sg_list(nx_ctx->in_sg, (u8 *)sctx->buf,
+sctx->count[0], nx_ctx->ap->sglen);
+   in_sg = nx_build_sg_list(in_sg, (u8 *)data,
+to_process - sctx->count[0],
+nx_ctx->ap->sglen);
+   nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) *
+   sizeof(struct nx_sg);
+   } else {
+   in_sg = nx_build_sg_list(nx_ctx->in_sg, (u8 *)data,
+to_process, nx_ctx->ap->sglen);
+   nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) *
+   sizeof(struct nx_sg);
+   }
+
+   NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE;
+
+   if (!nx_ctx->op.inlen || !nx_ctx->op.outlen) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   rc = nx_hcall_sync(nx_ctx, &nx_ctx->op);
+   if (rc)
+   goto out;
+
+   atomic_inc(&(nx_ctx->stats->sha512_ops));
+
+   /* copy the leftover back into the state struct */
+   memcpy(sctx->buf, data + len - leftover, leftover);
+   sctx->count[0] = leftover;
+
+   spbc_bits = csbcpb->cpb.sha512.spbc * 8;
+   csbcpb->cpb.sha512.message_bit_length_lo += spbc_bits;
+   if (csbcpb->cpb.sha512.message_bit_length_lo < spbc_bits)
+   csbcpb->cpb.sha512.message_bit_length_hi++;
+
+   /* everythin

[PATCH v2 11/17] powerpc: crypto: AES-XCBC mode routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for AES in XCBC mode on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-aes-xcbc.c |  234 +++
 1 files changed, 234 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-aes-xcbc.c

diff --git a/drivers/crypto/nx/nx-aes-xcbc.c b/drivers/crypto/nx/nx-aes-xcbc.c
new file mode 100644
index 000..f0eadb1
--- /dev/null
+++ b/drivers/crypto/nx/nx-aes-xcbc.c
@@ -0,0 +1,234 @@
+/**
+ * AES XCBC routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+struct xcbc_state {
+   u8 state[AES_BLOCK_SIZE];
+   unsigned int count;
+   u8 buffer[AES_BLOCK_SIZE];
+};
+
+static int nx_xcbc_set_key(struct crypto_shash *desc,
+  const u8*in_key,
+  unsigned int key_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_shash_ctx(desc);
+
+   switch (key_len) {
+   case AES_KEYSIZE_128:
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_128];
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   memcpy(nx_ctx->priv.xcbc.key, in_key, key_len);
+
+   return 0;
+}
+
+static int nx_xcbc_init(struct shash_desc *desc)
+{
+   struct xcbc_state *sctx = shash_desc_ctx(desc);
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   struct nx_sg *out_sg;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_AES);
+
+   memset(sctx, 0, sizeof *sctx);
+
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_128);
+   csbcpb->cpb.hdr.mode = NX_MODE_AES_XCBC_MAC;
+
+   memcpy(csbcpb->cpb.aes_xcbc.key, nx_ctx->priv.xcbc.key, AES_BLOCK_SIZE);
+   memset(nx_ctx->priv.xcbc.key, 0, sizeof *nx_ctx->priv.xcbc.key);
+
+   out_sg = nx_build_sg_list(nx_ctx->out_sg, (u8 *)sctx->state,
+ AES_BLOCK_SIZE, nx_ctx->ap->sglen);
+   nx_ctx->op.outlen = (nx_ctx->out_sg - out_sg) * sizeof(struct nx_sg);
+
+   return 0;
+}
+
+static int nx_xcbc_update(struct shash_desc *desc,
+ const u8  *data,
+ unsigned int   len)
+{
+   struct xcbc_state *sctx = shash_desc_ctx(desc);
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   struct nx_sg *in_sg;
+   u32 to_process, leftover;
+   int rc = 0;
+
+   if (NX_CPB_FDM(csbcpb) & NX_FDM_CONTINUATION) {
+   /* we've hit the nx chip previously and we're updating again,
+* so copy over the partial digest */
+   memcpy(csbcpb->cpb.aes_xcbc.cv,
+  csbcpb->cpb.aes_xcbc.out_cv_mac, AES_BLOCK_SIZE);
+   }
+
+   /* 2 cases for total data len:
+*  1: <= AES_BLOCK_SIZE: copy into state, return 0
+*  2: > AES_BLOCK_SIZE: process X blocks, copy in leftover
+*/
+   if (len + sctx->count <= AES_BLOCK_SIZE) {
+   memcpy(sctx->buffer + sctx->count, data, len);
+   sctx->count += len;
+   goto out;
+   }
+
+   /* to_process: the AES_BLOCK_SIZE data chunk to process in this
+* update */
+   to_process = (sctx->count + len) & ~(AES_BLOCK_SIZE - 1);
+   leftover = (sctx->count + len) & (AES_BLOCK_SIZE - 1);
+
+   /* the hardware will not accept a 0 byte operation for this algorithm
+* and the operation MUST be finalized to be correct. So if we happen
+* to get an update that falls on a block sized boundary, we must
+* save off the last block to finalize with later. */
+   if (!leftover) {
+   to_process -= AES_BLOCK_SIZE;
+   leftover = AES_BLOCK_SIZE;
+   }
+
+   if (sctx->count) {
+   in_sg = nx_build_sg_list(nx_ctx->in_sg, sctx->buffer,
+sctx->count, nx_ctx->ap->sglen);
+   in_sg = nx_build_sg_list(in_sg, (u8 *)data,
+to_process 

[PATCH v2 08/17] powerpc: crypto: AES-CTR mode routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for AES in CTR mode on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-aes-ctr.c |  177 
 1 files changed, 177 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-aes-ctr.c

diff --git a/drivers/crypto/nx/nx-aes-ctr.c b/drivers/crypto/nx/nx-aes-ctr.c
new file mode 100644
index 000..141079c
--- /dev/null
+++ b/drivers/crypto/nx/nx-aes-ctr.c
@@ -0,0 +1,177 @@
+/**
+ * AES CTR routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int ctr_aes_nx_set_key(struct crypto_tfm *tfm,
+ const u8  *in_key,
+ unsigned int   key_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(tfm);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_AES);
+
+   switch (key_len) {
+   case AES_KEYSIZE_128:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_128);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_128];
+   break;
+   case AES_KEYSIZE_192:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_192);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_192];
+   break;
+   case AES_KEYSIZE_256:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_256);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_256];
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   csbcpb->cpb.hdr.mode = NX_MODE_AES_CTR;
+   memcpy(csbcpb->cpb.aes_ctr.key, in_key, key_len);
+
+   return 0;
+}
+
+static int ctr3686_aes_nx_set_key(struct crypto_tfm *tfm,
+ const u8  *in_key,
+ unsigned int   key_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(tfm);
+
+   if (key_len < CTR_RFC3686_NONCE_SIZE)
+   return -EINVAL;
+
+   memcpy(nx_ctx->priv.ctr.iv,
+  in_key + key_len - CTR_RFC3686_NONCE_SIZE,
+  CTR_RFC3686_NONCE_SIZE);
+
+   key_len -= CTR_RFC3686_NONCE_SIZE;
+
+   return ctr_aes_nx_set_key(tfm, in_key, key_len);
+}
+
+static int ctr_aes_nx_crypt(struct blkcipher_desc *desc,
+   struct scatterlist*dst,
+   struct scatterlist*src,
+   unsigned int   nbytes)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_blkcipher_ctx(desc->tfm);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   int rc;
+
+   if (nbytes > nx_ctx->ap->databytelen)
+   return -EINVAL;
+
+   rc = nx_build_sg_lists(nx_ctx, desc, dst, src, nbytes,
+  csbcpb->cpb.aes_ctr.iv);
+   if (rc)
+   goto out;
+
+   if (!nx_ctx->op.inlen || !nx_ctx->op.outlen) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   rc = nx_hcall_sync(nx_ctx, &nx_ctx->op);
+   if (rc)
+   goto out;
+
+   atomic_inc(&(nx_ctx->stats->aes_ops));
+   atomic64_add(csbcpb->csb.processed_byte_count,
+&(nx_ctx->stats->aes_bytes));
+out:
+   return rc;
+}
+
+static int ctr3686_aes_nx_crypt(struct blkcipher_desc *desc,
+   struct scatterlist*dst,
+   struct scatterlist*src,
+   unsigned int   nbytes)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_blkcipher_ctx(desc->tfm);
+   u8 *iv = nx_ctx->priv.ctr.iv;
+
+   memcpy(iv + CTR_RFC3686_NONCE_SIZE,
+  desc->info, CTR_RFC3686_IV_SIZE);
+   iv[15] = 1;
+
+   desc->info = nx_ctx->priv.ctr.iv;
+
+   return ctr_aes_nx_crypt(desc, dst, src, nbytes);
+}
+
+struct crypto_alg nx_ctr_aes_alg = {
+   .cra_name= "ctr(aes)",
+   .cra_driver_name = "ctr-aes-nx",
+   .cra_priority= 300,
+   .cra_flags   = CRYPTO_ALG_TYPE_BLKCIPHER,
+   .cra_blocksize   = 1,
+   .cra_ctxsize = sizeof(struct nx_crypto_ctx),
+ 

[PATCH v2 12/17] powerpc: crypto: SHA256 hash routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for SHA-256 hashing on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-sha256.c |  244 +
 1 files changed, 244 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-sha256.c

diff --git a/drivers/crypto/nx/nx-sha256.c b/drivers/crypto/nx/nx-sha256.c
new file mode 100644
index 000..239cc3b
--- /dev/null
+++ b/drivers/crypto/nx/nx-sha256.c
@@ -0,0 +1,244 @@
+/**
+ * SHA-256 routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2011-2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int nx_sha256_init(struct shash_desc *desc)
+{
+   struct sha256_state *sctx = shash_desc_ctx(desc);
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
+   struct nx_sg *out_sg;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_SHA);
+
+   memset(sctx, 0, sizeof *sctx);
+
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_SHA256];
+
+   NX_CPB_SET_DIGEST_SIZE(nx_ctx->csbcpb, NX_DS_SHA256);
+   out_sg = nx_build_sg_list(nx_ctx->out_sg, (u8 *)sctx->state,
+ SHA256_DIGEST_SIZE, nx_ctx->ap->sglen);
+   nx_ctx->op.outlen = (nx_ctx->out_sg - out_sg) * sizeof(struct nx_sg);
+
+   return 0;
+}
+
+static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
+   unsigned int len)
+{
+   struct sha256_state *sctx = shash_desc_ctx(desc);
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&desc->tfm->base);
+   struct nx_csbcpb *csbcpb = (struct nx_csbcpb *)nx_ctx->csbcpb;
+   struct nx_sg *in_sg;
+   u64 to_process, leftover;
+   int rc = 0;
+
+   if (NX_CPB_FDM(csbcpb) & NX_FDM_CONTINUATION) {
+   /* we've hit the nx chip previously and we're updating again,
+* so copy over the partial digest */
+   memcpy(csbcpb->cpb.sha256.input_partial_digest,
+  csbcpb->cpb.sha256.message_digest, SHA256_DIGEST_SIZE);
+   }
+
+   /* 2 cases for total data len:
+*  1: <= SHA256_BLOCK_SIZE: copy into state, return 0
+*  2: > SHA256_BLOCK_SIZE: process X blocks, copy in leftover
+*/
+   if (len + sctx->count <= SHA256_BLOCK_SIZE) {
+   memcpy(sctx->buf + sctx->count, data, len);
+   sctx->count += len;
+   goto out;
+   }
+
+   /* to_process: the SHA256_BLOCK_SIZE data chunk to process in this
+* update */
+   to_process = (sctx->count + len) & ~(SHA256_BLOCK_SIZE - 1);
+   leftover = (sctx->count + len) & (SHA256_BLOCK_SIZE - 1);
+
+   if (sctx->count) {
+   in_sg = nx_build_sg_list(nx_ctx->in_sg, (u8 *)sctx->buf,
+sctx->count, nx_ctx->ap->sglen);
+   in_sg = nx_build_sg_list(in_sg, (u8 *)data,
+to_process - sctx->count,
+nx_ctx->ap->sglen);
+   nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) *
+   sizeof(struct nx_sg);
+   } else {
+   in_sg = nx_build_sg_list(nx_ctx->in_sg, (u8 *)data,
+to_process, nx_ctx->ap->sglen);
+   nx_ctx->op.inlen = (nx_ctx->in_sg - in_sg) *
+   sizeof(struct nx_sg);
+   }
+
+   NX_CPB_FDM(csbcpb) |= NX_FDM_INTERMEDIATE;
+
+   if (!nx_ctx->op.inlen || !nx_ctx->op.outlen) {
+   rc = -EINVAL;
+   goto out;
+   }
+
+   rc = nx_hcall_sync(nx_ctx, &nx_ctx->op);
+   if (rc)
+   goto out;
+
+   atomic_inc(&(nx_ctx->stats->sha256_ops));
+
+   /* copy the leftover back into the state struct */
+   memcpy(sctx->buf, data + len - leftover, leftover);
+   sctx->count = leftover;
+
+   csbcpb->cpb.sha256.message_bit_length += (u64)
+   (csbcpb->cpb.sha256.spbc * 8);
+
+   /* everything after the first update is continuation */
+   NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
+out:
+   return rc;
+}
+
+static int nx_sha256_final(struct shash_desc *desc, u

[PATCH v2 03/17] powerpc: Add PFO support to the VIO bus

2012-04-10 Thread Kent Yoder
Add support for the Platform Facilities Option (PFO) to the VIO bus.
These devices have a separate root node in OpenFirmware which
requires additional parsing to map into the existing VIO device
structure fields. This adds the interface for PFO device drivers to
make synchronous hypervisor calls.

Signed-off-by: Robert Jennings 
Signed-off-by: Kent Yoder 
---
 arch/powerpc/include/asm/vio.h |   46 +++
 arch/powerpc/kernel/vio.c  |  273 ++--
 2 files changed, 280 insertions(+), 39 deletions(-)

diff --git a/arch/powerpc/include/asm/vio.h b/arch/powerpc/include/asm/vio.h
index 6bfd5ff..b19adf7 100644
--- a/arch/powerpc/include/asm/vio.h
+++ b/arch/powerpc/include/asm/vio.h
@@ -46,6 +46,48 @@
 
 struct iommu_table;
 
+/*
+ * Platform Facilities Option (PFO)-specific data
+ */
+
+/* Starting unit address for PFO devices on the VIO BUS */
+#define VIO_BASE_PFO_UA0x5000
+
+/**
+ * vio_pfo_op - PFO operation parameters
+ *
+ * @flags: h_call subfunctions and modifiers
+ * @in: Input data block logical real address
+ * @inlen: If non-negative, the length of the input data block.  If negative,
+ * the length of the input data descriptor list in bytes.
+ * @out: Output data block logical real address
+ * @outlen: If non-negative, the length of the input data block.  If negative,
+ * the length of the input data descriptor list in bytes.
+ * @csbcpb: Logical real address of the 4k naturally-aligned storage block
+ * containing the CSB & optional FC field specific CPB
+ * @timeout: # of milliseconds to retry h_call, 0 for no timeout.
+ * @hcall_err: pointer to return the h_call return value, else NULL
+ */
+struct vio_pfo_op {
+   u64 flags;
+   s64 in;
+   s64 inlen;
+   s64 out;
+   s64 outlen;
+   u64 csbcpb;
+   void *done;
+   unsigned long handle;
+   unsigned int timeout;
+   long hcall_err;
+};
+
+/* End PFO specific data */
+
+enum vio_dev_family {
+   VDEVICE,/* The OF node is a child of /vdevice */
+   PFO,/* The OF node is a child of /ibm,platform-facilities */
+};
+
 /**
  * vio_dev - This structure is used to describe virtual I/O devices.
  *
@@ -58,6 +100,7 @@ struct vio_dev {
const char *name;
const char *type;
uint32_t unit_address;
+   uint32_t resource_id;
unsigned int irq;
struct {
size_t desired;
@@ -65,6 +108,7 @@ struct vio_dev {
size_t allocated;
atomic_t allocs_failed;
} cmo;
+   enum vio_dev_family family;
struct device dev;
 };
 
@@ -95,6 +139,8 @@ extern void vio_cmo_set_dev_desired(struct vio_dev *viodev, 
size_t desired);
 
 extern void __devinit vio_unregister_device(struct vio_dev *dev);
 
+extern int vio_h_cop_sync(struct vio_dev *vdev, struct vio_pfo_op *op);
+
 struct device_node;
 
 extern struct vio_dev *vio_register_device_node(
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index a3a9990..cb87301 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -14,7 +14,9 @@
  *  2 of the License, or (at your option) any later version.
  */
 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -709,13 +711,26 @@ static int vio_cmo_bus_probe(struct vio_dev *viodev)
struct vio_driver *viodrv = to_vio_driver(dev->driver);
unsigned long flags;
size_t size;
+   bool dma_capable = false;
+
+   /* A device requires entitlement if it has a DMA window property */
+   switch (viodev->family) {
+   case VDEVICE:
+   if (of_get_property(viodev->dev.of_node,
+   "ibm,my-dma-window", NULL))
+   dma_capable = true;
+   break;
+   case PFO:
+   dma_capable = false;
+   break;
+   default:
+   dev_warn(dev, "unknown device family: %d\n", viodev->family);
+   BUG();
+   break;
+   }
 
-   /*
-* Check to see that device has a DMA window and configure
-* entitlement for the device.
-*/
-   if (of_get_property(viodev->dev.of_node,
-   "ibm,my-dma-window", NULL)) {
+   /* Configure entitlement for the device. */
+   if (dma_capable) {
/* Check that the driver is CMO enabled and get desired DMA */
if (!viodrv->get_desired_dma) {
dev_err(dev, "%s: device driver does not support CMO\n",
@@ -1050,6 +1065,94 @@ static void vio_cmo_sysfs_init(void) { }
 EXPORT_SYMBOL(vio_cmo_entitlement_update);
 EXPORT_SYMBOL(vio_cmo_set_dev_desired);
 
+
+/*
+ * Platform Facilities Option (PFO) support
+ */
+
+/**
+ * vio_h_cop_sync - Perform a synchronous PFO co-processor operation
+ *
+ * @vdev - Pointer to a struct vio_dev for device
+ * @op - Pointer to a struct vio_pfo_op for the operation parameters
+ *
+ * Calls the 

[PATCH v2 04/17] hwrng: pseries - PFO-based hwrng driver

2012-04-10 Thread Kent Yoder
Adds support for the Platform Facilities Option (PFO)-based hardware
random number generator for POWER hardware.

Signed-off-by: Michael Neuling 
Signed-off-by: Robert Jennings 
Signed-off-by: Kent Yoder 
---
 drivers/char/hw_random/Kconfig   |   13 +
 drivers/char/hw_random/Makefile  |1 +
 drivers/char/hw_random/pseries-rng.c |   96 ++
 3 files changed, 110 insertions(+), 0 deletions(-)
 create mode 100644 drivers/char/hw_random/pseries-rng.c

diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 0689bf6..9355347 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -250,3 +250,16 @@ config UML_RANDOM
  (check your distro, or download from
  http://sourceforge.net/projects/gkernel/).  rngd periodically reads
  /dev/hwrng and injects the entropy into /dev/random.
+
+config HW_RANDOM_PSERIES
+   tristate "pSeries HW Random Number Generator support"
+   depends on HW_RANDOM && PPC64 && IBMVIO
+   default HW_RANDOM
+   ---help---
+ This driver provides kernel-side support for the Random Number
+ Generator hardware found on POWER7+ machines and above
+
+ To compile this driver as a module, choose M here: the
+ module will be called pseries-rng.
+
+ If unsure, say Y.
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index b2ff526..d901dfa 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o
 obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
 obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o
 obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o
+obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o
diff --git a/drivers/char/hw_random/pseries-rng.c 
b/drivers/char/hw_random/pseries-rng.c
new file mode 100644
index 000..5f11979
--- /dev/null
+++ b/drivers/char/hw_random/pseries-rng.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010 Michael Neuling IBM Corporation
+ *
+ * Driver for the pseries hardware RNG for POWER7+ and above
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+
+#define MODULE_NAME "pseries-rng"
+
+static int pseries_rng_data_read(struct hwrng *rng, u32 *data)
+{
+   if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) {
+   printk(KERN_ERR "pseries rng hcall error\n");
+   return 0;
+   }
+   return 8;
+}
+
+/**
+ * pseries_rng_get_desired_dma - Return desired DMA allocate for CMO operations
+ *
+ * This is a required function for a driver to operate in a CMO environment
+ * but this device does not make use of DMA allocations, return 0.
+ *
+ * Return value:
+ * Number of bytes of IO data the driver will need to perform well -> 0
+ */
+static unsigned long pseries_rng_get_desired_dma(struct vio_dev *vdev)
+{
+   return 0;
+};
+
+static struct hwrng pseries_rng = {
+   .name   = MODULE_NAME,
+   .data_read  = pseries_rng_data_read,
+};
+
+static int __init pseries_rng_probe(struct vio_dev *dev,
+   const struct vio_device_id *id)
+{
+   return hwrng_register(&pseries_rng);
+}
+
+static int __exit pseries_rng_remove(struct vio_dev *dev)
+{
+   hwrng_unregister(&pseries_rng);
+   return 0;
+}
+
+static struct vio_device_id pseries_rng_driver_ids[] = {
+   { "ibm,random-v1", "ibm,random"},
+   { "", "" }
+};
+MODULE_DEVICE_TABLE(vio, pseries_rng_driver_ids);
+
+static struct vio_driver pseries_rng_driver = {
+   .name = MODULE_NAME,
+   .probe = pseries_rng_probe,
+   .remove = pseries_rng_remove,
+   .get_desired_dma = pseries_rng_get_desired_dma,
+   .id_table = pseries_rng_driver_ids
+};
+
+static int __init rng_init(void)
+{
+   printk(KERN_INFO "Registering IBM pSeries RNG driver\n");
+   return vio_register_driver(&pseries_rng_driver);
+}
+
+module_init(rng_init);
+
+static void __exit rng_exit(void)
+{
+   vio_unregister_driver(&pseries_rng_driver);
+}
+module_exit(rng_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Michael Neuling ");
+MODULE_DESCRIPTION("H/W RNG driver for IBM pSeries processors");
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord

[PATCH v2 07/17] powerpc: crypto: AES-CCM mode routines for nx encryption

2012-04-10 Thread Kent Yoder
These routines add support for AES in CCM mode on the Power7+ CPU's
in-Nest accelerator driver.

Signed-off-by: Kent Yoder 
---
 drivers/crypto/nx/nx-aes-ccm.c |  465 
 1 files changed, 465 insertions(+), 0 deletions(-)
 create mode 100644 drivers/crypto/nx/nx-aes-ccm.c

diff --git a/drivers/crypto/nx/nx-aes-ccm.c b/drivers/crypto/nx/nx-aes-ccm.c
new file mode 100644
index 000..e418bef
--- /dev/null
+++ b/drivers/crypto/nx/nx-aes-ccm.c
@@ -0,0 +1,465 @@
+/**
+ * AES CCM routines supporting the Power 7+ Nest Accelerators driver
+ *
+ * Copyright (C) 2012 International Business Machines 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 only.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Kent Yoder 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nx_csbcpb.h"
+#include "nx.h"
+
+
+static int ccm_aes_nx_set_key(struct crypto_aead *tfm,
+ const u8   *in_key,
+ unsigned intkey_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&tfm->base);
+   struct nx_csbcpb *csbcpb = nx_ctx->csbcpb;
+   struct nx_csbcpb *csbcpb_aead = nx_ctx->csbcpb_aead;
+
+   nx_ctx_init(nx_ctx, HCOP_FC_AES);
+
+   switch (key_len) {
+   case AES_KEYSIZE_128:
+   NX_CPB_SET_KEY_SIZE(csbcpb, NX_KS_AES_128);
+   NX_CPB_SET_KEY_SIZE(csbcpb_aead, NX_KS_AES_128);
+   nx_ctx->ap = &nx_ctx->props[NX_PROPS_AES_128];
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   csbcpb->cpb.hdr.mode = NX_MODE_AES_CCM;
+   memcpy(csbcpb->cpb.aes_ccm.key, in_key, key_len);
+
+   csbcpb_aead->cpb.hdr.mode = NX_MODE_AES_CCA;
+   memcpy(csbcpb_aead->cpb.aes_cca.key, in_key, key_len);
+
+   return 0;
+
+}
+
+static int ccm4309_aes_nx_set_key(struct crypto_aead *tfm,
+ const u8   *in_key,
+ unsigned intkey_len)
+{
+   struct nx_crypto_ctx *nx_ctx = crypto_tfm_ctx(&tfm->base);
+
+   if (key_len < 3)
+   return -EINVAL;
+
+   key_len -= 3;
+
+   memcpy(nx_ctx->priv.ccm.nonce, in_key + key_len, 3);
+
+   return ccm_aes_nx_set_key(tfm, in_key, key_len);
+}
+
+static int ccm_aes_nx_setauthsize(struct crypto_aead *tfm,
+ unsigned int authsize)
+{
+   switch (authsize) {
+   case 4:
+   case 6:
+   case 8:
+   case 10:
+   case 12:
+   case 14:
+   case 16:
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   crypto_aead_crt(tfm)->authsize = authsize;
+
+   return 0;
+}
+
+static int ccm4309_aes_nx_setauthsize(struct crypto_aead *tfm,
+ unsigned int authsize)
+{
+   switch (authsize) {
+   case 8:
+   case 12:
+   case 16:
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   crypto_aead_crt(tfm)->authsize = authsize;
+
+   return 0;
+}
+
+/* taken from crypto/ccm.c */
+static int set_msg_len(u8 *block, unsigned int msglen, int csize)
+{
+   __be32 data;
+
+   memset(block, 0, csize);
+   block += csize;
+
+   if (csize >= 4)
+   csize = 4;
+   else if (msglen > (unsigned int)(1 << (8 * csize)))
+   return -EOVERFLOW;
+
+   data = cpu_to_be32(msglen);
+   memcpy(block - csize, (u8 *)&data + 4 - csize, csize);
+
+   return 0;
+}
+
+/* taken from crypto/ccm.c */
+static inline int crypto_ccm_check_iv(const u8 *iv)
+{
+   /* 2 <= L <= 8, so 1 <= L' <= 7. */
+   if (1 > iv[0] || iv[0] > 7)
+   return -EINVAL;
+
+   return 0;
+}
+
+/* based on code from crypto/ccm.c */
+static int generate_b0(u8 *iv, unsigned int assoclen, unsigned int authsize,
+  unsigned int cryptlen, u8 *b0)
+{
+   unsigned int l, lp, m = authsize;
+   int rc;
+
+   memcpy(b0, iv, 16);
+
+   lp = b0[0];
+   l = lp + 1;
+
+   /* set m, bits 3-5 */
+   *b0 |= (8 * ((m - 2) / 2));
+
+   /* set adata, bit 6, if associated data is used */
+   if (assoclen)
+   *b0 |= 64;
+
+   rc = set_msg_len(b0 + 16 - l, cryptlen, l);
+
+   return rc;
+}
+
+static int generate_pat(u8   *iv,
+ 

[PATCH v2 05/17] pseries: Enabled the PFO-based RNG accelerator

2012-04-10 Thread Kent Yoder
This patch adds the cas bits to advertise support for the Platform
Facilities Option (PFO) based random number generator accerator.
The pseries-rng driver provides support for this hardware feature.

Signed-off-by: Robert Jennings 
Signed-off-by: Kent Yoder 
---
 arch/powerpc/kernel/prom_init.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 9986027..26f6317 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -701,6 +701,7 @@ static void __init early_cmdline_parse(void)
 #define OV5_XCMO   0x00
 #endif
 #define OV5_TYPE1_AFFINITY 0x80/* Type 1 NUMA affinity */
+#define OV5_PFO_HW_RNG 0x80/* PFO Random Number Generator */
 
 /* Option Vector 6: IBM PAPR hints */
 #define OV6_LINUX  0x02/* Linux is our OS */
@@ -748,7 +749,7 @@ static unsigned char ibm_architecture_vec[] = {
0,  /* don't halt */
 
/* option vector 5: PAPR/OF options */
-   13 - 2, /* length */
+   18 - 2, /* length */
0,  /* don't ignore, don't halt */
OV5_LPAR | OV5_SPLPAR | OV5_LARGE_PAGES | OV5_DRCONF_MEMORY |
OV5_DONATE_DEDICATE_CPU | OV5_MSI,
@@ -764,6 +765,11 @@ static unsigned char ibm_architecture_vec[] = {
 */
 #define IBM_ARCH_VEC_NRCORES_OFFSET100
W(NR_CPUS), /* number of cores supported */
+   0,
+   0,
+   0,
+   0,
+   OV5_PFO_HW_RNG,
 
/* option vector 6: IBM PAPR hints */
4 - 2,  /* length */
-- 
1.7.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 v2 00/17] Platform Facilities Option and crypto accelerators

2012-04-10 Thread Kent Yoder
ChangeLog for v2:
- move crypto driver sysfs stuff to debugfs (Greg K-H)
- Remove CONFIG_ dependencies for the CMO bits (Anton Blanchard)
- move nx driver code to drivers/crypto (Kumar Gala)
- Add inline comment for nx_build_sg_list (Rob Jennings)
- make sure kmalloc'd pointers are aligned (Rob Jennings)
- get rid of bitfields in nx_csbcpb.h (Rob Jennings)
- Compile against Ben Herrenschmidt's ppc device naming patch
- Rebase against latest upstream

Kent Yoder (12):
  powerpc: crypto: AES-CBC mode routines for nx encryption
  powerpc: crypto: AES-CCM mode routines for nx encryption
  powerpc: crypto: AES-CTR mode routines for nx encryption
  powerpc: crypto: AES-ECB mode routines for nx encryption
  powerpc: crypto: AES-GCM mode routines for nx encryption
  powerpc: crypto: AES-XCBC mode routines for nx encryption
  powerpc: crypto: SHA256 hash routines for nx encryption
  powerpc: crypto: SHA512 hash routines for nx encryption
  powerpc: crypto: nx driver code supporting nx encryption
  powerpc: crypto: debugfs routines and docs for the nx device driver
  powerpc: crypto: Build files for the nx device driver
  powerpc: crypto: enable the PFO-based encryption device

Michael Neuling (1):
  hwrng: pseries - PFO-based hwrng driver

Robert Jennings (4):
  powerpc: Add new hvcall constants to support PFO
  powerpc: Add pseries update notifier for OFDT prop changes
  powerpc: Add PFO support to the VIO bus
  pseries: Enabled the PFO-based RNG accelerator

 Documentation/ABI/testing/debugfs-pfo-nx-crypto |   45 ++
 arch/powerpc/Makefile   |1 +
 arch/powerpc/include/asm/hvcall.h   |   25 +-
 arch/powerpc/include/asm/pSeries_reconfig.h |   12 +
 arch/powerpc/include/asm/vio.h  |   46 ++
 arch/powerpc/kernel/prom_init.c |9 +-
 arch/powerpc/kernel/vio.c   |  273 --
 arch/powerpc/platforms/pseries/reconfig.c   |7 +
 drivers/char/hw_random/Kconfig  |   13 +
 drivers/char/hw_random/Makefile |1 +
 drivers/char/hw_random/pseries-rng.c|   96 +++
 drivers/crypto/Kconfig  |   17 +
 drivers/crypto/nx/Makefile  |   11 +
 drivers/crypto/nx/nx-aes-cbc.c  |  140 +
 drivers/crypto/nx/nx-aes-ccm.c  |  465 +++
 drivers/crypto/nx/nx-aes-ctr.c  |  177 ++
 drivers/crypto/nx/nx-aes-ecb.c  |  138 +
 drivers/crypto/nx/nx-aes-gcm.c  |  353 +++
 drivers/crypto/nx/nx-aes-xcbc.c |  234 
 drivers/crypto/nx/nx-sha256.c   |  244 
 drivers/crypto/nx/nx-sha512.c   |  263 +
 drivers/crypto/nx/nx.c  |  711 +++
 drivers/crypto/nx/nx.h  |  192 ++
 drivers/crypto/nx/nx_csbcpb.h   |  205 +++
 drivers/crypto/nx/nx_debugfs.c  |  103 
 25 files changed, 3739 insertions(+), 42 deletions(-)
 create mode 100644 Documentation/ABI/testing/debugfs-pfo-nx-crypto
 create mode 100644 drivers/char/hw_random/pseries-rng.c
 create mode 100644 drivers/crypto/nx/Makefile
 create mode 100644 drivers/crypto/nx/nx-aes-cbc.c
 create mode 100644 drivers/crypto/nx/nx-aes-ccm.c
 create mode 100644 drivers/crypto/nx/nx-aes-ctr.c
 create mode 100644 drivers/crypto/nx/nx-aes-ecb.c
 create mode 100644 drivers/crypto/nx/nx-aes-gcm.c
 create mode 100644 drivers/crypto/nx/nx-aes-xcbc.c
 create mode 100644 drivers/crypto/nx/nx-sha256.c
 create mode 100644 drivers/crypto/nx/nx-sha512.c
 create mode 100644 drivers/crypto/nx/nx.c
 create mode 100644 drivers/crypto/nx/nx.h
 create mode 100644 drivers/crypto/nx/nx_csbcpb.h
 create mode 100644 drivers/crypto/nx/nx_debugfs.c


--
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 0/3 v5] crypto: ux500 crypto and hash driver

2012-04-10 Thread Andreas Westin
Removed incorrect comments.

This adds a driver for the ST-Ericsson ux500 crypto hardware
module. It supports AES, DES and 3DES, the driver implements
support for AES-ECB,CBC and CTR.

Patches are also available at: http://www.df.lth.se/~triad/ux500-crypto/

Andreas Westin (3):
  crypto: ux500: Add driver for CRYP hardware.
  crypto: ux500: Add driver for HASH hardware
  mach-ux500: Crypto: core support for CRYP/HASH module.

 arch/arm/mach-ux500/board-mop500.c  |   48 +
 arch/arm/mach-ux500/board-u5500.c   |   48 +
 arch/arm/mach-ux500/clock.c |   18 +-
 arch/arm/mach-ux500/devices-common.c|   16 +
 arch/arm/mach-ux500/devices-common.h|   23 +
 arch/arm/mach-ux500/devices-db5500.h|4 +
 arch/arm/mach-ux500/devices-db8500.h|4 +
 arch/arm/mach-ux500/include/mach/crypto-ux500.h |   21 +
 arch/arm/mach-ux500/include/mach/devices.h  |3 +
 arch/arm/mach-ux500/ste-dma40-db5500.h  |9 +-
 drivers/crypto/Kconfig  |   11 +
 drivers/crypto/Makefile |1 +
 drivers/crypto/ux500/Kconfig|   30 +
 drivers/crypto/ux500/Makefile   |8 +
 drivers/crypto/ux500/cryp/Makefile  |   13 +
 drivers/crypto/ux500/cryp/cryp.c|  391 +
 drivers/crypto/ux500/cryp/cryp.h|  308 
 drivers/crypto/ux500/cryp/cryp_core.c   | 1785 
 drivers/crypto/ux500/cryp/cryp_irq.c|   45 +
 drivers/crypto/ux500/cryp/cryp_irq.h|   31 +
 drivers/crypto/ux500/cryp/cryp_irqp.h   |  125 ++
 drivers/crypto/ux500/cryp/cryp_p.h  |  124 ++
 drivers/crypto/ux500/hash/Makefile  |   11 +
 drivers/crypto/ux500/hash/hash_alg.h|  387 +
 drivers/crypto/ux500/hash/hash_core.c   | 2006 +++
 25 files changed, 5459 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/mach-ux500/include/mach/crypto-ux500.h
 create mode 100644 drivers/crypto/ux500/Kconfig
 create mode 100644 drivers/crypto/ux500/Makefile
 create mode 100644 drivers/crypto/ux500/cryp/Makefile
 create mode 100644 drivers/crypto/ux500/cryp/cryp.c
 create mode 100644 drivers/crypto/ux500/cryp/cryp.h
 create mode 100644 drivers/crypto/ux500/cryp/cryp_core.c
 create mode 100644 drivers/crypto/ux500/cryp/cryp_irq.c
 create mode 100644 drivers/crypto/ux500/cryp/cryp_irq.h
 create mode 100644 drivers/crypto/ux500/cryp/cryp_irqp.h
 create mode 100644 drivers/crypto/ux500/cryp/cryp_p.h
 create mode 100644 drivers/crypto/ux500/hash/Makefile
 create mode 100644 drivers/crypto/ux500/hash/hash_alg.h
 create mode 100644 drivers/crypto/ux500/hash/hash_core.c

-- 
1.7.9.4

--
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 3/3 v5] mach-ux500: Crypto: core support for CRYP/HASH module.

2012-04-10 Thread Andreas Westin
This adds the required platform data and calls to enable
the CRYP/HASH driver.

Acked-by: Linus Walleij 
Signed-off-by: Andreas Westin 
---
 arch/arm/mach-ux500/board-mop500.c |   48 
 arch/arm/mach-ux500/board-u5500.c  |   48 
 arch/arm/mach-ux500/clock.c|   18 ++-
 arch/arm/mach-ux500/devices-common.c   |   16 ++
 arch/arm/mach-ux500/devices-common.h   |   23 +
 arch/arm/mach-ux500/devices-db5500.h   |4 +++
 arch/arm/mach-ux500/devices-db8500.h   |4 +++
 arch/arm/mach-ux500/include/mach/devices.h |3 ++
 arch/arm/mach-ux500/ste-dma40-db5500.h |9 --
 9 files changed, 162 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500.c 
b/arch/arm/mach-ux500/board-mop500.c
index 5c00712..4e9bcd6 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "pins-db8500.h"
 #include "ste-dma40-db8500.h"
@@ -409,6 +410,45 @@ static void mop500_prox_deactivate(struct device *dev)
regulator_put(prox_regulator);
 }
 
+static struct cryp_platform_data u8500_cryp1_platform_data = {
+   .mem_to_engine = {
+   .dir = STEDMA40_MEM_TO_PERIPH,
+   .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
+   .dst_dev_type = DB8500_DMA_DEV48_CAC1_TX,
+   .src_info.data_width = STEDMA40_WORD_WIDTH,
+   .dst_info.data_width = STEDMA40_WORD_WIDTH,
+   .mode = STEDMA40_MODE_LOGICAL,
+   .src_info.psize = STEDMA40_PSIZE_LOG_4,
+   .dst_info.psize = STEDMA40_PSIZE_LOG_4,
+   },
+   .engine_to_mem = {
+   .dir = STEDMA40_PERIPH_TO_MEM,
+   .src_dev_type = DB8500_DMA_DEV48_CAC1_RX,
+   .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
+   .src_info.data_width = STEDMA40_WORD_WIDTH,
+   .dst_info.data_width = STEDMA40_WORD_WIDTH,
+   .mode = STEDMA40_MODE_LOGICAL,
+   .src_info.psize = STEDMA40_PSIZE_LOG_4,
+   .dst_info.psize = STEDMA40_PSIZE_LOG_4,
+   }
+};
+
+static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
+   .dir = STEDMA40_MEM_TO_PERIPH,
+   .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
+   .dst_dev_type = DB8500_DMA_DEV50_HAC1_TX,
+   .src_info.data_width = STEDMA40_WORD_WIDTH,
+   .dst_info.data_width = STEDMA40_WORD_WIDTH,
+   .mode = STEDMA40_MODE_LOGICAL,
+   .src_info.psize = STEDMA40_PSIZE_LOG_16,
+   .dst_info.psize = STEDMA40_PSIZE_LOG_16,
+};
+
+static struct hash_platform_data u8500_hash1_platform_data = {
+   .mem_to_engine = &u8500_hash_dma_cfg_tx,
+   .dma_filter = stedma40_filter,
+};
+
 /* add any platform devices here - TODO */
 static struct platform_device *mop500_platform_devs[] __initdata = {
&mop500_gpio_keys_device,
@@ -594,6 +634,12 @@ static void __init mop500_uart_init(void)
db8500_add_uart2(&uart2_plat);
 }
 
+static void __init u8500_cryp1_hash1_init(void)
+{
+   db8500_add_cryp1(&u8500_cryp1_platform_data);
+   db8500_add_hash1(&u8500_hash1_platform_data);
+}
+
 static struct platform_device *snowball_platform_devs[] __initdata = {
&snowball_led_dev,
&snowball_key_dev,
@@ -611,6 +657,8 @@ static void __init mop500_init_machine(void)
 
mop500_pins_init();
 
+   u8500_cryp1_hash1_init();
+
platform_add_devices(mop500_platform_devs,
ARRAY_SIZE(mop500_platform_devs));
 
diff --git a/arch/arm/mach-ux500/board-u5500.c 
b/arch/arm/mach-ux500/board-u5500.c
index 9de9e9c..865aaf8 100644
--- a/arch/arm/mach-ux500/board-u5500.c
+++ b/arch/arm/mach-ux500/board-u5500.c
@@ -23,9 +23,11 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "pins-db5500.h"
 #include "devices-db5500.h"
+#include "ste-dma40-db5500.h"
 #include 
 
 /*
@@ -89,6 +91,45 @@ static struct lm3530_platform_data u5500_als_platform_data = 
{
.brt_val = 0x7F,/* Max brightness */
 };
 
+static struct cryp_platform_data u5500_cryp1_platform_data = {
+   .mem_to_engine = {
+   .dir = STEDMA40_MEM_TO_PERIPH,
+   .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
+   .dst_dev_type = DB5500_DMA_DEV48_CRYPTO1_TX,
+   .src_info.data_width = STEDMA40_WORD_WIDTH,
+   .dst_info.data_width = STEDMA40_WORD_WIDTH,
+   .mode 

Re: [PATCH 2/3 v4] crypto: ux500: Add driver for HASH hardware

2012-04-10 Thread Andreas WESTIN


On 2012-04-09 09:09, Herbert Xu wrote:

On Fri, Mar 30, 2012 at 11:02:47AM +0200, Andreas Westin wrote:


+/**
+ * hash_hw_update - Updates current HASH computation hashing another part of
+ *  the message.
+ * @req:   Byte array containing the message to be hashed (caller
+ * allocated).
+ *
+ * Reentrancy: Non Re-entrant
+ */


As the crypto API is reentrant this comment suggests that this
driver cannot be accepted as is.


This is a legacy comment, it does not apply anymore. I will remove it 
and create a new patch.


Cheers
Andreas
--
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