diff mbox series

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

Message ID 20220801123426.585801-2-gjoyce@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show
Series generic and PowerPC accessor functions for arch keystore | expand

Commit Message

Greg Joyce Aug. 1, 2022, 12:34 p.m. UTC
From: Greg Joyce <gjoyce@linux.vnet.ibm.com>

Generic kernel subsystems may rely on platform specific persistent
KeyStore to store objects containing sensitive key material. In such case,
they need to access architecture specific functions to perform read/write
operations on these variables.

Define the generic variable read/write prototypes to be implemented by
architecture specific versions. The default(weak) implementations of
these prototypes return -EOPNOTSUPP unless overridden by architecture
versions.

Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
---
 include/linux/arch_vars.h | 23 +++++++++++++++++++++++
 lib/Makefile              |  2 +-
 lib/arch_vars.c           | 25 +++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 include/linux/arch_vars.h
 create mode 100644 lib/arch_vars.c

Comments

Michal Suchánek Aug. 1, 2022, 1:40 p.m. UTC | #1
Hello,

On Mon, Aug 01, 2022 at 07:34:25AM -0500, gjoyce@linux.vnet.ibm.com wrote:
> From: Greg Joyce <gjoyce@linux.vnet.ibm.com>
> 
> Generic kernel subsystems may rely on platform specific persistent
> KeyStore to store objects containing sensitive key material. In such case,
> they need to access architecture specific functions to perform read/write
> operations on these variables.
> 
> Define the generic variable read/write prototypes to be implemented by
> architecture specific versions. The default(weak) implementations of
> these prototypes return -EOPNOTSUPP unless overridden by architecture
> versions.
> 
> Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
> ---
>  include/linux/arch_vars.h | 23 +++++++++++++++++++++++
>  lib/Makefile              |  2 +-
>  lib/arch_vars.c           | 25 +++++++++++++++++++++++++
>  3 files changed, 49 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/arch_vars.h
>  create mode 100644 lib/arch_vars.c
> 
> diff --git a/include/linux/arch_vars.h b/include/linux/arch_vars.h
> new file mode 100644
> index 000000000000..9c280ff9432e
> --- /dev/null
> +++ b/include/linux/arch_vars.h
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Platform variable opearations.
> + *
> + * Copyright (C) 2022 IBM Corporation
> + *
> + * These are the accessor functions (read/write) for architecture specific
> + * variables. Specific architectures can provide overrides.
> + *
> + */
> +
> +#include <linux/kernel.h>
> +
> +enum arch_variable_type {
> +	ARCH_VAR_OPAL_KEY      = 0,     /* SED Opal Authentication Key */
> +	ARCH_VAR_OTHER         = 1,     /* Other type of variable */
> +	ARCH_VAR_MAX           = 1,     /* Maximum type value */
> +};
> +
> +int arch_read_variable(enum arch_variable_type type, char *varname,
> +		       void *varbuf, u_int *varlen);
> +int arch_write_variable(enum arch_variable_type type, char *varname,
> +			void *varbuf, u_int varlen);
> diff --git a/lib/Makefile b/lib/Makefile
> index f99bf61f8bbc..b90c4cb0dbbb 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -48,7 +48,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
>  	 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
>  	 percpu-refcount.o rhashtable.o \
>  	 once.o refcount.o usercopy.o errseq.o bucket_locks.o \
> -	 generic-radix-tree.o
> +	 generic-radix-tree.o arch_vars.o
>  obj-$(CONFIG_STRING_SELFTEST) += test_string.o
>  obj-y += string_helpers.o
>  obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
> diff --git a/lib/arch_vars.c b/lib/arch_vars.c
> new file mode 100644
> index 000000000000..e6f16d7d09c1
> --- /dev/null
> +++ b/lib/arch_vars.c
> @@ -0,0 +1,25 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Platform variable operations.
> + *
> + * Copyright (C) 2022 IBM Corporation
> + *
> + * These are the accessor functions (read/write) for architecture specific
> + * variables. Specific architectures can provide overrides.
> + *
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/arch_vars.h>
> +
> +int __weak arch_read_variable(enum arch_variable_type type, char *varname,
> +			      void *varbuf, u_int *varlen)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +int __weak arch_write_variable(enum arch_variable_type type, char *varname,
> +			       void *varbuf, u_int varlen)
> +{
> +	return -EOPNOTSUPP;
> +}
> -- 

