From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 BE22323AB95 for ; Tue, 8 Jul 2025 19:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752004741; cv=none; b=O4yfCtGv9+Cvo9J23HK4sUwkQw86ZKJZDyVYvX2AyGuTF4ZzD8FcW2dZjENMhmTXvqQ9AKpK7SiNUHYbtzCiZWlT+QWln1gg176bwF/vCZHpHK/3AJpq2eRK4IWxJeMnJQkDwlxMvs2/2cjUqAiPphY4hUOcGRj3bBWk45JaTKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752004741; c=relaxed/simple; bh=qeaevY/WBAqE5QxM+YJ+9KYZuYqdnkSGgPZgsl4/+24=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VOwxp43V4KBAZKlHNNJ9+9RJ12SPVLATwcNdwXX2RJGnBYSm/bbdjFYmb6+OgSZ4l63SXc01BuE3fgmm63aLeMfZVXXSt1czGfkuUaO+fGUTs5bS7LNM67wT/0iIL9XujnC3J5dZtowP4RtuHSISx7z2ZOQglVP65ZIKYD480f8= 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=SMGwHSev; arc=none smtp.client-ip=209.85.216.74 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="SMGwHSev" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-3122368d82bso7266139a91.0 for ; Tue, 08 Jul 2025 12:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752004739; x=1752609539; 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=bK9rO788tLxJ4WTQcJIR4xppsNUsK51AEUh9HOz+/ZU=; b=SMGwHSevuBX8uNe7gV8O9YfcpuqqnWDeXaCNOcST83AMAhqcZ1XSHq9ViVw+uCImZu y6jO2HTl0Q3Z5v0szokGSVipKrWbC02Jy+/cQzTNlop4v3dV6KApdRmVM8lkj9xVq9IH yJapcaDc5QPvQZnRd4toVcrEK6LwzJXvoH0RYoyq7ii5rSFZQkeuwgrk7LTta2QTtRGa pu488oT8uOBeYu15u/NzlvE8MUV/tetecR38brWhYV5VRsKMq3llnnu6Rd9/OFToySN5 cUnFC0w3wJEZ/0NBPMy9x52a6w4M0Updzosw1m0i92BS4XOAbW92bW1pfPEway0ml1bk ao2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752004739; x=1752609539; 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=bK9rO788tLxJ4WTQcJIR4xppsNUsK51AEUh9HOz+/ZU=; b=N1Nkwu3Fr2naBudqDs0ubMkOqFj+Qr2EDE+hmC+fOpkMwRbB+646QUwMToKdtIFY7z Oiq2sO2owRzZPLme3Tz0ogLE3sDAIRjnv25rNMdFH4+rOzO2yZVpDA1Moyf0g3p2tKmp DMaLuqTHY7uT0B8Bm4ni0O7s9g7tYPngXlP723S2Z/MbH18ODyL1XSL7LldvOakA9pRR b7EgJ4rKscoyWZwAZ+NMKdqRPXjIxwTxY1lnibLSDtHNymed/KNB380Hrj3AsPx9cBgw B4eYkfMCw/QOFWZdClhOXL0sxXgJBa5BS+blZ5ETvA1r9sISEUJBJ44VyX/FPlf6Hhom zS8A== X-Forwarded-Encrypted: i=1; AJvYcCVfYCDLpKfoMi6rAMewSqZcDksPzfkCcFvaQABLG2zFW0GA5tRCp5W2AEzgd+0mvwC/7s7M6Eb2gXUqT75U@vger.kernel.org X-Gm-Message-State: AOJu0YyF7COKVRPdJEwxK5+h6lGV5vvXsIxdUD1594NipdbQfOkPYfUW pTnnlhKx2UFHwx3pyweMee0voqS7FAMgYWWn3urEdG4FcOKO/6WwwIT1o4kDsSpaGvHIynCiaac xQkSTxw== X-Google-Smtp-Source: AGHT+IFkETqYRl85TaDCY+mhRsKj3yh+DlVRrd5kJgA8yrUlr1VJNZkXzaK8N5MZ0Opd+f6mnf+G32B45Fc= X-Received: from pja6.prod.google.com ([2002:a17:90b:5486:b0:2ff:84e6:b2bd]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1f83:b0:311:df4b:4b94 with SMTP id 98e67ed59e1d1-31aac432a89mr24009325a91.4.1752004738302; Tue, 08 Jul 2025 12:58:58 -0700 (PDT) Date: Tue, 8 Jul 2025 12:58:56 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-fsdevel@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: Vishal Annapurve Cc: Rick P Edgecombe , "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, Vishal Annapurve wrote: > On Tue, Jul 8, 2025 at 11:03=E2=80=AFAM Sean Christopherson wrote: > Few points that seem important here: > 1) Userspace can and should be able to only dictate if memory contents > need to be preserved on shared to private conversion. No, I was wrong, pKVM has use cases where it's desirable to preserve data o= n private =3D> shared conversions. Side topic, if you're going to use fancy indentation, align the indentation= so it's actually readable. > -> For SNP/TDX VMs: > * Only usecase for preserving contents is initial memory > population, which can be achieved by: > - Userspace converting the ranges to shared, populating th= e contents, > converting them back to private and then calling SNP/TDX= specific > existing ABI functions. > * For runtime conversions, guest_memfd can't ensure memory content= s are > preserved during shared to private conversions as the architectu= res > don't support that behavior. > * So IMO, this "preserve" flag doesn't make sense for SNP/TDX VMs,= even It makes sense, it's just not supported by the architecture *at runtime*. = Case in point, *something* needs to allow preserving data prior to launching the= VM. If we want to go with the PRIVATE =3D> SHARED =3D> FILL =3D> PRIVATE approa= ch for TDX and SNP, then we'll probably want to allow PRESERVE only until the VM image= is finalized. > if we add this flag, today guest_memfd should effectively mark t= his > unsupported based on the backing architecture support. > > 2) For pKVM, if userspace wants to specify a "preserve" flag then this There is no "For pKVM". We are defining uAPI for guest_memfd. I.e. this s= tatement holds true for all implementations: PRESERVE is allowed based on the capabi= lities of the architecture. > So this topic is still orthogonal to "zeroing on private to shared conver= sion". As above, no. pKVM might not expose PRESERVE to _userspace_ since all curr= ent conversions are initiated by the guest, but for guest_memfd itself, this is= all one and the same.