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: Russell Currey <ruscur@russell.cc>
Co-developed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230210080401.345462-6-ajd@linux.ibm.com
This commit is contained in:
Russell Currey 2023-02-10 19:03:40 +11:00 committed by Michael Ellerman
parent 53cea34b0a
commit 26149b0202
3 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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[] = {