linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures
@ 2022-07-13 12:56 Steffen Eiden
  2022-07-13 12:56 ` [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits Steffen Eiden
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Steffen Eiden @ 2022-07-13 12:56 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm
  Cc: nrb

Currently the s390 implementaion of cpufeature is limited to elf_hwcap
bits. Using these to automatically load modules also exposes this
cpufeature to userspace which, sometimes is not intended.

Therefore, rework the s390-cpufeature implementation to allow for
various cpu feature indications, which is not only limited to hwcap bits.

Add a new type to allow facilities to be a cpufeature without using
hwcap bits that expose this feature to userspace.

Load uvdevice when facility 158 is present.

since v1:
	* add r-bs from Claudio
	* worked in comments

Heiko Carstens (2):
  s390/cpufeature: rework to allow more than only hwcap bits
  s390/cpufeature: allow for facility bits

Steffen Eiden (1):
  s390/uvdevice: autoload module based on CPU facility

 arch/s390/crypto/aes_s390.c        |  2 +-
 arch/s390/crypto/chacha-glue.c     |  2 +-
 arch/s390/crypto/crc32-vx.c        |  2 +-
 arch/s390/crypto/des_s390.c        |  2 +-
 arch/s390/crypto/ghash_s390.c      |  2 +-
 arch/s390/crypto/prng.c            |  2 +-
 arch/s390/crypto/sha1_s390.c       |  2 +-
 arch/s390/crypto/sha256_s390.c     |  2 +-
 arch/s390/crypto/sha3_256_s390.c   |  2 +-
 arch/s390/crypto/sha3_512_s390.c   |  2 +-
 arch/s390/crypto/sha512_s390.c     |  2 +-
 arch/s390/include/asm/cpufeature.h | 23 ++++++---------
 arch/s390/kernel/Makefile          |  2 +-
 arch/s390/kernel/cpufeature.c      | 46 ++++++++++++++++++++++++++++++
 arch/s390/kernel/processor.c       | 10 -------
 drivers/char/hw_random/s390-trng.c |  2 +-
 drivers/s390/char/uvdevice.c       |  5 ++--
 drivers/s390/crypto/pkey_api.c     |  2 +-
 18 files changed, 70 insertions(+), 42 deletions(-)
 create mode 100644 arch/s390/kernel/cpufeature.c

-- 
2.35.3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits
  2022-07-13 12:56 [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Steffen Eiden
@ 2022-07-13 12:56 ` Steffen Eiden
  2022-07-13 13:50   ` Claudio Imbrenda
  2022-07-15  7:59   ` Hendrik Brueckner
  2022-07-13 12:56 ` [PATCH v2 2/3] s390/cpufeature: allow for facility bits Steffen Eiden
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 9+ messages in thread
From: Steffen Eiden @ 2022-07-13 12:56 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm
  Cc: nrb

From: Heiko Carstens <hca@linux.ibm.com>

Rework cpufeature implementation to allow for various cpu feature
indications, which is not only limited to hwcap bits. This is achieved
by adding a sequential list of cpu feature numbers, where each of them
is mapped to an entry which indicates what this number is about.

Each entry contains a type member, which indicates what feature
name space to look into (e.g. hwcap, or cpu facility). If wanted this
allows also to automatically load modules only in e.g. z/VM
configurations.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
 arch/s390/crypto/aes_s390.c        |  2 +-
 arch/s390/crypto/chacha-glue.c     |  2 +-
 arch/s390/crypto/crc32-vx.c        |  2 +-
 arch/s390/crypto/des_s390.c        |  2 +-
 arch/s390/crypto/ghash_s390.c      |  2 +-
 arch/s390/crypto/prng.c            |  2 +-
 arch/s390/crypto/sha1_s390.c       |  2 +-
 arch/s390/crypto/sha256_s390.c     |  2 +-
 arch/s390/crypto/sha3_256_s390.c   |  2 +-
 arch/s390/crypto/sha3_512_s390.c   |  2 +-
 arch/s390/crypto/sha512_s390.c     |  2 +-
 arch/s390/include/asm/cpufeature.h | 22 +++++-----------
 arch/s390/kernel/Makefile          |  2 +-
 arch/s390/kernel/cpufeature.c      | 42 ++++++++++++++++++++++++++++++
 arch/s390/kernel/processor.c       | 10 -------
 drivers/char/hw_random/s390-trng.c |  2 +-
 drivers/s390/crypto/pkey_api.c     |  2 +-
 17 files changed, 63 insertions(+), 39 deletions(-)
 create mode 100644 arch/s390/kernel/cpufeature.c

diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index 1023e9d43d44..526c3f40f6a2 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -1049,7 +1049,7 @@ static int __init aes_s390_init(void)
 	return ret;
 }
 
-module_cpu_feature_match(MSA, aes_s390_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, aes_s390_init);
 module_exit(aes_s390_fini);
 
 MODULE_ALIAS_CRYPTO("aes-all");
diff --git a/arch/s390/crypto/chacha-glue.c b/arch/s390/crypto/chacha-glue.c
index 2ec51f339cec..7752bd314558 100644
--- a/arch/s390/crypto/chacha-glue.c
+++ b/arch/s390/crypto/chacha-glue.c
@@ -121,7 +121,7 @@ static void __exit chacha_mod_fini(void)
 		crypto_unregister_skciphers(chacha_algs, ARRAY_SIZE(chacha_algs));
 }
 
-module_cpu_feature_match(VXRS, chacha_mod_init);
+module_cpu_feature_match(S390_CPU_FEATURE_VXRS, chacha_mod_init);
 module_exit(chacha_mod_fini);
 
 MODULE_DESCRIPTION("ChaCha20 stream cipher");
diff --git a/arch/s390/crypto/crc32-vx.c b/arch/s390/crypto/crc32-vx.c
index fafecad20752..017143e9cef7 100644
--- a/arch/s390/crypto/crc32-vx.c
+++ b/arch/s390/crypto/crc32-vx.c
@@ -298,7 +298,7 @@ static void __exit crc_vx_mod_exit(void)
 	crypto_unregister_shashes(crc32_vx_algs, ARRAY_SIZE(crc32_vx_algs));
 }
 
-module_cpu_feature_match(VXRS, crc_vx_mod_init);
+module_cpu_feature_match(S390_CPU_FEATURE_VXRS, crc_vx_mod_init);
 module_exit(crc_vx_mod_exit);
 
 MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>");
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index e013088b5115..8e75b83a5ddc 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -492,7 +492,7 @@ static int __init des_s390_init(void)
 	return ret;
 }
 
-module_cpu_feature_match(MSA, des_s390_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, des_s390_init);
 module_exit(des_s390_exit);
 
 MODULE_ALIAS_CRYPTO("des");
diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c
index 6b07a2f1ce8a..0800a2a5799f 100644
--- a/arch/s390/crypto/ghash_s390.c
+++ b/arch/s390/crypto/ghash_s390.c
@@ -145,7 +145,7 @@ static void __exit ghash_mod_exit(void)
 	crypto_unregister_shash(&ghash_alg);
 }
 
-module_cpu_feature_match(MSA, ghash_mod_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, ghash_mod_init);
 module_exit(ghash_mod_exit);
 
 MODULE_ALIAS_CRYPTO("ghash");
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index ae382bafc772..a077087bc6cc 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -907,5 +907,5 @@ static void __exit prng_exit(void)
 	}
 }
 
-module_cpu_feature_match(MSA, prng_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, prng_init);
 module_exit(prng_exit);
diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c
index a3fabf310a38..bc3a22704e09 100644
--- a/arch/s390/crypto/sha1_s390.c
+++ b/arch/s390/crypto/sha1_s390.c
@@ -95,7 +95,7 @@ static void __exit sha1_s390_fini(void)
 	crypto_unregister_shash(&alg);
 }
 
-module_cpu_feature_match(MSA, sha1_s390_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, sha1_s390_init);
 module_exit(sha1_s390_fini);
 
 MODULE_ALIAS_CRYPTO("sha1");
diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c
index 24983f175676..6f1ccdf93d3e 100644
--- a/arch/s390/crypto/sha256_s390.c
+++ b/arch/s390/crypto/sha256_s390.c
@@ -134,7 +134,7 @@ static void __exit sha256_s390_fini(void)
 	crypto_unregister_shash(&sha256_alg);
 }
 
-module_cpu_feature_match(MSA, sha256_s390_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, sha256_s390_init);
 module_exit(sha256_s390_fini);
 
 MODULE_ALIAS_CRYPTO("sha256");
diff --git a/arch/s390/crypto/sha3_256_s390.c b/arch/s390/crypto/sha3_256_s390.c
index 30ac49b635bf..e1350e033a32 100644
--- a/arch/s390/crypto/sha3_256_s390.c
+++ b/arch/s390/crypto/sha3_256_s390.c
@@ -137,7 +137,7 @@ static void __exit sha3_256_s390_fini(void)
 	crypto_unregister_shash(&sha3_256_alg);
 }
 
-module_cpu_feature_match(MSA, sha3_256_s390_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, sha3_256_s390_init);
 module_exit(sha3_256_s390_fini);
 
 MODULE_ALIAS_CRYPTO("sha3-256");
diff --git a/arch/s390/crypto/sha3_512_s390.c b/arch/s390/crypto/sha3_512_s390.c
index e70d50f7620f..06c142ed9bb1 100644
--- a/arch/s390/crypto/sha3_512_s390.c
+++ b/arch/s390/crypto/sha3_512_s390.c
@@ -147,7 +147,7 @@ static void __exit fini(void)
 	crypto_unregister_shash(&sha3_384_alg);
 }
 
-module_cpu_feature_match(MSA, init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, init);
 module_exit(fini);
 
 MODULE_LICENSE("GPL");
diff --git a/arch/s390/crypto/sha512_s390.c b/arch/s390/crypto/sha512_s390.c
index 43ce4956df73..04f11c407763 100644
--- a/arch/s390/crypto/sha512_s390.c
+++ b/arch/s390/crypto/sha512_s390.c
@@ -142,7 +142,7 @@ static void __exit fini(void)
 	crypto_unregister_shash(&sha384_alg);
 }
 
-module_cpu_feature_match(MSA, init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, init);
 module_exit(fini);
 
 MODULE_LICENSE("GPL");
diff --git a/arch/s390/include/asm/cpufeature.h b/arch/s390/include/asm/cpufeature.h
index 14cfd48d598e..771caf5281e5 100644
--- a/arch/s390/include/asm/cpufeature.h
+++ b/arch/s390/include/asm/cpufeature.h
@@ -2,28 +2,20 @@
 /*
  * Module interface for CPU features
  *
- * Copyright IBM Corp. 2015
+ * Copyright IBM Corp. 2015, 2022
  * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
  */
 
 #ifndef __ASM_S390_CPUFEATURE_H
 #define __ASM_S390_CPUFEATURE_H
 
-#include <asm/elf.h>
+enum {
+	S390_CPU_FEATURE_MSA,
+	S390_CPU_FEATURE_VXRS,
+	MAX_CPU_FEATURES
+};
 
-/* Hardware features on Linux on z Systems are indicated by facility bits that
- * are mapped to the so-called machine flags.  Particular machine flags are
- * then used to define ELF hardware capabilities; most notably hardware flags
- * that are essential for user space / glibc.
- *
- * Restrict the set of exposed CPU features to ELF hardware capabilities for
- * now.  Additional machine flags can be indicated by values larger than
- * MAX_ELF_HWCAP_FEATURES.
- */
-#define MAX_ELF_HWCAP_FEATURES	(8 * sizeof(elf_hwcap))
-#define MAX_CPU_FEATURES	MAX_ELF_HWCAP_FEATURES
-
-#define cpu_feature(feat)	ilog2(HWCAP_ ## feat)
+#define cpu_feature(feature)	(feature)
 
 int cpu_have_feature(unsigned int nr);
 
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 27d6b3c7aa06..3cbfa9fddd9a 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -35,7 +35,7 @@ CFLAGS_unwind_bc.o	+= -fno-optimize-sibling-calls
 
 obj-y	:= traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
 obj-y	+= processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
-obj-y	+= debug.o irq.o ipl.o dis.o diag.o vdso.o
+obj-y	+= debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
 obj-y	+= sysinfo.o lgr.o os_info.o machine_kexec.o
 obj-y	+= runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
 obj-y	+= entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
diff --git a/arch/s390/kernel/cpufeature.c b/arch/s390/kernel/cpufeature.c
new file mode 100644
index 000000000000..9044c75d8b38
--- /dev/null
+++ b/arch/s390/kernel/cpufeature.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright IBM Corp. 2022
+ */
+#include <linux/cpufeature.h>
+#include <linux/bug.h>
+#include <asm/elf.h>
+
+enum {
+	TYPE_HWCAP,
+};
+
+struct s390_cpu_feature {
+	unsigned int type	: 4;
+	unsigned int num	: 28;
+};
+
+static struct s390_cpu_feature s390_cpu_features[MAX_CPU_FEATURES] = {
+	[S390_CPU_FEATURE_MSA]		= {.type = TYPE_HWCAP, .num = HWCAP_NR_MSA},
+	[S390_CPU_FEATURE_VXRS]		= {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS},
+};
+
+/*
+ * cpu_have_feature - Test CPU features on module initialization
+ */
+int cpu_have_feature(unsigned int num)
+{
+	struct s390_cpu_feature *feature;
+
+	if (WARN_ON_ONCE(num >= MAX_CPU_FEATURES))
+		return 0;
+
+	feature = &s390_cpu_features[num];
+	switch (feature->type) {
+	case TYPE_HWCAP:
+		return !!(elf_hwcap & BIT(feature->num));
+	default:
+		WARN_ON_ONCE(1);
+		return 0;
+	}
+}
+EXPORT_SYMBOL(cpu_have_feature);
diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
index aa0e0e7fc773..a194611ba88c 100644
--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -8,7 +8,6 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/stop_machine.h>
-#include <linux/cpufeature.h>
 #include <linux/bitops.h>
 #include <linux/kernel.h>
 #include <linux/random.h>
@@ -96,15 +95,6 @@ void cpu_init(void)
 	enter_lazy_tlb(&init_mm, current);
 }
 
-/*
- * cpu_have_feature - Test CPU features on module initialization
- */
-int cpu_have_feature(unsigned int num)
-{
-	return elf_hwcap & (1UL << num);
-}
-EXPORT_SYMBOL(cpu_have_feature);
-
 static void show_facilities(struct seq_file *m)
 {
 	unsigned int bit;
diff --git a/drivers/char/hw_random/s390-trng.c b/drivers/char/hw_random/s390-trng.c
index 2beaa35c0d74..12fbac0ed8ca 100644
--- a/drivers/char/hw_random/s390-trng.c
+++ b/drivers/char/hw_random/s390-trng.c
@@ -261,5 +261,5 @@ static void __exit trng_exit(void)
 	trng_debug_exit();
 }
 
-module_cpu_feature_match(MSA, trng_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, trng_init);
 module_exit(trng_exit);
diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c
index 7329caa7d467..5a05d1cdfec2 100644
--- a/drivers/s390/crypto/pkey_api.c
+++ b/drivers/s390/crypto/pkey_api.c
@@ -2115,5 +2115,5 @@ static void __exit pkey_exit(void)
 	pkey_debug_exit();
 }
 
-module_cpu_feature_match(MSA, pkey_init);
+module_cpu_feature_match(S390_CPU_FEATURE_MSA, pkey_init);
 module_exit(pkey_exit);
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] s390/cpufeature: allow for facility bits
  2022-07-13 12:56 [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Steffen Eiden
  2022-07-13 12:56 ` [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits Steffen Eiden
@ 2022-07-13 12:56 ` Steffen Eiden
  2022-07-13 12:56 ` [PATCH v2 3/3] s390/uvdevice: autoload module based on CPU facility Steffen Eiden
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Steffen Eiden @ 2022-07-13 12:56 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm
  Cc: nrb

From: Heiko Carstens <hca@linux.ibm.com>

Allow for facility bits to be used in cpu features.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
---
 arch/s390/kernel/cpufeature.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/s390/kernel/cpufeature.c b/arch/s390/kernel/cpufeature.c
index 9044c75d8b38..170894730fcc 100644
--- a/arch/s390/kernel/cpufeature.c
+++ b/arch/s390/kernel/cpufeature.c
@@ -8,6 +8,7 @@
 
 enum {
 	TYPE_HWCAP,
+	TYPE_FACILITY,
 };
 
 struct s390_cpu_feature {
@@ -34,6 +35,8 @@ int cpu_have_feature(unsigned int num)
 	switch (feature->type) {
 	case TYPE_HWCAP:
 		return !!(elf_hwcap & BIT(feature->num));
+	case TYPE_FACILITY:
+		return test_facility(feature->num);
 	default:
 		WARN_ON_ONCE(1);
 		return 0;
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] s390/uvdevice: autoload module based on CPU facility
  2022-07-13 12:56 [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Steffen Eiden
  2022-07-13 12:56 ` [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits Steffen Eiden
  2022-07-13 12:56 ` [PATCH v2 2/3] s390/cpufeature: allow for facility bits Steffen Eiden
@ 2022-07-13 12:56 ` Steffen Eiden
  2022-07-14 10:53 ` [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Heiko Carstens
  2022-07-15  7:49 ` Hendrik Brueckner
  4 siblings, 0 replies; 9+ messages in thread
From: Steffen Eiden @ 2022-07-13 12:56 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm
  Cc: nrb

Make sure the uvdevice driver will be automatically loaded when
facility 158 is available.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 arch/s390/include/asm/cpufeature.h | 1 +
 arch/s390/kernel/cpufeature.c      | 1 +
 drivers/s390/char/uvdevice.c       | 5 ++---
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/s390/include/asm/cpufeature.h b/arch/s390/include/asm/cpufeature.h
index 771caf5281e5..931204613753 100644
--- a/arch/s390/include/asm/cpufeature.h
+++ b/arch/s390/include/asm/cpufeature.h
@@ -12,6 +12,7 @@
 enum {
 	S390_CPU_FEATURE_MSA,
 	S390_CPU_FEATURE_VXRS,
+	S390_CPU_FEATURE_UV,
 	MAX_CPU_FEATURES
 };
 
diff --git a/arch/s390/kernel/cpufeature.c b/arch/s390/kernel/cpufeature.c
index 170894730fcc..5c69be58a057 100644
--- a/arch/s390/kernel/cpufeature.c
+++ b/arch/s390/kernel/cpufeature.c
@@ -19,6 +19,7 @@ struct s390_cpu_feature {
 static struct s390_cpu_feature s390_cpu_features[MAX_CPU_FEATURES] = {
 	[S390_CPU_FEATURE_MSA]		= {.type = TYPE_HWCAP, .num = HWCAP_NR_MSA},
 	[S390_CPU_FEATURE_VXRS]		= {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS},
+	[S390_CPU_FEATURE_UV]		= {.type = TYPE_FACILITY, .num = 158},
 };
 
 /*
diff --git a/drivers/s390/char/uvdevice.c b/drivers/s390/char/uvdevice.c
index 66505d7166a6..1d40457c7b10 100644
--- a/drivers/s390/char/uvdevice.c
+++ b/drivers/s390/char/uvdevice.c
@@ -27,6 +27,7 @@
 #include <linux/stddef.h>
 #include <linux/vmalloc.h>
 #include <linux/slab.h>
+#include <linux/cpufeature.h>
 
 #include <asm/uvdevice.h>
 #include <asm/uv.h>
@@ -244,12 +245,10 @@ static void __exit uvio_dev_exit(void)
 
 static int __init uvio_dev_init(void)
 {
-	if (!test_facility(158))
-		return -ENXIO;
 	return misc_register(&uvio_dev_miscdev);
 }
 
-module_init(uvio_dev_init);
+module_cpu_feature_match(S390_CPU_FEATURE_UV, uvio_dev_init);
 module_exit(uvio_dev_exit);
 
 MODULE_AUTHOR("IBM Corporation");
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits
  2022-07-13 12:56 ` [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits Steffen Eiden
@ 2022-07-13 13:50   ` Claudio Imbrenda
  2022-07-15  7:59   ` Hendrik Brueckner
  1 sibling, 0 replies; 9+ messages in thread
From: Claudio Imbrenda @ 2022-07-13 13:50 UTC (permalink / raw)
  To: Steffen Eiden
  Cc: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Vasily Gorbik, linux-s390, linux-kernel, linux-mm,
	nrb

On Wed, 13 Jul 2022 14:56:42 +0200
Steffen Eiden <seiden@linux.ibm.com> wrote:

> From: Heiko Carstens <hca@linux.ibm.com>
> 
> Rework cpufeature implementation to allow for various cpu feature
> indications, which is not only limited to hwcap bits. This is achieved
> by adding a sequential list of cpu feature numbers, where each of them
> is mapped to an entry which indicates what this number is about.
> 
> Each entry contains a type member, which indicates what feature
> name space to look into (e.g. hwcap, or cpu facility). If wanted this
> allows also to automatically load modules only in e.g. z/VM
> configurations.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  arch/s390/crypto/aes_s390.c        |  2 +-
>  arch/s390/crypto/chacha-glue.c     |  2 +-
>  arch/s390/crypto/crc32-vx.c        |  2 +-
>  arch/s390/crypto/des_s390.c        |  2 +-
>  arch/s390/crypto/ghash_s390.c      |  2 +-
>  arch/s390/crypto/prng.c            |  2 +-
>  arch/s390/crypto/sha1_s390.c       |  2 +-
>  arch/s390/crypto/sha256_s390.c     |  2 +-
>  arch/s390/crypto/sha3_256_s390.c   |  2 +-
>  arch/s390/crypto/sha3_512_s390.c   |  2 +-
>  arch/s390/crypto/sha512_s390.c     |  2 +-
>  arch/s390/include/asm/cpufeature.h | 22 +++++-----------
>  arch/s390/kernel/Makefile          |  2 +-
>  arch/s390/kernel/cpufeature.c      | 42 ++++++++++++++++++++++++++++++
>  arch/s390/kernel/processor.c       | 10 -------
>  drivers/char/hw_random/s390-trng.c |  2 +-
>  drivers/s390/crypto/pkey_api.c     |  2 +-
>  17 files changed, 63 insertions(+), 39 deletions(-)
>  create mode 100644 arch/s390/kernel/cpufeature.c
> 
> diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
> index 1023e9d43d44..526c3f40f6a2 100644
> --- a/arch/s390/crypto/aes_s390.c
> +++ b/arch/s390/crypto/aes_s390.c
> @@ -1049,7 +1049,7 @@ static int __init aes_s390_init(void)
>  	return ret;
>  }
>  
> -module_cpu_feature_match(MSA, aes_s390_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, aes_s390_init);
>  module_exit(aes_s390_fini);
>  
>  MODULE_ALIAS_CRYPTO("aes-all");
> diff --git a/arch/s390/crypto/chacha-glue.c b/arch/s390/crypto/chacha-glue.c
> index 2ec51f339cec..7752bd314558 100644
> --- a/arch/s390/crypto/chacha-glue.c
> +++ b/arch/s390/crypto/chacha-glue.c
> @@ -121,7 +121,7 @@ static void __exit chacha_mod_fini(void)
>  		crypto_unregister_skciphers(chacha_algs, ARRAY_SIZE(chacha_algs));
>  }
>  
> -module_cpu_feature_match(VXRS, chacha_mod_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_VXRS, chacha_mod_init);
>  module_exit(chacha_mod_fini);
>  
>  MODULE_DESCRIPTION("ChaCha20 stream cipher");
> diff --git a/arch/s390/crypto/crc32-vx.c b/arch/s390/crypto/crc32-vx.c
> index fafecad20752..017143e9cef7 100644
> --- a/arch/s390/crypto/crc32-vx.c
> +++ b/arch/s390/crypto/crc32-vx.c
> @@ -298,7 +298,7 @@ static void __exit crc_vx_mod_exit(void)
>  	crypto_unregister_shashes(crc32_vx_algs, ARRAY_SIZE(crc32_vx_algs));
>  }
>  
> -module_cpu_feature_match(VXRS, crc_vx_mod_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_VXRS, crc_vx_mod_init);
>  module_exit(crc_vx_mod_exit);
>  
>  MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>");
> diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
> index e013088b5115..8e75b83a5ddc 100644
> --- a/arch/s390/crypto/des_s390.c
> +++ b/arch/s390/crypto/des_s390.c
> @@ -492,7 +492,7 @@ static int __init des_s390_init(void)
>  	return ret;
>  }
>  
> -module_cpu_feature_match(MSA, des_s390_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, des_s390_init);
>  module_exit(des_s390_exit);
>  
>  MODULE_ALIAS_CRYPTO("des");
> diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c
> index 6b07a2f1ce8a..0800a2a5799f 100644
> --- a/arch/s390/crypto/ghash_s390.c
> +++ b/arch/s390/crypto/ghash_s390.c
> @@ -145,7 +145,7 @@ static void __exit ghash_mod_exit(void)
>  	crypto_unregister_shash(&ghash_alg);
>  }
>  
> -module_cpu_feature_match(MSA, ghash_mod_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, ghash_mod_init);
>  module_exit(ghash_mod_exit);
>  
>  MODULE_ALIAS_CRYPTO("ghash");
> diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
> index ae382bafc772..a077087bc6cc 100644
> --- a/arch/s390/crypto/prng.c
> +++ b/arch/s390/crypto/prng.c
> @@ -907,5 +907,5 @@ static void __exit prng_exit(void)
>  	}
>  }
>  
> -module_cpu_feature_match(MSA, prng_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, prng_init);
>  module_exit(prng_exit);
> diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c
> index a3fabf310a38..bc3a22704e09 100644
> --- a/arch/s390/crypto/sha1_s390.c
> +++ b/arch/s390/crypto/sha1_s390.c
> @@ -95,7 +95,7 @@ static void __exit sha1_s390_fini(void)
>  	crypto_unregister_shash(&alg);
>  }
>  
> -module_cpu_feature_match(MSA, sha1_s390_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, sha1_s390_init);
>  module_exit(sha1_s390_fini);
>  
>  MODULE_ALIAS_CRYPTO("sha1");
> diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c
> index 24983f175676..6f1ccdf93d3e 100644
> --- a/arch/s390/crypto/sha256_s390.c
> +++ b/arch/s390/crypto/sha256_s390.c
> @@ -134,7 +134,7 @@ static void __exit sha256_s390_fini(void)
>  	crypto_unregister_shash(&sha256_alg);
>  }
>  
> -module_cpu_feature_match(MSA, sha256_s390_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, sha256_s390_init);
>  module_exit(sha256_s390_fini);
>  
>  MODULE_ALIAS_CRYPTO("sha256");
> diff --git a/arch/s390/crypto/sha3_256_s390.c b/arch/s390/crypto/sha3_256_s390.c
> index 30ac49b635bf..e1350e033a32 100644
> --- a/arch/s390/crypto/sha3_256_s390.c
> +++ b/arch/s390/crypto/sha3_256_s390.c
> @@ -137,7 +137,7 @@ static void __exit sha3_256_s390_fini(void)
>  	crypto_unregister_shash(&sha3_256_alg);
>  }
>  
> -module_cpu_feature_match(MSA, sha3_256_s390_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, sha3_256_s390_init);
>  module_exit(sha3_256_s390_fini);
>  
>  MODULE_ALIAS_CRYPTO("sha3-256");
> diff --git a/arch/s390/crypto/sha3_512_s390.c b/arch/s390/crypto/sha3_512_s390.c
> index e70d50f7620f..06c142ed9bb1 100644
> --- a/arch/s390/crypto/sha3_512_s390.c
> +++ b/arch/s390/crypto/sha3_512_s390.c
> @@ -147,7 +147,7 @@ static void __exit fini(void)
>  	crypto_unregister_shash(&sha3_384_alg);
>  }
>  
> -module_cpu_feature_match(MSA, init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, init);
>  module_exit(fini);
>  
>  MODULE_LICENSE("GPL");
> diff --git a/arch/s390/crypto/sha512_s390.c b/arch/s390/crypto/sha512_s390.c
> index 43ce4956df73..04f11c407763 100644
> --- a/arch/s390/crypto/sha512_s390.c
> +++ b/arch/s390/crypto/sha512_s390.c
> @@ -142,7 +142,7 @@ static void __exit fini(void)
>  	crypto_unregister_shash(&sha384_alg);
>  }
>  
> -module_cpu_feature_match(MSA, init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, init);
>  module_exit(fini);
>  
>  MODULE_LICENSE("GPL");
> diff --git a/arch/s390/include/asm/cpufeature.h b/arch/s390/include/asm/cpufeature.h
> index 14cfd48d598e..771caf5281e5 100644
> --- a/arch/s390/include/asm/cpufeature.h
> +++ b/arch/s390/include/asm/cpufeature.h
> @@ -2,28 +2,20 @@
>  /*
>   * Module interface for CPU features
>   *
> - * Copyright IBM Corp. 2015
> + * Copyright IBM Corp. 2015, 2022
>   * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
>   */
>  
>  #ifndef __ASM_S390_CPUFEATURE_H
>  #define __ASM_S390_CPUFEATURE_H
>  
> -#include <asm/elf.h>
> +enum {
> +	S390_CPU_FEATURE_MSA,
> +	S390_CPU_FEATURE_VXRS,
> +	MAX_CPU_FEATURES
> +};
>  
> -/* Hardware features on Linux on z Systems are indicated by facility bits that
> - * are mapped to the so-called machine flags.  Particular machine flags are
> - * then used to define ELF hardware capabilities; most notably hardware flags
> - * that are essential for user space / glibc.
> - *
> - * Restrict the set of exposed CPU features to ELF hardware capabilities for
> - * now.  Additional machine flags can be indicated by values larger than
> - * MAX_ELF_HWCAP_FEATURES.
> - */
> -#define MAX_ELF_HWCAP_FEATURES	(8 * sizeof(elf_hwcap))
> -#define MAX_CPU_FEATURES	MAX_ELF_HWCAP_FEATURES
> -
> -#define cpu_feature(feat)	ilog2(HWCAP_ ## feat)
> +#define cpu_feature(feature)	(feature)
>  
>  int cpu_have_feature(unsigned int nr);
>  
> diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
> index 27d6b3c7aa06..3cbfa9fddd9a 100644
> --- a/arch/s390/kernel/Makefile
> +++ b/arch/s390/kernel/Makefile
> @@ -35,7 +35,7 @@ CFLAGS_unwind_bc.o	+= -fno-optimize-sibling-calls
>  
>  obj-y	:= traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
>  obj-y	+= processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
> -obj-y	+= debug.o irq.o ipl.o dis.o diag.o vdso.o
> +obj-y	+= debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
>  obj-y	+= sysinfo.o lgr.o os_info.o machine_kexec.o
>  obj-y	+= runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o sthyi.o
>  obj-y	+= entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
> diff --git a/arch/s390/kernel/cpufeature.c b/arch/s390/kernel/cpufeature.c
> new file mode 100644
> index 000000000000..9044c75d8b38
> --- /dev/null
> +++ b/arch/s390/kernel/cpufeature.c
> @@ -0,0 +1,42 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright IBM Corp. 2022
> + */
> +#include <linux/cpufeature.h>
> +#include <linux/bug.h>
> +#include <asm/elf.h>
> +
> +enum {
> +	TYPE_HWCAP,
> +};
> +
> +struct s390_cpu_feature {
> +	unsigned int type	: 4;
> +	unsigned int num	: 28;
> +};
> +
> +static struct s390_cpu_feature s390_cpu_features[MAX_CPU_FEATURES] = {
> +	[S390_CPU_FEATURE_MSA]		= {.type = TYPE_HWCAP, .num = HWCAP_NR_MSA},
> +	[S390_CPU_FEATURE_VXRS]		= {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS},
> +};
> +
> +/*
> + * cpu_have_feature - Test CPU features on module initialization
> + */
> +int cpu_have_feature(unsigned int num)
> +{
> +	struct s390_cpu_feature *feature;
> +
> +	if (WARN_ON_ONCE(num >= MAX_CPU_FEATURES))
> +		return 0;
> +
> +	feature = &s390_cpu_features[num];
> +	switch (feature->type) {
> +	case TYPE_HWCAP:
> +		return !!(elf_hwcap & BIT(feature->num));
> +	default:
> +		WARN_ON_ONCE(1);
> +		return 0;
> +	}
> +}
> +EXPORT_SYMBOL(cpu_have_feature);
> diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
> index aa0e0e7fc773..a194611ba88c 100644
> --- a/arch/s390/kernel/processor.c
> +++ b/arch/s390/kernel/processor.c
> @@ -8,7 +8,6 @@
>  #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
>  
>  #include <linux/stop_machine.h>
> -#include <linux/cpufeature.h>
>  #include <linux/bitops.h>
>  #include <linux/kernel.h>
>  #include <linux/random.h>
> @@ -96,15 +95,6 @@ void cpu_init(void)
>  	enter_lazy_tlb(&init_mm, current);
>  }
>  
> -/*
> - * cpu_have_feature - Test CPU features on module initialization
> - */
> -int cpu_have_feature(unsigned int num)
> -{
> -	return elf_hwcap & (1UL << num);
> -}
> -EXPORT_SYMBOL(cpu_have_feature);
> -
>  static void show_facilities(struct seq_file *m)
>  {
>  	unsigned int bit;
> diff --git a/drivers/char/hw_random/s390-trng.c b/drivers/char/hw_random/s390-trng.c
> index 2beaa35c0d74..12fbac0ed8ca 100644
> --- a/drivers/char/hw_random/s390-trng.c
> +++ b/drivers/char/hw_random/s390-trng.c
> @@ -261,5 +261,5 @@ static void __exit trng_exit(void)
>  	trng_debug_exit();
>  }
>  
> -module_cpu_feature_match(MSA, trng_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, trng_init);
>  module_exit(trng_exit);
> diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c
> index 7329caa7d467..5a05d1cdfec2 100644
> --- a/drivers/s390/crypto/pkey_api.c
> +++ b/drivers/s390/crypto/pkey_api.c
> @@ -2115,5 +2115,5 @@ static void __exit pkey_exit(void)
>  	pkey_debug_exit();
>  }
>  
> -module_cpu_feature_match(MSA, pkey_init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, pkey_init);
>  module_exit(pkey_exit);



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures
  2022-07-13 12:56 [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Steffen Eiden
                   ` (2 preceding siblings ...)
  2022-07-13 12:56 ` [PATCH v2 3/3] s390/uvdevice: autoload module based on CPU facility Steffen Eiden
@ 2022-07-14 10:53 ` Heiko Carstens
  2022-07-15  7:49 ` Hendrik Brueckner
  4 siblings, 0 replies; 9+ messages in thread
From: Heiko Carstens @ 2022-07-14 10:53 UTC (permalink / raw)
  To: Steffen Eiden
  Cc: Alexander Gordeev, Christian Borntraeger, Janosch Frank,
	Claudio Imbrenda, Vasily Gorbik, linux-s390, linux-kernel,
	linux-mm, nrb

On Wed, Jul 13, 2022 at 02:56:41PM +0200, Steffen Eiden wrote:
> Currently the s390 implementaion of cpufeature is limited to elf_hwcap
> bits. Using these to automatically load modules also exposes this
> cpufeature to userspace which, sometimes is not intended.
> 
> Therefore, rework the s390-cpufeature implementation to allow for
> various cpu feature indications, which is not only limited to hwcap bits.
> 
> Add a new type to allow facilities to be a cpufeature without using
> hwcap bits that expose this feature to userspace.
> 
> Load uvdevice when facility 158 is present.
> 
> since v1:
> 	* add r-bs from Claudio
> 	* worked in comments
> 
> Heiko Carstens (2):
>   s390/cpufeature: rework to allow more than only hwcap bits
>   s390/cpufeature: allow for facility bits
> 
> Steffen Eiden (1):
>   s390/uvdevice: autoload module based on CPU facility

Series applied, thanks!


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures
  2022-07-13 12:56 [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Steffen Eiden
                   ` (3 preceding siblings ...)
  2022-07-14 10:53 ` [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Heiko Carstens
@ 2022-07-15  7:49 ` Hendrik Brueckner
  4 siblings, 0 replies; 9+ messages in thread
From: Hendrik Brueckner @ 2022-07-15  7:49 UTC (permalink / raw)
  To: Steffen Eiden
  Cc: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm, nrb

Maybe, I am bit late ...

On Wed, Jul 13, 2022 at 02:56:41PM +0200, Steffen Eiden wrote:
> Currently the s390 implementaion of cpufeature is limited to elf_hwcap
> bits. Using these to automatically load modules also exposes this
> cpufeature to userspace which, sometimes is not intended.

Those features are (always) exposed to user space as module loading is
actually done by udev rules. However, we had some pseudo-hwcaps (e.g. sie64a)
in the past.. but I very appreciate this change!

Thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits
  2022-07-13 12:56 ` [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits Steffen Eiden
  2022-07-13 13:50   ` Claudio Imbrenda
@ 2022-07-15  7:59   ` Hendrik Brueckner
  2022-07-15  9:32     ` Heiko Carstens
  1 sibling, 1 reply; 9+ messages in thread
From: Hendrik Brueckner @ 2022-07-15  7:59 UTC (permalink / raw)
  To: Steffen Eiden
  Cc: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm, nrb

On Wed, Jul 13, 2022 at 02:56:42PM +0200, Steffen Eiden wrote:
> From: Heiko Carstens <hca@linux.ibm.com>
> 
> Rework cpufeature implementation to allow for various cpu feature
> indications, which is not only limited to hwcap bits. This is achieved
> by adding a sequential list of cpu feature numbers, where each of them
> is mapped to an entry which indicates what this number is about.
> 
> Each entry contains a type member, which indicates what feature
> name space to look into (e.g. hwcap, or cpu facility). If wanted this
> allows also to automatically load modules only in e.g. z/VM
> configurations.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
>  arch/s390/crypto/aes_s390.c        |  2 +-
>  arch/s390/crypto/chacha-glue.c     |  2 +-
>  arch/s390/crypto/crc32-vx.c        |  2 +-
>  arch/s390/crypto/des_s390.c        |  2 +-
>  arch/s390/crypto/ghash_s390.c      |  2 +-
>  arch/s390/crypto/prng.c            |  2 +-
>  arch/s390/crypto/sha1_s390.c       |  2 +-
>  arch/s390/crypto/sha256_s390.c     |  2 +-
>  arch/s390/crypto/sha3_256_s390.c   |  2 +-
>  arch/s390/crypto/sha3_512_s390.c   |  2 +-
>  arch/s390/crypto/sha512_s390.c     |  2 +-

Regarding facility bits for cpu features:  Initially, I used
MSA hwcap to cover all ciphers among all hw generations. With facility bit
checks, it makes more sense to fine-tune and load based on respective
MSA level or CPACF functions that is required for ciphers/hashes.


E.g. like

> diff --git a/arch/s390/crypto/sha512_s390.c b/arch/s390/crypto/sha512_s390.c
> index 43ce4956df73..04f11c407763 100644
> --- a/arch/s390/crypto/sha512_s390.c
> +++ b/arch/s390/crypto/sha512_s390.c
> @@ -142,7 +142,7 @@ static void __exit fini(void)
>  	crypto_unregister_shash(&sha384_alg);
>  }
> 
> -module_cpu_feature_match(MSA, init);
> +module_cpu_feature_match(S390_CPU_FEATURE_MSA, init);
>  module_exit(fini);

which becomes automatically loaded if (any) MSA is available and then
performs this check:

	cpacf_query_func(CPACF_KIMD, CPACF_KIMD_SHA_512

which in the worst case would fail.

This might be a very useful follow-up patch to remove those mod init checks
into the cpu feature.

Other than that,

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits
  2022-07-15  7:59   ` Hendrik Brueckner
@ 2022-07-15  9:32     ` Heiko Carstens
  0 siblings, 0 replies; 9+ messages in thread
From: Heiko Carstens @ 2022-07-15  9:32 UTC (permalink / raw)
  To: Hendrik Brueckner
  Cc: Steffen Eiden, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm, nrb

On Fri, Jul 15, 2022 at 09:59:49AM +0200, Hendrik Brueckner wrote:
> Regarding facility bits for cpu features:  Initially, I used
> MSA hwcap to cover all ciphers among all hw generations. With facility bit
> checks, it makes more sense to fine-tune and load based on respective
> MSA level or CPACF functions that is required for ciphers/hashes.
...
> > -module_cpu_feature_match(MSA, init);
> > +module_cpu_feature_match(S390_CPU_FEATURE_MSA, init);
> >  module_exit(fini);
> 
> which becomes automatically loaded if (any) MSA is available and then
> performs this check:
> 
> 	cpacf_query_func(CPACF_KIMD, CPACF_KIMD_SHA_512
> 
> which in the worst case would fail.
> 
> This might be a very useful follow-up patch to remove those mod init checks
> into the cpu feature.

Yes, that makes a lot of sense. Thanks for suggesting this!


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-07-15  9:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 12:56 [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Steffen Eiden
2022-07-13 12:56 ` [PATCH v2 1/3] s390/cpufeature: rework to allow more than only hwcap bits Steffen Eiden
2022-07-13 13:50   ` Claudio Imbrenda
2022-07-15  7:59   ` Hendrik Brueckner
2022-07-15  9:32     ` Heiko Carstens
2022-07-13 12:56 ` [PATCH v2 2/3] s390/cpufeature: allow for facility bits Steffen Eiden
2022-07-13 12:56 ` [PATCH v2 3/3] s390/uvdevice: autoload module based on CPU facility Steffen Eiden
2022-07-14 10:53 ` [PATCH v2 0/3] s390/cpufeature: rework to allow different types of cpufeatures Heiko Carstens
2022-07-15  7:49 ` Hendrik Brueckner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).