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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ACD8C07E95 for ; Tue, 20 Jul 2021 08:44:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CCCDD60FE9 for ; Tue, 20 Jul 2021 08:44:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCCDD60FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 67B1C8D0002; Tue, 20 Jul 2021 04:44:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62CE18D0001; Tue, 20 Jul 2021 04:44:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A4738D0002; Tue, 20 Jul 2021 04:44:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 272A68D0001 for ; Tue, 20 Jul 2021 04:44:31 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 95B148248047 for ; Tue, 20 Jul 2021 08:44:29 +0000 (UTC) X-FDA: 78382329858.30.6BEF8AA Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf04.hostedemail.com (Postfix) with ESMTP id 0C06050000A2 for ; Tue, 20 Jul 2021 08:44:28 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 51A491FDDB; Tue, 20 Jul 2021 08:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626770667; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/G5U5Sb4o8EhDLHWJkUeTkmM/VUVhqDbp2YFTroPI8=; b=GSby3uLc2ePOTrDe7jA//saLrtUzZj1ltjbOX+7tezEGlF3UWXShY6xIXIwRlCw2bJr8Bu HI98h3KEJT2/tWil/qp4/Spju5BdmxtxcE7p3ABr03CEd9rZDlJl2V0mMpRqtXxj9Q4ItA azFs7aqt0Ij9bGwMGFV/nIlgB0Ii+yQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626770667; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E/G5U5Sb4o8EhDLHWJkUeTkmM/VUVhqDbp2YFTroPI8=; b=wPN0PJdsWQrwKQ4Yvymw7Fj9x+mPScluyjmma3r9eckBxMpiF8lJiGg+MXTTX/vPQzMW0+ zlt/zMNERzwPUuCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9A93D13D66; Tue, 20 Jul 2021 08:44:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id u98FJOqM9mA/GQAAMHmgww (envelope-from ); Tue, 20 Jul 2021 08:44:26 +0000 Date: Tue, 20 Jul 2021 10:44:24 +0200 From: Joerg Roedel To: Andy Lutomirski Cc: David Rientjes , Borislav Petkov , Sean Christopherson , Andrew Morton , Vlastimil Babka , "Kirill A. Shutemov" , Andi Kleen , Brijesh Singh , Tom Lendacky , Jon Grimm , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , "Kaplan, David" , Varad Gautam , Dario Faggioli , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev Subject: Re: Runtime Memory Validation in Intel-TDX and AMD-SNP Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GSby3uLc; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wPN0PJds; spf=pass (imf04.hostedemail.com: domain of jroedel@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=jroedel@suse.de; dmarc=none X-Rspamd-Server: rspam05 X-Stat-Signature: mjbr9jwgzeek8ii7995dj86qnkcpnqmk X-Rspamd-Queue-Id: 0C06050000A2 X-HE-Tag: 1626770668-981476 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 Mon, Jul 19, 2021 at 05:26:20PM -0700, Andy Lutomirski wrote: > At the risk of asking a potentially silly question, would it be > reasonable to treat non-validated memory as not-present for kernel > purposes and hot-add it in a thread as it gets validated? Or would this > result in poor system behavior before enough memory is validated? > Perhaps we should block instead of failing allocations if we want more > memory than is currently validated? That is basically the idea of pre-validating the first X GB of memory (X==4 has been proposed) and validate the rest at runtime. I see two problems with this: 1) Pre-validating large amounts of memory takes a lot of time (in the range of a few seconds). This is not suitable for all workloads like, e.g., containers which want to boot in a few hundred milliseconds. 2) It limits the physical address range for KASLR placement, factually reducing the randomness of where the kernel is placed in physical memory. With the proposal I sent here only enough memory for the boot-loader and the kernel image is pre-validated, and when the decompressor takes over it can place the kernel anywhere, even in yet unvalidated/unaccepted memory. Regards, Joerg