Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp927959imi; Fri, 22 Jul 2022 12:47:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u8rRrAM/JI9U4gx6xVv7TVx+rHhqqmz0CkgUkB1UVTRGBh2QFHrVKYXKbDoOhLx+vkOUix X-Received: by 2002:aa7:9519:0:b0:528:c2e0:b7ae with SMTP id b25-20020aa79519000000b00528c2e0b7aemr1510972pfp.39.1658519269783; Fri, 22 Jul 2022 12:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658519269; cv=none; d=google.com; s=arc-20160816; b=K/4orcRYwbt83F7tkGiNRGUkz5kIC6udq8SH8oghTe9xCfy3GnUGyv4I9GUp48kPLo H5gGB1oD/0/OhXMqjkaOu8G0wloJsW+gETdRcCD0b6Uft4jGMX8QZXm6JWMN25UUa/8t X40kAyyca501+NXL6qT6gZA4T7FqMlsYrFSDZlBG6ow2IZlGnPilOB4Qr3OB0iG1Zoid fYOsCqOW4Ogjq4+5fHvADuslTuo7RpyNSnonifAzGdTIQ2+QgvJvQ2jvybhKfYdhiKd+ kqewN1dxZi2cvLoXEJe2ZHzO06ubmkLlprF0S4KY74qa5qpKDqPos0FDc/s0DRpVzbAR Ox5Q== 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=S7Nu4/eHKss0+qmBB7cZDNC3Q4DWm75cDoGs5TXikHo=; b=Gaf9BbLWtdVaxJu2s9wAVW+PTiK2w/hOm3kqCAQYr0wFluOjz8FT09DtMYCgu9ZCtx PNzCpKVQpioGCBKdty+whuQ+3nrHuCyzdt01BLu70AwmPM8XVbNBAhfekNI+Ti0enZ/y CnnUm/E1fd9UyMGYRa0srtvZTwVSAKUZ7yLX7o8I5caPDc4OHX61yyhX/8Iqsu7gOL5A 3phsnIq3NA/L7Tl4GoRHwIe6aaee20wAFMdroNyVQCHOKuhhiomaFFGjdJWJCRvPnjOo pzn2jDn0XWed4n6vVe3SoY2HHTE/QqwG4R9NJ9PhXSKyJmdTdTyNW4R+YCpiMPplsvAQ S7fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="LIx6g/LX"; 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=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a63b648000000b0040014afa1efsi6934595pgt.337.2022.07.22.12.47.34; Fri, 22 Jul 2022 12:47:49 -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=@alien8.de header.s=dkim header.b="LIx6g/LX"; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236061AbiGVTTB (ORCPT + 99 others); Fri, 22 Jul 2022 15:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbiGVTS4 (ORCPT ); Fri, 22 Jul 2022 15:18:56 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9983A5925F; Fri, 22 Jul 2022 12:18:53 -0700 (PDT) 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: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 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