[PATCH v3 1/2] lib: generic accessor functions for arch keystore

Greg Joyce gjoyce at linux.vnet.ibm.com
Wed Aug 3 08:39:57 AEST 2022


Michael and Michal,

On Tue, 2022-08-02 at 12:59 +1000, Michael Ellerman wrote:
> I don't think "arch" is the right level of abstraction here.
> 
> There isn't a standard way to get these variables across a given
> arch,
> they're not defined in the architecture specification etc.
> 
> As demonstrated in your patch 2, on powerpc they are coming from a
> platform level pseudo device (provided by the PowerVM hypervisor).
> But
> they would come from elsewhere on a bare metal system.

I'm open to something other than "arch_" if that causes confusion.
Maybe "plat_"?

> And you could imagine other architectures could support multiple ways
> to
> retrieve these kind of variables from various different places,
> possibly
> more than one place on a given system.

Agreed, and that's why an architecture or platform can override the
functions. The first parameter also allows for further distinction of
how the data could be interpreted, including in multiple ways as you
suggest.

I wanted to allow for different types of persistent storage. For
instance you could have a platform that used a NAND deice for permanent
storage that could still use the API as proposed.

> So I think at least you want a way for any device to register itself
> as
> able to provide these variables. Possibly with a chain of handlers,
> something like the sys_off_handlers, or maybe there only ever needs
> to
> be one provider, the way pm_power_off (used to) work.

I did look at some of the other ways of dynamically registering
functions but most of the exisiting examples are centered around a
specific device entity which is not the case here. The functionailty is
pretty simple so I was hoping to keep the API simple as well.

The sys_off_handler functions certainly provide a good way of
registering for asynchronous notifications but for this purpose we need
synchronous functions that possibly return data. Many of the pci
functions end up in platform specific code but they use information
from struct pci_dev to route the call to the appropriate place. 

> Looking at your patch to block/sed-opal.c:
> 
> https://lore.kernel.org/all/20220718210156.1535955-4-gjoyce@linux.vnet.ibm.com/
> 
> It seems like the calls to these arch routines are closely tied to
> calls
> to the keyring API. Should this functionality be part of the keyring
> API?

Those calls are just using the API to read/write named variables that
happen to be keys in this case. I was envisioning that there may be
uses other than SED for persistent key/values.


> At a mininmum I think you need to get much wider review on something
> like this. So I'd suggest the keyring folks and as Michal pointed
> out,
> this seems a bit like EFI variables so it would be good to Cc the
> EFI/EFI variable folks.

The keyring folks were on the original SED patchset review and I did
incorporate a good comment involving use of keyrings. I will copy them
again (as well as EFI folks) for the next update.

-Greg



More information about the Linuxppc-dev mailing list