From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Martin Subject: Re: [PATCH v3 08/27] ArmVirtualizationPkg: add padding to FDT allocation Date: Mon, 9 Feb 2015 05:08:02 +0000 Message-ID: <0877601216922E4B83A7129715B5DA2BC60B6FDE19__4496.19038631699$1423458596$gmane$org@GEORGE.Emea.Arm.com> References: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org>, <1422991212-9257-9-git-send-email-ard.biesheuvel@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1422991212-9257-9-git-send-email-ard.biesheuvel@linaro.org> Content-Language: en-GB List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ard Biesheuvel , "edk2-devel@lists.sourceforge.net" , "lersek@redhat.com" , "roy.franz@linaro.org" , "leif.lindholm@linaro.org" , "stefano.stabellini@eu.citrix.com" , "Ian.Campbell@citrix.com" , "anthony.perard@citrix.com" , "christoffer.dall@linaro.org" , "xen-devel@lists.xen.org" , "ilias.biris@linaro.org" , "julien.grall@linaro.org" List-Id: xen-devel@lists.xenproject.org Reviewed-By: Olivier Martin ________________________________________ From: Ard Biesheuvel [ard.biesheuvel@linaro.org] Sent: 03 February 2015 19:19 To: edk2-devel@lists.sourceforge.net; lersek@redhat.com; Olivier Martin; roy.franz@linaro.org; leif.lindholm@linaro.org; stefano.stabellini@eu.citrix.com; Ian.Campbell@citrix.com; anthony.perard@citrix.com; christoffer.dall@linaro.org; xen-devel@lists.xen.org; ilias.biris@linaro.org; julien.grall@linaro.org Cc: Ard Biesheuvel Subject: [PATCH v3 08/27] ArmVirtualizationPkg: add padding to FDT allocation Our primary user QEMU/mach-virt presents us with a FDT blob padded to 64 KB with plenty of room to set additional properties. However, in the general case, we should only add properties after making sure there is enough room available. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Laszlo Ersek Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec | 6 ++++++ .../ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 8 +++++--- .../Library/PlatformPeiLib/PlatformPeiLib.inf | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec index 868488906643..4ebfcddfa595 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec @@ -43,6 +43,12 @@ # gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001 + # + # Padding in bytes to add to the device tree allocation, so that the DTB can + # be modified in place (default: 256 bytes) + # + gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002 + [PcdsDynamic, PcdsFixedAtBuild] # # ARM PSCI function invocations can be done either through hypervisor diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c index c500d5964b25..bdf2b57fcb1e 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -33,6 +33,7 @@ PlatformPeim ( VOID *Base; VOID *NewBase; UINTN FdtSize; + UINTN FdtPages; UINT64 *FdtHobData; UINT64 *UartHobData; INT32 Node, Prev; @@ -47,10 +48,11 @@ PlatformPeim ( ASSERT (Base != NULL); ASSERT (fdt_check_header (Base) == 0); - FdtSize = fdt_totalsize (Base); - NewBase = AllocatePages (EFI_SIZE_TO_PAGES (FdtSize)); + FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding); + FdtPages = EFI_SIZE_TO_PAGES (FdtSize); + NewBase = AllocatePages (FdtPages); ASSERT (NewBase != NULL); - CopyMem (NewBase, Base, FdtSize); + fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages)); FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData); ASSERT (FdtHobData != NULL); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf index 96019e4009ff..6675a1f91561 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -40,6 +40,7 @@ gArmTokenSpaceGuid.PcdFvBaseAddress gArmTokenSpaceGuid.PcdFvSize gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress + gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeAllocationPadding [Guids] gEarlyPL011BaseAddressGuid -- 1.8.3.2 -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590 ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782