Looks good. Reviewed by: Jiewen Yao <[email protected]> Thank you Yao Jiewen
-----Original Message----- From: Laszlo Ersek [mailto:[email protected]] Sent: Sunday, January 25, 2015 07:05 To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected] Subject: [edk2] [PATCH 1/3] MdeModulePkg: Acpi: enforce exclusion between FirmwareCtrl and XFirmwareCtrl The code in AcpiTableDxe handles the installation of FADT and FACS in both possible orders. In the [FADT, FACS] installation order, the FACS is at once linked into the FADT. In the [FACS, FADT] installation order, the FACS is stashed temporarily, and it is linked into the FADT when the FADT is installed later. According to the ACPI specification, *at most one* of FADT.FirmwareCtrl and FADT.XFirmwareCtrl may be nonzero. The code is aware of this requirement, and it never sets both of them to nonzero values at once. However, the code doesn't expect the following: - The caller first installs the FACS, which is stashed. The address that is saved happens to fall below 4GB. - The caller then installs a FADT, with a zero FirmwareCtrl field, and a nonzero (pre-populated) XFirmwareCtrl field. In this case the code sets FADT.FirmwareCtrl to the less-than-4GB address of the stashed FACS, and leaves the different nonzero value in FADT.XFirmwareCtrl. This violates the ACPI specification. Prevent this by always zeroing the field that we do *not* set. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <[email protected]> --- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index 76f2199..247c398 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -618,19 +618,21 @@ AddTableToList ( // Update pointers in FADT. If tables don't exist this will put NULL pointers there. // Note: If the FIRMWARE_CTRL is non-zero, then X_FIRMWARE_CTRL must be zero, and // vice-versa. // if ((UINT64)(UINTN)AcpiTableInstance->Facs3 < BASE_4GB) { AcpiTableInstance->Fadt3->FirmwareCtrl = (UINT32) (UINTN) AcpiTableInstance->Facs3; + ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof + (UINT64)); } else { Buffer64 = (UINT64) (UINTN) AcpiTableInstance->Facs3; CopyMem ( &AcpiTableInstance->Fadt3->XFirmwareCtrl, &Buffer64, sizeof (UINT64) ); + AcpiTableInstance->Fadt3->FirmwareCtrl = 0; } AcpiTableInstance->Fadt3->Dsdt = (UINT32) (UINTN) AcpiTableInstance->Dsdt3; Buffer64 = (UINT64) (UINTN) AcpiTableInstance->Dsdt3; CopyMem ( &AcpiTableInstance->Fadt3->XDsdt, &Buffer64, @@ -747,19 +749,21 @@ AddTableToList ( // // Note: If the FIRMWARE_CTRL is non-zero, then X_FIRMWARE_CTRL must be zero, and // vice-versa. // if ((UINT64)(UINTN)AcpiTableInstance->Facs3 < BASE_4GB) { AcpiTableInstance->Fadt3->FirmwareCtrl = (UINT32) (UINTN) AcpiTableInstance->Facs3; + ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof + (UINT64)); } else { Buffer64 = (UINT64) (UINTN) AcpiTableInstance->Facs3; CopyMem ( &AcpiTableInstance->Fadt3->XFirmwareCtrl, &Buffer64, sizeof (UINT64) ); + AcpiTableInstance->Fadt3->FirmwareCtrl = 0; } // // Checksum FADT table // AcpiPlatformChecksum ( -- 1.8.3.1 ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
