From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ma1-aaemail-dr-lapp01.apple.com (ma1-aaemail-dr-lapp01.apple.com [17.171.2.60]) by mx.groups.io with SMTP id smtpd.web11.1718.1585963256899236963 for ; Fri, 03 Apr 2020 18:20:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=NTrSg9VI; spf=pass (domain: apple.com, ip: 17.171.2.60, mailfrom: afish@apple.com) Received: from pps.filterd (ma1-aaemail-dr-lapp01.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp01.apple.com (8.16.0.27/8.16.0.27) with SMTP id 0341HOI8041544; Fri, 3 Apr 2020 18:20:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=sender : from : message-id : content-type : mime-version : subject : date : in-reply-to : cc : to : references; s=20180706; bh=0u0+cU244RjSH2Rj0vu5nxrSk59Ew9pSKud8pt880Og=; b=NTrSg9VIX3GSgu/q5gpJGsaxenTTU0RCeuCsFqQCaAXTpx0/5Lyv9W8qfTs5B3h7sb9F Qw77s2TpgLDeBAAzQJihoTWnLKusyC1gMmT2RmHmzOoC8D8cPqCxWPR2C0JiWMepbBxI HGq52M4UtbChxMWkmp958LQmx2VDzWRlGG0fpC4lpVovSki+P9OxBLuZEFY3p3JJmcRq 8KzrexkRLNg+kFWRvCU6/jIO7vIGB26W8SY5PPc7zqKqw1ACVDera1I0LgfsspMquugt 4P72CP5taB73ExtCo1xi3jDZ9Qcol5AtiWXHO6JB4lU46aRG3GEPA0Y3uLZmcvvO+jQt qw== Received: from rn-mailsvcp-mta-lapp03.rno.apple.com (rn-mailsvcp-mta-lapp03.rno.apple.com [10.225.203.151]) by ma1-aaemail-dr-lapp01.apple.com with ESMTP id 3025855vwr-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 03 Apr 2020 18:20:55 -0700 Received: from rn-mailsvcp-mmp-lapp04.rno.apple.com (rn-mailsvcp-mmp-lapp04.rno.apple.com [17.179.253.17]) by rn-mailsvcp-mta-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.5.20200312 64bit (built Mar 12 2020)) with ESMTPS id <0Q8800X9OP2TSO80@rn-mailsvcp-mta-lapp03.rno.apple.com>; Fri, 03 Apr 2020 18:20:53 -0700 (PDT) Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp04.rno.apple.com by rn-mailsvcp-mmp-lapp04.rno.apple.com (Oracle Communications Messaging Server 8.1.0.5.20200312 64bit (built Mar 12 2020)) id <0Q8800P00OV5KS00@rn-mailsvcp-mmp-lapp04.rno.apple.com>; Fri, 03 Apr 2020 18:20:53 -0700 (PDT) X-Va-A: X-Va-T-CD: 678bf7de5df0d9ff994f556fd1b44182 X-Va-E-CD: d8189c7a231e3b09b73e5a83ea54399e X-Va-R-CD: 67aeb9456b0b2630385ad0db7765c6e6 X-Va-CD: 0 X-Va-ID: f0b7215d-d82a-466a-8151-d4eebd9b00cb X-V-A: X-V-T-CD: 678bf7de5df0d9ff994f556fd1b44182 X-V-E-CD: d8189c7a231e3b09b73e5a83ea54399e X-V-R-CD: 67aeb9456b0b2630385ad0db7765c6e6 X-V-CD: 0 X-V-ID: 844c2c19-ecdc-4765-a68c-7ac53224cf26 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-03_19:2020-04-03,2020-04-03 signatures=0 Received: from [17.235.40.53] by rn-mailsvcp-mmp-lapp04.rno.apple.com (Oracle Communications Messaging Server 8.1.0.5.20200312 64bit (built Mar 12 2020)) with ESMTPSA id <0Q8800TKWP2SRL20@rn-mailsvcp-mmp-lapp04.rno.apple.com>; Fri, 03 Apr 2020 18:20:53 -0700 (PDT) Sender: afish@apple.com From: "Andrew Fish" Message-id: <84142A31-26DB-42BB-A20C-B0EEA9CC2FFB@apple.com> MIME-version: 1.0 (Mac OS X Mail 13.0 \(3594.4.17\)) Subject: Re: [edk2-devel] Debug UEFI Event Date: Fri, 03 Apr 2020 18:20:52 -0700 In-reply-to: Cc: discuss@edk2.groups.io To: devel@edk2.groups.io, stanley.ganyezu@gmail.com References: X-Mailer: Apple Mail (2.3594.4.17) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-03_19:2020-04-03,2020-04-03 signatures=0 Content-type: multipart/alternative; boundary="Apple-Mail=_9CDF063E-B96F-4AD6-978F-1F32FE5F6846" --Apple-Mail=_9CDF063E-B96F-4AD6-978F-1F32FE5F6846 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Stanley, There is not much to debug with EFI events and that is why there are not a= lot of DEBUG_EVENT DEBUG prints. The only thing that can block your event = is for the current TPL level being >=3D to the TPL level of your event, but= that also blocks all forward progress in EFI.=20 Usually the problem is one of these: 1) The event was no created properly and thus never gets signaled.=20 2) The more generic issue is people code EFI events like threads, and that= is not how it works. EFI has a cooperative event model and there is only o= ne thread and that is the main thread. Events are dispatched when gBS->Rest= oreTPL() [1] is called. Higher priority (TPL) events dispatch 1st. So the o= nly way your event can get blocked is for another chunk of code to gBS->Rai= seTPL() to the level of your event or higher. If you put a while (TRUE) loo= p in an event it will deadlock the system.=20 So hopefully it is 1) and you are not error checking the return codes when= you create and hook in the event, or you are missing the call to hook in y= our event to get called. If it is a more subtle problem it is usually relat= ed to 2).=20 [1] https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Ev= ent/Tpl.c#L95 Thanks, Andrew Fish > On Apr 3, 2020, at 5:48 PM, Stanley Gan wrot= e: >=20 > I have an event callback function not called. So, I want to track event = execution in UEFI. There is a "DEBUG_EVENT" debug level in EDKII. But no mo= dule in EDKII actually use this debug level. > I add some debug print in "CoreCreateEventInternal" and "CoredispatchEve= ntNotifies"=EF=BC=8Cit cause TPL ASSERT. Can anybody give me some construct= ive debug suggestion? >=20 --Apple-Mail=_9CDF063E-B96F-4AD6-978F-1F32FE5F6846 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Stanley,
<= br class=3D"">
There is not much to debug with EFI eve= nts and that is why there are not a lot of DEBUG_EVENT DEBUG prints. The on= ly thing that can block your event is for the current TPL level being >= =3D to the TPL level of your event, but that also blocks all forward progr= ess in EFI. 

