GIT ed1c6427fc11a3b51708fcab582a20880268c145 master.kernel.org:/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git --- Signed-off-by: Andrew Morton --- arch/i386/crypto/aes.c | 2 arch/x86_64/crypto/aes.c | 2 crypto/Kconfig | 2 crypto/aes.c | 2 crypto/api.c | 71 ++++++++++++++++++++++++++++------ crypto/hmac.c | 19 ++------- crypto/internal.h | 12 +++++ crypto/proc.c | 29 ++++++++++--- crypto/tcrypt.c | 56 ++++++++------------------ drivers/crypto/padlock-aes.c | 2 drivers/md/dm-crypt.c | 12 +---- drivers/net/wireless/airo.c | 7 +-- drivers/scsi/arm/scsi.h | 6 +- drivers/scsi/libata-core.c | 10 ---- drivers/scsi/sg.c | 5 -- drivers/usb/misc/usbtest.c | 7 --- include/linux/crypto.h | 5 ++ include/linux/scatterlist.h | 17 ++++++-- net/ipv6/addrconf.c | 10 +--- net/sunrpc/auth_gss/gss_krb5_crypto.c | 10 +--- 20 files changed, 164 insertions(+), 122 deletions(-) diff -puN arch/i386/crypto/aes.c~git-cryptodev arch/i386/crypto/aes.c --- devel/arch/i386/crypto/aes.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/arch/i386/crypto/aes.c 2005-10-23 11:51:43.000000000 -0700 @@ -484,6 +484,8 @@ static inline void aes_decrypt(void *ctx static struct crypto_alg aes_alg = { .cra_name = "aes", + .cra_driver_name = "aes-i586", + .cra_priority = 200, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), diff -puN arch/x86_64/crypto/aes.c~git-cryptodev arch/x86_64/crypto/aes.c --- devel/arch/x86_64/crypto/aes.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/arch/x86_64/crypto/aes.c 2005-10-23 11:51:43.000000000 -0700 @@ -290,6 +290,8 @@ extern void aes_decrypt(void *ctx_arg, u static struct crypto_alg aes_alg = { .cra_name = "aes", + .cra_driver_name = "aes-x86_64", + .cra_priority = 200, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), diff -puN crypto/aes.c~git-cryptodev crypto/aes.c --- devel/crypto/aes.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/aes.c 2005-10-23 11:51:43.000000000 -0700 @@ -416,6 +416,8 @@ static void aes_decrypt(void *ctx_arg, u static struct crypto_alg aes_alg = { .cra_name = "aes", + .cra_driver_name = "aes", + .cra_priority = 100, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), diff -puN crypto/api.c~git-cryptodev crypto/api.c --- devel/crypto/api.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/api.c 2005-10-23 11:51:43.000000000 -0700 @@ -3,6 +3,7 @@ * * Copyright (c) 2002 James Morris * Copyright (c) 2002 David S. Miller (davem@redhat.com) + * Copyright (c) 2005 Herbert Xu * * Portions derived from Cryptoapi, by Alexander Kjeldaas * and Nettle, by Niels Möller. @@ -18,9 +19,11 @@ #include #include #include +#include #include #include #include +#include #include "internal.h" LIST_HEAD(crypto_alg_list); @@ -38,6 +41,7 @@ static inline void crypto_alg_put(struct static struct crypto_alg *crypto_alg_lookup(const char *name) { + struct crypto_driver_list *dl; struct crypto_alg *q, *alg = NULL; if (!name) @@ -45,12 +49,22 @@ static struct crypto_alg *crypto_alg_loo down_read(&crypto_alg_sem); - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (!(strcmp(q->cra_name, name))) { - if (crypto_alg_get(q)) + list_for_each_entry(dl, &crypto_alg_list, alg_list) { + unsigned int best; + + if (strcmp(dl->name, name)) + continue; + + best = 0; + list_for_each_entry(q, &dl->driver_list, cra_list) { + if (q->cra_priority >= best && crypto_alg_get(q)) { + best = q->cra_priority; + if (alg) + crypto_alg_put(alg); alg = q; - break; + } } + break; } up_read(&crypto_alg_sem); @@ -210,24 +224,44 @@ void crypto_free_tfm(struct crypto_tfm * int crypto_register_alg(struct crypto_alg *alg) { int ret = 0; + struct crypto_driver_list *dl; struct crypto_alg *q; if (alg->cra_alignmask & (alg->cra_alignmask + 1)) return -EINVAL; - if (alg->cra_alignmask > PAGE_SIZE) + if (alg->cra_alignmask & alg->cra_blocksize) + return -EINVAL; + + if (alg->cra_blocksize > PAGE_SIZE) return -EINVAL; down_write(&crypto_alg_sem); - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (!(strcmp(q->cra_name, alg->cra_name))) { + list_for_each_entry(dl, &crypto_alg_list, alg_list) { + if (strcmp(dl->name, alg->cra_name)) + continue; + + list_for_each_entry(q, &dl->driver_list, cra_list) { + if (strcmp(q->cra_driver_name, alg->cra_driver_name)) + continue; + ret = -EEXIST; goto out; } + goto found; } - list_add_tail(&alg->cra_list, &crypto_alg_list); + dl = kmalloc(sizeof(*dl), GFP_KERNEL); + INIT_LIST_HEAD(&dl->alg_list); + INIT_LIST_HEAD(&dl->driver_list); + strcpy(dl->name, alg->cra_name); + + list_add_tail(&dl->alg_list, &crypto_alg_list); + +found: + list_add_tail(&alg->cra_list, &dl->driver_list); + out: up_write(&crypto_alg_sem); return ret; @@ -236,19 +270,32 @@ out: int crypto_unregister_alg(struct crypto_alg *alg) { int ret = -ENOENT; + struct crypto_driver_list *dl; struct crypto_alg *q; BUG_ON(!alg->cra_module); down_write(&crypto_alg_sem); - list_for_each_entry(q, &crypto_alg_list, cra_list) { - if (alg == q) { + list_for_each_entry(dl, &crypto_alg_list, alg_list) { + if (strcmp(dl->name, alg->cra_name)) + continue; + + list_for_each_entry(q, &dl->driver_list, cra_list) { + if (alg != q) + continue; + list_del(&alg->cra_list); + if (list_empty(&dl->driver_list)) { + list_del(&dl->alg_list); + kfree(dl); + } + ret = 0; - goto out; + break; } + break; } -out: + up_write(&crypto_alg_sem); return ret; } diff -puN crypto/hmac.c~git-cryptodev crypto/hmac.c --- devel/crypto/hmac.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/hmac.c 2005-10-23 11:51:43.000000000 -0700 @@ -18,18 +18,15 @@ #include #include #include -#include +#include #include "internal.h" static void hash_key(struct crypto_tfm *tfm, u8 *key, unsigned int keylen) { struct scatterlist tmp; - tmp.page = virt_to_page(key); - tmp.offset = offset_in_page(key); - tmp.length = keylen; + sg_set_buf(&tmp, key, keylen); crypto_digest_digest(tfm, &tmp, 1, key); - } int crypto_alloc_hmac_block(struct crypto_tfm *tfm) @@ -69,9 +66,7 @@ void crypto_hmac_init(struct crypto_tfm for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++) ipad[i] ^= 0x36; - tmp.page = virt_to_page(ipad); - tmp.offset = offset_in_page(ipad); - tmp.length = crypto_tfm_alg_blocksize(tfm); + sg_set_buf(&tmp, ipad, crypto_tfm_alg_blocksize(tfm)); crypto_digest_init(tfm); crypto_digest_update(tfm, &tmp, 1); @@ -103,16 +98,12 @@ void crypto_hmac_final(struct crypto_tfm for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++) opad[i] ^= 0x5c; - tmp.page = virt_to_page(opad); - tmp.offset = offset_in_page(opad); - tmp.length = crypto_tfm_alg_blocksize(tfm); + sg_set_buf(&tmp, opad, crypto_tfm_alg_blocksize(tfm)); crypto_digest_init(tfm); crypto_digest_update(tfm, &tmp, 1); - tmp.page = virt_to_page(out); - tmp.offset = offset_in_page(out); - tmp.length = crypto_tfm_alg_digestsize(tfm); + sg_set_buf(&tmp, out, crypto_tfm_alg_digestsize(tfm)); crypto_digest_update(tfm, &tmp, 1); crypto_digest_final(tfm, out); diff -puN crypto/internal.h~git-cryptodev crypto/internal.h --- devel/crypto/internal.h~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/internal.h 2005-10-23 11:51:43.000000000 -0700 @@ -2,6 +2,7 @@ * Cryptographic API. * * Copyright (c) 2002 James Morris + * Copyright (c) 2005 Herbert Xu * * 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 @@ -16,10 +17,21 @@ #include #include #include +#include #include +#include #include #include +struct crypto_driver_list { + struct list_head alg_list; + struct list_head driver_list; + char name[CRYPTO_MAX_ALG_NAME]; +}; + +extern struct list_head crypto_alg_list; +extern struct rw_semaphore crypto_alg_sem; + extern enum km_type crypto_km_types[]; static inline enum km_type crypto_kmap_type(int out) diff -puN crypto/Kconfig~git-cryptodev crypto/Kconfig --- devel/crypto/Kconfig~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/Kconfig 2005-10-23 11:51:43.000000000 -0700 @@ -146,7 +146,7 @@ config CRYPTO_SERPENT config CRYPTO_AES tristate "AES cipher algorithms" - depends on CRYPTO && !(X86 || UML_X86) + depends on CRYPTO help AES cipher algorithms (FIPS-197). AES uses the Rijndael algorithm. diff -puN crypto/proc.c~git-cryptodev crypto/proc.c --- devel/crypto/proc.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/proc.c 2005-10-23 11:51:43.000000000 -0700 @@ -4,6 +4,7 @@ * Procfs information. * * Copyright (c) 2002 James Morris + * Copyright (c) 2005 Herbert Xu * * 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 @@ -18,29 +19,41 @@ #include #include "internal.h" -extern struct list_head crypto_alg_list; -extern struct rw_semaphore crypto_alg_sem; - static void *c_start(struct seq_file *m, loff_t *pos) { + struct crypto_driver_list *dl; struct list_head *v; loff_t n = *pos; down_read(&crypto_alg_sem); - list_for_each(v, &crypto_alg_list) - if (!n--) + list_for_each_entry(dl, &crypto_alg_list, alg_list) + list_for_each(v, &dl->driver_list) { + if (n--) + continue; + + m->private = dl; return list_entry(v, struct crypto_alg, cra_list); + } return NULL; } static void *c_next(struct seq_file *m, void *p, loff_t *pos) { struct list_head *v = p; + struct crypto_driver_list *dl = m->private; (*pos)++; v = v->next; - return (v == &crypto_alg_list) ? - NULL : list_entry(v, struct crypto_alg, cra_list); + if (v == &dl->driver_list) { + v = dl->alg_list.next; + if (v == &crypto_alg_list) + return NULL; + + dl = list_entry(v, struct crypto_driver_list, alg_list); + m->private = dl; + v = dl->driver_list.next; + } + return list_entry(v, struct crypto_alg, cra_list); } static void c_stop(struct seq_file *m, void *p) @@ -53,7 +66,9 @@ static int c_show(struct seq_file *m, vo struct crypto_alg *alg = (struct crypto_alg *)p; seq_printf(m, "name : %s\n", alg->cra_name); + seq_printf(m, "driver : %s\n", alg->cra_driver_name); seq_printf(m, "module : %s\n", module_name(alg->cra_module)); + seq_printf(m, "priority : %u\n", alg->cra_priority); switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { case CRYPTO_ALG_TYPE_CIPHER: diff -puN crypto/tcrypt.c~git-cryptodev crypto/tcrypt.c --- devel/crypto/tcrypt.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/crypto/tcrypt.c 2005-10-23 11:51:43.000000000 -0700 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,7 +86,6 @@ static void hexdump(unsigned char *buf, static void test_hash(char *algo, struct hash_testvec *template, unsigned int tcount) { - char *p; unsigned int i, j, k, temp; struct scatterlist sg[8]; char result[64]; @@ -116,10 +115,7 @@ static void test_hash(char *algo, struct printk("test %u:\n", i + 1); memset(result, 0, 64); - p = hash_tv[i].plaintext; - sg[0].page = virt_to_page(p); - sg[0].offset = offset_in_page(p); - sg[0].length = hash_tv[i].psize; + sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); crypto_digest_init(tfm); if (tfm->crt_u.digest.dit_setkey) { @@ -154,10 +150,8 @@ static void test_hash(char *algo, struct hash_tv[i].plaintext + temp, hash_tv[i].tap[k]); temp += hash_tv[i].tap[k]; - p = &xbuf[IDX[k]]; - sg[k].page = virt_to_page(p); - sg[k].offset = offset_in_page(p); - sg[k].length = hash_tv[i].tap[k]; + sg_set_buf(&sg[k], &xbuf[IDX[k]], + hash_tv[i].tap[k]); } crypto_digest_digest(tfm, sg, hash_tv[i].np, result); @@ -179,7 +173,6 @@ static void test_hash(char *algo, struct static void test_hmac(char *algo, struct hmac_testvec *template, unsigned int tcount) { - char *p; unsigned int i, j, k, temp; struct scatterlist sg[8]; char result[64]; @@ -210,11 +203,8 @@ static void test_hmac(char *algo, struct printk("test %u:\n", i + 1); memset(result, 0, sizeof (result)); - p = hmac_tv[i].plaintext; klen = hmac_tv[i].ksize; - sg[0].page = virt_to_page(p); - sg[0].offset = offset_in_page(p); - sg[0].length = hmac_tv[i].psize; + sg_set_buf(&sg[0], hmac_tv[i].plaintext, hmac_tv[i].psize); crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, 1, result); @@ -243,10 +233,8 @@ static void test_hmac(char *algo, struct hmac_tv[i].plaintext + temp, hmac_tv[i].tap[k]); temp += hmac_tv[i].tap[k]; - p = &xbuf[IDX[k]]; - sg[k].page = virt_to_page(p); - sg[k].offset = offset_in_page(p); - sg[k].length = hmac_tv[i].tap[k]; + sg_set_buf(&sg[k], &xbuf[IDX[k]], + hmac_tv[i].tap[k]); } crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, @@ -270,7 +258,7 @@ static void test_cipher(char *algo, int { unsigned int ret, i, j, k, temp; unsigned int tsize; - char *p, *q; + char *q; struct crypto_tfm *tfm; char *key; struct cipher_testvec *cipher_tv; @@ -330,10 +318,8 @@ static void test_cipher(char *algo, int goto out; } - p = cipher_tv[i].input; - sg[0].page = virt_to_page(p); - sg[0].offset = offset_in_page(p); - sg[0].length = cipher_tv[i].ilen; + sg_set_buf(&sg[0], cipher_tv[i].input, + cipher_tv[i].ilen); if (!mode) { crypto_cipher_set_iv(tfm, cipher_tv[i].iv, @@ -389,10 +375,8 @@ static void test_cipher(char *algo, int cipher_tv[i].input + temp, cipher_tv[i].tap[k]); temp += cipher_tv[i].tap[k]; - p = &xbuf[IDX[k]]; - sg[k].page = virt_to_page(p); - sg[k].offset = offset_in_page(p); - sg[k].length = cipher_tv[i].tap[k]; + sg_set_buf(&sg[k], &xbuf[IDX[k]], + cipher_tv[i].tap[k]); } if (!mode) { @@ -431,14 +415,12 @@ out: static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p, int blen, int sec) { - struct scatterlist sg[8]; + struct scatterlist sg[1]; unsigned long start, end; int bcount; int ret; - sg[0].page = virt_to_page(p); - sg[0].offset = offset_in_page(p); - sg[0].length = blen; + sg_set_buf(sg, p, blen); for (start = jiffies, end = start + sec * HZ, bcount = 0; time_before(jiffies, end); bcount++) { @@ -459,14 +441,12 @@ static int test_cipher_jiffies(struct cr static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p, int blen) { - struct scatterlist sg[8]; + struct scatterlist sg[1]; unsigned long cycles = 0; int ret = 0; int i; - sg[0].page = virt_to_page(p); - sg[0].offset = offset_in_page(p); - sg[0].length = blen; + sg_set_buf(sg, p, blen); local_bh_disable(); local_irq_disable(); @@ -709,9 +689,7 @@ static void test_crc32c(void) for (i = 0; i < NUMVEC; i++) { for (j = 0; j < VECSIZE; j++) test_vec[i][j] = ++b; - sg[i].page = virt_to_page(test_vec[i]); - sg[i].offset = offset_in_page(test_vec[i]); - sg[i].length = VECSIZE; + sg_set_buf(&sg[i], test_vec[i], VECSIZE); } seed = SEEDTESTVAL; diff -puN drivers/crypto/padlock-aes.c~git-cryptodev drivers/crypto/padlock-aes.c --- devel/drivers/crypto/padlock-aes.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/crypto/padlock-aes.c 2005-10-23 11:51:43.000000000 -0700 @@ -468,6 +468,8 @@ static unsigned int aes_decrypt_cbc(cons static struct crypto_alg aes_alg = { .cra_name = "aes", + .cra_driver_name = "padlock", + .cra_priority = 300, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct aes_ctx), diff -puN drivers/md/dm-crypt.c~git-cryptodev drivers/md/dm-crypt.c --- devel/drivers/md/dm-crypt.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/md/dm-crypt.c 2005-10-23 11:51:43.000000000 -0700 @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include "dm.h" @@ -164,9 +164,7 @@ static int crypt_iv_essiv_ctr(struct cry return -ENOMEM; } - sg.page = virt_to_page(cc->key); - sg.offset = offset_in_page(cc->key); - sg.length = cc->key_size; + sg_set_buf(&sg, cc->key, cc->key_size); crypto_digest_digest(hash_tfm, &sg, 1, salt); crypto_free_tfm(hash_tfm); @@ -207,14 +205,12 @@ static void crypt_iv_essiv_dtr(struct cr static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) { - struct scatterlist sg = { NULL, }; + struct scatterlist sg; memset(iv, 0, cc->iv_size); *(u64 *)iv = cpu_to_le64(sector); - sg.page = virt_to_page(iv); - sg.offset = offset_in_page(iv); - sg.length = cc->iv_size; + sg_set_buf(&sg, iv, cc->iv_size); crypto_cipher_encrypt((struct crypto_tfm *)cc->iv_gen_private, &sg, &sg, cc->iv_size); diff -puN drivers/net/wireless/airo.c~git-cryptodev drivers/net/wireless/airo.c --- devel/drivers/net/wireless/airo.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/net/wireless/airo.c 2005-10-23 11:51:43.000000000 -0700 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -1590,11 +1591,9 @@ static void emmh32_setseed(emmh32_contex aes_counter[12] = (u8)(counter >> 24); counter++; memcpy (plain, aes_counter, 16); - sg[0].page = virt_to_page(plain); - sg[0].offset = ((long) plain & ~PAGE_MASK); - sg[0].length = 16; + sg_set_buf(sg, plain, 16); crypto_cipher_encrypt(tfm, sg, sg, 16); - cipher = kmap(sg[0].page) + sg[0].offset; + cipher = kmap(sg->page) + sg->offset; for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); j += 4; diff -puN drivers/scsi/arm/scsi.h~git-cryptodev drivers/scsi/arm/scsi.h --- devel/drivers/scsi/arm/scsi.h~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/scsi/arm/scsi.h 2005-10-23 11:51:43.000000000 -0700 @@ -10,6 +10,8 @@ * Commonly used scsi driver functions. */ +#include + #define BELT_AND_BRACES /* @@ -22,9 +24,7 @@ static inline int copy_SCp_to_sg(struct BUG_ON(bufs + 1 > max); - sg->page = virt_to_page(SCp->ptr); - sg->offset = offset_in_page(SCp->ptr); - sg->length = SCp->this_residual; + sg_set_buf(sg, SCp->ptr, SCp->this_residual); if (bufs) memcpy(sg + 1, SCp->buffer + 1, diff -puN drivers/scsi/libata-core.c~git-cryptodev drivers/scsi/libata-core.c --- devel/drivers/scsi/libata-core.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/scsi/libata-core.c 2005-10-23 11:52:43.000000000 -0700 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include "scsi.h" @@ -2597,20 +2598,13 @@ void ata_qc_prep(struct ata_queued_cmd * void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) { - struct scatterlist *sg; - qc->flags |= ATA_QCFLAG_SINGLE; - memset(&qc->sgent, 0, sizeof(qc->sgent)); qc->__sg = &qc->sgent; qc->n_elem = 1; qc->orig_n_elem = 1; qc->buf_virt = buf; - - sg = qc->__sg; - sg->page = virt_to_page(buf); - sg->offset = (unsigned long) buf & ~PAGE_MASK; - sg->length = buflen; + sg_init_one(qc->__sg, buf, buflen); } /** diff -puN drivers/scsi/sg.c~git-cryptodev drivers/scsi/sg.c --- devel/drivers/scsi/sg.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/scsi/sg.c 2005-10-23 11:51:43.000000000 -0700 @@ -49,6 +49,7 @@ static int sg_version_num = 30533; /* 2 #include #include #include +#include #include "scsi.h" #include @@ -1992,9 +1993,7 @@ sg_build_indirect(Sg_scatter_hold * schp if (!p) break; } - sclp->page = virt_to_page(p); - sclp->offset = offset_in_page(p); - sclp->length = ret_sz; + sg_set_buf(sclp, p, ret_sz); SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", k, sg_scatg2virt(sclp), ret_sz)); diff -puN drivers/usb/misc/usbtest.c~git-cryptodev drivers/usb/misc/usbtest.c --- devel/drivers/usb/misc/usbtest.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/drivers/usb/misc/usbtest.c 2005-10-23 11:51:43.000000000 -0700 @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include @@ -381,7 +381,6 @@ alloc_sglist (int nents, int max, int va sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); if (!sg) return NULL; - memset (sg, 0, nents * sizeof *sg); for (i = 0; i < nents; i++) { char *buf; @@ -394,9 +393,7 @@ alloc_sglist (int nents, int max, int va memset (buf, 0, size); /* kmalloc pages are always physically contiguous! */ - sg [i].page = virt_to_page (buf); - sg [i].offset = offset_in_page (buf); - sg [i].length = size; + sg_init_one(&sg[i], buf, size); if (vary) { size += vary; diff -puN include/linux/crypto.h~git-cryptodev include/linux/crypto.h --- devel/include/linux/crypto.h~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/include/linux/crypto.h 2005-10-23 11:51:43.000000000 -0700 @@ -3,6 +3,7 @@ * * Copyright (c) 2002 James Morris * Copyright (c) 2002 David S. Miller (davem@redhat.com) + * Copyright (c) 2005 Herbert Xu * * Portions derived from Cryptoapi, by Alexander Kjeldaas * and Nettle, by Niels Möller. @@ -126,7 +127,11 @@ struct crypto_alg { unsigned int cra_blocksize; unsigned int cra_ctxsize; unsigned int cra_alignmask; + + unsigned int cra_priority; + const char cra_name[CRYPTO_MAX_ALG_NAME]; + const char cra_driver_name[CRYPTO_MAX_ALG_NAME]; union { struct cipher_alg cipher; diff -puN include/linux/scatterlist.h~git-cryptodev include/linux/scatterlist.h --- devel/include/linux/scatterlist.h~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/include/linux/scatterlist.h 2005-10-23 11:51:43.000000000 -0700 @@ -1,14 +1,23 @@ #ifndef _LINUX_SCATTERLIST_H #define _LINUX_SCATTERLIST_H -static inline void sg_init_one(struct scatterlist *sg, - u8 *buf, unsigned int buflen) -{ - memset(sg, 0, sizeof(*sg)); +#include +#include +#include +static inline void sg_set_buf(struct scatterlist *sg, void *buf, + unsigned int buflen) +{ sg->page = virt_to_page(buf); sg->offset = offset_in_page(buf); sg->length = buflen; } +static inline void sg_init_one(struct scatterlist *sg, void *buf, + unsigned int buflen) +{ + memset(sg, 0, sizeof(*sg)); + sg_set_buf(sg, buf, buflen); +} + #endif /* _LINUX_SCATTERLIST_H */ diff -puN net/ipv6/addrconf.c~git-cryptodev net/ipv6/addrconf.c --- devel/net/ipv6/addrconf.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/net/ipv6/addrconf.c 2005-10-23 11:51:43.000000000 -0700 @@ -75,7 +75,7 @@ #ifdef CONFIG_IPV6_PRIVACY #include #include -#include +#include #endif #include @@ -1217,12 +1217,8 @@ static int __ipv6_regen_rndid(struct ine struct net_device *dev; struct scatterlist sg[2]; - sg[0].page = virt_to_page(idev->entropy); - sg[0].offset = offset_in_page(idev->entropy); - sg[0].length = 8; - sg[1].page = virt_to_page(idev->work_eui64); - sg[1].offset = offset_in_page(idev->work_eui64); - sg[1].length = 8; + sg_set_buf(&sg[0], idev->entropy, 8); + sg_set_buf(&sg[1], idev->work_eui64, 8); dev = idev->dev; diff -puN net/sunrpc/auth_gss/gss_krb5_crypto.c~git-cryptodev net/sunrpc/auth_gss/gss_krb5_crypto.c --- devel/net/sunrpc/auth_gss/gss_krb5_crypto.c~git-cryptodev 2005-10-23 11:51:43.000000000 -0700 +++ devel-akpm/net/sunrpc/auth_gss/gss_krb5_crypto.c 2005-10-23 11:51:43.000000000 -0700 @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -75,9 +75,7 @@ krb5_encrypt( memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm)); memcpy(out, in, length); - sg[0].page = virt_to_page(out); - sg[0].offset = offset_in_page(out); - sg[0].length = length; + sg_set_buf(sg, out, length); ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv); @@ -117,9 +115,7 @@ krb5_decrypt( memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm)); memcpy(out, in, length); - sg[0].page = virt_to_page(out); - sg[0].offset = offset_in_page(out); - sg[0].length = length; + sg_set_buf(sg, out, length); ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv); _