VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c@ 14069

最後變更 在這個檔案從14069是 13994,由 vboxsync 提交於 16 年 前

better check

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Rev
檔案大小: 37.1 KB
 
1/* $Revision: 13994 $ */
2/** @file
3 * IPRT - Ring-0 Memory Objects, Linux.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include "the-linux-kernel.h"
36
37#include <iprt/memobj.h>
38#include <iprt/alloc.h>
39#include <iprt/assert.h>
40#include <iprt/log.h>
41#include <iprt/string.h>
42#include <iprt/process.h>
43#include "internal/memobj.h"
44
45/* early 2.6 kernels */
46#ifndef PAGE_SHARED_EXEC
47# define PAGE_SHARED_EXEC PAGE_SHARED
48#endif
49#ifndef PAGE_READONLY_EXEC
50# define PAGE_READONLY_EXEC PAGE_READONLY
51#endif
52
53
54/*******************************************************************************
55* Structures and Typedefs *
56*******************************************************************************/
57/**
58 * The Darwin version of the memory object structure.
59 */
60typedef struct RTR0MEMOBJLNX
61{
62 /** The core structure. */
63 RTR0MEMOBJINTERNAL Core;
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 we've vmap'ed thed memory into ring-0. */
68 bool fMappedToRing0;
69 /** The pages in the apPages array. */
70 size_t cPages;
71 /** Array of struct page pointers. (variable size) */
72 struct page *apPages[1];
73} RTR0MEMOBJLNX, *PRTR0MEMOBJLNX;
74
75
76/**
77 * Helper that converts from a RTR0PROCESS handle to a linux task.
78 *
79 * @returns The corresponding Linux task.
80 * @param R0Process IPRT ring-0 process handle.
81 */
82struct task_struct *rtR0ProcessToLinuxTask(RTR0PROCESS R0Process)
83{
84 /** @todo fix rtR0ProcessToLinuxTask!! */
85 return R0Process == RTR0ProcHandleSelf() ? current : NULL;
86}
87
88
89/**
90 * Compute order. Some functions allocate 2^order pages.
91 *
92 * @returns order.
93 * @param cPages Number of pages.
94 */
95static int rtR0MemObjLinuxOrder(size_t cPages)
96{
97 int iOrder;
98 size_t cTmp;
99
100 for (iOrder = 0, cTmp = cPages; cTmp >>= 1; ++iOrder)
101 ;
102 if (cPages & ~((size_t)1 << iOrder))
103 ++iOrder;
104
105 return iOrder;
106}
107
108
109/**
110 * Converts from RTMEM_PROT_* to Linux PAGE_*.
111 *
112 * @returns Linux page protection constant.
113 * @param fProt The IPRT protection mask.
114 * @param fKernel Whether it applies to kernel or user space.
115 */
116static pgprot_t rtR0MemObjLinuxConvertProt(unsigned fProt, bool fKernel)
117{
118 switch (fProt)
119 {
120 default:
121 AssertMsgFailed(("%#x %d\n", fProt, fKernel));
122 case RTMEM_PROT_NONE:
123 return PAGE_NONE;
124
125 case RTMEM_PROT_READ:
126 return fKernel ? PAGE_KERNEL_RO : PAGE_READONLY;
127
128 case RTMEM_PROT_WRITE:
129 case RTMEM_PROT_WRITE | RTMEM_PROT_READ:
130 return fKernel ? PAGE_KERNEL : PAGE_SHARED;
131
132 case RTMEM_PROT_EXEC:
133 case RTMEM_PROT_EXEC | RTMEM_PROT_READ:
134#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
135 if (fKernel)
136 {
137 pgprot_t fPg = MY_PAGE_KERNEL_EXEC;
138 pgprot_val(fPg) &= ~_PAGE_RW;
139 return fPg;
140 }
141 return PAGE_READONLY_EXEC;
142#else
143 return fKernel ? MY_PAGE_KERNEL_EXEC : PAGE_READONLY_EXEC;
144#endif
145
146 case RTMEM_PROT_WRITE | RTMEM_PROT_EXEC:
147 case RTMEM_PROT_WRITE | RTMEM_PROT_EXEC | RTMEM_PROT_READ:
148 return fKernel ? MY_PAGE_KERNEL_EXEC : PAGE_SHARED_EXEC;
149 }
150}
151
152
153/**
154 * Internal worker that allocates physical pages and creates the memory object for them.
155 *
156 * @returns IPRT status code.
157 * @param ppMemLnx Where to store the memory object pointer.
158 * @param enmType The object type.
159 * @param cb The number of bytes to allocate.
160 * @param fFlagsLnx The page allocation flags (GPFs).
161 * @param fContiguous Whether the allocation must be contiguous.
162 */
163static int rtR0MemObjLinuxAllocPages(PRTR0MEMOBJLNX *ppMemLnx, RTR0MEMOBJTYPE enmType, size_t cb, unsigned fFlagsLnx, bool fContiguous)
164{
165 size_t iPage;
166 size_t cPages = cb >> PAGE_SHIFT;
167 struct page *paPages;
168
169 /*
170 * Allocate a memory object structure that's large enough to contain
171 * the page pointer array.
172 */
173 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(RT_OFFSETOF(RTR0MEMOBJLNX, apPages[cPages]), enmType, NULL, cb);
174 if (!pMemLnx)
175 return VERR_NO_MEMORY;
176 pMemLnx->cPages = cPages;
177
178 /*
179 * Allocate the pages.
180 * For small allocations we'll try contiguous first and then fall back on page by page.
181 */
182#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
183 if ( fContiguous
184 || cb <= PAGE_SIZE * 2)
185 {
186#ifdef VBOX_USE_INSERT_PAGE
187 paPages = alloc_pages(fFlagsLnx | __GFP_COMP, rtR0MemObjLinuxOrder(cb >> PAGE_SHIFT));
188#else
189 paPages = alloc_pages(fFlagsLnx, rtR0MemObjLinuxOrder(cb >> PAGE_SHIFT));
190#endif
191 if (paPages)
192 {
193 fContiguous = true;
194 for (iPage = 0; iPage < cPages; iPage++)
195 pMemLnx->apPages[iPage] = &paPages[iPage];
196 }
197 else if (fContiguous)
198 {
199 rtR0MemObjDelete(&pMemLnx->Core);
200 return VERR_NO_MEMORY;
201 }
202 }
203
204 if (!fContiguous)
205 {
206 for (iPage = 0; iPage < cPages; iPage++)
207 {
208 pMemLnx->apPages[iPage] = alloc_page(fFlagsLnx);
209 if (RT_UNLIKELY(!pMemLnx->apPages[iPage]))
210 {
211 while (iPage-- > 0)
212 __free_page(pMemLnx->apPages[iPage]);
213 rtR0MemObjDelete(&pMemLnx->Core);
214 return VERR_NO_MEMORY;
215 }
216 }
217 }
218
219#else /* < 2.4.22 */
220 /** @todo figure out why we didn't allocate page-by-page on 2.4.21 and older... */
221 paPages = alloc_pages(fFlagsLnx, rtR0MemObjLinuxOrder(cb >> PAGE_SHIFT));
222 if (!paPages)
223 {
224 rtR0MemObjDelete(&pMemLnx->Core);
225 return VERR_NO_MEMORY;
226 }
227 for (iPage = 0; iPage < cPages; iPage++)
228 {
229 pMemLnx->apPages[iPage] = &paPages[iPage];
230 MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1);
231 if (PageHighMem(pMemLnx->apPages[iPage]))
232 BUG();
233 }
234
235 fContiguous = true;
236#endif /* < 2.4.22 */
237 pMemLnx->fContiguous = fContiguous;
238
239 /*
240 * Reserve the pages.
241 */
242 for (iPage = 0; iPage < cPages; iPage++)
243 SetPageReserved(pMemLnx->apPages[iPage]);
244
245 *ppMemLnx = pMemLnx;
246 return VINF_SUCCESS;
247}
248
249
250/**
251 * Frees the physical pages allocated by the rtR0MemObjLinuxAllocPages() call.
252 *
253 * This method does NOT free the object.
254 *
255 * @param pMemLnx The object which physical pages should be freed.
256 */
257static void rtR0MemObjLinuxFreePages(PRTR0MEMOBJLNX pMemLnx)
258{
259 size_t iPage = pMemLnx->cPages;
260 if (iPage > 0)
261 {
262 /*
263 * Restore the page flags.
264 */
265 while (iPage-- > 0)
266 {
267 ClearPageReserved(pMemLnx->apPages[iPage]);
268#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
269#else
270 MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);
271#endif
272 }
273
274 /*
275 * Free the pages.
276 */
277#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
278 if (!pMemLnx->fContiguous)
279 {
280 iPage = pMemLnx->cPages;
281 while (iPage-- > 0)
282 __free_page(pMemLnx->apPages[iPage]);
283 }
284 else
285#endif
286 __free_pages(pMemLnx->apPages[0], rtR0MemObjLinuxOrder(pMemLnx->cPages));
287
288 pMemLnx->cPages = 0;
289 }
290}
291
292
293/**
294 * Maps the allocation into ring-0.
295 *
296 * This will update the RTR0MEMOBJLNX::Core.pv and RTR0MEMOBJ::fMappedToRing0 members.
297 *
298 * Contiguous mappings that isn't in 'high' memory will already be mapped into kernel
299 * space, so we'll use that mapping if possible. If execute access is required, we'll
300 * play safe and do our own mapping.
301 *
302 * @returns IPRT status code.
303 * @param pMemLnx The linux memory object to map.
304 * @param fExecutable Whether execute access is required.
305 */
306static int rtR0MemObjLinuxVMap(PRTR0MEMOBJLNX pMemLnx, bool fExecutable)
307{
308 int rc = VINF_SUCCESS;
309
310 /*
311 * Choose mapping strategy.
312 */
313 bool fMustMap = fExecutable
314 || !pMemLnx->fContiguous;
315 if (!fMustMap)
316 {
317 size_t iPage = pMemLnx->cPages;
318 while (iPage-- > 0)
319 if (PageHighMem(pMemLnx->apPages[iPage]))
320 {
321 fMustMap = true;
322 break;
323 }
324 }
325
326 Assert(!pMemLnx->Core.pv);
327 Assert(!pMemLnx->fMappedToRing0);
328
329 if (fMustMap)
330 {
331 /*
332 * Use vmap - 2.4.22 and later.
333 */
334#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
335 pgprot_t fPg;
336 pgprot_val(fPg) = _PAGE_PRESENT | _PAGE_RW;
337# ifdef _PAGE_NX
338 if (!fExecutable)
339 pgprot_val(fPg) |= _PAGE_NX;
340# endif
341
342# ifdef VM_MAP
343 pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_MAP, fPg);
344# else
345 pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_ALLOC, fPg);
346# endif
347 if (pMemLnx->Core.pv)
348 pMemLnx->fMappedToRing0 = true;
349 else
350 rc = VERR_MAP_FAILED;
351#else /* < 2.4.22 */
352 rc = VERR_NOT_SUPPORTED;
353#endif
354 }
355 else
356 {
357 /*
358 * Use the kernel RAM mapping.
359 */
360 pMemLnx->Core.pv = phys_to_virt(page_to_phys(pMemLnx->apPages[0]));
361 Assert(pMemLnx->Core.pv);
362 }
363
364 return rc;
365}
366
367
368/**
369 * Undos what rtR0MemObjLinuxVMap() did.
370 *
371 * @param pMemLnx The linux memory object.
372 */
373static void rtR0MemObjLinuxVUnmap(PRTR0MEMOBJLNX pMemLnx)
374{
375#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
376 if (pMemLnx->fMappedToRing0)
377 {
378 Assert(pMemLnx->Core.pv);
379 vunmap(pMemLnx->Core.pv);
380 pMemLnx->fMappedToRing0 = false;
381 }
382#else /* < 2.4.22 */
383 Assert(!pMemLnx->fMappedToRing0);
384#endif
385 pMemLnx->Core.pv = NULL;
386}
387
388
389int rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
390{
391 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem;
392
393 /*
394 * Release any memory that we've allocated or locked.
395 */
396 switch (pMemLnx->Core.enmType)
397 {
398 case RTR0MEMOBJTYPE_LOW:
399 case RTR0MEMOBJTYPE_PAGE:
400 case RTR0MEMOBJTYPE_CONT:
401 case RTR0MEMOBJTYPE_PHYS:
402 case RTR0MEMOBJTYPE_PHYS_NC:
403 rtR0MemObjLinuxVUnmap(pMemLnx);
404 rtR0MemObjLinuxFreePages(pMemLnx);
405 break;
406
407 case RTR0MEMOBJTYPE_LOCK:
408 if (pMemLnx->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
409 {
410 size_t iPage;
411 struct task_struct *pTask = rtR0ProcessToLinuxTask(pMemLnx->Core.u.Lock.R0Process);
412 Assert(pTask);
413 if (pTask && pTask->mm)
414 down_read(&pTask->mm->mmap_sem);
415
416 iPage = pMemLnx->cPages;
417 while (iPage-- > 0)
418 {
419 if (!PageReserved(pMemLnx->apPages[iPage]))
420 SetPageDirty(pMemLnx->apPages[iPage]);
421 page_cache_release(pMemLnx->apPages[iPage]);
422 }
423
424 if (pTask && pTask->mm)
425 up_read(&pTask->mm->mmap_sem);
426 }
427 else
428 AssertFailed(); /* not implemented for R0 */
429 break;
430
431 case RTR0MEMOBJTYPE_RES_VIRT:
432 Assert(pMemLnx->Core.pv);
433 if (pMemLnx->Core.u.ResVirt.R0Process != NIL_RTR0PROCESS)
434 {
435 struct task_struct *pTask = rtR0ProcessToLinuxTask(pMemLnx->Core.u.Lock.R0Process);
436 Assert(pTask);
437 if (pTask && pTask->mm)
438 {
439 down_write(&pTask->mm->mmap_sem);
440 MY_DO_MUNMAP(pTask->mm, (unsigned long)pMemLnx->Core.pv, pMemLnx->Core.cb);
441 up_write(&pTask->mm->mmap_sem);
442 }
443 }
444 else
445 {
446 vunmap(pMemLnx->Core.pv);
447
448 Assert(pMemLnx->cPages == 1 && pMemLnx->apPages[0] != NULL);
449 __free_page(pMemLnx->apPages[0]);
450 pMemLnx->apPages[0] = NULL;
451 pMemLnx->cPages = 0;
452 }
453 pMemLnx->Core.pv = NULL;
454 break;
455
456 case RTR0MEMOBJTYPE_MAPPING:
457 Assert(pMemLnx->cPages == 0); Assert(pMemLnx->Core.pv);
458 if (pMemLnx->Core.u.ResVirt.R0Process != NIL_RTR0PROCESS)
459 {
460 struct task_struct *pTask = rtR0ProcessToLinuxTask(pMemLnx->Core.u.Lock.R0Process);
461 Assert(pTask);
462 if (pTask && pTask->mm)
463 {
464 down_write(&pTask->mm->mmap_sem);
465 MY_DO_MUNMAP(pTask->mm, (unsigned long)pMemLnx->Core.pv, pMemLnx->Core.cb);
466 up_write(&pTask->mm->mmap_sem);
467 }
468 }
469 else
470 vunmap(pMemLnx->Core.pv);
471 pMemLnx->Core.pv = NULL;
472 break;
473
474 default:
475 AssertMsgFailed(("enmType=%d\n", pMemLnx->Core.enmType));
476 return VERR_INTERNAL_ERROR;
477 }
478 return VINF_SUCCESS;
479}
480
481
482int rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
483{
484 PRTR0MEMOBJLNX pMemLnx;
485 int rc;
486
487#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
488 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, GFP_HIGHUSER, false /* non-contiguous */);
489#else
490 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, GFP_USER, false /* non-contiguous */);
491#endif
492 if (RT_SUCCESS(rc))
493 {
494 rc = rtR0MemObjLinuxVMap(pMemLnx, fExecutable);
495 if (RT_SUCCESS(rc))
496 {
497 *ppMem = &pMemLnx->Core;
498 return rc;
499 }
500
501 rtR0MemObjLinuxFreePages(pMemLnx);
502 rtR0MemObjDelete(&pMemLnx->Core);
503 }
504
505 return rc;
506}
507
508
509int rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
510{
511 PRTR0MEMOBJLNX pMemLnx;
512 int rc;
513
514#ifdef RT_ARCH_AMD64
515# ifdef GFP_DMA32
516 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_DMA32, false /* non-contiguous */);
517 if (RT_FAILURE(rc))
518# endif
519 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_DMA, false /* non-contiguous */);
520#else
521 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_USER, false /* non-contiguous */);
522#endif
523 if (RT_SUCCESS(rc))
524 {
525 rc = rtR0MemObjLinuxVMap(pMemLnx, fExecutable);
526 if (RT_SUCCESS(rc))
527 {
528 *ppMem = &pMemLnx->Core;
529 return rc;
530 }
531
532 rtR0MemObjLinuxFreePages(pMemLnx);
533 rtR0MemObjDelete(&pMemLnx->Core);
534 }
535
536 return rc;
537}
538
539
540int rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
541{
542 PRTR0MEMOBJLNX pMemLnx;
543 int rc;
544
545#ifdef RT_ARCH_AMD64
546# ifdef GFP_DMA32
547 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_DMA32, true /* contiguous */);
548 if (RT_FAILURE(rc))
549# endif
550 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_DMA, true /* contiguous */);
551#else
552 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_USER, true /* contiguous */);
553#endif
554 if (RT_SUCCESS(rc))
555 {
556 rc = rtR0MemObjLinuxVMap(pMemLnx, fExecutable);
557 if (RT_SUCCESS(rc))
558 {
559#if defined(RT_STRICT) && (defined(RT_ARCH_AMD64) || defined(CONFIG_HIGHMEM64G))
560 size_t iPage = pMemLnx->cPages;
561 while (iPage-- > 0)
562 Assert(page_to_phys(pMemLnx->apPages[iPage]) < _4G);
563#endif
564 pMemLnx->Core.u.Cont.Phys = page_to_phys(pMemLnx->apPages[0]);
565 *ppMem = &pMemLnx->Core;
566 return rc;
567 }
568
569 rtR0MemObjLinuxFreePages(pMemLnx);
570 rtR0MemObjDelete(&pMemLnx->Core);
571 }
572
573 return rc;
574}
575
576
577/**
578 * Worker for rtR0MemObjLinuxAllocPhysSub that tries one allocation strategy.
579 *
580 * @returns IPRT status.
581 * @param ppMemLnx Where to
582 * @param enmType The object type.
583 * @param cb The size of the allocation.
584 * @param PhysHighest See rtR0MemObjNativeAllocPhys.
585 * @param fGfp The Linux GFP flags to use for the allocation.
586 */
587static int rtR0MemObjLinuxAllocPhysSub2(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJTYPE enmType, size_t cb, RTHCPHYS PhysHighest, unsigned fGfp)
588{
589 PRTR0MEMOBJLNX pMemLnx;
590 int rc;
591
592 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, enmType, cb, fGfp,
593 enmType == RTR0MEMOBJTYPE_PHYS /* contiguous / non-contiguous */);
594 if (RT_FAILURE(rc))
595 return rc;
596
597 /*
598 * Check the addresses if necessary. (Can be optimized a bit for PHYS.)
599 */
600 if (PhysHighest != NIL_RTHCPHYS)
601 {
602 size_t iPage = pMemLnx->cPages;
603 while (iPage-- > 0)
604 if (page_to_phys(pMemLnx->apPages[iPage]) >= PhysHighest)
605 {
606 rtR0MemObjLinuxFreePages(pMemLnx);
607 rtR0MemObjDelete(&pMemLnx->Core);
608 return VERR_NO_MEMORY;
609 }
610 }
611
612 /*
613 * Complete the object.
614 */
615 if (enmType == RTR0MEMOBJTYPE_PHYS)
616 {
617 pMemLnx->Core.u.Phys.PhysBase = page_to_phys(pMemLnx->apPages[0]);
618 pMemLnx->Core.u.Phys.fAllocated = true;
619 }
620 *ppMem = &pMemLnx->Core;
621 return rc;
622}
623
624
625/**
626 * Worker for rtR0MemObjNativeAllocPhys and rtR0MemObjNativeAllocPhysNC.
627 *
628 * @returns IPRT status.
629 * @param ppMem Where to store the memory object pointer on success.
630 * @param enmType The object type.
631 * @param cb The size of the allocation.
632 * @param PhysHighest See rtR0MemObjNativeAllocPhys.
633 */
634static int rtR0MemObjLinuxAllocPhysSub(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJTYPE enmType, size_t cb, RTHCPHYS PhysHighest)
635{
636 int rc;
637
638 /*
639 * There are two clear cases and that's the <=16MB and anything-goes ones.
640 * When the physical address limit is somewhere inbetween those two we'll
641 * just have to try, starting with HIGHUSER and working our way thru the
642 * different types, hoping we'll get lucky.
643 *
644 * We should probably move this physical address restriction logic up to
645 * the page alloc function as it would be more efficient there. But since
646 * we don't expect this to be a performance issue just yet it can wait.
647 */
648 if (PhysHighest == NIL_RTHCPHYS)
649 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, PhysHighest, GFP_HIGHUSER);
650 else if (PhysHighest <= _1M * 16)
651 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, PhysHighest, GFP_DMA);
652 else
653 {
654 rc = VERR_NO_MEMORY;
655 if (RT_FAILURE(rc))
656 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, PhysHighest, GFP_HIGHUSER);
657 if (RT_FAILURE(rc))
658 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, PhysHighest, GFP_USER);
659#ifdef GFP_DMA32
660 if (RT_FAILURE(rc))
661 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, PhysHighest, GFP_DMA32);
662#endif
663 if (RT_FAILURE(rc))
664 rc = rtR0MemObjLinuxAllocPhysSub2(ppMem, enmType, cb, PhysHighest, GFP_DMA);
665 }
666 return rc;
667}
668
669
670int rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
671{
672 return rtR0MemObjLinuxAllocPhysSub(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest);
673}
674
675
676int rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
677{
678 return rtR0MemObjLinuxAllocPhysSub(ppMem, RTR0MEMOBJTYPE_PHYS_NC, cb, PhysHighest);
679}
680
681
682int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb)
683{
684 /*
685 * All we need to do here is to validate that we can use
686 * ioremap on the specified address (32/64-bit dma_addr_t).
687 */
688 PRTR0MEMOBJLNX pMemLnx;
689 dma_addr_t PhysAddr = Phys;
690 AssertMsgReturn(PhysAddr == Phys, ("%#llx\n", (unsigned long long)Phys), VERR_ADDRESS_TOO_BIG);
691
692 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_PHYS, NULL, cb);
693 if (!pMemLnx)
694 return VERR_NO_MEMORY;
695
696 pMemLnx->Core.u.Phys.PhysBase = PhysAddr;
697 pMemLnx->Core.u.Phys.fAllocated = false;
698 Assert(!pMemLnx->cPages);
699 *ppMem = &pMemLnx->Core;
700 return VINF_SUCCESS;
701}
702
703
704int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, RTR0PROCESS R0Process)
705{
706 const int cPages = cb >> PAGE_SHIFT;
707 struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process);
708 struct vm_area_struct **papVMAs;
709 PRTR0MEMOBJLNX pMemLnx;
710 int rc = VERR_NO_MEMORY;
711
712 /*
713 * Check for valid task and size overflows.
714 */
715 if (!pTask)
716 return VERR_NOT_SUPPORTED;
717 if (((size_t)cPages << PAGE_SHIFT) != cb)
718 return VERR_OUT_OF_RANGE;
719
720 /*
721 * Allocate the memory object and a temporary buffer for the VMAs.
722 */
723 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(RT_OFFSETOF(RTR0MEMOBJLNX, apPages[cPages]), RTR0MEMOBJTYPE_LOCK, (void *)R3Ptr, cb);
724 if (!pMemLnx)
725 return VERR_NO_MEMORY;
726
727 papVMAs = (struct vm_area_struct **)RTMemAlloc(sizeof(*papVMAs) * cPages);
728 if (papVMAs)
729 {
730 down_read(&pTask->mm->mmap_sem);
731
732 /*
733 * Get user pages.
734 */
735 rc = get_user_pages(pTask, /* Task for fault acounting. */
736 pTask->mm, /* Whose pages. */
737 R3Ptr, /* Where from. */
738 cPages, /* How many pages. */
739 1, /* Write to memory. */
740 0, /* force. */
741 &pMemLnx->apPages[0], /* Page array. */
742 papVMAs); /* vmas */
743 if (rc == cPages)
744 {
745 /*
746 * Flush dcache (required?) and protect against fork.
747 */
748 /** @todo The Linux fork() protection will require more work if this API
749 * is to be used for anything but locking VM pages. */
750 while (rc-- > 0)
751 {
752 flush_dcache_page(pMemLnx->apPages[rc]);
753 papVMAs[rc]->vm_flags |= VM_DONTCOPY;
754 }
755
756 up_read(&pTask->mm->mmap_sem);
757
758 RTMemFree(papVMAs);
759
760 pMemLnx->Core.u.Lock.R0Process = R0Process;
761 pMemLnx->cPages = cPages;
762 Assert(!pMemLnx->fMappedToRing0);
763 *ppMem = &pMemLnx->Core;
764
765 return VINF_SUCCESS;
766 }
767
768 /*
769 * Failed - we need to unlock any pages that we succeeded to lock.
770 */
771 while (rc-- > 0)
772 {
773 if (!PageReserved(pMemLnx->apPages[rc]))
774 SetPageDirty(pMemLnx->apPages[rc]);
775 page_cache_release(pMemLnx->apPages[rc]);
776 }
777
778 up_read(&pTask->mm->mmap_sem);
779
780 RTMemFree(papVMAs);
781 rc = VERR_LOCK_FAILED;
782 }
783
784 rtR0MemObjDelete(&pMemLnx->Core);
785 return rc;
786}
787
788
789int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
790{
791 /* What is there to lock? Should/Can we fake this? */
792 return VERR_NOT_SUPPORTED;
793}
794
795
796int rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
797{
798#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
799 const size_t cPages = cb >> PAGE_SHIFT;
800 struct page *pDummyPage;
801 struct page **papPages;
802
803 /* check for unsupported stuff. */
804 AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
805 AssertMsgReturn(uAlignment <= PAGE_SIZE, ("%#x\n", uAlignment), VERR_NOT_SUPPORTED);
806
807 /*
808 * Allocate a dummy page and create a page pointer array for vmap such that
809 * the dummy page is mapped all over the reserved area.
810 */
811 pDummyPage = alloc_page(GFP_HIGHUSER);
812 if (!pDummyPage)
813 return VERR_NO_MEMORY;
814 papPages = RTMemAlloc(sizeof(*papPages) * cPages);
815 if (papPages)
816 {
817 void *pv;
818 size_t iPage = cPages;
819 while (iPage-- > 0)
820 papPages[iPage] = pDummyPage;
821# ifdef VM_MAP
822 pv = vmap(papPages, cPages, VM_MAP, PAGE_KERNEL_RO);
823# else
824 pv = vmap(papPages, cPages, VM_ALLOC, PAGE_KERNEL_RO);
825# endif
826 RTMemFree(papPages);
827 if (pv)
828 {
829 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
830 if (pMemLnx)
831 {
832 pMemLnx->Core.u.ResVirt.R0Process = NIL_RTR0PROCESS;
833 pMemLnx->cPages = 1;
834 pMemLnx->apPages[0] = pDummyPage;
835 *ppMem = &pMemLnx->Core;
836 return VINF_SUCCESS;
837 }
838 vunmap(pv);
839 }
840 }
841 __free_page(pDummyPage);
842 return VERR_NO_MEMORY;
843
844#else /* < 2.4.22 */
845 /*
846 * Could probably use ioremap here, but the caller is in a better position than us
847 * to select some safe physical memory.
848 */
849 return VERR_NOT_SUPPORTED;
850#endif
851}
852
853
854/**
855 * Worker for rtR0MemObjNativeReserveUser and rtR0MemObjNativerMapUser that creates
856 * an empty user space mapping.
857 *
858 * The caller takes care of acquiring the mmap_sem of the task.
859 *
860 * @returns Pointer to the mapping.
861 * (void *)-1 on failure.
862 * @param R3PtrFixed (RTR3PTR)-1 if anywhere, otherwise a specific location.
863 * @param cb The size of the mapping.
864 * @param uAlignment The alignment of the mapping.
865 * @param pTask The Linux task to create this mapping in.
866 * @param fProt The RTMEM_PROT_* mask.
867 */
868static void *rtR0MemObjLinuxDoMmap(RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, struct task_struct *pTask, unsigned fProt)
869{
870 unsigned fLnxProt;
871 unsigned long ulAddr;
872
873 /*
874 * Convert from IPRT protection to mman.h PROT_ and call do_mmap.
875 */
876 fProt &= (RTMEM_PROT_NONE | RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC);
877 if (fProt == RTMEM_PROT_NONE)
878 fLnxProt = PROT_NONE;
879 else
880 {
881 fLnxProt = 0;
882 if (fProt & RTMEM_PROT_READ)
883 fLnxProt |= PROT_READ;
884 if (fProt & RTMEM_PROT_WRITE)
885 fLnxProt |= PROT_WRITE;
886 if (fProt & RTMEM_PROT_EXEC)
887 fLnxProt |= PROT_EXEC;
888 }
889
890 if (R3PtrFixed != (RTR3PTR)-1)
891 ulAddr = do_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
892 else
893 {
894 ulAddr = do_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
895 if ( !(ulAddr & ~PAGE_MASK)
896 && (ulAddr & (uAlignment - 1)))
897 {
898 /** @todo implement uAlignment properly... We'll probably need to make some dummy mappings to fill
899 * up alignment gaps. This is of course complicated by fragmentation (which we might have cause
900 * ourselves) and further by there begin two mmap strategies (top / bottom). */
901 /* For now, just ignore uAlignment requirements... */
902 }
903 }
904 if (ulAddr & ~PAGE_MASK) /* ~PAGE_MASK == PAGE_OFFSET_MASK */
905 return (void *)-1;
906 return (void *)ulAddr;
907}
908
909
910int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
911{
912 PRTR0MEMOBJLNX pMemLnx;
913 void *pv;
914 struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process);
915 if (!pTask)
916 return VERR_NOT_SUPPORTED;
917
918 /*
919 * Let rtR0MemObjLinuxDoMmap do the difficult bits.
920 */
921 down_write(&pTask->mm->mmap_sem);
922 pv = rtR0MemObjLinuxDoMmap(R3PtrFixed, cb, uAlignment, pTask, RTMEM_PROT_NONE);
923 up_write(&pTask->mm->mmap_sem);
924 if (pv == (void *)-1)
925 return VERR_NO_MEMORY;
926
927 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_RES_VIRT, pv, cb);
928 if (!pMemLnx)
929 {
930 down_write(&pTask->mm->mmap_sem);
931 MY_DO_MUNMAP(pTask->mm, (unsigned long)pv, cb);
932 up_write(&pTask->mm->mmap_sem);
933 return VERR_NO_MEMORY;
934 }
935
936 pMemLnx->Core.u.ResVirt.R0Process = R0Process;
937 *ppMem = &pMemLnx->Core;
938 return VINF_SUCCESS;
939}
940
941
942int rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
943{
944 int rc = VERR_NO_MEMORY;
945 PRTR0MEMOBJLNX pMemLnxToMap = (PRTR0MEMOBJLNX)pMemToMap;
946 PRTR0MEMOBJLNX pMemLnx;
947
948 /* Fail if requested to do something we can't. */
949 AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
950 AssertMsgReturn(uAlignment <= PAGE_SIZE, ("%#x\n", uAlignment), VERR_NOT_SUPPORTED);
951
952 /*
953 * Create the IPRT memory object.
954 */
955 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_MAPPING, NULL, pMemLnxToMap->Core.cb);
956 if (pMemLnx)
957 {
958 if (pMemLnxToMap->cPages)
959 {
960#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
961 /*
962 * Use vmap - 2.4.22 and later.
963 */
964 pgprot_t fPg = rtR0MemObjLinuxConvertProt(fProt, true /* kernel */);
965# ifdef VM_MAP
966 pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[0], pMemLnxToMap->cPages, VM_MAP, fPg);
967# else
968 pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[0], pMemLnxToMap->cPages, VM_ALLOC, fPg);
969# endif
970 if (pMemLnx->Core.pv)
971 {
972 pMemLnx->fMappedToRing0 = true;
973 rc = VINF_SUCCESS;
974 }
975 else
976 rc = VERR_MAP_FAILED;
977
978#else /* < 2.4.22 */
979 /*
980 * Only option here is to share mappings if possible and forget about fProt.
981 */
982 if (rtR0MemObjIsRing3(pMemToMap))
983 rc = VERR_NOT_SUPPORTED;
984 else
985 {
986 rc = VINF_SUCCESS;
987 if (!pMemLnxToMap->Core.pv)
988 rc = rtR0MemObjLinuxVMap(pMemLnxToMap, !!(fProt & RTMEM_PROT_EXEC));
989 if (RT_SUCCESS(rc))
990 {
991 Assert(pMemLnxToMap->Core.pv);
992 pMemLnx->Core.pv = pMemLnxToMap->Core.pv;
993 }
994 }
995#endif
996 }
997 else
998 {
999 /*
1000 * MMIO / physical memory.
1001 */
1002 Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
1003 pMemLnx->Core.pv = ioremap(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb);
1004 if (pMemLnx->Core.pv)
1005 {
1006 /** @todo fix protection. */
1007 rc = VINF_SUCCESS;
1008 }
1009 }
1010 if (RT_SUCCESS(rc))
1011 {
1012 pMemLnx->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;
1013 *ppMem = &pMemLnx->Core;
1014 return VINF_SUCCESS;
1015 }
1016 rtR0MemObjDelete(&pMemLnx->Core);
1017 }
1018
1019 return rc;
1020}
1021
1022
1023int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
1024{
1025 struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process);
1026 PRTR0MEMOBJLNX pMemLnxToMap = (PRTR0MEMOBJLNX)pMemToMap;
1027 int rc = VERR_NO_MEMORY;
1028 PRTR0MEMOBJLNX pMemLnx;
1029
1030 /*
1031 * Check for restrictions.
1032 */
1033 if (!pTask)
1034 return VERR_NOT_SUPPORTED;
1035
1036 /*
1037 * Create the IPRT memory object.
1038 */
1039 pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_MAPPING, NULL, pMemLnxToMap->Core.cb);
1040 if (pMemLnx)
1041 {
1042 /*
1043 * Allocate user space mapping.
1044 */
1045 void *pv;
1046 down_write(&pTask->mm->mmap_sem);
1047 pv = rtR0MemObjLinuxDoMmap(R3PtrFixed, pMemLnxToMap->Core.cb, uAlignment, pTask, fProt);
1048 if (pv != (void *)-1)
1049 {
1050 /*
1051 * Map page by page into the mmap area.
1052 * This is generic, paranoid and not very efficient.
1053 */
1054 pgprot_t fPg = rtR0MemObjLinuxConvertProt(fProt, false /* user */);
1055 unsigned long ulAddrCur = (unsigned long)pv;
1056 const size_t cPages = pMemLnxToMap->Core.cb >> PAGE_SHIFT;
1057 size_t iPage;
1058 rc = 0;
1059 if (pMemLnxToMap->cPages)
1060 {
1061 for (iPage = 0; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE)
1062 {
1063#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
1064 struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */
1065 AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR);
1066#endif
1067
1068#if defined(VBOX_USE_INSERT_PAGE) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
1069 rc = vm_insert_page(vma, ulAddrCur, pMemLnxToMap->apPages[iPage]);
1070 vma->vm_flags |= VM_RESERVED; /* This flag helps making 100% sure some bad stuff wont happen (swap, core, ++). */
1071#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
1072 rc = remap_pfn_range(vma, ulAddrCur, page_to_pfn(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
1073#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
1074 rc = remap_page_range(vma, ulAddrCur, page_to_phys(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
1075#else /* 2.4 */
1076 rc = remap_page_range(ulAddrCur, page_to_phys(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
1077#endif
1078 if (rc)
1079 break;
1080 }
1081 }
1082 else
1083 {
1084 RTHCPHYS Phys;
1085 if (pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS)
1086 Phys = pMemLnxToMap->Core.u.Phys.PhysBase;
1087 else if (pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_CONT)
1088 Phys = pMemLnxToMap->Core.u.Cont.Phys;
1089 else
1090 {
1091 AssertMsgFailed(("%d\n", pMemLnxToMap->Core.enmType));
1092 Phys = NIL_RTHCPHYS;
1093 }
1094 if (Phys != NIL_RTHCPHYS)
1095 {
1096 for (iPage = 0; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE, Phys += PAGE_SIZE)
1097 {
1098#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
1099 struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */
1100 AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR);
1101#endif
1102
1103#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
1104 rc = remap_pfn_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
1105#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
1106 rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
1107#else /* 2.4 */
1108 rc = remap_page_range(ulAddrCur, Phys, PAGE_SIZE, fPg);
1109#endif
1110 if (rc)
1111 break;
1112 }
1113 }
1114 }
1115 if (!rc)
1116 {
1117 up_write(&pTask->mm->mmap_sem);
1118
1119 pMemLnx->Core.pv = pv;
1120 pMemLnx->Core.u.Mapping.R0Process = R0Process;
1121 *ppMem = &pMemLnx->Core;
1122 return VINF_SUCCESS;
1123 }
1124
1125 /*
1126 * Bail out.
1127 */
1128 MY_DO_MUNMAP(pTask->mm, (unsigned long)pv, pMemLnxToMap->Core.cb);
1129 if (rc != VERR_INTERNAL_ERROR)
1130 rc = VERR_NO_MEMORY;
1131 }
1132
1133 up_write(&pTask->mm->mmap_sem);
1134
1135 rtR0MemObjDelete(&pMemLnx->Core);
1136 }
1137
1138 return rc;
1139}
1140
1141
1142RTHCPHYS rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, size_t iPage)
1143{
1144 PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem;
1145
1146 if (pMemLnx->cPages)
1147 return page_to_phys(pMemLnx->apPages[iPage]);
1148
1149 switch (pMemLnx->Core.enmType)
1150 {
1151 case RTR0MEMOBJTYPE_CONT:
1152 return pMemLnx->Core.u.Cont.Phys + (iPage << PAGE_SHIFT);
1153
1154 case RTR0MEMOBJTYPE_PHYS:
1155 return pMemLnx->Core.u.Phys.PhysBase + (iPage << PAGE_SHIFT);
1156
1157 /* the parent knows */
1158 case RTR0MEMOBJTYPE_MAPPING:
1159 return rtR0MemObjNativeGetPagePhysAddr(pMemLnx->Core.uRel.Child.pParent, iPage);
1160
1161 /* cPages > 0 */
1162 case RTR0MEMOBJTYPE_LOW:
1163 case RTR0MEMOBJTYPE_LOCK:
1164 case RTR0MEMOBJTYPE_PHYS_NC:
1165 case RTR0MEMOBJTYPE_PAGE:
1166 default:
1167 AssertMsgFailed(("%d\n", pMemLnx->Core.enmType));
1168 /* fall thru */
1169
1170 case RTR0MEMOBJTYPE_RES_VIRT:
1171 return NIL_RTHCPHYS;
1172 }
1173}
1174
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette