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 5FFA9C43334 for ; Fri, 22 Jul 2022 19:19:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84BFA6B0072; Fri, 22 Jul 2022 15:19:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DBBA6B0073; Fri, 22 Jul 2022 15:19:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69C0E6B0074; Fri, 22 Jul 2022 15:19:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5661C6B0072 for ; Fri, 22 Jul 2022 15:19:13 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0CE731A0E33 for ; Fri, 22 Jul 2022 19:19:13 +0000 (UTC) X-FDA: 79715698986.19.4AC3D55 Received: from mail.skyhub.de (unknown [5.9.137.197]) by imf30.hostedemail.com (Postfix) with ESMTP id A43158001F for ; Fri, 22 Jul 2022 19:19:04 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658517550; a=rsa-sha256; cv=none; b=0/QJd7obqYonFg5U9dRrm+U3s1OKMFMprxQUMWqOf49Ufsc/a1cu4xptiM+gOhVzGuHcHS 4D+8aEXuyFnwrQMMlgPoDYxLrDkDnktYwQVdrHp6isyhFbnzkSjnK9gRnUa/icA/wZXJzR vfdRbtHnhlA15JGiAg4k8rjGUaOJ724= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=alien8.de header.s=dkim header.b="LIx6g/LX"; dmarc=temperror reason="SPF/DKIM temp error" header.from=alien8.de (policy=temperror); spf=temperror (imf30.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658517550; 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=S7Nu4/eHKss0+qmBB7cZDNC3Q4DWm75cDoGs5TXikHo=; b=p+AuxSw+/nHj9zJ5vZGJ/B/poNLM9N5ur882AhT6lRnfR3ixWZgj1JhI81ssR0xMv8T/E9 UGMgtPWuzj2pVNY2G+6lUATcYas4g6g8HeHHWAmZU8xhdYz+VpfbILOmTJ2A94Mm49/KSm tapmhL5jLo16jxYjrfCyMglgoVrcxuo= X-Rspamd-Server: rspam12 Authentication-Results: imf30.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=alien8.de header.s=dkim header.b="LIx6g/LX"; dmarc=temperror reason="SPF/DKIM temp error" header.from=alien8.de (policy=temperror); spf=temperror (imf30.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de X-Rspam-User: X-Stat-Signature: 7tdzmjjxkkak3emzou8ibcg3p8root7a X-Rspamd-Queue-Id: A43158001F X-HE-Tag: 1658517544-502198 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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