Received: by 2002:a05:6520:2586:b029:fa:41f3:c225 with SMTP id u6csp867909lky; Thu, 10 Jun 2021 13:01:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxwmRKBPkU4xzb6D48MEzl8cdt1azUGeXsCen79N2CZ2voaPSRC2FgGKVzm/8YWC1OsLAp X-Received: by 2002:a05:6402:204:: with SMTP id t4mr217545edv.34.1623355318116; Thu, 10 Jun 2021 13:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623355318; cv=none; d=google.com; s=arc-20160816; b=xj22LSE9Ztm064iEreubz1Rfk0o5Z3cLw7MYwAvN/sbeXDwdN1gy4GBPhjyhDHGGQN eDHp7wlpXsiVklS4hDc6RAhkrW7cU2wsyEEFS7zgWEcJgj0nGzXf++SzKnCVuLGeSrJ+ 1VwQ3BLDylNsLWCtu7Jf7VOPGR8u/4E47JkXXt3t3zXbK0blfKp3ml95MPc8/VTKVoW1 QQk8t5tPptcQ721JTgSd47QJuZzPP4sAZsRHxeXRnUYinhZByPXngHvvTfH2+RTbZi8b Oh1Pm03ugRP3UFZ9wNJPz/M9AQ/qQsI0JxeFsFZIq2dl2Z5Rrve3WvbdhD1IVbjT2JUl +YtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lBBqddz2EGvOETeoLd88euAwewgGmyuu/AiEcw26P2I=; b=ub/Dw6hFT6fFkQdWHikboYTUVOMbB2Xju0x7nV1CBA/QCuSjf+/B2tHJMd2UamVbwD P5HvDy0J2HbXV/H73d037hMgaqQKlgmeMViOS3wnEbd5Tx4DEiRBRbVbA+vxZHdY+ctJ Ul2oIhHA2QDnBysGM3FVoJeoTY3dm/REbjpn3ephDTtFrZDqeVzkxaWizWS62GZNdI7T 53dXQe0OHyKOedF7BS63PJc4FDGfJxQYh/3aQFimQOtf2pDZzMMndfvfHcucl9+xVACF jnIaNwjr1jj6aNLeYq5nO+fJCdYg2LUw8lM2ejL12g/6Bz2KwGmPPfAyGjT0HSL44GyY 2NDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=nCoyXoW0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si3284633edc.271.2021.06.10.13.01.31; Thu, 10 Jun 2021 13:01:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=nCoyXoW0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbhFJUBw (ORCPT + 99 others); Thu, 10 Jun 2021 16:01:52 -0400 Received: from mail.skyhub.de ([5.9.137.197]:57488 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhFJUBw (ORCPT ); Thu, 10 Jun 2021 16:01:52 -0400 Received: from zn.tnic (p200300ec2f0cf6005d9c12d1298a6408.dip0.t-ipconnect.de [IPv6:2003:ec:2f0c:f600:5d9c:12d1:298a:6408]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 785851EC04DF; Thu, 10 Jun 2021 21:59:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1623355194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=lBBqddz2EGvOETeoLd88euAwewgGmyuu/AiEcw26P2I=; b=nCoyXoW03lmennUIFKhXDCv7QAHJF/cCAn2yEqLRQ87iKrZJVuMpwKDeUv8Cs0qgL8l52c ZnuaehH9aTwaIEn61rHZqXC4sGjsRGdvNs17iTiekIGP7aZf/WA0JsOwlJY/IwRmu5gmuN gj6uPxOSxfAKaj/T9iZu4KxoOYSgjBA= Date: Thu, 10 Jun 2021 21:59:48 +0200 From: Borislav Petkov To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Sean Christopherson , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v1 04/11] x86/x86: Add is_tdx_guest() interface Message-ID: References: <20210602022136.2186759-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210602022136.2186759-5-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210602022136.2186759-5-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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