From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 737BDC4338F for ; Wed, 4 Aug 2021 22:26:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57AD96056B for ; Wed, 4 Aug 2021 22:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232523AbhHDW0b (ORCPT ); Wed, 4 Aug 2021 18:26:31 -0400 Received: from mga03.intel.com ([134.134.136.65]:15091 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbhHDW0a (ORCPT ); Wed, 4 Aug 2021 18:26:30 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10066"; a="214054940" X-IronPort-AV: E=Sophos;i="5.84,295,1620716400"; d="scan'208";a="214054940" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 15:26:16 -0700 X-IronPort-AV: E=Sophos;i="5.84,295,1620716400"; d="scan'208";a="512253267" Received: from bguvendi-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.212.99.93]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 15:26:15 -0700 Subject: Re: [PATCH v5 04/12] x86/tdx: Add protected guest support for TDX guest To: Dave Hansen , Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org References: <20210804181329.2899708-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210804181329.2899708-5-sathyanarayanan.kuppuswamy@linux.intel.com> <9c576f24-e6de-f816-623d-408a4a2ae747@intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: <4f28fe6e-a8ce-e444-51db-d0eb564eca8f@linux.intel.com> Date: Wed, 4 Aug 2021 15:26:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <9c576f24-e6de-f816-623d-408a4a2ae747@intel.com> 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 8/4/21 3:03 PM, Dave Hansen wrote: >>> +#include >>> +#include >>> + >>> #ifndef __ASSEMBLY__ >>> >>> static inline bool prot_guest_has(unsigned int attr) >>> { >>> if (sme_me_mask) >>> return amd_prot_guest_has(attr); >>> + else if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) >> Why not "boot_cpu_has(X86_FEATURE_TDX_GUEST)"? > Even better: cpu_feature_enabled(X86_FEATURE_TDX_GUEST). That gets you > both static patching*and* compile-time optimization if you hook > X86_FEATURE_TDX_GUEST into disabled-features.h. This is how Borislav preferred it. tdx_prot_guest_has() internally uses cpu_feature_enabled(X86_FEATURE_TDX_GUEST) to return the status. I think the intention is to keep the first call generic (non TDX specific). So that it can be extended for other use cases. -- Sathyanarayanan Kuppuswamy Linux Kernel Developer