From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94C93C4332F for ; Thu, 24 Nov 2022 09:26:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E7F76B0071; Thu, 24 Nov 2022 04:26:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 097636B0072; Thu, 24 Nov 2022 04:26:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA1596B0074; Thu, 24 Nov 2022 04:26:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DB3536B0071 for ; Thu, 24 Nov 2022 04:26:28 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A1A871413AA for ; Thu, 24 Nov 2022 09:26:28 +0000 (UTC) X-FDA: 80167805256.30.9F5AF36 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 2CFC580008 for ; Thu, 24 Nov 2022 09:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SQZFDjndEHG3J/gZQ4hoB38UGRP7fGtXudSzN0rEezs=; b=wJdaVrg+LdaOfZl/BWnSKP3ydA UfFD3UMOwMOgDqdguC3qJaLTJxU5N2Wyfpn567fFuQ7IoSIa5+t+uYlm/sIcNKNpCLizneI9lP750 ak4fAmyZLock5gyuzPhODX+p0Y8q5oFRybW8iiE1/94zoJy9QjMdZytVdt436o+bzsdWBQ5y+cVZ9 PmRLPFtDpzsV5nmiZTzAvDq7qvRVYrIw3adfPR53tfJCZLHpAbXm2I/owg8xXLUBXv3tF5sJ3xcG1 2xZb6yfC43G1/A1W6PO5dvFQSD9tXgT+JGLhrElM6ZlbSNNjqnESyP++iVxDOovGWy6HqtqSQaR+d 6grxBkFA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oy8V2-008ZN0-Ps; Thu, 24 Nov 2022 09:26:28 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 04B6F300202; Thu, 24 Nov 2022 10:26:21 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id DD8E9203CF645; Thu, 24 Nov 2022 10:26:20 +0100 (CET) Date: Thu, 24 Nov 2022 10:26:20 +0100 From: Peter Zijlstra To: Dan Williams Cc: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, rafael.j.wysocki@intel.com, kirill.shutemov@linux.intel.com, ying.huang@intel.com, reinette.chatre@intel.com, len.brown@intel.com, tony.luck@intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com Subject: Re: [PATCH v7 10/20] x86/virt/tdx: Use all system memory when initializing TDX module as TDX memory Message-ID: References: <9b545148275b14a8c7edef1157f8ec44dc8116ee.1668988357.git.kai.huang@intel.com> <637ecded7b0f9_160eb329418@dwillia2-xfh.jf.intel.com.notmuch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <637ecded7b0f9_160eb329418@dwillia2-xfh.jf.intel.com.notmuch> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669281987; a=rsa-sha256; cv=none; b=FWgutdk9Pw9UbFlbDTnSLGWbiVxP61mIYnkFQvgiDrA6q5d7YggDmI1KU37gLQEPOXmMw8 QBsTFzO+4+MfEfUAMAE9wUBqu9fFZZbZXFrE+dKRy6hHzAcBtMSPZQ3JaPHOOAfJFYkyTU op0dI7Mkv4FEmZub86oKlC6SpFbXZ6w= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=wJdaVrg+; dmarc=none; spf=none (imf30.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669281987; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SQZFDjndEHG3J/gZQ4hoB38UGRP7fGtXudSzN0rEezs=; b=i3txdtRMPP805plNXP4YuxScyMNNxCO/KUT64g0AkkM/DmJAHngJIuRIOLJWKNo3jFECny 2SYbAXKGkVcfzxjRuvmQejUljEfKfA9el0K3vjFxYWXAx6ryHjTydSWgl7oSAH5aChPHQZ f+M2CZZOcZN6xPx2oGrQYazha8Es0G0= X-Stat-Signature: zbg9hw3fci5wbzobp8dnao7kan9g4j9j X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2CFC580008 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=wJdaVrg+; dmarc=none; spf=none (imf30.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org X-Rspam-User: X-HE-Tag: 1669281986-88702 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000278, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 23, 2022 at 05:50:37PM -0800, Dan Williams wrote: > arch_add_memory() does not add memory to the page allocator. For > example, memremap_pages() uses arch_add_memory() and explicitly does not > release the memory to the page allocator. This check belongs in > add_memory_resource() to prevent new memory that violates TDX from being > onlined. Hopefully there is also an option to disable TDX from the > kernel boot command line to recover memory-hotplug without needing to > boot into the BIOS to toggle TDX. So I've been pushing for all this to either require: tdx=force on the cmdline to boot-time enable, or delay all the memory allocation to the first KVM/TDX instance being created. That is, by default, none of this crud should ever trigger and consume memory if you're not using TDX (most of us really). (every machine I have loads kvm.ko unconditionally -- even if I never user KVM, so kvm.ko load time is not a valid point in time to do TDX enablement).