Doesn't EFI already have some variables?

And even powernv?

Shouldn't this generalize the already existing variables?

Or move to powerpc and at least generalize the powerpc ones?

Thanks

Michal
Nayna Aug. 1, 2022, 7:45 p.m. UTC | #2
On 8/1/22 09:40, Michal Suchánek wrote:
> Hello,
>
> On Mon, Aug 01, 2022 at 07:34:25AM -0500, gjoyce@linux.vnet.ibm.com wrote:
>> From: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>>
>> Generic kernel subsystems may rely on platform specific persistent
>> KeyStore to store objects containing sensitive key material. In such case,
>> they need to access architecture specific functions to perform read/write
>> operations on these variables.
>>
>> Define the generic variable read/write prototypes to be implemented by
>> architecture specific versions. The default(weak) implementations of
>> these prototypes return -EOPNOTSUPP unless overridden by architecture
>> versions.
>>
>> Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>> ---
>>   include/linux/arch_vars.h | 23 +++++++++++++++++++++++
>>   lib/Makefile              |  2 +-
>>   lib/arch_vars.c           | 25 +++++++++++++++++++++++++
>>   3 files changed, 49 insertions(+), 1 deletion(-)
>>   create mode 100644 include/linux/arch_vars.h
>>   create mode 100644 lib/arch_vars.c
>>
>> diff --git a/include/linux/arch_vars.h b/include/linux/arch_vars.h
>> new file mode 100644
>> index 000000000000..9c280ff9432e
>> --- /dev/null
>> +++ b/include/linux/arch_vars.h
>> @@ -0,0 +1,23 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Platform variable opearations.
>> + *
>> + * Copyright (C) 2022 IBM Corporation
>> + *
>> + * These are the accessor functions (read/write) for architecture specific
>> + * variables. Specific architectures can provide overrides.
>> + *
>> + */
>> +
>> +#include <linux/kernel.h>
>> +
>> +enum arch_variable_type {
>> +	ARCH_VAR_OPAL_KEY      = 0,     /* SED Opal Authentication Key */
>> +	ARCH_VAR_OTHER         = 1,     /* Other type of variable */
>> +	ARCH_VAR_MAX           = 1,     /* Maximum type value */
>> +};
>> +
>> +int arch_read_variable(enum arch_variable_type type, char *varname,
>> +		       void *varbuf, u_int *varlen);
>> +int arch_write_variable(enum arch_variable_type type, char *varname,
>> +			void *varbuf, u_int varlen);
>> diff --git a/lib/Makefile b/lib/Makefile
>> index f99bf61f8bbc..b90c4cb0dbbb 100644
>> --- a/lib/Makefile
>> +++ b/lib/Makefile
>> @@ -48,7 +48,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
>>   	 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
>>   	 percpu-refcount.o rhashtable.o \
>>   	 once.o refcount.o usercopy.o errseq.o bucket_locks.o \
>> -	 generic-radix-tree.o
>> +	 generic-radix-tree.o arch_vars.o
>>   obj-$(CONFIG_STRING_SELFTEST) += test_string.o
>>   obj-y += string_helpers.o
>>   obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
>> diff --git a/lib/arch_vars.c b/lib/arch_vars.c
>> new file mode 100644
>> index 000000000000..e6f16d7d09c1
>> --- /dev/null
>> +++ b/lib/arch_vars.c
>> @@ -0,0 +1,25 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Platform variable operations.
>> + *
>> + * Copyright (C) 2022 IBM Corporation
>> + *
>> + * These are the accessor functions (read/write) for architecture specific
>> + * variables. Specific architectures can provide overrides.
>> + *
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/arch_vars.h>
>> +
>> +int __weak arch_read_variable(enum arch_variable_type type, char *varname,
>> +			      void *varbuf, u_int *varlen)
>> +{
>> +	return -EOPNOTSUPP;
>> +}
>> +
>> +int __weak arch_write_variable(enum arch_variable_type type, char *varname,
>> +			       void *varbuf, u_int varlen)
>> +{
>> +	return -EOPNOTSUPP;
>> +}
>> -- 
> Doesn't EFI already have some variables?
>
> And even powernv?
>
> Shouldn't this generalize the already existing variables?
>
> Or move to powerpc and at least generalize the powerpc ones?

