Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3795623rwb; Tue, 16 Aug 2022 08:54:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4mLEFjcybwWR8HPZ5u2qGsZf3bscJIXG1CCzkW+iGAmehunRxzwsQEvzeDZvOK+g6DODtG X-Received: by 2002:a17:907:7283:b0:731:60a5:5fc9 with SMTP id dt3-20020a170907728300b0073160a55fc9mr13941664ejc.51.1660665273793; Tue, 16 Aug 2022 08:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660665273; cv=none; d=google.com; s=arc-20160816; b=dZJQBafeSfp3IcQlNUhi5IeMrppI/IgQ58Hg1DePZVXuRYbqvczC90caUdn+cbBXB0 mFosI/sKdtyIyr809ZZ6D6c39DOhkwxqkBZECcOeot9mq2Mkgcb4IqL7iryeJOseUdhf iSqF/B3RhkBZ4bU1EaC1wtauZmgxVOWXysQT35sGpIVF7nhj7NquWvvL4d7/uu0EzIAH vy03dTJXwA+RlQsSGoxNy9R2fIn522pfRFnGO0sp88CuTzcuw+76VxX5Ae/yfMHUzKQn AzaLZb4qQsydwinLYAR00yR4umelIWdI+AUhwXGRQTXa7Y5A/u35Dj8Wo9hMrzvoTj3H mJ8A== 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=6LpLI14G6coqJFruGZ3VYJdlLWVZL7InToOUXv07gLQ=; b=QdVxKLcaobTaVsfqe51J8Y0OooWfEdAqm+F5vefeKJfiuIfso5YOFYj7xtmWQLjRwm C56+5BeR6J8aOGaNjOoyfj6cKa3MWO/8dsSHXZ2M+49JxyCcEYZKtX1uvTASl9rvPeqK Efw0RHUOWVCKN4d+eujqNBwLf7jDFbfX5kO6WR20LMqP4VH4SXIK+bvkjN3nvsZ2chcV iceaCkWNs54LLMgo2KS+OBS1pIWZeXXiBTIsAf8JWYE+3pskRpv5viH+VQy2UxQMfk7W YlS8EOM8UmNaZN4JG18P/lV378qizOpf1phta2I0WvApiSaKybj47x/sZttlU6GXVuOl uAFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=V3kYfawN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs9-20020a170906dc8900b00730c36d50b3si11590446ejc.355.2022.08.16.08.54.06; Tue, 16 Aug 2022 08:54:33 -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=@google.com header.s=20210112 header.b=V3kYfawN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236324AbiHPPj3 (ORCPT + 99 others); Tue, 16 Aug 2022 11:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236193AbiHPPi0 (ORCPT ); Tue, 16 Aug 2022 11:38:26 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1635C33A00 for ; Tue, 16 Aug 2022 08:38:13 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id 130so9633241pfv.13 for ; Tue, 16 Aug 2022 08:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=6LpLI14G6coqJFruGZ3VYJdlLWVZL7InToOUXv07gLQ=; b=V3kYfawNPteaJkUnHbTXnRrS5N35HXy6iGSEoRvrRPR7lf/QPGG3xDy01PDbV3CNJU rYN3Q+NG+MI7miMCPrKRr9QMWbJNUvipQt7nZBzy91mXjgUP1bhKDg6Pv8PLccjK328e QHgPWN2TVwVDgsm0DNCSKHVDZJyXPC0S2jmlNvJNeN/YEUOYVYC0ArRAq7x4AOWHAAvX U8kkfqX2SlO0Wx9GoH6WDXhHME6I42+EOUK5vgZdNMDY/qSlMxKyT1KEekpwoGvFgNHf kgo444qsZ2z0tgTbJp5duXgBZVSHUHP1vb6nzpsrWEMHaATSgyPonGA239evs+ZXtTji kdPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=6LpLI14G6coqJFruGZ3VYJdlLWVZL7InToOUXv07gLQ=; b=FSEHeq3cHbIFlMsPPFnTuFBH9EymfB/e2HeUBflievsZ4g8AoI4Gts2PG1wH+W5fwU NuJmuIYMlpGrpY4cTX9W/cA1oNNqtg94cFLHs8o8GC5v0tk1Z9YStwIELhvHa//2GxUe W1pfXZzUU9Mgr7Ftv1/+DNnRLwuNoVfBOwMxR2aoaTAaalMvU4BaN3S/NKCQ4acU4JvJ wZWcqeOHZfV8+1icjh6VNr1MLUqC9qRmywlk/xkhs0H5pujZJmKBVKKclvVIs3zJcR27 dhNo05jjNBR5CAJbeST4fS7RI046Tte/BIIGOqJnLRnUZWqrPYkEDEu2CnL3XyCa7eEb H/uA== X-Gm-Message-State: ACgBeo2gHJXNfliQanWOmaUzl4SmPzygu7V9jdSfpnYuZ6nMDBGrfhlt THU8OE7FKNlMQXR0VacwJ8TWMQ== X-Received: by 2002:a63:81c7:0:b0:429:a566:e536 with SMTP id t190-20020a6381c7000000b00429a566e536mr2846519pgd.22.1660664292890; Tue, 16 Aug 2022 08:38:12 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b0016cf3f124e5sm9281691plh.131.2022.08.16.08.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 08:38:12 -0700 (PDT) Date: Tue, 16 Aug 2022 15:38:08 +0000 From: Sean Christopherson To: "Gupta, Pankaj" Cc: "Kirill A . Shutemov" , Chao Peng , "Nikunj A. Dadhania" , Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, david@redhat.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , bharata@amd.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v7 00/14] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: References: <9e86daea-5619-a216-fe02-0562cf14c501@amd.com> <9dc91ce8-4cb6-37e6-4c25-27a72dc11dd0@amd.com> <422b9f97-fdf5-54bf-6c56-3c45eff5e174@amd.com> <1407c70c-0c0b-6955-10bb-d44c5928f2d9@amd.com> <1136925c-2e37-6af4-acac-be8bed9f6ed5@amd.com> <1b02db9d-f2f1-94dd-6f37-59481525abff@amd.com> <20220815130411.GA1073443@chaop.bj.intel.com> <20220816122457.2fjyd4uz5hp5cani@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,FSL_HELO_FAKE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no 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 Tue, Aug 16, 2022, Gupta, Pankaj wrote: > > > > > Actually the current version allows you to delay the allocation to a > > > > later time (e.g. page fault time) if you don't call fallocate() on the > > > > private fd. fallocate() is necessary in previous versions because we > > > > treat the existense in the fd as 'private' but in this version we track > > > > private/shared info in KVM so we don't rely on that fact from memory > > > > backstores. > > > > > > Does this also mean reservation of guest physical memory with secure > > > processor (both for SEV-SNP & TDX) will also happen at page fault time? > > > > > > Do we plan to keep it this way? > > > > If you are talking about accepting memory by the guest, it is initiated by > > the guest and has nothing to do with page fault time vs fallocate() > > allocation of host memory. I mean acceptance happens after host memory > > allocation but they are not in lockstep, acceptance can happen much later. > > No, I meant reserving guest physical memory range from hypervisor e.g with > RMPUpdate for SEV-SNP or equivalent at TDX side (PAMTs?). As proposed, RMP/PAMT updates will occur in the fault path, i.e. there is no way for userspace to pre-map guest memory. I think the best approach is to turn KVM_TDX_INIT_MEM_REGION into a generic vCPU-scoped ioctl() that allows userspace to pre-map guest memory. Supporting initializing guest private memory with a source page can be implemented via a flag. That also gives KVM line of sight to in-place "conversion", e.g. another flag could be added to say that the dest is also the source. The TDX and SNP restrictions would then become addition restrictions on when initializing with a source is allowed (and VMs that don't have guest private memory wouldn't allow the flag at all).