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
22sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o22sha256-ppc-spe-y := sha256-spe-asm.o sha256-spe-glue.o
23crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o23crc32c-vpmsum-y := crc32c-vpmsum_asm.o crc32c-vpmsum_glue.o
24crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o24crct10dif-vpmsum-y := crct10dif-vpmsum_asm.o crct10dif-vpmsum_glue.o
25aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp8-ppc.o aesp8-ppc.o25aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp10-ppc.o aesp10-ppc.o
26 26
27quiet_cmd_perl = PERL $@27quiet_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
30targets += aesp8-ppc.S ghashp8-ppc.S30targets += aesp10-ppc.S ghashp10-ppc.S
31 31
32$(obj)/aesp8-ppc.S $(obj)/ghashp8-ppc.S: $(obj)/%.S: $(src)/%.pl FORCE32$(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
35OBJECT_FILES_NON_STANDARD_aesp8-ppc.o := y35OBJECT_FILES_NON_STANDARD_aesp10-ppc.o := y
36OBJECT_FILES_NON_STANDARD_ghashp8-ppc.o := y36OBJECT_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
30MODULE_LICENSE("GPL v2");30MODULE_LICENSE("GPL v2");
31MODULE_ALIAS_CRYPTO("aes");31MODULE_ALIAS_CRYPTO("aes");
32 32
33asmlinkage int aes_p8_set_encrypt_key(const u8 *userKey, const int bits,33asmlinkage int aes_p10_set_encrypt_key(const u8 *userKey, const int bits,
34 void *key);34 void *key);
35asmlinkage void aes_p8_encrypt(const u8 *in, u8 *out, const void *key);35asmlinkage void aes_p10_encrypt(const u8 *in, u8 *out, const void *key);
36asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len,36asmlinkage 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);
38asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len,38asmlinkage 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);
40asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]);40asmlinkage void gcm_init_htable(unsigned char htable[256], unsigned char Xi[16]);
41asmlinkage void gcm_ghash_p8(unsigned char *Xi, unsigned char *Htable,41asmlinkage 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
44struct aes_key {44struct 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;
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
110open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";110open 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";
arch/powerpc/crypto/ghashp10-ppc.plrenamed from arch/powerpc/crypto/ghashp8-ppc.pl+6−6
@@ -64,7 +64,7 @@ $code=<<___; · 63 unmodified lines
64 64
65.text65.text
66 66
67.globl .gcm_init_p867.globl .gcm_init_p10
68 lis r0,0xfff068 lis r0,0xfff0
69 li r8,0x1069 li r8,0x10
70 mfspr $vrsave,25670 mfspr $vrsave,256
@@ -110,7 +110,7 @@ $code=<<___; · 39 unmodified lines
110 .long 0110 .long 0
111 .byte 0,12,0x14,0,0,0,2,0111 .byte 0,12,0x14,0,0,0,2,0
112 .long 0112 .long 0
113.size .gcm_init_p8,.-.gcm_init_p8113.size .gcm_init_p10,.-.gcm_init_p10
114 114
115.globl .gcm_init_htable115.globl .gcm_init_htable
116 lis r0,0xfff0116 lis r0,0xfff0
@@ -237,7 +237,7 @@ $code=<<___; · 120 unmodified lines
237 .long 0237 .long 0
238.size .gcm_init_htable,.-.gcm_init_htable238.size .gcm_init_htable,.-.gcm_init_htable
239 239
240.globl .gcm_gmult_p8240.globl .gcm_gmult_p10
241 lis r0,0xfff8241 lis r0,0xfff8
242 li r8,0x10242 li r8,0x10
243 mfspr $vrsave,256243 mfspr $vrsave,256
@@ -283,9 +283,9 @@ $code=<<___; · 39 unmodified lines
283 .long 0283 .long 0
284 .byte 0,12,0x14,0,0,0,2,0284 .byte 0,12,0x14,0,0,0,2,0
285 .long 0285 .long 0
286.size .gcm_gmult_p8,.-.gcm_gmult_p8286.size .gcm_gmult_p10,.-.gcm_gmult_p10
287 287
288.globl .gcm_ghash_p8288.globl .gcm_ghash_p10
289 lis r0,0xfff8289 lis r0,0xfff8
290 li r8,0x10290 li r8,0x10
291 mfspr $vrsave,256291 mfspr $vrsave,256
@@ -350,7 +350,7 @@ Loop: · 58 unmodified lines
350 .long 0350 .long 0
351 .byte 0,12,0x14,0,0,0,4,0351 .byte 0,12,0x14,0,0,0,4,0
352 .long 0352 .long 0
353.size .gcm_ghash_p8,.-.gcm_ghash_p8353.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 2356.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
317static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages)317static 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");
arch/powerpc/xmon/xmon.c+1−1
@@ -88,7 +88,7 @@ static unsigned long ndump = 64; · 87 unmodified lines
88static unsigned long nidump = 16;88static unsigned long nidump = 16;
89static unsigned long ncsum = 4096;89static unsigned long ncsum = 4096;
90static int termch;90static int termch;
91static char tmpstr[128];91static char tmpstr[KSYM_NAME_LEN];
92static int tracing_enabled;92static int tracing_enabled;
93 93
94static long bus_error_jmp[JMP_BUF_LEN];94static 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