| | 510 | * User data passed to the apply_to_page_range() callback. |
| | 511 | */ |
| | 512 | typedef struct LNXAPPLYPGRANGE |
| | 513 | { |
| | 514 | /** Pointer to the memory object. */ |
| | 515 | PRTR0MEMOBJLNX pMemLnx; |
| | 516 | /** The page protection flags to apply. */ |
| | 517 | pgprot_t fPg; |
| | 518 | } LNXAPPLYPGRANGE; |
| | 519 | /** Pointer to the user data. */ |
| | 520 | typedef LNXAPPLYPGRANGE *PLNXAPPLYPGRANGE; |
| | 521 | /** Pointer to the const user data. */ |
| | 522 | typedef const LNXAPPLYPGRANGE *PCLNXAPPLYPGRANGE; |
| | 523 | |
| | 524 | /** |
| | 525 | * Callback called in apply_to_page_range(). |
| | 526 | * |
| | 527 | * @returns Linux status code. |
| | 528 | * @param pPte Pointer to the page table entry for the given address. |
| | 529 | * @param uAddr The address to apply the new protection to. |
| | 530 | * @param pvUser The opaque user data. |
| | 531 | */ |
| | 532 | static DECLCALLBACK(int) rtR0MemObjLinuxApplyPageRange(pte_t *pPte, unsigned long uAddr, void *pvUser) |
| | 533 | { |
| | 534 | PCLNXAPPLYPGRANGE pArgs = (PCLNXAPPLYPGRANGE)pvUser; |
| | 535 | PRTR0MEMOBJLNX pMemLnx = pArgs->pMemLnx; |
| | 536 | uint32_t idxPg = (uAddr - (unsigned long)pMemLnx->Core.pv) >> PAGE_SHIFT; |
| | 537 | |
| | 538 | set_pte(pPte, mk_pte(pMemLnx->apPages[idxPg], pArgs->fPg)); |
| | 539 | return 0; |
| | 540 | } |
| | 541 | #endif |
| | 542 | |
| | 543 | |
| | 544 | /** |
| | 1898 | # elif defined(IPRT_USE_APPLY_TO_PAGE_RANGE_FOR_EXEC) |
| | 1899 | PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem; |
| | 1900 | if ( pMemLnx->fExecutable |
| | 1901 | && pMemLnx->fMappedToRing0) |
| | 1902 | { |
| | 1903 | LNXAPPLYPGRANGE Args; |
| | 1904 | Args.pMemLnx = pMemLnx; |
| | 1905 | Args.fPg = rtR0MemObjLinuxConvertProt(fProt, true /*fKernel*/); |
| | 1906 | int rcLnx = apply_to_page_range(current->active_mm, (unsigned long)pMemLnx->Core.pv + offSub, cbSub, |
| | 1907 | rtR0MemObjLinuxApplyPageRange, (void *)&Args); |
| | 1908 | if (rcLnx) |
| | 1909 | return VERR_NOT_SUPPORTED; |
| | 1910 | |
| | 1911 | return VINF_SUCCESS; |
| | 1912 | } |