|
Line
Link Here
|
| 0 |
-- a/vboxdrv/r0drv/linux/memobj-r0drv-linux.c |
0 |
++ b/vboxdrv/r0drv/linux/memobj-r0drv-linux.c |
|
Lines 1-4
Link Here
|
| 1 |
/* $Id: memobj-r0drv-linux.c 103604 2015-10-22 13:10:56Z bird $ */ |
1 |
/* $Id: memobj-r0drv-linux.c 60457 2016-04-12 13:27:21Z vboxsync $ */ |
| 2 |
/** @file |
2 |
/** @file |
| 3 |
* IPRT - Ring-0 Memory Objects, Linux. |
3 |
* IPRT - Ring-0 Memory Objects, Linux. |
| 4 |
*/ |
4 |
*/ |
|
Lines 372-382
Link Here
|
| 372 |
#endif /* < 2.4.22 */ |
372 |
#endif /* < 2.4.22 */ |
| 373 |
pMemLnx->fContiguous = fContiguous; |
373 |
pMemLnx->fContiguous = fContiguous; |
| 374 |
|
374 |
|
|
|
375 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) |
| 375 |
/* |
376 |
/* |
| 376 |
* Reserve the pages. |
377 |
* Reserve the pages. |
|
|
378 |
* |
| 379 |
* Linux >= 4.5 with CONFIG_DEBUG_VM panics when setting PG_reserved on compound |
| 380 |
* pages. According to Michal Hocko this shouldn't be necessary anyway because |
| 381 |
* as pages which are not on the LRU list are never evictable. |
| 377 |
*/ |
382 |
*/ |
| 378 |
for (iPage = 0; iPage < cPages; iPage++) |
383 |
for (iPage = 0; iPage < cPages; iPage++) |
| 379 |
SetPageReserved(pMemLnx->apPages[iPage]); |
384 |
SetPageReserved(pMemLnx->apPages[iPage]); |
|
|
385 |
#endif |
| 380 |
|
386 |
|
| 381 |
/* |
387 |
/* |
| 382 |
* Note that the physical address of memory allocated with alloc_pages(flags, order) |
388 |
* Note that the physical address of memory allocated with alloc_pages(flags, order) |
|
Lines 423-429
Link Here
|
| 423 |
*/ |
429 |
*/ |
| 424 |
while (iPage-- > 0) |
430 |
while (iPage-- > 0) |
| 425 |
{ |
431 |
{ |
|
|
432 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0) |
| 433 |
/* |
| 434 |
* See SetPageReserved() in rtR0MemObjLinuxAllocPages() |
| 435 |
*/ |
| 426 |
ClearPageReserved(pMemLnx->apPages[iPage]); |
436 |
ClearPageReserved(pMemLnx->apPages[iPage]); |
|
|
437 |
#endif |
| 427 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) |
438 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) |
| 428 |
#else |
439 |
#else |
| 429 |
MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1); |
440 |
MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1); |
|
Lines 578-584
Link Here
|
| 578 |
{ |
589 |
{ |
| 579 |
if (!PageReserved(pMemLnx->apPages[iPage])) |
590 |
if (!PageReserved(pMemLnx->apPages[iPage])) |
| 580 |
SetPageDirty(pMemLnx->apPages[iPage]); |
591 |
SetPageDirty(pMemLnx->apPages[iPage]); |
|
|
592 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) |
| 593 |
put_page(pMemLnx->apPages[iPage]); |
| 594 |
#else |
| 581 |
page_cache_release(pMemLnx->apPages[iPage]); |
595 |
page_cache_release(pMemLnx->apPages[iPage]); |
|
|
596 |
#endif |
| 582 |
} |
597 |
} |
| 583 |
|
598 |
|
| 584 |
if (pTask && pTask->mm) |
599 |
if (pTask && pTask->mm) |
|
Lines 1029-1042
Link Here
|
| 1029 |
/* |
1044 |
/* |
| 1030 |
* Get user pages. |
1045 |
* Get user pages. |
| 1031 |
*/ |
1046 |
*/ |
| 1032 |
rc = get_user_pages(pTask, /* Task for fault accounting. */ |
1047 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) |
| 1033 |
pTask->mm, /* Whose pages. */ |
1048 |
if (R0Process == RTR0ProcHandleSelf()) |
| 1034 |
R3Ptr, /* Where from. */ |
1049 |
rc = get_user_pages(R3Ptr, /* Where from. */ |
| 1035 |
cPages, /* How many pages. */ |
1050 |
cPages, /* How many pages. */ |
| 1036 |
fWrite, /* Write to memory. */ |
1051 |
fWrite, /* Write to memory. */ |
| 1037 |
fWrite, /* force write access. */ |
1052 |
fWrite, /* force write access. */ |
| 1038 |
&pMemLnx->apPages[0], /* Page array. */ |
1053 |
&pMemLnx->apPages[0], /* Page array. */ |
| 1039 |
papVMAs); /* vmas */ |
1054 |
papVMAs); /* vmas */ |
|
|
1055 |
/* |
| 1056 |
* Actually this should not happen at the moment as call this function |
| 1057 |
* only for our own process. |
| 1058 |
*/ |
| 1059 |
else |
| 1060 |
rc = get_user_pages_remote( |
| 1061 |
pTask, /* Task for fault accounting. */ |
| 1062 |
pTask->mm, /* Whose pages. */ |
| 1063 |
R3Ptr, /* Where from. */ |
| 1064 |
cPages, /* How many pages. */ |
| 1065 |
fWrite, /* Write to memory. */ |
| 1066 |
fWrite, /* force write access. */ |
| 1067 |
&pMemLnx->apPages[0], /* Page array. */ |
| 1068 |
papVMAs); /* vmas */ |
| 1069 |
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) */ |
| 1070 |
rc = get_user_pages(pTask, /* Task for fault accounting. */ |
| 1071 |
pTask->mm, /* Whose pages. */ |
| 1072 |
R3Ptr, /* Where from. */ |
| 1073 |
cPages, /* How many pages. */ |
| 1074 |
fWrite, /* Write to memory. */ |
| 1075 |
fWrite, /* force write access. */ |
| 1076 |
&pMemLnx->apPages[0], /* Page array. */ |
| 1077 |
papVMAs); /* vmas */ |
| 1078 |
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) */ |
| 1040 |
if (rc == cPages) |
1079 |
if (rc == cPages) |
| 1041 |
{ |
1080 |
{ |
| 1042 |
/* |
1081 |
/* |
|
Lines 1081-1087
Link Here
|
| 1081 |
{ |
1120 |
{ |
| 1082 |
if (!PageReserved(pMemLnx->apPages[rc])) |
1121 |
if (!PageReserved(pMemLnx->apPages[rc])) |
| 1083 |
SetPageDirty(pMemLnx->apPages[rc]); |
1122 |
SetPageDirty(pMemLnx->apPages[rc]); |
|
|
1123 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) |
| 1124 |
put_page(pMemLnx->apPages[rc]); |
| 1125 |
#else |
| 1084 |
page_cache_release(pMemLnx->apPages[rc]); |
1126 |
page_cache_release(pMemLnx->apPages[rc]); |
|
|
1127 |
#endif |
| 1085 |
} |
1128 |
} |
| 1086 |
|
1129 |
|
| 1087 |
up_read(&pTask->mm->mmap_sem); |
1130 |
up_read(&pTask->mm->mmap_sem); |