From patchwork Tue May 10 12:11:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 67442 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2091673qge; Tue, 10 May 2016 05:14:01 -0700 (PDT) X-Received: by 10.140.179.76 with SMTP id z73mr43612539qhz.36.1462882441843; Tue, 10 May 2016 05:14:01 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l30si1192944qge.78.2016.05.10.05.14.01; Tue, 10 May 2016 05:14:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 76DDE6168C; Tue, 10 May 2016 12:14:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id DF3ED61103; Tue, 10 May 2016 12:12:45 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 032186163F; Tue, 10 May 2016 12:12:41 +0000 (UTC) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by lists.linaro.org (Postfix) with ESMTPS id 5103D61647 for ; Tue, 10 May 2016 12:12:09 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id g17so27080368wme.0 for ; Tue, 10 May 2016 05:12:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DS/fo37JI5z8iyvjttyMbKXmZR7PhM3BkUU5CMpfVdk=; b=Vf9PN++YhrWbO4nkIN8LxKw6j6D4le8omZcmb/9BMY6YN7AwSTSR7GU0uWadXMytaq Xv2zl2yc3KJxdv3ZGA3pBkeCX0DCIH+oFXBT32fWlZJVMaQra2wUC2MdarwNzy89Wrzj c8T1vrCllFoakWFIGZojH6MiQPDwxK37EnsdKhPKqmrTkhT8AcM5+WGsOSBh1XZa0PZ1 gUt2QOlHEPL2O81PLWYa7T5SUfiirnzpHNrLDLlKm0vy+MLDM8Hbx/CD1OunpLzWj2nX 6l0Y6Uxu5cAhzEA5GAo0t1dVnIj5P456pXw7W8lm0zXcINCw0OiWzo2sEqcmIJdty4Ao 0dyw== X-Gm-Message-State: AOPr4FXC7oMpN57MhMFj3YZuTMOISjXS949PP0aANbbrraEzI5UOCqCdW9su00xVMF158HQzVRw= X-Received: by 10.194.110.168 with SMTP id ib8mr38804451wjb.71.1462882328465; Tue, 10 May 2016 05:12:08 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id m20sm2623084wma.23.2016.05.10.05.12.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 May 2016 05:12:07 -0700 (PDT) From: Ard Biesheuvel To: linaro-uefi@lists.linaro.org Date: Tue, 10 May 2016 14:11:44 +0200 Message-Id: <1462882313-7637-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462882313-7637-1-git-send-email-ard.biesheuvel@linaro.org> References: <1462882313-7637-1-git-send-email-ard.biesheuvel@linaro.org> Cc: leo.duran@amd.com Subject: [Linaro-uefi] [PATCH 05/14] Platforms/AMD/Styx: separate trusted FW region from primary memory HOB X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" The GCD layer in DXE core claims the HOB that covers the PHIT memory allocation fully, even if this single HOB covers system memory completely. This means the memory allocation HOBs that are declared next have no effect, since they conflict with the allocation performed by DXE core, and are dropped silently. Instead, describe system memory as two separate regions, one of which can be used to host the EfiReservedMemory allocation. The EfiRuntimeServicesData allocation of the FD region also had no effect, but since it is unnecessary, let's just remove it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- Platforms/AMD/Styx/Library/MemoryInitPei/MemoryInitPeiLib.c | 56 +++++++++++++------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/Platforms/AMD/Styx/Library/MemoryInitPei/MemoryInitPeiLib.c b/Platforms/AMD/Styx/Library/MemoryInitPei/MemoryInitPeiLib.c index fd3b36ea45a1..ac172fa526c5 100644 --- a/Platforms/AMD/Styx/Library/MemoryInitPei/MemoryInitPeiLib.c +++ b/Platforms/AMD/Styx/Library/MemoryInitPei/MemoryInitPeiLib.c @@ -79,6 +79,8 @@ MemoryPeim ( IN UINT64 UefiMemorySize ) { + UINT64 Base, Size; + // Ensure PcdSystemMemorySize has been set ASSERT (PcdGet64 (PcdSystemMemorySize) != 0); @@ -86,6 +88,40 @@ MemoryPeim ( // Now, the permanent memory has been installed, we can call AllocatePages() // + Base = PcdGet64 (PcdSystemMemoryBase); + Size = PcdGet64 (PcdSystemMemorySize); + if (FixedPcdGetBool (PcdTrustedFWSupport)) { + + // + // For now, we assume that the trusted firmware region is at the base of + // system memory, since that is much easier to deal with. + // + ASSERT (Base == PcdGet64 (PcdTrustedFWMemoryBase)); + + Base += PcdGet64 (PcdTrustedFWMemorySize); + Size -= PcdGet64 (PcdTrustedFWMemorySize); + + // Reserved Trusted Firmware region + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ( EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED ), + PcdGet64 (PcdTrustedFWMemoryBase), + PcdGet64 (PcdTrustedFWMemorySize) + ); + + BuildMemoryAllocationHob ( + PcdGet64 (PcdTrustedFWMemoryBase), + PcdGet64 (PcdTrustedFWMemorySize), + EfiReservedMemoryType + ); + } + // Declare system memory BuildResourceDescriptorHob ( EFI_RESOURCE_SYSTEM_MEMORY, @@ -96,26 +132,10 @@ MemoryPeim ( EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | EFI_RESOURCE_ATTRIBUTE_TESTED ), - PcdGet64 (PcdSystemMemoryBase), - PcdGet64 (PcdSystemMemorySize) + Base, + Size ); - // Reserve firmware - BuildMemoryAllocationHob ( - PcdGet64 (PcdFdBaseAddress), - PcdGet32 (PcdFdSize), - EfiRuntimeServicesData - ); - - // Reserved Trusted Firmware region - if (FixedPcdGetBool (PcdTrustedFWSupport)) { - BuildMemoryAllocationHob ( - PcdGet64 (PcdTrustedFWMemoryBase), - PcdGet64 (PcdTrustedFWMemorySize), - EfiReservedMemoryType - ); - } - // Build Memory Allocation Hob InitMmu ();