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 A80E33E5A0B for ; Tue, 16 Jun 2026 22:38:09 +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=1781649492; cv=none; b=CsPBL/azAA8kax/Yqxc0aa56FHE+nHOQIdEoo+nB+hK6rjtxL5nOiJN+QfgIg1b35NCgLmTyCh9VS5TvISbuTltLPo+4n16Ak1CdObsBwRUB/unJ2MWFC83JgUmC+n/pBm/DJ3A3sr805eD5ONFJOMFjeYWu+3zw8NhpWUxIqyE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781649492; c=relaxed/simple; bh=SzOIf7pvTrhn5azy2CCHd4TxIzP64uBs5kiqdkjXq5o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nqk6RcC9+dLtzFlGIbDOU5s3gnI3w6xyF0XGIl7si01eyNh8PSPjPiSkAnURbSFi0tz2r5+wvXzg7IYTR4SOc8s/JA7JSeez8ZfpudGml8dpK+h/qxXejjSjlKSf+g3zFSCfwfKklQCzcfKhWqMBOHqToIbW+05IFXfUz+HXujk= 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=QK88VdTy; 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="QK88VdTy" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2c6b7bd4e8dso21655ad.0 for ; Tue, 16 Jun 2026 15:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781649489; x=1782254289; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=0bi42mNvv8zEfpJesfq39j8DzoTdUbmNl2yt46Rb57o=; b=QK88VdTyfjvr7670wdm65rCnPdX0HHkloz6bJLV/Vyw61jlA95IZ7cyBBT/8Oiklm9 gruRKLm128sd+MnvUQMvgyTtY9bNzimKv8ydKqs6DcsXz7uG2f6kYYrx0gSna+MiJmB5 OCUMe2QbWzNtdCj6aNLquZiM5BI+pwERtPXoz3TwcsSS3uMObjFa+nf9g9LKuKubSfTY wyto/xnkV/ivLb9xdgEJukuwSFT9ZnLAdhc/pnOHdbDLUUG70/capwRXAxo8K9pXTt8g jZjGYVi4Lnzgo25meQyTDwbVD9pmz1oGBl3BEDlEmtDe9rk3caPzwhHsN8n63plERuwi yUTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781649489; x=1782254289; h=in-reply-to:content-transfer-encoding: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=0bi42mNvv8zEfpJesfq39j8DzoTdUbmNl2yt46Rb57o=; b=gfuEQLMuQ9enC7PkLsV9shQ8Ppw7vjx6PM29w+1ElVZ0KLuGMdcKPAEmAwRIVZ/1mK tq82JDDU+6sBj/7Qa1+nHuPZ3atOSuk2E38aMREXxyPOiNvvOZZXleesez8NVZyT3e29 8pm910dLMkSKhpXAu24UIjGXlBygFZMJ/GRpRW/ibLGYX5h3CNwrp0SJUNQmm+ssNdEL l7jVCEPQ0/Ffatmt0Gh8IvDZftLNVA0Z88Le7gmlNs0+SuaOYdxe+0+/TYPwcTrnegxj qcgkXRiDe72NzMVfyqU+mE/kYP0e9WW1MOnYH0G7kslIeI5yZLrbRXfvuWTG9bCULOBI EkGw== X-Forwarded-Encrypted: i=1; AFNElJ8nD0td+GCqOQsdTwnIkwTDMZdqXI8BWjIf1Bv0Bq2eIedRRrqkYYTOCKa8Krvs4sc75Nnm+47UKmKJczc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyvts9h39+Nqe5UEeCFDymSnfxFIUYMthBlBksEUTWq5d9iMJ9a CUK4lVIz27V86XMo5pXagY+Umuql7eJDhWEIjAlpanP/4ztFil2GuvDdyIR1z4It0Q== X-Gm-Gg: AfdE7cnbNRj0LHsxO58qCRJdhOQPgYji0SV/LU0oQODpxjC7i91XCDYN+M7uN+sFFUV 41Dhwu8E0MzN4iqrcTKqPqNiT6bydsbmgwQMcI4yy8yHfO0Z71NEgjk0Jx8vYzpXBL4vdp9wn7h rMYcuVe5MI8JSzQ94ZnhrYN66Uskqyy3UQYeKQTkzYQbDa4ZDZhXA8NgFDgvrLyFgfdd8Go22Xa 3SLW89sw8HvH5zOIEY8HXXYqFm+fuxoPLThhqG8rCa2EIPqFtBz5Q1ydgV6+N7cj9aYgNREU3Am f8KTpcZNMblAs+6csbOgkeDxdCFB75mtJfbG5rrFrQNsCdSrKkLVYnnQXn/kOMNb4BrwAALXthD JqIElaxMZG83obQS6Emd7SEy4c4wVAxD2wDtLUeafMFcu3cHnDc+THyZV1pqfetDt0qpp6YkMx0 dbPhb5zw8doBFh2BbW9xQZCePVP8LI7/VVd2kWMel0idR1BJa+BoN4lTWDptyPRtWldXhanvlE1 M3l1cnmL5zLt8YIiF0= X-Received: by 2002:a17:903:289:b0:2bf:2e8c:db96 with SMTP id d9443c01a7336-2c6bd35b47fmr636505ad.5.1781649488392; Tue, 16 Jun 2026 15:38:08 -0700 (PDT) Received: from google.com (25.75.145.34.bc.googleusercontent.com. [34.145.75.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c42f2e5590sm159640205ad.14.2026.06.16.15.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2026 15:38:07 -0700 (PDT) Date: Tue, 16 Jun 2026 22:38:04 +0000 From: Samiullah Khawaja 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 , Pranjal Shrivastava , Pratyush Yadav , Saeed Mahameed , Shuah Khan , Vipin Sharma , William Tu , Yi Liu Subject: Re: [PATCH v6 03/12] PCI: liveupdate: Track incoming preserved PCI devices Message-ID: References: <20260522202410.3104264-1-dmatlack@google.com> <20260522202410.3104264-4-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=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jun 16, 2026 at 03:20:33PM -0700, David Matlack wrote: >On Tue, Jun 16, 2026 at 1:09 PM Samiullah Khawaja wrote: >> [snip] >> >> Hmm.. This is interesting, so the KHO state is freed and it cannot be >> reused. I see you already pointed out that we are putting an LUO policy >> to say that the retry is not allowed. >> >> But what should be the behaviour of liveupdate in this regard? Let the >> system boot in a normal way? This might break other subsystems as they >> might depend on PCIe restoring state properly. Also I think some of the >> PCIe state, like device-id, BAR addresses, ACLs etc, might be used as >> source of truth by other components. >> >> For example, lets say FLB retrieve() of PCIe fails, but succeeds for >> VFIO/IOMMU, now VFIO/IOMMU are restoring state of a device that is not >> restored/preserved? >> >> Should this be considered fatal? > >If PCI FLB retrieve fails then there are certain things that cannot be >guaranteed, such as BDF (B specifically) remaining constant. This >could lead to memory corruption as the IOMMU may have live >translations in place for those specific RequesterIDs. And, in the >future, preserved devices may be doing P2P which depends on BARs not >moving. If the PCI core cannot retrieve the FLB saved by the previous >kernel, it cannot make these guarantees. Yes, this is what I was worried about. > >So yeah I think you're right that PCI core should treat FLB retrieve >as fatal and just panic. This sounds great. > >> > } >> > >> > static void pci_flb_finish(struct liveupdate_flb_op_args *args) >> > { >> >- kho_restore_free(args->obj); >> >+ struct pci_flb_incoming *incoming = args->obj; >> >+ >> >+ xa_destroy(&incoming->xa); >> >+ kho_restore_free(incoming->ser); >> >+ kfree(incoming); >> > } >> > >> > static struct liveupdate_flb_ops pci_liveupdate_flb_ops = { >> >@@ -270,6 +335,91 @@ void pci_liveupdate_unpreserve(struct pci_dev *dev) >> > } >> > EXPORT_SYMBOL_GPL(pci_liveupdate_unpreserve); >> > >> >+static struct pci_flb_incoming *pci_liveupdate_flb_get_incoming(void) >> >+{ >> >+ struct pci_flb_incoming *incoming = NULL; >> >+ int ret; >> >+ >> >+ ret = liveupdate_flb_get_incoming(&pci_liveupdate_flb, (void **)&incoming); >> >+ >> >+ /* Live Update is not enabled. */ >> >+ if (ret == -EOPNOTSUPP) >> >+ return NULL; >> >+ >> >+ /* Live Update is enabled, but there is no incoming FLB data. */ >> >+ if (ret == -ENODATA) >> >+ return NULL; >> >+ >> >+ /* >> >+ * Live Update is enabled and there is incoming FLB data, but none of it >> >+ * matches pci_liveupdate_flb.compatible. >> >+ * >> >+ * This could mean that no PCI FLB data was passed by the previous >> >+ * kernel, but it could also mean the previous kernel used a different >> >+ * compatibility string (i.e. a different ABI). >> >+ */ >> >+ if (ret == -ENOENT) { >> >+ pr_info_once("No incoming FLB matched %s\n", pci_liveupdate_flb.compatible); >> >+ return NULL; >> >+ } >> >+ >> >+ /* >> >+ * There is incoming FLB data that matches pci_liveupdate_flb.compatible >> >+ * but it cannot be retrieved. >> >+ */ >> >+ if (ret) { >> >+ WARN_ONCE(ret, "Failed to retrieve incoming FLB data\n"); >> >> I think this should probably be considered fatal as mentioned above or >> the caller of this function should get an error so it can fail. I think >> retrievel of preserved state should generally not fail unless there is >> memory corruption or ABI is incompatible. > >Yeah. I think I will just call panic() here to cover all cases. We have an luo specific panic macro/function that you can use. luo_restore_fail() > >> >+ return NULL; >> >+ } >> >+ >> >+ return incoming; >> >+} >> >+ >> >> [snip] >> >+ >> >+static inline bool pci_liveupdate_is_incoming(struct pci_dev *dev) >> >+{ >> >+ return false; >> >+} >> > #endif >> > >> > #endif /* LINUX_PCI_LIVEUPDATE_H */ >> >-- >> >2.54.0.746.g67dd491aae-goog >> > >> >> Sami