From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 669686AD4 for ; Fri, 22 Jul 2022 19:18:54 +0000 (UTC) Received: from zn.tnic (p200300ea97297665329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9729:7665:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 2AC521EC0657; Fri, 22 Jul 2022 21:18:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1658517528; h=from:from: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; bh=S7Nu4/eHKss0+qmBB7cZDNC3Q4DWm75cDoGs5TXikHo=; b=LIx6g/LXOmTk6uDJhPVmnoqKJ4EyZUKtMASYEeKCWrJykfa0uvj2XCpcPqEFKveUw1OzcC jVAmUcMNmbHoXPYgcGrCxhHJjA8xsZN1P/OyU403HZxaEvzq24nYzbK8bDBP+UCbWNjFE+ qFKSWzhGfIcthc/2fyBXoBfWXC1k5XQ= Date: Fri, 22 Jul 2022 21:18:44 +0200 From: Borislav Petkov To: Dave Hansen Cc: "Kirill A. Shutemov" , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: Re: [PATCHv7 02/14] mm: Add support for unaccepted memory Message-ID: References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-3-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Thu, Jul 21, 2022 at 08:49:31AM -0700, Dave Hansen wrote: > Acceptance is slow and the heavy lifting is done inside the TDX module. > It involves flushing old aliases out of the caches and initializing the > memory integrity metadata for every cacheline. This implementation does > acceptance in 2MB chunks while holding a global lock. Oh, fun. > So, those (effective) 2MB clflush+memset's (plus a few thousand cycles > for the hypercall/tdcall transitions) So this sounds strange - page validation on AMD - judging by the pseudocode of the PVALIDATE insn - does a bunch of sanity checks on the gVA of the page and then installs it into the RMP and also "PVALIDATE performs the same segmentation and paging checks as a 1-byte read. PVALIDATE does not invalidate TLB caches." But that still sounds a lot less work than what the TDX module needs to do... > can't happen in parallel. They are serialized and must wait on each > other. Ofc, the Intel version of the RMP table needs to be protected. :-) > If you have a few hundred CPUs all trying to allocate memory (say, > doing the first kernel compile after a reboot), this is going to be > very, very painful for a while. > > That said, I think this is the right place to _start_. There is going > to need to be some kind of follow-on solution (likely background > acceptance of some kind). But, even with that solution, *this* code > is still needed to handle the degenerate case where the background > accepter can't keep up with foreground memory needs. I'm still catering to the view that it should be a two-tier thing: you validate during boot a certain amount - say 4G - a size for which the boot delay is acceptable and you do the rest on-demand along with a background accepter. That should give you the best of both worlds... Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette