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

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
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 −2
Original line number Diff line number Diff line
@@ -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;
}
+1 −3
Original line number Diff line number Diff line
@@ -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[] = {