From nobody Sat Nov 2 16:24:53 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 1488133841771281.74730921333366; Sun, 26 Feb 2017 10:30:41 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A49048212B; Sun, 26 Feb 2017 10:30:40 -0800 (PST) Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (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 CBAA38212B for ; Sun, 26 Feb 2017 10:30:38 -0800 (PST) Received: by mail-wm0-x232.google.com with SMTP id 196so15075064wmm.1 for ; Sun, 26 Feb 2017 10:30:38 -0800 (PST) Received: from localhost.localdomain ([105.149.201.216]) by smtp.gmail.com with ESMTPSA id s103sm4499474wrc.6.2017.02.26.10.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Feb 2017 10:30:36 -0800 (PST) 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:in-reply-to:references; bh=XVg5C3+o4/fR4e4gaC4Bjpv4JB1mS+5YqUZt4czq1OA=; b=fSNhJeCs7szxrb6btdZ40Se7NP7SNMBeOPQRidpOBA9vLem/ErHeu9aBpr13vdAE9W IW6Elp9GZ0qgjHMXFcnnOKwO5AGrlBmw6mBbAfLba5QZr2qM0mFNNAIpnR7djaFFBFCK TEVSJ3llXDs3zxAIEJanTFjROqyWjq/c+Cypg= 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:in-reply-to :references; bh=XVg5C3+o4/fR4e4gaC4Bjpv4JB1mS+5YqUZt4czq1OA=; b=koccGgxGZlfNi1EW9JynLO3wqqXiSJlAUlZiMrPm1RR1aKBjYTRrR8bqXTdtrz1zJU 4XSbCK7uEBC8EK0V+p25uoNqHXd48OSAhLRujdKbN8ixvwEdsCQPR45sFj79F+tDLaeI nOSvENxlYsf9fgcwJ3R8B5OSBgigAV7fFJ/MHv24AdTdWJtPG2r8S39aKKJDLwWZ/LbU Zw/2uNyjROIQRaC6segmffdrSMaAvldEg55fnOqk/lfu0M9ZELNFL88r6FCyyr3k6Wy2 EncxLMyKlgiIizTD1yb71PcK2CkOuFkYT1Pc9/AKJxsxATVUCra+J6lP9YLAhXt9glRx Eprw== X-Gm-Message-State: AMke39n7j86b3XIfFI64wnI8SJDTcIOwYo1mzOG+RYI2+9eO5ruYLR4HtXACQC+yytXwnts8 X-Received: by 10.28.52.19 with SMTP id b19mr11114221wma.134.1488133837417; Sun, 26 Feb 2017 10:30:37 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, jiewen.yao@intel.com, leif.lindholm@linaro.org Date: Sun, 26 Feb 2017 18:30:01 +0000 Message-Id: <1488133805-4773-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488133805-4773-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488133805-4773-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v3 2/6] MdeModulePkg/PeiCore: allocate BootServicesCode memory for PE/COFF images 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: feng.tian@intel.com, Ard Biesheuvel , afish@apple.com, liming.gao@Intel.com, michael.d.kinney@intel.com, lersek@redhat.com, star.zeng@intel.com 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" Ensure that any memory allocated for PE/COFF images is identifiable as a boot services code region, so that we know it requires its executable permissions to be preserved when we tighten mapping permissions later on. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Jiewen Yao --- MdeModulePkg/Core/Pei/Image/Image.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Im= age/Image.c index d659de8b3e64..8cc9ed93e9b6 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -453,12 +453,16 @@ LoadAndRelocatePeCoffImage ( // // The PEIM is not assiged valid address, try to allocate page to = load it. // - ImageContext.ImageAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN) Alloca= tePages (EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize)); + Status =3D PeiServicesAllocatePages (EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINT32) Ali= gnImageSize), + &ImageContext.ImageAddress); } } else { - ImageContext.ImageAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN) Allocate= Pages (EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize)); + Status =3D PeiServicesAllocatePages (EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINT32) Align= ImageSize), + &ImageContext.ImageAddress); } - if (ImageContext.ImageAddress !=3D 0) { + if (!EFI_ERROR (Status)) { // // Adjust the Image Address to make sure it is section alignment. // --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel