From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 5ED54399351 for ; Mon, 8 Jun 2026 20:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780951870; cv=none; b=gbsTTrCgONS37ejbLfxyO13bGQwqHS5tgFV9DEQ5W04NGE0iYWRVX7y4/I+2pWFGJHeI+xZi+WZewyCm0rKfFqGIdQZRKoF4xur3Qla520bESlZaQXpenqfdi3wAoVOg7vtOBye9egWuOWmHz6Ik9m7+7Pdihge1kFIEYcP6BOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780951870; c=relaxed/simple; bh=RgrBSzRAxPq1hTiEITmRzTE416WdMM+7VkSjXwkwPk4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KeYmJE3j9lvzwa6ByWlgfo3N7yN1nl0tlrMrPOiuEKjDYQeFPnKrsS6F9K/BmM6oBfwj5lnRRZoRENQAcRCfOJ+Bx1rJkxp3Iy/ohrudTLXCPmkH5rs4ZsHBtqVMbyDdyarWpvQp8ZLnQr7Yxy+jNNlFWzqUzKthf1hgupMkDJA= 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=eZe/h+O/; arc=none smtp.client-ip=209.85.215.170 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="eZe/h+O/" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-c85a2c012e5so1648388a12.1 for ; Mon, 08 Jun 2026 13:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780951867; x=1781556667; 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=OqANBGSP00mnERvECbdyBZ/QnoUicIMj2Z9x9A+M1D8=; b=eZe/h+O/8Oa/XTt7FeXjKP9js+XVO8RqJQUg68yRxQTmgI50v+Q+NGutCCzPtthJL8 RqKn3xUkoNpsQtW8Tb1nqfEOWLd4dFgts1suLFyvf+baW7TKAlV3kiZBrj1OjcMe8TVm jqe2KHIm0dA60iVTjn10RS439nJYTL0Cf91F4+1QJUilaaxZQSf7RxDHySgniJI7aHAz s/xZV5L2ItrQyLc3RHU5+HL2RwdfzkscC2cP4HTC77zdEFMA+V/9OjsitA8OZtIesjo6 3o6MeQ9iNETHAHIYxu0qMgShoZGKtyQ+11xUo9fGe/nyA2ZMKqBzMMX3KL4oasN9H5GW RMrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780951867; x=1781556667; 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=OqANBGSP00mnERvECbdyBZ/QnoUicIMj2Z9x9A+M1D8=; b=eJKGQnVWc4zSy78eIJqbop0ZvP/5pNxFo6TVUVX36Rz5t+Te2C+uG2Stq+0rGiq9Z+ 3/B436CRISPW25fajhNHISOCDCGATO1k0JgJGH6JFmCoLDhsg1Jvd0m9Ac4Hsh6IDOpc cjOllOlIGLlpeFoiApZ9snRGgDOmq5tyaYzfOSbdVa/eqAbwQJnbegZo2Lxzm8rgsuKB nHX/Rep8SAUN/esN/5iEepZ6zX9RRA0XkTTa2eLjoud+U1OZRIIiBSsepWwLsZklkYte viAvFcjny7OtHgjlKdT2EhTsCzUcWMfnsOIIYNVSVEdiLy3q5FS74KJ/PSrir0amSQCX dRJg== X-Forwarded-Encrypted: i=1; AFNElJ+pPRNQjQevicNLWMK+2rp+V0apYwtA+lsBmNvhq6iK2P98DpSFZoxNEqxKwOWkAzTZzZ4LrM++BGsHW2U=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5ynHhP9PorF22XJnGKC3yqXZ3L/9Natf5IhpKFMQcdTpZYJff r9rdzW0Xt230bKL1V5ZGQ4+VfZ2PrAV4Ae1PmdWJWvUKCPXGgO5USHhhzK8Tqd4wnA== X-Gm-Gg: Acq92OF7GLnqa+586sfM6LirR+OuHZKr9nNLMaKT/ZMvMyyq47WZJJ6GJSV5T8s5IRR bQ2Ul5zv6U9FgjoOw391KKYKfBt3R3ylinNIfAqKrDDPNsD4t5FNifa2DsvWitlhWPyemasDIpI ee8QX5LM1BU62ZB/MIpy9cz/QUGPXntmNVHT8QR86DSPiyRYxl1WK0Jwin1gqHSZNeKLn/ZQ/mO VPXWQVxEzbRf+w6QrpUhuPSCbKmd9l+jTEOeUltLgCdk7wPdvn+PVU7GtFVOjGOd2AVvKuXK6xQ MEcYoj6LQ0kdHmYb2oXqY6hR18aoyC+yypxphELzMcjpkRJpie9FRvhnRZYw40acnnk5irzdB6O gd6p87CtqrVZCkWV+G7h1qGL40pDiQuC9HQBYgEd5VawpZDr51zR9LATOFkfebr/A2G0fU155Pe VpkO0AmfYlUC2Llo7Al07KsZhnrDfesppDovLNYY2MqsefLzzRTzqHZNTvGSDOSrLkiaALZnnb X-Received: by 2002:a05:6a21:a38b:b0:3b4:904f:c9cd with SMTP id adf61e73a8af0-3b4cccffc4fmr20088541637.6.1780951866181; Mon, 08 Jun 2026 13:51:06 -0700 (PDT) Received: from google.com (56.149.168.34.bc.googleusercontent.com. [34.168.149.56]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df0b315esm15840734a12.26.2026.06.08.13.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 13:51:04 -0700 (PDT) Date: Mon, 8 Jun 2026 20:51:00 +0000 From: David Matlack To: Pranjal Shrivastava 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: On 2026-06-05 05:41 AM, Pranjal Shrivastava wrote: > 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.. I think natural alignment is what matters for efficient access of the array elements. So failing the assert only on 64-bit architectures seems like the correct behavior. > > [...] > > With the nit: > > Reviewed-by: Pranjal Shrivastava > > Thanks, > Praan