Yes, EFI and PowerNV do have variables, but I am not exactly clear about 
your reference to them in this context. What do you mean by generalize 
already existing variables ?

This interface is actually generalizing calls to access platform 
specific keystores. It is explained in cover letter that this patch is 
defining generic interface and these are default implementations which 
needs to be overridden by arch specific versions.  For PowerVM PLPAR 
Platform KeyStore, the arch specific version is implemented in Patch 2.

Access to EFI variables should be implemented by EFI arch specific 
interface and PowerNV will have to do the same if it needs to.

Hope it helps.

Thanks & Regards,

     - Nayna
Michal Suchánek Aug. 1, 2022, 8:24 p.m. UTC | #3
On Mon, Aug 01, 2022 at 03:45:45PM -0400, Nayna wrote:
> 
> On 8/1/22 09:40, Michal Suchánek wrote:
> > Hello,
> > 
> > On Mon, Aug 01, 2022 at 07:34:25AM -0500, gjoyce@linux.vnet.ibm.com wrote:
> > > From: Greg Joyce <gjoyce@linux.vnet.ibm.com>
> > > 
> > > Generic kernel subsystems may rely on platform specific persistent
> > > KeyStore to store objects containing sensitive key material. In such case,
> > > they need to access architecture specific functions to perform read/write
> > > operations on these variables.
> > > 
> > > Define the generic variable read/write prototypes to be implemented by
> > > architecture specific versions. The default(weak) implementations of
> > > these prototypes return -EOPNOTSUPP unless overridden by architecture
> > > versions.
> > > 
> > > Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
> > > ---
> > >   include/linux/arch_vars.h | 23 +++++++++++++++++++++++
> > >   lib/Makefile              |  2 +-
> > >   lib/arch_vars.c           | 25 +++++++++++++++++++++++++
> > >   3 files changed, 49 insertions(+), 1 deletion(-)
> > >   create mode 100644 include/linux/arch_vars.h
> > >   create mode 100644 lib/arch_vars.c
> > > 
> > > diff --git a/include/linux/arch_vars.h b/include/linux/arch_vars.h
> > > new file mode 100644
> > > index 000000000000..9c280ff9432e
> > > --- /dev/null
> > > +++ b/include/linux/arch_vars.h
> > > @@ -0,0 +1,23 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +/*
> > > + * Platform variable opearations.
> > > + *
> > > + * Copyright (C) 2022 IBM Corporation
> > > + *
> > > + * These are the accessor functions (read/write) for architecture specific
> > > + * variables. Specific architectures can provide overrides.
> > > + *
> > > + */
> > > +
> > > +#include <linux/kernel.h>
> > > +
> > > +enum arch_variable_type {
> > > +	ARCH_VAR_OPAL_KEY      = 0,     /* SED Opal Authentication Key */
> > > +	ARCH_VAR_OTHER         = 1,     /* Other type of variable */
> > > +	ARCH_VAR_MAX           = 1,     /* Maximum type value */
> > > +};
> > > +
> > > +int arch_read_variable(enum arch_variable_type type, char *varname,
> > > +		       void *varbuf, u_int *varlen);
> > > +int arch_write_variable(enum arch_variable_type type, char *varname,
> > > +			void *varbuf, u_int varlen);
> > > diff --git a/lib/Makefile b/lib/Makefile
> > > index f99bf61f8bbc..b90c4cb0dbbb 100644
> > > --- a/lib/Makefile
> > > +++ b/lib/Makefile
> > > @@ -48,7 +48,7 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
> > >   	 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
> > >   	 percpu-refcount.o rhashtable.o \
> > >   	 once.o refcount.o usercopy.o errseq.o bucket_locks.o \
> > > -	 generic-radix-tree.o
> > > +	 generic-radix-tree.o arch_vars.o
> > >   obj-$(CONFIG_STRING_SELFTEST) += test_string.o
> > >   obj-y += string_helpers.o
> > >   obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
> > > diff --git a/lib/arch_vars.c b/lib/arch_vars.c
> > > new file mode 100644
> > > index 000000000000..e6f16d7d09c1
> > > --- /dev/null
> > > +++ b/lib/arch_vars.c
> > > @@ -0,0 +1,25 @@
> > > +// SPDX-License-Identifier: GPL-2.0-only
> > > +/*
> > > + * Platform variable operations.
> > > + *
> > > + * Copyright (C) 2022 IBM Corporation
> > > + *
> > > + * These are the accessor functions (read/write) for architecture specific
> > > + * variables. Specific architectures can provide overrides.
> > > + *
> > > + */
> > > +
> > > +#include <linux/kernel.h>
> > > +#include <linux/arch_vars.h>
> > > +
> > > +int __weak arch_read_variable(enum arch_variable_type type, char *varname,
> > > +			      void *varbuf, u_int *varlen)
> > > +{
> > > +	return -EOPNOTSUPP;
> > > +}
> > > +
> > > +int __weak arch_write_variable(enum arch_variable_type type, char *varname,
> > > +			       void *varbuf, u_int varlen)
> > > +{
> > > +	return -EOPNOTSUPP;
> > > +}
> > > -- 
> > Doesn't EFI already have some variables?
> > 
> > And even powernv?
> > 
> > Shouldn't this generalize the already existing variables?
> > 
> > Or move to powerpc and at least generalize the powerpc ones?
> 
> Yes, EFI and PowerNV do have variables, but I am not exactly clear about
> your reference to them in this context. What do you mean by generalize
> already existing variables ?
> 
> This interface is actually generalizing calls to access platform specific
> keystores. It is explained in cover letter that this patch is defining
> generic interface and these are default implementations which needs to be
> overridden by arch specific versions.  For PowerVM PLPAR Platform KeyStore,
> the arch specific version is implemented in Patch 2.
For powervm, not powernv.

