Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/virtualbox-modules/, app-emulation/virtualbox-modules/files/
Date: Wed, 27 Nov 2019 12:18:03
Message-Id: 1574857032.9e99aae326f9512cf08560abd4f784b15baee850.polynomial-c@gentoo
1 commit: 9e99aae326f9512cf08560abd4f784b15baee850
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 27 12:17:12 2019 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 27 12:17:12 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9e99aae3
7
8 app-emulation/virtualbox-modules: Fixed build with kernel-5.4
9
10 Closes: https://bugs.gentoo.org/701154
11 Package-Manager: Portage-2.3.80, Repoman-2.3.18
12 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
13
14 .../virtualbox-modules-6.0.14-kernel-5.4_rc6.patch | 308 +++++++++++++++++++++
15 .../virtualbox-modules-6.0.14.ebuild | 4 +
16 2 files changed, 312 insertions(+)
17
18 diff --git a/app-emulation/virtualbox-modules/files/virtualbox-modules-6.0.14-kernel-5.4_rc6.patch b/app-emulation/virtualbox-modules/files/virtualbox-modules-6.0.14-kernel-5.4_rc6.patch
19 new file mode 100644
20 index 00000000000..2c52aa6757c
21 --- /dev/null
22 +++ b/app-emulation/virtualbox-modules/files/virtualbox-modules-6.0.14-kernel-5.4_rc6.patch
23 @@ -0,0 +1,308 @@
24 +https://www.virtualbox.org/changeset/81586/vbox
25 +https://www.virtualbox.org/changeset/81587/vbox
26 +https://www.virtualbox.org/changeset/81649/vbox (partially)
27 +
28 +--- 6.0.14/vboxdrv/include/iprt/cdefs.h
29 ++++ 6.0.14/vboxdrv/include/iprt/cdefs.h
30 +@@ -1166,7 +1166,7 @@
31 + * Tell the compiler that we're falling through to the next case in a switch.
32 + * @sa RT_FALL_THRU */
33 + #if RT_GNUC_PREREQ(7, 0)
34 +-# define RT_FALL_THROUGH() __attribute__((fallthrough))
35 ++# define RT_FALL_THROUGH() __attribute__((__fallthrough__))
36 + #else
37 + # define RT_FALL_THROUGH() (void)0
38 + #endif
39 +--- 6.0.14/vboxdrv/r0drv/linux/alloc-r0drv-linux.c
40 ++++ 6.0.14/vboxdrv/r0drv/linux/alloc-r0drv-linux.c
41 +@@ -443,9 +443,6 @@
42 + }
43 +
44 + SetPageReserved(&paPages[iPage]);
45 +-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 20) /** @todo find the exact kernel where change_page_attr was introduced. */
46 +- MY_SET_PAGES_EXEC(&paPages[iPage], 1);
47 +-#endif
48 + }
49 + *pPhys = page_to_phys(paPages);
50 + pvRet = phys_to_virt(page_to_phys(paPages));
51 +@@ -491,9 +488,6 @@
52 + for (iPage = 0; iPage < cPages; iPage++)
53 + {
54 + ClearPageReserved(&paPages[iPage]);
55 +-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 20) /** @todo find the exact kernel where change_page_attr was introduced. */
56 +- MY_SET_PAGES_NOEXEC(&paPages[iPage], 1);
57 +-#endif
58 + }
59 + __free_pages(paPages, cOrder);
60 + IPRT_LINUX_RESTORE_EFL_AC();
61 +--- 6.0.14/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
62 ++++ 6.0.14/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
63 +@@ -86,6 +86,8 @@
64 + /** Set if the allocation is contiguous.
65 + * This means it has to be given back as one chunk. */
66 + bool fContiguous;
67 ++ /** Set if executable allocation. */
68 ++ bool fExecutable;
69 + /** Set if we've vmap'ed the memory into ring-0. */
70 + bool fMappedToRing0;
71 + /** The pages in the apPages array. */
72 +@@ -289,10 +291,11 @@
73 + * Only valid if fContiguous == true, ignored otherwise.
74 + * @param fFlagsLnx The page allocation flags (GPFs).
75 + * @param fContiguous Whether the allocation must be contiguous.
76 ++ * @param fExecutable Whether the memory must be executable.
77 + * @param rcNoMem What to return when we're out of pages.
78 + */
79 + static int rtR0MemObjLinuxAllocPages(PRTR0MEMOBJLNX *ppMemLnx, RTR0MEMOBJTYPE enmType, size_t cb,
80 +- size_t uAlignment, gfp_t fFlagsLnx, bool fContiguous, int rcNoMem)
81 ++ size_t uAlignment, gfp_t fFlagsLnx, bool fContiguous, bool fExecutable, int rcNoMem)
82 + {
83 + size_t iPage;
84 + size_t const cPages = cb >> PAGE_SHIFT;
85 +@@ -371,7 +374,8 @@
86 + for (iPage = 0; iPage < cPages; iPage++)
87 + {
88 + pMemLnx->apPages[iPage] = &paPages[iPage];
89 +- MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1);
90 ++ if (fExecutable)
91 ++ MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1);
92 + if (PageHighMem(pMemLnx->apPages[iPage]))
93 + BUG();
94 + }
95 +@@ -379,6 +383,7 @@
96 + fContiguous = true;
97 + #endif /* < 2.4.22 */
98 + pMemLnx->fContiguous = fContiguous;
99 ++ pMemLnx->fExecutable = fExecutable;
100 +
101 + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
102 + /*
103 +@@ -409,7 +414,7 @@
104 + * This should never happen!
105 + */
106 + printk("rtR0MemObjLinuxAllocPages(cb=0x%lx, uAlignment=0x%lx): alloc_pages(..., %d) returned physical memory at 0x%lx!\n",
107 +- (unsigned long)cb, (unsigned long)uAlignment, rtR0MemObjLinuxOrder(cPages), (unsigned long)page_to_phys(pMemLnx->apPages[0]));
108 ++ (unsigned long)cb, (unsigned long)uAlignment, rtR0MemObjLinuxOrder(cPages), (unsigned long)page_to_phys(pMemLnx->apPages[0]));
109 + rtR0MemObjLinuxFreePages(pMemLnx);
110 + return rcNoMem;
111 + }
112 +@@ -438,14 +443,12 @@
113 + while (iPage-- > 0)
114 + {
115 + #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
116 +- /*
117 +- * See SetPageReserved() in rtR0MemObjLinuxAllocPages()
118 +- */
119 ++ /* See SetPageReserved() in rtR0MemObjLinuxAllocPages() */
120 + ClearPageReserved(pMemLnx->apPages[iPage]);
121 + #endif
122 +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
123 +-#else
124 +- MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);
125 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 22)
126 ++ if (pMemLnx->fExecutable)
127 ++ MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);
128 + #endif
129 + }
130 +
131 +@@ -662,10 +665,10 @@
132 +
133 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
134 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER,
135 +- false /* non-contiguous */, VERR_NO_MEMORY);
136 ++ false /* non-contiguous */, fExecutable, VERR_NO_MEMORY);
137 + #else
138 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_USER,
139 +- false /* non-contiguous */, VERR_NO_MEMORY);
140 ++ false /* non-contiguous */, fExecutable, VERR_NO_MEMORY);
141 + #endif
142 + if (RT_SUCCESS(rc))
143 + {
144 +@@ -696,19 +699,19 @@
145 + #if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
146 + /* ZONE_DMA32: 0-4GB */
147 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA32,
148 +- false /* non-contiguous */, VERR_NO_LOW_MEMORY);
149 ++ false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY);
150 + if (RT_FAILURE(rc))
151 + #endif
152 + #ifdef RT_ARCH_AMD64
153 + /* ZONE_DMA: 0-16MB */
154 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA,
155 +- false /* non-contiguous */, VERR_NO_LOW_MEMORY);
156 ++ false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY);
157 + #else
158 + # ifdef CONFIG_X86_PAE
159 + # endif
160 + /* ZONE_NORMAL: 0-896MB */
161 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_USER,
162 +- false /* non-contiguous */, VERR_NO_LOW_MEMORY);
163 ++ false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY);
164 + #endif
165 + if (RT_SUCCESS(rc))
166 + {
167 +@@ -738,17 +741,17 @@
168 + #if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
169 + /* ZONE_DMA32: 0-4GB */
170 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA32,
171 +- true /* contiguous */, VERR_NO_CONT_MEMORY);
172 ++ true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY);
173 + if (RT_FAILURE(rc))
174 + #endif
175 + #ifdef RT_ARCH_AMD64
176 + /* ZONE_DMA: 0-16MB */
177 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA,
178 +- true /* contiguous */, VERR_NO_CONT_MEMORY);
179 ++ true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY);
180 + #else
181 + /* ZONE_NORMAL (32-bit hosts): 0-896MB */
182 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_USER,
183 +- true /* contiguous */, VERR_NO_CONT_MEMORY);
184 ++ true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY);
185 + #endif
186 + if (RT_SUCCESS(rc))
187 + {
188 +@@ -795,7 +798,7 @@
189 +
190 + rc = rtR0MemObjLinuxAllocPages(&pMemLnx, enmType, cb, uAlignment, fGfp,
191 + enmType == RTR0MEMOBJTYPE_PHYS /* contiguous / non-contiguous */,
192 +- VERR_NO_PHYS_MEMORY);
193 ++ false /*fExecutable*/, VERR_NO_PHYS_MEMORY);
194 + if (RT_FAILURE(rc))
195 + return rc;
196 +
197 +--- 6.0.14/vboxdrv/r0drv/linux/the-linux-kernel.h
198 ++++ 6.0.14/vboxdrv/r0drv/linux/the-linux-kernel.h
199 +@@ -337,8 +337,10 @@
200 + #endif
201 +
202 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
203 +-# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
204 +-# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
205 ++# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
206 ++# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
207 ++# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
208 ++# endif
209 + #else
210 + # define MY_SET_PAGES_EXEC(pPages, cPages) \
211 + do { \
212 +--- 6.0.14/vboxdrv/r0drv/linux/thread2-r0drv-linux.c
213 ++++ 6.0.14/vboxdrv/r0drv/linux/thread2-r0drv-linux.c
214 +@@ -36,6 +36,9 @@
215 + #include <iprt/errcore.h>
216 + #include "internal/thread.h"
217 +
218 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
219 ++ #include <uapi/linux/sched/types.h>
220 ++#endif /* >= KERNEL_VERSION(4, 11, 0) */
221 +
222 + RTDECL(RTTHREAD) RTThreadSelf(void)
223 + {
224 +--- 6.0.14/vboxnetadp/include/iprt/cdefs.h
225 ++++ 6.0.14/vboxnetadp/include/iprt/cdefs.h
226 +@@ -1166,7 +1166,7 @@
227 + * Tell the compiler that we're falling through to the next case in a switch.
228 + * @sa RT_FALL_THRU */
229 + #if RT_GNUC_PREREQ(7, 0)
230 +-# define RT_FALL_THROUGH() __attribute__((fallthrough))
231 ++# define RT_FALL_THROUGH() __attribute__((__fallthrough__))
232 + #else
233 + # define RT_FALL_THROUGH() (void)0
234 + #endif
235 +--- 6.0.14/vboxnetadp/r0drv/linux/the-linux-kernel.h
236 ++++ 6.0.14/vboxnetadp/r0drv/linux/the-linux-kernel.h
237 +@@ -337,8 +337,10 @@
238 + #endif
239 +
240 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
241 +-# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
242 +-# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
243 ++# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
244 ++# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
245 ++# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
246 ++# endif
247 + #else
248 + # define MY_SET_PAGES_EXEC(pPages, cPages) \
249 + do { \
250 +--- 6.0.14/vboxnetflt/include/iprt/cdefs.h
251 ++++ 6.0.14/vboxnetflt/include/iprt/cdefs.h
252 +@@ -1166,7 +1166,7 @@
253 + * Tell the compiler that we're falling through to the next case in a switch.
254 + * @sa RT_FALL_THRU */
255 + #if RT_GNUC_PREREQ(7, 0)
256 +-# define RT_FALL_THROUGH() __attribute__((fallthrough))
257 ++# define RT_FALL_THROUGH() __attribute__((__fallthrough__))
258 + #else
259 + # define RT_FALL_THROUGH() (void)0
260 + #endif
261 +--- 6.0.14/vboxnetflt/linux/VBoxNetFlt-linux.c
262 ++++ 6.0.14/vboxnetflt/linux/VBoxNetFlt-linux.c
263 +@@ -924,8 +924,13 @@
264 + for (i = 0; i < skb_shinfo(pBuf)->nr_frags; i++)
265 + {
266 + skb_frag_t *pFrag = &skb_shinfo(pBuf)->frags[i];
267 ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
268 ++ pSG->aSegs[iSeg].cb = pFrag->bv_len;
269 ++ pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
270 ++# else /* < KERNEL_VERSION(5, 4, 0) */
271 + pSG->aSegs[iSeg].cb = pFrag->size;
272 + pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->page_offset;
273 ++# endif /* >= KERNEL_VERSION(5, 4, 0) */
274 + Log6((" %p", pSG->aSegs[iSeg].pv));
275 + pSG->aSegs[iSeg++].Phys = NIL_RTHCPHYS;
276 + Assert(iSeg <= pSG->cSegsAlloc);
277 +@@ -940,8 +945,13 @@
278 + for (i = 0; i < skb_shinfo(pFragBuf)->nr_frags; i++)
279 + {
280 + skb_frag_t *pFrag = &skb_shinfo(pFragBuf)->frags[i];
281 ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
282 ++ pSG->aSegs[iSeg].cb = pFrag->bv_len;
283 ++ pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
284 ++# else /* < KERNEL_VERSION(5, 4, 0) */
285 + pSG->aSegs[iSeg].cb = pFrag->size;
286 + pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->page_offset;
287 ++# endif /* >= KERNEL_VERSION(5, 4, 0) */
288 + Log6((" %p", pSG->aSegs[iSeg].pv));
289 + pSG->aSegs[iSeg++].Phys = NIL_RTHCPHYS;
290 + Assert(iSeg <= pSG->cSegsAlloc);
291 +--- 6.0.14/vboxnetflt/r0drv/linux/the-linux-kernel.h
292 ++++ 6.0.14/vboxnetflt/r0drv/linux/the-linux-kernel.h
293 +@@ -337,8 +337,10 @@
294 + #endif
295 +
296 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
297 +-# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
298 +-# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
299 ++# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
300 ++# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
301 ++# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
302 ++# endif
303 + #else
304 + # define MY_SET_PAGES_EXEC(pPages, cPages) \
305 + do { \
306 +--- 6.0.14/vboxpci/include/iprt/cdefs.h
307 ++++ 6.0.14/vboxpci/include/iprt/cdefs.h
308 +@@ -1166,7 +1166,7 @@
309 + * Tell the compiler that we're falling through to the next case in a switch.
310 + * @sa RT_FALL_THRU */
311 + #if RT_GNUC_PREREQ(7, 0)
312 +-# define RT_FALL_THROUGH() __attribute__((fallthrough))
313 ++# define RT_FALL_THROUGH() __attribute__((__fallthrough__))
314 + #else
315 + # define RT_FALL_THROUGH() (void)0
316 + #endif
317 +--- 6.0.14/vboxpci/r0drv/linux/the-linux-kernel.h
318 ++++ 6.0.14/vboxpci/r0drv/linux/the-linux-kernel.h
319 +@@ -337,8 +337,10 @@
320 + #endif
321 +
322 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
323 +-# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
324 +-# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
325 ++# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
326 ++# define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
327 ++# define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
328 ++# endif
329 + #else
330 + # define MY_SET_PAGES_EXEC(pPages, cPages) \
331 + do { \
332
333 diff --git a/app-emulation/virtualbox-modules/virtualbox-modules-6.0.14.ebuild b/app-emulation/virtualbox-modules/virtualbox-modules-6.0.14.ebuild
334 index 7257cb3b581..e98eef5b938 100644
335 --- a/app-emulation/virtualbox-modules/virtualbox-modules-6.0.14.ebuild
336 +++ b/app-emulation/virtualbox-modules/virtualbox-modules-6.0.14.ebuild
337 @@ -27,6 +27,10 @@ BUILD_TARGETS="all"
338 BUILD_TARGET_ARCH="${ARCH}"
339 MODULE_NAMES="vboxdrv(misc:${S}) vboxnetflt(misc:${S}) vboxnetadp(misc:${S}) vboxpci(misc:${S})"
340
341 +PATCHES=(
342 + "${FILESDIR}/${P}-kernel-5.4_rc6.patch"
343 +)
344 +
345 pkg_setup() {
346 enewgroup vboxusers
347 linux-mod_pkg_setup