On Tue, Jun 01, 2021 at 07:21:29PM -0700, Kuppuswamy Sathyanarayanan wrote:
+ if (memcmp("IntelTDX ", signature, 12))
+ return false;
+
+ return true;
As before,
return !memcmp(...
and then that function can return simply an int.
+}
+
+bool is_tdx_guest(void)
If anything, this should be early_is_tdx_guest().
+{
+ if (tdx_guest < 0)
+ tdx_guest = native_cpuid_has_tdx_guest();
+
+ return !!tdx_guest;
+}
+
Applying: x86/x86: Add is_tdx_guest() interface
.git/rebase-apply/patch:58: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c
index 5b14b72e41c5..5e70617e9877 100644
--- a/arch/x86/kernel/tdx.c
+++ b/arch/x86/kernel/tdx.c
@@ -19,6 +19,12 @@ static inline bool cpuid_has_tdx_guest(void)
return true;
}
+bool is_tdx_guest(void)
+{
+ return static_cpu_has(X86_FEATURE_TDX_GUEST);
+}
+EXPORT_SYMBOL_GPL(is_tdx_guest);
I don't like this is_tdx_guest() thing in kernel proper - what's wrong
with
prot_guest_has(PR_GUEST_TDX)
?
Also, why is it exported, for kvm?
Thx.