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=-6.7 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 DD403C4338F for ; Fri, 20 Aug 2021 16:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B359C61057 for ; Fri, 20 Aug 2021 16:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbhHTQni (ORCPT ); Fri, 20 Aug 2021 12:43:38 -0400 Received: from mga02.intel.com ([134.134.136.20]:5650 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbhHTQnh (ORCPT ); Fri, 20 Aug 2021 12:43:37 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10082"; a="204001447" X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="204001447" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 09:42:59 -0700 X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="506519677" Received: from jmorauga-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.209.135.55]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 09:42:58 -0700 Subject: Re: [PATCH v5 04/12] x86/tdx: Add protected guest support for TDX guest To: Borislav Petkov Cc: Sean Christopherson , Dave Hansen , Thomas Gleixner , Ingo Molnar , 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> <4f28fe6e-a8ce-e444-51db-d0eb564eca8f@linux.intel.com> <486afc0e-0396-e57b-63fe-31a8433bd603@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: Date: Fri, 20 Aug 2021 09:42:55 -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: 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/20/21 7:28 AM, Borislav Petkov wrote: > On Thu, Aug 12, 2021 at 10:18:39AM -0700, Kuppuswamy, Sathyanarayanan wrote: >> I can implement intel_prot_guest_has() in arch/x86/kernel/cpu/intel.c. >> And call tdx_prot_guest_has() from it. > > No, you should simply implement intel_prot_guest_has() or whatever we > end up calling it and have the generic routine call it. Not two routines > - tdx_* and intel_* > Reason for suggesting seperate function for tdx_* specific protected guest check is, we will be adding some exceptions for TDX features (like command line option used to override the default flags or when device filter support is disabled). Our current final version looks like below. Such customization are not good in generic intel_* function right? bool tdx_prot_guest_has(unsigned long flag) { bool tdx_guest_enabled = cpu_feature_enabled(X86_FEATURE_TDX_GUEST); if (flag == tdg_disable_prot) return false; switch (flag) { case PATTR_GUEST_TDX: case PATTR_GUEST_UNROLL_STRING_IO: case PATTR_GUEST_MEM_ENCRYPT: case PATTR_GUEST_SHARED_MAPPING_INIT: case PATTR_MEM_ENCRYPT: case PATTR_GUEST_SECURE_TIME: case PATTR_GUEST_CPUID_FILTER: case PATTR_GUEST_RAND_LOOP: return tdx_guest_enabled; case PATTR_GUEST_DRIVER_FILTER: return tdg_filter_enabled() && tdx_guest_enabled; } return false; } -- Sathyanarayanan Kuppuswamy Linux Kernel Developer