Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp312893iog; Fri, 24 Jun 2022 04:42:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sq3B8wIWJh7kE19dDxZY1nosRsgsZ7G1VCscTAL+y5P974ibQUIZYvwh58MX2XFWdlRqyw X-Received: by 2002:a05:6402:43cd:b0:435:d76d:f9a7 with SMTP id p13-20020a05640243cd00b00435d76df9a7mr9288502edc.119.1656070922624; Fri, 24 Jun 2022 04:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656070922; cv=none; d=google.com; s=arc-20160816; b=nRFPkVz8Xnto5c6VY+udqcNsmnuM7UmUPh4inHqSKAGJbHoW+bh+oZFYfRh/el1ggK 47HLl9nG2cJZZTzWUMXBtlKeXCoAGUgg6JlvEABkkucI+1RF/rDfOyVi2M7I8HJOYADb stVH8OPzholRAWLxqTXslw1jUFgkPoI1xnyLcUoeYU8VvM3jleJwArrN2wOy6fo9JxIj rdLet86t6Xo5o3KCLjAg06A8128wYcZ4YK79Zva5R5nI7aQnRWjoFWnbJFfxibAmyeX6 qE6mYImk++3UFj9qjIpdozphpcBHNmlA47RyUXSS+m7UdeD2m4b5JiGA2esb9prQpAQ1 Pp0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=LRpwuBNZIIGQ3mW9b7ZiJcvyU5iccsQNL+ADaLEZ2yQ=; b=MPY5qMi4svjvryAfuxC+124WaG51tSuWN8O3A9ChwQO/ZsdW63y3l2R1TtJFbbbnpG DLHoVZVkZi8WCjKRDDlhruvvKhryBpu7wcd74lwe5TljA5y0nFwkr+SSsMs5ON7OgSHn eSORv4CQFz5O437+FFWPVcMOoV4+D/32FfyMPemrZmcnRFTj7/3j4Df4elCIX+WS3ycZ gEW+nPLE4vhBbU1ZDPdI+svXZjsWgIjFwy2RC5iog8ZdeGaGQe76IzoYkn8kBSW4x/iX Ctb0rla05jQpk35r0hKYYN1AlGLS+RNOeiLdMkWWlXKlDl2zLem2AetYytIpJ+NtsqdU sczw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jqd9q9VF; 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 g13-20020a50ee0d000000b0042bdb036342si2532315eds.398.2022.06.24.04.41.37; Fri, 24 Jun 2022 04:42:02 -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=Jqd9q9VF; 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 S231265AbiFXLX0 (ORCPT + 99 others); Fri, 24 Jun 2022 07:23:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbiFXLXX (ORCPT ); Fri, 24 Jun 2022 07:23:23 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F79220C3; Fri, 24 Jun 2022 04:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656069799; x=1687605799; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=xgjsDnXlP1t2rfiijqMLMBJUg2+1poD5XRUpahbyPQg=; b=Jqd9q9VFUcoYY6jbavLgMCdoec9vsTV9KX1a/LSVv31u/7/YWRIaaguK yz9n9KEh38VC1Jy4y1pYgn2+jhx0rj9Fb1b+84R2QSC/9I5hMBod40Onq eWNCCL6PyRo01vByjWb/PTaW9/msOl3A1284DDTdqpGo36JJ5um77AFkA N56rmK+koN/KfMAnowkEiUghMn4fl5gBoEXTJbh4jAE95Jx3NkIsPgKMM C2lS4Sp0jtMvD4aSnR+4wOZe0vD6WFqS042Vi2cG1eO/J2aa5Yy4WC0JY jzEQcKGHaPYIFvyO4uQ3NbpWPtrSqFHuIh8Qyk5vwLFKhANGFQUDS+uds A==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="264020161" X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="264020161" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 04:23:18 -0700 X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="915645909" Received: from jvrobert-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.212.99.67]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 04:23:15 -0700 Message-ID: <97945fb19901f6ec11c72b015f55f6bb42cbc7c1.camel@intel.com> Subject: Re: [PATCH v5 05/22] x86/virt/tdx: Prevent hot-add driver managed memory From: Kai Huang To: Chao Gao Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.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, akpm@linux-foundation.org Date: Fri, 24 Jun 2022 23:23:13 +1200 In-Reply-To: <20220624021200.GB15566@gao-cwp> References: <173e1f9b2348f29e5f7d939855b8dd98625bcb35.1655894131.git.kai.huang@intel.com> <20220624021200.GB15566@gao-cwp> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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, 2022-06-24 at 10:12 +0800, Chao Gao wrote: > On Wed, Jun 22, 2022 at 11:16:19PM +1200, Kai Huang wrote: > > @@ -55,6 +55,7 @@ > > #include > > #include > > #include > > +#include > >=20 > > #include "mm_internal.h" > >=20 > > @@ -972,6 +973,26 @@ int arch_add_memory(int nid, u64 start, u64 size, > > return add_pages(nid, start_pfn, nr_pages, params); > > } > >=20 > > +int arch_memory_add_precheck(int nid, u64 start, u64 size, mhp_t mhp_f= lags) > > +{ > > + if (!platform_tdx_enabled()) > > + return 0; >=20 > add a new cc attribute (if existing ones don't fit) for TDX host platform= and > check the attribute here. So that the code here can be reused by other cc > platforms if they have the same requirement. Please see my explanation in the commit message: The __weak arch-specific hook is used instead of a new CC_ATTR similar to disable software CPU hotplug. It is because some driver managed memory resources may actually be TDX-capable (such as legacy PMEM, which is underneath indeed RAM), and the arch-specific hook can be further enhanced to allow those when needed. --=20 Thanks, -Kai