// Update GCD with the last region\r
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,\r
*StartGcdRegion,\r
- (BaseAddress + (Index * TT_ADDRESS_AT_LEVEL(TableLevel)) - 1) - *StartGcdRegion,\r
+ (BaseAddress + (Index * TT_ADDRESS_AT_LEVEL(TableLevel))) - *StartGcdRegion,\r
PageAttributeToGcdAttribute (EntryAttribute));\r
}\r
\r
// Update GCD with the last region\r
SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,\r
*StartGcdRegion,\r
- (BaseAddress + (Index * TT_ADDRESS_AT_LEVEL(TableLevel)) - 1) - *StartGcdRegion,\r
- PageAttributeToGcdAttribute (EntryAttribute));\r
+ (BaseAddress + (Index * TT_ADDRESS_AT_LEVEL(TableLevel))) - *StartGcdRegion,\r
+ PageAttributeToGcdAttribute (*PrevEntryAttribute));\r
\r
// Start of the new region\r
*StartGcdRegion = BaseAddress + (Index * TT_ADDRESS_AT_LEVEL(TableLevel));\r
BaseAddressGcdRegion,\r
&PageAttribute, &BaseAddressGcdRegion);\r
\r
- // Update GCD with the last region\r
- SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,\r
- BaseAddressGcdRegion,\r
- EndAddressGcdRegion - BaseAddressGcdRegion,\r
- PageAttributeToGcdAttribute (PageAttribute));\r
+ // Update GCD with the last region if valid\r
+ if (PageAttribute != TT_ATTR_INDX_INVALID) {\r
+ SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors,\r
+ BaseAddressGcdRegion,\r
+ EndAddressGcdRegion - BaseAddressGcdRegion,\r
+ PageAttributeToGcdAttribute (PageAttribute));\r
+ }\r
\r
FreePool (MemorySpaceMap);\r
\r
DEBUG ((DEBUG_GCD, "SetGcdMemorySpaceAttributes[0x%lX; 0x%lX] = 0x%lX\n",\r
BaseAddress, BaseAddress + Length, Attributes));\r
\r
+ // We do not support a smaller granularity than 4KB on ARM Architecture\r
+ if ((Length & EFI_PAGE_MASK) != 0) {\r
+ DEBUG ((DEBUG_WARN,\r
+ "Warning: We do not support smaller granularity than 4KB on ARM Architecture (passed length: 0x%lX).\n",\r
+ Length));\r
+ }\r
+\r
//\r
// Get all memory descriptors covered by the memory range\r
//\r