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 62EC3C83F09 for ; Tue, 8 Jul 2025 18:03:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C309D6B0096; Tue, 8 Jul 2025 14:03:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB9B26B0098; Tue, 8 Jul 2025 14:03:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5AFA6B0099; Tue, 8 Jul 2025 14:03:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 86CA16B0096 for ; Tue, 8 Jul 2025 14:03:30 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2E1E31D355B for ; Tue, 8 Jul 2025 18:03:30 +0000 (UTC) X-FDA: 83641869780.21.C64E3AC Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf16.hostedemail.com (Postfix) with ESMTP id 2B4AE18001F for ; Tue, 8 Jul 2025 18:03:27 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="affmQ/Oe"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3bl1taAYKCCkXJFSOHLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--seanjc.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3bl1taAYKCCkXJFSOHLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--seanjc.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751997808; a=rsa-sha256; cv=none; b=GLk3ZB1AongF81e/9D4+/uQXC+/gViDW41GnJmWdVKmu8vDepbhakQd+u7QhgRa08+MImP SUusEyzpSKrovj3laeEOljmjib0C9AZv/VjhcSlGATrfnVyK3P1Jm6emCrPCUMDAZiopYn d43giJ9SCE3TJgXCNZXZjTFXHLHLNCY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="affmQ/Oe"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3bl1taAYKCCkXJFSOHLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--seanjc.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3bl1taAYKCCkXJFSOHLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--seanjc.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751997808; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=x10LXm7PeGMN7MOtWLfXfbWmNGz9S10d7VYiV0yVtCU=; b=gnjy/4ytIkzQla+nZnXP+2P5xnxeyIDKq2MUlNqXPgqv1Y4y1BJKQAVimLit+UeHlUMbgx WbRGXhVLPAU0XwRN5Gwbm9vWa90TUZ41o//fXcape+MJGev990KBg25GP1AHE22VoDDvHL GPh5G4fBPDi49iQKaEMkTqAa8ornw0g= Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7491814d6f2so5062170b3a.3 for ; Tue, 08 Jul 2025 11:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1751997807; x=1752602607; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=x10LXm7PeGMN7MOtWLfXfbWmNGz9S10d7VYiV0yVtCU=; b=affmQ/Oej9rYxQ+v8liX42yDDaJ31NNmeNMmxvW+2gLwBltotfEsfkeHq46fbdfKc+ flIiPVshh4EqSmKvR1RAQP54VRnxBerFdCTfmFLWqKewSp7Dhg71PtM0cBvC51/5b0kW wpkOGL7uK5QzQKtFaIELmc5vfzQHcJnf7ABIxQ9L/WvnzW6Xs0Ob7B1V6Fwxmu5zppt8 xlccgVa/8O1nmgGjLEw9B6NBA6+YdtvjsjJYWCWhRzCe/5JjSpcfdx4f0rY9oI7Qs329 LyYb0wfySTSdmRWnNHwAPN3Psy0VXt7A4urfXrqDS6VbP/J+rPO/sBPzNcXuqi45CjPu HY9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751997807; x=1752602607; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=x10LXm7PeGMN7MOtWLfXfbWmNGz9S10d7VYiV0yVtCU=; b=MNS5m5XUlqlCZJ9gwlRgxMcAayv6HcgSCAQXf2K1L5f1BOQsfTjAH7oyZTuasyILPM /fL5y7xNdkserC7UyiT/3E58C4yf8p9MpU8xJD609STQg7y10bVoNEScNBz8Zw23X43U KCA+eB5Ci1FDfrMkKe78sRH0zOWw9QedSswKHVNY2vIVmiSi4VF0qS+WSiKJCpiCPi+6 s1NIoX6tjlLrLEkRNOGXSX93wF47iJdM6uW8VFPhc8s9VIJMVx5NvK6RSvQGQw/g8YYH IT3dB1UzvRDRcckrUzUl3CG4u/NYcIzCFR3TGPHor9tdyVzadwZ7yUj6sE5O2kdWb7y3 7CSA== X-Forwarded-Encrypted: i=1; AJvYcCWZWUng99hwUA6dpc7i675GHXMAXuI4GJ5/MTBQpkgE7mKTJPvCV0Zgh2KlYYk1N9osm5cCIOKZVg==@kvack.org X-Gm-Message-State: AOJu0YyA3nLxdCWgtbrYK8NbEgU8VaTMdaoJr3lr7CZ4m53IAqwSbkSr f385D7PpkGagFpa45ram7VbJkQH51ywCQbnlnZUeMl5hI95FLhMh/xDjtmLFqCl8qRTgHPWa0hD mAOnsTg== X-Google-Smtp-Source: AGHT+IFe4SBpWGzwWywsUZpN2vnR08oPkVmXJnGtvFDNSO2RDy7ZqC2nSucMyoDDGRjNc9DXvg6wKac3oiE= X-Received: from pfbna28.prod.google.com ([2002:a05:6a00:3e1c:b0:748:f98a:d97b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:549d:b0:1f5:717b:46dc with SMTP id adf61e73a8af0-22c7f545df3mr622282637.27.1751997806375; Tue, 08 Jul 2025 11:03:26 -0700 (PDT) Date: Tue, 8 Jul 2025 11:03:24 -0700 In-Reply-To: Mime-Version: 1.0 References: <006899ccedf93f45082390460620753090c01914.camel@intel.com> Message-ID: Subject: Re: [RFC PATCH v2 00/51] 1G page support for guest_memfd From: Sean Christopherson To: Rick P Edgecombe Cc: Vishal Annapurve , "pvorel@suse.cz" , "kvm@vger.kernel.org" , "catalin.marinas@arm.com" , Jun Miao , "nsaenz@amazon.es" , Kirill Shutemov , "pdurrant@amazon.co.uk" , "peterx@redhat.com" , "x86@kernel.org" , "tabba@google.com" , "amoorthy@google.com" , "quic_svaddagi@quicinc.com" , "jack@suse.cz" , "vkuznets@redhat.com" , "quic_eberman@quicinc.com" , "keirf@google.com" , "mail@maciej.szmigiero.name" , "anthony.yznaga@oracle.com" , Wei W Wang , "palmer@dabbelt.com" , "Wieczor-Retman, Maciej" , Yan Y Zhao , "ajones@ventanamicro.com" , "willy@infradead.org" , "paul.walmsley@sifive.com" , Dave Hansen , "aik@amd.com" , "usama.arif@bytedance.com" , "quic_mnalajal@quicinc.com" , "fvdl@google.com" , "rppt@kernel.org" , "quic_cvanscha@quicinc.com" , "maz@kernel.org" , "vbabka@suse.cz" , "anup@brainfault.org" , "thomas.lendacky@amd.com" , "linux-kernel@vger.kernel.org" , "mic@digikod.net" , "oliver.upton@linux.dev" , Fan Du , "akpm@linux-foundation.org" , "steven.price@arm.com" , "muchun.song@linux.dev" , "binbin.wu@linux.intel.com" , Zhiquan1 Li , "rientjes@google.com" , "mpe@ellerman.id.au" , Erdem Aktas , "david@redhat.com" , "jgg@ziepe.ca" , "hughd@google.com" , "jhubbard@nvidia.com" , Haibo1 Xu , Isaku Yamahata , "jthoughton@google.com" , "steven.sistare@oracle.com" , "quic_pheragu@quicinc.com" , "jarkko@kernel.org" , "chenhuacai@kernel.org" , Kai Huang , "shuah@kernel.org" , "bfoster@redhat.com" , "dwmw@amazon.co.uk" , Chao P Peng , "pankaj.gupta@amd.com" , Alexander Graf , "nikunj@amd.com" , "viro@zeniv.linux.org.uk" , "pbonzini@redhat.com" , "yuzenghui@huawei.com" , "jroedel@suse.de" , "suzuki.poulose@arm.com" , "jgowans@amazon.com" , Yilun Xu , "liam.merwick@oracle.com" , "michael.roth@amd.com" , "quic_tsoni@quicinc.com" , Xiaoyao Li , "aou@eecs.berkeley.edu" , Ira Weiny , "richard.weiyang@gmail.com" , "kent.overstreet@linux.dev" , "qperret@google.com" , "dmatlack@google.com" , "james.morse@arm.com" , "brauner@kernel.org" , "roypat@amazon.co.uk" , "linux-fsdevel@vger.kernel.org" , "ackerleytng@google.com" , "pgonda@google.com" , "quic_pderrin@quicinc.com" , "hch@infradead.org" , "will@kernel.org" , "linux-mm@kvack.org" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 2B4AE18001F X-Stat-Signature: z9nwn45ks7r6rbeuuawqgsf53jcqzyof X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1751997807-380428 X-HE-Meta: U2FsdGVkX1+PPxfzzzI1elBU/mO9y7ys192JX1Hu9MRW+gWaQZ5cSFSKVjXxt2xqmQRjG5qobT7+sHHW/JGf35qjdKTAycObyeeQ/iiUnDNt5CGoeg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0vG9F+wuugfOIYWg3+YdkA/FRdObL9BUcsXeRl0AqPOxVeT9RXwBrPThfUXWa/8+lrIeTlwhQ6VWYSXT+lfehFVdif/G4p9ukZwFjUGPQk9RcqhY1BiLr8DZFtEDJ41gWDG8Dn3WmVSlaccKy4PBYJ3AviEgJG0AbDoaA5ADd+flWticeBryCt7sNkFusS3G4vM8sD/tV/ceFb081EnMotoeQNNjDDsqrqEoodiwt4Atdg/ooCaQs2/7imGcSEudxKRWOi9mjK7MJnCNlSg0SAT6SQmpGFvTtWZCNqe5l1x4Sfs5nE7iYee23cunIuu1lauFv4KbRxO4P5bMDAUyAHJdIOiH603932i2VI0neb1TpjOHqPxRz7w7UDmMqO40Lp2GeQbu6YDEv3MRCPt7D9kxtjr05jrWSxOck8PmN+9X5xzwFerZhXGVnb9Xi7sHnGm8WYTwvWdUCdLdgFz84CSHr43G3A/GcX/y8x0qUN08e1sPKScNY1UQNoO+0kMeVF8D7vAY= 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: List-Subscribe: List-Unsubscribe: On Tue, Jul 08, 2025, Rick P Edgecombe wrote: > On Tue, 2025-07-08 at 10:16 -0700, Vishal Annapurve wrote: > > > Right, I read that. I still don't see why pKVM needs to do normal > > > private/shared > > > conversion for data provisioning. Vs a dedicated operation/flag to ma= ke it a > > > special case. > >=20 > > It's dictated by pKVM usecases, memory contents need to be preserved > > for every conversion not just for initial payload population. >=20 > We are weighing pros/cons between: > - Unifying this uABI across all gmemfd VM types > - Userspace for one VM type passing a flag for it's special non-shared u= se case >=20 > I don't see how passing a flag or not is dictated by pKVM use case. Yep. Baking the behavior of a single usecase into the kernel's ABI is rare= ly a good idea. Just because pKVM's current usecases always wants contents to b= e preserved doesn't mean that pKVM will never change. As a general rule, KVM should push policy to userspace whenever possible. > P.S. This doesn't really impact TDX I think. Except that TDX development = needs > to work in the code without bumping anything. So just wishing to work in = code > with less conditionals. >=20 > >=20 > > >=20 > > > I'm trying to suggest there could be a benefit to making all gmem VM = types > > > behave the same. If conversions are always content preserving for pKV= M, why > > > can't userspace=C2=A0 always use the operation that says preserve con= tent? Vs > > > changing the behavior of the common operations? > >=20 > > I don't see a benefit of userspace passing a flag that's kind of > > default for the VM type (assuming pKVM will use a special VM type). >=20 > The benefit is that we don't need to have special VM default behavior for > gmemfd. Think about if some day (very hypothetical and made up) we want t= o add a > mode for TDX that adds new private data to a running guest (with special = accept > on the guest side or something). Then we might want to add a flag to over= ride > the default destructive behavior. Then maybe pKVM wants to add a "don't > preserve" operation and it adds a second flag to not destroy. Now gmemfd = has > lots of VM specific flags. The point of this example is to show how unifi= ed uABI > can he helpful. Yep again. Pivoting on the VM type would be completely inflexible. If pKVM= gains a usecase that wants to zero memory on conversions, we're hosed. If SNP or= TDX gains the ability to preserve data on conversions, we're hosed. The VM type may restrict what is possible, but (a) that should be abstracte= d, e.g. by defining the allowed flags during guest_memfd creation, and (b) the capabilities of the guest_memfd instance need to be communicated to userspa= ce. =20 > > Common operations in guest_memfd will need to either check for the > > userspace passed flag or the VM type, so no major change in > > guest_memfd implementation for either mechanism. >=20 > While we discuss ABI, we should allow ourselves to think ahead. So, is a = gmemfd > fd tied to a VM? Yes. > I think there is interest in de-coupling it? No? Even if we get to a point where multiple distinct VMs can bind to a si= ngle guest_memfd, e.g. for inter-VM shared memory, there will still need to be a= sole owner of the memory. AFAICT, fully decoupling guest_memfd from a VM would = add non-trivial complexity for zero practical benefit. > Is the VM type sticky? >=20 > It seems the more they are separate, the better it will be to not have VM= -aware > behavior living in gmem. Ya. A guest_memfd instance may have capabilities/features that are restric= ted and/or defined based on the properties of the owning VM, but we should do o= ur best to make guest_memfd itself blissly unaware of the VM type.