Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6408061iog; Thu, 23 Jun 2022 19:11:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uGb+btSZ9zm9z2iLaT9fK77zPce71ryKpEkHvlBeM1mD96qd/St+nfHhFGP/2s4iFpWf31 X-Received: by 2002:a17:902:bf49:b0:16a:87a:349e with SMTP id u9-20020a170902bf4900b0016a087a349emr34242328pls.86.1656036696509; Thu, 23 Jun 2022 19:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656036696; cv=none; d=google.com; s=arc-20160816; b=vSAUwDcwvsyZ6h9Ewfok9McNr6wlzpHEXzG4NQLFOfy9VSM3aLU6HTddMrEk8mkxdB 8WDuFcLfOu18Xl21J9s8etOTAprA1VlsSsCgPFBVIRxpHm5s0gvu5ttxVhmuZ/OP5go9 oM0yAgHa8hqhwAvacuGnSbs06idLGCFWuclqtC/rCZbYl4b+sdW4Xs91Gt9WMQpfxxfl 90eIP1sv4y27nwJX/Sl0lIR3uFu015XSO0CzRgORIYbzwklqqKT7YY1j9axrvrrL8jMd rEVtvWZzW0HG9VtRWR5c2NKVVwGuozHUY8uVrkGOZg3FhRVUaZA3EFxUJHrILTSay+ow qKQA== 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=Tdzvp0F9gW+/E5TeUvKM7PSw6aQKBHgLmrqQ9E3TiFU=; b=WXMeBQmyGfx4xE20Br09w2mI/8LPUdt5Oe9uRMfWB6FJLhMVyGOBtZNgrV3uOfAV1T Ivi6298lAe9+2TC1MuYrEWjM2n7GM340yZVDg8eIQ653xdMQ2si7L37bttxV+l23fQEH 5a+FOzjYTRk6X7jkChSPgxbYQ4FDB0A+R5AQTi7FxdJ86V5TvcWo1lg4ZAuW3/CZHVxH 9x/nKTq/WN3z0hDr27ej4zdediHCLYtPzwFz9J8m51S8I6ntJvTbB0vuszM+3hwcqS5J UZQDTCLOEIL1lUeuz7lTnoRzumsTTuzxZlF3vugKRd2ZJMv3CW9bB3goV453Wd0tZj3v 8q1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eUD9ett6; 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 s15-20020a056a0008cf00b0051899760d88si1310143pfu.9.2022.06.23.19.11.23; Thu, 23 Jun 2022 19:11:36 -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=eUD9ett6; 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 S231231AbiFXBli (ORCPT + 99 others); Thu, 23 Jun 2022 21:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiFXBlh (ORCPT ); Thu, 23 Jun 2022 21:41:37 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B5AD56C17; Thu, 23 Jun 2022 18:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656034896; x=1687570896; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=pHZ6e8v+fa1nH+kBXHgGT2nmDCcLtFBwLhaHNFSRyw0=; b=eUD9ett603m+kcnJ4GtaawknJa9TbQfdHLwgkuJjtf3bmW2Q2BTMa0sc VXAZk06d1aykShqT53ENN4DneIt8AAfrPeAn/fqJgsf39IsabuBqk69eP b4BJWdrc3df7oc9LnSWO0xDjFKrs+k+jDYr2meZWfV5Bq+klIso+fHHSD FDRj38BDXjEioU4ZSRJ83CPnJPHPDoneOc21acLWoXskAwTIq/anjHTiE wSho3b7X0L2A/HVM3tExPdfsfzsw6lDk6Jzbx6AIQGHgUgercaSADvTxg /RY4bcypo8xMrcq3U5MVIJIfpRx/aW+YvA3rChBkH+m1bocqa7oeLNiBA g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="342580074" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="342580074" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 18:41:35 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="645041375" Received: from gao-cwp.sh.intel.com (HELO gao-cwp) ([10.239.159.23]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 18:41:31 -0700 Date: Fri, 24 Jun 2022 09:41:17 +0800 From: Chao Gao To: Kai Huang Cc: 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: <20220624014112.GA15566@gao-cwp> References: <3a1c9807d8c140bdd550cd5736664f86782cca64.1655894131.git.kai.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3a1c9807d8c140bdd550cd5736664f86782cca64.1655894131.git.kai.huang@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 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.