Changeset 81196 in vbox
- Timestamp:
- Oct 9, 2019 8:24:12 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuMpPei/CpuPaging.c
r80721 r81196 13 13 #include <Library/CpuLib.h> 14 14 #include <Library/BaseLib.h> 15 #ifdef VBOX 16 # define IN_RING0 17 # include <iprt/asm.h> 18 #endif 15 19 16 20 #include "CpuMpPei.h" … … 68 72 }; 69 73 74 #ifdef VBOX 75 /** 76 Safe page table entry write function, make 104% sure the compiler won't 77 split up the access (fatal if modifying entries for current code or data). 78 79 @param[in] PageEntry The page table entry to modify.* 80 @param[in] CurrentPageEntry The old page table value (for cmpxchg8b). 81 @param[in] NewPageEntry What to write. 82 **/ 83 static VOID SafePageTableEntryWrite64 (UINT64 volatile *PageEntry, UINT64 CurrentPageEntry, UINT64 NewPageEntry) 84 { 85 # ifdef VBOX 86 ASMAtomicWriteU64(PageEntry, NewPageEntry); RT_NOREF(CurrentPageEntry); 87 # else 88 for (;;) { 89 UINT64 CurValue = InterlockedCompareExchange64(PageEntry, CurrentPageEntry, NewPageEntry); 90 if (CurValue == CurrentPageEntry) 91 return; 92 CurrentPageEntry = CurValue; 93 } 94 # endif 95 } 96 #endif 97 70 98 /** 71 99 The function will check if IA32 PAE is supported. … … 235 263 RETURN_STATUS 236 264 SplitPage ( 265 #ifdef VBOX 266 IN UINT64 volatile *PageEntry, 267 #else 237 268 IN UINT64 *PageEntry, 269 #endif 238 270 IN PAGE_ATTRIBUTE PageAttribute, 239 271 IN PAGE_ATTRIBUTE SplitAttribute, … … 241 273 ) 242 274 { 275 #ifdef VBOX 276 UINT64 CurrentPageEntry; 277 #endif 243 278 UINT64 BaseAddress; 244 279 UINT64 *NewPageEntry; … … 265 300 AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & 266 301 mPageAttributeTable[SplitTo].AddressMask; 302 #ifdef VBOX 303 CurrentPageEntry = *PageEntry; 304 BaseAddress = CurrentPageEntry & 305 #else 267 306 BaseAddress = *PageEntry & 307 #endif 268 308 ~PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & 269 309 mPageAttributeTable[PageAttribute].AddressMask; 270 310 for (Index = 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { 271 311 NewPageEntry[Index] = BaseAddress | AddressEncMask | 312 #ifdef VBOX 313 (CurrentPageEntry & PAGE_PROGATE_BITS); 314 #else 272 315 ((*PageEntry) & PAGE_PROGATE_BITS); 316 #endif 273 317 274 318 if (SplitTo != PageMin) { … … 283 327 } 284 328 329 #ifdef VBOX 330 SafePageTableEntryWrite64 (PageEntry, CurrentPageEntry, 331 (UINT64)(UINTN)NewPageEntry | AddressEncMask | PAGE_ATTRIBUTE_BITS); 332 #else 285 333 (*PageEntry) = (UINT64)(UINTN)NewPageEntry | AddressEncMask | PAGE_ATTRIBUTE_BITS; 334 #endif 286 335 287 336 return RETURN_SUCCESS; … … 318 367 ) 319 368 { 369 #ifdef VBOX 370 UINT64 volatile *PageEntry; 371 UINT64 CurrentPageEntry; 372 #else 320 373 UINT64 *PageEntry; 374 #endif 321 375 PAGE_ATTRIBUTE PageAttribute; 322 376 RETURN_STATUS Status; … … 364 418 // Just take care of 'present' bit for Stack Guard. 365 419 // 420 #ifdef VBOX 421 CurrentPageEntry = *PageEntry; 422 if ((CurrentPageEntry & IA32_PG_P) != (Attributes & IA32_PG_P)) 423 SafePageTableEntryWrite64 (PageEntry, CurrentPageEntry, 424 (CurrentPageEntry & ~(UINT64)IA32_PG_P) | (Attributes & IA32_PG_P)); 425 #else 366 426 if ((Attributes & IA32_PG_P) != 0) { 367 427 *PageEntry |= (UINT64)IA32_PG_P; … … 369 429 *PageEntry &= ~((UINT64)IA32_PG_P); 370 430 } 431 #endif 371 432 372 433 //
Note:
See TracChangeset
for help on using the changeset viewer.