History

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

Linus Torvalds committed 3 years ago

Commit 9455b4b2 parents e5282a7 719dfd56 files · +33 −24Browse files

Unified · Split

6 files
  1. arch/powerpc/crypto/Makefile +5 −5
  2. arch/powerpc/crypto/aes-gcm-p10-glue.c +9 −9
  3. arch/powerpc/crypto/aesp10-ppc.pl +1 −1
  4. arch/powerpc/crypto/ghashp10-ppc.pl +6 −6
  5. arch/powerpc/platforms/pseries/iommu.c +11 −2
  6. arch/powerpc/xmon/xmon.c +1 −1
arch/powerpc/crypto/Makefile+5−5
@@ -22,15 +22,15 @@ sha1-ppc-spe-y := sha1-spe-asm.o sha1-spe-glue.o · 21 unmodified lines
2222 sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o
2323 crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o
2424 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
2626
2727 quiet_cmd_perl = PERL $@
2828 cmd_perl = $(PERL) $< $(if $(CONFIG_CPU_LITTLE_ENDIAN), linux-ppc64le, linux-ppc64) > $@
2929
30−targets += aesp8-ppc.S ghashp8-ppc.S
30+targets += aesp10-ppc.S ghashp10-ppc.S
3131
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
3333 $(call if_changed,perl)
3434
35−OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y
36−OBJECT_FILES_NON_STANDARD_ghashp8-ppc.o := y
35+OBJECT_FILES_NON_STANDARD_aesp10-ppc.o := y
36+OBJECT_FILES_NON_STANDARD_ghashp10-ppc.o := y
arch/powerpc/crypto/aes-gcm-p10-glue.c+9−9
@@ -30,15 +30,15 @@ MODULE_AUTHOR("Danny Tsen <dtsen@linux.ibm.com"); · 29 unmodified lines
3030 MODULE_LICENSE("GPL v2");
3131 MODULE_ALIAS_CRYPTO("aes");
3232
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,
3434 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);
3636 asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len,
3737 void *rkey, u8 *iv, void *Xi);
3838 asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len,
3939 void *rkey, u8 *iv, void *Xi);
4040 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,
4242 unsigned char *aad, unsigned int alen);
4343
4444 struct aes_key {
@@ -93,7 +93,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash, · 48 unmodified lines
9393 gctx->aadLen = alen;
9494 i = alen & ~0xf;
9595 if (i) {
96− gcm_ghash_p8(nXi, hash->Htable+32, aad, i);
96+ gcm_ghash_p10(nXi, hash->Htable+32, aad, i);
9797 aad += i;
9898 alen -= i;
9999 }
@@ -102,7 +102,7 @@ static void set_aad(struct gcm_ctx *gctx, struct Hash_ctx *hash, · 2 unmodified lines
102102 nXi[i] ^= aad[i];
103103
104104 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);
106106 } else {
107107 memcpy(gctx->aad_hash, nXi, 16);
108108 }
@@ -115,7 +115,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey, · 6 unmodified lines
115115 {
116116 __be32 counter = cpu_to_be32(1);
117117
118− aes_p8_encrypt(hash->H, hash->H, rdkey);
118+ aes_p10_encrypt(hash->H, hash->H, rdkey);
119119 set_subkey(hash->H);
120120 gcm_init_htable(hash->Htable+32, hash->H);
121121
@@ -126,7 +126,7 @@ static void gcmp10_init(struct gcm_ctx *gctx, u8 *iv, unsigned char *rdkey, · 4 unmodified lines
126126 /*
127127 * Encrypt counter vector as iv tag and increment counter.
128128 */
129− aes_p8_encrypt(iv, gctx->ivtag, rdkey);
129+ aes_p10_encrypt(iv, gctx->ivtag, rdkey);
130130
131131 counter = cpu_to_be32(2);
132132 *((__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
160160 /*
161161 * hash (AAD len and len)
162162 */
163− gcm_ghash_p8(hash->Htable, hash->Htable+32, aclen, 16);
163+ gcm_ghash_p10(hash->Htable, hash->Htable+32, aclen, 16);
164164
165165 for (i = 0; i < 16; i++)
166166 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
192192 int ret;
193193
194194 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);
196196 vsx_end();
197197
198198 return ret ? -EINVAL : 0;
arch/powerpc/crypto/aesp10-ppc.plrenamed from arch/powerpc/crypto/aesp8-ppc.pl+1−1
@@ -110,7 +110,7 @@ die "can't locate ppc-xlate.pl"; · 109 unmodified lines
110110 open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
111111
112112 $FRAME=8*$SIZE_T;
113−$prefix="aes_p8";
113+$prefix="aes_p10";
114114
115115 $sp="r1";
116116 $vrsave="r12";
arch/powerpc/crypto/ghashp10-ppc.plrenamed from arch/powerpc/crypto/ghashp8-ppc.pl+6−6
@@ -64,7 +64,7 @@ $code=<<___; · 63 unmodified lines
6464
6565 .text
6666
67−.globl .gcm_init_p8
67+.globl .gcm_init_p10
6868 lis r0,0xfff0
6969 li r8,0x10
7070 mfspr $vrsave,256
@@ -110,7 +110,7 @@ $code=<<___; · 39 unmodified lines
110110 .long 0
111111 .byte 0,12,0x14,0,0,0,2,0
112112 .long 0
113−.size .gcm_init_p8,.-.gcm_init_p8
113+.size .gcm_init_p10,.-.gcm_init_p10
114114
115115 .globl .gcm_init_htable
116116 lis r0,0xfff0
@@ -237,7 +237,7 @@ $code=<<___; · 120 unmodified lines
237237 .long 0
238238 .size .gcm_init_htable,.-.gcm_init_htable
239239
240−.globl .gcm_gmult_p8
240+.globl .gcm_gmult_p10
241241 lis r0,0xfff8
242242 li r8,0x10
243243 mfspr $vrsave,256
@@ -283,9 +283,9 @@ $code=<<___; · 39 unmodified lines
283283 .long 0
284284 .byte 0,12,0x14,0,0,0,2,0
285285 .long 0
286−.size .gcm_gmult_p8,.-.gcm_gmult_p8
286+.size .gcm_gmult_p10,.-.gcm_gmult_p10
287287
288−.globl .gcm_ghash_p8
288+.globl .gcm_ghash_p10
289289 lis r0,0xfff8
290290 li r8,0x10
291291 mfspr $vrsave,256
@@ -350,7 +350,7 @@ Loop: · 58 unmodified lines
350350 .long 0
351351 .byte 0,12,0x14,0,0,0,4,0
352352 .long 0
353−.size .gcm_ghash_p8,.-.gcm_ghash_p8
353+.size .gcm_ghash_p10,.-.gcm_ghash_p10
354354
355355 .asciz "GHASH for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>"
356356 .align 2
arch/powerpc/platforms/pseries/iommu.c+11−2
@@ -317,13 +317,22 @@ static void tce_free_pSeriesLP(unsigned long liobn, long tcenum, long tceshift, · 316 unmodified lines
317317 static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)
318318 {
319319 u64 rc;
320+ long rpages = npages;
321+ unsigned long limit;
320322
321323 if (!firmware_has_feature(FW_FEATURE_STUFF_TCE))
322324 return tce_free_pSeriesLP(tbl->it_index, tcenum,
323325 tbl->it_page_shift, npages);
324326
325− rc = plpar_tce_stuff((u64)tbl->it_index,
326− (u64)tcenum << tbl->it_page_shift, 0, npages);
327+ do {
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);
327336
328337 if (rc && printk_ratelimit()) {
329338 printk("tce_freemulti_pSeriesLP: plpar_tce_stuff failed\n");
arch/powerpc/xmon/xmon.c+1−1
@@ -88,7 +88,7 @@ static unsigned long ndump = 64; · 87 unmodified lines
8888 static unsigned long nidump = 16;
8989 static unsigned long ncsum = 4096;
9090 static int termch;
91−static char tmpstr[128];
91+static char tmpstr[KSYM_NAME_LEN];
9292 static int tracing_enabled;
9393
9494 static long bus_error_jmp[JMP_BUF_LEN];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t