From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (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 AE6FA40488E for ; Fri, 5 Jun 2026 05:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780638127; cv=none; b=cvwwDeRpFgW9FqsWHSnzJpkd9AA8K7MAU3QVVyqzBEd8rvLTc7yWAsIRo8MBGsGdnWQk1D/RYFte7EMsX56iZvg1FoYPrzsKU9+Wuy3ds+VOIm3ZZjIV4r1UJSGCBpGtTz00M7iUnSz15JVxppGiP2GSSqEpzzYRQqDXJomdSkM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780638127; c=relaxed/simple; bh=vyPxlSjO6tbgGdJvKWRY97zHRXm672uv5NrREWHPfeE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TCa904zGmsV04/jjddvtycpqTZL/jYMzCHAKoRp3gzfvF9SxW4xkQjJgJjk/+17GPKQvcU475a+1qZicofyNv9hAAnfK5NSLE/BY2I3h3eWS+95rOyUruW9AVrUZ31l0HcXfZrb+LZ4C6p3HfTUcya5r9OVK4Hq3p3u6dkE4ByU= 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=aUEoaGdE; arc=none smtp.client-ip=74.125.82.51 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="aUEoaGdE" Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-137ff9a7d5eso6098c88.1 for ; Thu, 04 Jun 2026 22:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780638125; x=1781242925; 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=Rbv0AZ2j24l1SmU6m1H5V7hzpCBteEa/IZu6sKIRnTI=; b=aUEoaGdE5xeLiqjFRYh8R+9uF57aT6yN6Bzoo6hn+5Jd6ygxas+pD+2/fLa/CGCCY2 W2BeRb7mx0nbIVcSEJVAmkmxxOy59AorDZS73yj5E/sthVK8wJgIAS1G/8Dt4X9vGK1w KNj1asIlSXKf4u0dSiaYC77XUxR4fDydKpt1G/XiWcSdokyxRJXd+Ev1rtRxI9mVh9LG tc/9FHc9+Qhj2f5r+aF9IhNY1ULFC2dRPFADPzeYvVrz3+3Hvb8D4noNwDAOOkHfnp9v O+0bHnFE80/zfpN2CK8Wa81Td49lA8p6jk0pk9sjEEaTOe3xMdSR9JzFeXzJUsVLdCIr PXdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780638125; x=1781242925; 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=Rbv0AZ2j24l1SmU6m1H5V7hzpCBteEa/IZu6sKIRnTI=; b=WMb8NzIVKmRcFZDGcaa4QqM7a//4Nv3FvrBk0tWRJNjILrtP3d4fUKLtc6G4XneKAk NkK0khElUVV6toQGMe48S6HfpxCqzgc/N7rIXdGk6ouEg5zgqMcRDXvwUmSI8ft8E/eu 6iICjX8wS5XSBEEE8JWFfZ7irhCeTXO6RQVvchNNZq9wrl+ScBDKeJa8bf+rSL8nm+5a 2PI9X8LsVF1Yoq2aTTy2EKH0VkuCNhLm6gIiYnOX97bzupQ5jtwm9I30TDkZo7aZ+RWu 6JBEeD5K0cWqwS92kMy+LkdV5Ncf2jMoTKzNEZ7O0mm6M2zUrRyUtI8SODxbYEVy0+nc ECpQ== X-Forwarded-Encrypted: i=1; AFNElJ8H0Jnp1MCQHNOaxr+VCNxcopL4A4hd9Ln96kY1gb5NwKc6pR5N1QL9+DbRD4SxdPvuEEfdZbD0f6fmndQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9PTT1dZInChwAbXR/bNPiFGijDq+FzKqH0DxCoBWC5D87oJyO mBrJamEsyxJCv4lU0KxAKAjAM9585sU9Iw3gaPy0N/un2Rjxw9bRTHUEGi842Ac16ktZBAZz/Uo wVLiNGuzU X-Gm-Gg: Acq92OFxCBAALiGpajf8eFWnJr+r4dAyy+NGmedw77gZYDXH9RvGvTT4zhAhkVjj98z 9HETwzAChYE/Sw+8tvisFuI8ZkqOsbvfOy5+gU+3JEWr+W55Pw7Z3M+pbfDo4U7DaRkanx2/vtW gZP3VIMW4GkGaSwI1VYq9BmM2CpAm3KCoD8YcDH8+X95ANjUp7H/gvcjNIA7Nyz4PmIKftMIRWk 4RUz+ccOj2AwPDEuWyet/rmnH/4WVpnTaE/YISFZN2OrU5WdZyr76Z0FaIjo9FqizCHlmn8pq0x AC1EKfMynJP9X1u4UBEilwLmUv3kI5s6ke8aLgUz/yLC6tZ5LGhf+2GRX5476SgfpaI0fqbskHf uOGnF3dfud8hN8Se6zqEhkMsfvPa8mz41NUX2vSLi4KdSnloaGp2Mv57S8gYfexOmf4Y38EP3UA SLVZwprPKKcWFVSMGlsv2vwzTX1E2gsnD/MG+rpWdx4lg70vK8DZm7uxGhSL7ORwxAYwfXrcU= X-Received: by 2002:a05:7022:107:b0:136:d02a:67ee with SMTP id a92af1059eb24-13807cf45e2mr63052c88.24.1780638123822; Thu, 04 Jun 2026 22:42:03 -0700 (PDT) Received: from google.com (199.255.142.34.bc.googleusercontent.com. [34.142.255.199]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3074deaab1asm6539103eec.17.2026.06.04.22.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 22:42:03 -0700 (PDT) Date: Fri, 5 Jun 2026 05:41:54 +0000 From: Pranjal Shrivastava To: David Matlack Cc: kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Rientjes , Jacob Pan , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pratyush Yadav , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Vipin Sharma , William Tu , Yi Liu Subject: Re: [PATCH v6 01/12] PCI: liveupdate: Set up FLB handler for the PCI core Message-ID: References: <20260522202410.3104264-1-dmatlack@google.com> <20260522202410.3104264-2-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: <20260522202410.3104264-2-dmatlack@google.com> On Fri, May 22, 2026 at 08:23:59PM +0000, David Matlack wrote: > Set up a File-Lifecycle-Bound (FLB) handler for the PCI core to enable > it to participate in the preservation of PCI devices across Live Update. > Essentially, this commit enables the PCI core to allocate a struct > (struct pci_ser) and preserve it across a Live Update whenever at least > one device is preserved. > > Preserving PCI devices across Live Update is built on top of the Live > Update Orchestrator's (LUO) support for file preservation. Drivers are > expected to expose a file to userspace to represent a single PCI device > and support preservation of that file. This is intended primarily to > support preservation of PCI devices bound to VFIO drivers. > > This commit enables drivers to register their liveupdate_file_handler > with the PCI core so that the PCI core can do its own tracking and > enforcement of which devices are preserved. > > pci_liveupdate_register_flb(driver_file_handler); > pci_liveupdate_unregister_flb(driver_file_handler); > > When the first file (with a handler registered with the PCI core) is > preserved, the PCI core will be notified to allocate its tracking struct > (pci_ser). When the last file is unpreserved (i.e. preservation > cancelled) the PCI core will be notified to free struct pci_ser. > > This struct is preserved across a Live Update using KHO and can be > fetched by the PCI core during early boot (e.g. during device > enumeration) so that it knows which devices were preserved. > > Note: This commit only allocates struct pci_ser and preserves it across > Live Update. A subsequent commit will add an API for drivers to tell the > PCI core exactly which devices are being preserved. > > Note: There is no reason to check for kho_is_enabled() since it can be > assumed to return true. If KHO was not enabled then Live Update would > not be enabled and these routines would never run. > [...] > +/** > + * struct pci_dev_ser - Serialized state about a single PCI device. > + * > + * @domain: The device's PCI domain number (segment). > + * @bdf: The device's PCI bus, device, and function number. > + * @padding: Padding to naturally align struct pci_dev_ser. > + */ > +struct pci_dev_ser { > + u32 domain; > + u16 bdf; > + u16 padding; > +} __packed; > + > +/** > + * struct pci_ser - PCI Subsystem Live Update State > + * > + * This struct tracks state about all devices that are being preserved across > + * a Live Update for the next kernel. > + * > + * @max_nr_devices: The length of the devices[] flexible array. > + * @nr_devices: The number of devices that were preserved. > + * @devices: Flexible array of pci_dev_ser structs for each device. > + */ > +struct pci_ser { > + u32 max_nr_devices; > + u32 nr_devices; > + struct pci_dev_ser devices[]; > +} __packed; > + > +/* Ensure all elements of devices[] are naturally aligned. */ > +static_assert(offsetof(struct pci_ser, devices) % sizeof(unsigned long) == 0); > +static_assert(sizeof(struct pci_dev_ser) % sizeof(unsigned long) == 0); Minor Nit: Shall we consider using specific bitwidth types here? I'm wondering if down the line another u32 field is added to struct pci_dev_ser.. in that case on a 32-bit machine 12 % 4 == 0 but on a 64-bit machine 12 % 8 != 0.. [...] With the nit: Reviewed-by: Pranjal Shrivastava Thanks, Praan