mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
ocvalidate: Only known first byte can be set to ProcessorType.
This commit is contained in:
parent
db90ad3dbb
commit
4d8b7aa89c
@ -81,6 +81,7 @@ Utility to validate whether a `config.plist` matches requirements and convention
|
||||
#### Generic
|
||||
- SystemProductName: Only real Mac models are accepted.
|
||||
- SystemMemoryStatus: Only `Auto`, `Upgradable`, or `Soldered` are accepted.
|
||||
- ProcessorType: Only known first byte can be set.
|
||||
|
||||
### UEFI
|
||||
#### APFS
|
||||
|
||||
@ -17,6 +17,47 @@
|
||||
#include "OcValidateLib.h"
|
||||
|
||||
#include <Library/OcMacInfoLib.h>
|
||||
#include <IndustryStandard/AppleSmBios.h>
|
||||
|
||||
STATIC
|
||||
BOOLEAN
|
||||
ValidateProcessorType (
|
||||
IN UINT16 ProcessorType
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT8 AllowedProcessorType[] = {
|
||||
AppleProcessorMajorCore,
|
||||
AppleProcessorMajorCore2,
|
||||
AppleProcessorMajorXeonPenryn,
|
||||
AppleProcessorMajorXeonNehalem,
|
||||
AppleProcessorMajorI5,
|
||||
AppleProcessorMajorI7,
|
||||
AppleProcessorMajorI3,
|
||||
AppleProcessorMajorI9,
|
||||
AppleProcessorMajorXeonE5,
|
||||
AppleProcessorMajorM,
|
||||
AppleProcessorMajorM3,
|
||||
AppleProcessorMajorM5,
|
||||
AppleProcessorMajorM7,
|
||||
AppleProcessorMajorXeonW
|
||||
};
|
||||
|
||||
//
|
||||
// 0 is allowed.
|
||||
//
|
||||
if (ProcessorType == 0U) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < ARRAY_SIZE (AllowedProcessorType); ++Index) {
|
||||
if ((ProcessorType >> 8U) == AllowedProcessorType[Index]) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE: Only PlatformInfo->Generic is checked here. The rest is ignored.
|
||||
@ -33,6 +74,7 @@ CheckPlatformInfoGeneric (
|
||||
CONST CHAR8 *SystemProductName;
|
||||
CONST CHAR8 *SystemMemoryStatus;
|
||||
CONST CHAR8 *AsciiSystemUUID;
|
||||
UINT16 ProcessorType;
|
||||
|
||||
ErrorCount = 0;
|
||||
UserPlatformInfo = &Config->PlatformInfo;
|
||||
@ -57,6 +99,12 @@ CheckPlatformInfoGeneric (
|
||||
++ErrorCount;
|
||||
}
|
||||
|
||||
ProcessorType = UserPlatformInfo->Generic.ProcessorType;
|
||||
if (!ValidateProcessorType (ProcessorType)) {
|
||||
DEBUG ((DEBUG_WARN, "PlatformInfo->Generic->ProcessorType is borked!\n"));
|
||||
++ErrorCount;
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Sanitise MLB, ProcessorType, and SystemSerialNumber if possible...
|
||||
//
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user