]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.97/s390-early-improve-machine-detection.patch
Linux 4.9.154
[thirdparty/kernel/stable-queue.git] / releases / 4.14.97 / s390-early-improve-machine-detection.patch
1 From 03aa047ef2db4985e444af6ee1c1dd084ad9fb4c Mon Sep 17 00:00:00 2001
2 From: Christian Borntraeger <borntraeger@de.ibm.com>
3 Date: Fri, 9 Nov 2018 09:21:47 +0100
4 Subject: s390/early: improve machine detection
5
6 From: Christian Borntraeger <borntraeger@de.ibm.com>
7
8 commit 03aa047ef2db4985e444af6ee1c1dd084ad9fb4c upstream.
9
10 Right now the early machine detection code check stsi 3.2.2 for "KVM"
11 and set MACHINE_IS_VM if this is different. As the console detection
12 uses diagnose 8 if MACHINE_IS_VM returns true this will crash Linux
13 early for any non z/VM system that sets a different value than KVM.
14 So instead of assuming z/VM, do not set any of MACHINE_IS_LPAR,
15 MACHINE_IS_VM, or MACHINE_IS_KVM.
16
17 CC: stable@vger.kernel.org
18 Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
19 Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
20 Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 arch/s390/kernel/early.c | 4 ++--
25 arch/s390/kernel/setup.c | 2 ++
26 2 files changed, 4 insertions(+), 2 deletions(-)
27
28 --- a/arch/s390/kernel/early.c
29 +++ b/arch/s390/kernel/early.c
30 @@ -226,10 +226,10 @@ static noinline __init void detect_machi
31 if (stsi(vmms, 3, 2, 2) || !vmms->count)
32 return;
33
34 - /* Running under KVM? If not we assume z/VM */
35 + /* Detect known hypervisors */
36 if (!memcmp(vmms->vm[0].cpi, "\xd2\xe5\xd4", 3))
37 S390_lowcore.machine_flags |= MACHINE_FLAG_KVM;
38 - else
39 + else if (!memcmp(vmms->vm[0].cpi, "\xa9\x61\xe5\xd4", 4))
40 S390_lowcore.machine_flags |= MACHINE_FLAG_VM;
41 }
42
43 --- a/arch/s390/kernel/setup.c
44 +++ b/arch/s390/kernel/setup.c
45 @@ -884,6 +884,8 @@ void __init setup_arch(char **cmdline_p)
46 pr_info("Linux is running under KVM in 64-bit mode\n");
47 else if (MACHINE_IS_LPAR)
48 pr_info("Linux is running natively in 64-bit mode\n");
49 + else
50 + pr_info("Linux is running as a guest in 64-bit mode\n");
51
52 /* Have one command line that is parsed and saved in /proc/cmdline */
53 /* boot_command_line has been already set up in early.c */