From nobody Sat Nov 2 12:22:20 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 1489397321960320.11529569176207; Mon, 13 Mar 2017 02:28:41 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8BFB6803B6; Mon, 13 Mar 2017 02:28:40 -0700 (PDT) Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) (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 EE8D1803A6 for ; Mon, 13 Mar 2017 02:28:39 -0700 (PDT) Received: by mail-wr0-x22a.google.com with SMTP id u48so99538943wrc.0 for ; Mon, 13 Mar 2017 02:28:39 -0700 (PDT) Received: from localhost.localdomain ([160.169.103.157]) by smtp.gmail.com with ESMTPSA id q75sm10546830wmd.27.2017.03.13.02.28.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Mar 2017 02:28:37 -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=tEebw+oVPVtF4DEAzBKDSyPNMc0MSAFpebrph0iMNe8=; b=PtGeg6oSwbmqumVgzvMNxCefF9prsSTAYuyL8XtT1Ciu4y9uu7MV4aXjusJ3ED99MZ 0dDkANbLSkY6qxH8aebz2R/1K/SfvbZnllOXbw32FhpPXR0+T73TDcxlB46LqkOronl/ qDbG8pk3fXm+WjRvzBkn7Of5eG+rHB5U/B6q8= 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=tEebw+oVPVtF4DEAzBKDSyPNMc0MSAFpebrph0iMNe8=; b=Jydk8+nVg8C0Pqvb6Bi7u1LSApHy5HWbwBvwDvg95iPiI6vFt+msCbBtLKYGNzQYDA kNN4zwi2WPX+XVj2jV/hJx5RDCwnViMGypQXLJn+pzT9+btOZYHitnRUi4XT/6pr0+V8 LnU1Wcj0ikFeSoMJ9n+fGBnvxh6yLmdFllM0Wj356DZ3D/JoIjXJqB9AnbEUeceHLePa QgZTRLYeyguZG6W/NZZs0DnPB7vrZ+IMg0tE0BjfZd5VtzHmsYSYLZdJpw7ePEG0FOkc zEtr//czmxFJkTk+tPH42mubphAb/En2/swsKE++y3HjlPfPZACxTU0DnQ79jaqttCrf 6G3g== X-Gm-Message-State: AMke39mhlXFTs+DvE+EmGaB2pV4a23MwLgteNUdbDDfmcbiTqhuXkjYlfDfO2gAXgAwaDPX1 X-Received: by 10.223.170.200 with SMTP id i8mr30812768wrc.79.1489397318367; Mon, 13 Mar 2017 02:28:38 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Mon, 13 Mar 2017 09:28:16 +0000 Message-Id: <1489397296-23566-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [edk2] [PATCH] 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 --- EmbeddedPkg/Library/PrePiLib/PrePiLib.c | 34 +++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) 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