Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp504621iob; Wed, 4 May 2022 01:25:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmTouEPtXcTwvoe/gpytaVlcSz42bBX0e/6LLS1ST5/RoOmZRYGvZ1USc4ANoEaYtMRGsu X-Received: by 2002:a17:902:e5c7:b0:15e:9bba:d4dc with SMTP id u7-20020a170902e5c700b0015e9bbad4dcmr16095425plf.95.1651652708312; Wed, 04 May 2022 01:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651652708; cv=none; d=google.com; s=arc-20160816; b=Pn5/OmrXLJnH4EN8EtJpk59griSy/VWcgK/otWpYO2F3gX8o+bE1xubPHoLe6xu9ZJ hRCizyxD06HyTqlCvjRpA8fu3k29PD05I1qhi4pgPkEW62ciUJqWBCN1C7JNZ7mj3Kmo eQgC4N6cwRFS/JaDnf9XmtZdx5MoLCaLqqPQCMrYoCo/MH0tpu1WKvCn98js1k8HgLxH qpAE2dlvbrv/pD2YMGibDkBTX1QG70Jy5TkMQvKCRJ6UmudKsvUOVsEMPKQXxgsQfC0Y 5t3dFzbqIyZKD9rFl8IMU7cX5INrZpOxZiHi+uXQ+EPVMtRGfJ/CUtND7mM8bXbjq+Kg 7KIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CYDVlBff3W8X34dtlH9cy+YUp1Ly1jz6slmLBlPY6iY=; b=vaEw0IkAKj/SPAKD56hHIBdY1scn5h9K8PiW/WvX8LZbiXvoRKRjEH2XgRtR2UQm7X RBSPs93a7KBu/00XZtsQFrVqEOci1w5aItI/wJ60kywjG3RBZXfDjr5Z1TN9mti6kxEI mpxKFjRSaNDz+qyzNYtxd0kSNzQp5DTnbjhblU96oZhwJUxCRMkl7flKty+N9HnYmPRY Wj2Bu7lDQRdkc1q5Y7FCDm0cfRe9RKmfiBA/xGDw+xBIJwP6PTzLjZRIQBfOexVaDECp e+9O+9KEyUrjoGA9pUtr9WY7RwAHbkJqQckUy40/RdpYIxu6LRg9M8gyugZgFbSMEgSr ddKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n7yHHnSb; 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 i36-20020a631324000000b003ab1669d40esi19371356pgl.358.2022.05.04.01.24.53; Wed, 04 May 2022 01:25:08 -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=n7yHHnSb; 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 S244672AbiEDA2z (ORCPT + 99 others); Tue, 3 May 2022 20:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244656AbiEDA2v (ORCPT ); Tue, 3 May 2022 20:28:51 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 609EC5F71; Tue, 3 May 2022 17:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651623917; x=1683159917; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ZCzg68E9e6BqBao4oWRrx0n2MdE1MfcFFpx+KA+MVak=; b=n7yHHnSbciamEuX96JvhMtGmN3pbbfxFPoiyeXL4PSkndFhYIuq5F9ce 3bTxW050PVXT7w566JDjwzFcE5eVxh9onga4VVcUQRCaO13N4PHclw4lt xUUBW5GHKggPuUf58+XvWg5zeiIlPaAuLcpce35FDiKJSb43yUh4WLAhB GTpaNUUIDU+iNpq0OFD/+HRaf5XM74PftP36+7m7n3AxOIaF/9f+Ba4R2 UC8ImQSu0uVg5GXLJMFi2Uiq4PuhFmRXJ4EfOd+LO1ZX9C0t1uzNQX1oD vnru3/NkjZmPaH7nrcQE83QXz7V5FzPItMwcBzwBytS9uvsDvFhdKg3FE A==; X-IronPort-AV: E=McAfee;i="6400,9594,10336"; a="328169916" X-IronPort-AV: E=Sophos;i="5.91,196,1647327600"; d="scan'208";a="328169916" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 May 2022 17:25:16 -0700 X-IronPort-AV: E=Sophos;i="5.91,196,1647327600"; d="scan'208";a="664215706" Received: from dbandax-mobl2.amr.corp.intel.com (HELO [10.209.188.251]) ([10.209.188.251]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 May 2022 17:25:15 -0700 Message-ID: <1b681365-ef98-ec78-96dc-04e28316cf0e@intel.com> Date: Tue, 3 May 2022 17:25:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 00/21] TDX host kernel support Content-Language: en-US To: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.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 References: <522e37eb-68fc-35db-44d5-479d0088e43f@intel.com> <9b388f54f13b34fe684ef77603fc878952e48f87.camel@intel.com> <664f8adeb56ba61774f3c845041f016c54e0f96e.camel@intel.com> From: Dave Hansen In-Reply-To: <664f8adeb56ba61774f3c845041f016c54e0f96e.camel@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,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 5/3/22 16:59, Kai Huang wrote: > Should be: > > // prevent racing with TDX module initialization */ > tdx_init_disable(); > > if (tdx_module_initialized()) { > if (new_memory_resource in TDMRs) > // allow memory hot-add > else > // reject memory hot-add > } else if (new_memory_resource in CMR) { > // add new memory to TDX memory so it can be > // included into TDMRs > > // allow memory hot-add > } > else > // reject memory hot-add > > tdx_module_enable(); > > And when platform doesn't TDX, always allow memory hot-add. I don't think it even needs to be *that* complicated. It could just be winner take all: if TDX is initialized first, don't allow memory hotplug. If memory hotplug happens first, don't allow TDX to be initialized. That's fine at least for a minimal patch set. What you have up above is probably where you want to go eventually, but it means doing things like augmenting the e820 since it's the single source of truth for creating the TMDRs right now.