From nobody Mon Feb 9 13:02:59 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 90B1836212C for ; Thu, 29 Jan 2026 21:25:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769721953; cv=none; b=GT4sh/psOgKdw3TuKCvoYwIzGfQV4YQOJKOSESTDT0zA+yGyOUYqUMFPZO6qw/GMzcZoNx1c6jfxrdvo0aXFS6WrZVNUHU6AEb5gGf95QZrVs5EIEIelZP3r4Oz0EE4rGbWy7+H/faVgjmVL88odHhylPMOUouuYDA1kBmvbBOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769721953; c=relaxed/simple; bh=s2EF+0wW+b5BmyDvXoLeRzuJ8QMd8hJHZ8kLYdzRY0Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=t7XFO5j5JgHlBbft9iscylLYXWRWC13QDcb7F7QSDyd0RVhwJXF1sxPnsVMNlL+U6Ff6Bxo4zyiWjq8W+8r7TO8a5LAMqOoJIB1HmeEJg/ulRG3S4jJ74rqTSw7A3KkTVX98RklgMk2yD+Uhzv9cUR0V2+0gYIJxS0iuHN4wy/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MjNid7Wr; arc=none smtp.client-ip=209.85.214.202 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--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MjNid7Wr" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a0a0bad5dfso30902945ad.0 for ; Thu, 29 Jan 2026 13:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769721949; x=1770326749; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AVUDzL5NEoLRiR0kq4rtjTLHEzT2c4a+QSQgWmkEpoo=; b=MjNid7WrOyEJT1IuYZdcgcGfdihVHcDFOUlYLCAAuNkFKHRth/gQaAA5frJ1KHYwur kM5Z22z3Y2+cE4N4p8JS27nWJCBRsTo15KFDUdzKxCnr6PYbR/4o9j8xOK8jCAyIoh4A KE1IC+P4h9JuZCG5aOio+d3OVeBq448eX7STBsLxM839FCDNyTuzboldeBZWoY/cx3EN N/RyJkYmSyCdlyGvL3fffoA8tswrFrLYVO9wRG1b1ygGrn4YWuT4DmmqPFuE/rKfHO9c kc2UW9GgqiJvZcyH9VAK1bNVrAQnAM+CshOPTrugIaT00cEpaW/uHFdi20QfcdmEl8bA Ovrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769721949; x=1770326749; 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=AVUDzL5NEoLRiR0kq4rtjTLHEzT2c4a+QSQgWmkEpoo=; b=AWxMiGiAwsblCH09Ye1GMq/pA8Jn2p3VqZtdBrSYXwP5KdVT9s3TreY4QRnkgctDj0 M/HbzTBqzoh/ZXr7uOP/ma6Vaz1DHYd+Q6reWLP47XNxX0oyyfOeWZ9x+sqH6Ks9uJxc OstlTKUBwL/ADJBqpSqDu8F3uoamEeAuw6D27pxkQo4xT4m33Jrf8HPjikXGpRv3kHFS itBrIFm+ssFEWzVEQVYo2tEgWvcNNoH+OcASNHnj0JIcbD6HOgjcE7jPA9EPrkcnXXZG pgyR7JVJGrLADoStZWFr/coRVPdaEGzYn0IuovUBrLnoPzDolG8rAzXRmKHH5SdhI335 D9SA== X-Forwarded-Encrypted: i=1; AJvYcCUOUwbTsktmZAbH18C+41ihouDePZcRX1UsAlHOg89PV4aBLr9j+5728NmeLhxyRYjziRmSveaNuzR6SA0=@vger.kernel.org X-Gm-Message-State: AOJu0YxMQY+yA4OReNxrXl66T3ITmpilUvfavUnrzuwMJo5GVhiPEdFL 33OSV+bnqvmOkg0ZZRhfPwKjYaBT+MavfnhuixA3lswcySFfbXlCzqPNEABQ9Ofd/zhg5kmbkvR PfBlyJkUpnD1yiw== X-Received: from pllm10.prod.google.com ([2002:a17:902:768a:b0:2a0:a0e0:a9c3]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:124c:b0:2a1:3ade:c351 with SMTP id d9443c01a7336-2a8d959a4bamr5657375ad.2.1769721949051; Thu, 29 Jan 2026 13:25:49 -0800 (PST) Date: Thu, 29 Jan 2026 21:24:54 +0000 In-Reply-To: <20260129212510.967611-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260129212510.967611-1-dmatlack@google.com> X-Mailer: git-send-email 2.53.0.rc1.225.gd81095ad13-goog Message-ID: <20260129212510.967611-8-dmatlack@google.com> Subject: [PATCH v2 07/22] vfio/pci: Notify PCI subsystem about devices preserved across Live Update From: David Matlack To: Alex Williamson Cc: Adithya Jayachandran , Alexander Graf , Alex Mastro , Alistair Popple , Andrew Morton , Ankit Agrawal , Bjorn Helgaas , Chris Li , David Matlack , 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=20Winiarski?=" , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Raghavendra Rao Ananta , Rodrigo Vivi , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , "=?UTF-8?q?Thomas=20Hellstr=C3=B6m?=" , Tomita Moeko , Vipin Sharma , Vivek Kasireddy , William Tu , Yi Liu , Zhu Yanjun Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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); =20 + pci_liveupdate_outgoing_preserve(pdev); + ser->bdf =3D pci_dev_id(pdev); ser->domain =3D pci_domain_nr(pdev->bus); =20 @@ -62,6 +64,9 @@ static int vfio_pci_liveupdate_preserve(struct liveupdate= _file_op_args *args) =20 static void vfio_pci_liveupdate_unpreserve(struct liveupdate_file_op_args = *args) { + struct vfio_device *device =3D vfio_device_from_file(args->file); + + pci_liveupdate_outgoing_unpreserve(to_pci_dev(device->dev)); kho_unpreserve_free(phys_to_virt(args->serialized_data)); } =20 @@ -171,6 +176,9 @@ static bool vfio_pci_liveupdate_can_finish(struct liveu= pdate_file_op_args *args) =20 static void vfio_pci_liveupdate_finish(struct liveupdate_file_op_args *arg= s) { + struct vfio_device *device =3D vfio_device_from_file(args->file); + + pci_liveupdate_incoming_finish(to_pci_dev(device->dev)); kho_restore_free(phys_to_virt(args->serialized_data)); } =20 @@ -192,10 +200,24 @@ static struct liveupdate_file_handler vfio_pci_liveup= date_fh =3D { =20 int __init vfio_pci_liveupdate_init(void) { + int ret; + if (!liveupdate_enabled()) return 0; =20 - return liveupdate_register_file_handler(&vfio_pci_liveupdate_fh); + ret =3D liveupdate_register_file_handler(&vfio_pci_liveupdate_fh); + if (ret) + return ret; + + ret =3D 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; } =20 void vfio_pci_liveupdate_cleanup(void) @@ -203,5 +225,6 @@ void vfio_pci_liveupdate_cleanup(void) if (!liveupdate_enabled()) return; =20 + WARN_ON_ONCE(pci_liveupdate_unregister_fh(&vfio_pci_liveupdate_fh)); liveupdate_unregister_file_handler(&vfio_pci_liveupdate_fh); } --=20 2.53.0.rc1.225.gd81095ad13-goog