diff mbox series

[RFC] s390: Autoload uvdevice module based on CPU feature

Message ID 20220629153741.195789-1-seiden@linux.ibm.com (mailing list archive)
State New
Headers show
Series [RFC] s390: Autoload uvdevice module based on CPU feature | expand

Commit Message

Steffen Eiden June 29, 2022, 3:37 p.m. UTC
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.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
---
 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(-)

Comments

Heiko Carstens June 29, 2022, 5:14 p.m. UTC | #1
On Wed, Jun 29, 2022 at 05:37:41PM +0200, Steffen Eiden wrote:
> 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.
> 
> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
> ---
>  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.

> +	/* 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.
diff mbox series

Patch

diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index 70a30ae258b7..3a5e89ce4fd0 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -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.
diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
index aa0e0e7fc773..3ca528cb3819 100644
--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -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);
diff --git a/drivers/s390/char/uvdevice.c b/drivers/s390/char/uvdevice.c
index 66505d7166a6..fddbfc1e27a2 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(UV, uvio_dev_init);
 module_exit(uvio_dev_exit);
 
 MODULE_AUTHOR("IBM Corporation");