From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-x242.google.com (mail-vk0-x242.google.com [IPv6:2607:f8b0:400c:c05::242]) (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 A8666803AB for ; Mon, 13 Mar 2017 02:55:51 -0700 (PDT) Received: by mail-vk0-x242.google.com with SMTP id k62so4642363vkb.2 for ; Mon, 13 Mar 2017 02:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=SiJ5uCM1sOu3DT/aDD7Zw7mXApPQJ3/SCoTz+6pI6i8=; b=JlTIE1pYlro9UzGs8nCUcRlo5ssLWNkG4HEop3pCFYhhDlo1zLrlqQ4HKDYDHBqagO lExlFkSwrNpmz9/Cze4KquTOG85jpWX5xMF7UxQvC12nCFyCqTk3xj7sehPpl+32h7/K wQ3ppGwLB7t/5AMtDpsiP1MGA0f+1KPtb57/+Rcbc5vuf1vgRFmJz7avtR7biQ3XpKER r5Qcoc3T/8jm9Q0Lwsyn1wsW3qlN9gCwH2Dgur04dmDVsOU9ElPaBmxZkS3botJmkEu9 Bh3AfPQgu9Bx63Lt9qBTXX+DqQKg50akGFvJX4stHJkUnd7LioOKMl1rYZY9nlyMv02C hDDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=SiJ5uCM1sOu3DT/aDD7Zw7mXApPQJ3/SCoTz+6pI6i8=; b=QDcTtpmf27wIGpU3tTKw6u95ZP0zhnQ1ODtfCIP8QtQIN1oZaA+QSQO3CCbvaAEQFH Z6moH0Ft5zGf4LaDtD5NQvCz99e4LxZoLy3bl2eIlTm784DWryYj478nn5Pf0n9BqN5d mRLyW0mAZS86qJrGC6IK/VC40c/P79A+i8YlOftqkTTcAhVS56xVPZdwqHZ9kYgxaH7y acbpvaGkKytkpOaVEItl/p4gh5gG50cnkm0qcXa84qZVB7UcBciSDHk0Ga8WNF+f7SFK N2RjwjrArpNXxdckKMHKRrxxJJnNTKGnIilnR4LOQTaUetiNrpy9TWDNh0x7sUVpqnjI Oyxg== X-Gm-Message-State: AMke39k+fJPBO4CuN7V6iWCiF+xMHqEyCcp/Auq6Ce8VA2JoZ7nncyo56aKecekgJPlv0DkTrNSfMBAnLCuYfw== X-Received: by 10.31.89.197 with SMTP id n188mr11775675vkb.58.1489398950509; Mon, 13 Mar 2017 02:55:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.151.68 with HTTP; Mon, 13 Mar 2017 02:55:50 -0700 (PDT) In-Reply-To: <1489397296-23566-1-git-send-email-ard.biesheuvel@linaro.org> References: <1489397296-23566-1-git-send-email-ard.biesheuvel@linaro.org> From: Michael Zimmermann Date: Mon, 13 Mar 2017 10:55:50 +0100 Message-ID: To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Ryan Harkin , Laszlo Ersek Subject: Re: [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: , X-List-Received-Date: Mon, 13 Mar 2017 09:55:51 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I had to include because I was getting this error: EmbeddedPkg/Library/PrePiLib/PrePiLib.c: In function =E2=80=98AllocateCodeP= ages=E2=80=99: EmbeddedPkg/Library/PrePiLib/PrePiLib.c:59:3: error: implicit declaration of function =E2=80=98FreePages=E2=80=99 [-Werror=3Dimplicit-function-declaration] FreePages (Alloc, Pages); Other than that it works great(you can take this as a Tested-By). Sry if it's a stupid question because I didn't look into all of the protection code yet, but wouldn't this mark everything as Code(including Data)? Thanks Michael On Mon, Mar 13, 2017 at 10:28 AM, Ard Biesheuvel wrote: > 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/Librar= y/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 > ); > > +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 EfiBootService= sCode > + Hob.Raw =3D GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION); > + while (Hob.Raw !=3D NULL) { > + if (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress =3D=3D (= UINTN)Alloc) { > + Hob.MemoryAllocation->AllocDescriptor.MemoryType =3D EfiBootServic= esCode; > + 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; > +} > + > > EFI_STATUS > EFIAPI > @@ -54,7 +86,7 @@ LoadPeCoffImage ( > // > // Allocate Memory for the image > // > - Buffer =3D AllocatePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.Image= Size)); > + Buffer =3D AllocateCodePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.I= mageSize)); > ASSERT (Buffer !=3D 0); > > > -- > 2.7.4 >