From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 502747803CE for ; Thu, 10 Aug 2023 18:06:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8PF3h3yYJGrwo0FdZ/bg/QDv+EG4RrOFe5Avip8LFsc=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1691690804; v=1; b=pE7P5knI7El7mTb9Lj6Jl0Q4VAq4iFXhi1iy0ziE9bQh3uFyhaxh0ULy4wm6McN68189t7da tJjy8FhYBXzxUoIyZjwsL8utRT5maYtu1IJBcNn/6RsL9v9o9bcpkloQWtMfEOE2grthIbBmKuU MQGmfy72B/A3zRXwynlBwwA4= X-Received: by 127.0.0.2 with SMTP id nxwAYY7687511xRyZBz9uZbK; Thu, 10 Aug 2023 11:06:44 -0700 X-Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mx.groups.io with SMTP id smtpd.web11.24833.1691690802967724987 for ; Thu, 10 Aug 2023 11:06:43 -0700 X-Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-686efb9ee3cso1090843b3a.3 for ; Thu, 10 Aug 2023 11:06:42 -0700 (PDT) X-Gm-Message-State: AEGXoxeBrkLwdMbR25UDPAsmx7686176AA= X-Google-Smtp-Source: AGHT+IEZgK8HXqef4577qoTXU8jR3Wxrs9HHbVzQXQDm/WxVUf3Es1A5PkIY5D94+k0/AaRAXRB1YQ== X-Received: by 2002:a05:6a20:9191:b0:133:6219:15e2 with SMTP id v17-20020a056a20919100b00133621915e2mr4246809pzd.21.1691690802125; Thu, 10 Aug 2023 11:06:42 -0700 (PDT) X-Received: from localhost.localdomain ([50.46.253.1]) by smtp.gmail.com with ESMTPSA id c2-20020aa78802000000b00687087d8bc3sm1873579pfo.141.2023.08.10.11.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 11:06:41 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Dandan Bi Subject: [edk2-devel] [PATCH v1 0/1] Fix Memory Bin Range Calculation to Account for Guard Page Date: Thu, 10 Aug 2023 11:06:29 -0700 Message-ID: <20230810180630.1879-1-t@taylorbeebe.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,t@taylorbeebe.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=pE7P5knI; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Taylor Beebe The following flow will produce an issue: If page guards are active for EfiReservedMemoryType and SMM NULL pointer protection is active with nonstop mode enabled, then a large (600 page) allocation of EfiReservedMemoryType will be made for profiling. 0. InitSmmProfile() will be called to allocate a large range of memory for profiling. 1. gBS->AllocatePages() will be called with Type = EfiReservedMemoryType and Pages = 600. 2. gBS->AllocatePages() will call FindFreePages() to find a range of 600 pages in the memory map. 3. FindFreePages() will find a range and the binned address range will need to be updated. 4. The binned address range start will be updated to include the start of the range found by FindFreePages() but will NOT include the guard page. 5. CoreConvertPagesWithGuard() will be called to change the range type to EfiReservedMemoryType. The function will increase the conversion range to include the guard pages. 6. After converting the range, the CoreConvertRangeEx() logic will check if the range is in the binned address bounds to see if it should updated the memory type statistics. 7. The range will be outside of the binned address bounds by one page because the guard page was not included in the binned address range causing the large allocation to be unnacounted for in the of memory type statistics. 8. When the original bins are compared with the current bins to see if the system should reset with a larger original bin size, the large allocation will not be accounted for and the system will not reset with a larger bin size which is incorrect behavior. Cc: Taylor Beebe Cc: Jian J Wang Cc: Liming Gao Cc: Dandan Bi Taylor Beebe (1): MdeModulePkg: Memory Bin Range Update Accounts for Guard Page MdeModulePkg/Core/Dxe/Mem/Page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.41.0.windows.3 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107697): https://edk2.groups.io/g/devel/message/107697 Mute This Topic: https://groups.io/mt/100668861/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-