Compare commits

..
Author SHA1 Message Date
Michal Kubecek 9366e2f3f3 vmmon: fix version check for <linux/frame.h> include
Both the version check for include of <linux/frame.h> in common/crosspage.c
and the comment explaining it are wrong for multiple reasons:

  1. <linux/frame.h> was introduced in v4.6-rc1, not v4.5-rc5
  2. ANNOTATE_INTRA_FUNCTION_CALL was introduced in v5.8-rc1, not v5.7
  3. Even if it were, the check should use ">=", not ">"
  4. Most important, the code in fact needs STACK_FRAME_NON_STANDARD

Without the definition of STACK_FRAME_NON_STANDARD, build against vanilla
5.7 kernel fails on objtool error (but succeeds against 5.7.1, because of
the mistake from point 3).

Change the check from "> 5.7" to ">= 4.6" to get STACK_FRAME_NON_STANDARD
whenever available and update the explaining comment.
2020-09-15 21:45:22 +02:00
Michal Kubecek ccf92d942d vmmon: include <asm/irq_vectors.h> explicitly
After mainline commit 13c01139b171 ("x86/headers: Remove APIC headers from
<asm/smp.h>") in 5.9-rc1, APIC headers are no longer included via
<asm/smp.h> so that linux/hostif.c will use incorrect fallback definitions
of SPURIOUS_APIC_VECTOR, POSTED_INTR_VECTOR and ERROR_APIC_VECTOR even if
built against kernel where these are defined.

Include <asm/irq_vectors.h> in linux/hostif.c explicitly to avoid that.
2020-09-15 19:12:45 +02:00
Michal Kubecek 11ea886ad4 vmmon: use standard definitions of MSR_TEST_CTRL and MSR_TEST_CTRL_SPLIT_LOCK_DETECT
The MSR_TEST_CTRL and MSR_TEST_CTRL_SPLIT_LOCK_DETECT macros are defined in
arch/x86/include/asm/msr-index.h since commit 6650cdd9a8cc
("x86/split_lock: Enable split lock detection by kernel") in v5.7-rc1.
2020-09-15 19:02:42 +02:00
Michal Kubecek da6f140d42 vmmon: use standard definition of MSR_TSX_FORCE_ABORT if available
The MSR_TSX_FORCE_ABORT macro is defined in mainline since commit
52f64909409c ("x86: Add TSX Force Abort CPUID/MSR") in v5.1-rc1.
2020-09-15 19:02:42 +02:00
Michal Kubecek 23cb94b72d vmnet: convert VNetBridge debugging code to ktime_get_ns()
The do_gettimeofday() helper was removed by commit e4b92b108c6c
("timekeeping: remove obsolete time accessors") in v5.0-rc1 and since
commit c766d1472c70 ("y2038: hide timeval/timespec/itimerval/itimerspec
types") in v5.6-rc3, struct timeval should no longer be used in kernel
code.

Convert the do_gettimeofday() relics in VNetBridge (which are only compiled
with LOGLEVEL >= 4) completely to ktime based interface.
2020-09-15 19:02:42 +02:00
Michal Kubecek 99646e1456 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.
2020-09-15 19:02:42 +02:00
Michal Kubecek 652107fe58 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.
2020-09-15 19:02:42 +02:00
Michal Kubecek 5d5ab3dfe2 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.
2020-09-15 19:02:42 +02:00
Theo Bertacchini 252a291e8f 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").
2020-09-15 19:02:42 +02:00
Michal Kubecek b064272379 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.
2020-09-15 19:02:42 +02:00
Michal Kubecek 7e0692fc83 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.
2020-09-15 19:02:42 +02:00
Michal Kubecek 754f491259 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.
2020-09-15 19:02:42 +02:00
Michal Kubecek db64d53fb7 vmmon: rename GDT_SIZE macro to avoid collision
When building against kernel 4.12 and newer, macro name GDT_SIZE used in
(vmmon) include/segs.h collides with macro defined in (kernel source)
arch/x86/include/asm/segment.h, resulting in its redefinition.

To prevent potential problems, rename vmmon's GDT_SIZE to VMMON_GDT_SIZE
and GDT_LIMIT to VMMON_GDT_LIMIT. (There is no GDT_LIMIT in mainline kernel
source but let's be consistent.)
2020-09-15 19:02:42 +02:00
Michal Kubecek fdfd34a74d 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.
2020-09-15 17:19:51 +02:00
Michal Kubecek 2f34c27498 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.
2020-09-15 17:13:35 +02:00
Michal Kubecek 572c0ba586 vmmon: fix wrong VMX86_DEVEL test
If VMX86_DEVEL macro is not defined, preprocessor warns when it is tested
with "#if" in vmmon-only/linux/driver.c. As VMX86_DEVEL is tested with
"#ifdef" everywhere else, change this one test to match the rest.
2020-09-15 17:11:01 +02:00
Michal Kubecek d67ec2e11c import Workstation 16.0.0 module sources 2020-09-15 17:05:51 +02:00
Michal Kubecek dec5bab6a0 import Workstation 15.5.5 module sources 2020-05-30 02:35:30 +02:00
Michal Kubecek 02fd1f0829 import Workstation 15.5.2 module sources 2020-03-14 09:56:53 +01:00
Michal Kubecek bf5aeaca48 import Workstation 15.5.1 module sources 2019-11-14 08:00:40 +01:00
Michal Kubecek 51949a3872 import Workstation 15.5.0 module sources 2019-09-21 00:18:33 +02:00
Michal Kubecek 4d36d6a1d2 Merge branch 'master' into workstation 2019-09-21 00:10:22 +02:00
Michal Kubecek a93f44ee44 import Workstation 15.1.0 module sources 2019-05-15 07:10:51 +02:00
Michal Kubecek b71c1b9e0b import Workstation 15.0.1 module sources 2018-11-12 07:53:50 +01:00
Michal Kubecek d7fe4fe97c import Workstation 15.0.0 module sources 2018-10-02 19:58:28 +02:00
Michal Kubecek 3f188d0a76 import Workstation 14.1.3 module sources 2018-08-20 07:30:12 +02:00
Michal Kubecek 454cbd7b96 Merge branch 'master' into workstation 2018-05-27 16:13:45 +02:00
Michal Kubecek 2749950c5f import Workstation 14.1.2 module sources 2018-05-23 18:49:52 +02:00
Michal Kubecek 7fa9cbe769 Merge branch 'master' into workstation 2018-04-02 15:37:06 +02:00
Michal Kubecek cb66161bb5 Merge branch 'master' into workstation 2018-02-04 21:50:23 +01:00
Michal Kubecek 876363be72 import Workstation 14.1.1 module sources 2018-01-12 13:51:07 +01:00
Michal Kubecek f78dd5288e import Workstation 14.1.0 module sources 2017-12-25 10:06:21 +01:00
Michal Kubecek e4df7e3461 import Workstation 14.0.0 module sources 2017-09-30 21:05:11 +02:00
Michal Kubecek 2bd541e265 import Workstation 12.5.7 module sources 2017-06-23 09:12:56 +02:00
Michal Kubecek 2a214307b9 import Workstation 12.5.6 module sources 2017-05-31 10:17:49 +02:00
Michal Kubecek 755b521dd1 import Workstation 12.5.5 module sources 2017-05-31 09:36:09 +02:00
20 changed files with 139 additions and 119 deletions

No files matched your search

+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)))
+6 -4
View File
@@ -47,9 +47,11 @@
#ifdef __linux__
# include "driver-config.h"
# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
# include <linux/objtool.h>
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
/*
* linux/frame.h dates back to 4.6-rc1, we need the STACK_FRAME_NON_STANDARD
* definition from it which is there from the start.
*/
# if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
# include <linux/frame.h>
# endif
#endif
@@ -139,7 +141,7 @@ CPDATA const VMCrossPageData cpDataTemplate = {
.monTask.IOMapBase = sizeof(Task64),
.monGDTR.limit = GDT_LIMIT,
.monGDTR.limit = VMMON_GDT_LIMIT,
.monGDTR.offset = GDT_START_VA,
.shadowDR[6].ureg64 = DR6_DEFAULT,
+1 -1
View File
@@ -110,7 +110,7 @@ EXTERN int HostIF_SemaphoreWait(VMDriver *vm,
Vcpuid vcpuid,
uint64 *args);
EXTERN int HostIF_SemaphoreSignal(VMDriver *vm, uint64 *args);
EXTERN int HostIF_SemaphoreSignal(uint64 *args);
EXTERN void HostIF_SemaphoreForceWakeup(VMDriver *vm, const VCPUSet *vcs);
EXTERN void HostIF_IPI(VMDriver *vm, const VCPUSet *vcs);
+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__ */
+1 -3
View File
@@ -148,7 +148,7 @@ PtrToVA64(void const *ptr) // IN
* the NT specific VMX86_DRIVER_VERSION.
*/
#define VMMON_VERSION (401 << 16 | 0)
#define VMMON_VERSION (398 << 16 | 0)
#define VMMON_VERSION_MAJOR(v) ((uint32) (v) >> 16)
#define VMMON_VERSION_MINOR(v) ((uint16) (v))
@@ -533,8 +533,6 @@ typedef struct IPIVectors {
*/
typedef struct VMCreateBlock {
VA64 bsBlob; // IN: User VA of the VMM bootstrap blob.
VA64 vmmonData; // IN: User VA of a userlevel scratch area
// required by the Linux vmmon
uint32 bsBlobSize; // IN: Size of VMM bootstrap blob.
uint32 numVCPUs; // IN: Number of VCPUs.
uint16 vmid; // OUT: VM ID for the created VM.
+4 -2
View File
@@ -421,7 +421,9 @@ VMCrossPageData;
#define MX_WAITINTERRUPTED 3
#define MX_WAITTIMEDOUT 2
#define MX_WAITNORMAL 1
#define MX_WAITERROR 0
#define MX_WAITNORMAL 1 // Must equal one; see linux module code.
#define MX_WAITERROR 0 // Use MX_ISWAITERROR() to test for error.
// Any zero or negative value denotes error.
#define MX_ISWAITERROR(e) ((e) <= MX_WAITERROR)
#endif
+3 -3
View File
@@ -51,14 +51,14 @@
* it can use a single cross GDT).
*/
#define GDT_SIZE (sizeof(Descriptor) * NUM_VALID_SEGMENTS)
#define GDT_LIMIT (GDT_SIZE - 1)
#define VMMON_GDT_SIZE (sizeof(Descriptor) * NUM_VALID_SEGMENTS)
#define VMMON_GDT_LIMIT (VMMON_GDT_SIZE - 1)
#define IRB_SIZE 32 /* Interrupt redirection bitmap. */
#define TSS_SIZE (sizeof(Task64) + IRB_SIZE)
#define GDT_START_VA (VPN_2_VA(GDT_AND_TASK_START))
#define TASK_START_VA (VPN_2_VA(GDT_AND_TASK_START) + GDT_SIZE)
#define TASK_START_VA (VPN_2_VA(GDT_AND_TASK_START) + VMMON_GDT_SIZE)
/*
* vmkBoot uses some of the lower-numbered segments, as do host kernels on
+3 -4
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2002-2020 VMware, Inc. All rights reserved.
* Copyright (C) 2002-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
@@ -44,11 +44,10 @@
# include "str.h" /* Str_Snprintf */
# define VCS_SNPRINTF Str_Snprintf
#elif defined MONITOR_APP
# include <stdio.h> /* libc snprintf */
# if defined WIN32
# include "str.h" /* Str_Snprintf */
# define VCS_SNPRINTF Str_Snprintf
# define VCS_SNPRINTF _snprintf
# else
# include <stdio.h> /* libc snprintf */
# define VCS_SNPRINTF snprintf
# endif
#elif defined VMM || defined VMKERNEL
+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
+15
View File
@@ -24,6 +24,7 @@
#ifndef _X86MSR_H_
#define _X86MSR_H_
#include <asm/msr-index.h>
#define INCLUDE_ALLOW_USERLEVEL
#define INCLUDE_ALLOW_VMX
@@ -124,8 +125,12 @@ MSRQuery;
#define MSR_PL3_SSP 0x6a7
#define MSR_ISST_ADDR 0x6a8
#ifndef MSR_TEST_CTRL
#define MSR_TEST_CTRL 0x33
#endif
#ifndef MSR_TEST_CTRL_SPLIT_LOCK_DETECT
#define MSR_TEST_CTRL_SPLIT_LOCK_DETECT (1ULL << 29)
#endif
#define IA32_MSR_ARCH_CAPABILITIES 0x10a
#define MSR_ARCH_CAPABILITIES_RDCL_NO (1ULL << 0)
@@ -151,7 +156,9 @@ MSRQuery;
#define MSR_TSX_CTRL_RTM_DISABLE (1ULL << 0)
#define MSR_TSX_CTRL_CPUID_CLEAR (1ULL << 1)
#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
@@ -486,7 +493,9 @@ MSRQuery;
#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
@@ -658,7 +667,9 @@ MSRQuery;
#define MSR_HYPERV_GUESTOSID_OS_WINNT_DERIVATIVE 4ULL
/* MSR for forcing RTM abort to recover PMC3 (see PR 2333817) */
#ifndef MSR_TSX_FORCE_ABORT
#define MSR_TSX_FORCE_ABORT 0x0000010f
#endif
#define MSR_TSX_FORCE_ABORT_RTM_BIT_INDEX 0
/*
@@ -712,7 +723,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
+2 -3
View File
@@ -676,7 +676,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;
@@ -799,7 +799,6 @@ LinuxDriver_Ioctl(struct file *filp, // IN:
} else {
device->vm = vm;
args.vmid = vm->userID;
vm->vmhost->vmmonData = (void *__user)args.vmmonData;
retval = HostIF_CopyToUser((VA64)ioarg, &args, sizeof args);
}
break;
@@ -1257,7 +1256,7 @@ LinuxDriver_Ioctl(struct file *filp, // IN:
}
case IOCTL_VMX86_WRITE_PAGE: {
#if VMX86_DEVEL
#ifdef VMX86_DEVEL
VMMReadWritePage req;
retval = HostIF_CopyFromUser(&req, ioarg, sizeof req);
+47 -63
View File
@@ -48,6 +48,7 @@
#include <asm/io.h>
#include <asm/page.h>
#include <asm/uaccess.h>
#include <asm/irq_vectors.h>
#include <linux/capability.h>
#include <linux/kthread.h>
#include <linux/wait.h>
@@ -76,6 +77,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
@@ -2347,23 +2349,16 @@ HostIF_VMLockIsHeld(VMDriver *vm) // IN
static Bool
isVAReadable(VA r) // IN:
{
mm_segment_t old_fs;
uint32 dummy;
int ret;
r = APICR_TO_ADDR(r, APICR_VERSION);
#ifdef HAVE_GET_KERNEL_NOFAULT
ret = get_kernel_nofault(dummy, (void *)r);
#else
{
mm_segment_t old_fs;
old_fs = get_fs();
set_fs(KERNEL_DS);
r = APICR_TO_ADDR(r, APICR_VERSION);
ret = HostIF_CopyFromUser(&dummy, r, sizeof dummy);
set_fs(old_fs);
}
#endif
return ret == 0;
}
#endif
@@ -2529,10 +2524,8 @@ HostIF_GetPerfCtrVector(void)
* Perform the semaphore wait (P) operation, possibly blocking.
*
* Result:
* On success: MX_WAITINTERRUPTED (3) if interrupted by a Unix signal.
* MX_WAITTIMEDOUT (2) if the timeout occurred.
* MX_WAITNORMAL (1) if the event was raised.
* On error: MX_WAITERROR (0) on generic error.
* 1 (which equals MX_WAITNORMAL) if success,
* negated error code otherwise.
*
* Side-effects:
* None
@@ -2559,15 +2552,10 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
if (file == NULL) {
return MX_WAITERROR;
}
if (file->f_op->poll == NULL) {
fput(file);
Warning("%s: File poll operation is NULL\n", __func__);
return MX_WAITERROR;
}
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
@@ -2588,17 +2576,18 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
#else
res = kernel_read(file, &value, sizeof value, &file->f_pos);
#endif
if (res == sizeof value) {
res = MX_WAITNORMAL;
} else {
if (res == 0) {
res = -EBADF;
}
}
fput(file);
if (res == sizeof value) {
return MX_WAITNORMAL;
}
if (res == 0) {
res = -EBADF;
}
/*
* Handle various errors:
* Handle benign errors:
* EAGAIN is MX_WAITTIMEDOUT.
* The signal-related errors are all mapped into MX_WAITINTERRUPTED.
*/
@@ -2617,10 +2606,6 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
case -EBADF:
res = MX_WAITERROR;
break;
default:
Warning("Unexpected error: %s err=%d\n", __FUNCTION__, res);
res = MX_WAITERROR;
break;
}
return res;
}
@@ -2674,6 +2659,7 @@ HostIF_SemaphoreForceWakeup(VMDriver *vm, // IN:
* On error: MX_WAITINTERRUPTED (3) if interrupted by a Unix signal (we
* can block on a preemptive kernel).
* MX_WAITERROR (0) on generic error.
* Negated system error (< 0).
*
* Side-effects:
* None
@@ -2682,64 +2668,57 @@ HostIF_SemaphoreForceWakeup(VMDriver *vm, // IN:
*/
int
HostIF_SemaphoreSignal(VMDriver *vm, // IN:
uint64 *args) // IN:
HostIF_SemaphoreSignal(uint64 *args) // IN:
{
struct file *file;
int res;
int signalFD = args[1];
struct file *file;
uint64 value = 1; // make an eventfd happy should it be there
file = vmware_fget(signalFD);
if (file == NULL) {
return FALSE;
if (!file) {
return MX_WAITERROR;
}
/*
* Always write sizeof(uint64) bytes. This works fine for eventfd and
* pipes. The data written is formatted to make an eventfd happy should
* it be present.
*
* Upstream Linux changed the function parameter types/ordering in 4.14.0.
*/
if (file->f_op->write != NULL) {
/*
* PR2650348 - The kernel_write function signature changed in the vanilla
* kernel in 4.14.0 and the signature update was backported before that
* point in a kernel used by OpenSUSE 15.1 so call the function directly
* instead of via the wrapper.
*
* Kernel 5.10 removed the set_fs functionality which means a user pointer
* must be passed into the write function or a -EFAULT will be returned.
*/
res = file->f_op->write(file, vm->vmhost->vmmonData, sizeof (uint64),
&file->f_pos);
} else {
Warning("%s: File write operation is NULL\n", __func__);
res = -ENOTSUPP;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
res = kernel_write(file, (char *)&value, sizeof value, file->f_pos);
#else
res = kernel_write(file, &value, sizeof value, &file->f_pos);
#endif
if (res == sizeof value) {
res = MX_WAITNORMAL;
}
fput(file);
if (res == sizeof (uint64)) {
return MX_WAITNORMAL;
}
/*
* Handle various errors:
* Handle benign errors:
* EAGAIN is MX_WAITTIMEDOUT.
* The signal-related errors are all mapped into MX_WAITINTERRUPTED.
*/
switch (res) {
case -EAGAIN:
/* The pipe is full, so it is already signalled. Success. */
return MX_WAITNORMAL;
// The pipe is full, so it is already signalled. Success.
res = MX_WAITNORMAL;
break;
case -EINTR:
case -ERESTART:
case -ERESTARTSYS:
case -ERESTARTNOINTR:
case -ERESTARTNOHAND:
return MX_WAITINTERRUPTED;
default:
Warning("Unexpected error: %s err=%d\n", __FUNCTION__, res);
return MX_WAITERROR;
res = MX_WAITINTERRUPTED;
break;
}
return res;
}
@@ -3264,9 +3243,12 @@ static int
HostIFFastClockThread(void *unused) // IN:
{
int res;
mm_segment_t oldFS;
unsigned int rate = 0;
unsigned int prevRate = 0;
oldFS = get_fs();
set_fs(KERNEL_DS);
allow_signal(SIGKILL);
while ((rate = linuxState.fastClockRate) > MIN_RATE) {
@@ -3289,6 +3271,8 @@ HostIFFastClockThread(void *unused) // IN:
}
out:
set_fs(oldFS);
/*
* Do not exit thread until we are told to do so.
*/
-5
View File
@@ -92,11 +92,6 @@ typedef struct VMHost {
* as pages for "AWE" guest memory.
*/
struct PhysTracker *AWEPages;
/*
* Pointer to a userlevel 64-bit area containing the value 1.
* This is used for HostIF_SemaphoreSignal.
*/
void *__user vmmonData;
} VMHost;
#endif
+2 -8
View File
@@ -180,7 +180,7 @@ skipTaskSwitch:;
}
case MODULECALL_SEMASIGNAL: {
retval = HostIF_SemaphoreSignal(vm, crosspage->args);
retval = HostIF_SemaphoreSignal(crosspage->args);
if (retval == MX_WAITINTERRUPTED) {
crosspage->moduleCallInterrupted = TRUE;
@@ -362,13 +362,7 @@ skipTaskSwitch:;
default:
Warning("ModuleCall %d not supported\n", crosspage->moduleCallType);
}
if (retval != (uint64)((uint32)retval)) {
Warning("Unexpected error in modulecall %u (%llu)\n",
crosspage->moduleCallType, retval);
bailValue = USERCALL_SWITCHERR;
goto bailOut;
}
ASSERT(retval == (uint64)((uint32)retval));
crosspage->retval = (uint32)retval;
#if defined(__linux__)
cond_resched(); // Other kernels are preemptible
+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
+6 -7
View File
@@ -66,7 +66,7 @@
#endif
#if LOGLEVEL >= 4
static struct timeval vnetTime;
static u64 vnetTime;
#endif
typedef struct VNetBridge VNetBridge;
@@ -693,7 +693,7 @@ VNetBridgeReceiveFromVNet(VNetJack *this, // IN: jack
netif_rx_ni(clone);
# if LOGLEVEL >= 4
do_gettimeofday(&vnetTime);
vnetTime = ktime_get_ns();
# endif
}
}
@@ -1490,12 +1490,11 @@ VNetBridgeReceiveFromDev(struct sk_buff *skb, // IN: packet to receive
# if LOGLEVEL >= 4
{
struct timeval now;
do_gettimeofday(&now);
u64 now;
now = ktime_get_ns();
LOG(3, (KERN_DEBUG "bridge-%s: time %d\n",
bridge->name,
(int)((now.tv_sec * 1000000 + now.tv_usec)
- (vnetTime.tv_sec * 1000000 + vnetTime.tv_usec))));
bridge->name, (int)((now - vnetTime) / NSEC_PER_USEC)));
}
# endif
+2 -2
View File
@@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2002,2018,2020 VMware, Inc. All rights reserved.
* Copyright (C) 2002,2018 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
@@ -4327,7 +4327,7 @@ LookupTypeClass(unsigned short typeValue) // IN: ethernet type
*----------------------------------------------------------------------
*/
#ifdef _WIN32
#if _WIN32
_Use_decl_annotations_
#endif
void
-11
View File
@@ -561,12 +561,7 @@ VNetCsumCopyDatagram(const struct sk_buff *skb, // IN: skb to copy
return -EINVAL;
}
#if COMPAT_LINUX_VERSION_CHECK_LT(5, 10, 0)
csum = csum_and_copy_to_user(skb->data + offset, curr, len, 0, &err);
#else
csum = csum_and_copy_to_user(skb->data + offset, curr, len);
err = (csum == 0) ? -EFAULT : 0;
#endif
if (err) {
return err;
}
@@ -580,14 +575,8 @@ VNetCsumCopyDatagram(const struct sk_buff *skb, // IN: skb to copy
const void *vaddr;
vaddr = kmap(skb_frag_page(frag));
#if COMPAT_LINUX_VERSION_CHECK_LT(5, 10, 0)
tmpCsum = csum_and_copy_to_user(vaddr + skb_frag_off(frag),
curr, skb_frag_size(frag), 0, &err);
#else
tmpCsum = csum_and_copy_to_user(vaddr + skb_frag_off(frag),
curr, skb_frag_size(frag));
err = (tmpCsum == 0) ? -EFAULT : 0;
#endif
kunmap(skb_frag_page(frag));
if (err) {
+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_SVGA3 0x0406
#define PCI_DEVICE_ID_VMWARE_SVGA2 0x0405
#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710
@@ -71,7 +76,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