From patchwork Fri Jan 23 15:02:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43655 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5CAF8218DB for ; Fri, 23 Jan 2015 15:04:04 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf1694627wiv.2 for ; Fri, 23 Jan 2015 07:04:03 -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=wP+DK9DiNxIFi5hI098ZRQr2h+r94sU/zmAeTwFPTyY=; b=Oyo9g5jhfoHc7qHn5GUdJIbQg/E5xJR894RVbw2cEN1Kt8pKlSV7Kyq1/wdUK8Pj1T KH7zd6eHsnFgsPbY06GpdNq5lDOdvEzkB75BzmmYbPq0TpNwiN+mwLEi/5HtFk4LY1jg IHxama6VAWS9nJrhwHP8JZbKo2yoQkJWklZDAguqL4m/5IvwJ93pLv8Y5meccXQJbiZr IfuXwuLgoS3YEhPhaq97f82ZszipfxdVEJl/Ls621xMmwUSyXLwe9WGFzaY7ofzds1g0 rv4X/C6nl2E2g+cyBQ9jbbfX/TCwIdvxtj9ifGMAjczH1mrFLCfzMT1YnsKBBTUlubJj /DUQ== X-Gm-Message-State: ALoCoQkmyKcfPIRfWym9jl4xtA+n4GG5xXmZemFUvwyjhqaGNp25InS9AvOxHiWrdSjf0HVZ19ka X-Received: by 10.112.114.162 with SMTP id jh2mr419165lbb.9.1422025443601; Fri, 23 Jan 2015 07:04:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.200 with SMTP id n8ls274384lag.15.gmail; Fri, 23 Jan 2015 07:04:03 -0800 (PST) X-Received: by 10.112.144.136 with SMTP id sm8mr7803629lbb.95.1422025443391; Fri, 23 Jan 2015 07:04:03 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id jt16si767598lab.9.2015.01.23.07.04.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 07:04:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id ge10so3590813lab.11 for ; Fri, 23 Jan 2015 07:04:03 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr7741963lbm.98.1422025443242; Fri, 23 Jan 2015 07:04:03 -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.9.200 with SMTP id c8csp283014lbb; Fri, 23 Jan 2015 07:04:02 -0800 (PST) X-Received: by 10.50.56.70 with SMTP id y6mr2320636igp.27.1422025441754; Fri, 23 Jan 2015 07:04:01 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id i63si1262445ioe.106.2015.01.23.07.04.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:04:01 -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-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfm6-0001Nw-Aq; Fri, 23 Jan 2015 15:03:54 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfm4-0001Ne-Oo for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:03:52 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f50.google.com; Received: from mail-wg0-f50.google.com ([74.125.82.50]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YEfm0-0002do-NR for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:03:52 +0000 Received: by mail-wg0-f50.google.com with SMTP id b13so7921128wgh.9 for ; Fri, 23 Jan 2015 07:03:42 -0800 (PST) X-Received: by 10.180.198.51 with SMTP id iz19mr4446992wic.65.1422025422695; Fri, 23 Jan 2015 07:03:42 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.136.117]) by mx.google.com with ESMTPSA id pl1sm2176036wic.16.2015.01.23.07.03.39 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:03:41 -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 Date: Fri, 23 Jan 2015 15:02:55 +0000 Message-Id: <1422025390-8036-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422025390-8036-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422025390-8036-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 -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YEfm0-0002do-NR Subject: [edk2] [PATCH v1 06/21] 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.215.52 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 Signed-off-by: Ard Biesheuvel --- .../Library/PlatformPeiLib/PlatformPeiLib.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c index f2404f89d152..540474608deb 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -24,6 +24,15 @@ #include #include +// +// We may want to apply some changes to the device tree before passing it +// to the OS: for instance, if we find a PL031 RTC node and attach our +// runtime driver to it, we should disable it in the device tree by setting +// its status property to "disabled". Add some padding to make sure this is +// possible. +// +#define FDT_PADDING 256 + EFI_STATUS EFIAPI PlatformPeim ( @@ -32,7 +41,7 @@ PlatformPeim ( { VOID *Base; VOID *NewBase; - UINTN FdtSize; + UINTN FdtPages; UINTN *FdtHobData; UINT64 *UartHobData; INT32 Node, Prev; @@ -46,10 +55,10 @@ PlatformPeim ( Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); ASSERT (Base != NULL && fdt_check_header (Base) == 0); - FdtSize = fdt_totalsize (Base); - NewBase = AllocatePages (EFI_SIZE_TO_PAGES (FdtSize)); + FdtPages = EFI_SIZE_TO_PAGES (fdt_totalsize (Base) + FDT_PADDING); + 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);