Skip to contentSkip to conversation

s390/crypto: Use -ENODEV instead of -EOPNOTSUPP

PATCH In review David Hildenbrand 4 participants 9 messages Jun 12, 2019 – Jun 13, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover s390/crypto: Use -ENODEV instead of -EOPNOTSUPP

s390x crypto is one of the rare modules that returns -EOPNOTSUPP instead of -ENODEV in case HW support is not available.

Convert to -ENODEV, so e.g., systemd's systemd-modules-load.service ignores this error properly.

v2 -> v3:
- "s390/pkey: Use -ENODEV instead of -EOPNOTSUPP" -- Also convert pkey_clr2protkey() as requested by Harald
- Add r-b's (thanks!)

v1 -> v2:
- Include
-- "s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP"

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Harald Freudenberger <[email protected]>
Cc Cornelia Huck <[email protected]>

David Hildenbrand (4):
s390/pkey: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP

 arch/s390/crypto/ghash_s390.c  | 2 +-
 arch/s390/crypto/prng.c        | 4 ++--
 arch/s390/crypto/sha1_s390.c   | 2 +-
 arch/s390/crypto/sha256_s390.c | 2 +-
 arch/s390/crypto/sha512_s390.c | 2 +-
 drivers/s390/crypto/pkey_api.c | 8 ++++----
 6 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v3 1/4 s390/pkey: Use -ENODEV instead of -EOPNOTSUPP

systemd-modules-load.service automatically tries to load the pkey module on systems that have MSA.

Pkey also requires the MSA3 facility and a bunch of subfunctions. Failing with -EOPNOTSUPP makes "systemd-modules-load.service" fail on any system that does not have all needed subfunctions. For example, when running under QEMU TCG (but also on systems where protected keys are disabled via the HMC).

Let's use -ENODEV, so systemd-modules-load.service properly ignores failing to load the pkey module because of missing HW functionality.

While at it, also convert the -EOPNOTSUPP in pkey_clr2protkey() to -ENODEV.

---
 drivers/s390/crypto/pkey_api.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/s390/crypto/pkey_api.c +4 -4
index 45eb0c14b880..7f418d2d8cdf 100644
@@ -690,7 +690,7 @@ int pkey_clr2protkey(u32 keytype,
 	 */
 	if (!cpacf_test_func(&pckmo_functions, fc)) {
 		DEBUG_ERR("%s pckmo functions not available\n", __func__);
-		return -EOPNOTSUPP;
+		return -ENODEV;
 	}
 
 	/* prepare param block */
@@ -1695,15 +1695,15 @@ static int __init pkey_init(void)
 	 * are able to work with protected keys.
 	 */
 	if (!cpacf_query(CPACF_PCKMO, &pckmo_functions))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 
 	/* check for kmc instructions available */
 	if (!cpacf_query(CPACF_KMC, &kmc_functions))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 	if (!cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_128) ||
 	    !cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_192) ||
 	    !cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_256))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 
 	pkey_debug_init();
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH v3 2/4 s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP

In reply to David Hildenbrand

Let's use the error value that is typically used if HW support is not available when trying to load a module - this is also what systemd's systemd-modules-load.service expects.

---
 arch/s390/crypto/ghash_s390.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/crypto/ghash_s390.c +1 -1
index 86aed30fad3a..eeeb6a7737a4 100644
@@ -137,7 +137,7 @@ static struct shash_alg ghash_alg = {
 static int __init ghash_mod_init(void)
 {
 	if (!cpacf_query_func(CPACF_KIMD, CPACF_KIMD_GHASH))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 
 	return crypto_register_shash(&ghash_alg);
 }
Signature · 1 line
2.21.0
#3 lore raw

PATCH v3 3/4 s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP

In reply to David Hildenbrand

Let's use the error value that is typically used if HW support is not available when trying to load a module - this is also what systemd's systemd-modules-load.service expects.

---
 arch/s390/crypto/prng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/crypto/prng.c +2 -2
index 12cca467af7d..d977643fa627 100644
@@ -824,7 +824,7 @@ static int __init prng_init(void)
 
 	/* check if the CPU has a PRNG */
 	if (!cpacf_query_func(CPACF_KMC, CPACF_KMC_PRNG))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 
 	/* check if TRNG subfunction is available */
 	if (cpacf_query_func(CPACF_PRNO, CPACF_PRNO_TRNG))
@@ -837,7 +837,7 @@ static int __init prng_init(void)
 			if (prng_mode == PRNG_MODE_SHA512) {
 				pr_err("The prng module cannot "
 				       "start in SHA-512 mode\n");
-				return -EOPNOTSUPP;
+				return -ENODEV;
 			}
 			prng_mode = PRNG_MODE_TDES;
 		} else
Signature · 1 line
2.21.0
#4 lore raw

PATCH v3 4/4 s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP

In reply to David Hildenbrand

Let's use the error value that is typically used if HW support is not available when trying to load a module - this is also what systemd's systemd-modules-load.service expects.

---
 arch/s390/crypto/sha1_s390.c   | 2 +-
 arch/s390/crypto/sha256_s390.c | 2 +-
 arch/s390/crypto/sha512_s390.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/s390/crypto/sha1_s390.c +1 -1
