From patchwork Mon Jan 26 19:03:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43781 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B5B7720D5D for ; Mon, 26 Jan 2015 19:04:36 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf5312865lam.2 for ; Mon, 26 Jan 2015 11:04:35 -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=F7sOK7nAeBAg7VBc74WnJqoHe8t2me0Kybc8cppsGt8=; b=iosXq/kwv7gCv7J0fwv2h3atVVo21hS+sKrB8a0CnUYOGTLQjK2NYI1/btJv0GxdhK eBjQB13BM7gxYVEaxxGmykwg39EMIy2DpqjH53oOrDwRQfo69t/w8IeRXgFhgLTtasXW 9zpqYiCPC7cNJPx+A+Ov3zQWU2VU2AdJTh8UPSeFFdueUswzaSweDIRKxNii6NRM8+AT L0eYnxhvu1XOlSuEWA4tyl4cAfUp1YdULvO2iQ97lXFF+N6bzLZI6CRq398VGRQcu54J 6kMo983nBtKLqF0jtzeBiDt+XYO1x+xyL/8SGC2IpyQvMeUnX/iLK36/OB2APoxNAyEj 3Hww== X-Gm-Message-State: ALoCoQnsKGlJip8FXjN09Ik09fBcARtokoOW06Cvka4qt49KJehfLdyfS6JPq1A+14gBqE5S+8Fb X-Received: by 10.112.163.42 with SMTP id yf10mr2112776lbb.8.1422299075648; Mon, 26 Jan 2015 11:04:35 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.225 with SMTP id i1ls574772lae.19.gmail; Mon, 26 Jan 2015 11:04:35 -0800 (PST) X-Received: by 10.112.61.228 with SMTP id t4mr23024986lbr.0.1422299075401; Mon, 26 Jan 2015 11:04:35 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id ud9si2421548lac.84.2015.01.26.11.04.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:04:35 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so9354017lab.6 for ; Mon, 26 Jan 2015 11:04:35 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr3044814lbb.41.1422299075315; Mon, 26 Jan 2015 11:04:35 -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 h5csp870317lbj; Mon, 26 Jan 2015 11:04:34 -0800 (PST) X-Received: by 10.42.88.9 with SMTP id a9mr22195801icm.34.1422299070517; Mon, 26 Jan 2015 11:04:30 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id 1si8487834icx.94.2015.01.26.11.04.29 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:04:30 -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-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFoxO-00077k-Fw; Mon, 26 Jan 2015 19:04:18 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFoxN-00077f-Ru for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:04:17 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f169.google.com; Received: from mail-wi0-f169.google.com ([209.85.212.169]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YFoxN-00071y-Ai for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:04:19 +0000 Received: by mail-wi0-f169.google.com with SMTP id h11so6206771wiw.0 for ; Mon, 26 Jan 2015 11:04:12 -0800 (PST) X-Received: by 10.180.92.199 with SMTP id co7mr6463542wib.47.1422299052389; Mon, 26 Jan 2015 11:04:12 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.8.190]) by mx.google.com with ESMTPSA id fo17sm15471007wjc.19.2015.01.26.11.04.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:04:11 -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: Mon, 26 Jan 2015 19:03:10 +0000 Message-Id: <1422299011-2409-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422299011-2409-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422299011-2409-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: 1YFoxN-00071y-Ai Subject: [edk2] [PATCH v2 08/29] 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.47 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 --- ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c index c500d5964b25..42a87309aebe 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 ( @@ -33,6 +42,7 @@ PlatformPeim ( VOID *Base; VOID *NewBase; UINTN FdtSize; + UINTN FdtPages; UINT64 *FdtHobData; UINT64 *UartHobData; INT32 Node, Prev; @@ -47,10 +57,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) + FDT_PADDING; + 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);