Compare commits

...
Author SHA1 Message Date
Michal Kubecek be81b2f770 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-03-17 21:29:57 +01:00
Michal Kubecek d9bb126f7d 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-03-17 21:29:57 +01:00
Michal Kubecek d09d2d0188 modules: handle access_ok() with two arguments
Since commit 96d4f267e40f ("Remove 'type' argument from access_ok()
function") in v5.0-rc1, the type argument of access_ok() was dropped.
The same commit also dropped macros VERIFY_READ and VERIFY_WRITE so check
for their existence on pre-5.0 kernels to allow build against kernels with
this change backported.
2019-01-07 13:38:55 +01:00
Michal Kubecek 8b1156629b vmmon: 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 vmmon-only/linux/hostif.c.

This feels like a quick and clumsy band aid to allow build with post-4.20
kernels. On a closer look, the whole gymnastics around uptimeState and
HostIFReadUptimeWork() with jiffies and wall time checking and correcting
each other seems to be a workaround for an absence of high resolution
monotonic time. Considering ktime_get_ts64() is available since 3.17 and
before that, ktime_get_ts() since 2.6.17, perhaps the time has come to
clean all this machinery up. But something like this would be beyond the
scope of this repository.
2019-01-07 13:38:55 +01:00
Michal Kubecek 46911bde4f vmmon: totalram_pages is a function since 5.0
Since commit ca79b0c211af ("mm: convert totalram_pages and totalhigh_pages
variables to atomic") in v5.0-rc1, totalram_pages() is an accessor function
and the actual variable is an atomic.
2019-01-07 13:38:55 +01:00
Michal Kubecek ee5d329441 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-01-07 13:38:55 +01:00
5 changed files with 46 additions and 18 deletions

No files matched your search

+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
+6 -3
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);
@@ -594,7 +597,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
+31 -12
View File
@@ -181,6 +181,32 @@ static struct {
uint8 monitorIPIVector;
uint8 hvIPIVector;
static unsigned long compat_totalram_pages(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
return totalram_pages;
#else
return totalram_pages();
#endif
}
#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
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) && defined(VERIFY_WRITE)
#define write_access_ok(addr, size) access_ok(VERIFY_WRITE, addr, size)
#else
#define write_access_ok(addr, size) access_ok(addr, size)
#endif
/*
*-----------------------------------------------------------------------------
*
@@ -1495,14 +1521,7 @@ unsigned int
HostIF_EstimateLockedPageLimit(const VMDriver* vm, // IN
unsigned int currentlyLockedPages) // IN
{
/*
* This variable is available and exported to modules,
* since at least 2.6.0.
*/
extern unsigned long totalram_pages;
unsigned int totalPhysicalPages = totalram_pages;
unsigned int totalPhysicalPages = compat_totalram_pages();
/*
* Use the memory information linux exports as of late for a more
@@ -2165,7 +2184,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);
@@ -2366,7 +2385,7 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
}
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
{
struct poll_wqueues table;
@@ -2495,7 +2514,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
@@ -3201,7 +3220,7 @@ HostIF_MapUserMem(VA addr, // IN: User memory virtual address
ASSERT(handle);
if (!access_ok(VERIFY_WRITE, p, size)) {
if (!write_access_ok(p, size)) {
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
+7 -1
View File
@@ -85,6 +85,12 @@ extern unsigned int vnet_max_qlen;
# define compat_kunmap(page) kunmap((page).p)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) && defined(VERIFY_WRITE)
#define write_access_ok(addr, size) access_ok(VERIFY_WRITE, addr, size)
#else
#define write_access_ok(addr, size) access_ok(addr, size)
#endif
/*
*-----------------------------------------------------------------------------
*
@@ -142,7 +148,7 @@ VNetUserIfMapPtr(VA uAddr, // IN: pointer to user memory
struct page **p, // OUT: locked page
void **ptr) // OUT: kernel mapped pointer
{
if (!access_ok(VERIFY_WRITE, (void *)uAddr, size) ||
if (!write_access_ok((void *)uAddr, size) ||
(((uAddr + size - 1) & ~(PAGE_SIZE - 1)) !=
(uAddr & ~(PAGE_SIZE - 1)))) {
return -EINVAL;