table_walker.hh (10037:5cac77888310) | table_walker.hh (10324:f40134eb3f85) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2010-2013 ARM Limited | 2 * Copyright (c) 2010-2014 ARM Limited |
3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 346 unchanged lines hidden (view full) --- 357 /** This entry needs to be written back to memory */ 358 bool dirty() const 359 { 360 return _dirty; 361 } 362 363 }; 364 | 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 346 unchanged lines hidden (view full) --- 357 /** This entry needs to be written back to memory */ 358 bool dirty() const 359 { 360 return _dirty; 361 } 362 363 }; 364 |
365 // Granule sizes for AArch64 long descriptors 366 enum GrainSize { 367 Grain4KB = 12, 368 Grain16KB = 14, 369 Grain64KB = 16, 370 ReservedGrain = 0 371 }; 372 |
|
365 /** Long-descriptor format (LPAE) */ 366 class LongDescriptor : public DescriptorBase { 367 public: 368 /** Descriptor type */ 369 enum EntryType { 370 Invalid, 371 Table, 372 Block, --- 31 unchanged lines hidden (view full) --- 404 { 405 assert(type() == Block || type() == Page); 406 return have_security && (currState->secureLookup && !bits(data, 5)); 407 } 408 409 /** True if the current lookup is performed in AArch64 state */ 410 bool aarch64; 411 | 373 /** Long-descriptor format (LPAE) */ 374 class LongDescriptor : public DescriptorBase { 375 public: 376 /** Descriptor type */ 377 enum EntryType { 378 Invalid, 379 Table, 380 Block, --- 31 unchanged lines hidden (view full) --- 412 { 413 assert(type() == Block || type() == Page); 414 return have_security && (currState->secureLookup && !bits(data, 5)); 415 } 416 417 /** True if the current lookup is performed in AArch64 state */ 418 bool aarch64; 419 |
412 /** True if the granule size is 64 KB (AArch64 only) */ 413 bool largeGrain; 414 | |
415 /** Width of the granule size in bits */ | 420 /** Width of the granule size in bits */ |
416 int grainSize; | 421 GrainSize grainSize; |
417 418 /** Return the descriptor type */ 419 EntryType type() const 420 { 421 switch (bits(data, 1, 0)) { 422 case 0x1: 423 // In AArch64 blocks are not allowed at L0 for the 4 KB granule | 422 423 /** Return the descriptor type */ 424 EntryType type() const 425 { 426 switch (bits(data, 1, 0)) { 427 case 0x1: 428 // In AArch64 blocks are not allowed at L0 for the 4 KB granule |
424 // and at L1 for the 64 KB granule 425 if (largeGrain) | 429 // and at L1 for 16/64 KB granules 430 if (grainSize > Grain4KB) |
426 return lookupLevel == L2 ? Block : Invalid; 427 return lookupLevel == L0 || lookupLevel == L3 ? Invalid : Block; 428 case 0x3: 429 return lookupLevel == L3 ? Page : Table; 430 default: 431 return Invalid; 432 } 433 } 434 435 /** Return the bit width of the page/block offset */ 436 uint8_t offsetBits() const 437 { | 431 return lookupLevel == L2 ? Block : Invalid; 432 return lookupLevel == L0 || lookupLevel == L3 ? Invalid : Block; 433 case 0x3: 434 return lookupLevel == L3 ? Page : Table; 435 default: 436 return Invalid; 437 } 438 } 439 440 /** Return the bit width of the page/block offset */ 441 uint8_t offsetBits() const 442 { |
438 assert(type() == Block || type() == Page); 439 if (largeGrain) { 440 if (type() == Block) 441 return 29 /* 512 MB */; 442 return 16 /* 64 KB */; // type() == Page | 443 if (type() == Block) { 444 switch (grainSize) { 445 case Grain4KB: 446 return lookupLevel == L1 ? 30 /* 1 GB */ 447 : 21 /* 2 MB */; 448 case Grain16KB: 449 return 25 /* 32 MB */; 450 case Grain64KB: 451 return 29 /* 512 MB */; 452 default: 453 panic("Invalid AArch64 VM granule size\n"); 454 } 455 } else if (type() == Page) { 456 switch (grainSize) { 457 case Grain4KB: 458 case Grain16KB: 459 case Grain64KB: 460 return grainSize; /* enum -> uint okay */ 461 default: 462 panic("Invalid AArch64 VM granule size\n"); 463 } |
443 } else { | 464 } else { |
444 if (type() == Block) 445 return lookupLevel == L1 ? 30 /* 1 GB */ : 21 /* 2 MB */; 446 return 12 /* 4 KB */; // type() == Page | 465 panic("AArch64 page table entry must be block or page\n"); |
447 } 448 } 449 450 /** Return the physical frame, bits shifted right */ 451 Addr pfn() const 452 { 453 if (aarch64) 454 return bits(data, 47, offsetBits()); --- 247 unchanged lines hidden (view full) --- 702 SCTLR sctlr; 703 704 /** Cached copy of the scr as it existed when translation began */ 705 SCR scr; 706 707 /** Cached copy of the cpsr as it existed when translation began */ 708 CPSR cpsr; 709 | 466 } 467 } 468 469 /** Return the physical frame, bits shifted right */ 470 Addr pfn() const 471 { 472 if (aarch64) 473 return bits(data, 47, offsetBits()); --- 247 unchanged lines hidden (view full) --- 721 SCTLR sctlr; 722 723 /** Cached copy of the scr as it existed when translation began */ 724 SCR scr; 725 726 /** Cached copy of the cpsr as it existed when translation began */ 727 CPSR cpsr; 728 |
710 /** Cached copy of the ttbcr as it existed when translation began. */ 711 TTBCR ttbcr; | 729 /** Cached copy of ttbcr/tcr as it existed when translation began */ 730 union { 731 TTBCR ttbcr; // AArch32 translations 732 TCR tcr; // AArch64 translations 733 }; |
712 713 /** Cached copy of the htcr as it existed when translation began. */ 714 HTCR htcr; 715 716 /** Cached copy of the htcr as it existed when translation began. */ 717 HCR hcr; 718 719 /** Cached copy of the vtcr as it existed when translation began. */ --- 243 unchanged lines hidden --- | 734 735 /** Cached copy of the htcr as it existed when translation began. */ 736 HTCR htcr; 737 738 /** Cached copy of the htcr as it existed when translation began. */ 739 HCR hcr; 740 741 /** Cached copy of the vtcr as it existed when translation began. */ --- 243 unchanged lines hidden --- |