From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 CDB741FE44B for ; Fri, 27 Feb 2026 00:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772152136; cv=none; b=p9FCfslsDQ3mWxJ4L/MhES3Z00xZzR9u/+bKNao5N3lsaXR3eeu91R7Zgnlg9I949SLchbM5GGdRovH3t00sOlgtF9sekGFxldXHTjAYato7jUS8nUx3j4sOdRdDvawBIbHttN7edCrq8hVxvw+ThIXsW384SCaEnLHJdVRrASQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772152136; c=relaxed/simple; bh=lEB97ADOecWVEVe02PkREEzKIO4xAqb815Ec9Z1vUj8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bnBCD9VLjaxpIxIwMZqcTc2KseLHIkGTtlX4LM42LpZeKoc8k8ou5keGdUWYFme4P7hGHJsowdn6Ntxz5DwgG7K6QEYxjN+DLVfO1oxznacJEBy8so31hOoeDhs80vDzZVmYobUi+s49/B1wty6tvVy3d/wv2D9WT/YiK9QH8gE= 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=C+TrdXFx; arc=none smtp.client-ip=209.85.214.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="C+TrdXFx" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2adcab21141so13498125ad.2 for ; Thu, 26 Feb 2026 16:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772152135; x=1772756935; darn=lists.linux.dev; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=F6kmoc5vi0J5hNeqO/ZaE6q23lfiWCinIzXvzDb0g9U=; b=C+TrdXFxT6gvXn6/uptTLKwnS7mBAoJUM6qJS5qAXdXAxfNHREqlwP0rMR9DOom+QB 8JzzHA+pymCePeb5oBKo4vxy1vI6BCVBj865dsQfJ3dwQhcVMgfk4l2HQcbIND3U4tVA kIMzLL7vME/vjkbUNkSFu5vBCwmXzQ8YCNFWh9NPwnecyBzCUIOfuRqYGmrVoR3/ed5o t6SpJkthfw0hi7Bb4W14qdZPAnvkRqQvBOYkMZPoUlEJ72wXxrH8LpZcm0bqaSytzuys yzpk6tfrOJTGV727b8K/dhsWRiDZ+ek0HIzXYk2Sw02kekXmx9BQXOmvhhqYa8zmzShl suyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772152135; x=1772756935; h=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=F6kmoc5vi0J5hNeqO/ZaE6q23lfiWCinIzXvzDb0g9U=; b=fJvIioLGBCDCozHj20j90GMI8yXxCRRTW7fNeLPDy9Vu1oB0bPZm1UJ8K7d1NfniEF kZKl1I4PS6rlDTV6MJXlCsqi2b5J4JGG7ax7KsB9R+UeLR1EOnzb4RuhW+q6KDAkw4yD nRFo2zFKhPZWkLzogvF2g7q6YVMrydD39GX4Emnh/d2HoM8Eyhukvk+H49hFcLFI/oPC YlUwDp0MDWqr8kodwVZr1k3H7QCHpREkGGuxZGJ8NIVl91jjhMwjbLWJcsdqqHnxldkV zpkXkx9Bl/0aLOISNY5NrATtdAMqwCMN2YjlEkDYD7XU+EIfgUv38yo1SOsWKIMFF9+F AtKA== X-Forwarded-Encrypted: i=1; AJvYcCVtrMXVRZN03DuBAkQ0NFHK1YzxwSbe3y81jcuE5leqYIq/7/OYcM6ENcCJs2YZtQ6xfHhu5q/mtbnk@lists.linux.dev X-Gm-Message-State: AOJu0YwLU+ToqTKP5A2CiGUkAK9ec7F6TP3ImDp9ssr9lCCXyTWOF6/o CAkQHoSBa9atUw7c0j4cxKxJBXZvl6WihHAvfBAV+lOa0Eulmh63M3ml8zd3ky/KE8x9Ma7u34C 3V8wf9A== X-Received: from plbmp13.prod.google.com ([2002:a17:902:fd0d:b0:2ad:c29c:618a]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:22c2:b0:2a9:5c0b:e5d3 with SMTP id d9443c01a7336-2ae2e40a0d8mr7490925ad.20.1772152134981; Thu, 26 Feb 2026 16:28:54 -0800 (PST) Date: Thu, 26 Feb 2026 16:28:53 -0800 In-Reply-To: <20260227002105.GC44359@ziepe.ca> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260225075211.3353194-1-aik@amd.com> <20260226190757.GA44359@ziepe.ca> <20260227002105.GC44359@ziepe.ca> Message-ID: Subject: Re: [RFC PATCH kernel] iommufd: Allow mapping from KVM's guest_memfd From: Sean Christopherson To: Jason Gunthorpe Cc: Ackerley Tng , Alexey Kardashevskiy , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Paolo Bonzini , Steve Sistare , Nicolin Chen , iommu@lists.linux.dev, linux-coco@lists.linux.dev, Dan Williams , Santosh Shukla , "Pratik R . Sampat" , Fuad Tabba , Xu Yilun , "Aneesh Kumar K . V" , michael.roth@amd.com, vannapurve@google.com Content-Type: text/plain; charset="us-ascii" On Thu, Feb 26, 2026, Jason Gunthorpe wrote: > On Thu, Feb 26, 2026 at 02:40:50PM -0800, Sean Christopherson wrote: > > > > If guestmemfd is fully pinned and cannot free memory outside of > > > truncate that may be good enough (though somehow I think that is not > > > the case) > > > > With in-place conversion, PUNCH_HOLE and private=>shared conversions are the only > > two ways to partial "remove" memory from guest_memfd, so it may really be that > > simple. > > PUNCH_HOLE can be treated like truncate right? Yep. Tomato, tomato. I called out PUNCH_HOLE because guest_memfd doesn't support a pure truncate, the size is immutable (ignoring that destroying the inode is kinda sorta a truncate). > I'm confused though - I thought in-place conversion ment that > private<->shared re-used the existing memory allocation? Why does it > "remove" memory? > > Or perhaps more broadly, where is the shared memory kept/accessed in > these guest memfd systems? Oh, the physical memory doesn't change, but the IOMMU might care that memory is being converted from private<=>shared. AMD IOMMU probably doesn't? But unless Intel IOMMU reuses S-EPT from the VM itself, the IOMMU page tables will need to be updated. FWIW, conceptually, we're basically treating private=>shared in particular as "free() + alloc()" that just so happens to guarantee the allocated page is the same.