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=1796104145; b=aEjS13gxs4ND06/bqqjjd4ZM8reAGSvrbxoT1p13BXQxl3ddQBajd/DsHXckuniwHrzz lFy0iQj0lispcWB+37AKH4osvlXCiCWrGodaqmhsKpHEHmijBsqjXJDz6p/8HD6EGAYTz Ohrw9QNH9kC+7MC+jyb3d4oMLDKe8aZQn3dFQIhE9DHvbKcqh1Y1sa5YAQIulKJvHiGwW BeFrR/hBRwEkVK42nvZVDVgHNtDESgPqCcmjfguAITgI31BJZwqDyjxKr+xbCsJM6xyB6 Nq5Xw/9GrYAcRjVthB7QST7dWXaDtnM5pYbzQBJWMC0qEIWlD8pkv1iDth8avWXBusw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796104145; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=UC0Wr9WJGcgYUsPPrdssn4zyLNhgHlzcpao+1eE9dhE=; b=Kd2tF0WJIo8QMfRGGmM3WZIk6/41x9mcGYF4oicGmePM2jqCKQfVhEiQxU0YchLxJvVL KWFFlFWO6mp7iZap91YdsBMLKuz4C8w7Mxz+AS3YqPWYdYmDzBrhX9Axy4hBCjNUjXMuP ykhesG5FnQ4JHqAvU6PZ2riHliDABGdoLnJn5G091U3S3lefapPycGqtYpUuB7t+uUxHU 950l+Bn8YnPz/Lr9ZrVYZpePg2Hqg7hIwH4cW6+GeL6YTdYEVuXE1bCX6uR98tmct/m6Y qmsrhS5MzCcIUpZc+ioE7bfWlgs45GmJsZQ4XywpbytCsNnsWb1ydX/RHYuJiuXkaNQ== 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=WloAjciy; 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 485B3606A332 for ; Tue, 1 Dec 2026 05:49:05 +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=WloAjciy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1092C1F00897; Tue, 1 Dec 2026 05:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796104145; bh=UC0Wr9WJGcgYUsPPrdssn4zyLNhgHlzcpao+1eE9dhE=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=WloAjciyhf6kRWDFhMt7UuPN5F4+qVQ+XQHDSxrXbenKhC8rBuRI+SOkjwo71xsOM jWg+SEHMpXgL3TJfS3fET63b5fdznVfLUq8vT4xuxD/PC3TiGkjwj/8cZCvZBhaDZ8 jtFtZEgL31j/cJoDfud8t4QpRPRjL2QdvOqzYWv37AUYGQD8xZC3gsFL2XSyu5Hb7X oPCCQ4oYguQ6jxPQr4cgdhLI55a0FMAIJlVuI3dvU6w+AYtkj/t+5MjDpR3wOtPgzj BgvjEw7JtFllJWnejcDq5vgciZBKN8z1ayFJPOceReQ7fQ7lFoCRQdVhUZyF1404gr rFf4W//Q+FJQA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] pci: Prefer MMCONFIG for all config space accesses if available Reply-To: sashiko-reviews@lists.linux.dev To: "Josh Triplett" , linux-pci@vger.kernel.org In-Reply-To: <4b37c09a330f78db0ac3265a9b8e278d1d7d6f1c.1796103197.git.josh@joshtriplett.org> References: <4b37c09a330f78db0ac3265a9b8e278d1d7d6f1c.1796103197.git.josh@joshtriplett.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 05:49:04 +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 1 potential issue to consider: - [Medium] x86/pci: 32-bit pci_mmcfg preference adds fixmap TLB flushes under lock -- commit ed763afa39424e0a8e5b03379200b33b56222587 Author: Josh Triplett pci: Prefer MMCONFIG for all config space accesses if available This commit updates raw_pci_read() and raw_pci_write() on x86 to prefer MMCONFIG (pci_mmcfg) even for the first 256 bytes of PCI config space, with a quirk disabling this on AMD K8 systems and a pci=3Dno_prefer_mmconf boot parameter. > diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c > index 63105b29fbf54..5ad2f108686ec 100644 > --- a/arch/x86/pci/common.c > +++ b/arch/x86/pci/common.c [ ... ] > @@ -40,9 +43,20 @@ const struct pci_raw_ops *__read_mostly raw_pci_ext_op= s; > int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int dev= fn, > int reg, int len, u32 *val) > { > + bool tried_mmconf =3D false; > + > +#ifdef CONFIG_PCI_MMCONFIG > + if (!pci_no_prefer_mmconf && raw_pci_ext_ops =3D=3D &pci_mmcfg) { > + int ret =3D raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); > + > + if (ret !=3D -EINVAL) > + return ret; > + tried_mmconf =3D true; > + } > +#endif > if (domain =3D=3D 0 && reg < 256 && raw_pci_ops) > return raw_pci_ops->read(domain, bus, devfn, reg, len, val); > - if (raw_pci_ext_ops) > + if (!tried_mmconf && raw_pci_ext_ops) > return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); > return -EINVAL; > } > @@ -50,9 +64,20 @@ int raw_pci_read(unsigned int domain, unsigned int bus= , unsigned int devfn, > int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int de= vfn, > int reg, int len, u32 val) > { > + bool tried_mmconf =3D false; > + > +#ifdef CONFIG_PCI_MMCONFIG > + if (!pci_no_prefer_mmconf && raw_pci_ext_ops =3D=3D &pci_mmcfg) { > + int ret =3D raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); > + > + if (ret !=3D -EINVAL) > + return ret; > + tried_mmconf =3D true; > + } > +#endif > if (domain =3D=3D 0 && reg < 256 && raw_pci_ops) > return raw_pci_ops->write(domain, bus, devfn, reg, len, val); > - if (raw_pci_ext_ops) > + if (!tried_mmconf && raw_pci_ext_ops) > return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); > return -EINVAL; > } [Severity: Medium] Should preferring pci_mmcfg for base config space be restricted to 64-bit x86? On 32-bit x86, pci_mmcfg is not lockless and does not keep ECAM regions permanently mapped. Instead, pci_mmcfg_read() and pci_mmcfg_write() walk pci_mmcfg_list under RCU, take pci_config_lock, and multiplex a single FIX_PCIE_MCFG fixmap slot across all devices and CPUs: arch/x86/pci/mmconfig_32.c:pci_exp_set_dev_base() { u32 dev_base =3D base | PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12); int cpu =3D smp_processor_id(); if (dev_base !=3D mmcfg_last_accessed_device || cpu !=3D mmcfg_last_accessed_cpu) { mmcfg_last_accessed_device =3D dev_base; mmcfg_last_accessed_cpu =3D cpu; set_fixmap_nocache(FIX_PCIE_MCFG, dev_base); } } During PCI enumeration or interleaved config accesses across devices or CPUs on CONFIG_X86_32, routing reg < 256 through pci_mmcfg still serializes on pci_config_lock while adding a PTE write and TLB flush via set_fixmap_nocache() whenever the target device or CPU changes. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/4b37c09a330f78db0ac= 3265a9b8e278d1d7d6f1c.1796103197.git.josh@joshtriplett.org?part=3D1