Commit 26149b02 authored by Russell Currey's avatar Russell Currey Committed by Michael Ellerman

powerpc/secvar: Warn and error if multiple secvar ops are set

The secvar code only supports one consumer at a time.

Multiple consumers aren't possible at this point in time, but we'd want
it to be obvious if it ever could happen.
Signed-off-by: default avatarRussell Currey <ruscur@russell.cc>
Co-developed-by: default avatarAndrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: default avatarAndrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230210080401.345462-6-ajd@linux.ibm.com
parent 53cea34b
......@@ -21,11 +21,11 @@ struct secvar_operations {
#ifdef CONFIG_PPC_SECURE_BOOT
extern void set_secvar_ops(const struct secvar_operations *ops);
int set_secvar_ops(const struct secvar_operations *ops);
#else
static inline void set_secvar_ops(const struct secvar_operations *ops) { }
static inline int set_secvar_ops(const struct secvar_operations *ops) { return 0; }
#endif
......
......@@ -8,10 +8,16 @@
#include <linux/cache.h>
#include <asm/secvar.h>
#include <asm/bug.h>
const struct secvar_operations *secvar_ops __ro_after_init;
const struct secvar_operations *secvar_ops __ro_after_init = NULL;
void set_secvar_ops(const struct secvar_operations *ops)
int set_secvar_ops(const struct secvar_operations *ops)
{
if (WARN_ON_ONCE(secvar_ops))
return -EBUSY;
secvar_ops = ops;
return 0;
}
......@@ -113,9 +113,7 @@ static int opal_secvar_probe(struct platform_device *pdev)
return -ENODEV;
}
set_secvar_ops(&opal_secvar_ops);
return 0;
return set_secvar_ops(&opal_secvar_ops);
}
static const struct of_device_id opal_secvar_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment