lkml.org 
[lkml]   [2021]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v10 04/11] x86/tdx: Add TDX support to intel_cc_platform_has()
Date
cc_platform_has() can be used to check for specific active confidential
computing attributes, like memory encryption. For Intel platform like
Trusted Domain Extensions (TDX) guest has need for using this function
to protect the TDX specific changes made in generic drivers.

So add TDX guest support to intel_cc_platform_has().

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---

Changes since v9:
* None

Changes since v8:
* Rebased this patch on top of x86/tip/master branch.

Changes since v7:
* Merged patches titled "x86/tdx: Add Intel ARCH support to cc_platform_has()" and
"x86/tdx: Add TDX guest support to intel_cc_platform_has()" into one patch.
* Used cpuid_has_tdx_guest() when adding Intel support to cc_platform_has().

Change since v6:
* Used cc_platform_has() in place of prot_guest_has().
* Rebased on top of Tom Landecky's CC platform support patch series.
https://lore.kernel.org/linux-iommu/f9951644147e27772bf4512325e8ba6472e363b7.1631141919.git.thomas.lendacky@amd.com/T/

Changes since v5:
* Replaced tdx_prot_guest_has() with intel_prot_guest_has() to
keep the Intel call non TDX specific.
* Added TDX guest support to intel_prot_guest_has().

Changes since v4:
* Rebased on top of Tom Lendacky's protected guest changes.
* Moved memory encryption related protected guest flags in
tdx_prot_guest_has() to the patch that actually uses them.

arch/x86/Kconfig | 1 +
arch/x86/kernel/cc_platform.c | 12 ++++++++++--
include/linux/cc_platform.h | 9 +++++++++
3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index eab7f2911f94..af49ad084919 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -870,6 +870,7 @@ config INTEL_TDX_GUEST
depends on X86_64 && CPU_SUP_INTEL && PARAVIRT
depends on SECURITY
depends on X86_X2APIC
+ select ARCH_HAS_CC_PLATFORM
help
Provide support for running in a trusted domain on Intel processors
equipped with Trusted Domain Extensions. TDX is a Intel technology
diff --git a/arch/x86/kernel/cc_platform.c b/arch/x86/kernel/cc_platform.c
index 03bb2f343ddb..589c003d8954 100644
--- a/arch/x86/kernel/cc_platform.c
+++ b/arch/x86/kernel/cc_platform.c
@@ -11,12 +11,18 @@
#include <linux/cc_platform.h>
#include <linux/mem_encrypt.h>

+#include <asm/tdx.h>
#include <asm/processor.h>

-static bool __maybe_unused intel_cc_platform_has(enum cc_attr attr)
+static bool intel_cc_platform_has(enum cc_attr attr)
{
#ifdef CONFIG_INTEL_TDX_GUEST
- return false;
+ switch (attr) {
+ case CC_ATTR_GUEST_TDX:
+ return is_tdx_guest();
+ default:
+ return false;
+ }
#else
return false;
#endif
@@ -63,6 +69,8 @@ bool cc_platform_has(enum cc_attr attr)
{
if (sme_me_mask)
return amd_cc_platform_has(attr);
+ else if (is_tdx_guest())
+ return intel_cc_platform_has(attr);

return false;
}
diff --git a/include/linux/cc_platform.h b/include/linux/cc_platform.h
index a075b70b9a70..6124527a0423 100644
--- a/include/linux/cc_platform.h
+++ b/include/linux/cc_platform.h
@@ -61,6 +61,15 @@ enum cc_attr {
* Examples include SEV-ES.
*/
CC_ATTR_GUEST_STATE_ENCRYPT,
+
+ /**
+ * @CC_ATTR_GUEST_TDX: Trusted Domain Extension Support
+ *
+ * The platform/OS is running as a TDX guest/virtual machine.
+ *
+ * Examples include Intel TDX.
+ */
+ CC_ATTR_GUEST_TDX,
};

#ifdef CONFIG_ARCH_HAS_CC_PLATFORM
--
2.25.1
\
 
 \ /
  Last update: 2021-10-09 07:38    [W:0.372 / U:2.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site