Messages in this thread | | | Date | Thu, 10 Jun 2021 21:59:48 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH v1 04/11] x86/x86: Add is_tdx_guest() interface |
| |
On Tue, Jun 01, 2021 at 07:21:29PM -0700, Kuppuswamy Sathyanarayanan wrote: > +static int __ro_after_init tdx_guest = -1; > + > +static inline bool native_cpuid_has_tdx_guest(void) > +{ > + u32 eax = TDX_CPUID_LEAF_ID, signature[3] = {0}; > + > + if (native_cpuid_eax(0) < TDX_CPUID_LEAF_ID) > + return false; > + > + native_cpuid(&eax, &signature[0], &signature[1], &signature[2]); > + > + 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.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |