Apply last patch's idea to LocalApicNMI as well

and resolves an uninitialized read:
......
   LocalApicNMI++;
   ApicTable->Length += LocalApicNMI->Length;
......
This commit is contained in:
Florin9doi 2019-09-14 17:02:39 +03:00
parent d5021f3f04
commit ebcac449c7

View File

@ -1718,7 +1718,6 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
BOOLEAN DsdtLoaded = FALSE;
BOOLEAN NeedUpdate = FALSE;
OPER_REGION *tmpRegion;
INTN ApicCPUBase = 0;
CHAR16* AcpiOemPath = PoolPrint(L"%s\\ACPI\\patched", OEMPath);
DbgHeader("PatchACPI");
@ -2128,12 +2127,6 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
ApicTable = (EFI_ACPI_DESCRIPTION_HEADER*)(UINTN)(*xf);
// ApicLen = ApicTable->Length;
ProcLocalApic = (EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE *)(UINTN)(*xf + sizeof(EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER));
//determine first ID of CPU. This must be 0 for Mac and for good Hack
// but = 1 for stupid ASUS
//
if (ProcLocalApic->Type == EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC) {
ApicCPUBase = ProcLocalApic->AcpiProcessorId; //we want first instance
}
while ((ProcLocalApic->Type == EFI_ACPI_4_0_PROCESSOR_LOCAL_APIC) && (ProcLocalApic->Length == 8)) {
if (ProcLocalApic->Flags & EFI_ACPI_4_0_LOCAL_APIC_ENABLED) {
@ -2150,7 +2143,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
ApicCPUNum = gCPUStructure.Threads;
}
DBG("ApicCPUBase=%d ApicCPUNum=%d\n", ApicCPUBase, ApicCPUNum);
DBG("ApicCPUNum=%d\n", ApicCPUNum);
//reallocate table
if (gSettings.PatchNMI) {
BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS;
@ -2198,11 +2191,11 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion)
for (Index = 0; Index < ApicCPUNum; Index++) {
LocalApicNMI->Type = EFI_ACPI_4_0_LOCAL_APIC_NMI;
LocalApicNMI->Length = sizeof(EFI_ACPI_4_0_LOCAL_APIC_NMI_STRUCTURE);
LocalApicNMI->AcpiProcessorId = (UINT8)(ApicCPUBase + Index);
LocalApicNMI->AcpiProcessorId = acpi_cpu_processor_id[Index];
LocalApicNMI->Flags = 5;
LocalApicNMI->LocalApicLint = 1;
LocalApicNMI++;
ApicTable->Length += LocalApicNMI->Length;
ApicTable->Length += sizeof(EFI_ACPI_4_0_LOCAL_APIC_NMI_STRUCTURE);
}
DBG("ApicTable new Length=%d\n", ApicTable->Length);
// insert corrected MADT