If it's not generic enough to cover even powerpc-specific keystores does
such generalization even need to exist?
> 
> Access to EFI variables should be implemented by EFI arch specific interface
> and PowerNV will have to do the same if it needs to.

If such generic interface is desirable it should cover the existing
architectures I think. Otherwise how can you tell if it's usable there?

Thanks

Michal
Michael Ellerman Aug. 2, 2022, 2:59 a.m. UTC | #4
Hi Greg,

gjoyce@linux.vnet.ibm.com writes:
> From: Greg Joyce <gjoyce@linux.vnet.ibm.com>
>
> Generic kernel subsystems may rely on platform specific persistent
> KeyStore to store objects containing sensitive key material. In such case,
> they need to access architecture specific functions to perform read/write
> operations on these variables.
>
> Define the generic variable read/write prototypes to be implemented by
> architecture specific versions. The default(weak) implementations of
> these prototypes return -EOPNOTSUPP unless overridden by architecture
> versions.
>
> Signed-off-by: Greg Joyce <gjoyce@linux.vnet.ibm.com>
> ---
>  include/linux/arch_vars.h | 23 +++++++++++++++++++++++
>  lib/Makefile              |  2 +-
>  lib/arch_vars.c           | 25 +++++++++++++++++++++++++
>  3 files changed, 49 insertions(+), 1 deletion(-)
>  create mode 100644 include/linux/arch_vars.h
>  create mode 100644 lib/arch_vars.c

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.

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.

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.

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?

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.

