]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0161-x86-paravirt-Provide-a-way-to-check-for-hypervisors.patch
revert buggy SCSI error handler commit
[pve-kernel.git] / patches / kernel / 0161-x86-paravirt-Provide-a-way-to-check-for-hypervisors.patch
CommitLineData
321d628a
FG
1From 75ea12fecab1f4af63b39227509bf706b3faf21d Mon Sep 17 00:00:00 2001
2From: Thomas Gleixner <tglx@linutronix.de>
3Date: Mon, 4 Dec 2017 15:07:31 +0100
633c5ed1 4Subject: [PATCH 161/242] x86/paravirt: Provide a way to check for hypervisors
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11There is no generic way to test whether a kernel is running on a specific
12hypervisor. But that's required to prevent the upcoming user address space
13separation feature in certain guest modes.
14
15Make the hypervisor type enum unconditionally available and provide a
16helper function which allows to test for a specific type.
17
18Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
19Reviewed-by: Juergen Gross <jgross@suse.com>
20Cc: Andy Lutomirski <luto@kernel.org>
21Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
22Cc: Borislav Petkov <bp@alien8.de>
23Cc: Borislav Petkov <bpetkov@suse.de>
24Cc: Brian Gerst <brgerst@gmail.com>
25Cc: Dave Hansen <dave.hansen@intel.com>
26Cc: Dave Hansen <dave.hansen@linux.intel.com>
27Cc: David Laight <David.Laight@aculab.com>
28Cc: Denys Vlasenko <dvlasenk@redhat.com>
29Cc: Eduardo Valentin <eduval@amazon.com>
30Cc: Greg KH <gregkh@linuxfoundation.org>
31Cc: H. Peter Anvin <hpa@zytor.com>
32Cc: Josh Poimboeuf <jpoimboe@redhat.com>
33Cc: Linus Torvalds <torvalds@linux-foundation.org>
34Cc: Peter Zijlstra <peterz@infradead.org>
35Cc: Rik van Riel <riel@redhat.com>
36Cc: Will Deacon <will.deacon@arm.com>
37Cc: aliguori@amazon.com
38Cc: daniel.gruss@iaik.tugraz.at
39Cc: hughd@google.com
40Cc: keescook@google.com
41Link: https://lkml.kernel.org/r/20171204150606.912938129@linutronix.de
42Signed-off-by: Ingo Molnar <mingo@kernel.org>
43(cherry picked from commit 79cc74155218316b9a5d28577c7077b2adba8e58)
44Signed-off-by: Andy Whitcroft <apw@canonical.com>
45Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
46(cherry picked from commit 9f637574068f1ffdaded1cd1f408917582594b36)
47Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
48---
49 arch/x86/include/asm/hypervisor.h | 25 +++++++++++++++----------
50 1 file changed, 15 insertions(+), 10 deletions(-)
51
52diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
53index 1b0a5abcd8ae..96aa6b9884dc 100644
54--- a/arch/x86/include/asm/hypervisor.h
55+++ b/arch/x86/include/asm/hypervisor.h
56@@ -20,16 +20,7 @@
57 #ifndef _ASM_X86_HYPERVISOR_H
58 #define _ASM_X86_HYPERVISOR_H
59
60-#ifdef CONFIG_HYPERVISOR_GUEST
61-
62-#include <asm/kvm_para.h>
63-#include <asm/x86_init.h>
64-#include <asm/xen/hypervisor.h>
65-
66-/*
67- * x86 hypervisor information
68- */
69-
70+/* x86 hypervisor types */
71 enum x86_hypervisor_type {
72 X86_HYPER_NATIVE = 0,
73 X86_HYPER_VMWARE,
74@@ -39,6 +30,12 @@ enum x86_hypervisor_type {
75 X86_HYPER_KVM,
76 };
77
78+#ifdef CONFIG_HYPERVISOR_GUEST
79+
80+#include <asm/kvm_para.h>
81+#include <asm/x86_init.h>
82+#include <asm/xen/hypervisor.h>
83+
84 struct hypervisor_x86 {
85 /* Hypervisor name */
86 const char *name;
87@@ -58,7 +55,15 @@ struct hypervisor_x86 {
88
89 extern enum x86_hypervisor_type x86_hyper_type;
90 extern void init_hypervisor_platform(void);
91+static inline bool hypervisor_is_type(enum x86_hypervisor_type type)
92+{
93+ return x86_hyper_type == type;
94+}
95 #else
96 static inline void init_hypervisor_platform(void) { }
97+static inline bool hypervisor_is_type(enum x86_hypervisor_type type)
98+{
99+ return type == X86_HYPER_NATIVE;
100+}
101 #endif /* CONFIG_HYPERVISOR_GUEST */
102 #endif /* _ASM_X86_HYPERVISOR_H */
103--
1042.14.2
105