mbox series

[0/2] efivarfs: fix hibernation problem with EFI variables

Message ID 20250107213129.28454-1-James.Bottomley@HansenPartnership.com (mailing list archive)
Headers show
Series efivarfs: fix hibernation problem with EFI variables | expand

Message

James Bottomley Jan. 7, 2025, 9:31 p.m. UTC
I've cc'd both fsdevel and linux-pm on this because no other
filesystem actually has a hook for hibernation so I need people to
think whether the way I've done it (adding a direct PM hook per
superblock) is the right way and then whether the mechanism is the
best one for addressing the problem.

Problem statement: efivarfs is a pseudo filesystem that is used to
interact with the EFI variables.  After the system is booted, the only
way to retrieve and update variables is via the UEFI Runtime Variable
Services, which are mediated by efivarfs, so it caches the state of
the variables (existence and size) in a dentry tree that ls can see.
However, on hibernation the variables may get altered either by other
operating systems or directly in UEFI setup.  This means that on
hibernation restore, the dentry cache may be out of sync and thus
should be updated.  The added PM_POST_HIBERNATION hook brings the
dentry tree back into sync again.

The first patch abstracts variable creation so it can be reused from
the second patch which, on resume from hibernation, firstly loops over
all the dentries and deletes those which don't exist in the UEFI
variable store and then loops over the variable store creating
dentries for ones that don't exist.

Regards,

James

---

James Bottomley (2):
  efivarfs: abstract initial variable creation routine
  efivarfs: add variable resync after hibernation

 fs/efivarfs/internal.h |   3 +-
 fs/efivarfs/super.c    | 187 +++++++++++++++++++++++++++++++++++++----
 fs/efivarfs/vars.c     |   5 +-
 3 files changed, 177 insertions(+), 18 deletions(-)