Compare commits
1
Commits
p16.0.0-k4.9
...
player
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31c032e989 |
No files matched your search
@@ -47,11 +47,9 @@
|
||||
|
||||
#ifdef __linux__
|
||||
# include "driver-config.h"
|
||||
/*
|
||||
* linux/frame.h dates back to 4.5-rc5, we need the ANNOTATE_INTRA_FUNCTION_CALL
|
||||
* definition from it which came in with 5.7.
|
||||
*/
|
||||
# if LINUX_VERSION_CODE > KERNEL_VERSION(5, 7, 0)
|
||||
# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
|
||||
# include <linux/objtool.h>
|
||||
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
|
||||
# include <linux/frame.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,7 @@ EXTERN int HostIF_SemaphoreWait(VMDriver *vm,
|
||||
Vcpuid vcpuid,
|
||||
uint64 *args);
|
||||
|
||||
EXTERN int HostIF_SemaphoreSignal(uint64 *args);
|
||||
EXTERN int HostIF_SemaphoreSignal(VMDriver *vm, uint64 *args);
|
||||
|
||||
EXTERN void HostIF_SemaphoreForceWakeup(VMDriver *vm, const VCPUSet *vcs);
|
||||
EXTERN void HostIF_IPI(VMDriver *vm, const VCPUSet *vcs);
|
||||
|
||||
@@ -148,7 +148,7 @@ PtrToVA64(void const *ptr) // IN
|
||||
* the NT specific VMX86_DRIVER_VERSION.
|
||||
*/
|
||||
|
||||
#define VMMON_VERSION (398 << 16 | 0)
|
||||
#define VMMON_VERSION (401 << 16 | 0)
|
||||
#define VMMON_VERSION_MAJOR(v) ((uint32) (v) >> 16)
|
||||
#define VMMON_VERSION_MINOR(v) ((uint16) (v))
|
||||
|
||||
@@ -533,6 +533,8 @@ 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.
|
||||
|
||||
@@ -421,9 +421,7 @@ VMCrossPageData;
|
||||
|
||||
#define MX_WAITINTERRUPTED 3
|
||||
#define MX_WAITTIMEDOUT 2
|
||||
#define MX_WAITNORMAL 1 // Must equal one; see linux module code.
|
||||
#define MX_WAITERROR 0 // Use MX_ISWAITERROR() to test for error.
|
||||
#define MX_WAITNORMAL 1
|
||||
#define MX_WAITERROR 0
|
||||
|
||||
// Any zero or negative value denotes error.
|
||||
#define MX_ISWAITERROR(e) ((e) <= MX_WAITERROR)
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*********************************************************
|
||||
* Copyright (C) 2002-2019 VMware, Inc. All rights reserved.
|
||||
* Copyright (C) 2002-2020 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,10 +44,11 @@
|
||||
# include "str.h" /* Str_Snprintf */
|
||||
# define VCS_SNPRINTF Str_Snprintf
|
||||
#elif defined MONITOR_APP
|
||||
# include <stdio.h> /* libc snprintf */
|
||||
# if defined WIN32
|
||||
# define VCS_SNPRINTF _snprintf
|
||||
# include "str.h" /* Str_Snprintf */
|
||||
# define VCS_SNPRINTF Str_Snprintf
|
||||
# else
|
||||
# include <stdio.h> /* libc snprintf */
|
||||
# define VCS_SNPRINTF snprintf
|
||||
# endif
|
||||
#elif defined VMM || defined VMKERNEL
|
||||
|
||||
@@ -799,6 +799,7 @@ 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;
|
||||
|
||||
+62
-44
@@ -2347,16 +2347,23 @@ 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
|
||||
@@ -2522,8 +2529,10 @@ HostIF_GetPerfCtrVector(void)
|
||||
* Perform the semaphore wait (P) operation, possibly blocking.
|
||||
*
|
||||
* Result:
|
||||
* 1 (which equals MX_WAITNORMAL) if success,
|
||||
* negated error code otherwise.
|
||||
* 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.
|
||||
*
|
||||
* Side-effects:
|
||||
* None
|
||||
@@ -2550,6 +2559,11 @@ 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;
|
||||
@@ -2574,18 +2588,17 @@ 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 benign errors:
|
||||
* Handle various errors:
|
||||
* EAGAIN is MX_WAITTIMEDOUT.
|
||||
* The signal-related errors are all mapped into MX_WAITINTERRUPTED.
|
||||
*/
|
||||
@@ -2604,6 +2617,10 @@ 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;
|
||||
}
|
||||
@@ -2657,7 +2674,6 @@ 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
|
||||
@@ -2666,57 +2682,64 @@ HostIF_SemaphoreForceWakeup(VMDriver *vm, // IN:
|
||||
*/
|
||||
|
||||
int
|
||||
HostIF_SemaphoreSignal(uint64 *args) // IN:
|
||||
HostIF_SemaphoreSignal(VMDriver *vm, // IN:
|
||||
uint64 *args) // IN:
|
||||
{
|
||||
struct file *file;
|
||||
int res;
|
||||
int signalFD = args[1];
|
||||
uint64 value = 1; // make an eventfd happy should it be there
|
||||
struct file *file;
|
||||
|
||||
file = vmware_fget(signalFD);
|
||||
if (!file) {
|
||||
return MX_WAITERROR;
|
||||
if (file == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 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;
|
||||
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;
|
||||
}
|
||||
|
||||
fput(file);
|
||||
|
||||
if (res == sizeof (uint64)) {
|
||||
return MX_WAITNORMAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle benign errors:
|
||||
* Handle various 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.
|
||||
res = MX_WAITNORMAL;
|
||||
break;
|
||||
/* The pipe is full, so it is already signalled. Success. */
|
||||
return MX_WAITNORMAL;
|
||||
case -EINTR:
|
||||
case -ERESTART:
|
||||
case -ERESTARTSYS:
|
||||
case -ERESTARTNOINTR:
|
||||
case -ERESTARTNOHAND:
|
||||
res = MX_WAITINTERRUPTED;
|
||||
break;
|
||||
return MX_WAITINTERRUPTED;
|
||||
default:
|
||||
Warning("Unexpected error: %s err=%d\n", __FUNCTION__, res);
|
||||
return MX_WAITERROR;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -3241,12 +3264,9 @@ 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) {
|
||||
@@ -3269,8 +3289,6 @@ HostIFFastClockThread(void *unused) // IN:
|
||||
}
|
||||
|
||||
out:
|
||||
set_fs(oldFS);
|
||||
|
||||
/*
|
||||
* Do not exit thread until we are told to do so.
|
||||
*/
|
||||
|
||||
@@ -92,6 +92,11 @@ 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
|
||||
@@ -180,7 +180,7 @@ skipTaskSwitch:;
|
||||
}
|
||||
|
||||
case MODULECALL_SEMASIGNAL: {
|
||||
retval = HostIF_SemaphoreSignal(crosspage->args);
|
||||
retval = HostIF_SemaphoreSignal(vm, crosspage->args);
|
||||
|
||||
if (retval == MX_WAITINTERRUPTED) {
|
||||
crosspage->moduleCallInterrupted = TRUE;
|
||||
@@ -362,7 +362,13 @@ skipTaskSwitch:;
|
||||
default:
|
||||
Warning("ModuleCall %d not supported\n", crosspage->moduleCallType);
|
||||
}
|
||||
ASSERT(retval == (uint64)((uint32)retval));
|
||||
|
||||
if (retval != (uint64)((uint32)retval)) {
|
||||
Warning("Unexpected error in modulecall %u (%llu)\n",
|
||||
crosspage->moduleCallType, retval);
|
||||
bailValue = USERCALL_SWITCHERR;
|
||||
goto bailOut;
|
||||
}
|
||||
crosspage->retval = (uint32)retval;
|
||||
#if defined(__linux__)
|
||||
cond_resched(); // Other kernels are preemptible
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*********************************************************
|
||||
* Copyright (C) 2002,2018 VMware, Inc. All rights reserved.
|
||||
* Copyright (C) 2002,2018,2020 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
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
_Use_decl_annotations_
|
||||
#endif
|
||||
void
|
||||
|
||||
@@ -561,7 +561,12 @@ 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;
|
||||
}
|
||||
@@ -575,8 +580,14 @@ 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) {
|
||||
|
||||
Reference in new issue
Block a user