Compare commits

..
Author SHA1 Message Date
Michal Kubecek 707625968b mark branch workstation-15.1.0 as retired 2020-02-10 07:09:20 +01:00
Michal Kubecek 8cd6f1f548 vmnet: work around skb_frag_t build failure for SLE15-SP2 and openSUSE-15.2
The kernels used in (upcoming) SLE15 SP2 and openSUSE Leap 15.2 are based
on upstream version 5.3 but have a backport of the skb_frag_t conversion to
bio_vec which reached mainline in v5.4-rc1. As we cannot easily check
availability compat_skb_frag_off() (which was also added in v5.4-rc1) and
have to resort to version check, add an exception for SLE15-SP2 and
openSUSE-15.2 kernels.
2019-11-25 08:33:42 +01:00
Michal Kubecek 40fa50e167 vmnet: handle switch of skb_frag_t to bio_vec
The switch from custom skb_frag_t implementation to bio_vec in v5.4-rc1 is
mostly transparent for modules which use accessor for skb_frag_t members.
Unfortunately many users access the members directly and function
VNetCsumCopyDatagram() in vmnet is one of those.

Use accessors everywhere so that vmnet code is compatible with kernel 5.4
and newer. Use "compat_" prefix to avoid clashes with backports adding the
accessors to older codebase.
2019-09-19 12:20:20 +02:00
Michal Kubecek 5ce7df3a11 Merge branch 'master' into workstation-15.1.0 2019-09-09 08:40:06 +02:00
Michal Kubecek 85ede6aae9 misc: fix wrong directory name in INSTALL (fixes #36)
Fix wrong directory name in one of the examples.
2019-09-09 08:38:27 +02:00
Michal Kubecek 98008ff6ad vmmon: fix HostIF_SetFastClockRate() not to use force_sig()
Commit 3cf5d076fb4d ("signal: Remove task parameter from force_sig") in
v5.3-rc1 drops second argument of force_sig(); before that, all callers
which passed something else than current task as second argument were
fixed, mostly to use send_sig() instead.

The situation in HostIF_SetFastClockRate() is the same as e.g. in bpfilter
call fixed by commit 1dfd1711de29 ("signal/bpfilter: Fix bpfilter_kernl to
use send_sig not force_sig"): locking in force_sig_info() cannot handle
task exiting and using force_sig() for SIGKILL is pointless anyway as this
signal cannot be blocked.

As send_sig() is present with unchanged signature since the pre-git era, we
can use send_sig() unconditionally, regardless of kernel version.
2019-07-09 21:07:04 +02:00
Michal Kubecek 06587f75da vmmon: fix return type of vm_operations_struct::fault handler
Commit 3d3539018d2c ("mm: create the new vm_fault_t type") in mainline
5.1-rc1 changed the definition of vm_fault_t type to unsigned to catch
vm_operations_struct::fault handlers which still have int as return value.
LinuxDriverFault() in vmmon module is one of those.

As handler return type was changed by commit 1c8f422059ae ("mm: change
return type to vm_fault_t") in 4.17-rc1, make LinuxDriverFault() always
return vm_fault_t and define vm_fault_t as int when building against
a pre-4.17 kernel.
2019-05-15 07:29:22 +02:00
Michal Kubecek 1eb5aca24f vmmon: use KERNEL_DS rather than get_ds()
Commit 736706bee329 ("get rid of legacy 'get_ds()' function") in v5.1-rc1
removed get_ds() helper. As this helper always returned KERNEL_DS on x86_64
since the architecture was introduced (and even on i386, it did so since
v2.1.0), simply use KERNEL_DS regardless of kernel version.
2019-05-15 07:29:10 +02:00
Michal Kubecek f68df94fef vmnet: bring back the do_gettimeofday() helper
The do_gettimeofday() helper was removed by commit e4b92b108c6c
("timekeeping: remove obsolete time accessors") in v5.0-rc1. Bring it back
for users in vmnet-only/bridge.c

Note that Workstation/Player 15.1.0 did in fact resolve the absence of
do_gettimeofday() in kernel 5.0 and newer but it did so only for calls in
vmmon-only/linux/hostif.c. Calls in vmnet-only/bridge.c were left in place
as those are only compiled when building with LOGLEVEL >= 4.
2019-05-15 07:23:17 +02:00
Michal Kubecek b7a4ced6fc modules: replace SUBDIRS with M
Since commit 0126be38d988 ("kbuild: announce removal of SUBDIRS if used")
in v5.0-rc1, using SUBDIRS when building out of tree modules produces
a deprecation warning. As M used to work since pretty much ever, use it
unconditionally.
2019-05-15 07:14:55 +02:00
Michal Kubecek 36da83e6e9 vmmon: check presence of file_operations::poll()
Commit 11c5ad0ec441 ("eventpoll: switch to ->poll_mask") in v4.18-rc1, made
eventpoll switch from ->poll() to ->poll_mask(), resulting in a null
pointer dereference as vmmon calls the callback directly without checking
its availability.

Rather than calling the callback directly (which would result in null
pointer dereference), use vfs_poll() wrapper. As this wrapper is only
available since 4.18-rc1 cycle as well, provide a copy to use when building
against older kernels.

Note: even if the commit revealing the problem was reverted in 4.18-rc3
(and is unlikely to go back in the same form) so that vmmon no longer
crashes with 4.18 kernel, calling the callback without a check is a bad
practice so let's keep the patch in place.
2019-05-15 07:14:30 +02:00
Michal Kubecek b5e7506fc1 vmmon: fix indirect call with retpoline build
Build against kernel with retpoline support issues warning

  objtool: Task_Switch()+0x425: indirect call found in RETPOLINE build

This is because an indirect call in TaskSwitchToMonitor() is encoded using
inline assembler so that it bypasses retpoline generation. For this
purpose, macro CALL_NOSPEC exists since v4.15-rc8 (and has been backported
into some distribution kernels with the rest of retpoline support). Use the
macro if available and fallback to the original code if not.
2019-05-15 07:14:03 +02:00
Michal Kubecek f408354770 vmmon: fix always_inline attribute usage
Function declared with __attribute__((always_inline)) should also be
declared as inline, otherwise gcc issues a warning "always_inline function
might not be inlinable". It's just cosmetic but getting rid of known
harmless warnings makes it easier to spot actual problems. Use the
__always_inline macro for LinuxDriverSyncReadTSCs() as this is how always
inline functions should be declared in kernel code.
2019-05-15 07:13:53 +02:00
Michal Kubecek eb72fde445 vmmon: use standard definition of MSR_K7_HWCR_SMMLOCK if available
The MSR_K7_HWCR_SMMLOCK macro is defined in mainline since commit
18c71ce9c882 ("x86/CPU/AMD: Add the Secure Encrypted Virtualization CPU
feature") in v4.16-rc1.
2019-05-15 07:13:47 +02:00
Theo Bertacchini 767d3fba57 modules: remove .cache.mk on make clean
Remove .cache.mk inside vmmon-only and vmnet-only when executing
"make clean". This file can cause issues when upgrading gcc as make will
still look for includes inside older gcc includes directory.

File .cache.mk with cache of generated variables was created by build since
kernel v4.15-rc1, commit 3298b690b21c ("kbuild: Add a cache for generated
variables") until the feature was removed in v4.18-rc1, commit e08d6de4e532
("kbuild: remove kbuild cache").
2019-05-15 07:13:26 +02:00
Michal Kubecek 101f86a31b vmmon: quick workaround for objtool warnings
As discussed in

  https://bugzilla.suse.com/show_bug.cgi?id=1059674

the reason for multiple objtool warnings is the fact that vmmon module
defines its own Panic() function which never returns. While it is marked as
such which is used by the compiler for optimization, there is no way to
find this from object file.

While this seems innocuous, it might result in problems with unwinder
later. The quickest way around is to replace vmmon's own Panic() with
standard kernel panic() until a cleaner solution is found.
2019-05-15 07:13:14 +02:00
Michal Kubecek b4541973e1 vmmon: use standard definition of CR3_PCID_MASK if available
The CR3_PCID_MASK is defined in mainline asm/processor-flags.h since
commit 6c690ee1039b ("x86/mm: Split read_cr3() into read_cr3_pa() and
__read_cr3()") in v4.13-rc1.
2019-05-15 07:12:55 +02:00
Michal Kubecek 6facae64df vmmon: use standard definition of MSR_MISC_FEATURES_ENABLES if available
The MSR_MISC_FEATURES_ENABLES macro is defined in mainline since commit
ab6d9468631a ("x86/msr: Rename MISC_FEATURE_ENABLES to
MISC_FEATURES_ENABLES") in v4.12-rc1.

The MSR_MISC_FEATURES_ENABLES_CPUID_FAULT macro is defined in mainline
since commit e9ea1e7f53b8 ("x86/arch_prctl: Add ARCH_[GET|SET]_CPUID") in
v4.12-rc1.
2019-05-15 07:12:39 +02:00
Michal Kubecek 4c4847e89b vmnet: use standard definition of PCI_VENDOR_ID_VMWARE_VMXNET3 if available
The PCI_DEVICE_ID_VMWARE_VMXNET3 macro is defined in mainline pci_ids.h
since commit b1226c7db1d9 ("vmxnet3: Move PCI Id to pci_ids.h") in
v4.10-rc1.
2019-05-15 07:12:28 +02:00
Michal Kubecek a0922934ed vmnet: use standard definition of PCI_VENDOR_ID_VMWARE if available
The PCI_VENDOR_ID_VMWARE macro is defined in mainline pci_ids.h since
commit 94e57fea6202 ("PCI: Move PCI_VENDOR_ID_VMWARE to pci_ids.h")
in v3.18-rc1.
2019-05-15 07:12:02 +02:00
Michal Kubecek a93f44ee44 import Workstation 15.1.0 module sources 2019-05-15 07:10:51 +02:00
20 changed files with 243 additions and 55 deletions

No files matched your search

+1 -1
View File
@@ -150,7 +150,7 @@ test build).
When using a downloaded tarball, simply run
tar -cf vmmon.tar vmmon-only
tar -cf vmnet.tar vmmon-only
tar -cf vmnet.tar vmnet-only
to create the tarballs. In this case, there is no protection against
unwanted local changes.
+7
View File
@@ -0,0 +1,7 @@
*-----------------------------------------------------------------------------
* Branch workstation-15.1.0 has been retired on 2020-02-10 and has not been
* receiving any updates since. Please switch to latest 15.1.x version
* available.
*
* Latest kernel version this branch is intended to work with is 5.5.
*-----------------------------------------------------------------------------
+1 -1
View File
@@ -107,7 +107,7 @@ prebuild:: ;
postbuild:: ;
$(DRIVER_KO): prebuild
$(MAKE) -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) \
$(MAKE) -C $(BUILD_DIR) M=$$PWD SRCROOT=$$PWD/$(SRCROOT) \
MODULEBUILDDIR=$(MODULEBUILDDIR) modules
$(MAKE) -C $$PWD SRCROOT=$$PWD/$(SRCROOT) \
MODULEBUILDDIR=$(MODULEBUILDDIR) postbuild
+1 -1
View File
@@ -31,7 +31,7 @@ $(DRIVER)-y := $(subst $(SRCROOT)/, , $(patsubst %.c, %.o, \
$(SRCROOT)/bootstrap/*.c)))
clean:
rm -rf $(wildcard $(DRIVER).mod.c $(DRIVER).ko .tmp_versions \
rm -rf $(wildcard $(DRIVER).mod.c $(DRIVER).ko .tmp_versions .cache.mk \
Module.symvers Modules.symvers Module.markers modules.order \
$(foreach dir,linux/ common/ vmcore/ bootstrap/ \
./,$(addprefix $(dir),.*.cmd .*.o.flags *.o)))
+5 -8
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998,2014 VMware, Inc. All rights reserved.
* Copyright (C) 1998,2014,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -24,9 +24,8 @@
* Depending on configuration phystracker provides either 2-level or
* 3-level structure to track whether page (specified by its MPN) is
* locked or no. Linux uses 3-level structures with top limit of
* 1TB (32bit) or 16TB (64bit). Windows use 2-level structures
* ready to hold 128GB (32bit) or 2TB (64bit) of memory. On Mac
* limit is 2-level 128GB.
* 1TB (32bit) or 16TB (64bit). Windows and Mac use 2-level structures
* ready to hold 128GB (32bit) or 2TB (64bit) of memory.
*
* 2-level phystracker is built on top of 3-level one by collapsing
* middle level.
@@ -50,9 +49,7 @@
#define BYTES_PER_ENTRY (PAGE_SIZE)
#define PHYSTRACK_L3_ENTRIES (8 * BYTES_PER_ENTRY) /* 128MB */
#if defined(WINNT_DDK)
#define PHYSTRACK_L1_ENTRIES (PHYSTRACK_MAX_SUPPORTED_GB * 8)
#elif defined(__linux__)
#if defined(__linux__)
#define PHYSTRACK_L2_ENTRIES (BYTES_PER_ENTRY / sizeof(void *)) /* 64GB or 128GB */
/*
* Currently MPN is 32 bits. 15 bits are in L3, 9 bits are in L2,
@@ -60,7 +57,7 @@
*/
#define PHYSTRACK_L1_ENTRIES (256) /* 16TB. */
#else
#define PHYSTRACK_L1_ENTRIES ((128 + 4) * 8) /* 128 GB */
#define PHYSTRACK_L1_ENTRIES (PHYSTRACK_MAX_SUPPORTED_GB * 8)
#endif
#ifndef PHYSTRACK_L2_ENTRIES
+2 -2
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998 VMware, Inc. All rights reserved.
* Copyright (C) 1998,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -29,7 +29,7 @@
#define INCLUDE_ALLOW_VMCORE
#include "includeCheck.h"
#if defined(WINNT_DDK)
#if !defined (__linux__)
/* XXX: can be more efficient based on server vs. desktop and version of Windows */
#define PHYSTRACK_MAX_SUPPORTED_GB (2048 + 4) /* 2 TB 64-bit W2k8 + 4 GB PCI */
#endif
+24 -1
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
* Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -2322,12 +2322,23 @@ TaskSwitchToMonitor(VMCrossPage *crosspage)
{
uint64 raxGetsWiped, rcxGetsWiped;
#ifdef CALL_NOSPEC
__asm__ __volatile__(CALL_NOSPEC
: "=a" (raxGetsWiped),
"=c" (rcxGetsWiped)
: "0" (codePtr),
"1" (crosspage),
THUNK_TARGET(codePtr)
: "rdx", "r8", "r9", "r10", "r11", "cc", "memory");
#else
__asm__ __volatile__("call *%%rax"
: "=a" (raxGetsWiped),
"=c" (rcxGetsWiped)
: "0" (codePtr),
"1" (crosspage)
: "rdx", "r8", "r9", "r10", "r11", "cc", "memory");
#endif
}
#elif defined(_MSC_VER)
/*
@@ -2909,6 +2920,18 @@ Task_Switch(VMDriver *vm, // IN
}
if (crosspage->crosspageData.moduleCallType == MODULECALL_INTR) {
/*
* Newer versions of Window expect EFLAGS_AC to be set when handling an
* interupt - PR 2248661.
*/
if ((flags & EFLAGS_AC) != 0) {
uintptr_t curFlags;
SAVE_FLAGS(curFlags);
curFlags |= EFLAGS_AC;
RESTORE_FLAGS(curFlags);
}
/*
* Note we must do the RAISE_INTERRUPT before ever enabling
* interrupts or bad things have happened (might want to know exactly
+30
View File
@@ -0,0 +1,30 @@
#ifndef __COMPAT_POLL_H__
#define __COMPAT_POLL_H__
#include <linux/poll.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
#ifndef __poll_t
typedef unsigned int __poll_t;
#endif
static inline __poll_t compat_vfs_poll(struct file *file,
struct poll_table_struct *pt)
{
if (unlikely(!file->f_op->poll))
return DEFAULT_POLLMASK;
return file->f_op->poll(file, pt);
}
#else
static inline __poll_t compat_vfs_poll(struct file *file,
struct poll_table_struct *pt)
{
return vfs_poll(file, pt);
}
#endif
#endif /* __COMPAT_POLL_H__ */
+2 -1
View File
@@ -144,7 +144,7 @@ PtrToVA64(void const *ptr) // IN
* See bora/doc/vmcore details.
*/
#define VMMON_VERSION (360 << 16 | 0)
#define VMMON_VERSION (361 << 16 | 0)
#define VMMON_VERSION_MAJOR(v) ((uint32) (v) >> 16)
#define VMMON_VERSION_MINOR(v) ((uint16) (v))
@@ -276,6 +276,7 @@ enum IOCTLCmd {
#endif
#if defined __APPLE__
IOCTLCMD(GET_NUM_RESPONDING_CPUS),
IOCTLCMD(ALLOC_LOW_PAGES),
IOCTLCMD(INIT_DRIVER),
IOCTLCMD(BLUEPILL),
+2 -1
View File
@@ -67,6 +67,7 @@ extern "C" {
#if defined (VMKPANIC)
#include "vmk_assert.h"
#else /* !VMKPANIC */
#include <linux/kernel.h>
#define _ASSERT_PANIC(name) \
Panic(_##name##Fmt "\n", __FILE__, __LINE__)
#define _ASSERT_PANIC_BUG(bug, name) \
@@ -107,7 +108,7 @@ NORETURN void Panic_NoSave(const char *fmt, ...) PRINTF_DECL(1, 2);
} while(0)
#else
NORETURN void Panic(const char *fmt, ...) PRINTF_DECL(1, 2);
#define Panic panic
#endif
void LogThrottled(uint32 *count, const char *fmt, ...) PRINTF_DECL(2, 3);
+4
View File
@@ -35,6 +35,8 @@
#define INCLUDE_ALLOW_VMCORE
#include "includeCheck.h"
#include <asm/processor-flags.h>
#define X86_MAX_INSTR_LEN 15 /* Max byte length of an x86 instruction. */
#define NUM_IDT_VECTORS 256
@@ -75,7 +77,9 @@
#define CR3_PDB_MASK 0xfffff000
#define CR3_IGNORE 0xFFF
#define PAE_CR3_IGNORE 0x1F
#ifndef CR3_PCID_MASK
#define CR3_PCID_MASK 0xFFF
#endif
#define CR3_NO_FLUSH (1ULL << 63)
#define CR4_VME 0x00000001
+16 -1
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
* Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -465,6 +465,9 @@ FLAG( 6, 0, ECX, 3, 1, ENERGY_PERF_BIAS, NO, 0, FALSE)
#define CPUID_7_EDX_28 \
FLAG( 7, 0, EDX, 28, 1, LEVEL7EDX_RSVD1, NO, 0, FALSE)
/* LEVEL, SUB-LEVEL, REG, POS, SIZE, NAME, MON SUPP, HWV, CPL3 */
#define CPUID_7_EDX_10 \
FLAG( 7, 0, EDX, 10, 1, LEAF7_RSVD, NO, 0, FALSE)
#define CPUID_7_EDX_31 \
FLAG( 7, 0, EDX, 31, 1, LEVEL7EDX_RSVD2, NO, 0, FALSE)
@@ -519,6 +522,7 @@ FLAG( 7, 0, ECX, 22, 1, RDPID, NO, 0, TRUE) \
FLAG( 7, 0, ECX, 30, 1, SGX_LC, YES, 17, FALSE) \
FLAG( 7, 0, EDX, 2, 1, AVX512QVNNIW, YES, 16, TRUE) \
FLAG( 7, 0, EDX, 3, 1, AVX512QFMAPS, YES, 16, TRUE) \
CPUID_7_EDX_10 \
FLAG( 7, 0, EDX, 26, 1, IBRSIBPB, ANY, 9, FALSE) \
FLAG( 7, 0, EDX, 27, 1, STIBP, YES, 9, FALSE) \
CPUID_7_EDX_28 \
@@ -1432,6 +1436,8 @@ CPUIDCheck(int32 eaxIn, int32 eaxInCheck,
#define CPUID_STEPPING_KABYLAKE_ES 0x8 // Kabylake S/H/U/Y ES
#define CPUID_STEPPING_COFFEELAKE_A 0xA // Coffeelake U/S/H
#define CPUID_STEPPING_COFFEELAKE_B 0xB // Coffeelake S/H
#define CPUID_STEPPING_CASCADELAKE_A 0x5 // Cascade Lake A-step
#define CPUID_STEPPING_CASCADELAKE_B1 0x7 // Cascade Lake B1-step
#define CPUID_MODEL_PIII_07 7
#define CPUID_MODEL_PIII_08 8
@@ -1656,6 +1662,15 @@ CPUID_MODEL_IS_HASWELL(uint32 v) // IN: %eax from CPUID with %eax=1.
effectiveModel == CPUID_MODEL_HASWELL_46);
}
static INLINE Bool
CPUID_MODEL_IS_CASCADELAKE(uint32 v) // IN: %eax from CPUID with %eax=1.
{
/* Assumes the CPU manufacturer is Intel. */
return CPUID_FAMILY_IS_P6(v) &&
CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_SKYLAKE_55 &&
CPUID_EFFECTIVE_STEPPING(v) >= CPUID_STEPPING_CASCADELAKE_A &&
CPUID_EFFECTIVE_STEPPING(v) <= CPUID_STEPPING_CASCADELAKE_B1;
}
static INLINE Bool
CPUID_MODEL_IS_SKYLAKE(uint32 v) // IN: %eax from CPUID with %eax=1.
+12 -1
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 1998-2018 VMware, Inc. All rights reserved.
* Copyright (C) 1998-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -24,6 +24,7 @@
#ifndef _X86MSR_H_
#define _X86MSR_H_
#include <asm/msr-index.h>
#define INCLUDE_ALLOW_USERLEVEL
#define INCLUDE_ALLOW_VMX
@@ -120,6 +121,8 @@ MSRQuery;
#define MSR_ARCH_CAPABILITIES_RDCL_NO (1ULL << 0)
#define MSR_ARCH_CAPABILITIES_IBRS_ALL (1ULL << 1)
#define MSR_ARCH_CAPABILITIES_RSBA (1ULL << 2)
#define MSR_ARCH_CAPABILITIES_NOL1F_VMENTRY (1ULL << 3)
#define MSR_ARCH_CAPABILITIES_SSB_NO (1ULL << 4)
#define MSR_SPEC_CTRL_IBRS (1UL << 0)
@@ -127,7 +130,9 @@ MSRQuery;
#define MSR_PRED_CMD_IBPB (1UL << 0)
#ifndef MSR_MISC_FEATURES_ENABLES
#define MSR_MISC_FEATURES_ENABLES 0x140
#endif
/* Intel Core Architecture and later: use only architected counters. */
#define IA32_MSR_PERF_CAPABILITIES 0x345
@@ -463,7 +468,9 @@ typedef enum {
#define MSR_K7_HWCR_SSEDIS 0x00008000ULL // Disable SSE bit
#define MSR_K7_HWCR_MONMWAITUSEREN 0x00000400ULL // Enable MONITOR/MWAIT CPL>0
#define MSR_K7_HWCR_TLBFFDIS 0x00000040ULL // Disable TLB Flush Filter
#ifndef MSR_K7_HWCR_SMMLOCK
#define MSR_K7_HWCR_SMMLOCK 0x00000001ULL // Lock SMM environment
#endif
#ifndef MSR_K8_SYSCFG
#define MSR_K8_SYSCFG 0xc0010010
@@ -652,7 +659,11 @@ typedef unsigned char MTRRType;
/*
* MISC_FEATURES_ENABLES bits
*/
#ifdef MSR_MISC_FEATURES_ENABLES_CPUID_FAULT
#define MSR_MISC_FEATURES_ENABLES_CPUID_FAULTING MSR_MISC_FEATURES_ENABLES_CPUID_FAULT
#else
#define MSR_MISC_FEATURES_ENABLES_CPUID_FAULTING 1
#endif
+7 -4
View File
@@ -73,6 +73,9 @@ static Bool LinuxDriverCheckPadding(void);
struct VMXLinuxState linuxState;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
typedef int vm_fault_t;
#endif
/*
*----------------------------------------------------------------------
@@ -97,9 +100,9 @@ long LinuxDriver_Ioctl(struct file *filp, u_int iocmd,
static int LinuxDriver_Close(struct inode *inode, struct file *filp);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
static int LinuxDriverFault(struct vm_fault *fault);
static vm_fault_t LinuxDriverFault(struct vm_fault *fault);
#else
static int LinuxDriverFault(struct vm_area_struct *vma, struct vm_fault *fault);
static vm_fault_t LinuxDriverFault(struct vm_area_struct *vma, struct vm_fault *fault);
#endif
static int LinuxDriverMmap(struct file *filp, struct vm_area_struct *vma);
@@ -595,7 +598,7 @@ LinuxDriver_Close(struct inode *inode, // IN
*-----------------------------------------------------------------------------
*/
static int
static vm_fault_t
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
LinuxDriverFault(struct vm_fault *fault) //IN/OUT
#else
@@ -982,7 +985,7 @@ LinuxDriverReadTSC(void *data, // OUT: TSC values
*-----------------------------------------------------------------------------
*/
__attribute__((always_inline)) static Bool
__always_inline static Bool
LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min
{
TSCDelta tscDelta;
+63 -14
View File
@@ -74,6 +74,7 @@
#include "pgtbl.h"
#include "versioned_atomic.h"
#include "compat_poll.h"
#if !defined(CONFIG_HIGH_RES_TIMERS)
#error CONFIG_HIGH_RES_TIMERS required for acceptable performance
@@ -1638,9 +1639,13 @@ HostIF_EstimateLockedPageLimit(const VMDriver* vm, // IN
* since at least 2.6.0.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
extern unsigned long totalram_pages;
unsigned int totalPhysicalPages = totalram_pages;
#else
unsigned int totalPhysicalPages = totalram_pages();
#endif
/*
* Use the memory information linux exports as of late for a more
@@ -1738,6 +1743,49 @@ HostIF_WaitForFreePages(unsigned int timeoutMs) // IN:
}
/*
*----------------------------------------------------------------------
*
* HostIFGetTime --
*
* Reads the current time in UPTIME_FREQ units.
*
* Results:
* The uptime, in units of UPTIME_FREQ.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static uint64
HostIFGetTime(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
struct timeval tv;
do_gettimeofday(&tv);
return tv.tv_usec * (UPTIME_FREQ / 1000000) + tv.tv_sec * UPTIME_FREQ;
#else
struct timespec64 now;
/*
* Use raw time used by Posix timers. This time is not affected by
* NTP adjustments, so it may drift from real time and monotonic time,
* but it will stay in sync with other timers.
*/
ktime_get_raw_ts64(&now);
/*
* UPTIME_FREQ resolution is lower than tv_nsec,
* so we have to do division...
*/
ASSERT_ON_COMPILE(1000000000 % UPTIME_FREQ == 0);
return now.tv_nsec / (1000000000 / UPTIME_FREQ) + now.tv_sec * UPTIME_FREQ;
#endif
}
/*
*----------------------------------------------------------------------
*
@@ -1769,7 +1817,6 @@ HostIF_WaitForFreePages(unsigned int timeoutMs) // IN:
static uint64
HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
{
struct timeval tv;
uint64 monotime, uptime, upBase, monoBase;
int64 diff;
uint32 version;
@@ -1784,13 +1831,12 @@ HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
monoBase = uptimeState.monotimeBase;
} while (!VersionedAtomic_EndTryRead(&uptimeState.version, version));
do_gettimeofday(&tv);
uptime = HostIFGetTime();
upBase = Atomic_Read64(&uptimeState.uptimeBase);
monotime = (uint64)(jifs - jifBase) * (UPTIME_FREQ / HZ);
monotime += monoBase;
uptime = tv.tv_usec * (UPTIME_FREQ / 1000000) + tv.tv_sec * UPTIME_FREQ;
uptime += upBase;
/*
@@ -1895,13 +1941,11 @@ HostIFUptimeResyncMono(struct timer_list *timer) // IN: ignored
void
HostIF_InitUptime(void)
{
struct timeval tv;
uint64 tm;
uptimeState.jiffiesBase = jiffies;
do_gettimeofday(&tv);
Atomic_Write64(&uptimeState.uptimeBase,
-(tv.tv_usec * (UPTIME_FREQ / 1000000) +
tv.tv_sec * UPTIME_FREQ));
tm = HostIFGetTime();
Atomic_Write64(&uptimeState.uptimeBase, -tm);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) && !defined(timer_setup)
init_timer(&uptimeState.timer);
@@ -2285,7 +2329,7 @@ isVAReadable(VA r) // IN:
int ret;
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
r = APICR_TO_ADDR(r, APICR_VERSION);
ret = HostIF_CopyFromUser(&dummy, r, sizeof dummy);
set_fs(old_fs);
@@ -2562,7 +2606,7 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
}
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
{
struct poll_wqueues table;
@@ -2570,7 +2614,7 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
poll_initwait(&table);
current->state = TASK_INTERRUPTIBLE;
mask = file->f_op->poll(file, &table.pt);
mask = compat_vfs_poll(file, &table.pt);
if (!(mask & (POLLIN | POLLERR | POLLHUP))) {
vm->vmhost->vcpuSemaTask[vcpuid] = current;
schedule_timeout(timeoutms * HZ / 1000); // convert to Hz
@@ -2691,7 +2735,7 @@ HostIF_SemaphoreSignal(uint64 *args) // IN:
}
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
/*
* Always write sizeof(uint64) bytes. This works fine for eventfd and
@@ -3359,7 +3403,7 @@ HostIF_SetFastClockRate(unsigned int rate) // IN: Frequency in Hz.
}
} else {
if (linuxState.fastClockThread) {
force_sig(SIGKILL, linuxState.fastClockThread);
send_sig(SIGKILL, linuxState.fastClockThread, 1);
kthread_stop(linuxState.fastClockThread);
linuxState.fastClockThread = NULL;
@@ -3405,7 +3449,12 @@ HostIF_MapUserMem(VA addr, // IN: User memory virtual address
ASSERT(handle);
if (!access_ok(VERIFY_WRITE, p, size)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
if (!access_ok(VERIFY_WRITE, p, size))
#else
if (!access_ok(p, size))
#endif
{
printk(KERN_ERR "%s: Couldn't verify write to uva 0x%p with size %"
FMTSZ"u\n", __func__, p, size);
+1 -1
View File
@@ -107,7 +107,7 @@ prebuild:: ;
postbuild:: ;
$(DRIVER_KO): prebuild
$(MAKE) -C $(BUILD_DIR) SUBDIRS=$$PWD SRCROOT=$$PWD/$(SRCROOT) \
$(MAKE) -C $(BUILD_DIR) M=$$PWD SRCROOT=$$PWD/$(SRCROOT) \
MODULEBUILDDIR=$(MODULEBUILDDIR) modules
$(MAKE) -C $$PWD SRCROOT=$$PWD/$(SRCROOT) \
MODULEBUILDDIR=$(MODULEBUILDDIR) postbuild
+1 -1
View File
@@ -32,6 +32,6 @@ $(DRIVER)-y := driver.o hub.o userif.o netif.o bridge.o procfs.o smac_compat.o \
####
clean:
rm -rf $(DRIVER).o $(DRIVER).mod.o $(DRIVER).mod.c $(DRIVER).ko \
rm -rf $(DRIVER).o $(DRIVER).mod.o $(DRIVER).mod.c $(DRIVER).ko .cache.mk \
.tmp_versions Module.symvers Modules.symvers Module.markers \
modules.order $($(DRIVER)-y) .*.cmd .*.o.flags
+12
View File
@@ -67,6 +67,18 @@
#if LOGLEVEL >= 4
static struct timeval vnetTime;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
static void do_gettimeofday(struct timeval *tv)
{
struct timespec64 now;
ktime_get_real_ts64(&now);
tv->tv_sec = now.tv_sec;
tv->tv_usec = now.tv_nsec / 1000;
}
#endif
#endif
typedef struct VNetBridge VNetBridge;
+43 -17
View File
@@ -78,13 +78,33 @@ static int VNetUserIfSetUplinkState(VNetPort *port, uint8 linkUp);
extern unsigned int vnet_max_qlen;
#if COMPAT_LINUX_VERSION_CHECK_LT(3, 2, 0)
# define compat_kmap(page) kmap(page)
# define compat_kunmap(page) kunmap(page)
# define compat_kmap_frag(frag) kmap((frag)->page)
# define compat_kunmap_frag(page) kunmap((frag)->page)
#else
# define compat_kmap(page) kmap((page).p)
# define compat_kunmap(page) kunmap((page).p)
# define compat_kmap_frag(frag) kmap(skb_frag_page(frag))
# define compat_kunmap_frag(frag) kunmap(skb_frag_page(frag))
#endif
static unsigned int compat_skb_frag_size(const skb_frag_t *frag)
{
#if COMPAT_LINUX_VERSION_CHECK_LT(3, 2, 0)
return frag->size;
#else
return skb_frag_size(frag);
#endif
}
static unsigned int compat_skb_frag_off(const skb_frag_t *frag)
{
#if COMPAT_LINUX_VERSION_CHECK_LT(5, 4, 0) && \
!(defined(CONFIG_SUSE_VERSION) && CONFIG_SUSE_VERSION == 15 && \
defined(CONFIG_SUSE_PATCHLEVEL) && CONFIG_SUSE_PATCHLEVEL >= 2)
return frag->page_offset;
#else
return skb_frag_off(frag);
#endif
}
/*
*-----------------------------------------------------------------------------
*
@@ -137,16 +157,21 @@ UserifLockPage(VA addr) // IN
*/
static INLINE int
VNetUserIfMapPtr(VA uAddr, // IN: pointer to user memory
VNetUserIfMapPtr(VA64 uAddr, // IN: pointer to user memory
size_t size, // IN: size of data
struct page **p, // OUT: locked page
void **ptr) // OUT: kernel mapped pointer
{
if (!access_ok(VERIFY_WRITE, (void *)uAddr, size) ||
(((uAddr + size - 1) & ~(PAGE_SIZE - 1)) !=
(uAddr & ~(PAGE_SIZE - 1)))) {
uint8 v;
/* Check area does not straddle two pages. */
if ((uAddr & (PAGE_SIZE - 1)) + size > PAGE_SIZE) {
return -EINVAL;
}
/* Check if it is user's area. UserifLockPage() checks writability. */
if (copy_from_user(&v, (void *)(unsigned long)uAddr, sizeof v) != 0) {
return -EFAULT;
}
*p = UserifLockPage(uAddr);
if (*p == NULL) {
@@ -158,7 +183,7 @@ VNetUserIfMapPtr(VA uAddr, // IN: pointer to user memory
}
static INLINE int
VNetUserIfMapUint32Ptr(VA uAddr, // IN: pointer to user memory
VNetUserIfMapUint32Ptr(VA64 uAddr, // IN: pointer to user memory
struct page **p, // OUT: locked page
uint32 **ptr) // OUT: kernel mapped pointer
{
@@ -201,7 +226,7 @@ VNetUserIfSetupNotify(VNetUserIF *userIf, // IN
return -EBUSY;
}
if ((retval = VNetUserIfMapUint32Ptr((VA)vn->pollPtr, &pollPage,
if ((retval = VNetUserIfMapUint32Ptr(vn->pollPtr, &pollPage,
&pollPtr)) < 0) {
return retval;
}
@@ -213,7 +238,7 @@ VNetUserIfSetupNotify(VNetUserIF *userIf, // IN
goto error_free;
}
if ((retval = VNetUserIfMapUint32Ptr((VA)vn->recvClusterPtr,
if ((retval = VNetUserIfMapUint32Ptr(vn->recvClusterPtr,
&recvClusterPage,
&recvClusterCount)) < 0) {
goto error_free;
@@ -559,20 +584,21 @@ VNetCsumCopyDatagram(const struct sk_buff *skb, // IN: skb to copy
for (frag = skb_shinfo(skb)->frags;
frag != skb_shinfo(skb)->frags + skb_shinfo(skb)->nr_frags;
frag++) {
if (frag->size > 0) {
if (compat_skb_frag_size(frag) > 0) {
unsigned int tmpCsum;
const void *vaddr;
vaddr = compat_kmap(frag->page);
tmpCsum = csum_and_copy_to_user(vaddr + frag->page_offset,
curr, frag->size, 0, &err);
compat_kunmap(frag->page);
vaddr = compat_kmap_frag(frag);
tmpCsum = csum_and_copy_to_user(vaddr + compat_skb_frag_off(frag),
curr, compat_skb_frag_size(frag), 0,
&err);
compat_kunmap_frag(frag);
if (err) {
return err;
}
csum = csum_block_add(csum, tmpCsum, curr - buf);
curr += frag->size;
curr += compat_skb_frag_size(frag);
}
}
+9
View File
@@ -35,6 +35,8 @@
#endif
#endif
#include <linux/pci_ids.h>
/* LSILogic 53C1030 Parallel SCSI controller
* LSILogic SAS1068 SAS controller
*/
@@ -53,7 +55,10 @@
* VMware HD Audio codec
* VMware HD Audio controller
*/
#ifndef PCI_VENDOR_ID_VMWARE
#define PCI_VENDOR_ID_VMWARE 0x15AD
#endif
#define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710
#define PCI_DEVICE_ID_VMWARE_VGA 0x0711
@@ -70,7 +75,11 @@
#define PCI_DEVICE_ID_VMWARE_1394 0x0780
#define PCI_DEVICE_ID_VMWARE_BRIDGE 0x0790
#define PCI_DEVICE_ID_VMWARE_ROOTPORT 0x07A0
#ifndef PCI_DEVICE_ID_VMWARE_VMXNET3
#define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07B0
#endif
#define PCI_DEVICE_ID_VMWARE_PVSCSI 0x07C0
#define PCI_DEVICE_ID_VMWARE_82574 0x07D0
#define PCI_DEVICE_ID_VMWARE_AHCI 0x07E0