From nobody Fri May 17 06:07:50 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 14894784759681020.4307486107394; Tue, 14 Mar 2017 01:01:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4133F8033C; Tue, 14 Mar 2017 01:01:14 -0700 (PDT) Received: from mail-wr0-x22e.google.com (mail-wr0-x22e.google.com [IPv6:2a00:1450:400c:c0c::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CC8C5802A5 for ; Tue, 14 Mar 2017 01:01:12 -0700 (PDT) Received: by mail-wr0-x22e.google.com with SMTP id l37so118384909wrc.1 for ; Tue, 14 Mar 2017 01:01:12 -0700 (PDT) Received: from localhost.localdomain ([197.130.229.126]) by smtp.gmail.com with ESMTPSA id p93sm27974450wrc.67.2017.03.14.01.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Mar 2017 01:01:10 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BhtiWMd5S96t+Zpnd/sW28vNKUi0deuD2mEFljPpbPo=; b=OQlh7OQo+qCSgMoIqpFEUEX8kcp4DHcPfZb4350yFudvIPBz7ZnO1kzOhd7Wq8c0fJ 6X1/7uu+RF1krKb90myAEC+sT7sijRwGG3yY3p9Bp+b4HwLFFS3fRj+xHSqUV9Uwu2k6 eOXZ95ZkbvxCi23Iu2fukLCAjMyv+qCVRCN1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BhtiWMd5S96t+Zpnd/sW28vNKUi0deuD2mEFljPpbPo=; b=saSC+De1cmY7pR8He4Jxf8UaSVQvbVgh67GVkvmDzuxnpwWdWkXk5W6H8NYpQF6dXK sZPVILEmqqO4LxeosYPVXSetB7Akaya1siBrp82H/5ZdNSI4vzRmRdvtuiOgxBXjWOKA 32tbcx7dkbEM+wuQZRefzAoJffON2W+2/Mv0Tysej4lM0hPepRE4NS2+qTHgO/VuWexM Vy9w443FTuIQ3hV1tyNoQ+HqL1ckFmP71u4FRp7c3qxAJcnvXqWz9lY2ZK4XuBsn2cCt 9jX92hebO74ZK+EZIg3FQLNa1RfYpv/HLGOUyCdUVAW44Hw3C9rWEbKYfPMc0jEWj5i6 B95w== X-Gm-Message-State: AMke39n2HUJrD95y9mecU1yxmMBzzbwzATjODZGt9a5qqWoOUsTmwCNvbfdFRdHvw0jAWBN+ X-Received: by 10.223.155.135 with SMTP id d7mr29169323wrc.99.1489478470978; Tue, 14 Mar 2017 01:01:10 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Tue, 14 Mar 2017 08:01:04 +0000 Message-Id: <1489478464-5737-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [edk2] [PATCH v2] EmbeddedPkg/PrePiLib: allocate code pages for DxeCore X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryan.harkin@linaro.org, sigmaepsilon92@gmail.com, lersek@redhat.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The recently introduced memory protection features inadvertently broke the boot on all PrePi platforms, because the changes to explicitly use EfiBootServicesCode for loading the DxeCore PE/COFF image need to be applied in a different way for PrePi. So add a simple helper function that sets the type of an allocation to EfiBootServicesCode, and invoke it to allocate the space for DxeCore. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Tested-by: Michael Zimmermann Reviewed-by: Leif Lindholm --- v2: add missing MemoryAllocationLib.h include add Michael's T/b EmbeddedPkg/Library/PrePiLib/PrePi.h | 1 + EmbeddedPkg/Library/PrePiLib/PrePiLib.c | 34 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/EmbeddedPkg/Library/PrePiLib/PrePi.h b/EmbeddedPkg/Library/Pre= PiLib/PrePi.h index 607561cd2496..84eca23ec8a6 100644 --- a/EmbeddedPkg/Library/PrePiLib/PrePi.h +++ b/EmbeddedPkg/Library/PrePiLib/PrePi.h @@ -28,6 +28,7 @@ #include #include #include +#include =20 #include =20 diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c b/EmbeddedPkg/Library/= PrePiLib/PrePiLib.c index 9a1ef344df6e..bba8e7384edc 100644 --- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c +++ b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c @@ -28,6 +28,38 @@ SecWinNtPeiLoadFile ( IN EFI_PHYSICAL_ADDRESS *EntryPoint ); =20 +STATIC +VOID* +EFIAPI +AllocateCodePages ( + IN UINTN Pages + ) +{ + VOID *Alloc; + EFI_PEI_HOB_POINTERS Hob; + + Alloc =3D AllocatePages (Pages); + if (Alloc =3D=3D NULL) { + return NULL; + } + + // find the HOB we just created, and change the type to EfiBootServicesC= ode + Hob.Raw =3D GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION); + while (Hob.Raw !=3D NULL) { + if (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress =3D=3D (UI= NTN)Alloc) { + Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D EfiBootServices= Code; + return Alloc; + } + Hob.Raw =3D GET_NEXT_HOB (Hob); + Hob.Raw =3D GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw); + } + + ASSERT (FALSE); + + FreePages (Alloc, Pages); + return NULL; +} + =20 EFI_STATUS EFIAPI @@ -54,7 +86,7 @@ LoadPeCoffImage ( // // Allocate Memory for the image // - Buffer =3D AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSi= ze)); + Buffer =3D AllocateCodePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.Ima= geSize)); ASSERT (Buffer !=3D 0); =20 =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel