From nobody Sat Nov 2 16:31:02 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 148794871719022.626112372846023; Fri, 24 Feb 2017 07:05:17 -0800 (PST) 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) 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) 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) 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=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) 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 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 --- 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