From patchwork Fri Feb 24 15:04:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94486 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp728358qgi; Fri, 24 Feb 2017 07:05:17 -0800 (PST) X-Received: by 10.84.172.1 with SMTP id m1mr4453742plb.5.1487948717383; Fri, 24 Feb 2017 07:05:17 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 78si7588640pgh.202.2017.02.24.07.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 07:05:17 -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 00F2482164; Fri, 24 Feb 2017 07:05:16 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) (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 CB60D82164 for ; Fri, 24 Feb 2017 07:05:14 -0800 (PST) Received: by mail-wr0-x235.google.com with SMTP id o22so9319247wro.1 for ; Fri, 24 Feb 2017 07:05:14 -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=ry1ipyrL6ZsNhWbUSOe31tUIKoFxO6pcpsUY8K8z6lE=; b=cXeGEnrp5PVkHqtmzMt3Rhah8wP7WmQfyPX5MTnIPyU1xfUrVJmPKWaFUFcjBR9ugG 045LZyzvoXwS2zvynTsyE9CwR4Ujsj5Z/I/7XUw30N2X96PyIJ5NrNbs2eeiptdY96C0 Moo1W7W0Y8ah1tA1QFGXmkw2Tsy8FJJjiz8pY= 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=ry1ipyrL6ZsNhWbUSOe31tUIKoFxO6pcpsUY8K8z6lE=; b=KVlbqCJv9ZOd02eEN1/cXpuUcc1+UZYr/lkcu3RRFm2FUb38FaBbYCVfF5uOf8s2CS ZjABDXHp5vZpA3Dsyfm2zphONcRTj23YCUZMlP2FwnBt6dFd77m0pf7+3IkVm4zuGyGy /tcTe8Ry2DWdmSCOuma64tt06eHrWbHUyCiiv/Wn5Ie8/eELZqV8mINHW6Ln8DYTMMwU lyVZkDWL8LEO/aJk3f27SWKBOATdhPYoUK603F8h9EcTgQwOrFBSZgzyR/JRECLsBmcu +ULASdMDj+ITW8pdg8AO/EloHTN+HHXjOHvhIXtZ+/UljUj0ZwLOGAUVNLi4jT5Wfp6z TPGg== X-Gm-Message-State: AMke39l2u0z/ofvYrDsF/FCZ1uswqLNxjWr18QMyncvJWrMDwQlGugXDektVU/1LbUiF90gH X-Received: by 10.223.163.20 with SMTP id c20mr3315808wrb.114.1487948713266; Fri, 24 Feb 2017 07:05:13 -0800 (PST) Received: from localhost.localdomain ([105.149.201.216]) by smtp.gmail.com with ESMTPSA id w207sm2687048wmw.1.2017.02.24.07.05.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Feb 2017 07:05:12 -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:57 +0000 Message-Id: <1487948699-3179-4-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 3/5] MdeModulePkg/DxeCore: pass pool type to CoreFreePoolPages () 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" In order to make it easier to manage memory permission attributes of page allocations performed on behalf of the pool allocator, pass the pool type when freeing pages. This way, we can easily check whether the freed pages need to have their permission attributes changed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Mem/Imem.h | 2 ++ MdeModulePkg/Core/Dxe/Mem/Page.c | 1 + MdeModulePkg/Core/Dxe/Mem/Pool.c | 5 +++-- 3 files changed, 6 insertions(+), 2 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/Dxe/Mem/Imem.h b/MdeModulePkg/Core/Dxe/Mem/Imem.h index fb53f95575f0..fde533100d37 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Imem.h +++ b/MdeModulePkg/Core/Dxe/Mem/Imem.h @@ -77,12 +77,14 @@ CoreAllocatePoolPages ( /** Internal function. Frees pool pages allocated via AllocatePoolPages () + @param PoolType The memory type of the pool pages @param Memory The base address to free @param NumberOfPages The number of pages to free **/ VOID CoreFreePoolPages ( + IN EFI_MEMORY_TYPE PoolType, IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages ); diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index bda4f6397e91..6330d41e7b3b 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1871,6 +1871,7 @@ CoreAllocatePoolPages ( **/ VOID CoreFreePoolPages ( + IN EFI_MEMORY_TYPE PoolType, IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages ) diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index 7afd2d312c1d..9e15e0cfb5b2 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -624,7 +624,7 @@ CoreFreePoolI ( // NoPages = EFI_SIZE_TO_PAGES(Size) + EFI_SIZE_TO_PAGES (Granularity) - 1; NoPages &= ~(UINTN)(EFI_SIZE_TO_PAGES (Granularity) - 1); - CoreFreePoolPages ((EFI_PHYSICAL_ADDRESS) (UINTN) Head, NoPages); + CoreFreePoolPages (Pool->MemoryType, (EFI_PHYSICAL_ADDRESS) (UINTN) Head, NoPages); } else { @@ -680,7 +680,8 @@ CoreFreePoolI ( // // Free the page // - CoreFreePoolPages ((EFI_PHYSICAL_ADDRESS) (UINTN)NewPage, EFI_SIZE_TO_PAGES (Granularity)); + CoreFreePoolPages (Pool->MemoryType, (EFI_PHYSICAL_ADDRESS) (UINTN)NewPage, + EFI_SIZE_TO_PAGES (Granularity)); } } }