summarylogtreecommitdiffstats
path: root/vmmon.patch
blob: 167c16fdcfdd9f6939b4c4ca4b5ad80b18e7dd67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--- a/vmmon/Makefile
+++ b/vmmon/Makefile
@@ -43,7 +43,11 @@ INCLUDE      += -I$(SRCROOT)/shared
 endif
 
 
+ifdef KVERSION
+VM_UNAME = $(KVERSION)
+else
 VM_UNAME = $(shell uname -r)
+endif
 
 # Header directory for the running kernel
 ifdef LINUXINCLUDE
From 9a6a17fe0bc6d1ab9e0e0dfa8d587b12a21cd49e Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Sun, 17 Oct 2021 17:06:26 +0200
Subject: [PATCH] modules: include <linux/stdarg.h> when available

Workstation/Player code changes between 16.1.2 and 16.2.0 added some
includes of <stdarg.h> which is interpreted as regular (userspace) header
file in /usr/include. Shortly before that, mainline commit c0891ac15f04
("isystem: ship and use stdarg.h") added minimalistic kernel version of
stdarg.h to avoid including userspace headers from kernel code. As the
kernel version is sometimes included via other header files, build against
5.15 kernel results in a lot of warnings (about redefined va_* macros).

Include <stdarg.h> when building against kernel < 5.15 and <linux/stdarg.h>
when building against kernel >= 5.15.
---
 vmmon-only/include/vm_assert.h | 4 ++++
 vmnet-only/vm_assert.h         | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/vmmon-only/include/vm_assert.h b/vmmon-only/include/vm_assert.h
index 4a69dcc..2817a08 100644
--- a/vmmon-only/include/vm_assert.h
+++ b/vmmon-only/include/vm_assert.h
@@ -40,7 +40,11 @@
 
 // XXX not necessary except some places include vm_assert.h improperly
 #include "vm_basic_types.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
 #include <stdarg.h>
+#else
+#include <linux/stdarg.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {
From 4232f780eb114f22498f3274eaeef81d8c63f2ab Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Tue, 9 Nov 2021 09:01:57 +0100
Subject: [PATCH] modules: fix stddef.h include

After mainline commit 04e85bbf71c9 ("isystem: delete global -isystem
compile option") in 5.16-rc1, vm_basic_types.h in both vmmon and vmnet
does not find (userspace) stddef.h any more. As it should not include this
header anyway, fix the include directives to include stddef.h from kernel.

Kernel version of stddef.h has been available since the beginning of git so
that it is safe to include it regardless of kernel version.
---
 vmmon-only/include/vm_basic_defs.h | 2 +-
 vmnet-only/vm_basic_defs.h         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/vmmon-only/include/vm_basic_defs.h b/vmmon-only/include/vm_basic_defs.h
index 0ec30b3..b920e2d 100644
--- a/vmmon-only/include/vm_basic_defs.h
+++ b/vmmon-only/include/vm_basic_defs.h
@@ -51,7 +51,7 @@
  *   C90 7.17, C99 7.19, C11 7.19
  */
 #if !defined(VMKERNEL)
-#  include <stddef.h>
+#  include <linux/stddef.h>
 #else
    /*
     * Vmkernel's bogus __FreeBSD__ value causes gcc <stddef.h> to break.
From 16d490ae022d7fc4ca867971e20e2dcd59e6ca5a Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Mon, 4 Apr 2022 01:57:28 +0200
Subject: [PATCH] vmmon: do not rely on HAVE_GET_KERNEL_NOFAULT

Mainline commit 34737e269803 ("uaccess: add generic
__{get,put}_kernel_nofault") in 5.18-rc1 removes HAVE_GET_KERNEL_NOFAULT
macro as all architectures can use get_kernel_nofault() now. Check for
existence of __get_kernel_nofault() instead and add also a version check in
case it stops being a macro or is removed in the future.
---
 vmmon-only/linux/hostif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c
index a21c300..b6326e9 100644
--- a/vmmon-only/linux/hostif.c
+++ b/vmmon-only/linux/hostif.c
@@ -2356,7 +2356,8 @@ isVAReadable(VA r)  // IN:
    int ret;
 
    r = APICR_TO_ADDR(r, APICR_VERSION);
-#ifdef HAVE_GET_KERNEL_NOFAULT
+#if defined(HAVE_GET_KERNEL_NOFAULT) || defined(__get_kernel_nofault) || \
+    (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
    ret = get_kernel_nofault(dummy, (void *)r);
 #else
    {