aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorGravatar Russell Currey <ruscur@russell.cc> 2023-02-10 19:03:40 +1100
committerGravatar Michael Ellerman <mpe@ellerman.id.au> 2023-02-12 22:12:36 +1100
commit26149b02021158248b13e323f06372d87f076883 (patch)
treea51bb3bd4339839314d256dba48f78561fc4a5dd /arch/powerpc/kernel
parentpowerpc/secvar: Use u64 in secvar_operations (diff)
downloadlinux-26149b02021158248b13e323f06372d87f076883.tar.gz
linux-26149b02021158248b13e323f06372d87f076883.tar.bz2
linux-26149b02021158248b13e323f06372d87f076883.zip
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
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/secvar-ops.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/secvar-ops.c b/arch/powerpc/kernel/secvar-ops.c
index 6a29777d6a2d..19172a2804f0 100644
--- a/arch/powerpc/kernel/secvar-ops.c
+++ b/arch/powerpc/kernel/secvar-ops.c
@@ -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;
}