s390: Autoload uvdevice module based on CPU feature
Subsystems (4)
cover s390: Autoload uvdevice module based on CPU feature
Currently, the uvdevice (drivers/s390/char/uvdevice) must be loaded manually. We can, however, determine if the Ultravisor is available by observing facility 158.
This series, first, introduces the HWCAP_UV connected to facility 158. And, second, it automatically loads the uvdevice if HWCAP_UV is present.
Steffen Eiden (2):
s390/hwcaps: Add HWCAP_UV
drivers/s390/char/uvdevice: Autoload module based on CPU feature
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(-)
Signature · 1 line
2.35.3
PATCH 1/2 s390/hwcaps: Add HWCAP_UV
This patch adds a hardware capability for the Ultravisor. This capability will be present if facility 158 is enabled.
--- arch/s390/include/asm/elf.h | 2 ++ arch/s390/kernel/processor.c | 5 +++++ 2 files changed, 7 insertions(+)
arch/s390/include/asm/elf.h +2 -0
@@ -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
@@ -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 ; +/* ultravisor-call (secure execution) */ +if (test_facility (158 )) + elf_hwcap |=HWCAP_UV ; +return 0 ; }arch_initcall (setup_hwcaps);
Signature · 1 line
2.35.3
Christian Borntraeger
maintainerRe: [PATCH 1/2] s390/hwcaps: Add HWCAP_UV
Am 01.07.22 um 12:02 schrieb Steffen Eiden:
Quoted 14 lines
This patch adds a hardware capability for the Ultravisor. This capability will be present if facility 158 is enabled.
Signed-off-by Steffen Eiden <[email protected]>--- arch/s390/include/asm/elf.h | 2 ++ arch/s390/kernel/processor.c | 5 +++++ 2 files changed, 7 insertions(+)arch/s390/include/asm/elf.h +0
-0
arch/s390/include/asm/elf.h enum { · line 120
Quoted 6 lines
arch/s390/include/asm/elf.h +1
-0@@ -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 };
question for Heiko, Vasily, Alexander. This certainly works.
An alternative implementation would be to separate module_cpu_feature_match from HWCAP. (so uv would not be shown in /proc/cpuinfo and it would be seen in the aux vector). I would imagine that we might have more drivers in the future that depend on a facility but this facility is not really useful for userspace to know.
See arch/s390/include/asm/cpufeature.h
* 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.
Any preference from your side?
Quoted 32 lines
arch/s390/include/asm/elf.h +1
-0@@ -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@@ -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 ; +/* ultravisor-call (secure execution) */ +if (test_facility (158 )) + elf_hwcap |=HWCAP_UV ; +return 0 ; }arch_initcall (setup_hwcaps);
Heiko Carstens
maintainerRe: [PATCH 1/2] s390/hwcaps: Add HWCAP_UV
Quoted 29 lines · Christian Borntraeger
Am 01.07.22 um 12:02 schrieb Steffen Eiden:
Quoted 14 lines
This patch adds a hardware capability for the Ultravisor. This capability will be present if facility 158 is enabled.
Signed-off-by Steffen Eiden <[email protected]>--- arch/s390/include/asm/elf.h | 2 ++ arch/s390/kernel/processor.c | 5 +++++ 2 files changed, 7 insertions(+)arch/s390/include/asm/elf.h +0
-0arch/s390/include/asm/elf.h enum { · line 120
Quoted 6 lines
arch/s390/include/asm/elf.h +1
-0@@ -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 };question for Heiko, Vasily, Alexander. This certainly works.
An alternative implementation would be to separatemodule_cpu_feature_matchfrom HWCAP. (so uv would not be shown in/proc/cpuinfoand it would be seen in the aux vector). I would imagine that we might have more drivers in the future that depend on a facility but this facility is not really useful for userspace to know.
Quoted 6 lines
See
arch/s390/include/asm/cpufeature.h
* 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.Any preference from your side?
I mentioned already before this RFC that my preferred solution would be to have a solution which extends the existing method to work (also) with facility bits - haven't checked if all existing users could be converted to facility bits, but making it more flexible would work certainly.
If Steffen is willing to do that, that would be very welcome. Otherwise I'll put that on my todo list.
Re: [PATCH 1/2] s390/hwcaps: Add HWCAP_UV
Quoted 1 line · Heiko Carstens
On Fri, Jul 01, 2022 at 12:10:18PM +0200, Christian Borntraeger wrote:
[ snip ]
Quoted 10 lines
Quoted 1 line
Any preference from your side?
I mentioned already before this RFC that my preferred solution would be to have a solution which extends the existing method to work (also) with facility bits - haven't checked if all existing users could be converted to facility bits, but making it more flexible would work certainly.
If Steffen is willing to do that, that would be very welcome. Otherwise I'll put that on my todo list.
I'll have a look on that.
PATCH 2/2 drivers/s390/char/uvdevice: Autoload module based on CPU feature
In reply to Steffen EidenWith this patch the uvdevice will be automatically loaded when the HWCAP_UV bit is set.
--- drivers/s390/char/uvdevice.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/s390/char/uvdevice.c +2 -3
@@ -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