Commit 9455b4b6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'powerpc-6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:

 - Fix link errors in new aes-gcm-p10 code when built-in with other
   drivers

 - Limit number of TCEs passed to H_STUFF_TCE hcall as per spec

 - Use KSYM_NAME_LEN in xmon array size to avoid possible OOB write

Thanks to Gaurav Batra and Maninder Singh Vishal Chourasia.

* tag 'powerpc-6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/xmon: Use KSYM_NAME_LEN in array size
  powerpc/iommu: Limit number of TCEs to 512 for H_STUFF_TCE hcall
  powerpc/crypto: Fix aes-gcm-p10 link errors
parents e5282a7d 719dfd59
...@@ -22,15 +22,15 @@ sha1-ppc-spe-y := sha1-spe-asm.o sha1-spe-glue.o ...@@ -22,15 +22,15 @@ sha1-ppc-spe-y := sha1-spe-asm.o sha1-spe-glue.o
sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o
crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o
crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o
aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp8-ppc.o aesp8-ppc.o aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp10-ppc.o aesp10-ppc.o
quiet_cmd_perl = PERL $@ quiet_cmd_perl = PERL $@
cmd_perl = $(PERL) $< $(if $(CONFIG_CPU_LITTLE_ENDIAN), linux-ppc64le, linux-ppc64) > $@ cmd_perl = $(PERL) $< $(if $(CONFIG_CPU_LITTLE_ENDIAN), linux-ppc64le, linux-ppc64) > $@
targets += aesp8-ppc.S ghashp8-ppc.S targets += aesp10-ppc.S ghashp10-ppc.S
$(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE $(obj)/aesp10-ppc.S $(obj)/ghashp10-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE
$(call if_changed,perl) $(call if_changed,perl)
OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y OBJECT_FILES_NON_STANDARD_aesp10-ppc.o := y
OBJECT_FILES_NON_STANDARD_ghashp8-ppc.o := y OBJECT_FILES_NON_STANDARD_ghashp10-ppc.o := y
...@@ -30,15 +30,15 @@ MODULE_AUTHOR("Danny Tsen <dtsen@linux.ibm.com"); ...@@ -30,15 +30,15 @@ MODULE_AUTHOR("Danny Tsen <dtsen@linux.ibm.com");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS_CRYPTO("aes"); MODULE_ALIAS_CRYPTO("aes");
asmlinkage int aes_p8_set_encrypt_key(const u8 *userKey, const int bits, asmlinkage int aes_p10_set_encrypt_key(const u8 *userKey, const int bits,
void *key); void *key);
asmlinkage void aes_p8_encrypt(const u8 *in, u8 *out, const void *key); asmlinkage void aes_p10_encrypt(const u8 *in, u8 *out, const void *key);
asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len, asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len,
void *rkey, u8 *iv, void *Xi); void *rkey, u8 *iv, void *Xi);
asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len, asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len,
void *rkey, u8 *iv, void *Xi); void *rkey, u8 *iv, void *Xi);
asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]); asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]);
asmlinkage void gcm_ghash_p8(unsigned char *Xi, unsigned char *Htable, asmlinkage void gcm_ghash_p10(unsigned char *Xi, unsigned char *Htable,
unsigned char *aad, unsigned int alen); unsigned char *aad, unsigned int alen);
struct aes_key { struct aes_key {
...@@ -93,7 +93,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash, ...@@ -93,7 +93,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash,
gctx->aadLen = alen; gctx->aadLen = alen;
i = alen & ~0xf; i = alen & ~0xf;
if (i) { if (i) {
gcm_ghash_p8(nXi, hash->Htable+32, aad, i); gcm_ghash_p10(nXi, hash->Htable+32, aad, i);
aad += i; aad += i;
alen -= i; alen -= i;
} }
...@@ -102,7 +102,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash, ...@@ -102,7 +102,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash,
nXi[i] ^= aad[i]; nXi[i] ^= aad[i];
memset(gctx->aad_hash, 0, 16); memset(gctx->aad_hash, 0, 16);
gcm_ghash_p8(gctx->aad_hash, hash->Htable+32, nXi, 16); gcm_ghash_p10(gctx->aad_hash, hash->Htable+32, nXi, 16);
} else { } else {
memcpy(gctx->aad_hash, nXi, 16); memcpy(gctx->aad_hash, nXi, 16);
} }
...@@ -115,7 +115,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey, ...@@ -115,7 +115,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey,
{ {
__be32 counter = cpu_to_be32(1); __be32 counter = cpu_to_be32(1);
aes_p8_encrypt(hash->H, hash->H, rdkey); aes_p10_encrypt(hash->H, hash->H, rdkey);
set_subkey(hash->H); set_subkey(hash->H);
gcm_init_htable(hash->Htable+32, hash->H); gcm_init_htable(hash->Htable+32, hash->H);
...@@ -126,7 +126,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey, ...@@ -126,7 +126,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey,
/* /*
* Encrypt counter vector as iv tag and increment counter. * Encrypt counter vector as iv tag and increment counter.
*/ */
aes_p8_encrypt(iv, gctx->ivtag, rdkey); aes_p10_encrypt(iv, gctx->ivtag, rdkey);
counter = cpu_to_be32(2); counter = cpu_to_be32(2);
*((__be32 *)(iv+12)) = counter; *((__be32 *)(iv+12)) = counter;
...@@ -160,7 +160,7 @@ static void finish_tag(struct gcm_ctx *gctx, struct Hash_ctx *hash, int len) ...@@ -160,7 +160,7 @@ static void finish_tag(struct gcm_ctx *gctx, struct Hash_ctx *hash, int len)
/* /*
* hash (AAD len and len) * hash (AAD len and len)
*/ */
gcm_ghash_p8(hash->Htable, hash->Htable+32, aclen, 16); gcm_ghash_p10(hash->Htable, hash->Htable+32, aclen, 16);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
hash->Htable[i] ^= gctx->ivtag[i]; hash->Htable[i] ^= gctx->ivtag[i];
...@@ -192,7 +192,7 @@ static int p10_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, ...@@ -192,7 +192,7 @@ static int p10_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key,
int ret; int ret;
vsx_begin(); vsx_begin();
ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); ret = aes_p10_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
vsx_end(); vsx_end();
return ret ? -EINVAL : 0; return ret ? -EINVAL : 0;
......
...@@ -110,7 +110,7 @@ die "can't locate ppc-xlate.pl"; ...@@ -110,7 +110,7 @@ die "can't locate ppc-xlate.pl";
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
$FRAME=8*$SIZE_T; $FRAME=8*$SIZE_T;
$prefix="aes_p8"; $prefix="aes_p10";
$sp="r1"; $sp="r1";
$vrsave="r12"; $vrsave="r12";
......
...@@ -64,7 +64,7 @@ $code=<<___; ...@@ -64,7 +64,7 @@ $code=<<___;
.text .text
.globl .gcm_init_p8 .globl .gcm_init_p10
lis r0,0xfff0 lis r0,0xfff0
li r8,0x10 li r8,0x10
mfspr $vrsave,256 mfspr $vrsave,256
...@@ -110,7 +110,7 @@ $code=<<___; ...@@ -110,7 +110,7 @@ $code=<<___;
.long 0 .long 0
.byte 0,12,0x14,0,0,0,2,0 .byte 0,12,0x14,0,0,0,2,0
.long 0 .long 0
.size .gcm_init_p8,.-.gcm_init_p8 .size .gcm_init_p10,.-.gcm_init_p10
.globl .gcm_init_htable .globl .gcm_init_htable
lis r0,0xfff0 lis r0,0xfff0
...@@ -237,7 +237,7 @@ $code=<<___; ...@@ -237,7 +237,7 @@ $code=<<___;
.long 0 .long 0
.size .gcm_init_htable,.-.gcm_init_htable .size .gcm_init_htable,.-.gcm_init_htable
.globl .gcm_gmult_p8 .globl .gcm_gmult_p10
lis r0,0xfff8 lis r0,0xfff8
li r8,0x10 li r8,0x10
mfspr $vrsave,256 mfspr $vrsave,256
...@@ -283,9 +283,9 @@ $code=<<___; ...@@ -283,9 +283,9 @@ $code=<<___;
.long 0 .long 0
.byte 0,12,0x14,0,0,0,2,0 .byte 0,12,0x14,0,0,0,2,0
.long 0 .long 0
.size .gcm_gmult_p8,.-.gcm_gmult_p8 .size .gcm_gmult_p10,.-.gcm_gmult_p10
.globl .gcm_ghash_p8 .globl .gcm_ghash_p10
lis r0,0xfff8 lis r0,0xfff8
li r8,0x10 li r8,0x10
mfspr $vrsave,256 mfspr $vrsave,256
...@@ -350,7 +350,7 @@ Loop: ...@@ -350,7 +350,7 @@ Loop:
.long 0 .long 0
.byte 0,12,0x14,0,0,0,4,0 .byte 0,12,0x14,0,0,0,4,0
.long 0 .long 0
.size .gcm_ghash_p8,.-.gcm_ghash_p8 .size .gcm_ghash_p10,.-.gcm_ghash_p10
.asciz "GHASH for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>" .asciz "GHASH for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>"
.align 2 .align 2
......
...@@ -317,13 +317,22 @@ static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift, ...@@ -317,13 +317,22 @@ static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift,
static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages) static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
{ {
u64 rc; u64 rc;
long rpages = npages;
unsigned long limit;
if (!firmware_has_feature(FW_FEATURE_STUFF_TCE)) if (!firmware_has_feature(FW_FEATURE_STUFF_TCE))
return tce_free_pSeriesLP(tbl->it_index, tcenum, return tce_free_pSeriesLP(tbl->it_index, tcenum,
tbl->it_page_shift, npages); tbl->it_page_shift, npages);
do {
limit = min_t(unsigned long, rpages, 512);
rc = plpar_tce_stuff((u64)tbl->it_index, rc = plpar_tce_stuff((u64)tbl->it_index,
(u64)tcenum << tbl->it_page_shift, 0, npages); (u64)tcenum << tbl->it_page_shift, 0, limit);
rpages -= limit;
tcenum += limit;
} while (rpages > 0 && !rc);
if (rc && printk_ratelimit()) { if (rc && printk_ratelimit()) {
printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n"); printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n");
......
...@@ -88,7 +88,7 @@ static unsigned long ndump = 64; ...@@ -88,7 +88,7 @@ static unsigned long ndump = 64;
static unsigned long nidump = 16; static unsigned long nidump = 16;
static unsigned long ncsum = 4096; static unsigned long ncsum = 4096;
static int termch; static int termch;
static char tmpstr[128]; static char tmpstr[KSYM_NAME_LEN];
static int tracing_enabled; static int tracing_enabled;
static long bus_error_jmp[JMP_BUF_LEN]; static long bus_error_jmp[JMP_BUF_LEN];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment