From patchwork Tue Feb 3 19:19:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44289 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A47E42034D for ; Tue, 3 Feb 2015 19:21:24 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf22200049lab.3 for ; Tue, 03 Feb 2015 11:21:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=GdW4+q8QxXbp6QbaEuc36nnwsq1XN05R6CLocweL8vk=; b=JQKqSPpVJd0qnnIXO/zt8KRDrtYELh402rBrvqYPDOM28PDorYTQ0oEnQA2A1k46fV 4icXDYcdm4v+NrBvbJvdjxZGSpFkGl/7/EiwVrCSf1gsRRuO9//P/8cf6WGupppnG4Mq ZZYnwmOp5rajMQLCUlaFMoa9IkbPHWF4d9ugg60zREp5AwqQZSBZKfnwSSE7afbr493g iZrjIDO6BPBUZ8trSo02fgEBnIm8/aOIDVAgoaLKJwqumnHrEa1DdyQ/q4ElD7NPab4f U2FqC32JZqFkPynqIiFc0gQ8OHxhy0KCHC/CofNRMv+X4nCyvuGH7QAuI5vnIx6aq5H1 pOPw== X-Gm-Message-State: ALoCoQnDexfM8foQAyIJLt/wgQJ6qcDouf3f1fkdrv0nMymcunmvnva6wmd1LdsSZ703P7TFKSBi X-Received: by 10.112.131.106 with SMTP id ol10mr3394108lbb.20.1422991283392; Tue, 03 Feb 2015 11:21:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.74 with SMTP id j10ls422720lag.7.gmail; Tue, 03 Feb 2015 11:21:23 -0800 (PST) X-Received: by 10.152.4.233 with SMTP id n9mr26950922lan.61.1422991283244; Tue, 03 Feb 2015 11:21:23 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id p8si10678160laf.50.2015.02.03.11.21.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:21:23 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id 10so40428675lbg.10 for ; Tue, 03 Feb 2015 11:21:23 -0800 (PST) X-Received: by 10.152.20.4 with SMTP id j4mr9778901lae.29.1422991283105; Tue, 03 Feb 2015 11:21:23 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp33928lbj; Tue, 3 Feb 2015 11:21:22 -0800 (PST) X-Received: by 10.107.154.17 with SMTP id c17mr30338692ioe.74.1422991280044; Tue, 03 Feb 2015 11:21:20 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ci2si10357588igc.46.2015.02.03.11.21.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:21:20 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YIj27-0008Sj-84; Tue, 03 Feb 2015 19:21:11 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YIj25-0008Sa-QY for edk2-devel@lists.sourceforge.net; Tue, 03 Feb 2015 19:21:09 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f178.google.com; Received: from mail-wi0-f178.google.com ([209.85.212.178]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YIj24-0002Du-Qt for edk2-devel@lists.sourceforge.net; Tue, 03 Feb 2015 19:21:09 +0000 Received: by mail-wi0-f178.google.com with SMTP id bs8so24047217wib.5 for ; Tue, 03 Feb 2015 11:21:02 -0800 (PST) X-Received: by 10.180.76.133 with SMTP id k5mr36979702wiw.30.1422991262803; Tue, 03 Feb 2015 11:21:02 -0800 (PST) Received: from ards-macbook-pro.local (73.233.28.37.rev.vodafone.pt. [37.28.233.73]) by mx.google.com with ESMTPSA id eb7sm25860139wic.11.2015.02.03.11.20.59 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 11:21:01 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.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 Date: Tue, 3 Feb 2015 19:19:53 +0000 Message-Id: <1422991212-9257-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422991212-9257-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YIj24-0002Du-Qt Subject: [edk2] [PATCH v3 08/27] ArmVirtualizationPkg: add padding to FDT allocation X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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