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 748047803D7 for ; Wed, 24 Jan 2024 17:19:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/5OaUDxpvPQx0BnyGsitPR/E4/KnCYcB3wbz6bRKf2g=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version: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=1706116761; v=1; b=WPLX/SkumMECN1RxATsnm8jk10HWhoflLzxrjXJ74NFkZJASuMIGGFh44RGnzA5788+aaYzc qVulMte8U5SuzJ7kmRztwQqAYmwXz81U3D9bnyOYggSo31EYXg111KmZsaiiCP5P+8bNGugt2Bn smgVpRQ82H7vhwFXGRZFe/lg= X-Received: by 127.0.0.2 with SMTP id PdocYY7687511x32qi0MGyhG; Wed, 24 Jan 2024 09:19:21 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.28816.1706116760364162606 for ; Wed, 24 Jan 2024 09:19:20 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-3_JHHm03NVmrSeH5GLyRng-1; Wed, 24 Jan 2024 12:19:14 -0500 X-MC-Unique: 3_JHHm03NVmrSeH5GLyRng-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D906381A883; Wed, 24 Jan 2024 17:19:12 +0000 (UTC) X-Received: from [10.39.195.127] (unknown [10.39.195.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B628111E408; Wed, 24 Jan 2024 17:19:11 +0000 (UTC) Message-ID: Date: Wed, 24 Jan 2024 18:19:10 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/SMM: Support to unregister SMI handler inside SMI handler To: devel@edk2.groups.io, felixp@ami.com, "Ni, Ray" , "Liu, Zhiguang" Cc: Liming Gao , "Wu, Jiaxin" References: <20240124040301.2176-1-zhiguang.liu@intel.com> <9aa1a85d-89c0-6c7b-0174-184791d75bcd@redhat.com> From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: OziYLIu2ijbKKsoSMQ3AgnxCx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 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="WPLX/Sku"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.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 1/24/24 18:15, Felix Polyudov via groups.io wrote: > In my opinion this is not a spec conformance fix, but it is a bug fix. > > The spec does not explicitly mentions unregistering from within the handler, > > but by applying a principle that everything that’s not forbidden is legal, > > it’s fair for a caller to expect that unregistering works fine in any > valid context > > including from within the MM handler. > >   > > The spec does mention that UEFI/PI interfaces are not reentrant, > > however, reentrancy typically implies repetitive invocation of the same > interface, > > not a call to one MM Core interface while another MM Core interface is > in progress. Sure, I'm not contesting any of that; it's great that you and Ray seem to agree. I just wanted to understand. My R-b stands. Thanks! Laszlo > *From:*Ni, Ray > *Sent:* Wednesday, January 24, 2024 11:17 AM > *To:* Laszlo Ersek ; devel@edk2.groups.io; Liu, > Zhiguang > *Cc:* Liming Gao ; Wu, Jiaxin > ; Felix Polyudov > *Subject:* [EXTERNAL] Re: [edk2-devel] [PATCH] MdeModulePkg/SMM: Support > to unregister SMI handler inside SMI handler > >   > >   > > ***CAUTION:*The e-mail below is from an external source. Please exercise > caution before opening attachments, clicking links, or following > guidance.** > > spec does not say the unregistration is allowed inside handler. it's > just to improve the qualiquali the code. > >   > > thanks, > > ray > > ------------------------------------------------------------------------ > > *From:*Laszlo Ersek > > *Sent:* Wednesday, January 24, 2024 9:06:13 PM > *To:* devel@edk2.groups.io > >; Ni, Ray > >; Liu, Zhiguang > > > *Cc:* Liming Gao >; Wu, Jiaxin >; POLUDOV, FELIX > > *Subject:* Re: [edk2-devel] [PATCH] MdeModulePkg/SMM: Support to > unregister SMI handler inside SMI handler > >   > > On 1/24/24 09:11, Ni, Ray wrote: >> Felix, I remember you mentioned to me about the usage of SMI handler unregistering itself. > > I wanted to ask: is this something that the PI spec comments on? I.e., > is this usage expected by the spec (in which case this bugfix is a > conformance fix), or is the spec silent on it (in which case I guess we > can call this a quality-of-implementation improvement)? > >> >> Reviewed-by: Ray Ni > > > Reviewed-by: Laszlo Ersek > > > Thanks > Laszlo > >> >> Thanks, >> Ray >>> -----Original Message----- >>> From: Liu, Zhiguang > >>> Sent: Wednesday, January 24, 2024 12:03 PM >>> To: devel@edk2.groups.io >>> Cc: Liu, Zhiguang >; Liming Gao >>> >; Wu, Jiaxin > >; Ni, Ray >>> > >>> Subject: [PATCH] MdeModulePkg/SMM: Support to unregister SMI handler >>> inside SMI handler >>> >>> To support unregister SMI handler inside SMI handler itself, >>> get next node before SMI handler is executed, since LIST_ENTRY that >>> Link points to may be freed if unregister SMI handler in SMI handler >>> itself. >>> >>> Cc: Liming Gao > >>> Cc: Jiaxin Wu > >>> Cc: Ray Ni > >>> Signed-off-by: Zhiguang Liu > >>> --- >>>  MdeModulePkg/Core/PiSmmCore/Smi.c | 8 +++++++- >>>  1 file changed, 7 insertions(+), 1 deletion(-) >>> >>> diff --git a/MdeModulePkg/Core/PiSmmCore/Smi.c >>> b/MdeModulePkg/Core/PiSmmCore/Smi.c >>> index 2985f989c3..a75e52b1ae 100644 >>> --- a/MdeModulePkg/Core/PiSmmCore/Smi.c >>> +++ b/MdeModulePkg/Core/PiSmmCore/Smi.c >>> @@ -134,8 +134,14 @@ SmiManage ( >>> >>>    Head = &SmiEntry->SmiHandlers; >>> >>> -  for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) { >>> +  for (Link = Head->ForwardLink; Link != Head;) { >>>      SmiHandler = CR (Link, SMI_HANDLER, Link, >>> SMI_HANDLER_SIGNATURE); >>> +    // >>> +    // To support unregiser SMI handler inside SMI handler itself, >>> +    // get next node before handler is executed, since LIST_ENTRY that >>> +    // Link points to may be freed if unregister SMI handler. >>> +    // >>> +    Link = Link->ForwardLink; >>> >>>      Status = SmiHandler->Handler ( >>>                             (EFI_HANDLE)SmiHandler, >>> -- >>> 2.31.1.windows.1 >> >> >> >> >> >> > > -The information contained in this message may be confidential and > proprietary to American Megatrends (AMI). This communication is intended > to be read only by the individual or entity to whom it is addressed or > by their designee. If the reader of this message is not the intended > recipient, you are on notice that any distribution of this message, in > any form, is strictly prohibited. Please promptly notify the sender by > reply e-mail or by telephone at 770-246-8600, and then delete or destroy > all copies of the transmission. > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114342): https://edk2.groups.io/g/devel/message/114342 Mute This Topic: https://groups.io/mt/103925794/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-