index 009572e8276d..7c15542d3685 100644
@@ -86,7 +86,7 @@ static struct shash_alg alg = {
 static int __init sha1_s390_init(void)
 {
 	if (!cpacf_query_func(CPACF_KIMD, CPACF_KIMD_SHA_1))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 	return crypto_register_shash(&alg);
 }
 
arch/s390/crypto/sha256_s390.c +1 -1
index 62833a1d8724..af7505148f80 100644
@@ -117,7 +117,7 @@ static int __init sha256_s390_init(void)
 	int ret;
 
 	if (!cpacf_query_func(CPACF_KIMD, CPACF_KIMD_SHA_256))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 	ret = crypto_register_shash(&sha256_alg);
 	if (ret < 0)
 		goto out;
arch/s390/crypto/sha512_s390.c +1 -1
index be589c340d15..ad29db085a18 100644
@@ -127,7 +127,7 @@ static int __init init(void)
 	int ret;
 
 	if (!cpacf_query_func(CPACF_KIMD, CPACF_KIMD_SHA_512))
-		return -EOPNOTSUPP;
+		return -ENODEV;
 	if ((ret = crypto_register_shash(&sha512_alg)) < 0)
 		goto out;
 	if ((ret = crypto_register_shash(&sha384_alg)) < 0)
Signature · 1 line
2.21.0
#5 lore raw
In reply to David Hildenbrand
Quoted 9 lines · On Wed, 12 Jun 2019 15:33:02 +0200 David Hildenbrand <[email protected]> wrote:

s390x crypto is one of the rare modules that returns -EOPNOTSUPP instead of -ENODEV in case HW support is not available.

Convert to -ENODEV, so e.g., systemd's systemd-modules-load.service ignores this error properly.

v2 -> v3:
- "s390/pkey: Use -ENODEV instead of -EOPNOTSUPP" -- Also convert pkey_clr2protkey() as requested by Harald

Looks reasonable; my r-b still stands.

Quoted 30 lines

- Add r-b's (thanks!)

v1 -> v2:
- Include
-- "s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP"

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Harald Freudenberger <[email protected]>
Cc Cornelia Huck <[email protected]>

David Hildenbrand (4):
s390/pkey: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP

 arch/s390/crypto/ghash_s390.c  | 2 +-
 arch/s390/crypto/prng.c        | 4 ++--
 arch/s390/crypto/sha1_s390.c   | 2 +-
 arch/s390/crypto/sha256_s390.c | 2 +-
 arch/s390/crypto/sha512_s390.c | 2 +-
 drivers/s390/crypto/pkey_api.c | 8 ++++----
 6 files changed, 10 insertions(+), 10 deletions(-)
#6 lore raw
In reply to David Hildenbrand
Quoted 25 lines · David Hildenbrand

s390x crypto is one of the rare modules that returns -EOPNOTSUPP instead of -ENODEV in case HW support is not available.

Convert to -ENODEV, so e.g., systemd's systemd-modules-load.service ignores this error properly.

v2 -> v3:
- "s390/pkey: Use -ENODEV instead of -EOPNOTSUPP" -- Also convert pkey_clr2protkey() as requested by Harald
- Add r-b's (thanks!)

v1 -> v2:
- Include
-- "s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP"

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Harald Freudenberger <[email protected]>
Cc Cornelia Huck <[email protected]>
Quoted 5 lines

David Hildenbrand (4):
s390/pkey: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP

Should I pick these up so they can go upstream via the s390 tree?

maintainer
#7 lore raw
Quoted 26 lines · Heiko Carstens
Quoted 25 lines · David Hildenbrand

s390x crypto is one of the rare modules that returns -EOPNOTSUPP instead of -ENODEV in case HW support is not available.

Convert to -ENODEV, so e.g., systemd's systemd-modules-load.service ignores this error properly.

v2 -> v3:
- "s390/pkey: Use -ENODEV instead of -EOPNOTSUPP" -- Also convert pkey_clr2protkey() as requested by Harald
- Add r-b's (thanks!)

v1 -> v2:
- Include
-- "s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP"

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Harald Freudenberger <[email protected]>
Cc Cornelia Huck <[email protected]>
Quoted 7 lines
Quoted 5 lines

David Hildenbrand (4):
s390/pkey: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP

Should I pick these up so they can go upstream via the s390 tree?

Sure Heiko. Thanks!

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#8 lore raw
Quoted 33 lines · Herbert Xu
Quoted 32 lines · Heiko Carstens
Quoted 30 lines · David Hildenbrand

s390x crypto is one of the rare modules that returns -EOPNOTSUPP instead of -ENODEV in case HW support is not available.

Convert to -ENODEV, so e.g., systemd's systemd-modules-load.service ignores this error properly.

v2 -> v3:
- "s390/pkey: Use -ENODEV instead of -EOPNOTSUPP" -- Also convert pkey_clr2protkey() as requested by Harald
- Add r-b's (thanks!)

v1 -> v2:
- Include
-- "s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP" -- "s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP"

Cc Herbert Xu <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Harald Freudenberger <[email protected]>
Cc Cornelia Huck <[email protected]>

David Hildenbrand (4):
s390/pkey: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: ghash: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: prng: Use -ENODEV instead of -EOPNOTSUPP s390/crypto: sha: Use -ENODEV instead of -EOPNOTSUPP

Quoted 3 lines
Quoted 1 line

Should I pick these up so they can go upstream via the s390 tree?

Sure Heiko. Thanks!

Ok, all applied. Thanks!