powerpc/pseries/svm: Add a powerpc version of cc_platform_has()
authorTom Lendacky <thomas.lendacky@amd.com>
Wed, 8 Sep 2021 22:58:35 +0000 (17:58 -0500)
committerBorislav Petkov <bp@suse.de>
Mon, 4 Oct 2021 09:46:33 +0000 (11:46 +0200)
Introduce a powerpc version of the cc_platform_has() function. This will
be used to replace the powerpc mem_encrypt_active() implementation, so
the implementation will initially only support the CC_ATTR_MEM_ENCRYPT
attribute.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lkml.kernel.org/r/20210928191009.32551-5-bp@alien8.de
arch/powerpc/platforms/pseries/Kconfig
arch/powerpc/platforms/pseries/Makefile
arch/powerpc/platforms/pseries/cc_platform.c [new file with mode: 0644]

index 5e037df2a3a1778363dc44966dbaad836d4f07aa..2e57391e07781f9302b2933438da36dcc44b0021 100644 (file)
@@ -159,6 +159,7 @@ config PPC_SVM
        select SWIOTLB
        select ARCH_HAS_MEM_ENCRYPT
        select ARCH_HAS_FORCE_DMA_UNENCRYPTED
+       select ARCH_HAS_CC_PLATFORM
        help
         There are certain POWER platforms which support secure guests using
         the Protected Execution Facility, with the help of an Ultravisor
index 4cda0ef87be00405609b22bc3983a315378e8fee..41d8aee98da4e6475c82435d4516f3b626b3d26b 100644 (file)
@@ -31,3 +31,5 @@ obj-$(CONFIG_FA_DUMP)         += rtas-fadump.o
 
 obj-$(CONFIG_SUSPEND)          += suspend.o
 obj-$(CONFIG_PPC_VAS)          += vas.o
+
+obj-$(CONFIG_ARCH_HAS_CC_PLATFORM)     += cc_platform.o
diff --git a/arch/powerpc/platforms/pseries/cc_platform.c b/arch/powerpc/platforms/pseries/cc_platform.c
new file mode 100644 (file)
index 0000000..e8021af
--- /dev/null
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Confidential Computing Platform Capability checks
+ *
+ * Copyright (C) 2021 Advanced Micro Devices, Inc.
+ *
+ * Author: Tom Lendacky <thomas.lendacky@amd.com>
+ */
+
+#include <linux/export.h>
+#include <linux/cc_platform.h>
+
+#include <asm/machdep.h>
+#include <asm/svm.h>
+
+bool cc_platform_has(enum cc_attr attr)
+{
+       switch (attr) {
+       case CC_ATTR_MEM_ENCRYPT:
+               return is_secure_guest();
+
+       default:
+               return false;
+       }
+}
+EXPORT_SYMBOL_GPL(cc_platform_has);