From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 465B821B9C6 for ; Tue, 8 Jul 2025 18:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751997808; cv=none; b=aLXUMbrjM74E28JC4l+uMRsPk6O14lFdz/jCRXMpUPsb86j2Hq3ZJV6v++mwlbgkU1VcsBswR3dhgs7GpKP2bdbwQ6R+RApndbq2msNOh2OpcAnpedo2TJ9Lq1lLzxGT1Ad/VZHnkfz6iZCz84v+7U4U6KaqAIwR5wt4//QOjhg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751997808; c=relaxed/simple; bh=s4RZ8nQJieFScy8n8qpYU1+xTprPbswQodWfgBTVO6c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dX31WcjOvmnSKAty1Kn6kVxFp7jCqKdNF5BAYErrKw5XEZJT674sI6e5pngFQkY9QJeuUVeuAZ0ECFxTHWsCcx8f43QCERg/VPfee5EJVN8FDXDRB9xi4u5ivYgiGU1aguupVv3OXAiAdBSsDYsduSzTzlx7Hiv85sy8HrAPysE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MpxduJu3; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MpxduJu3" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7491814d6f2so5062150b3a.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=1751997806; x=1752602606; darn=vger.kernel.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=MpxduJu3u+fM/VC2SJDo/bINjCHvo/qYcsNIIghMojw2PvcG85Zt6mm9wXxC8Y4lVe goWMsSHQdl5c9Eq+Vj4z5aIgubDgompaJPCS2+biVcsJC+wmIq0Cg8/WiDLaZ3K1Vdao 2hOlKDcQOHhBTS1DEdcTHbvUgGQFAwCKVVpdsf1nIWCEQ0vEVBOWDYAVI1jagLbnHdd6 DNXuxYGVRTFGUErbsUcVv+uNdGdCc2wMvZBOsx0d2Ri1pnvaCPdO4wqi928S/KUJu6fb ckqOSIXQbgYaS8hgDpCSTG0YJEvLaWIalHjcJzKFqWCRFyiyH0sl2aI6EM9OVYOG625L 2Nbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751997806; x=1752602606; 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=ENWVFFTen1PZ8QHB4cln9w3m2QhlUzaIx8bVnwKUALqE030zHBEmMw0biv10oPghnm 8DlOZNzQWFxX0ShJXWAKQhd/JH1PWGmIeMvOWqgxvBUVymQcW7bdiNjPzQibiXiFBmPN d6E/flDRfYZ8a4QTLTaIZchM2LZL8K0vEsqUeNOD2C2jGx9ceM3cpRHZIEk9Y6UT2p9f L86PstcHFMbJZ8XhRJRtBzLEWZ4XLgrD99DaX9sXHh6h1xKzD3A4pQb67/AaKTqFXaQe taE4wg9tSJ2MYUYzXuKtAX9UmHlhous0R81/Zf6EC2FG/yB3vA5GSZDIAwZpiwzChruy DZmQ== X-Forwarded-Encrypted: i=1; AJvYcCXCC9BFCcTfuunrB+FNoZ+dZJhaoOrV/eztHv6n3PTm5yrjy2msF6n2MqiccDlHF8nOmfo=@vger.kernel.org X-Gm-Message-State: AOJu0YxFijtp+x/dCr58xiXnoFBaa+ZeXZO1XuwRY8lQ+4VZ9KFu1O/R oxi0fPaB/tUEzuSO/xVIUbED3+HTOM2ZxGKKKnPTyNZ3M2FDdLDxcOlwJzYezzQM8rfwxgg3YGw WMTObOg== 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: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.