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 483A7740038 for ; Tue, 5 Sep 2023 02:21:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=5vXuyL3Z4dv4+7hq9tIJCfhoThGG5/AFiygc2zmY1eM=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Message-ID:Date:User-Agent:From:Subject:To:Cc:References: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=1693880459; v=1; b=QUehCWi2YsEjKlJ/RwnAKWogjsHnjOqLLJ0wK0nVCzzf/xh4p+/lB0tHsZj4u7VgSfLBqOnJ aLP87FrijbyNxAZdw1sFuYegbZd6i8HuVryd5N3KvAciIa5tK3EdCCmjcZ8pWjkNe79vyIouj1q 6ISeCYmC+zSAoy/Nzj4sRJpc= X-Received: by 127.0.0.2 with SMTP id MfqtYY7687511xWtKlKnvS8l; Mon, 04 Sep 2023 19:20:59 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.90]) by mx.groups.io with SMTP id smtpd.web10.12939.1693880458605098001 for ; Mon, 04 Sep 2023 19:20:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KCetRcqHm2YFvLgC/lqz8tR+4tqdVZQFXIAnv4R5HsBnetDnw1mijmwIRnT+TOmw7BqBmkcl0elA2Gbw2AT+rSeDY/g7aOOnCtuafAPJFJf8Qh67aolcZsPvE0lJZOtNupQuxRGbFxqFwSycZ+c6MNA3REqU3novmpQjMiZJ+GFMz0y4ArUjbqmnqfO6qWn3VCamAjOHYYnNbt3o2vrT/SjqHnfakeCcVXTGwbs3f2cAT4F+c0ks33aS/rwELLhe0+6ZmxxYtVXqEOTFgdf897nS+maaOv4jr3PUl7J+cqVYheYEZPvCSE0/JvKxlwAkXaGTZF2JQ2LxwJBp6BYgtw== 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=bscVFpSqcEhiUZ379IDl9En88O3OYbZO+p4Stqujfb8=; b=gY/tHnH6b64Tppii54rPxiEsZX68BGtK2Uo6Fx/QiIg6N71jZRupNu2qI2vU7SCLU7tpk+pX9esuPSF511McL3jd/rQ1/eeC8LG3wjjdw4zDISHMH+r4l5StpFfzo2T+ixPFeTeMFJ5Y9oM/YG1k5VKiuygbRTJwgIqwgkt5BY+5gmV9X595Tvwq4TYAsKWJf0v9t7YI/73bzEvDzUvHMqvB3Xgkx+TM1gns/dE+TWLf3yN3KM///ztXHBfv5YZLvN2k5FeB3YTDp0rk0RLws3VfAmqx1JCAg3epEFHDoDPWKPGf1K2UthXdphzAqA0iZflREodX0qrZkYuveSS+VQ== 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 SN4PR01MB7519.prod.exchangelabs.com (2603:10b6:806:206::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.32; Tue, 5 Sep 2023 02:20:54 +0000 X-Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::dc7b:d4c5:71cf:1ea0]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::dc7b:d4c5:71cf:1ea0%4]) with mapi id 15.20.6745.030; Tue, 5 Sep 2023 02:20:54 +0000 Message-ID: Date: Tue, 5 Sep 2023 09:20:45 +0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 From: "Nhi Pham via groups.io" Subject: Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue To: Oliver Smith-Denny , 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> In-Reply-To: X-ClientProxiedBy: SI2PR02CA0012.apcprd02.prod.outlook.com (2603:1096:4:194::7) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7287:EE_|SN4PR01MB7519:EE_ X-MS-Office365-Filtering-Correlation-Id: af2de1ac-d8e2-48d5-f4ae-08dbadb6bb0a 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: +X0+6t5BCAzhZRmQzydW4nZCcqyqeX+8Nv9SPyYSYiKquQxKKeI4LnjZDldZW1IozA2RW/60XlP9wFJdo0+9Ora+Xk53Ow1LbOl3+Dt6sKA2jAWcRVwWbIixNr0mvD6epuAawSpHxOzF3RY6ughaWRm3LwABXVHPiBAVeYt0J2tY1GFW9dCUBvCK6y0b2B1McRdbZ5/EuWDaYAEy4GFR5/h62kZ5AkdC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-8?B?OGdIdENyOGdxQlhkdW03S1EybjlHMGV2YWVkSCtqUEZScUF6SFlSVEVFbG9Z?= =?utf-8?B?aURPajc3QmZzTzZhU3dxTEoxalMwRVVvUmRCRVhHV01MVjkwbjJEZ2NVMThV?= =?utf-8?B?MVcrenU4ZXZhMGROWERhcmxDZEUrc1luODM4cWhKUzVzNFhCYVFOQkVpbk9n?= =?utf-8?B?WlFDYWhYNzJaeFF3N0F4QzVFZTBSWWFGWVhDVEdtWkdtNGJaUFZsZksxdzJD?= =?utf-8?B?d1hLdWVSdHNEdlVVaWEvUGpJaml4ZGVmS0R5MnFpcXlQMVZEMUdhVzhON210?= =?utf-8?B?bWhsRk9NMXFHM0VvSjVLd2VaSk5rcmVHM1pUaVN0ak9IOEQ2NzJYQmpJa1Yw?= =?utf-8?B?MllvUTk5eTNDcm51M1BPbnJYYkZVVDVFSVhiZGZwQ0dzKzd0TVltSW5KT2kr?= =?utf-8?B?L3lJWTdlODlSMlFoOTVVUUtoR2pLQ3FZOS9CY0YvdmYweFBtaTE0ZnVwRVU5?= =?utf-8?B?LzZxT0RoRlQvc1ZGeVhqZFdtR01qVGh3ZHlFSUtRVnN6T1ZZcnpTdzNxSGl5?= =?utf-8?B?ZzJxVEhMUUtJa09vWWZnZXNFcFRqMDhPWjdpTEVyY2lOa2VqZTZRNjJhZlJF?= =?utf-8?B?OTZUMmZBbUl2cjhVV05GbTJEQ25rcHQ5aW5NcU9HWHVvamRDbVlQaS9VWCs2?= =?utf-8?B?NmQyUlVOa2oxUDBsck03Nzl4ME9HUkl4VUtNbFdYTktrUkJjc3kxYmIyNVVD?= =?utf-8?B?NlRpNnVqK09vTFB5V241d1hXeWpSOWNSa0ZWcTk2Y3lZam0vUjVtdmR1WEY4?= =?utf-8?B?TFE9PQ==?= X-OriginatorOrg: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: af2de1ac-d8e2-48d5-f4ae-08dbadb6bb0a X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2023 02:20:53.9095 (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: CueBO8RDxeK0wdc6wIgHMJ3jhuNIXHSEwYVZ7GqUbHJ4WioJfJoqCK1nv0SsO3C4sAIfeIQSZhEYDQXwtx2xdNRWB/X6XEOswW8bqurVgxU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR01MB7519 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: ljHlKqGoMhuiRkOUtlCWAIyGx7686176AA= 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=QUehCWi2; 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 Oliver, thank you for taking a look at this patch. On 9/2/2023 3:43 AM, Oliver Smith-Denny wrote: > On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote: >> 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=20 >>> sender. Please be mindful of safe email handling and proprietary=20 >>> information 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.= inf=20 >>>> >>>> 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=20 >>>> this 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? >> >> Per your question, I had a deep dive into the HOB today. I think I=20 >> need to clarify further the issue to make sure that we are on the=20 >> 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()=20 >> function always look up the old HOB list instead of the new HOB list. >> >> 2. The Memory Allocation StandaloneMmPkg/Core/Page.c does not update=20 >> the Hob->EfiFreeMemoryTop, this may cause the MM heap space and HOB=20 >> space to be overlapped at some points. >> >> It sounds like the issue on the memory allocation in StandaloneMM.=20 >> For #1, I think we should write a new patch for it. For #2, could you=20 >> advise? >> > > 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? Yes, the issue only occurs when HOB are created in StandaloneMM by the=20 HOB library instance=20 StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf > > If so, is HOB creation in StMM and supported use case? The only instance I think it is intended to work as the CreateHob() function is implemented. > 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. I have a use case when enabling the UEFI Variable driver running in=20 StandaloneMM. Instead of using the PCDs, the in-memory NVRAM region is=20 allocated **dynamically** at boot time in the StMM secure memory. Then,=20 they will be passed into the gVariableFlashInfoHobGuid for being=20 consumed by other variable MM drivers. > > 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 (#108269): https://edk2.groups.io/g/devel/message/108269 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-