From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410410; b=FWrWypCbQ9zsLJdkzjvjmjbBuC7wwXD4Tv6dYqJoyKcHDvk9n+sd2k97d/438p503yt2 1d1nFJz1ZEaPWWDfHArjvogqSlNAAqLoI3Xr4ZwZy15gmG8Y/wSAhRu4qm93nMkT0Giw3 L6C5O3XVzNzOnirOdO3Xs9+e/5lUQpgD8GwCGMYtcHlEPaakWKujjgJV8HQ4xBOR71f3i YrLRsKjh4nXlQjdcBi9xcOjpZefuZ80O8buhK66AF3uwrj/buw7Dvl3MtZfCxJATG6cQA b3ijgIXKpQrjBUcuiWE/eZMbAvvY07EBHETPd4913c160D25QGek1lRtpSlhXKehNKA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410410; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=uZreAMLsZ9bpCXgNLEewgX1bvM96ro3qYVlZtTw/ZNE=; b=ZgS5xbzEfCnm9/unnzO3UFIr/EplTMxZAF97hrt98suRk+uSg0bnfYcEWgC1hL+9DgNi Ujdef1ivxdVApE3Mvt/YhaThWwfdt3GU1u9TxBlSUS4NTLlnCStxM3f6pgJoOLx60EnGY 0OId760jVVVGctPAypC7qE+1XBtbHs+X7Y+VRb9O2fNbPwjc7b3Ud5Fo7sMNF/HSoB5/2 EpMmZf2lqelTZ23EkoRXAcJ43l0UKtdvqCE6FpML9dxSL2DPiYxS8u9ikOfyQPkc0ifXa 7fgexxz/XNdkfV4PAMCuvyKjgmH+u4+q7RqvGzJYnBbIhgp6IciUoxlChpSh8qRjC9A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VOu7mMH0; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1ACC606A330 for ; Fri, 4 Dec 2026 18:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VOu7mMH0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 803F21F0093B; Fri, 4 Dec 2026 18:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796410410; bh=uZreAMLsZ9bpCXgNLEewgX1bvM96ro3qYVlZtTw/ZNE=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=VOu7mMH0W5SjY6/eDQ8KWBTTUyGT86Pqjo01X8Y4VB0YLBAS56pqh+MFHj6Iwz/rb C4xUEUR2m2Udnx2eg5yiYTTKCo7r62LLTk5aAWoBz6vSgWT98H5vgKW/U6540Mu7hn tvnYlcxwkkNczaGCP44AGJHifPDL/pNs6vCYViq2ld1RYwYUMQpznlXmjrmStzhfz2 ZRbRRtifuXP27NQLni2U0qvAQydradx8ez5vyyYS76lEZIktYVchSm23v02CfXOd77 wL4R6US5whi7vxYjXTUJj4+eifL5yR8AgVOH91jNSUWwIqJjaH+9oIbh59TUz8AcM2 JT9KDAV3+mnSw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 6/6] PCI/FLIT: Manage Flit Logging on Endpoint Upstream Ports Reply-To: sashiko-reviews@lists.linux.dev To: "Yazen Ghannam" , linux-pci@vger.kernel.org In-Reply-To: <20261204181556.1418843-7-yazen.ghannam@amd.com> References: <20261204181556.1418843-1-yazen.ghannam@amd.com> <20261204181556.1418843-7-yazen.ghannam@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:53:30 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 7 potential issues to consider: - [High] vfio/pci: host-managed Endpoint Flit Logging capability left raw RW - [Medium] PCI/FLIT: aer_root_reset() clears PCI_ERR_ROOT_STATUS without re-arming Flit - [Medium] PCI/FLIT: pci_flit_init() enables ERR_COR before bus->devices insertion - [Medium] PCI/FLIT: pci_flit_init() ignores pcie_ports_disabled on non-ACPI hosts - [Medium] PCI/FLIT: flit_report() emits unratelimited pci_warn() in drain loop - [Medium] PCI/FLIT: pci_flit_rearm() accesses config space of D3cold Endpoints - [Medium] PCI/FLIT: aerdriver lacks runtime_resume to re-arm ERR_COR Flit counters -- commit 3b2b4ec344229286e14d4e998c43a9ee5c0536f6 Author: Yazen Ghannam PCI/FLIT: Manage Flit Logging on Endpoint Upstream Ports This commit extends pci_flit_init() to manage the Flit Logging Extended Capability on PCIe Endpoints when ERR_COR signaling is usable, leaving other Endpoints untouched. > diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c > index 83a6b50221ef1..050360295f2f7 100644 > --- a/drivers/pci/pcie/flit.c > +++ b/drivers/pci/pcie/flit.c [ ... ] > @@ -229,7 +244,8 @@ void pci_flit_init(struct pci_dev *pdev) > u16 trigger; > u32 ctrl; > =20 > - if (!flit_is_port(pdev) || !flit_is_native(pdev)) > + if (!(flit_is_port(pdev) || flit_is_endpoint(pdev)) || > + !flit_is_native(pdev)) > return; [Severity: High] Does vfio-pci leave the host-managed Flit Logging capability registers directly writable by an assigned guest? PCI_EXT_CAP_ID_FLIT is missing from pci_ext_cap_length[] in drivers/vfio/pci/vfio_pci_config.c, so vfio_ecap_init() leaves its registers unmapped (PCI_CAP_ID_INVALID) in vdev->pci_config_map. vfio_pci_config_rw_single() then routes accesses to unassigned_perms, allowing raw hardware reads and writes. An untrusted guest assigned a Flit-capable Endpoint can lower the trigger threshold to 1 to amplify host ERR_COR interrupts and kernel warnings, set PCI_FLIT_ERR_CNTR_CTRL_SIG_SFW_EN to redirect events to host firmware, or disable host Flit monitoring. Adding PCI_EXT_CAP_ID_FLIT to pci_ext_cap_length[] and vfio_ext_cap_len() would map the capability under default read-only ecap_perms. [Severity: Medium] Should flit_is_native() or flit_err_cor_usable() check pcie_ports_disabled? On non-ACPI hosts where pcie_ports_disabled is true (such as PowerNV, where pnv_pci_init() sets it unconditionally for EEH, or DT hosts booted with pcie_ports=3Dcompat), pci_init_host_bridge() still sets native_aer and native_flit, and pci_aer_available() does not check pcie_ports_disabled. pci_flit_init() therefore enables ERR_COR signaling on Endpoints and Ports even though pcie_portdrv_init() aborts and no AER driver ever binds to service the generated ERR_COR messages. [Severity: Medium] Can aer_enable_rootport() access config space on a D3cold Endpoint via pci_flit_rearm() during system resume? Unlike pcieport devices, a runtime-suspended Endpoint in PCI_D3cold can skip pci_pm_resume_noirq() via direct_complete or DPM_FLAG_MAY_SKIP_RESUME (for example amdgpu with BOCO). When dpm_resume() runs aer_resume() -> aer_enable_rootport() on the Root Port, flit_rearm_iter() unconditionally calls pci_flit_rearm() -> flit_service() on subordinate Endpoints. flit_service() then issues config reads and unchecked read-modify-write config writes to the powered-off Endpoint right after aer_enable_rootport() clears Root Port AER status and before aer_enable_irq(), which can latch Unsupported Request completions and trigger spurious AER errors on resume. Skipping pci_flit_rearm() when pdev->current_state !=3D PCI_D0 would avoid touching powered-off Endpoints. [Severity: Medium] What re-arms ERR_COR Flit Error Counters after a Root Port runtime-resumes from D3hot? When an unbound Endpoint runtime-suspends, pci_pm_runtime_suspend() leaves it in D0 with its Flit Error Counter active, allowing the parent Root Port to enter D3hot. If the Endpoint triggers an ERR_COR while the Root Port is in D3hot, PCI_ERR_ROOT_STATUS latches the event without delivering an interrupt. On Root Port runtime resume, pci_pm_runtime_resume() -> pci_restore_state() -> pci_aer_clear_status() clears PCI_ERR_ROOT_STATUS, discarding the pending ERR_COR. Because aerdriver has no .runtime_resume callback to invoke pci_flit_rearm() and pci_restore_flit_state() does not clear status or toggle Counter Enable, the Endpoint's Flit Error Counter stays permanently silent until a full system suspend/resume. > @@ -247,6 +263,12 @@ void pci_flit_init(struct pci_dev *pdev) > info->cntr_cap =3D flit_read_cntr_cap(pdev); > info->err_cor =3D flit_err_cor_usable(pdev); > =20 > + /* Leave an Endpoint without ERR_COR as found */ > + if (!info->err_cor && flit_is_endpoint(pdev)) { > + pci_flit_exit(pdev); > + return; > + } > + > spin_lock_init(&info->lock); > mutex_init(&info->service_lock); [Severity: Medium] Does aer_root_reset() need to call pci_flit_rearm() after clearing PCI_ERR_ROOT_STATUS? aer_root_reset() disables AER IRQs on root, resets the device or link, unconditionally clears PCI_ERR_ROOT_STATUS, and re-enables AER IRQs without calling pci_flit_rearm() on root or its subordinate hierarchy. If a Flit Error Counter on root, a sibling Endpoint under the same root, or the retrained link triggers an ERR_COR while AER IRQs are masked, clearing PCI_ERR_ROOT_STATUS discards it. Endpoints have no flitdriver slot_reset callback, so the ERR_COR Generated status bit remains latched and the counter stays permanently silent. [Severity: Medium] Can a hotplugged Endpoint lose its first Flit ERR_COR if it fires before pci_device_add() inserts the device onto bus->devices? CPU0 (hotplug) CPU1 (Root Port AER) pci_device_add() pci_init_capabilities() pci_flit_init() flit_cntr_enable() pci_doe_init() / ... aer_irq() clear PCI_ERR_ROOT_STATUS aer_isr() find_source_device() pci_walk_bus() <-- dev not listed list_add_tail(&dev->bus_list, &bus->devices) pci_flit_init() enables the ERR_COR counter inside pci_init_capabilities(), before dev is added to bus->devices. Under an already-probed Root Port, aer_enable_rootport() does not run again for a hotplugged Endpoint, so a missed ERR_COR leaves ERR_COR_GEN latched and the counter permanently silent. Enabling or re-arming the ERR_COR counter after list_add_tail(&dev->bus_list, &bus->devices) would close this window. [Severity: Medium] Is flit_report() missing ratelimiting in the drain loop? flit_drain_log() can call flit_report() -> pci_warn() up to FLIT_MAX_LOG_ENTRIES (255) times per ERR_COR event before flit_service() immediately re-arms the counter. In aer_process_err_devices(), pci_flit_handle_err_cor() is also called without checking e_info->ratelimit_print[i], bypassing AER's per-device ratelimiting. On a degrading link or malfunctioning Endpoint, repeated Flit ERR_COR events can flood the kernel log buffer and stall serial consoles. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204181556.1418= 843-1-yazen.ghannam@amd.com?part=3D6