From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 D48FE34F481 for ; Tue, 24 Mar 2026 20:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774384233; cv=none; b=uBLki2HxdhzBNItdJKi4hzHp9A/nr3el3gWpoziZPDs7pPGfrqYvnEKHgDNAgp31iQRGPUSOGM2fQPIcL0+wiyhtnkR7fgwyXlb1z0TtU7+0bz0KQTwAa4aB3y6q0E1k2JhxZWxlI3JKsTXRkuW9qmf3/VMMX54X2UQBgoI9nxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774384233; c=relaxed/simple; bh=Tey6SVYpWtryUf49rWPG/gjXRb3iJqKZf+I/nXWKq3w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jSspp8pFIAVwL4QDc3H4jJWPwLb1XC/70hJcfjbymh9zd1FAq7rUBbxFaN+n4+PyYowJi5gM3JqTttPGPhofJOvOVIicGqlt8nSVF31S6YOk/BaeEroDdpp/qWsDBxPGmTksty9y+nPo0y+yeSq7VOLRzXrOVNlrAViBw65g/qk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GlzBCp7V; arc=none smtp.client-ip=209.85.214.172 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GlzBCp7V" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2b052562254so27975ad.0 for ; Tue, 24 Mar 2026 13:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774384231; x=1774989031; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4GyQVsw9WUXq0Tx/o/WK9RzM8Q6jgQHyNgH4GZL/eMM=; b=GlzBCp7VhEaSUTMEWeHQB2SRwYEbds+t8ADwD+sRmPNCFiND8+FSrLzfmWr1UszKZ5 nzad9ksgGx0Nu9czsUDcY5ku26boW7m8E0ul3Xjuam4I+b7k2HjWqPWz3Fkl8ohEH4+W 0c4KEu0ETACnUIWqO8MYBO6OzS6g5vQc0HNr2KPu69Sve4yT8TrCZ1PqYf0nHVYJ8ofS yo/LFxkKdNP7RTIEjs1Wu2acdyyeEr1dCO8wlQ3Z9aA1w5jusCiAlJzjb2yqL4zhshUb e3PGQvq1qxDNsT6QbkgErLcPj3AgR7gKjR7oFdGWETP/rC6+X5T1iHELLkB0ncxX0bY5 zE0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774384231; x=1774989031; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4GyQVsw9WUXq0Tx/o/WK9RzM8Q6jgQHyNgH4GZL/eMM=; b=WPFQLosRRloLrX0YwWbFhgeCHMOYZ9AHGa7+ILhWQT1D2RD4C16LZk8EaRwyCTNcbO PiWOZjyOZgJj2gmWFAFbv9i4WbIAusCAol8dwJ7wdXsgMCJP8Yy+u7Xw4VkK7kTDbZ3S Gb7/iAYA5deehbOMn7MS8AgwyU09Vw7uXMeoABce1qbT9NZF0JJKIImg3sLoL4BrC7d7 RYnGQyEwfpc6GbqvOcbmi/TVlh/qYkUBqQYFqpdgKV/IMwoaJpTR7oMNSKbo9M24YJy8 gGqN6lZ7+OetWh3Fe2qfvQJ91fi/BtcAVgUmCWmwX9L3gyuHd+jEqlWhoRvhIxVcpwb1 rEdg== X-Forwarded-Encrypted: i=1; AJvYcCVDQo/3U3nifA+Q6ZGYgWNkJBZabwzmwo64H7buBbM5wy2Nm4+0uz9jW+H9/oFOnGEuk/0CYTv8YMU+rMc=@vger.kernel.org X-Gm-Message-State: AOJu0YyCS02gXqX7WAar/GceNU0j5PWQxROaToDfi93ChrSRTN4YvkHJ vZmKUyKdfFhDHQz2ICG+l45beIrg3Z8SEnMi1hO4skKdIvjT7P/23v7utc12ad+PPw== X-Gm-Gg: ATEYQzwV95AJ2NvFHK8Dz6gWUPCjpwc18DE1tCMMhGZpRkzQOUHfgOFVJTmDZpfo0wu YGeZHZkwsYLHD/wR2luBy8Z8igqG5xQQRyxjpeMI7Sell2A2rMw6x7ss0RC/MyA1XDA+35/IVGE f4B5qMOIBH8ARnUYB+XcFcW2iV7+GCECEfkCj5mdxPLSDO9LQb3zOt48NjPP+ZlDjgfC05Y+SoV 4Ov3Kc+k5Pmf8/FeRcWTnGv6Dn8wNKKs5kznWqSbNKZv9GLUwg9jD2SGI0/DTiP3Kirbce0pflI f61NgJVYqNcT5uBSsvlyaHaLVmZfYw/QUJxaw+dYjVaSJKU7be6PThKLVKzZ0rQvebIGLP7k4bw EwP+JG1+SwPoKusr0FBfjmuS73Bbqc9/tHdLRmQMg/KZFW03XXYN78VUKLd409u7ulW3R27Tkxx MSFC6kv/2At2SgKUq9x0rTmPNbyrH/xfJG3oXyqa4Q99OhJaJIfItBovGFWA== X-Received: by 2002:a17:903:32c5:b0:2b0:95a2:f84e with SMTP id d9443c01a7336-2b0b2ad9dbamr141655ad.19.1774384230665; Tue, 24 Mar 2026 13:30:30 -0700 (PDT) Received: from google.com (60.89.247.35.bc.googleusercontent.com. [35.247.89.60]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82b03aa960csm16439526b3a.12.2026.03.24.13.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 13:30:28 -0700 (PDT) Date: Tue, 24 Mar 2026 13:30:24 -0700 From: Vipin Sharma To: Samiullah Khawaja Cc: David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Jason Gunthorpe , Robin Murphy , Kevin Tian , Alex Williamson , Shuah Khan , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Saeed Mahameed , Adithya Jayachandran , Parav Pandit , Leon Romanovsky , William Tu , Pratyush Yadav , Pasha Tatashin , David Matlack , Andrew Morton , Chris Li , Pranjal Shrivastava , YiFei Zhu Subject: Re: [PATCH 13/14] vfio/pci: Preserve the iommufd state of the vfio cdev Message-ID: <20260324202859.GF190066.vipinsh@google.com> References: <20260203220948.2176157-1-skhawaja@google.com> <20260203220948.2176157-14-skhawaja@google.com> <20260323210111.GB2571566.vipinsh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Mar 23, 2026 at 10:07:31PM +0000, Samiullah Khawaja wrote: > On Mon, Mar 23, 2026 at 02:17:29PM -0700, Vipin Sharma wrote: > > On Tue, Feb 03, 2026 at 10:09:47PM +0000, Samiullah Khawaja wrote: > > > diff --git a/drivers/vfio/pci/vfio_pci_liveupdate.c b/drivers/vfio/pci/vfio_pci_liveupdate.c > > > @@ -49,15 +51,32 @@ static int vfio_pci_liveupdate_preserve(struct liveupdate_file_op_args *args) > > > if (vfio_pci_is_intel_display(pdev)) > > > return -EINVAL; > > > > > > +#if CONFIG_IOMMU_LIVEUPDATE > > > + /* If iommufd is attached, preserve the underlying domain */ > > > + if (device->iommufd_attached) { > > > + int err = iommufd_device_preserve(args->session, > > > + device->iommufd_device, > > > + &token); > > > + if (err < 0) > > > + return err; > > > + } > > > +#endif > > > + > > > ser = kho_alloc_preserve(sizeof(*ser)); > > > - if (IS_ERR(ser)) > > > + if (IS_ERR(ser)) { > > > + if (device->iommufd_attached) > > > + iommufd_device_unpreserve(args->session, > > > + device->iommufd_device, token); > > > + > > > return PTR_ERR(ser); > > > + } > > > > driver/vfio/pci/iommufd.c has all of the code which interacts with > > iommufd in VFIO, I think we should follow the convention and add a > > function there which can be called from here. > > I am assuming you meant driver/vfio/iommufd.c as > drivers/vfio/pci/iommufd.c doens't exist. > > I see iommufd_ctx and other iommufd_ functions being used directly in > various places outside drivers/vfio/iommufd.c, so there is not a hard > split I think. This will introduce unnecessary indirection I think. Yes. sorry, for the wrong path. Sounds good, I misunderstood things.