]>
Commit | Line | Data |
---|---|---|
59d5af67 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
321d628a FG |
2 | From: Thomas Gleixner <tglx@linutronix.de> |
3 | Date: Mon, 4 Dec 2017 15:07:31 +0100 | |
59d5af67 | 4 | Subject: [PATCH] x86/paravirt: Provide a way to check for hypervisors |
321d628a FG |
5 | MIME-Version: 1.0 |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | CVE-2017-5754 | |
10 | ||
11 | There is no generic way to test whether a kernel is running on a specific | |
12 | hypervisor. But that's required to prevent the upcoming user address space | |
13 | separation feature in certain guest modes. | |
14 | ||
15 | Make the hypervisor type enum unconditionally available and provide a | |
16 | helper function which allows to test for a specific type. | |
17 | ||
18 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> | |
19 | Reviewed-by: Juergen Gross <jgross@suse.com> | |
20 | Cc: Andy Lutomirski <luto@kernel.org> | |
21 | Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> | |
22 | Cc: Borislav Petkov <bp@alien8.de> | |
23 | Cc: Borislav Petkov <bpetkov@suse.de> | |
24 | Cc: Brian Gerst <brgerst@gmail.com> | |
25 | Cc: Dave Hansen <dave.hansen@intel.com> | |
26 | Cc: Dave Hansen <dave.hansen@linux.intel.com> | |
27 | Cc: David Laight <David.Laight@aculab.com> | |
28 | Cc: Denys Vlasenko <dvlasenk@redhat.com> | |
29 | Cc: Eduardo Valentin <eduval@amazon.com> | |
30 | Cc: Greg KH <gregkh@linuxfoundation.org> | |
31 | Cc: H. Peter Anvin <hpa@zytor.com> | |
32 | Cc: Josh Poimboeuf <jpoimboe@redhat.com> | |
33 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
34 | Cc: Peter Zijlstra <peterz@infradead.org> | |
35 | Cc: Rik van Riel <riel@redhat.com> | |
36 | Cc: Will Deacon <will.deacon@arm.com> | |
37 | Cc: aliguori@amazon.com | |
38 | Cc: daniel.gruss@iaik.tugraz.at | |
39 | Cc: hughd@google.com | |
40 | Cc: keescook@google.com | |
41 | Link: https://lkml.kernel.org/r/20171204150606.912938129@linutronix.de | |
42 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
43 | (cherry picked from commit 79cc74155218316b9a5d28577c7077b2adba8e58) | |
44 | Signed-off-by: Andy Whitcroft <apw@canonical.com> | |
45 | Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com> | |
46 | (cherry picked from commit 9f637574068f1ffdaded1cd1f408917582594b36) | |
47 | Signed-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 | ||
52 | diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h | |
53 | index 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 | -- | |
104 | 2.14.2 | |
105 |