lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Jun 2021 21:59:48 +0200
From:   Borislav Petkov <bp@...en8.de>
To:     Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Andy Lutomirski <luto@...nel.org>,
        Peter H Anvin <hpa@...or.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
        Kuppuswamy Sathyanarayanan <knsathya@...nel.org>,
        Sean Christopherson <seanjc@...gle.com>,
        linux-kernel@...r.kernel.org, x86@...nel.org
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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