Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29185756rwd; Wed, 5 Jul 2023 08:19:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45t31STbuNJHR/SblNrKKxc9bx/p4cZmW1OZWoZEufFsvTVhhYSIg+MS/iT6X2oq19K9/o X-Received: by 2002:a05:6808:150c:b0:3a1:e17a:b3fb with SMTP id u12-20020a056808150c00b003a1e17ab3fbmr22186125oiw.1.1688570367980; Wed, 05 Jul 2023 08:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688570367; cv=none; d=google.com; s=arc-20160816; b=P47GZZGDng67t+7p9SEbbczeYmtXNSP7eml7rEa+gSLFOuygJMG/1pkDzlGor9zJ7D qyN6RnoLlPmGT+xeIw3g9gyjoAoz7N3jgJA/FCWACo8emMNs1xmfr2faHYOKArCN5KXR abjYWaIZaTlJqu727PR9vbOA5vJo9mTm4nMvtRIys2qsdDB+1Lx9LFSQss93bw6/ttEx 8XovKmPPcUf61yN6NUhrels6UhtD2FnZW7rUth4LjUxFib+B0vdt36Y1ZE062TIRhZsJ EaKjHjiAEH8L/nCHQi049sYzbm6MleTYCz1H4N0m85ZEzgh4IThu1sXt1zE721pVEJTd cmdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K66hg10RS0xPL3sDSP6x+hgXXU7ubwcqX1w5rGjcqkQ=; fh=m68nlDyI3p8CkJdfCOOf76mt+HLOArEEAh2mTpaiS3M=; b=sUey4ImsEkaJmrhz/6BP4w0I4ryKsKZcynQanotjIOxd+ApGSu95tLRjrEIiuEGe6g GotRWOoNeX2nzED5pSKo0lGQnN68cu4HkRZnHEqbQDROsMul2Vz5y685zaz6+HkJEKqL 40EQIRwM0TlAa0R6n2z/r+P1r4HBQtnXrhoDCsnmt6FSxWuWfwyXZsc09vFG8LIIrvgP FcYz71MlWof89+DyJS/g2gRJNKde0kKks87qWzk5U9K5ZtJfNpG0KTH4I5KU1OsHJOQB V5fnZaJn6XVsXnafRetk+TihyLB0zSTMPibuDcWzIguSxLoKce74/oAZdej4732vVNXO OtwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Zh3WsjW1; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a632a0c000000b00557523b8fa1si23858498pgq.880.2023.07.05.08.19.13; Wed, 05 Jul 2023 08:19:27 -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=@infradead.org header.s=desiato.20200630 header.b=Zh3WsjW1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232873AbjGEO62 (ORCPT + 99 others); Wed, 5 Jul 2023 10:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232869AbjGEO6Y (ORCPT ); Wed, 5 Jul 2023 10:58:24 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 982BC1988; Wed, 5 Jul 2023 07:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=K66hg10RS0xPL3sDSP6x+hgXXU7ubwcqX1w5rGjcqkQ=; b=Zh3WsjW1vqCcD+OuqBPmuZIecy PcdciMOT+MVMVIXVmHMPi4CulMbU/oCKAEmlanfajsmL4tOrr5jrRUOYkDWzpuwbttVmRvdQqyrkQ g6WDuev8lr3jltNE5qb/+XsnL0WZ8S4eyEzzPy5dV3tWmtBH3idKZO1H2Jd7PeTVQfa80M+t8bf85 ndJTbXlsu3gj60UERjKdpI3Df/bgmYJqQDBq27r5mWzBjnerUzgYN7pW6DLyOAHzJo4+k5+UEEvj6 3YsiG0Timevwn32rycrD0ZU8ZyitIF0AWWk5bkwZcu1DoembCkV4k4ghbd70J+//Cwq8q+g5JjmWF PcxuOZkQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qH3x2-00CBot-2S; Wed, 05 Jul 2023 14:57:53 +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 188B93001E7; Wed, 5 Jul 2023 16:57:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 025E72025BA45; Wed, 5 Jul 2023 16:57:50 +0200 (CEST) Date: Wed, 5 Jul 2023 16:57:50 +0200 From: Peter Zijlstra To: Dave Hansen Cc: Sean Christopherson , Isaku Yamahata , Kai Huang , "kvm@vger.kernel.org" , Ashok Raj , Tony Luck , "david@redhat.com" , "bagasdotme@gmail.com" , "ak@linux.intel.com" , Rafael J Wysocki , "kirill.shutemov@linux.intel.com" , Reinette Chatre , "pbonzini@redhat.com" , "mingo@redhat.com" , "tglx@linutronix.de" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Isaku Yamahata , "nik.borisov@suse.com" , "hpa@zytor.com" , Sagi Shahar , "imammedo@redhat.com" , "bp@alien8.de" , Chao Gao , Len Brown , "sathyanarayanan.kuppuswamy@linux.intel.com" , Ying Huang , Dan J Williams , "x86@kernel.org" Subject: Re: [PATCH v12 07/22] x86/virt/tdx: Add skeleton to enable TDX on demand Message-ID: <20230705145750.GD4253@hirez.programming.kicks-ass.net> References: <104d324cd68b12e14722ee5d85a660cccccd8892.1687784645.git.kai.huang@intel.com> <20230628131717.GE2438817@hirez.programming.kicks-ass.net> <0c9639db604a0670eeae5343d456e43d06b35d39.camel@intel.com> <20230630092615.GD2533791@hirez.programming.kicks-ass.net> <2659d6eef84f008635ba300f4712501ac88cef2c.camel@intel.com> <20230630183020.GA4253@hirez.programming.kicks-ass.net> <20230630190514.GH3436214@ls.amr.corp.intel.com> <20230704165836.GB462772@hirez.programming.kicks-ass.net> <1a8099e2-da28-6b2a-7b5a-1d6346b7f95d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1a8099e2-da28-6b2a-7b5a-1d6346b7f95d@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, Jul 05, 2023 at 07:34:06AM -0700, Dave Hansen wrote: > On 7/4/23 09:58, Peter Zijlstra wrote: > > If we have concerns about allocating the PAMT array, can't we use CMA > > for this? Allocate the whole thing at boot as CMA such that when not > > used for TDX it can be used for regular things like userspace and > > filecache pages? > > I never thought of CMA as being super reliable. Maybe it's improved > over the years. > > KVM also has a rather nasty habit of pinning pages, like for device > passthrough. I suspect that means that we'll have one of two scenarios: > > 1. CMA works great, but the TDX/CMA area is unusable for KVM because > it's pinning all its pages and they just get moved out of the CMA > area immediately. The CMA area is effectively wasted. > 2. CMA sucks, and users get sporadic TDX failures when they wait a long > time to run a TDX guest after boot. Users just work around the CMA > support by starting up TDX guests at boot or demanding a module > parameter be set. Hacking in CMA support was a waste. > > Am I just too much of a pessimist? Well, if CMA still sucks, then that needs fixing. If CMA works, but we have a circular fail in that KVM needs to long-term pin the PAMT pages but long-term pin is evicted from CMA (the whole point of long-term pin, after all), then surely we can break that cycle somehow, since in this case the purpose of the CMA is being able to grab that memory chunk when we needs it. That is, either way around is just a matter of a little code, no?