|
| 1 | +commit 47fee9325e3b5feed0dbc4ba9e2de77c6d55e3bb |
| 2 | +Author: vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> |
| 3 | +Date: Wed May 17 09:42:23 2017 +0000 |
| 4 | + |
| 5 | + Runtime/r0drv: Linux 4.12 5-level page table adaptions |
| 6 | + |
| 7 | + |
| 8 | + git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@66927 cfe28804-0f27-0410-a406-dd0f0b0b656f |
| 9 | + |
| 10 | +diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c |
| 11 | +index 28dc33f963..41ed058860 100644 |
| 12 | +--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c |
| 13 | ++++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c |
| 14 | +@@ -902,6 +902,9 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv) |
| 15 | + union |
| 16 | + { |
| 17 | + pgd_t Global; |
| 18 | ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) |
| 19 | ++ p4d_t Four; |
| 20 | ++#endif |
| 21 | + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11) |
| 22 | + pud_t Upper; |
| 23 | + #endif |
| 24 | +@@ -917,12 +920,26 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv) |
| 25 | + u.Global = *pgd_offset(current->active_mm, ulAddr); |
| 26 | + if (RT_UNLIKELY(pgd_none(u.Global))) |
| 27 | + return NULL; |
| 28 | +- |
| 29 | +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11) |
| 30 | ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) |
| 31 | ++ u.Four = *p4d_offset(&u.Global, ulAddr); |
| 32 | ++ if (RT_UNLIKELY(p4d_none(u.Four))) |
| 33 | ++ return NULL; |
| 34 | ++ if (p4d_large(u.Four)) |
| 35 | ++ { |
| 36 | ++ pPage = p4d_page(u.Four); |
| 37 | ++ AssertReturn(pPage, NULL); |
| 38 | ++ pfn = page_to_pfn(pPage); /* doing the safe way... */ |
| 39 | ++ AssertCompile(P4D_SHIFT - PAGE_SHIFT < 31); |
| 40 | ++ pfn += (ulAddr >> PAGE_SHIFT) & ((UINT32_C(1) << (P4D_SHIFT - PAGE_SHIFT)) - 1); |
| 41 | ++ return pfn_to_page(pfn); |
| 42 | ++ } |
| 43 | ++ u.Upper = *pud_offset(&u.Four, ulAddr); |
| 44 | ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11) |
| 45 | + u.Upper = *pud_offset(&u.Global, ulAddr); |
| 46 | ++#endif |
| 47 | + if (RT_UNLIKELY(pud_none(u.Upper))) |
| 48 | + return NULL; |
| 49 | +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) |
| 50 | ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) |
| 51 | + if (pud_large(u.Upper)) |
| 52 | + { |
| 53 | + pPage = pud_page(u.Upper); |
| 54 | +@@ -931,8 +948,8 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv) |
| 55 | + pfn += (ulAddr >> PAGE_SHIFT) & ((UINT32_C(1) << (PUD_SHIFT - PAGE_SHIFT)) - 1); |
| 56 | + return pfn_to_page(pfn); |
| 57 | + } |
| 58 | +-# endif |
| 59 | +- |
| 60 | ++#endif |
| 61 | ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11) |
| 62 | + u.Middle = *pmd_offset(&u.Upper, ulAddr); |
| 63 | + #else /* < 2.6.11 */ |
| 64 | + u.Middle = *pmd_offset(&u.Global, ulAddr); |
| 65 | +diff --git a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h |
| 66 | +index 5afdee9e71..20aab0817f 100644 |
| 67 | +--- a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h |
| 68 | ++++ b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h |
| 69 | +@@ -159,6 +159,11 @@ |
| 70 | + # include <asm/tlbflush.h> |
| 71 | + #endif |
| 72 | + |
| 73 | ++/* for set_pages_x() */ |
| 74 | ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) |
| 75 | ++# include <asm/set_memory.h> |
| 76 | ++#endif |
| 77 | ++ |
| 78 | + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) |
| 79 | + # include <asm/smap.h> |
| 80 | + #else |
0 commit comments