Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp374929iog; Wed, 29 Jun 2022 01:56:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ucms7PlOyHLSngTtiawHVXPfOVvEiMHvJelZePbcV1lPZg66QNr5/YPzOqAHqAFUcupijg X-Received: by 2002:a05:6a00:1a91:b0:525:b9ea:feac with SMTP id e17-20020a056a001a9100b00525b9eafeacmr8064170pfv.13.1656493013852; Wed, 29 Jun 2022 01:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656493013; cv=none; d=google.com; s=arc-20160816; b=jlG2RJ0n+mheMsQwVFmSttGTsr+UKUomceqjVP1i/OmRZnWsQBc2C87LKjLfmBQLiy pt+Wzf8lfGinRuE/zapdVS2rHww/39QBXx+fEFeYJNRjrDT75h4qb9nS8eFCAJ0W0jMh eYUjpDT26HE12g/riIu7IODbTFH5r1Ln2021k5pXAEwYx6Aj06LXD1wuJc4+hUDla2ay F7SgKMhV1nSm6I7EQmsvLKOLJn1ErfSeVYZDdfD+PwHXkSQ7ML5LGeyltnOcBH3qRtuc QrPTnosOi/2Sn4mcMxf+jof+B4tpJNhB9d0cGoi94msWyuj9Sa1ZAMSzfJFaGkyBlhVo xBzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+4F9/Ye+E/CYHhiDg9SY4TdjLvk5hoyNr+967f7U3v0=; b=jFMPxgWpuIkLWajPZgig+2xlXN9lkO9jjDAGTkZ9wkasQIptWlNmgsinE8tBS59qZA 4ysR/zUTiHNcrtmwQI9vzlvbR8OrXMOmwRJ1VSfcFQU2aO8ceNYmaldxHOu4PNGc/eFI /stWHRdnT3CJ3wKIBl9moIoIxPPqrW3ozhwQQWDN+tRM1vCevrPTWUSUYsmKgZi/Pkd5 OEUYBMosG4spo/zTYwhBJ+pv2bUNTgPAm3TfvD++lfKxq/jqPQiOGaxwcwdYsqBnAsQl DtuZrTXs+OdrXoI3yyBHi70QUDt19JbTd+6HV5F7TEL8SdyzW6+ssPMOReaxmTsZ0WMg qZlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Msn9efjY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a63fe4b000000b0040c9af0b731si18965915pgj.50.2022.06.29.01.56.41; Wed, 29 Jun 2022 01:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Msn9efjY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232318AbiF2Ig0 (ORCPT + 99 others); Wed, 29 Jun 2022 04:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbiF2IgX (ORCPT ); Wed, 29 Jun 2022 04:36:23 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A75463C705; Wed, 29 Jun 2022 01:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656491782; x=1688027782; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/tpHLNK39bZmEplNDXU1bTXTKX1BV6N9O59YCs9I+Jo=; b=Msn9efjYVKFCl0bXyS0Drt5cYr2IINCUZoaBzqhck1oUen2RqQLpcf4f W38Ie6HM6lGwzCYugUMgKjnHXp4kqAXrdKFTyYpz1NvfOTD9hKUvlgcsa LS9o/oYnJax4rd+ws25CuaBMxEqy7RdMwtX/RAgaLFqadJK7fOLAEEoeo QQc0XzeplXOxamhIXVuea/Qxwww4qmMs6prWvg0o7zjBjzrFt7CUVBrdQ z1dyZlqeDmIwA0bGIifluhelFSZx2NSSeWREGAW+KwQ5mtUbAitn27iZ9 rGfbghQ7uNuz/iLJDUr417Oc4k6Df1fcV1+kXl+jjy84Kh/eA7dpcTmyd g==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="282005990" X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="282005990" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 01:36:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="590616731" Received: from yy-desk-7060.sh.intel.com (HELO localhost) ([10.239.159.76]) by orsmga002.jf.intel.com with ESMTP; 29 Jun 2022 01:35:56 -0700 Date: Wed, 29 Jun 2022 16:35:55 +0800 From: Yuan Yao To: Kai Huang Cc: Chao Gao , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, isaku.yamahata@intel.com, thomas.lendacky@amd.com, Tianyu.Lan@microsoft.com Subject: Re: [PATCH v5 04/22] x86/virt/tdx: Prevent ACPI CPU hotplug and ACPI memory hotplug Message-ID: <20220629083555.wre7uab6schvifkg@yy-desk-7060> References: <3a1c9807d8c140bdd550cd5736664f86782cca64.1655894131.git.kai.huang@intel.com> <20220624014112.GA15566@gao-cwp> <951da5eeb4214521635602ce3564246ad49018f5.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <951da5eeb4214521635602ce3564246ad49018f5.camel@intel.com> User-Agent: NeoMutt/20171215 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 24, 2022 at 11:21:59PM +1200, Kai Huang wrote: > On Fri, 2022-06-24 at 09:41 +0800, Chao Gao wrote: > > On Wed, Jun 22, 2022 at 11:16:07PM +1200, Kai Huang wrote: > > > -static bool intel_cc_platform_has(enum cc_attr attr) > > > +#ifdef CONFIG_INTEL_TDX_GUEST > > > +static bool intel_tdx_guest_has(enum cc_attr attr) > > > { > > > switch (attr) { > > > case CC_ATTR_GUEST_UNROLL_STRING_IO: > > > @@ -28,6 +31,33 @@ static bool intel_cc_platform_has(enum cc_attr attr) > > > return false; > > > } > > > } > > > +#endif > > > + > > > +#ifdef CONFIG_INTEL_TDX_HOST > > > +static bool intel_tdx_host_has(enum cc_attr attr) > > > +{ > > > + switch (attr) { > > > + case CC_ATTR_ACPI_CPU_HOTPLUG_DISABLED: > > > + case CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED: > > > + return true; > > > + default: > > > + return false; > > > + } > > > +} > > > +#endif > > > + > > > +static bool intel_cc_platform_has(enum cc_attr attr) > > > +{ > > > +#ifdef CONFIG_INTEL_TDX_GUEST > > > + if (boot_cpu_has(X86_FEATURE_TDX_GUEST)) > > > + return intel_tdx_guest_has(attr); > > > +#endif > > > +#ifdef CONFIG_INTEL_TDX_HOST > > > + if (platform_tdx_enabled()) > > > + return intel_tdx_host_has(attr); > > > +#endif > > > + return false; > > > +} > > > > how about: > > > > static bool intel_cc_platform_has(enum cc_attr attr) > > { > > switch (attr) { > > /* attributes applied to TDX guest only */ > > case CC_ATTR_GUEST_UNROLL_STRING_IO: > > ... > > return boot_cpu_has(X86_FEATURE_TDX_GUEST); > > > > /* attributes applied to TDX host only */ > > case CC_ATTR_ACPI_CPU_HOTPLUG_DISABLED: > > case CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED: > > return platform_tdx_enabled(); > > > > default: > > return false; > > } > > } > > > > so that we can get rid of #ifdef/endif. > > Personally I don't quite like this way. To me having separate function for host > and guest is more clear and more flexible. And I don't think having > #ifdef/endif has any problem. I would like to leave to maintainers. I see below statement, for you reference: "Wherever possible, don't use preprocessor conditionals (#if, #ifdef) in .c" From Documentation/process/coding-style.rst, 21) Conditional Compilation. > > -- > Thanks, > -Kai > >