Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6420968iog; Thu, 23 Jun 2022 19:36:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ufqwBrAFaFDqLwi/ocPvaWpXGFexRgZDbhEnevVBi+qxWsyqtnLtl7L+ZScU7k5exAq89h X-Received: by 2002:a05:6a00:1acc:b0:525:345d:cdcf with SMTP id f12-20020a056a001acc00b00525345dcdcfmr18240832pfv.76.1656038189122; Thu, 23 Jun 2022 19:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656038189; cv=none; d=google.com; s=arc-20160816; b=ByDc7KyC5bEegeAI133+of0eLhRprpwhp0hDw2/9+gW+m+7LojHKDSN/yOZ2XMuGow jfB2Wfcfb2P7XJ+/81zbheYCLM3RFapoyv9gDuu6gSvoPk4Ki6PYKQiZbYIHA0YYA14q ZUpJfAezAzcKF0onrPbxBeG/Oer4gf8rBu10SeH/L59lYO7Afd2YjM7WKe0/MrGQgWUc 8bzBjXOL36QqVHSYKRE3rQfdlA2OPDMGOR63ll5zAwuuhVQ4CqOmTIcCAWKvbKXIn9VX Uu4hgF2mMyiX9TOHqjzexj+jsFfTnGoPVpF6l+I2UgaIeSWzJED4xwQnRaV6arbfr2L/ y/zA== 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=JpimjPUBYU3+5+9w8FuyspLtVH7Wgzu+Q3LZOHs8Kfo=; b=kMK5m0kHEaprhWb+T4S0E2l28I8Hzwy5N9ryOLjSFUhv7rnFWtdpNPlymAj3UGUd/6 lI0bAqaCw0poBnL4fUOWS6gJqmwuPMCYiBDxM7joPhLlPh8hOrdAQGmGi0HbJhJ322ys 4RSfMHaDE1qaaWGPixWOnMv+7fRXdrpVuRAsx2psc7DBf2M7iLq6/7YYxrIE1gANuNaM W4cOFQnb9vlSLX9MhSD9ZhqO8HQhM98dn/kLDH6e3GJ3/p1+uJ7cYXFutBw4+5qpJaUA RNezzAFE1YkCt+zaqKC32ZYpTwjcb488aadc3wIqL4Ps1cOBaqbunQesGLxkkuH4eqEK a3ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e1qwFutL; 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 w5-20020a056a0014c500b0051873a68dd2si1232995pfu.252.2022.06.23.19.36.13; Thu, 23 Jun 2022 19:36:29 -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=e1qwFutL; 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 S230512AbiFXCM0 (ORCPT + 99 others); Thu, 23 Jun 2022 22:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbiFXCMY (ORCPT ); Thu, 23 Jun 2022 22:12:24 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E6250B14; Thu, 23 Jun 2022 19:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656036744; x=1687572744; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/ZHx+jG00ZO8ZCYzEWOrH0StMRMC4BjW65hod6Xx3uk=; b=e1qwFutLUE4pDSWo1WFxd7nndMy3znsTF60cOXA+qfMKVNxv9cem2k4R cIju9k/sy4wQt0zwHDAh0bG4ifIsfwvdDqwj4Jf/7xPjPmkHEVGj2wlwk TvudVzYC0aVth+JKEO0iKU9/EYbmYhXkRo8OT0kRKiFEzfSGGcztnN0kH JPIKDxvYRAid1rINHW59TxDmpYE8liEH4aMwiF48A29trqS9YiTvgTb4o YRrIMsbpPaHYOhtf+FQOcueKai/xstfmsANEyn8ry43ChcQsNT+9EnZDG VIM1lVl+HuIhilj29jkdm8SXSPrC0qIol1cLkma2JVxcjygjj6a1yOVrO Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="263934549" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="263934549" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:12:24 -0700 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="645051512" 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 19:12:20 -0700 Date: Fri, 24 Jun 2022 10:12:05 +0800 From: Chao Gao To: Kai Huang 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 Subject: Re: [PATCH v5 05/22] x86/virt/tdx: Prevent hot-add driver managed memory Message-ID: <20220624021200.GB15566@gao-cwp> References: <173e1f9b2348f29e5f7d939855b8dd98625bcb35.1655894131.git.kai.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <173e1f9b2348f29e5f7d939855b8dd98625bcb35.1655894131.git.kai.huang@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) 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 Wed, Jun 22, 2022 at 11:16:19PM +1200, Kai Huang wrote: >@@ -55,6 +55,7 @@ > #include > #include > #include >+#include > > #include "mm_internal.h" > >@@ -972,6 +973,26 @@ int arch_add_memory(int nid, u64 start, u64 size, > return add_pages(nid, start_pfn, nr_pages, params); > } > >+int arch_memory_add_precheck(int nid, u64 start, u64 size, mhp_t mhp_flags) >+{ >+ if (!platform_tdx_enabled()) >+ return 0; 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.