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 6E67A740059 for ; Thu, 31 Aug 2023 08:20:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=fBJ03AkYKbECBoIQ9xeWKhFPTmnibTyJQFupACDHX4I=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Message-ID:Date:User-Agent:Subject:To:Cc:References:From:In-Reply-To:MIME-Version: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=1693470044; v=1; b=X5cnbMRLq8TMQ7lBpatzU2bUJDbuRNmry5PP1oA8rDvI7cbShS3llcBHDm8nuGXwwj0kCjnL JhF3dqHQKvJV20QjyAoPcBjm6AtGSmJN2OzPjKU35xthoHNpNMyriU7J1FTSRn7Wfo7g+T8Q+6N tUDE64jXgPtw7UbRg1WNmVX0= X-Received: by 127.0.0.2 with SMTP id yIQvYY7687511xov8vINZcPw; Thu, 31 Aug 2023 01:20:44 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.95]) by mx.groups.io with SMTP id smtpd.web10.11949.1693470043459160885 for ; Thu, 31 Aug 2023 01:20:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VDdr89ZiD771fh1B6GQCFBKIzTXtgZIpj009CuvBfVgO3bGVQ3yP7KhTJbSYGZmqC76nR0GXVLDi6ijw9/LV8XQsjVhNZWs4prTHPxKxzbpMw9YSS/Ae8ind32dQyhbR72HHNNCeJupsnoDEAYPUXzSJv8I0wDWs/Y8lRY9NLvLSBOa3UBsEkNdaWoL8Z7z4i0sTa5A2T5AhsGps3Cp2KSgkyw1D61uunqEDL1CdQ4Ib49fkeaFWJIZHz5q5Us1yY4+Gxypc7EkiJEtSzX4MIOhhk37tfzeWBMzilQ7FE/kFQxI5nRus0BrNN6rzlT/t+gwePE70GD/NcYMuUYb1Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bKboEucyyULLHJxbiBLGzFkfgepzFMBUIVcJxdRRvt8=; b=XgyMNS1byjO6wtftTHqfruZDmbGrRdjj9n2ntF34ooBmPLtPzkhwaLT5rbJU22MC0byUsNGf1C3BeFAVV8p0O39sQE2fG91ltCN4nnkzru8OOSwvcnFA6koqM133cCN0FpZ6Bdyg1xmei8GfxWLuiaj5Mqxa8xOQw8MBlB3F14ZgwRewj4qdaUKx81gGCyCrqla1ahv4kMal2kj4MjcvTBC87MY+oJPR5zLbxY7wY7wwXmKclhV4cp9KhYTtoR7/cbCLARxMtH/7eUFYUCx4DvBjNZq5iqZGwmhda35QrImPAJP3tA8a1LzN+0mfiqo9zxSoFM1UtGRDdL7Diw70bg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=amperemail.onmicrosoft.com; dkim=pass header.d=amperemail.onmicrosoft.com; arc=none X-Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by CH0PR01MB6812.prod.exchangelabs.com (2603:10b6:610:111::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Thu, 31 Aug 2023 08:20:38 +0000 X-Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::47db:e2da:2ade:2e19]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::47db:e2da:2ade:2e19%5]) with mapi id 15.20.6699.035; Thu, 31 Aug 2023 08:20:37 +0000 Message-ID: Date: Thu, 31 Aug 2023 15:20:25 +0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue To: Ard Biesheuvel Cc: devel@edk2.groups.io, 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: "Nhi Pham via groups.io" In-Reply-To: X-ClientProxiedBy: SG3P274CA0021.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::33) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7287:EE_|CH0PR01MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: 811c6bde-db9a-441f-801f-08dba9fb27e5 X-LD-Processed: 3bc2b170-fd94-476d-b0ce-4229bdc904a7,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: B/gapCOXRxRTlUdppGytSU5BpKqI/0q6ctXk8vVUm1VxN59spuFukPKDIjS2MgrmzdwQo+lxY+AR3Ef57JOPDA8NEm30TOgQ7m2g86yPy/IEzT3SG7iEIBD3q5RjvaJxMiWKT++0h3QApzwhiFyC+qdKQMyYOC0x9tM76BHyEM4A5VpUd+damEjCpjCoc3XnD9Uo3VKpJAHSecK0xAjdvUUQSmVwIxfDjetk4+kujOf5hUM/CXnsohry4aD76N+F42WQnObKHwtsgZ603D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RJWFI0YXBRSFFBdGdVWFBaM0l2RnlUbGVDWHJ3UFNPL0lX?= =?utf-8?B?bzVDb3AydisvMXEvQmNXVWYxRmZvbmdvakl1TGxqeWxvdTcwNmh5YlpsT2Jq?= =?utf-8?B?dlRIVW5SdVp1UDlLdjRHamVubDRXenpCaDFIWjJTaXdqcWRxTDRtMVVneUMy?= =?utf-8?B?UXpoV3BEMHVVSkxZcnJmb0ZpcitjaUZGaUxRc2NzQ1NOQXFiVzNDejAvNnRh?= =?utf-8?B?OGRoc0QwWGlCemFmaktYQkoyK2hPNFlxV1kwZFkwU0tNUC9BaWllV3c0Wmt6?= =?utf-8?B?Vk5hYUREYXNFalI0czEzYUVmRk5zcnhqTDY3alBDUnBKaDNrdVpLUDRrRERy?= =?utf-8?B?ejdjcVJ0UlJ5bW1CWStWdElhVU9tYTUvQkVhcUxPK2dKaklrK3B1NE5OUUJk?= =?utf-8?B?eHVVNm41SGtTY1hZMjVlb0tpOVIvODd2OGlkeHNVQnlkQ242N0t2Vnd0dzJm?= =?utf-8?B?RHdSaUZrdnM5cnZJdy9SZVcwK1pqKzF2b2w3SHVEL1lsYzlhTnBXUEh5cFBr?= =?utf-8?B?bDA4QWZ1VUtuSFloVVBBbjRLcThhQ21lYzNRUDlGZml0dlBaV2VrNXhpQXFZ?= =?utf-8?B?cEJpeG82cmtmeTRQcko1dVZMVk1NUXNZaEdYbExWT2NlVmMwOVJCQ1FtWFdl?= =?utf-8?B?Vms4cUFNMmlCN2JrcXVtb3RtcFZSay9EYmxmOGVZby8ram1rTytLWm5TMUo3?= =?utf-8?B?c05aUys5UU1xS3BxUTlWNy9PamRYMGdKMzA0VHJWTStPUjhHMlJHdHhlOVV4?= =?utf-8?B?Ync9PQ==?= X-OriginatorOrg: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 811c6bde-db9a-441f-801f-08dba9fb27e5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 08:20:37.6585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 24NwWXIs/dAsm5LJT9GoiE1dJJ5tGQHRA01Fn0eRes/HJ0plyPmwBJ0oIC7z/taPnFzEutnuy2XG8JUvavlqsC91qm994yeRm7O3t17opTU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR01MB6812 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,nhi@os.amperecomputing.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: S1ug6LCcpageF1CO7olSf7rdx7686176AA= 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=X5cnbMRL; 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; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi Ard, Thanks for your response on this patch. Please see my reply inline... On 8/30/2023 8:10 PM, Ard Biesheuvel wrote: > [EXTERNAL EMAIL NOTICE: This email originated from an external sender. Pl= ease be mindful of safe email handling and proprietary information protecti= on practices.] > > > On Wed, 16 Aug 2023 at 10:56, Nhi Pham w= rote: >> 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.in= f >> 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 iss= ue. >> >> 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? 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. 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. 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. 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? Thanks, -Nhi -=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 (#108185): https://edk2.groups.io/g/devel/message/108185 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-