From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web10.6834.1592398405028547192 for ; Wed, 17 Jun 2020 05:53:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ejul/i4R; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592398404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ibVBaALT2VrGd6UquvaPpfLezI4CLYYwLRdyaA5RoZo=; b=Ejul/i4Ri1UV8F8tr/Xob67xJgBPisGHDUf2gUDb+16htF4EbYXoEHUrexS7ZQdqf0T0h+ W4RI/6vRi/j9u71O+xbQUkRYtupYS7nRyKpTVK7tnseFKmN9Xu5uqM98GqGZUZ5m9x4tA+ OVB4pWqfGCo8qOywJCk2d/0+AxNd3ms= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-496-DAPmZOA2NFeRxDFyRbrUQw-1; Wed, 17 Jun 2020 08:53:21 -0400 X-MC-Unique: DAPmZOA2NFeRxDFyRbrUQw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 788A21010897; Wed, 17 Jun 2020 12:53:20 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-92.ams2.redhat.com [10.36.115.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 411341002388; Wed, 17 Jun 2020 12:53:19 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 5/5] UefiCpuPkg: Uninstall EFI_SMM_CONFIGURATION_PROTOCOL at end of Dxe. To: "Liu, Zhiguang" , "devel@edk2.groups.io" Cc: "Dong, Eric" , "Ni, Ray" , "Kumar, Rahul1" References: <20200616090434.1201-1-zhiguang.liu@intel.com> <20200616090434.1201-5-zhiguang.liu@intel.com> <5763f977-74b8-96bb-a444-e3e1fdfc7dea@redhat.com> From: "Laszlo Ersek" Message-ID: Date: Wed, 17 Jun 2020 14:53:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 06/17/20 07:30, Liu, Zhiguang wrote: > Hi Laszlo, > Thanks for the comments, I will take the first one. > But I can't find service to unregister protocol notify in EFI_SMM_SYSTEM_TABLE2. > Do you now how the unregister it in SMM driver? It's a bit hidden, but it is explained by the PI spec, under MmRegisterProtocolNotify(): If Function == NULL and Registration is an existing registration, then the callback is unhooked. *Protocol must be validated it with *Registration. If Registration is not found then EFI_NOT_FOUND is returned. So where you do gSmst->SmmRegisterProtocolNotify ( &gEfiSmmEndOfDxeProtocolGuid, SmmEndOfDxeNotify, &Registration ); in PiCpuSmmEntry(), you'd have to save the registration value into a global variable (which would live in SMRAM): VOID *mEndOfDxeRegistration; gSmst->SmmRegisterProtocolNotify ( &gEfiSmmEndOfDxeProtocolGuid, SmmEndOfDxeNotify, &mEndOfDxeRegistration // <----- here ); Then in SmmEndOfDxeNotify(), you could call Status = gSmst->SmmRegisterProtocolNotify ( &gEfiSmmEndOfDxeProtocolGuid, NULL, &mEndOfDxeRegistration ); ASSERT_EFI_ERROR (Status); You can see examples in: - MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c - MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c - MdePkg/Library/SmmIoLib/SmmIoLib.c - MdePkg/Library/SmmMemLib/SmmMemLib.c Thanks Laszlo