On 11/23/15 21:04, Wei Huang wrote: > > > On 11/23/2015 11:16 AM, Laszlo Ersek wrote: >> On 11/23/15 18:10, Ard Biesheuvel wrote: >>> The ID mapping routines on virtual platforms simply map the entire >>> address space as device memory, and then punch some holes for regions >>> that need to be mapped cacheable. On virtual platforms hosted on CPUs >>> that support a large physical address range, this may result in a lot >>> of overhead, i.e., 4 KB of page tables for each 512 GB of address >>> space, which quickly adds up (i.e. 2 MB for the architectural maximum >>> of 48 bits). >>> >>> Since there may be a platform specific limit to the size of the (I)PA >>> space that is not reflected by CPU id registers, restrict the range of >>> the ID mapping to gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize bits, >>> since we cannot manipulate mappings above that limit anwyay (because >>> they are not covered by GCD). This allows the PCD to be set by platforms >>> whose (I)PA space has a fixed limit. >>> >>> Contributed-under: TianoCore Contribution Agreement 1.0 >>> Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org> >>> --- >>> ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf | 1 + >>> ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c | 4 +++- >>> 2 files changed, 4 insertions(+), 1 deletion(-) >>> >>> diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf >>> b/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf >>> index 22ee3625c37a..3cb3fb1f3aea 100644 >>> --- a/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf >>> +++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/ArmVirtPlatformLib.inf >>> @@ -61,3 +61,4 @@ [FixedPcd] >>> gArmTokenSpaceGuid.PcdArmPrimaryCore >>> gArmTokenSpaceGuid.PcdFdBaseAddress >>> gArmTokenSpaceGuid.PcdFdSize >>> + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize >>> diff --git a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c >>> b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c >>> index 530f7d608e0b..e5536ecd8e28 100644 >>> --- a/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c >>> +++ b/ArmVirtPkg/Library/ArmVirtPlatformLib/VirtMem.c >>> @@ -97,7 +97,9 @@ ArmPlatformGetVirtualMemoryMap ( >>> // Peripheral space after DRAM >>> VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + >>> VirtualMemoryTable[1].Length; >>> VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase; >>> - VirtualMemoryTable[2].Length = ArmGetPhysAddrTop () - >>> VirtualMemoryTable[2].PhysicalBase; >>> + VirtualMemoryTable[2].Length = MIN (1ULL << FixedPcdGet8 >>> (PcdPrePiCpuMemorySize), >>> + ArmGetPhysAddrTop ()) - >>> + VirtualMemoryTable[2].PhysicalBase; >>> VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE; >>> >>> // Remap the FD region as normal executable memory >>> >> >> Reviewed-by: Laszlo Ersek <ler...@redhat.com> >> >> Wei, can you please test this version on the ThunderX? > > Without this patch, VM fails to boot with: > > PeiCreateHob fail: Length - 0x00000030 > FreeMemoryTop - 0x4007E018 > FreeMemoryBottom - 0x4007DFF8 > ASSERT /home/test/edk2/edk2.git/MdePkg/Library/PeiHobLib/HobLib.c(250): > Hob != ((void *) 0) > > This patch solves the problem with VM able to boot fully.
Thanks! Could you please reply with a Tested-by? Cheers! Laszlo > > -Wei > > >> >> Thanks >> Laszlo >> _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel