From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: lersek@redhat.com, feng.tian@intel.com, star.zeng@intel.com, Ard Biesheuvel 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: [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: , X-List-Received-Date: Fri, 24 Feb 2017 15:05:15 -0000 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(-) 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)); } } } -- 2.7.4