Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp36336pxj; Thu, 10 Jun 2021 14:04:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwm0X5+NUJf0wCU9FPXg7JqfWwiRfwB/g936++Zm0jAplaweq55qBBztfzoqzH1qVA1j3e X-Received: by 2002:a50:eb8f:: with SMTP id y15mr371438edr.285.1623359052959; Thu, 10 Jun 2021 14:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623359052; cv=none; d=google.com; s=arc-20160816; b=LPJi4tEKRfu2IgXD0yzWh5oo3taeZNRjw4BHFa9EDIO96UdwGR/zZbuATz+zv2kp5Q 1szG7yPtm2C3yhfmiw3AA8MKhKvl55fU/k7uEjJiMtfnmE+Zk2WAtiNXssVFAJzS+GZ/ /nO6mwJ8YYfW+Wlg5INMeycEC7mkRbQJ3MGvfndsVhTzt12wiIC8WHY6xWVL1nng+Fqh jT0W+h6QJWM6SCBJEC5iUEvR/ApSX9qcxkyqHEZR13W9Q7epNEgyS2yQZe2Mic6+bIlj +5PzQfT2WZJZXsflt+yGh+XOx5gdNMc3QAUC66jQTx4k2jWojoj+qf4bC0eNOhny3ZT0 FXFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=BlDwihJBRWDVBM0KesXORnwkIZIry9SirHhYVvnDqRc=; b=MJCRoTq5eEFItzkx+RP2Z978ClhxlIBn6ICCJuWJGOjG3fDtm0dV1nzxGilLuiKpDG QcJYzFfkHxBXjA1yh5oejm4nzyoPDhby/VX5eLxssp6pmhioe/8rJTD6ZoQuGxBWRdJ9 7bfnPk9X5ZKm8MPSVQ5qjyQULjGvCh0Eg9OEDCn68V8ij0U/wCtyfCg9XgK5CxS72GZA /56tU8zMzondEYKi/oxUuzN1yYxLgiMP66QGG6zwDA4jwQ80705M9cnvmrUwHmiUlh7y wDYF1OgrKLJcigcYXuhVhwEs7z5ThhcuM40waRDIZTBaWeJkn7OBgQsATtjh4ZFSOfu1 fPMw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu6si3328377ejb.547.2021.06.10.14.03.49; Thu, 10 Jun 2021 14:04:12 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbhFJVEL (ORCPT + 99 others); Thu, 10 Jun 2021 17:04:11 -0400 Received: from mga18.intel.com ([134.134.136.126]:6315 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhFJVEK (ORCPT ); Thu, 10 Jun 2021 17:04:10 -0400 IronPort-SDR: vKLP2Ow0fAX9d62SqnnOqLbHeAmWmyfZYm83UXLTOIBC0KD19FtZAruyP+/ymhKdLNM8crV3XA s8kYpBgQHN4w== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="192716663" X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="192716663" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 14:02:06 -0700 IronPort-SDR: lbmup0cC6XTkT/KNzijKds2JjYsdvUR6XV1oUqeJ9V4O88iqYA8L5gAaNl/0vIpStGqDc+qqMe TXjbdrESLk+g== X-IronPort-AV: E=Sophos;i="5.83,264,1616482800"; d="scan'208";a="486332906" Received: from miishak-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.212.54.237]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 14:02:04 -0700 Subject: Re: [PATCH v1 04/11] x86/x86: Add is_tdx_guest() interface To: Borislav Petkov 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 References: <20210602022136.2186759-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210602022136.2186759-5-sathyanarayanan.kuppuswamy@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: <3437ff11-4656-2c2a-ae58-04b77b6ff663@linux.intel.com> Date: Thu, 10 Jun 2021 14:01:41 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/10/21 12:59 PM, Borislav Petkov wrote: > 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. I will make the above change in next version. > > >> +} >> + >> +bool is_tdx_guest(void) > > If anything, this should be early_is_tdx_guest(). If this is the recommendation, I am fine with it. It is only used by __in/__out macros in decompression code. > >> +{ >> + 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. I will fix it in next version. > > >> 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) Is it alright to use vendor name in prot_guest_has() flag? I thought we want to keep them generic. If this is acceptable, we can replace is_tdx_guest() with prot_guest_has() calls. Currently it is not used in many places. > > ? > > Also, why is it exported, for kvm? Yes. It is used in exported KVM functions. > > Thx. > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer