From patchwork Sun Feb 26 18:30:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94531 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp566254qgi; Sun, 26 Feb 2017 10:30:41 -0800 (PST) X-Received: by 10.98.137.152 with SMTP id n24mr9400518pfk.43.1488133841057; Sun, 26 Feb 2017 10:30:41 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 7si13110939pfj.170.2017.02.26.10.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Feb 2017 10:30:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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) 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) 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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/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 = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize)); + Status = PeiServicesAllocatePages (EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize), + &ImageContext.ImageAddress); } } else { - ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) AllocatePages (EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize)); + Status = PeiServicesAllocatePages (EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize), + &ImageContext.ImageAddress); } - if (ImageContext.ImageAddress != 0) { + if (!EFI_ERROR (Status)) { // // Adjust the Image Address to make sure it is section alignment. //