From nobody Mon Dec 2 14:18:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+114251+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+114251+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1706068997; cv=none; d=zohomail.com; s=zohoarc; b=jk6SvpX8gx4cDFoXDKymCS84qt8qXmnBt1wP5PTGYL4Gwj7r7NG7QyafM4yDARvcQw+onXcrQm5rVNXeCikipPnNREG30guolrcEst2jRNDrZuPOHlsF4KTNY5wW+Yu1Id2d6wGTvwHZ9kVDQTpYUNQuEXtRMf9OMpdEUGRUPi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706068997; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=cj6nzCPcU699grp/ItAiOY6GYazO1sFfoLDBoq29arU=; b=Uw7ZQEu+81ndV1wwm4keQB0oFQf3NQTUIDfN+2z9MtNSV5if9Jggnr88FXG1OS0N6zzavr/dSBJjA5ik925p5lPHaQdAgUv7dcxHk3D+U7at3M6nS9XnAbUyCubg3uiPp6674cYcmCaO/i3TIZRv+FGdguK1OCRjSKtOpA3iRWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+114251+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1706068997974637.871992396492; Tue, 23 Jan 2024 20:03:17 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=GGgjjzRyu9SXESkjqMbC7kXVn1R6oW0ErKafunA2WNo=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1706068997; v=1; b=WTN9CsDRmUH9ZpCNgSdkN4h16t2pSEU6msCZcba8mVP0NJU5DQHnRP74Zf+m5+o2Tu6pv8O1 vOozSlmJLTlpaUiQ1P6XHdFIBanCbdzuXh94T8z7S1T9Zr8yhudGwYXUVgQoHI8BOF0+eucc0iu 9Y8JbR8FqHKk5K91/S7syGII= X-Received: by 127.0.0.2 with SMTP id or3OYY1788612xN5vhrhYtFK; Tue, 23 Jan 2024 20:03:17 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mx.groups.io with SMTP id smtpd.web10.15102.1706068996561620962 for ; Tue, 23 Jan 2024 20:03:16 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="15085766" X-IronPort-AV: E=Sophos;i="6.05,215,1701158400"; d="scan'208";a="15085766" X-Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 20:03:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,215,1701158400"; d="scan'208";a="1903655" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 20:03:13 -0800 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Liming Gao , Jiaxin Wu , Ray Ni Subject: [edk2-devel] [PATCH] MdeModulePkg/SMM: Support to unregister SMI handler inside SMI handler Date: Wed, 24 Jan 2024 12:03:01 +0800 Message-Id: <20240124040301.2176-1-zhiguang.liu@intel.com> MIME-Version: 1.0 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,zhiguang.liu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rv78eSalXYNZPHkV4bn3Mbpvx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1706068999215100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Laszlo Ersek > Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- MdeModulePkg/Core/PiSmmCore/Smi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/PiSmmCore/Smi.c b/MdeModulePkg/Core/PiSmmCor= e/Smi.c index 2985f989c3..a75e52b1ae 100644 --- a/MdeModulePkg/Core/PiSmmCore/Smi.c +++ b/MdeModulePkg/Core/PiSmmCore/Smi.c @@ -134,8 +134,14 @@ SmiManage ( =20 Head =3D &SmiEntry->SmiHandlers; =20 - for (Link =3D Head->ForwardLink; Link !=3D Head; Link =3D Link->ForwardL= ink) { + for (Link =3D Head->ForwardLink; Link !=3D Head;) { SmiHandler =3D 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.=20 + // + Link =3D Link->ForwardLink; =20 Status =3D SmiHandler->Handler ( (EFI_HANDLE)SmiHandler, --=20 2.31.1.windows.1 -=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 (#114251): https://edk2.groups.io/g/devel/message/114251 Mute This Topic: https://groups.io/mt/103925794/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-