diff options
| author | Heiko Carstens <hca@linux.ibm.com> | 2025-02-07 15:49:07 +0100 |
|---|---|---|
| committer | Vasily Gorbik <gor@linux.ibm.com> | 2025-03-04 17:18:07 +0100 |
| commit | 52109a067aaa96474a5b0f12aee60d73cf5f92e1 (patch) | |
| tree | 69786a1518c0339f110934f05f7b034b05ba8b4c /arch/s390/boot | |
| parent | 91d6e44221e871c6a2b6c4a67f52b62b36c441a3 (diff) | |
s390: Convert MACHINE_IS_[LPAR|VM|KVM], etc, machine_is_[lpar|vm|kvm]()
Move machine type detection to the decompressor and use static branches
to implement and use machine_is_[lpar|vm|kvm]() instead of a runtime check
via MACHINE_IS_[LPAR|VM|KVM].
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch/s390/boot')
| -rw-r--r-- | arch/s390/boot/startup.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c index 41dda285ee2c..9c4b2b317af2 100644 --- a/arch/s390/boot/startup.c +++ b/arch/s390/boot/startup.c @@ -8,6 +8,7 @@ #include <asm/sections.h> #include <asm/maccess.h> #include <asm/machine.h> +#include <asm/sysinfo.h> #include <asm/cpu_mf.h> #include <asm/setup.h> #include <asm/timex.h> @@ -49,6 +50,27 @@ void error(char *x) disabled_wait(); } +static char sysinfo_page[PAGE_SIZE] __aligned(PAGE_SIZE); + +static void detect_machine_type(void) +{ + struct sysinfo_3_2_2 *vmms = (struct sysinfo_3_2_2 *)&sysinfo_page; + + /* Check current-configuration-level */ + if (stsi(NULL, 0, 0, 0) <= 2) { + set_machine_feature(MFEATURE_LPAR); + return; + } + /* Get virtual-machine cpu information. */ + if (stsi(vmms, 3, 2, 2) || !vmms->count) + return; + /* Detect known hypervisors */ + if (!memcmp(vmms->vm[0].cpi, "\xd2\xe5\xd4", 3)) + set_machine_feature(MFEATURE_KVM); + else if (!memcmp(vmms->vm[0].cpi, "\xa9\x61\xe5\xd4", 4)) + set_machine_feature(MFEATURE_VM); +} + static void detect_diag9c(void) { unsigned long reg1, reg2; @@ -520,6 +542,7 @@ void startup_kernel(void) sclp_early_detect_machine_features(); detect_facilities(); detect_diag9c(); + detect_machine_type(); cmma_init(); sanitize_prot_virt_host(); max_physmem_end = detect_max_physmem_end(); |
