From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 8D60C30DD12 for ; Wed, 25 Feb 2026 07:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772006164; cv=none; b=n0NtA9ZEkKs17ssqM/gXfjAZ/8/YBfysmlQBg7vEHE68siMp2apVskZsVikvuS2qoqyu4iLol1HH+3CpbcIYzKQl8tde5l9HTiTvKCkhf31RSbICph3zk6Lc9/O10rCPwFFax8zEYjkcCYLY1D5EgEU7TX289+MtcrYuYoAp5pI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772006164; c=relaxed/simple; bh=/phNhW5Uy8/CpWeGcbySlurAcomYqpo/e8d49tUgN+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fG0R674fKpUxyXYb6v2Sm/bhZ5WvJa4sxHs82deRXsBZn/QUtVTp8hhH+jKkdoykGDzIkb5lfHVb3ydP8uhDbiHw2NKBpEbUixfaMRaVbRe+W02LRSZL2yFsUjKeylZDAn+TOZoVIiL9rLVcxaFH9sElhAHI2RBIfmNL9M4cGb0= 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=cMr5HWXx; arc=none smtp.client-ip=209.85.214.178 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="cMr5HWXx" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2aad8123335so58425ad.1 for ; Tue, 24 Feb 2026 23:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772006163; x=1772610963; 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=sT2VtKh2V5oEus0jIgTdEjDE+//UyVLRT7BohuHzzWw=; b=cMr5HWXxsinnyXoEwMHazVNRF3kOv/wkVKQxR+M98tFKdRWHFYT8B06/GW9yfsBqAW j5fFyDjk/0eKSa7ZENGTrj1QKZkZ75EZZYioyJhoS34pkZFhd3iC3jGQldklBdUtr90D ox8GgTpNMyc5aFO8FWk/RCKCyXYWDJ5Iqe2S1AVAbuiYtc54b7/YCL5SkVCCXzLcow+s 2FpsosqfcxYfpLVjeGADRu3H4JO0TBCamAHtADHIVnFtQh98APl2+mvxIAJR5+qrI1XZ QPCVl26UKxp+e6jQQ+SOE1Q4WxjNLJYKkT4sCVAvh3byNDLO4broTTmZ4rO3wlC5jvso 3PxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772006163; x=1772610963; 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=sT2VtKh2V5oEus0jIgTdEjDE+//UyVLRT7BohuHzzWw=; b=aGzzuLrNSHvyVp/HMLWKrEEP1jFHLZjjFzDLpAC+nrYCSz7+WMHySbz3FHiZs4qEoL 8o4YDxqE8GkRtmfcFUTq4V2Onq1u8n9YVV5mo5Mi/VzZopkiQJz0jsw6B6Bj8rx2ZREh Z55EFKMNBDpaTyw71Kzr8XME/bVZ9qgQ2LtLUmxHq1FYXOmnWAQzPf+5yeLnQ6qDXxFI 3eaxhfvEWkz2AvUqFSWkGOpjK/uHItmNc8SV6WoKREmyrjB8G8x6b6IGHeaOOa79HH79 PcRsk9KQvjvTF7MlEO10P9ctTF8o/C6Arvknb+vFAfj3A2SJdw+RIFn6JB1SMGfu/Hle R4eg== X-Forwarded-Encrypted: i=1; AJvYcCVT3NA45sCnbVAj/zH9r27uPTxM2kU2Q6BllcHFAhlbtZZH+R2+KpB8B+zSkIhye8MCUpx0rBQ850g=@vger.kernel.org X-Gm-Message-State: AOJu0Yyw6wAmTkEHaQe2KkFxvIkdJCyGbziD7i8WfZzWKP/NDM9ua0bz Smx1U8H53gXaUIAgQoQ6MOqTHEvtOCbQwHXjRGVhTcyQZBnwPZJfEgU87m8TDMXA/g== X-Gm-Gg: ATEYQzxLb9eGGvYCTY03uG52K58nP3SM8hGumGARPaFqTFwBrpoKFfmKKCCULhztheA bAWrRiARpdZgF/2weM5idoRd37ROVvknOVmpi56JV/e+WtwA79M7CVHPKJ9Lm9MfHVtFEdVCC5K fkB5dXXVCXHNlXdT+p+4KJGIjYlIf/MgcLmruGY7+GKsSlF/VfixdhxtDKpX/C5ra0nhhU4e3Jn Z1it9IFfGCIt2OTzo4Il/vSqPDRNsavbs6dBFVkc7dxKxLv9CLkflAf1Y4DaZS7lzTzrqwwVCgo qOeSi9zIquX6cCLgHO/+5jBqkXlj3RFkC3G8JyrBS4HMAnrRJJvSPMQCqUnv/t/6orNSzBbIG2k Q0u3pjF3XWsl0GTGRqdmU5ZpgnI3z+H8EDtXa55P5dI9XDUy4AS5OSpRsgv5yE9/s3RZPhseIyh eu1Z53J94owcS5KmS62RJBUSiLluDJe4DLoyD4LTduD/rxcP00WLOXqak3pX9s X-Received: by 2002:a17:902:d592:b0:2a7:6c4e:5924 with SMTP id d9443c01a7336-2adca6e950fmr1322615ad.12.1772006162194; Tue, 24 Feb 2026 23:56:02 -0800 (PST) Received: from google.com (222.245.187.35.bc.googleusercontent.com. [35.187.245.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad7500e2b2sm124024035ad.52.2026.02.24.23.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 23:56:01 -0800 (PST) Date: Wed, 25 Feb 2026 07:55:51 +0000 From: Pranjal Shrivastava To: David Matlack Cc: Alex Williamson , Adithya Jayachandran , Alexander Graf , Alex Mastro , Alistair Popple , Andrew Morton , Ankit Agrawal , Bjorn Helgaas , Chris Li , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Kevin Tian , kexec@lists.infradead.org, kvm@vger.kernel.org, Leon Romanovsky , Leon Romanovsky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Lukas Wunner , =?utf-8?Q?Micha=C5=82?= Winiarski , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pratyush Yadav , Raghavendra Rao Ananta , Rodrigo Vivi , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Tomita Moeko , Vipin Sharma , Vivek Kasireddy , William Tu , Yi Liu , Zhu Yanjun Subject: Re: [PATCH v2 07/22] vfio/pci: Notify PCI subsystem about devices preserved across Live Update Message-ID: References: <20260129212510.967611-1-dmatlack@google.com> <20260129212510.967611-8-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-doc@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: <20260129212510.967611-8-dmatlack@google.com> On Thu, Jan 29, 2026 at 09:24:54PM +0000, David Matlack wrote: > Notify the PCI subsystem about devices vfio-pci is preserving across > Live Update by registering the vfio-pci liveupdate file handler with the > PCI subsystem's FLB handler. > > Notably this will ensure that devices preserved through vfio-pci will > have their PCI bus numbers preserved across Live Update, allowing VFIO > to use BDF as a key to identify the device across the Live Update and > (in the future) allow the device to continue DMA operations across > the Live Update. > > This also enables VFIO to detect that a device was preserved before > userspace first retrieves the file from it, which will be used in > subsequent commits. > > Signed-off-by: David Matlack > --- > drivers/vfio/pci/vfio_pci_liveupdate.c | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/vfio/pci/vfio_pci_liveupdate.c b/drivers/vfio/pci/vfio_pci_liveupdate.c > index 7f4117181fd0..ad915352303f 100644 > --- a/drivers/vfio/pci/vfio_pci_liveupdate.c > +++ b/drivers/vfio/pci/vfio_pci_liveupdate.c > @@ -53,6 +53,8 @@ static int vfio_pci_liveupdate_preserve(struct liveupdate_file_op_args *args) > if (IS_ERR(ser)) > return PTR_ERR(ser); > > + pci_liveupdate_outgoing_preserve(pdev); > + > ser->bdf = pci_dev_id(pdev); > ser->domain = pci_domain_nr(pdev->bus); > > @@ -62,6 +64,9 @@ static int vfio_pci_liveupdate_preserve(struct liveupdate_file_op_args *args) > > static void vfio_pci_liveupdate_unpreserve(struct liveupdate_file_op_args *args) > { > + struct vfio_device *device = vfio_device_from_file(args->file); > + > + pci_liveupdate_outgoing_unpreserve(to_pci_dev(device->dev)); > kho_unpreserve_free(phys_to_virt(args->serialized_data)); > } > > @@ -171,6 +176,9 @@ static bool vfio_pci_liveupdate_can_finish(struct liveupdate_file_op_args *args) > > static void vfio_pci_liveupdate_finish(struct liveupdate_file_op_args *args) > { > + struct vfio_device *device = vfio_device_from_file(args->file); > + > + pci_liveupdate_incoming_finish(to_pci_dev(device->dev)); > kho_restore_free(phys_to_virt(args->serialized_data)); > } > > @@ -192,10 +200,24 @@ static struct liveupdate_file_handler vfio_pci_liveupdate_fh = { > > int __init vfio_pci_liveupdate_init(void) > { > + int ret; > + > if (!liveupdate_enabled()) > return 0; > > - return liveupdate_register_file_handler(&vfio_pci_liveupdate_fh); > + ret = liveupdate_register_file_handler(&vfio_pci_liveupdate_fh); > + if (ret) > + return ret; Nit: We might need to handle the retval here if we remove the liveupdate_enabled() check above (as discussed in patch 2). > + > + ret = pci_liveupdate_register_fh(&vfio_pci_liveupdate_fh); > + if (ret) > + goto error; > + > + return 0; > + > +error: > + liveupdate_unregister_file_handler(&vfio_pci_liveupdate_fh); > + return ret; > } > > void vfio_pci_liveupdate_cleanup(void) > @@ -203,5 +225,6 @@ void vfio_pci_liveupdate_cleanup(void) > if (!liveupdate_enabled()) > return; > > + WARN_ON_ONCE(pci_liveupdate_unregister_fh(&vfio_pci_liveupdate_fh)); same here. > liveupdate_unregister_file_handler(&vfio_pci_liveupdate_fh); > } Reviewed-by: Pranjal Shrivastava Thanks, Praan