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 65320AC1A44 for ; Fri, 1 Sep 2023 20:43:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=wYEzRB+4nJSmn/8aKG5ubvHHWnq4Q7H00IUy66uegwg=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1693601004; v=1; b=EQvt6+w4ZAwS9nKBeMtZWIw7F+Mqoxk6Z1YIzAaWWDfjsWANtdDG20i6GObUDp/P6vF5TR+n pJMU3g3DIZ5pmAnyfycHHYmX0jn3QRAD34IJ2cICgDzrxJbwenhVVb7jlaKVGXIH1myHbytnbBW mBi8FWWmBV54EIo+bOez3CT8= X-Received: by 127.0.0.2 with SMTP id 8KsBYY7687511xx6DzusfyM0; Fri, 01 Sep 2023 13:43:24 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.6140.1693601003485022200 for ; Fri, 01 Sep 2023 13:43:23 -0700 X-Received: from [10.137.194.171] (unknown [131.107.1.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 7F399212A77F; Fri, 1 Sep 2023 13:43:22 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7F399212A77F Message-ID: Date: Fri, 1 Sep 2023 13:43:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue To: devel@edk2.groups.io, nhi@os.amperecomputing.com, Ard Biesheuvel Cc: huangming@linux.alibaba.com, Sami Mujawar , Ard Biesheuvel , Jiewen Yao , Supreeth Venkatesh , ming.huang-@outlook.com References: <20220209122558.60329-1-huangming@linux.alibaba.com> <20220209122558.60329-3-huangming@linux.alibaba.com> <14f25a95-7153-4eec-8804-a3da768ccb11@linux.alibaba.com> <0e0bc14c-88a1-21a8-0be7-34ed023e1127@amperemail.onmicrosoft.com> From: "Oliver Smith-Denny" In-Reply-To: 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,osde@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rDqI6hMnCmKePLrarL9gYtzmx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=EQvt6+w4; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=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 On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote: > Hi Ard, >=20 > Thanks for your response on this patch. Please see my reply inline... >=20 > On 8/30/2023 8:10 PM, Ard Biesheuvel wrote: >> [EXTERNAL EMAIL NOTICE: This email originated from an external sender.= =20 >> Please be mindful of safe email handling and proprietary information=20 >> protection practices.] >> >> >> On Wed, 16 Aug 2023 at 10:56, Nhi Pham=20 >> wrote: >>> Hi Ard and Ming, >>> >>> I have been seeing an issue with StandaloneMM HobLib that can be fixed >>> by this patch as well. >>> >>> The function CreateHob() in the HobLib instance >>> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.i= nf >>> does not work at all. The HobList is early created by the >>> StandaloneMmCoreEntryPoint then it is relocated on the heap memory by >>> StandaloneMmCore. But the FreeMemoryTop and FreeMemoryBottom are not >>> updated accordingly and the HOB free memory top is overlapped with the >>> heap space. This causes the CreateHob() function to not work as >>> expected. Introducing the PcdMemoryHobSize is reasonable to fix this=20 >>> issue. >>> >>> I tested this patch in my end. >>> >>> Tested-by: Nhi Pham >>> >> Thanks for reminding me. >> >> So if the HOB creation is completely broken, are we sure this is the >> correct fix? Wouldn't it be better to update FreeMemoryTop and >> FreeMemoryBottom to the correct values? >=20 > Per your question, I had a deep dive into the HOB today. I think I need= =20 > to clarify further the issue to make sure that we are on the same page. >=20 > 1. When the base of the HOB list (HobStart) is reallocated in the MM=20 > heap memory, the Hob->EfiEndOfHobList must be adjusted accordingly=20 > compared to the new HOB base. Currently, we are missing that. That=20 > causes the CreateHob() function does not work. The GetNextHob() function= =20 > always look up the old HOB list instead of the new HOB list. >=20 > 2. The Memory Allocation StandaloneMmPkg/Core/Page.c does not update the= =20 > Hob->EfiFreeMemoryTop, this may cause the MM heap space and HOB space to= =20 > be overlapped at some points. >=20 > It sounds like the issue on the memory allocation in StandaloneMM. For=20 > #1, I think we should write a new patch for it. For #2, could you advise? >=20 If I am understanding this correctly, this is only an issue when HOBs are created in StMM, i.e. not from HOBs that are passed in. Is this correct? If so, is HOB creation in StMM and supported use case? The only instance a quick search turns up is the ARM StMM Core entry, where some information from TF-A is converted to HOB format. Do we have any other use cases (and curious more on this use case). My thought process would be that StMM would not create any HOBs. Depending on FW configuration, it may receive HOBs from PEI. In PEI/DXE to StMM communication, we should be using the MM_Communicate interface. But in StMM to StMM communication, I would expect we would go through interfaces like protocols, PCDs, or UEFI variables. Any reason for HOBs that I'm not thinking of? I'm wondering if the answer here is to address what seemingly is one (or a very small set) of use cases and remove the HOB creation code in StMM altogether. Thanks, Oliver -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108232): https://edk2.groups.io/g/devel/message/108232 Mute This Topic: https://groups.io/mt/89020085/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-