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
Unified · Split
| @@ -22,15 +22,15 @@ sha1-ppc-spe-y := sha1-spe-asm.o sha1-spe-glue.o · 21 unmodified lines | |||
| 22 | sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o | 22 | sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o |
| 23 | crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o | 23 | crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o |
| 24 | crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o | 24 | crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o |
| 25 | aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp8-ppc.o aesp8-ppc.o | 25 | aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp10-ppc.o aesp10-ppc.o |
| 26 | 26 | ||
| 27 | quiet_cmd_perl = PERL $@ | 27 | quiet_cmd_perl = PERL $@ |
| 28 | cmd_perl = $(PERL) $< $(if $(CONFIG_CPU_LITTLE_ENDIAN), linux-ppc64le, linux-ppc64) > $@ | 28 | cmd_perl = $(PERL) $< $(if $(CONFIG_CPU_LITTLE_ENDIAN), linux-ppc64le, linux-ppc64) > $@ |
| 29 | 29 | ||
| 30 | targets += aesp8-ppc.S ghashp8-ppc.S | 30 | targets += aesp10-ppc.S ghashp10-ppc.S |
| 31 | 31 | ||
| 32 | $(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE | 32 | $(obj)/aesp10-ppc.S $(obj)/ghashp10-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE |
| 33 | $(call if_changed,perl) | 33 | $(call if_changed,perl) |
| 34 | 34 | ||
| 35 | OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y | 35 | OBJECT_FILES_NON_STANDARD_aesp10-ppc.o := y |
| 36 | OBJECT_FILES_NON_STANDARD_ghashp8-ppc.o := y | 36 | OBJECT_FILES_NON_STANDARD_ghashp10-ppc.o := y |
| @@ -30,15 +30,15 @@ MODULE_AUTHOR("Danny Tsen <dtsen@linux.ibm.com"); · 29 unmodified lines | |||
| 30 | MODULE_LICENSE("GPL v2"); | 30 | MODULE_LICENSE("GPL v2"); |
| 31 | MODULE_ALIAS_CRYPTO("aes"); | 31 | MODULE_ALIAS_CRYPTO("aes"); |
| 32 | 32 | ||
| 33 | asmlinkage int aes_p8_set_encrypt_key(const u8 *userKey, const int bits, | 33 | asmlinkage int aes_p10_set_encrypt_key(const u8 *userKey, const int bits, |
| 34 | void *key); | 34 | void *key); |
| 35 | asmlinkage void aes_p8_encrypt(const u8 *in, u8 *out, const void *key); | 35 | asmlinkage void aes_p10_encrypt(const u8 *in, u8 *out, const void *key); |
| 36 | asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len, | 36 | asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len, |
| 37 | void *rkey, u8 *iv, void *Xi); | 37 | void *rkey, u8 *iv, void *Xi); |
| 38 | asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len, | 38 | asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len, |
| 39 | void *rkey, u8 *iv, void *Xi); | 39 | void *rkey, u8 *iv, void *Xi); |
| 40 | asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]); | 40 | asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]); |
| 41 | asmlinkage void gcm_ghash_p8(unsigned char *Xi, unsigned char *Htable, | 41 | asmlinkage void gcm_ghash_p10(unsigned char *Xi, unsigned char *Htable, |
| 42 | unsigned char *aad, unsigned int alen); | 42 | unsigned char *aad, unsigned int alen); |
| 43 | 43 | ||
| 44 | struct aes_key { | 44 | struct aes_key { |
| @@ -93,7 +93,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash, · 48 unmodified lines | |||
| 93 | gctx->aadLen = alen; | 93 | gctx->aadLen = alen; |
| 94 | i = alen & ~0xf; | 94 | i = alen & ~0xf; |
| 95 | if (i) { | 95 | if (i) { |
| 96 | gcm_ghash_p8(nXi, hash->Htable+32, aad, i); | 96 | gcm_ghash_p10(nXi, hash->Htable+32, aad, i); |
| 97 | aad += i; | 97 | aad += i; |
| 98 | alen -= i; | 98 | alen -= i; |
| 99 | } | 99 | } |
| @@ -102,7 +102,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash, · 2 unmodified lines | |||
| 102 | nXi[i] ^= aad[i]; | 102 | nXi[i] ^= aad[i]; |
| 103 | 103 | ||
| 104 | memset(gctx->aad_hash, 0, 16); | 104 | memset(gctx->aad_hash, 0, 16); |
| 105 | gcm_ghash_p8(gctx->aad_hash, hash->Htable+32, nXi, 16); | 105 | gcm_ghash_p10(gctx->aad_hash, hash->Htable+32, nXi, 16); |
| 106 | } else { | 106 | } else { |
| 107 | memcpy(gctx->aad_hash, nXi, 16); | 107 | memcpy(gctx->aad_hash, nXi, 16); |
| 108 | } | 108 | } |
| @@ -115,7 +115,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey, · 6 unmodified lines | |||
| 115 | { | 115 | { |
| 116 | __be32 counter = cpu_to_be32(1); | 116 | __be32 counter = cpu_to_be32(1); |
| 117 | 117 | ||
| 118 | aes_p8_encrypt(hash->H, hash->H, rdkey); | 118 | aes_p10_encrypt(hash->H, hash->H, rdkey); |
| 119 | set_subkey(hash->H); | 119 | set_subkey(hash->H); |
| 120 | gcm_init_htable(hash->Htable+32, hash->H); | 120 | gcm_init_htable(hash->Htable+32, hash->H); |
| 121 | 121 | ||
| @@ -126,7 +126,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey, · 4 unmodified lines | |||
| 126 | /* | 126 | /* |
| 127 | * Encrypt counter vector as iv tag and increment counter. | 127 | * Encrypt counter vector as iv tag and increment counter. |
| 128 | */ | 128 | */ |
| 129 | aes_p8_encrypt(iv, gctx->ivtag, rdkey); | 129 | aes_p10_encrypt(iv, gctx->ivtag, rdkey); |
| 130 | 130 | ||
| 131 | counter = cpu_to_be32(2); | 131 | counter = cpu_to_be32(2); |
| 132 | *((__be32 *)(iv+12)) = counter; | 132 | *((__be32 *)(iv+12)) = counter; |
| @@ -160,7 +160,7 @@ static void finish_tag(struct gcm_ctx *gctx, struct Hash_ctx *hash, int len) · 27 unmodified lines | |||
| 160 | /* | 160 | /* |
| 161 | * hash (AAD len and len) | 161 | * hash (AAD len and len) |
| 162 | */ | 162 | */ |
| 163 | gcm_ghash_p8(hash->Htable, hash->Htable+32, aclen, 16); | 163 | gcm_ghash_p10(hash->Htable, hash->Htable+32, aclen, 16); |
| 164 | 164 | ||
| 165 | for (i = 0; i < 16; i++) | 165 | for (i = 0; i < 16; i++) |
| 166 | hash->Htable[i] ^= gctx->ivtag[i]; | 166 | hash->Htable[i] ^= gctx->ivtag[i]; |
| @@ -192,7 +192,7 @@ static int p10_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, · 25 unmodified lines | |||
| 192 | int ret; | 192 | int ret; |
| 193 | 193 | ||
| 194 | vsx_begin(); | 194 | vsx_begin(); |
| 195 | ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); | 195 | ret = aes_p10_set_encrypt_key(key, keylen * 8, &ctx->enc_key); |
| 196 | vsx_end(); | 196 | vsx_end(); |
| 197 | 197 | ||
| 198 | return ret ? -EINVAL : 0; | 198 | return ret ? -EINVAL : 0; |
| @@ -110,7 +110,7 @@ die "can't locate ppc-xlate.pl"; · 109 unmodified lines | |||
| 110 | open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; | 110 | open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; |
| 111 | 111 | ||
| 112 | $FRAME=8*$SIZE_T; | 112 | $FRAME=8*$SIZE_T; |
| 113 | $prefix="aes_p8"; | 113 | $prefix="aes_p10"; |
| 114 | 114 | ||
| 115 | $sp="r1"; | 115 | $sp="r1"; |
| 116 | $vrsave="r12"; | 116 | $vrsave="r12"; |
| @@ -64,7 +64,7 @@ $code=<<___; · 63 unmodified lines | |||
| 64 | 64 | ||
| 65 | .text | 65 | .text |
| 66 | 66 | ||
| 67 | .globl .gcm_init_p8 | 67 | .globl .gcm_init_p10 |
| 68 | lis r0,0xfff0 | 68 | lis r0,0xfff0 |
| 69 | li r8,0x10 | 69 | li r8,0x10 |
| 70 | mfspr $vrsave,256 | 70 | mfspr $vrsave,256 |
| @@ -110,7 +110,7 @@ $code=<<___; · 39 unmodified lines | |||
| 110 | .long 0 | 110 | .long 0 |
| 111 | .byte 0,12,0x14,0,0,0,2,0 | 111 | .byte 0,12,0x14,0,0,0,2,0 |
| 112 | .long 0 | 112 | .long 0 |
| 113 | .size .gcm_init_p8,.-.gcm_init_p8 | 113 | .size .gcm_init_p10,.-.gcm_init_p10 |
| 114 | 114 | ||
| 115 | .globl .gcm_init_htable | 115 | .globl .gcm_init_htable |
| 116 | lis r0,0xfff0 | 116 | lis r0,0xfff0 |
| @@ -237,7 +237,7 @@ $code=<<___; · 120 unmodified lines | |||
| 237 | .long 0 | 237 | .long 0 |
| 238 | .size .gcm_init_htable,.-.gcm_init_htable | 238 | .size .gcm_init_htable,.-.gcm_init_htable |
| 239 | 239 | ||
| 240 | .globl .gcm_gmult_p8 | 240 | .globl .gcm_gmult_p10 |
| 241 | lis r0,0xfff8 | 241 | lis r0,0xfff8 |
| 242 | li r8,0x10 | 242 | li r8,0x10 |
| 243 | mfspr $vrsave,256 | 243 | mfspr $vrsave,256 |
| @@ -283,9 +283,9 @@ $code=<<___; · 39 unmodified lines | |||
| 283 | .long 0 | 283 | .long 0 |
| 284 | .byte 0,12,0x14,0,0,0,2,0 | 284 | .byte 0,12,0x14,0,0,0,2,0 |
| 285 | .long 0 | 285 | .long 0 |
| 286 | .size .gcm_gmult_p8,.-.gcm_gmult_p8 | 286 | .size .gcm_gmult_p10,.-.gcm_gmult_p10 |
| 287 | 287 | ||
| 288 | .globl .gcm_ghash_p8 | 288 | .globl .gcm_ghash_p10 |
| 289 | lis r0,0xfff8 | 289 | lis r0,0xfff8 |
| 290 | li r8,0x10 | 290 | li r8,0x10 |
| 291 | mfspr $vrsave,256 | 291 | mfspr $vrsave,256 |
| @@ -350,7 +350,7 @@ Loop: · 58 unmodified lines | |||
| 350 | .long 0 | 350 | .long 0 |
| 351 | .byte 0,12,0x14,0,0,0,4,0 | 351 | .byte 0,12,0x14,0,0,0,4,0 |
| 352 | .long 0 | 352 | .long 0 |
| 353 | .size .gcm_ghash_p8,.-.gcm_ghash_p8 | 353 | .size .gcm_ghash_p10,.-.gcm_ghash_p10 |
| 354 | 354 | ||
| 355 | .asciz "GHASH for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>" | 355 | .asciz "GHASH for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>" |
| 356 | .align 2 | 356 | .align 2 |
| @@ -317,13 +317,22 @@ static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift, · 316 unmodified lines | |||
| 317 | static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages) | 317 | static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages) |
| 318 | { | 318 | { |
| 319 | u64 rc; | 319 | u64 rc; |
| 320 | long rpages = npages; | ||
| 321 | unsigned long limit; | ||
| 320 | 322 | ||
| 321 | if (!firmware_has_feature(FW_FEATURE_STUFF_TCE)) | 323 | if (!firmware_has_feature(FW_FEATURE_STUFF_TCE)) |
| 322 | return tce_free_pSeriesLP(tbl->it_index, tcenum, | 324 | return tce_free_pSeriesLP(tbl->it_index, tcenum, |
| 323 | tbl->it_page_shift, npages); | 325 | tbl->it_page_shift, npages); |
| 324 | 326 | ||
| 325 | rc = plpar_tce_stuff((u64)tbl->it_index, | 327 | do { |
| 326 | (u64)tcenum << tbl->it_page_shift, 0, npages); | 328 | limit = min_t(unsigned long, rpages, 512); |
| 329 | |||
| 330 | rc = plpar_tce_stuff((u64)tbl->it_index, | ||
| 331 | (u64)tcenum << tbl->it_page_shift, 0, limit); | ||
| 332 | |||
| 333 | rpages -= limit; | ||
| 334 | tcenum += limit; | ||
| 335 | } while (rpages > 0 && !rc); | ||
| 327 | 336 | ||
| 328 | if (rc && printk_ratelimit()) { | 337 | if (rc && printk_ratelimit()) { |
| 329 | printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n"); | 338 | printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n"); |
| @@ -88,7 +88,7 @@ static unsigned long ndump = 64; · 87 unmodified lines | |||
| 88 | static unsigned long nidump = 16; | 88 | static unsigned long nidump = 16; |
| 89 | static unsigned long ncsum = 4096; | 89 | static unsigned long ncsum = 4096; |
| 90 | static int termch; | 90 | static int termch; |
| 91 | static char tmpstr[128]; | 91 | static char tmpstr[KSYM_NAME_LEN]; |
| 92 | static int tracing_enabled; | 92 | static int tracing_enabled; |
| 93 | 93 | ||
| 94 | static long bus_error_jmp[JMP_BUF_LEN]; | 94 | static long bus_error_jmp[JMP_BUF_LEN]; |