[{"id":3680045,"web_url":"http://patchwork.ozlabs.org/comment/3680045/","msgid":"<20260421200609.GE1684602@rocinante>","date":"2026-04-21T20:06:09","subject":"Re: [PATCH v5 22/23] PCI/sysfs: Convert legacy I/O and memory\n attributes to static definitions","submitter":{"id":86709,"url":"http://patchwork.ozlabs.org/api/people/86709/","name":"Krzysztof Wilczyński","email":"kwilczynski@kernel.org"},"content":"Hello,\n\n> Currently, legacy_io and legacy_mem are dynamically allocated and\n> created by pci_create_legacy_files(), with pci_adjust_legacy_attr()\n> updating the attributes at runtime on Alpha to rename them and shift\n> the size for sparse addressing.\n> \n> Convert to four static const attributes (legacy_io, legacy_io_sparse,\n> legacy_mem, legacy_mem_sparse) with is_bin_visible() callbacks that\n> use pci_legacy_has_sparse() to select the appropriate variant per bus.\n> The sizes are compile-time constants and .size is set directly on\n> each attribute.\n> \n> Register the groups in pcibus_groups[] under a HAVE_PCI_LEGACY guard\n> so the driver model handles creation and removal automatically.\n> \n> Stub out pci_create_legacy_files() and pci_remove_legacy_files() as\n> the dynamic creation is no longer needed.  Remove the __weak\n> pci_adjust_legacy_attr(), Alpha's override, and its declaration from\n> both Alpha and PowerPC asm/pci.h headers.\n\nThere is feedback from Sashiko about this:\n\n  https://sashiko.dev/#/patchset/20260416180107.777065-1-kwilczynski%40kernel.org?part=22\n\nThis is a pre-existing issue that is does trip KASAN:\n\n  - Read successful; larger buffer.\n\n    root@kvm:~# dd if=/dev/zero of=/sys/class/pci_bus/0000:00/legacy_io bs=4 count=1 seek=32\n    1+0 records in\n    1+0 records out\n    4 bytes (4B) copied, 0.004042 seconds, 989B/s\n\n  - Splat; smaller buffer.\n\n    root@kvm:~# dd if=/dev/zero of=/sys/class/pci_bus/0000:00/legacy_io bs=1 count=1 seek=128\n    [  138.516163] ==================================================================\n    [  138.516843] BUG: KASAN: slab-out-of-bounds in pci_write_legacy_io+0x90/0xc8\n    [  138.517311] Read of size 4 at addr c29697b0 by task dd/37\n    [  138.517685] \n    [  138.518188] CPU: 0 UID: 0 PID: 37 Comm: dd Not tainted 7.0.0-rc1-g973e040579d6 #1 PREEMPTLAZY \n    [  138.518578] Hardware name: PowerMac3,1 7400 0xc0209 PowerMac\n    [  138.519019] Call Trace:\n    [  138.519165] [c2b8bbd0] [c12deee4] dump_stack_lvl+0x50/0x78 (unreliable)\n    [  138.519632] [c2b8bbf0] [c03f67e4] print_report+0x14c/0x514\n    [  138.519968] [c2b8bc50] [c03f646c] kasan_report+0x104/0x1d0\n    [  138.520288] [c2b8bcd0] [c0925e94] pci_write_legacy_io+0x90/0xc8\n    [  138.520624] [c2b8bcf0] [c0626cb4] kernfs_fop_write_iter+0x484/0x6cc\n    [  138.521003] [c2b8bd30] [c0419d1c] vfs_write+0x5fc/0x12f4\n    [  138.521299] [c2b8be60] [c041aeac] ksys_write+0x120/0x244\n    [  138.521605] [c2b8bf00] [c001d218] system_call_exception+0x14c/0x304\n    [  138.521976] [c2b8bf30] [c002b1bc] ret_from_syscall+0x0/0x2c\n    [  138.522317] ---- interrupt: c00 at 0x100a59f4\n    [  138.522695] NIP:  100a59f4 LR: 101005e4 CTR: b7bf44a0\n    [  138.523013] REGS: c2b8bf40 TRAP: 0c00   Not tainted  (7.0.0-rc1-g973e040579d6)\n    [  138.523413] MSR:  0000d932 <EE,PR,ME,IR,DR,RI>  CR: 28004462  XER: 00000000\n    [  138.524028] \n    [  138.524028] GPR00: 00000004 bfbff210 1027d520 00000001 102795a0 00000001 10277237 100a4ac4 \n    [  138.524028] GPR08: 0000d932 00000002 00000000 bfbff2c0 b7bf0000 102790b2 10230000 10226faa \n    [  138.524028] GPR16: 10237d81 00000000 00000000 102795a0 102795a0 00000000 1027721f 00000001 \n    [  138.524028] GPR24: 00000001 00000000 10271500 10270000 00000000 00000001 102795a0 00000001 \n    [  138.526014] NIP [100a59f4] 0x100a59f4\n    [  138.526264] LR [101005e4] 0x101005e4\n    [  138.526500] ---- interrupt: c00\n    [  138.526740] \n    [  138.526913] Allocated by task 37 on cpu 0 at 138.516066s:\n    [  138.527334]  kasan_save_track+0x3c/0x90\n    [  138.527572]  __kasan_kmalloc+0xb8/0xec\n    [  138.527816]  kernfs_fop_write_iter+0x55c/0x6cc\n    [  138.528076]  vfs_write+0x5fc/0x12f4\n    [  138.528269]  ksys_write+0x120/0x244\n    [  138.528472]  system_call_exception+0x14c/0x304\n    [  138.528688]  ret_from_syscall+0x0/0x2c\n    [  138.528950] \n    [  138.529108] The buggy address belongs to the object at c29697b0\n    [  138.529108]  which belongs to the cache kmalloc-8 of size 8\n    [  138.529673] The buggy address is located 0 bytes inside of\n    [  138.529673]  allocated 2-byte region [c29697b0, c29697b2)\n    [  138.530173] \n    [  138.530318] The buggy address belongs to the physical page:\n    [  138.531001] page: refcount:0 mapcount:0 mapping:00000000 index:0x0 pfn:0x2969\n    [  138.531454] flags: 0x0(zone=0)\n    [  138.532076] page_type: f5(slab)\n    [  138.532520] raw: 00000000 c1c01300 00000122 00000000 00000000 005500aa f5000000 00000000\n    [  138.533046] page dumped because: kasan: bad access detected\n    [  138.533372] \n    [  138.533496] Memory state around the buggy address:\n    [  138.533955]  c2969680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n    [  138.534328]  c2969700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc\n    [  138.534693] >c2969780: fc fc fc fc fc fc 02 fc fc fc fc fc fa fc fc fc\n    [  138.535066]                              ^\n    [  138.535358]  c2969800: fc fc fa fc fc fc fc fc fa fc fc fc fc fc 04 fc\n    [  138.535661]  c2969880: fc fc fc fc 00 fc fc fc fc fc fa fc fc fc fc fc\n    [  138.536058] ==================================================================\n    [  138.537335] Disabling lock debugging due to kernel taint\n    1+0 records in\n    1+0 records out\n    1 bytes (1B) copied, 0.023071 seconds, 43B/s\n\nSomething to fix as a follow-up.\n\nThank you!\n\n\tKrzysztof","headers":{"Return-Path":"\n <linuxppc-dev+bounces-19914-incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=PLk8TvvJ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19914-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=172.234.252.31","lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=PLk8TvvJ;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=172.234.252.31; helo=sea.source.kernel.org;\n envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0YJm4q7qz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:06:15 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4g0YJk5JVdz30Wg;\n\tWed, 22 Apr 2026 06:06:14 +1000 (AEST)","from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4g0YJj3L7Mz30WX\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 22 Apr 2026 06:06:13 +1000 (AEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 39DF443AF0;\n\tTue, 21 Apr 2026 20:06:11 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id AC9ACC2BCB0;\n\tTue, 21 Apr 2026 20:06:10 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776801974;\n\tcv=none;\n b=OuRw4IVGz6vE34xxujygN7OvJ7/tuUexIxTtcsxxsa8BhFnPoTwSSo2gNDfN+OEtH5CTblTkxlXrNtB+heGVsa64rYgGoP0GyhHS2mJcR2J4O+uQGkOdPvVtHNTKYBg4yfr6AGzDp+nT4TmouB9+zmcqYBglxQpLVLSpjbu4kL2Rjo18Az26vCRo7bXTHtRfY0MDWam4cj+KgjhmikM4YaO4L/Jl9e593P+mCJC7CE01ngVn8yjYSW/ubwLnDgFs7SRgaurRAgECb/IrHquo94SHo92OfWiw/RQePh3df4bWgv2ei+vds2AK3hGK818JbfBn9L6q568VuvJrNSmVKg==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1776801974; c=relaxed/relaxed;\n\tbh=PtN4PZJC/OcIb74YuUiIqpdcEcsYergNC0G0dv1+pOA=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=D2OESU2BZYqdHZjlZVSAnPr04Kjnub0ApVrJlYrhK/p5s/6BuBE2+8y7l/aOYGZ2rVMnXKgt6JLrqxHSWwJzCw7oiigB0Qdqv3qmF6dVP4HcHF7dUFOoCoDE3xS5LYO4vxPcgJzkUsiUrM23Y806fZEJNeDxHNbVnItCufqQRwAv+kPl6O9xLIj+AJIi8X9cCd6fpy2MELF9iyXBpNHEimtqbP/cZQJcN+iYom/GWuPcCWdjKkBDyKyjIbKZ4DjeNg2Gj/ADhGHZY9c9gtbzY/RISyXmxZzZKipL+l/Tkz1J/osfCnwf3prFAnVZ2jaD0mrO+oUEV9DXA2q7PbBrJw==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=PLk8TvvJ; dkim-atps=neutral;\n spf=pass (client-ip=172.234.252.31; helo=sea.source.kernel.org;\n envelope-from=kwilczynski@kernel.org;\n receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776801971;\n\tbh=zLaqEY2AdfsU2z/D1pNc/O8p+28fE6XTfonBYfspxZc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PLk8TvvJWIBLYMgP5fE2xmhBa2sDysetrsKMet0ZyBqA4TLBhTuhOrlV6iENIIWdR\n\t 9MV2DnzdojJcU3BaEzpZCq2nUisl1jhVxlquirkUp8NXpn/65Tey1NbkfAf0MoQRcv\n\t BpBJ4xsWX8UfXeTe08QMZri30FLYvVkHL44G4R3Hm2kTuyCO6FGLT0kmyUuMmo9qzC\n\t eHkN1fzraxOPfgFp/hQv5mF0ZAen36o18ZcP+xAqjQw9i1L1JMGfMochPPfqEaOKtP\n\t Z4t34hSHUtGQudYD+6ZGVOL5oHNDy5g84MtN1dY3ENmO/ZjzYdaXdh/GgRcBd6KaOs\n\t fKtSFqf6yTcTA==","Date":"Wed, 22 Apr 2026 05:06:09 +0900","From":"Krzysztof =?utf-8?q?Wilczy=C5=84ski?= <kwilczynski@kernel.org>","To":"Bjorn Helgaas <bhelgaas@google.com>","Cc":"Bjorn Helgaas <helgaas@kernel.org>,\n Manivannan Sadhasivam <mani@kernel.org>,\n Lorenzo Pieralisi <lpieralisi@kernel.org>,\n Magnus Lindholm <linmag7@gmail.com>, Matt Turner <mattst88@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Christophe Leroy <chleroy@kernel.org>,\n Madhavan Srinivasan <maddy@linux.ibm.com>,\n Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>,\n Dexuan Cui <decui@microsoft.com>,\n Krzysztof =?utf-8?q?Ha=C5=82asa?= <khalasa@piap.pl>,\n Lukas Wunner <lukas@wunner.de>, Oliver O'Halloran <oohall@gmail.com>,\n Saurabh Singh Sengar <ssengar@microsoft.com>,\n Shuan He <heshuan@bytedance.com>, Srivatsa Bhat <srivatsabhat@microsoft.com>,\n Ilpo =?utf-8?b?SsOkcnZpbmVu?= <ilpo.jarvinen@linux.intel.com>,\n linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org,\n linuxppc-dev@lists.ozlabs.org","Subject":"Re: [PATCH v5 22/23] PCI/sysfs: Convert legacy I/O and memory\n attributes to static definitions","Message-ID":"<20260421200609.GE1684602@rocinante>","References":"<20260416180107.777065-1-kwilczynski@kernel.org>\n <20260416180107.777065-23-kwilczynski@kernel.org>","X-Mailing-List":"linuxppc-dev@lists.ozlabs.org","List-Id":"<linuxppc-dev.lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev+help@lists.ozlabs.org>","List-Owner":"<mailto:linuxppc-dev+owner@lists.ozlabs.org>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Archive":"<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Subscribe":"<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>","List-Unsubscribe":"<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>","Precedence":"list","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260416180107.777065-23-kwilczynski@kernel.org>","X-Spam-Status":"No, score=-0.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"}}]