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 D6930AC0DEC for ; Thu, 18 Jan 2024 06:00:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=EEzW1tZPkWjKnIVJqwUEreXTGEAoE4gjHdCH559QKVw=; 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=1705557652; v=1; b=XxhxbtaMWwHdNYv9zhj1UqkpJFXSCIzydA2Krp0vdMkXN2tWDCAwITUMzUMrGUsagZYwMOPl Yg13J03v1zIO0c0gCR1kAdvPELBZgaEoSaomYu9TQtdGdJiYzw2Y+NMwD+wjmVqO5unvm3MJDJl eZW412JTzD4jcGA5lqes6fqQ= X-Received: by 127.0.0.2 with SMTP id EkWFYY7687511xDFQvEBEsvo; Wed, 17 Jan 2024 22:00:52 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.107]) by mx.groups.io with SMTP id smtpd.web11.5412.1705557651496632651 for ; Wed, 17 Jan 2024 22:00:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZvZ96V7D7pWYDMqoUNpca5Pkh6SiHGuQ2A5cFao7B+3hh0iJpstGu5//vMUFh+jGXuv/YCfnVRRq6wrvriNbLCpz1rVsZZS0gnW75jNDSbuzHshHKJ2xWbMaAfZ0RO6Q7upfOeE+ZfuXIO+EO2BJnpUF3hGKHekTkhxN+bxWDT+XuMl/FHwPiSVE3Ecm9S9l55n9786i3GS9kzoVn1z+sc4MtEq6ilI0XUqzkioQPyA5J5sO9M+F9Li/OKniPoolTTGWEiityKDcPK3zYlho7lIATuTK4uJMOG0mST+67jnEs9KflMX8aL/SU5/anfam0LRGIisDwMS5jkcVny5tg== 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=rVowDM6aiyUN2GkKB/7V5lpjWysOBUyfo10W5kJxur8=; b=KlJ24epqzX4um9k+71AR5ChDYHytVLSv8ZrenWuo1M49eTsrHv6vzQiL/F7kN3VFRT9ZjywIalvWbsCzqkvIlKqAwPuO2bWJQdZj91ZTt6U5+5KUMnNFcGSR0iPu8UhgrVqZgUwBBthRxhBFv9xBt8mWImqsRXAC7+U44KL3e8euI35KEi7U0Pyds79dgU2CSw2NJbJGf2cAxmyCGZf6snvAoKavLvbQpnuu6nvqwngbqFBqdtxhuL5iTgsZbc1RbaQuIhkCjtLf3zmNSNrB907kanCj0kntHJWcW4YHvuBSWlOqdEHvUny5v0sAEF/WiKtqGsHIBMNabPq9OmE3Kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none X-Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.21; Thu, 18 Jan 2024 06:00:46 +0000 X-Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::d2bd:7ad:570c:9dc8]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::d2bd:7ad:570c:9dc8%6]) with mapi id 15.20.7202.024; Thu, 18 Jan 2024 06:00:45 +0000 Message-ID: <8efe1653-7383-44a6-b820-efb1c6132f74@os.amperecomputing.com> Date: Thu, 18 Jan 2024 13:00:36 +0700 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] Memory Attribute for depex section To: Laszlo Ersek , Ard Biesheuvel CC: "Andrew (EFI) Fish" , edk2-devel-groups-io , "ardb+tianocore@kernel.org" References: <44ca139f-4d78-4322-b5b6-8e9788bb7486@os.amperecomputing.com> <2ad16043-754e-3bb9-3a4a-702d9a50bf63@redhat.com> <45b95719-f1fc-dbc6-a4cc-a022d691844c@redhat.com> <8d745268-263c-c99a-67c6-fe0fb6cd4b8e@redhat.com> <0e0b2e56-30dd-4f5f-9708-98690246efda@os.amperecomputing.com> <20d8728f-daaa-51ed-18ad-3087695d21f1@redhat.com> From: "Nhi Pham via groups.io" In-Reply-To: <20d8728f-daaa-51ed-18ad-3087695d21f1@redhat.com> X-ClientProxiedBy: SI2PR01CA0007.apcprd01.prod.exchangelabs.com (2603:1096:4:191::11) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7287:EE_|PH0PR01MB7975:EE_ X-MS-Office365-Filtering-Correlation-Id: 051d0329-49ac-4a0b-bc6f-08dc17eacf9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: OjIYeS2l8/oo7MTscG8J/a5GNkSO4zSc/JJMPteDfTXYddA2ksv07MJ6Bqk8X/6rqsJmJrgibbkU8l5YILJU3iZtVLTzYgTvKH9AFJI+5Zzz76p9sK0cOW7yPltzjU/s5QWlays0g1y2ReEuKGUQhHTqji8cB4NNjhPx9a9QShVZYLsmv4TsPOQXU20zbKH42svUO8D54p/m/0xi0mcaNMj5oFXOkO16jgfAmy5xmm4G3Ul7nPnzbPnTwgTnZ/hVGtuvenrIKq4jITw4/K6dyL0bkDNcNcFWHBoYhw6vAIhxJWr8fQ0SgWID4ejDDb9r8zmLfrfjyIY31qu7Atc0cbB5OwaIA+156AddTK63fOA8/3ITm7QAODo0VqPkooKw1HCRVAimGamtvNUtwnZz8M3bGSe7MHatWuCC0yP0m1V5QAgSRYk9KkTRDBWNv+g7NTEdUI8O00Si92nPBjwKjgcEDCDL3w9Mx/aQOncshmf+mYPGZn+mapBT+M0iuhBUanL0csoo5fM4QgyoSyrACgch/dPfvR+4Os8nMNc0yyzEhzynFOmWuAx/yR/op40UWtwNWtw8ZSR3tt8ZFrdeBV1H0r0NdlW9+I6E54f3z/9NsG+AHqj2EtzYlF4KBLJn X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?L6LwgEUqakLfRmVsqhYIF+ok/14/twBm92WdxmNr3T+sjJYk96Z8gD8AfGZs?= =?us-ascii?Q?3z5GlJ+bU8hDgJiZ1whNugFFGsQ9t2cfPy+mqNVNtaMmg6UbZRG34b2FeAbP?= =?us-ascii?Q?UouKYapLthCvVjcT7cMN6QsQjY4AvFnmX6Nv900gmQsh7JLNlID1CVorbZ/a?= =?us-ascii?Q?JkvdG8xRhdVG4hrrJe+GtCe/UYLGHpczRcduBbtCfIIZbPQsUrN+ZGXRHxA3?= =?us-ascii?Q?wMv5dJvu8Ev8xGawrtH5OEGsR31muGhBAJPHqv2JWPbF9Xe0jgYF4izrLrTV?= =?us-ascii?Q?Dat2tyr0EACe20O2I37HbYsNlPT/3RAuWVX8MgKy/+L/tp8V7n70FyElVemV?= =?us-ascii?Q?HmwHTYd8YS53BVTypNqAPEz610oGqsB2HhNUyUrDfU6PmZ482MD2oAFPT15C?= =?us-ascii?Q?GEjI34ID15nTWyYRDVCbdKrkA31RFi7uMGRQJVpfBNcRBJWwoOoTOMFXW+kB?= =?us-ascii?Q?r13Kpf8L0g59osmYbnU/p1QEC5UNq9zNfA7IFWZvnZtYYLAodhAgOQO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kk9Zp0DSvtXJaLxNX9wD?= =?us-ascii?Q?71gXQhdVkZF1tvgNOPGLa3AfHnpOdNjG2CV7FW/OoA9g1Z3MtVMZmhdnYGoX?= =?us-ascii?Q?qMY0otDXqiod02Tc0HGDoHls73VgUYiUxWf6h6YkeuqFGrvS6utiqi/x8gPa?= =?us-ascii?Q?SBBg+e8f8hdbjRLGZfshgEC2E+AjZ5Abqv16ysyopnRsOnLFDr62neKD4vo0?= =?us-ascii?Q?YA=3D=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 051d0329-49ac-4a0b-bc6f-08dc17eacf9d X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2024 06:00:45.6003 (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: wbUISQqqE7PuMFE1QGyHzNBJZtr7Vc3ti64FuxFHlLdacrHHjS4LQ2+KSA/p/gvSEJcGUbI3TIdjMbnXDdu01uUC754/brMvQkvTy95Tbjw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7975 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: 3edJkhctBadJXjtR5wsI1fXNx7686176AA= 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=XxhxbtaM; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 Hi Laszlo, On 1/16/2024 2:00 AM, Laszlo Ersek wrote: > On 1/15/24 15:04, Ard Biesheuvel wrote: >> On Mon, 15 Jan 2024 at 14:07, Nhi Pham wrot= e: >>> >>> On 1/12/2024 4:45 PM, Laszlo Ersek wrote: >>>> (Independently: I think that's a valid thing to do for *SMM* drivers, >>>> because the entry point functions of those drivers are permitted to us= e >>>> both SMM and DXE/UEFI protocols. But whether the same is valid for the >>>> *standalone* MM drivers -- that looks questionable. Standalone MM >>>> drivers should not depend on UEFI/DXE protocols ever, IIUC.) >>>> >>>>> 3) The issue is patching the grammar in place, why can=E2=80=99t we j= ust make a >>>>> copy for the dispatcher grammer, and operate on the copy. Maybe via a >>>>> copy on 1st update strategy? >>>> >>>> Yes, copying the depex to the heap, and patching it there, was Nhi's #= 1 >>>> fix proposal. I think that could be made work. But I'm not sure if the >>>> perf savings are worth the additional complexity. The heap allocation >>>> (where the writeable depex would exist) would have to be permanently >>>> associated with the loaded PE image -- because the dispatcher might ne= ed >>>> to reevaluate the depex across multiple rounds of dispatching. So that= 's >>>> a new field in some image-related structure, it also needs to be freed >>>> upon unload (?), what if the memory allocation fails during depex eval >>>> (just consider the depex to eval to FALSE?), etc. Doable, but hairy; n= ot >>>> sure if the perf is worth that effort. >>>> >>> >>> Thanks so much, Laszlo for your valuable insights. >>> >>> The approach #1 works for me. I will do further check for your concerns >>> above. >>> >>> I'm trying your suggested patch and investigating the performance being >>> discussed here. >>> >> >> Not sure what approach #1 means, >=20 > (copying the depex to the heap, and maintaining it there, so that it can > be patched) Thanks! >=20 >> but I'd prefer to just remove this >> optimization from standalone MM, given that not only a) it shouldn't >> have to deal with a large number of protocol GUIDs, but also b) the >> driver dispatch is much more straight-forward. (Typically, StMM >> drivers can be dispatched in the order they appear in the firmware >> volume, in which case each DEPEX is evaluated only once anyway) >=20 > Sounds like a promising basis for removing the optimization indeed! >=20 Your patch suggested earlier works for me. And I don't see significant=20 performance reduction compared with keeping optimization. I don't have strong reason on removing the optimization, but I think it=20 would be simply good for now. Could you post your patch to edk2-devel=20 for review and merge? 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 (#113986): https://edk2.groups.io/g/devel/message/113986 Mute This Topic: https://groups.io/mt/103594587/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-