sep: SEP update
PATCH 1/1 sep: SEP update
From: Mark Allyn <[email protected]>
This is basically a rewrite so there isn't a nice easy to present way of providing this as a patch series. This patch is a pull of Mark's new driver into the upstream staging area. On top of that are a series of patches by Andy Shevchenko to make it build on the current tree, fix a few things and even get it passed sparse.
The new driver supports the kernel crypto layer, passes the coding style checks, passes human taste checks and has proper kernel-doc formatted comments.
I've then folded back in some later fixes it was missing that got applied to to the kernel tree.
This should be ready for more serious review with a view to migration from the staging tree shortly.
---
drivers/staging/sep/Kconfig | 3 drivers/staging/sep/Makefile | 5 drivers/staging/sep/TODO | 5 drivers/staging/sep/sep_crypto.c | 3768 ++++++++++++++++++++++++++ drivers/staging/sep/sep_crypto.h | 348 ++ drivers/staging/sep/sep_dev.h | 99 - drivers/staging/sep/sep_driver.c | 2932 --------------------- drivers/staging/sep/sep_driver_api.h | 280 ++ drivers/staging/sep/sep_driver_config.h | 79 - drivers/staging/sep/sep_driver_hw_defs.h | 182 - drivers/staging/sep/sep_main.c | 4286 ++++++++++++++++++++++++++++++ drivers/staging/sep/sep_trace_events.h | 188 + 12 files changed, 8960 insertions(+), 3215 deletions(-) create mode 100644 drivers/staging/sep/sep_crypto.c create mode 100644 drivers/staging/sep/sep_crypto.h delete mode 100644 drivers/staging/sep/sep_driver.c create mode 100644 drivers/staging/sep/sep_main.c create mode 100644 drivers/staging/sep/sep_trace_events.h
drivers/staging/sep/Kconfig +2 -1
@@ -3,7 +3,8 @@ config DX_SEP depends on PCI help Discretix SEP driver; used for the security processor subsystem - on bard the Intel Mobile Internet Device. + on board the Intel Mobile Internet Device and adds SEP availability + to the kernel crypto infrastructure The driver's name is sep_driver.
drivers/staging/sep/Makefile +3 -2
@@ -1,2 +1,3 @@ -obj-$(CONFIG_DX_SEP) := sep_driver.o - +ccflags-y += -I$(srctree)/$(src) +obj-$(CONFIG_DX_SEP) += sep_driver.o +sep_driver-objs := sep_crypto.o sep_main.o
drivers/staging/sep/TODO +2 -3
@@ -1,4 +1,3 @@ Todo's so far (from Alan Cox) -- Check whether it can be plugged into any of the kernel crypto API - interfaces - Crypto API 'glue' is still not ready to submit -- Clean up un-needed debug prints - Started to work on this +- Clean up unused ioctls +- Clean up unused fields in ioctl structures
drivers/staging/sep/sep_crypto.c new file +3768 -0
2,980 lines not on this page · raw message
drivers/staging/sep/sep_crypto.h new file +348 -0
348 lines not on this page · raw message
drivers/staging/sep/sep_dev.h +65 -34
99 lines not on this page · raw message
drivers/staging/sep/sep_driver.c deleted +0 -2932
2,932 lines not on this page · raw message
drivers/staging/sep/sep_driver_api.h +227 -53
280 lines not on this page · raw message
drivers/staging/sep/sep_driver_config.h +67 -12
79 lines not on this page · raw message
drivers/staging/sep/sep_driver_hw_defs.h +4 -178
182 lines not on this page · raw message
drivers/staging/sep/sep_main.c new file +4286 -0
4,286 lines not on this page · raw message
drivers/staging/sep/sep_trace_events.h new file +188 -0
188 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 3 lines · Alan Cox
From: Mark Allyn <[email protected]>
The new driver supports the kernel crypto layer, passes the coding style checks, passes human taste checks and has proper kernel-doc formatted comments.
These are just taste comments.
drivers/staging/sep/sep_crypto.c
Quoted 1 line
drivers/staging/sep/sep_crypto.c +0
-0
[]
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
drivers/staging/sep/sep_crypto.c
Quoted 2 lines
drivers/staging/sep/sep_crypto.c +2
-0+/* #define DEBUG */ +#include <linux/init.h>
[]
drivers/staging/sep/sep_crypto.c line 155
Quoted 6 lines
drivers/staging/sep/sep_crypto.c +6
-0+ sep_work->callback = funct; + sep_work->data = data; +INIT_WORK (&sep_work->work, sep_do_callback); + result =queue_work (work_queue, &sep_work->work); +if (!result) { +pr_debug ("sep_crypto: queue_work failed\n" );
So these pr_debug and any other pr_<level> become:
pr_debug("queue_work failed\n");Quoted 6 lines
drivers/staging/sep/sep_crypto.c +6
-0+/* Debug - prints only if DEBUG is defined; follows kernel debug model */ +static void sep_dump (struct sep_device *sep,char *stg,void *start,int len) +{ +#if 0 +int ct1; +u8 *ptt;
drivers/staging/sep/sep_crypto.c line 503
Quoted 10 lines
drivers/staging/sep/sep_crypto.c +10
-0+ +dev_dbg (&sep->pdev->dev, +"Dump of %s starting at %08lx for %08x bytes\n" , + stg, (unsigned long )start, len); +for (ct1 =0 ; ct1 < len; ct1 +=1 ) { + ptt = (u8 *)(start + ct1); +dev_dbg (&sep->pdev->dev,"%02x " , *ptt); +if (ct1 %16 ==15 ) +dev_dbg (&sep->pdev->dev,"\n" ); + }
While this is #if 0, more likely it should
use print_hex_dump_bytes
drivers/staging/sep/sep_crypto.c line 546
Quoted 10 lines
drivers/staging/sep/sep_crypto.c +10
-0+/** +* RFC2451: Weak key check +* Returns: 1 (weak), 0 (not weak) +*/ +static int sep_weak_key (const u8 *key,unsigned int keylen) +{ +static const u8 parity[] = { +8 ,1 ,0 ,8 ,0 ,8 ,8 ,0 ,0 ,8 ,8 ,0 ,8 ,0 ,2 ,8 , +0 ,8 ,8 ,0 ,8 ,0 ,0 ,8 ,8 , +0 ,0 ,8 ,0 ,8 ,8 ,3 ,
Any reason this is formatted with line lengths of 16, 9, 7 instea of all 16?
drivers/staging/sep/sep_crypto.c line 584
Quoted 6 lines
drivers/staging/sep/sep_crypto.c +5
-0+0 ,8 ,8 ,0 ,8 ,0 ,0 ,8 ,8 ,0 ,0 ,8 ,0 ,8 ,8 ,0 , +8 ,0 ,0 ,8 ,0 ,8 ,8 ,0 ,0 , +8 ,8 ,0 ,8 ,0 ,0 ,8 , + if (!((n - (w >> 3)) & w)) { + if (n < 0x41415151) {
Perhaps use a switch/case instead of an
difficult to read binary chop?
drivers/staging/sep/sep_crypto.c line 1332
Quoted 2 lines
drivers/staging/sep/sep_crypto.c +2
-0+/* Portion of msg is nulled (no data) */ + msg[0 ] = (u32 )0 ;
The casts of zero are odd.
Quoted 6 lines · On Wed, 28 Dec 2011 14:14:38 -0800 Joe Perches <[email protected]> wrote:
Quoted 3 lines · Alan Cox
From: Mark Allyn <[email protected]>
The new driver supports the kernel crypto layer, passes the coding style checks, passes human taste checks and has proper kernel-doc formatted comments.These are just taste comments.
Not so sure about the switch case one but the others I concur - I'll send Greg a follow up patch once the main one is merged.
Alan