summaryrefslogtreecommitdiff
path: root/debian/patches/0001-Fix-msa-level-detection.patch
blob: 1f2035c0bde6c6a6c4cc74ab3deff00a55128689 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From eeb40e5aea7dd36580629e6b17cd7f03fb62549c Mon Sep 17 00:00:00 2001
From: Patrick Steuer <patrick.steuer@de.ibm.com>
Date: Thu, 17 Nov 2016 14:39:29 +0100
Subject: [PATCH] Fix msa level detection

Fixed problem in library constructor that was leading to false positive
msa level detection resulting in illegal instruction.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
---
 src/s390_crypto.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/s390_crypto.c b/src/s390_crypto.c
index f119202..17cc068 100644
--- a/src/s390_crypto.c
+++ b/src/s390_crypto.c
@@ -146,6 +146,8 @@ void set_switches(int msa)
 	 * kimd query and do not need to over the whole array. Therfore there
 	 * is also no distict setting of the switch needed in form
 	 * msa4_switch = 1. */
+
+	/* kmc query */
 	memset(mask, 0, sizeof(mask));
 	if (msa) {
 		if (begin_sigill_section(&oldact, &oldset) == 0) {
@@ -162,13 +164,14 @@ void set_switches(int msa)
 		*s390_kmc_functions[n].enabled = on;
 	}
 
+	/* kimd query */
+	memset(mask, 0, sizeof(mask));
 	if (msa) {
 		if (begin_sigill_section(&oldact, &oldset) == 0) {
 			s390_kimd(S390_CRYPTO_QUERY, mask, (void *) 0, 0);
 			end_sigill_section(&oldact, &oldset);
 		}
 	}
-
 	for (n = 0; n < (sizeof(s390_kimd_functions) /
 			 sizeof(s390_supported_function_t)); n++) {
 		if (S390_CRYPTO_TEST_MASK(mask, s390_kimd_functions[n].hw_fc))
@@ -178,6 +181,8 @@ void set_switches(int msa)
 		*s390_kimd_functions[n].enabled = on;
 	}
 
+	/* ppno query */
+	memset(mask, 0, sizeof(mask));
 	if (5 <= msa) {
 		msa5_switch = 1;
 		if (begin_sigill_section(&oldact, &oldset) == 0) {
@@ -185,7 +190,6 @@ void set_switches(int msa)
 			end_sigill_section(&oldact, &oldset);
 		}
 	}
-
 	for (n = 0; n < (sizeof(s390_ppno_functions) /
 			 sizeof(s390_supported_function_t)); n++) {
 		if (S390_CRYPTO_TEST_MASK(mask, s390_ppno_functions[n].hw_fc))
@@ -256,7 +260,7 @@ libica_func_list_element_int icaList[] = {
  {RSA_KEY_GEN_ME,  	ADAPTER, 0, ICA_FLAG_SW, 		0},	// SW (openssl)
  {RSA_KEY_GEN_CRT, 	ADAPTER, 0, ICA_FLAG_SW, 		0},	// SW (openssl)
 
- {SHA512_DRNG, PPNO, SHA512_DRNG_GEN, ICA_FLAG_SHW | ICA_FLAG_SW, 0},
+ {SHA512_DRNG, PPNO, SHA512_DRNG_GEN, ICA_FLAG_SW, 0},
 
 /* available for the MSA4 instruction */
 /* available for the RSA instruction */
-- 
2.7.4