fix trust smbios

Signed-off-by: Slice <sergey.slice@gmail.com>
This commit is contained in:
Slice 2024-01-12 22:14:09 +03:00
parent 1947d48706
commit fa55f15b4f
4 changed files with 1404 additions and 1373 deletions

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,37 @@ const card_config_t card_configs[] = {
};
const radeon_card_info_t radeon_cards[] = {
/* Vega 20 */
{ 0x66AF, CHIP_FAMILY_VEGA20, "AMD Radeon VII", kNull },
// Polaris 10
{ 0x67DF, CHIP_FAMILY_ELLESMERE, "AMD Radeon RX 480/570/580", kNull },
// Polaris 11
{ 0x67E0, CHIP_FAMILY_BAFFIN, "AMD Radeon RX 460", kNull },
{ 0x67E3, CHIP_FAMILY_BAFFIN, "AMD Radeon Pro WX4100", kNull },
{ 0x67EF, CHIP_FAMILY_BAFFIN, "AMD Radeon Pro 555", kNull },
{ 0x67FF, CHIP_FAMILY_BAFFIN, "AMD Radeon RX 560", kNull },
/* Vega 10 */
{ 0x6863, CHIP_FAMILY_VEGA10, "AMD Radeon Vega Frontier", kNull },
{ 0x6867, CHIP_FAMILY_VEGA10, "AMD Radeon Pro Vega 56", kNull },
{ 0x687F, CHIP_FAMILY_VEGA10, "AMD Radeon Vega 64", kNull },
/* Polaris12 */
{ 0x6987, CHIP_FAMILY_GREENLAND, "AMD Radeon RX640", kNull },
{ 0x699F, CHIP_FAMILY_GREENLAND, "AMD Radeon RX550", kNull },
// Fiji
{ 0x7300, CHIP_FAMILY_FIJI, "AMD Radeon R9 Fury", kNull },
// Navi10
{ 0x731F, CHIP_FAMILY_NAVI10, "AMD Radeon RX5700", kNull },
// Navi15
{ 0x7340, CHIP_FAMILY_NAVI10, "AMD Radeon RX5500", kNull },
{ 0x7360, CHIP_FAMILY_NAVI10, "AMD Radeon Pro RX5600M", kNull }, // found in MacBookPro16,4
// Navi2x
{ 0x73A5, CHIP_FAMILY_NAVI20, "AMD Radeon RX6950XT", kNull },
{ 0x73AF, CHIP_FAMILY_NAVI20, "AMD Radeon RX6900XT", kNull },
{ 0x73BF, CHIP_FAMILY_NAVI20, "AMD Radeon RX6800XT", kNull },
{ 0x73DF, CHIP_FAMILY_NAVI20, "AMD Radeon RX6700XT", kNull },
{ 0x73EF, CHIP_FAMILY_NAVI20, "AMD Radeon RX6650XT", kNull },
{ 0x73FF, CHIP_FAMILY_NAVI20, "AMD Radeon RX6600XT", kNull },
{ 0x0000, CHIP_FAMILY_UNKNOW, "AMD Unknown", kNull }
};
@ -1205,7 +1235,7 @@ Lexa-based WX 2100, WX 3100 and WX 3200 do NOT work.
*/
#if ATI_LESS
#if 0 //ATI_LESS
const CHAR8 *chip_family_name[] = {
"UNKNOW",
"Ellesmere",
@ -1281,6 +1311,9 @@ const CHAR8 *chip_family_name[] = {
"Baffin",
"Greenland",
"Vega10",
"Vega20",
"Navi10",
"Navi20",
// Vega11
// Navi
""
@ -1806,7 +1839,7 @@ XBool load_vbios_file(UINT16 vendor_id, UINT16 device_id)
void get_vram_size(void)
{
//check card->vram_size in bytes!
ati_chip_family_t chip_family = card->info->chip_family;
ati_chip_family_t chip_family = CHIP_FAMILY_UNKNOW; //card->info->chip_family;
card->vram_size = 128 << 20; //default 128Mb, this is minimum for OS
if (gSettings.Graphics.VRAM != 0) {

View File

@ -160,7 +160,6 @@ SMBIOS_TABLE_STRING SMBIOS_TABLE_TYPE4_STR_IDX[] = {
// validate the SMBIOS entry point structure
XBool IsEntryPointStructureValid (IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure)
{
UINTN I;
UINT8 Length;
UINT8 Checksum = 0;
UINT8 *BytePtr;
@ -171,7 +170,7 @@ XBool IsEntryPointStructureValid (IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructu
BytePtr = (UINT8*) EntryPointStructure;
Length = EntryPointStructure->EntryPointLength;
for (I = 0; I < Length; I++) {
for (UINTN I = 0; I < Length; I++) {
Checksum = Checksum + (UINT8) BytePtr[I];
}
@ -181,10 +180,8 @@ XBool IsEntryPointStructureValid (IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructu
void* FindOemSMBIOSPtr (void)
{
UINTN Address;
// Search 0x0f0000 - 0x0fffff for SMBIOS Ptr
for (Address = 0xf0000; Address < 0xfffff; Address += 0x10) {
for (UINTN Address = 0xf0000; Address < 0xfffff; Address += 0x10) {
if (*(UINT32 *)(Address) == SMBIOS_PTR && IsEntryPointStructureValid((SMBIOS_TABLE_ENTRY_POINT*)Address)) {
return (void *)Address;
}
@ -217,7 +214,7 @@ void* GetSmbiosTablesFromHob (void)
void* GetSmbiosTablesFromConfigTables (void)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS *Table;
EFI_PHYSICAL_ADDRESS *Table = NULL;
Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (void **)&Table);
if (EFI_ERROR(Status) || Table == NULL) {
@ -1604,41 +1601,42 @@ void PatchTableType17(const SmbiosInjectedSettings& smbiosSettings, XArray<UINT1
// Detect whether the SMBIOS is trusted information
if (trustSMBIOS) {
if (gRAM.SMBIOS.size() != 0) {
if (gRAM.SPD.size() != 0) {
if (gRAM.SPD.size() != gRAM.SMBIOS.size()) {
// Prefer the SPD information
if (gRAM.SPD.size() > gRAM.SMBIOS.size()) {
DBG("Not trusting SMBIOS because SPD reports more modules...\n");
trustSMBIOS = false;
} else if (gRAM.SPD.doesSlotForIndexExist(0) || !gRAM.SMBIOS.doesSlotForIndexExist(0)) {
if (gRAM.SPD.size() > 1) {
DBG("Not trusting SMBIOS because SPD reports different modules...\n");
trustSMBIOS = false;
} else if (gRAM.SMBIOS.size() == 1) {
channels = 1;
}
} else if (gRAM.SPD.size() == 1) {
// The SMBIOS may contain table for built-in module
if (gRAM.SMBIOS.size() <= 2) {
if (!gRAM.SMBIOS.doesSlotForIndexExist(0) || !gRAM.SPD.doesSlotForIndexExist(2) ||
(gRAM.SMBIOS.getSlotInfoForSlotIndex(0).Frequency != gRAM.SPD.getSlotInfoForSlotIndex(2).Frequency) ||
(gRAM.SMBIOS.getSlotInfoForSlotIndex(0).ModuleSize != gRAM.SPD.getSlotInfoForSlotIndex(2).ModuleSize)) {
channels = 1;
}
} else {
DBG("Not trusting SMBIOS because SPD reports only one module...\n");
trustSMBIOS = false;
}
} else {
DBG("Not trusting SMBIOS because SPD reports less modules...\n");
trustSMBIOS = false;
}
} else if (gRAM.SPD.doesSlotForIndexExist(0) != gRAM.SMBIOS.doesSlotForIndexExist(0)) {
// Never trust a sneaky SMBIOS!
DBG("Not trusting SMBIOS because it's being sneaky...\n");
trustSMBIOS = false;
}
} else if (gRAM.SMBIOS.size() == 1) {
// if (gRAM.SPD.size() != 0) {
// if (gRAM.SPD.size() != gRAM.SMBIOS.size()) {
// // Prefer the SPD information -- no, we trust SMBIOS!
// if (gRAM.SPD.size() > gRAM.SMBIOS.size()) {
// DBG("Not trusting SMBIOS because SPD reports more modules...\n");
// trustSMBIOS = false;
// } else if (gRAM.SPD.doesSlotForIndexExist(0) || !gRAM.SMBIOS.doesSlotForIndexExist(0)) {
// if (gRAM.SPD.size() > 1) {
// DBG("Not trusting SMBIOS because SPD reports different modules...\n");
// trustSMBIOS = false;
// } else if (gRAM.SMBIOS.size() == 1) {
// channels = 1;
// }
// } else if (gRAM.SPD.size() == 1) {
// // The SMBIOS may contain table for built-in module
// if (gRAM.SMBIOS.size() <= 2) {
// if (!gRAM.SMBIOS.doesSlotForIndexExist(0) || !gRAM.SPD.doesSlotForIndexExist(2) ||
// (gRAM.SMBIOS.getSlotInfoForSlotIndex(0).Frequency != gRAM.SPD.getSlotInfoForSlotIndex(2).Frequency) ||
// (gRAM.SMBIOS.getSlotInfoForSlotIndex(0).ModuleSize != gRAM.SPD.getSlotInfoForSlotIndex(2).ModuleSize)) {
// channels = 1;
// }
// } else {
// DBG("Not trusting SMBIOS because SPD reports only one module...\n");
// trustSMBIOS = false;
// }
// } else {
// DBG("Not trusting SMBIOS because SPD reports less modules...\n");
// trustSMBIOS = false;
// }
// } else if (gRAM.SPD.doesSlotForIndexExist(0) != gRAM.SMBIOS.doesSlotForIndexExist(0)) {
// // Never trust a sneaky SMBIOS!
// DBG("Not trusting SMBIOS because it's being sneaky...\n");
// trustSMBIOS = false;
// }
// } else
if (gRAM.SMBIOS.size() == 1) {
channels = 1;
}
}
@ -1656,7 +1654,7 @@ void PatchTableType17(const SmbiosInjectedSettings& smbiosSettings, XArray<UINT1
// Check if smbios has a good total count
if ( (!gMobile || smbiosSettings.RamSlotCount == 2) && expectedCount < smbiosSettings.RamSlotCount ) {
if ( smbiosSettings.RamSlotCount > MAX_UINT8 ) {
log_technical_bug("smbiosSettings.RamSlotCount > MAX_UINT8");
// log_technical_bug("smbiosSettings.RamSlotCount > MAX_UINT8");
expectedCount = MAX_RAM_SLOTS;
}else{
expectedCount = (UINT8)smbiosSettings.RamSlotCount;
@ -2279,7 +2277,7 @@ void PatchSmbios(const SmbiosInjectedSettings& smbiosSettings) //continue
PatchTableTypeSome();
auto SlotCounts = smbiosSettings.RamSlotCount;
if ( SlotCounts > MAX_RAM_SLOTS ) {
log_technical_bug("GetTableType16() assign smbiosSettings.RamSlotCount a value bigger than MAX_RAM_SLOTS");
// log_technical_bug("GetTableType16() assign smbiosSettings.RamSlotCount a value bigger than MAX_RAM_SLOTS");
SlotCounts = MAX_RAM_SLOTS;
}
XArray<UINT16> mMemory17;

View File

@ -3520,7 +3520,7 @@ displayFreeMemory("Before RunMainMenu"_XS8);
AfterTool = true;
}
#ifdef ENABLE_SECURE_BOOT
log_technical_bug("not done yet");
//log_technical_bug("not done yet");
// if ( ChosenEntry->getREFIT_MENU_ENTRY_SECURE_BOOT() ) { // Try to enable secure boot
// EnableSecureBoot();
// MainLoopRunning = false;