From patchwork Fri Feb 24 15:04:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94485 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp728320qgi; Fri, 24 Feb 2017 07:05:14 -0800 (PST) X-Received: by 10.84.133.163 with SMTP id f32mr4432722plf.64.1487948714398; Fri, 24 Feb 2017 07:05:14 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 69si7570322pgc.364.2017.02.24.07.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 07:05:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 198.145.21.10 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 C2B9582171; Fri, 24 Feb 2017 07:05:13 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (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 50B7F82161 for ; Fri, 24 Feb 2017 07:05:12 -0800 (PST) Received: by mail-wm0-x22b.google.com with SMTP id v186so16712548wmd.0 for ; Fri, 24 Feb 2017 07:05:12 -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=bo3RDMGP0os0yZ1FCiCOmHWWahEhdZ9oNlsN0M4viw4=; b=j76Qu0Gs7FVAhEuP0qLOMqqoQuZEMNwiby5eZ+2+XRECJqvKHGgbpPNpHF/9JVImkF WfFbeqRBRfSed0FP2DAd4d0FS6thTmdFZJCtl4wVlP7o6LA5hs75yjixdk5j7XfNh/Ua MHz9SkUlV4eXhsWT+uA9YZ5xomvcCA/T0no2I= 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=bo3RDMGP0os0yZ1FCiCOmHWWahEhdZ9oNlsN0M4viw4=; b=DU0mcLgoPJWNl36pHXPNS0/JvQdw7JpN2GnBW9lpD5n1l0zs0PJx6A4A6ps+uAz+0z NoorQhL0Z/9gpcDolk2dTMfx7gOh0UfaYBGNo9MySLA7x9xibOc3xz7j/bGSEjwmTzPi sMx6zlhbK66EuBDm2npv/q3qL1/kfEp4aWc/1nQGA+VAqpRbA6hP2QOnGWU48YXgNJnv DidcYFLs4mK6xVmi17poUNBFtTA4uy+rg1+KDij9exj+yaPO5pdhhwyX7Jif7hXzwlWW 2hjfKhyOP/44KsHJSYj2rhYsOYuhQYP4MZCe7Z++vBXc+kIkOMMDV2jJc+O79jxWuVNw 0EeQ== X-Gm-Message-State: AMke39knkYV9AGw1VZ0aUJheVxt9i+5d9/wIgGEe+d3F1kOuShTnfwFpkxe5Nx1D9qaj9Eyl X-Received: by 10.28.166.199 with SMTP id p190mr3151595wme.25.1487948710903; Fri, 24 Feb 2017 07:05:10 -0800 (PST) Received: from localhost.localdomain ([105.149.201.216]) by smtp.gmail.com with ESMTPSA id w207sm2687048wmw.1.2017.02.24.07.05.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Feb 2017 07:05:10 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, afish@apple.com, leif.lindholm@linaro.org, michael.d.kinney@intel.com, liming.gao@intel.com, jiewen.yao@intel.com Date: Fri, 24 Feb 2017 15:04:56 +0000 Message-Id: <1487948699-3179-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487948699-3179-1-git-send-email-ard.biesheuvel@linaro.org> References: <1487948699-3179-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 2/5] 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, lersek@redhat.com, star.zeng@intel.com, Ard Biesheuvel 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 --- 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. //