cheers
Greg Joyce Aug. 2, 2022, 10:39 p.m. UTC | #5
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
Greg Joyce Aug. 4, 2022, 3:41 p.m. UTC | #6
On Mon, 2022-08-01 at 22:24 +0200, Michal Suchánek wrote:
> > > > +
> > > > +int __weak arch_read_variable(enum arch_variable_type type,
> > > > char *varname,
> > > > +			      void *varbuf, u_int *varlen)
> > > > +{
> > > > +	return -EOPNOTSUPP;
> > > > +}
> > > > +
> > > > +int __weak arch_write_variable(enum arch_variable_type type,
> > > > char *varname,
> > > > +			       void *varbuf, u_int varlen)
> > > > +{
> > > > +	return -EOPNOTSUPP;
> > > > +}
> > > > -- 
> > > Doesn't EFI already have some variables?
> > > 
> > > And even powernv?
> > > 
> > > Shouldn't this generalize the already existing variables?
> > > 
> > > Or move to powerpc and at least generalize the powerpc ones?
> > 
> > Yes, EFI and PowerNV do have variables, but I am not exactly clear
> > about
> > your reference to them in this context. What do you mean by
> > generalize
> > already existing variables ?
> > 
> > This interface is actually generalizing calls to access platform
> > specific
> > keystores. It is explained in cover letter that this patch is
> > defining
> > generic interface and these are default implementations which needs
> > to be
> > overridden by arch specific versions.  For PowerVM PLPAR Platform
> > KeyStore,
> > the arch specific version is implemented in Patch 2.
> For powervm, not powernv.
> 
> If it's not generic enough to cover even powerpc-specific keystores
> does
> such generalization even need to exist?

I believe that the interface is generic enough to cover most if not all
keystores. However, we're just implementing a PowerVM version since
that is our mandate. 

> > Access to EFI variables should be implemented by EFI arch specific
> > interface
> > and PowerNV will have to do the same if it needs to.
> 
> If such generic interface is desirable it should cover the existing
> architectures I think. Otherwise how can you tell if it's usable
> there?

Are you suggesting that we implement architecture specific
implementations for every architecture supported by Linux? I'm afraid
that we don't have the time (or skills) to do that. The intent is to
provide the "weak" versions of the interface functions so that they can
be overridden as folks have the time or inclination to provide them for
other architectures.

-Greg
diff mbox series

Patch

diff --git a/include/linux/arch_vars.h b/include/linux/arch_vars.h
new file mode 100644
index 000000000000..9c280ff9432e
--- /dev/null
+++ b/include/linux/arch_vars.h
@@ -0,0 +1,23 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Platform variable opearations.
+ *
+ * Copyright (C) 2022 IBM Corporation
+ *
+ * These are the accessor functions (read/write) for architecture specific
+ * variables. Specific architectures can provide overrides.
+ *
+ */
+
+#include <linux/kernel.h>
+
+enum arch_variable_type {
+	ARCH_VAR_OPAL_KEY      = 0,     /* SED Opal Authentication Key */
+	ARCH_VAR_OTHER         = 1,     /* Other type of variable */
+	ARCH_VAR_MAX           = 1,     /* Maximum type value */
+};
+
+int arch_read_variable(enum arch_variable_type type, char *varname,
+		       void *varbuf, u_int *varlen);
+int arch_write_variable(enum arch_variable_type type, char *varname,
+			void *varbuf, u_int varlen);
diff --git a/lib/Makefile b/lib/Makefile
index f99bf61f8bbc..b90c4cb0dbbb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -48,7 +48,7 @@  obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \
 	 bsearch.o find_bit.o llist.o memweight.o kfifo.o \
 	 percpu-refcount.o rhashtable.o \
 	 once.o refcount.o usercopy.o errseq.o bucket_locks.o \
-	 generic-radix-tree.o
+	 generic-radix-tree.o arch_vars.o
 obj-$(CONFIG_STRING_SELFTEST) += test_string.o
 obj-y += string_helpers.o
 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
diff --git a/lib/arch_vars.c b/lib/arch_vars.c
new file mode 100644
index 000000000000..e6f16d7d09c1
--- /dev/null
+++ b/lib/arch_vars.c
@@ -0,0 +1,25 @@ 
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Platform variable operations.
+ *
+ * Copyright (C) 2022 IBM Corporation
+ *
+ * These are the accessor functions (read/write) for architecture specific
+ * variables. Specific architectures can provide overrides.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/arch_vars.h>
+
+int __weak arch_read_variable(enum arch_variable_type type, char *varname,
+			      void *varbuf, u_int *varlen)
+{
+	return -EOPNOTSUPP;
+}
+
+int __weak arch_write_variable(enum arch_variable_type type, char *varname,
+			       void *varbuf, u_int varlen)
+{
+	return -EOPNOTSUPP;
+}