From patchwork Tue Feb 24 18:02:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44965 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A1EA2029F for ; Tue, 24 Feb 2015 18:05:38 +0000 (UTC) Received: by wesw55 with SMTP id w55sf18403855wes.0 for ; Tue, 24 Feb 2015 10:05:37 -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:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=ZhfJljS7CcgoekJIIu+m8ZhzKHVAVtykZRg5poVEsDk=; b=PcfIlldwysUM8LvFBZ286JiEaPcSIXveOZmkN/hSSMdbWMtRTAVXBslrcubuXfS4ua HE8CffhWp0+d2NlXpXORy2p5EXuZ24l27Una5UCd8qDaCNx+cvW5lWC99n7JBzjtbBy7 u4JrUICquMz1skqSDD35Chm4HjkHx5SGJrvNrJUYnAmvrlcrV7naGM9KQa3iQKJ42wF4 GqXVlpp4N6cenIDp6tn829LfDTkMC9wZozPak1XtdksaAqyYcnRLHDDFNqwG5ACfbXQD ShhP0cGPy/Xo2IH2CRRumuHT8ySt16i1oOHngFUVmq5AWlZ6JJPKvFmCjs3EXPPr4ocA tpUg== X-Gm-Message-State: ALoCoQkllOptfIRg3Hl5Rk0faL6H5XsJUrHxNUtW2m2pmaBELQ3gQ7cxotiqweb/NiRXCuBUxUMh X-Received: by 10.152.4.229 with SMTP id n5mr2343312lan.1.1424801137752; Tue, 24 Feb 2015 10:05:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.132 with SMTP id rk4ls268535lac.79.gmail; Tue, 24 Feb 2015 10:05:37 -0800 (PST) X-Received: by 10.152.43.67 with SMTP id u3mr15679567lal.10.1424801137581; Tue, 24 Feb 2015 10:05:37 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id cr12si23074091lad.39.2015.02.24.10.05.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 10:05:37 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by labgq15 with SMTP id gq15so27690216lab.3 for ; Tue, 24 Feb 2015 10:05:37 -0800 (PST) X-Received: by 10.152.28.5 with SMTP id x5mr15156710lag.112.1424801137297; Tue, 24 Feb 2015 10:05:37 -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 h5csp2078660lbj; Tue, 24 Feb 2015 10:05:36 -0800 (PST) X-Received: by 10.52.254.2 with SMTP id ae2mr17307649vdd.33.1424801129680; Tue, 24 Feb 2015 10:05:29 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b17si19147164vdf.20.2015.02.24.10.05.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:05:29 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJqW-0001q2-A7; Tue, 24 Feb 2015 18:04:36 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQJqU-0001nw-Ep for xen-devel@lists.xen.org; Tue, 24 Feb 2015 18:04:34 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 8B/26-03170-13DBCE45; Tue, 24 Feb 2015 18:04:33 +0000 X-Env-Sender: ard.biesheuvel@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1424801073!12574111!1 X-Originating-IP: [74.125.82.45] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4293 invoked from network); 24 Feb 2015 18:04:33 -0000 Received: from mail-wg0-f45.google.com (HELO mail-wg0-f45.google.com) (74.125.82.45) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 24 Feb 2015 18:04:33 -0000 Received: by wghk14 with SMTP id k14so7005262wgh.3 for ; Tue, 24 Feb 2015 10:04:33 -0800 (PST) X-Received: by 10.194.63.230 with SMTP id j6mr10818158wjs.31.1424801072931; Tue, 24 Feb 2015 10:04:32 -0800 (PST) Received: from ards-macbook-pro.lan (bl11-65-113.dsl.telepac.pt. [85.244.65.113]) by mx.google.com with ESMTPSA id w8sm12792521wja.4.2015.02.24.10.04.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Feb 2015 10:04:31 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, olivier.martin@arm.com, lersek@redhat.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, xen-devel@lists.xen.org, julien.grall@linaro.org, jordan.l.justen@intel.com, michael.d.kinney@intel.com Date: Tue, 24 Feb 2015 18:02:49 +0000 Message-Id: <1424800990-15777-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1424800990-15777-1-git-send-email-ard.biesheuvel@linaro.org> References: <1424800990-15777-1-git-send-email-ard.biesheuvel@linaro.org> Cc: wei.liu2@citrix.com, Ard Biesheuvel Subject: [Xen-devel] [PATCH v5 08/29] ArmVirtualizationPkg: add padding to FDT allocation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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.53 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 List-Archive: 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 Reviewed-by: Olivier Martin 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 7ab2405b8848..791b45bf500b 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