Guest User

vmmon-15.0.3-5.0.patch

a guest
Mar 23rd, 2019
420
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -urN a/vmmon-only/Makefile b/vmmon-only/Makefile
  2. --- a/vmmon-only/Makefile 2019-03-23 13:07:32.073918051 +0100
  3. +++ b/vmmon-only/Makefile 2019-03-23 13:33:52.738577571 +0100
  4. @@ -107,7 +107,7 @@
  5. postbuild:: ;
  6.  
  7. $(DRIVER_KO): prebuild
  8. - $(MAKE) -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) \
  9. + $(MAKE) -C $(BUILD_DIR) M=$$PWD SRCROOT=$$PWD/$(SRCROOT) \
  10. MODULEBUILDDIR=$(MODULEBUILDDIR) modules
  11. $(MAKE) -C $$PWD SRCROOT=$$PWD/$(SRCROOT) \
  12. MODULEBUILDDIR=$(MODULEBUILDDIR) postbuild
  13. diff -urN a/vmmon-only/Makefile.kernel b/vmmon-only/Makefile.kernel
  14. --- a/vmmon-only/Makefile.kernel 2019-03-23 13:07:32.073918051 +0100
  15. +++ b/vmmon-only/Makefile.kernel 2019-03-23 13:33:52.738577571 +0100
  16. @@ -31,7 +31,7 @@
  17. $(SRCROOT)/bootstrap/*.c)))
  18.  
  19. clean:
  20. - rm -rf $(wildcard $(DRIVER).mod.c $(DRIVER).ko .tmp_versions \
  21. + rm -rf $(wildcard $(DRIVER).mod.c $(DRIVER).ko .tmp_versions .cache.mk \
  22. Module.symvers Modules.symvers Module.markers modules.order \
  23. $(foreach dir,linux/ common/ vmcore/ bootstrap/ \
  24. ./,$(addprefix $(dir),.*.cmd .*.o.flags *.o)))
  25. diff -urN a/vmmon-only/common/task.c b/vmmon-only/common/task.c
  26. --- a/vmmon-only/common/task.c 2019-03-23 13:07:32.077251366 +0100
  27. +++ b/vmmon-only/common/task.c 2019-03-23 13:33:52.741910887 +0100
  28. @@ -2322,12 +2322,23 @@
  29. {
  30. uint64 raxGetsWiped, rcxGetsWiped;
  31.  
  32. +#ifdef CALL_NOSPEC
  33. + __asm__ __volatile__(CALL_NOSPEC
  34. + : "=a" (raxGetsWiped),
  35. + "=c" (rcxGetsWiped)
  36. + : "0" (codePtr),
  37. + "1" (crosspage),
  38. + THUNK_TARGET(codePtr)
  39. + : "rdx", "r8", "r9", "r10", "r11", "cc", "memory");
  40. +#else
  41. __asm__ __volatile__("call *%%rax"
  42. : "=a" (raxGetsWiped),
  43. "=c" (rcxGetsWiped)
  44. : "0" (codePtr),
  45. "1" (crosspage)
  46. : "rdx", "r8", "r9", "r10", "r11", "cc", "memory");
  47. +#endif
  48. +
  49. }
  50. #elif defined(_MSC_VER)
  51. /*
  52. diff -urN a/vmmon-only/include/compat_poll.h b/vmmon-only/include/compat_poll.h
  53. --- a/vmmon-only/include/compat_poll.h 1970-01-01 01:00:00.000000000 +0100
  54. +++ b/vmmon-only/include/compat_poll.h 2019-03-23 13:33:52.745244202 +0100
  55. @@ -0,0 +1,30 @@
  56. +#ifndef __COMPAT_POLL_H__
  57. +#define __COMPAT_POLL_H__
  58. +
  59. +#include <linux/poll.h>
  60. +
  61. +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
  62. +
  63. +#ifndef __poll_t
  64. +typedef unsigned int __poll_t;
  65. +#endif
  66. +
  67. +static inline __poll_t compat_vfs_poll(struct file *file,
  68. + struct poll_table_struct *pt)
  69. +{
  70. + if (unlikely(!file->f_op->poll))
  71. + return DEFAULT_POLLMASK;
  72. + return file->f_op->poll(file, pt);
  73. +}
  74. +
  75. +#else
  76. +
  77. +static inline __poll_t compat_vfs_poll(struct file *file,
  78. + struct poll_table_struct *pt)
  79. +{
  80. + return vfs_poll(file, pt);
  81. +}
  82. +
  83. +#endif
  84. +
  85. +#endif /* __COMPAT_POLL_H__ */
  86. diff -urN a/vmmon-only/include/vm_assert.h b/vmmon-only/include/vm_assert.h
  87. --- a/vmmon-only/include/vm_assert.h 2019-03-23 13:07:32.077251366 +0100
  88. +++ b/vmmon-only/include/vm_assert.h 2019-03-23 13:33:52.741910887 +0100
  89. @@ -67,6 +67,7 @@
  90. #if defined (VMKPANIC)
  91. #include "vmk_assert.h"
  92. #else /* !VMKPANIC */
  93. +#include <linux/kernel.h>
  94. #define _ASSERT_PANIC(name) \
  95. Panic(_##name##Fmt "\n", __FILE__, __LINE__)
  96. #define _ASSERT_PANIC_BUG(bug, name) \
  97. @@ -107,7 +108,7 @@
  98. } while(0)
  99.  
  100. #else
  101. -NORETURN void Panic(const char *fmt, ...) PRINTF_DECL(1, 2);
  102. +#define Panic panic
  103. #endif
  104.  
  105. void LogThrottled(uint32 *count, const char *fmt, ...) PRINTF_DECL(2, 3);
  106. diff -urN a/vmmon-only/include/x86_basic_defs.h b/vmmon-only/include/x86_basic_defs.h
  107. --- a/vmmon-only/include/x86_basic_defs.h 2019-03-23 13:07:32.080584681 +0100
  108. +++ b/vmmon-only/include/x86_basic_defs.h 2019-03-23 13:33:52.745244202 +0100
  109. @@ -35,6 +35,8 @@
  110. #define INCLUDE_ALLOW_VMCORE
  111. #include "includeCheck.h"
  112.  
  113. +#include <asm/processor-flags.h>
  114. +
  115. #define X86_MAX_INSTR_LEN 15 /* Max byte length of an x86 instruction. */
  116.  
  117. #define NUM_IDT_VECTORS 256
  118. @@ -75,7 +77,9 @@
  119. #define CR3_PDB_MASK 0xfffff000
  120. #define CR3_IGNORE 0xFFF
  121. #define PAE_CR3_IGNORE 0x1F
  122. +#ifndef CR3_PCID_MASK
  123. #define CR3_PCID_MASK 0xFFF
  124. +#endif
  125. #define CR3_NO_FLUSH (1ULL << 63)
  126.  
  127. #define CR4_VME 0x00000001
  128. diff -urN a/vmmon-only/include/x86msr.h b/vmmon-only/include/x86msr.h
  129. --- a/vmmon-only/include/x86msr.h 2019-03-23 13:07:32.077251366 +0100
  130. +++ b/vmmon-only/include/x86msr.h 2019-03-23 13:33:52.741910887 +0100
  131. @@ -24,6 +24,7 @@
  132.  
  133. #ifndef _X86MSR_H_
  134. #define _X86MSR_H_
  135. +#include <asm/msr-index.h>
  136. #define INCLUDE_ALLOW_USERLEVEL
  137. #define INCLUDE_ALLOW_VMX
  138.  
  139. @@ -127,7 +128,9 @@
  140.  
  141. #define MSR_PRED_CMD_IBPB (1UL << 0)
  142.  
  143. +#ifndef MSR_MISC_FEATURES_ENABLES
  144. #define MSR_MISC_FEATURES_ENABLES 0x140
  145. +#endif
  146.  
  147. /* Intel Core Architecture and later: use only architected counters. */
  148. #define IA32_MSR_PERF_CAPABILITIES 0x345
  149. @@ -463,7 +466,9 @@
  150. #define MSR_K7_HWCR_SSEDIS 0x00008000ULL // Disable SSE bit
  151. #define MSR_K7_HWCR_MONMWAITUSEREN 0x00000400ULL // Enable MONITOR/MWAIT CPL>0
  152. #define MSR_K7_HWCR_TLBFFDIS 0x00000040ULL // Disable TLB Flush Filter
  153. +#ifndef MSR_K7_HWCR_SMMLOCK
  154. #define MSR_K7_HWCR_SMMLOCK 0x00000001ULL // Lock SMM environment
  155. +#endif
  156.  
  157. #ifndef MSR_K8_SYSCFG
  158. #define MSR_K8_SYSCFG 0xc0010010
  159. @@ -652,8 +657,11 @@
  160. /*
  161. * MISC_FEATURES_ENABLES bits
  162. */
  163. +#ifdef MSR_MISC_FEATURES_ENABLES_CPUID_FAULT
  164. +#define MSR_MISC_FEATURES_ENABLES_CPUID_FAULTING MSR_MISC_FEATURES_ENABLES_CPUID_FAULT
  165. +#else
  166. #define MSR_MISC_FEATURES_ENABLES_CPUID_FAULTING 1
  167. -
  168. +#endif
  169.  
  170.  
  171.  
  172. diff -urN a/vmmon-only/linux/driver.c b/vmmon-only/linux/driver.c
  173. --- a/vmmon-only/linux/driver.c 2019-03-23 13:07:32.080584681 +0100
  174. +++ b/vmmon-only/linux/driver.c 2019-03-23 13:33:52.748577517 +0100
  175. @@ -982,7 +982,7 @@
  176. *-----------------------------------------------------------------------------
  177. */
  178.  
  179. -__attribute__((always_inline)) static Bool
  180. +__always_inline static Bool
  181. LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min
  182. {
  183. TSCDelta tscDelta;
  184. diff -urN a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c
  185. --- a/vmmon-only/linux/hostif.c 2019-03-23 13:07:32.080584681 +0100
  186. +++ b/vmmon-only/linux/hostif.c 2019-03-23 13:33:52.745244202 +0100
  187. @@ -74,6 +74,7 @@
  188.  
  189. #include "pgtbl.h"
  190. #include "versioned_atomic.h"
  191. +#include "compat_poll.h"
  192.  
  193. #if !defined(CONFIG_HIGH_RES_TIMERS)
  194. #error CONFIG_HIGH_RES_TIMERS required for acceptable performance
  195. @@ -182,6 +183,32 @@
  196. uint8 monitorIPIVector;
  197. uint8 hvIPIVector;
  198.  
  199. +static unsigned long compat_totalram_pages(void)
  200. +{
  201. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
  202. + return totalram_pages;
  203. +#else
  204. + return totalram_pages();
  205. +#endif
  206. +}
  207. +
  208. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
  209. +static void do_gettimeofday(struct timeval *tv)
  210. +{
  211. + struct timespec64 now;
  212. +
  213. + ktime_get_real_ts64(&now);
  214. + tv->tv_sec = now.tv_sec;
  215. + tv->tv_usec = now.tv_nsec / 1000;
  216. +}
  217. +#endif
  218. +
  219. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) && defined(VERIFY_WRITE)
  220. + #define write_access_ok(addr, size) access_ok(VERIFY_WRITE, addr, size)
  221. +#else
  222. + #define write_access_ok(addr, size) access_ok(addr, size)
  223. +#endif
  224. +
  225. /*
  226. *-----------------------------------------------------------------------------
  227. *
  228. @@ -1633,14 +1660,7 @@
  229. HostIF_EstimateLockedPageLimit(const VMDriver* vm, // IN
  230. unsigned int currentlyLockedPages) // IN
  231. {
  232. - /*
  233. - * This variable is available and exported to modules,
  234. - * since at least 2.6.0.
  235. - */
  236. -
  237. - extern unsigned long totalram_pages;
  238. -
  239. - unsigned int totalPhysicalPages = totalram_pages;
  240. + unsigned int totalPhysicalPages = compat_totalram_pages();
  241.  
  242. /*
  243. * Use the memory information linux exports as of late for a more
  244. @@ -2570,7 +2590,7 @@
  245.  
  246. poll_initwait(&table);
  247. current->state = TASK_INTERRUPTIBLE;
  248. - mask = file->f_op->poll(file, &table.pt);
  249. + mask = compat_vfs_poll(file, &table.pt);
  250. if (!(mask & (POLLIN | POLLERR | POLLHUP))) {
  251. vm->vmhost->vcpuSemaTask[vcpuid] = current;
  252. schedule_timeout(timeoutms * HZ / 1000); // convert to Hz
  253. @@ -3405,7 +3425,7 @@
  254.  
  255. ASSERT(handle);
  256.  
  257. - if (!access_ok(VERIFY_WRITE, p, size)) {
  258. + if (!write_access_ok(p, size)) {
  259. printk(KERN_ERR "%s: Couldn't verify write to uva 0x%p with size %"
  260. FMTSZ"u\n", __func__, p, size);
RAW Paste Data