public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* VariablePolicy: Final Changes Thread 1 - TPL Ordering
@ 2020-10-07  0:23 Bret Barkelew
  2020-10-07  1:54 ` Michael D Kinney
  2020-10-07 13:04 ` Laszlo Ersek
  0 siblings, 2 replies; 19+ messages in thread
From: Bret Barkelew @ 2020-10-07  0:23 UTC (permalink / raw)
  To: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 3473 bytes --]

As many will be aware, I’m in the final stages of having Variable Policy ready for commit. However, after moving the “Lock” event back to EndOfDxe, this exposed a race condition in variable services.

A quick synopsis of the problem:

  *   Previously, MorLock abused a privileged position by being tightly coupled to Variable Services, and its lock callback was called directly so that it could be strongly ordered with the internal property lock that disables future RequestToLock calls.
  *   VariablePolicy attempted to decouple this (without realizing it was a problem) and go through formalized interfaces that could ultimately be broken out of Variable Services altogether.
  *   However, doing so triggered the race condition, causing an ASSERT when MorLock attempted to lock its variables.
  *   I current have a reimplementation of the strong ordering workaround that can be previewed at the link below. I have tested that it works the same as the OLD system.
     *   Take a stab at solving the lock ordering problem · corthon/edk2@e7d0164 (github.com)<https://github.com/corthon/edk2/commit/e7d0164c8263b1fbfb8b4e289851fbedaa8997f1>

However, replacing one bad design with another is not what this community is about (when we can help it), so we’d like to take a moment to revisit a conversation that has come up before: expanding the number of supported TPL levels.


Now, I know that the current TPL levels are defined in the UEFI spec and we don’t want to have to change those, but there’s no reason that we can come up with not to add some more granularity in the PI spec, dedicated to platform and implementation ordering (the UEFI spec events will have to remain on UEFI spec TPLs). Basically there would be a set of DXE Services that allow WaitForEvent, CheckEvent, Event registration at TPLs other than notify/callback.  The UEFI system table versions of the functions would still have this restriction but code built with the platform could use the DXE Services. Right now, any attempt to use a non-UEFI TPL will ASSERT, so we can keep that in place on the SystemTable interface, but allow the platform to go around it with DXE Services. Similar functionality would have to be provided by the Mmst, but that’s already platform-specific and can probably allow it in all cases.



We’re suggesting something like the below:



//

// Task priority level

//

#define TPL_APPLICATION       4

#define TPL_CALLBACK_LOW      7

#define TPL_CALLBACK          8

#define TPL_CALLBACK_HIGH     9

#define TPL_NOTIFY_LOW        15

#define TPL_NOTIFY            16

#define TPL_NOTIFY_HIGH       17

#define TPL_HIGH_LEVEL        31



There’s already a long-in-the-tooth bug tracking a similar issue:

https://bugzilla.tianocore.org/show_bug.cgi?id=1676<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D1676&data=02%7C01%7CBret.Barkelew%40microsoft.com%7C9f3aa3e42bee4dd3a39208d8669a00e2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637372158932158036&sdata=vlC%2FB5f%2BDAMMp%2F3ECfBPukWiinHAmQj%2Flz1EPbSDKEA%3D&reserved=0>



This proposal is simpler than what’s in that bug, and would greatly simplify some of our event ordering (and code).



Thoughts?



If this conversation takes too long, I will publish a set of patches that just go with the lesser solution posted above, but I’d much rather work the problem this way.

- Bret

[-- Attachment #2: Type: text/html, Size: 9549 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-10-27 14:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-07  0:23 VariablePolicy: Final Changes Thread 1 - TPL Ordering Bret Barkelew
2020-10-07  1:54 ` Michael D Kinney
2020-10-07  2:17   ` [edk2-devel] " Andrew Fish
2020-10-07 16:21     ` Michael D Kinney
2020-10-07 16:39       ` Bret Barkelew
2020-10-12 16:44         ` Michael D Kinney
2020-10-12 22:14           ` Bret Barkelew
2020-10-13 15:04             ` Michael D Kinney
2020-10-13 17:56               ` Bret Barkelew
2020-10-13 18:22                 ` Michael D Kinney
2020-10-13 18:37                   ` Bret Barkelew
     [not found]                   ` <163DA129E4AEAEEE.24865@groups.io>
2020-10-15 17:03                     ` Bret Barkelew
2020-10-19 18:44                       ` Laszlo Ersek
2020-10-19 18:48                         ` [EXTERNAL] " Bret Barkelew
2020-10-20  9:23                           ` Laszlo Ersek
2020-10-22 21:54                             ` Bret Barkelew
2020-10-27 14:04                               ` Laszlo Ersek
2020-10-07 13:04 ` Laszlo Ersek
2020-10-07 17:48   ` [EXTERNAL] " Bret Barkelew

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox