/**\r
Macro to get the value of a System Locality\r
**/\r
-#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (MultU64x64 (i, LocalityCount)) + j)\r
+#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j)\r
\r
/**\r
This function parses the ACPI SLIT table.\r
)\r
{\r
UINT32 Offset;\r
- UINT64 Count;\r
- UINT64 Index;\r
- UINT64 LocalityCount;\r
+ UINT32 Count;\r
+ UINT32 Index;\r
+ UINT32 LocalityCount;\r
UINT8* LocalityPtr;\r
CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi\r
\r
return;\r
}\r
\r
+ /*\r
+ Despite the 'Number of System Localities' being a 64-bit field in SLIT,\r
+ the maximum number of localities that can be represented in SLIT is limited\r
+ by the 'Length' field of the ACPI table.\r
+\r
+ Since the ACPI table length field is 32-bit wide. The maximum number of\r
+ localities that can be represented in SLIT can be calculated as:\r
+\r
+ MaxLocality = sqrt (MAX_UINT32 - sizeof (EFI_ACPI_6_3_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEADER))\r
+ = 65535\r
+ = MAX_UINT16\r
+ */\r
+ if (*SlitSystemLocalityCount > MAX_UINT16) {\r
+ IncrementErrorCount ();\r
+ Print (\r
+ L"ERROR: The Number of System Localities provided can't be represented " \\r
+ L"in the SLIT table. SlitSystemLocalityCount = %ld. " \\r
+ L"MaxLocalityCountAllowed = %d.\n",\r
+ *SlitSystemLocalityCount,\r
+ MAX_UINT16\r
+ );\r
+ return;\r
+ }\r
+\r
+ LocalityCount = (UINT32)*SlitSystemLocalityCount;\r
+\r
+ // Make sure system localities fit in the table buffer provided\r
+ if (Offset + (LocalityCount * LocalityCount) > AcpiTableLength) {\r
+ IncrementErrorCount ();\r
+ Print (\r
+ L"ERROR: Invalid Number of System Localities. " \\r
+ L"SlitSystemLocalityCount = %ld. AcpiTableLength = %d.\n",\r
+ *SlitSystemLocalityCount,\r
+ AcpiTableLength\r
+ );\r
+ return;\r
+ }\r
+\r
LocalityPtr = Ptr + Offset;\r
- LocalityCount = *SlitSystemLocalityCount;\r
\r
// We only print the Localities if the count is less than 16\r
// If the locality count is more than 16 then refer to the\r