Changeset 42037 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jul 6, 2012 5:58:07 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
r42035 r42037 35 35 #include <iprt/asm.h> 36 36 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 37 # include <iprt/x86.h> 37 38 # include <iprt/asm-amd64-x86.h> 38 39 #endif … … 260 261 bool fPAE = false; 261 262 bool fLMA = false; 262 if (cr4 & RT_BIT(5) /*X86_CR4_PAE*/)263 if (cr4 & X86_CR4_PAE) 263 264 { 264 265 fPAE = true; 265 266 uint32_t fExtFeatures = ASMCpuId_EDX(0x80000001); 266 if (fExtFeatures & RT_BIT(29) /* X86_CPUID_EXT_FEATURE_EDX_LONG_MODE */)267 { 268 uint64_t efer = ASMRdMsr( 0xc0000080 /*MSR_K6_EFER*/);269 if (efer & RT_BIT(10) /*MSR_K6_EFER_LMA*/)267 if (fExtFeatures & X86_CPUID_EXT_FEATURE_EDX_LONG_MODE) 268 { 269 uint64_t efer = ASMRdMsr(MSR_K6_EFER); 270 if (efer & MSR_K6_EFER_LMA) 270 271 fLMA = true; 271 272 } … … 275 276 { 276 277 /* PML4 */ 277 rtR0MemObjDarwinReadPhys((cr3 & ~(RTCCUINTREG)PAGE_OFFSET_MASK) | (((uint64_t)(uintptr_t)pvPage >> 39) & 0x1ff) * 8, 8, &u64);278 if (!(u64.u & RT_BIT(0) /* present */))278 rtR0MemObjDarwinReadPhys((cr3 & ~(RTCCUINTREG)PAGE_OFFSET_MASK) | (((uint64_t)(uintptr_t)pvPage >> X86_PML4_SHIFT) & X86_PML4_MASK) * 8, 8, &u64); 279 if (!(u64.u & X86_PML4E_P)) 279 280 { 280 281 printf("rtR0MemObjDarwinGetPTE: %p -> PML4E !p\n", pvPage); … … 283 284 284 285 /* PDPTR */ 285 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 30) & 0x1ff) * 8, 8, &u64);286 if (!(u64.u & RT_BIT(0) /* present */))286 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PDPT_SHIFT) & X86_PDPT_MASK_AMD64) * 8, 8, &u64); 287 if (!(u64.u & X86_PDPE_P)) 287 288 { 288 289 printf("rtR0MemObjDarwinGetPTE: %p -> PDPTE !p\n", pvPage); 289 290 return 0; 290 291 } 291 if (u64.u & RT_BIT(7) /* big */)292 if (u64.u & X86_PDPE_LM_PS) 292 293 return (u64.u & ~(uint64_t)(_1G -1)) | ((uintptr_t)pvPage & (_1G -1)); 293 294 294 295 /* PD */ 295 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 21) & 0x1ff) * 8, 8, &u64);296 if (!(u64.u & RT_BIT(0) /* present */))296 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK) * 8, 8, &u64); 297 if (!(u64.u & X86_PDE_P)) 297 298 { 298 299 printf("rtR0MemObjDarwinGetPTE: %p -> PDE !p\n", pvPage); 299 300 return 0; 300 301 } 301 if (u64.u & RT_BIT(7) /* big */)302 if (u64.u & X86_PDE_PS) 302 303 return (u64.u & ~(uint64_t)(_2M -1)) | ((uintptr_t)pvPage & (_2M -1)); 303 304 304 /* P D*/305 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 12) & 0x1ff) * 8, 8, &u64);306 if (!(u64.u & RT_BIT(0) /* present */))305 /* PT */ 306 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK) * 8, 8, &u64); 307 if (!(u64.u & X86_PTE_P)) 307 308 { 308 309 printf("rtR0MemObjDarwinGetPTE: %p -> PTE !p\n", pvPage); … … 315 316 { 316 317 /* PDPTR */ 317 rtR0MemObjDarwinReadPhys((u64.u & 0xffffffe0 /*X86_CR3_PAE_PAGE_MASK*/) | (((uintptr_t)pvPage >> 30) & 0x3) * 8, 8, &u64);318 if (!(u64.u & RT_BIT(0) /* present */))318 rtR0MemObjDarwinReadPhys((u64.u & X86_CR3_PAE_PAGE_MASK) | (((uintptr_t)pvPage >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE) * 8, 8, &u64); 319 if (!(u64.u & X86_PDE_P)) 319 320 return 0; 320 321 321 322 /* PD */ 322 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 21) & 0x1ff) * 8, 8, &u64);323 if (!(u64.u & RT_BIT(0) /* present */))323 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK) * 8, 8, &u64); 324 if (!(u64.u & X86_PDE_P)) 324 325 return 0; 325 if (u64.u & RT_BIT(7) /* big */)326 if (u64.u & X86_PDE_PS) 326 327 return (u64.u & ~(uint64_t)(_2M -1)) | ((uintptr_t)pvPage & (_2M -1)); 327 328 328 /* P D*/329 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 12) & 0x1ff) * 8, 8, &u64);330 if (!(u64.u & RT_BIT(0) /* present */))329 /* PT */ 330 rtR0MemObjDarwinReadPhys((u64.u & ~(uint64_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK) * 8, 8, &u64); 331 if (!(u64.u & X86_PTE_P)) 331 332 return 0; 332 333 return u64.u; … … 334 335 335 336 /* PD */ 336 rtR0MemObjDarwinReadPhys((u64.au32[0] & ~(uint32_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 22) & 0x3ff) * 4, 4, &u64);337 if (!(u64.au32[0] & RT_BIT(0) /* present */))337 rtR0MemObjDarwinReadPhys((u64.au32[0] & ~(uint32_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PD_SHIFT) & X86_PD_MASK) * 4, 4, &u64); 338 if (!(u64.au32[0] & X86_PDE_P)) 338 339 return 0; 339 if (u64.au32[0] & RT_BIT(7) /* big */)340 if (u64.au32[0] & X86_PDE_PS) 340 341 return (u64.u & ~(uint64_t)(_2M -1)) | ((uintptr_t)pvPage & (_2M -1)); 341 342 342 /* P D*/343 rtR0MemObjDarwinReadPhys((u64.au32[0] & ~(uint32_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> 12) & 0x3ff) * 4, 4, &u64);344 if (!(u64.au32[0] & RT_BIT(0) /* present */))343 /* PT */ 344 rtR0MemObjDarwinReadPhys((u64.au32[0] & ~(uint32_t)PAGE_OFFSET_MASK) | (((uintptr_t)pvPage >> X86_PT_SHIFT) & X86_PT_MASK) * 4, 4, &u64); 345 if (!(u64.au32[0] & X86_PTE_P)) 345 346 return 0; 346 347 return u64.au32[0];
Note:
See TracChangeset
for help on using the changeset viewer.