When trying the seemingly simple fix I see it doesn't work properly because the IPL could try to stomp over the reserved range at the beginning. To really handle this correctly we would either need to reduce the descriptor from the beginning (increase start address) and end (decrease size) or even go so far as to split the descriptor into multiple ones. I'd like to hear what the module maintainer prefers to do.
Eugene -----Original Message----- From: Cohen, Eugene Sent: Thursday, June 04, 2015 1:02 PM To: edk2-devel@lists.sourceforge.net Subject: [edk2] PiSmmIpl SMRAM Reservation Logic I've been debugging an SMM IPL issue and have isolated it to an assumption in the SMRAM range reservation logic in SmmIplEntry. The logic checks to see if the reserved range resides within the SMRAM descriptor and if it does it reduces the size of the SMRAM range by the start address of the reservation. The purpose of this code is to find a large enough region to load the SMM Core. This logic is flawed in that it assumes that the reserved range is only near the end of the SMRAM descriptor: // // This range has reserved area, calculate the left free size // gSmmCorePrivate->SmramRanges[Index].PhysicalSize = SmramResRegion->SmramReservedStart - gSmmCorePrivate->SmramRanges[Index].CpuStart; Imagine the following scenario where we just reserve the first page of the SMRAM range: SMRAM Descriptor: Start: 0x80000000 Size: 0x02000000 Reserved Range: Start: 0x80000000 Size: 0x00001000 In this case the adjustment to the SMRAM range size yields zero: ReservedStart - SMRAM Start is 0x80000000 - 0x80000000 = 0. So even though most of the range is still free the IPL code decides its unusable. I don't know what the original intent was, but maybe if the math was changed to subtract the reserved size it would yield a more sensible result: gSmmCorePrivate->SmramRanges[Index].PhysicalSize = gSmmCorePrivate->SmramRanges[Index].PhysicalSize - SmramResRegion->SmramReservedSize; This logic only works if the reservation fits entirely within an SMRAM descriptor range. The PI SMM spec does not state that the reserved ranges (from SMM Configuration) must reside entirely within an SMRAM range (from SMM Access). If we want to keep the implementation this simple we should clarify this requirement in the spec. Eugene ------------------------------------------------------------------------------ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel ------------------------------------------------------------------------------ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel