Skip to contentSkip to conversation

s390: Autoload uvdevice module based on CPU feature

RFC PATCH In review Steffen Eiden 2 participants 2 messages Jun 29, 2022

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

RFC PATCH 1/1 s390: Autoload uvdevice module based on CPU feature

With this patch the uvdevice will be automatically loaded when the facility 158 is present. This is accomplished by using ``module_cpu_feature_match`` and adding HWCAP_UV connected to to facility 158.

---
 arch/s390/include/asm/elf.h  | 2 ++
 arch/s390/kernel/processor.c | 5 +++++
 drivers/s390/char/uvdevice.c | 5 ++---
 3 files changed, 9 insertions(+), 3 deletions(-)
arch/s390/include/asm/elf.h +2 -0
index 70a30ae258b7..3a5e89ce4fd0 100644
@@ -115,6 +115,7 @@ enum {
 	HWCAP_NR_NNPA		= 20,
 	HWCAP_NR_PCI_MIO	= 21,
 	HWCAP_NR_SIE		= 22,
+	HWCAP_NR_UV		= 23,
 	HWCAP_NR_MAX
 };
 
@@ -142,6 +143,7 @@ enum {
 #define HWCAP_NNPA		BIT(HWCAP_NR_NNPA)
 #define HWCAP_PCI_MIO		BIT(HWCAP_NR_PCI_MIO)
 #define HWCAP_SIE		BIT(HWCAP_NR_SIE)
+#define HWCAP_UV		BIT(HWCAP_NR_UV)
 
 /*
  * These are used to set parameters in the core dumps.
arch/s390/kernel/processor.c +5 -0
index aa0e0e7fc773..3ca528cb3819 100644
@@ -141,6 +141,7 @@ static void show_cpu_summary(struct seq_file *m, void *v)
 		[HWCAP_NR_NNPA]		= "nnpa",
 		[HWCAP_NR_PCI_MIO]	= "pcimio",
 		[HWCAP_NR_SIE]		= "sie",
+		[HWCAP_NR_UV]		= "uv",
 	};
 	int i, cpu;
 
@@ -249,6 +250,10 @@ static int __init setup_hwcaps(void)
 	if (sclp.has_sief2)
 		elf_hwcap |= HWCAP_SIE;
 
+	/* IBM Secure Execution (Ultravisor) support */
+	if (test_facility(158)) {
+		elf_hwcap |= HWCAP_UV;
+
 	return 0;
 }
 arch_initcall(setup_hwcaps);
drivers/s390/char/uvdevice.c +2 -3
index 66505d7166a6..fddbfc1e27a2 100644
@@ -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(UV, uvio_dev_init);
 module_exit(uvio_dev_exit);
 
 MODULE_AUTHOR("IBM Corporation");
Signature · 1 line
2.35.3
maintainer
#1 lore raw
Quoted 11 lines · Steffen Eiden

With this patch the uvdevice will be automatically loaded when the facility 158 is present. This is accomplished by using ``module_cpu_feature_match`` and adding HWCAP_UV connected to to facility 158.

---
 arch/s390/include/asm/elf.h  | 2 ++
 arch/s390/kernel/processor.c | 5 +++++
 drivers/s390/char/uvdevice.c | 5 ++---
 3 files changed, 9 insertions(+), 3 deletions(-)

Please split this into two patches: one which adds the hwcap bit, and one which makes use of it.

Also please make sure the subject contains (nearly) always a component, which would be "s390/hwcaps: ..." in this case.

arch/s390/kernel/processor.c static int __init setup_hwcaps(void) · line 255

Quoted 3 lines
arch/s390/kernel/processor.c +3 -0
+	/* IBM Secure Execution (Ultravisor) support */
+	if (test_facility(158)) {
+		elf_hwcap |= HWCAP_UV;

Just keep the comment short like all other one and take the PoP as reference. I would have expected something like:
"ultravisor-call (secure execution)"

Besides that, everything looks ok as far as I can tell.