linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] s390: Autoload uvdevice module based on CPU feature
@ 2022-06-29 15:37 Steffen Eiden
  2022-06-29 17:14 ` Heiko Carstens
  0 siblings, 1 reply; 2+ messages in thread
From: Steffen Eiden @ 2022-06-29 15:37 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev, Christian Borntraeger,
	Janosch Frank, Claudio Imbrenda, Vasily Gorbik, linux-s390,
	linux-kernel, linux-mm
  Cc: nrb

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(-)

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");
-- 
2.35.3



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

* Re: [RFC PATCH] s390: Autoload uvdevice module based on CPU feature
  2022-06-29 15:37 [RFC PATCH] s390: Autoload uvdevice module based on CPU feature Steffen Eiden
@ 2022-06-29 17:14 ` Heiko Carstens
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Carstens @ 2022-06-29 17:14 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, 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.


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

end of thread, other threads:[~2022-06-29 17:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 15:37 [RFC PATCH] s390: Autoload uvdevice module based on CPU feature Steffen Eiden
2022-06-29 17:14 ` Heiko Carstens

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).