Usually the problem is one of these:
1) The event was= no created properly and thus never gets signaled. 
2) The more generic issue is people code EFI events like threads, and th= at is not how it works. EFI has a cooperative event model and there is only= one thread and that is the main thread. Events are dispatched when gBS->= ;RestoreTPL() [1] is called. Higher priority (TPL) events dispatch 1st. So = the only way your event can get blocked is for another chunk of code to gBS= ->RaiseTPL() to the level of your event or higher. If you put a while (T= RUE) loop in an event it will deadlock the system. 

So hopefully it is 1) and you are n= ot error checking the return codes when you create and hook in the event, o= r you are missing the call to hook in your event to get called. If it is a = more subtle problem it is usually related to 2). 

[1] https://githu= b.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Event/Tpl.c#L95<= /div>

Thanks,

=
Andrew Fish


On Apr 3, 2020, at 5:48 PM, S= tanley Gan <stan= ley.ganyezu@gmail.com> wrote:

I have an event callback= function not called. So, I want to track event execution in UEFI. There is= a "DEBUG_EVENT" debug level in EDKII. But no module in EDKII actually use = this debug level.
I add some debug print in "CoreCreateEventI= nternal" and "CoredispatchEventNotifies"=EF=BC=8Cit cause TPL ASSERT. Can a= nybody give me some constructive debug suggestion?

--Apple-Mail=_9CDF063E-B96F-4AD6-978F-1F32FE5F6846--