From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 97E9030DD1C for ; Wed, 25 Feb 2026 07:56:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772006164; cv=none; b=DJ4y1kxVa0LHXNtIwV0rjOfAt89nJl4Wttuc7l8mmpOu7wrEoNEdVLBtOI5Ze6anK9m9jFuLfCBfI43oRCTcfLlkAeKMLCngTVza/9mZm+15VZ8FYvGe8ezVXj7HKWfUIxqbXs2tJKs0Ngo0wLwumCv/ZI19TRrZ2nCH76oHWQQ= 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.179 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-f179.google.com with SMTP id d9443c01a7336-2aad8123335so58435ad.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=grRLfOzQKqBBUVDZh4u1ydhMLK7nC6Yw3f/XRGLZo7My0ft3DBC6L6oB8thrvQplL9 AeF62BBNhlqQtPU+Lxrkt0Tya+FTMw3w1pbARQOVFzS4eOpEorZ9Wz+fsxeY4Ac60FoV TgFitt89yWKDDq9CB21R7U+8Edr7ucVenDiDe8RwHzMXozB1hDDsbZzCRUrICygN0sZm bJpLeJDbQPZp3xNFsehiQ4Ntdk3wuDYpjR9AdVW2ZscA+PZQWaF4XhVNuYHfGnAgC1xm oPwYalPWjKlIyrsgcLzhuDxf/wsooYAI0rNMDM5U9QyTSVQeoWztZl+UmLUI15hVdBAI EEzQ== X-Forwarded-Encrypted: i=1; AJvYcCX26R76vsfQrXIO7+HdkyQzYNe/N3RqKXV1yKdVyINVCTjIDKtX8PvWspajfNIaa9GI30q8l7hMTkGzWF0=@vger.kernel.org X-Gm-Message-State: AOJu0YwKRBN10jHV7zZPp2xBgwEyVFgmlEj09aObbtrbEqEOyYKOh8Lv mNo/cFBu9rTRe2S2zg2ubsaJ+UlpmvWft4OQy1GqYks/sgTrTz+UlSWt/MS7xZCqyw== X-Gm-Gg: ATEYQzyunOd8fVF6PNCRJtDXmmYX550E+IDKHxRhUKRMY66nmeW9rVoFF5DnnBlDNZc OKio5gmx7qyzhbk5rH2d8GNTLX8uAZd5AEdIJTp90I4SnMYPAsUkHnrJPJ/g2MSL13oyB9AdIVE 2xwfXvobWTbdTLjvlC8lZN6Q8cerZMyR8QGdPyTJ0CQP7MZFQkGPUDH+5NsbAz1xslrRhM/gMGv /Z+y5ZG9QclQWMRiMAy4lPFyiKxBlHNUy7sIYryUCr14CfqFRpFGXd7iA+I1+z+3knfvNwphvzt yOebnZbTQ7GMKuZv1bG58rMzFwzgdARRFZwZrBPKzDdes9ppy88IK0R+iG96/wztOrtj9kWr+8B obeyHzDB3+izcR6efnwV499w0e2XY/4YHLadBQEYcgX1bDoT9XTbFkmTkZn3P3jUdq0qngtQq6p u4n91gcu5yHS6P7nuVj9S3ob2VPyzH+LpfcehnkrIkzJRM3374QhiJfgUdjVT0 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-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: <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