]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/Include/Chipset: Fix translation table address calculations for AARCH64
authorGarrett Kirkendall <garrett.kirkendall@amd.com>
Tue, 15 Oct 2013 09:25:38 +0000 (09:25 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Oct 2013 09:25:38 +0000 (09:25 +0000)
TT_ADDRESS_* macros were not casting immediate values to UINTN.
This causes shift operations to be off by 32-bits when calculating
addresses above 4GB.  Any address above 4GB was being improperly calculated.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Garrett Kirkendall <garrett.kirkendall@amd.com>
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14777 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Include/Chipset/AArch64Mmu.h

index 17c28fa205c35aa9129658bc51a73814ce117066..7c9890331feb88eb28d035bcc6864e63ac61e77d 100644 (file)
 // The first offset starts at 12bit. There are 4 levels of 9-bit address range from level 3 to level 0\r
 #define TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel)  (12 + ((3 - (TableLevel)) * 9))\r
 \r
-#define TT_BLOCK_ENTRY_SIZE_AT_LEVEL(Level)     (1 << TT_ADDRESS_OFFSET_AT_LEVEL(Level))\r
+#define TT_BLOCK_ENTRY_SIZE_AT_LEVEL(Level)     (1ULL << TT_ADDRESS_OFFSET_AT_LEVEL(Level))\r
 \r
 // Get the associated entry in the given Translation Table\r
 #define TT_GET_ENTRY_FOR_ADDRESS(TranslationTable, Level, Address)  \\r
-    ((UINTN)(TranslationTable) + ((((Address) >> TT_ADDRESS_OFFSET_AT_LEVEL(Level)) & (BIT9-1)) * sizeof(UINT64)))\r
+    ((UINTN)(TranslationTable) + ((((UINTN)(Address) >> TT_ADDRESS_OFFSET_AT_LEVEL(Level)) & (BIT9-1)) * sizeof(UINT64)))\r
 \r
 // Return the smallest address granularity from the table level.\r
 // The first offset starts at 12bit. There are 4 levels of 9-bit address range from level 3 to level 0\r
-#define TT_ADDRESS_AT_LEVEL(TableLevel)       (1 << TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel))\r
+#define TT_ADDRESS_AT_LEVEL(TableLevel)       (1ULL << TT_ADDRESS_OFFSET_AT_LEVEL(TableLevel))\r
 \r
 #define TT_LAST_BLOCK_ADDRESS(TranslationTable, EntryCount) \\r
     ((UINT64*)((EFI_PHYSICAL_ADDRESS)(TranslationTable) + (((EntryCount) - 1) * sizeof(UINT64))))\r