From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2852836196C; Wed, 5 Aug 2026 21:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785966009; cv=none; b=aLTWOl2zbRaJUSBELwmnhohvDnrbkPzxGZHem8BOsGurCGRtrk1w5KCyo4Xi2xEceTl56y580AobdeMNPLyd9ZmXwMb/QoAYxsSGKTyAAsAaL5nMdd7y1Gcrw7mfnYsww7zNKG7tpQdGBlnha/o0tLTKl6GReRYKmxOK/UFjNsk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785966009; c=relaxed/simple; bh=IH1mds9i04KMXx1v2FBvcb/ofb0ez7o11nT1Dg+yRqA=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=VJsps6CZj1If8K5JC9lIDhqA7y5FNaghlsIIT5jp7yJPEllANa5o5ZmsxoTL0CxNB7nuYeGxlMzY6oKsAQ4xMIKwjfcrugXJJIPP3fOjbpU9UKOaFUBnmlh98bcYLTcJjsxovgoVVG4EHBRgu2FuUUrXjWW9KV4jykDuTCxRpGQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=PmTZCmOd; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=iHBtt4xu; arc=none smtp.client-ip=202.12.124.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="PmTZCmOd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="iHBtt4xu" Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfhigh.stl.internal (Postfix) with ESMTP id 2D6927A00D3; Wed, 5 Aug 2026 17:40:05 -0400 (EDT) Received: from ams-imap-03 ([10.64.2.23]) by ams-compute-02.internal (MEProxy); Wed, 05 Aug 2026 17:40:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1785966004; x=1786052404; bh=oYApZU2ZObPMUCR6FXXUpKhTnmwws91LKg3O/fOuaXM=; b= PmTZCmOdhsjVlstN+u/VLJfX7+q+NueJW2Gxg3M+dXpAAx4WFgOQNaanTVFlzSnQ qlICIt0EVLO6PDUA10ngQ7TTrAGH7K7qAWQAqQQMm4o+wu8VZ1LeLEnaLUGKt14v 0EjCW1LpjGfp45o6TsiUxdNZUxfkHJ4xzOaQorSA9Hd+38WDaIXd9VsBwPOmTQU6 mcXypBEqVZw6Ufu/r+yWpBu/NEcsw2LpIlBIn5V92TH6mdSuhWVUc0v0iAduTbJm buj20hBorwbXuIf/pj2rvmewh5/3mfo81K2bOe3T+cDtZWmtbE2elXpzu2IwOlwW M6kEX8Xatdaqrvr8AXmMMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1785966004; x= 1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zHPV8tG6P/88AGwRM1t7FIMEMGUKTg8uIhXpTVpgXQ X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id C336B32A0062; Wed, 5 Aug 2026 17:39:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: A0yYJuUxkgs3 Date: Wed, 05 Aug 2026 23:39:35 +0200 From: "Arnd Bergmann" To: "Danilo Krummrich" , "Greg Kroah-Hartman" , "Rafael J . Wysocki" , "Alice Ryhl" , "Daniel Almeida" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Tamir Duberstein" , acourbot@nvidia.com, =?UTF-8?Q?Onur_=C3=96zkan?= Cc: driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <9fbff830-d1b3-428b-b7b2-205eff41b6d5@app.fastmail.com> In-Reply-To: <20260805212920.1996937-1-dakr@kernel.org> References: <20260805212920.1996937-1-dakr@kernel.org> Subject: Re: [PATCH v2 1/2] rust: io: gate ioremap/iounmap on CONFIG_HAS_IOMEM Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, Aug 5, 2026, at 23:28, Danilo Krummrich wrote: > s390 does not provide ioremap()/iounmap() when CONFIG_HAS_IOMEM is not > set (which requires CONFIG_PCI on that architecture). This causes a > build failure with Rust enabled on e.g. s390 allnoconfig: > > In file included from rust/helpers/helpers.c:68: > rust/helpers/io.c:8:9: error: call to undeclared function 'ioremap'; > ISO C99 and later do not support implicit function declarations > [-Wimplicit-function-declaration] > 8 | return ioremap(offset, size); > | ^ > rust/helpers/io.c:19:2: error: call to undeclared function 'iounmap'; > ISO C99 and later do not support implicit function declarations > [-Wimplicit-function-declaration] > 19 | iounmap(addr); > > Guard the C helpers behind #ifdef CONFIG_HAS_IOMEM and cfg-gate the Rust > io::mem module, such that IoMem, ExclusiveIoMem and IoRequest are not > available without CONFIG_HAS_IOMEM. > > Note that the C API is inconsistent about this. For instance, > devm_ioremap() has no stub and produces a link failure without > CONFIG_HAS_IOMEM, whereas devm_platform_ioremap_resource() provides an > inline stub returning -EINVAL. > > The approach taken here (compile-time gating) matches the former, which > is slightly more appropriate since any driver performing MMIO currently > requires CONFIG_HAS_IOMEM. > > Ideally, s390 should provide ioremap()/iounmap() stubs unconditionally > (as UML already does), removing the need for any config gating as > discussed in [1]; a follow-up patch for s390 is expected. > > Cc: Arnd Bergmann > Reported-by: Miguel Ojeda > Closes: https://lore.kernel.org/all/20260803180931.97202-1-ojeda@kernel.org [1] > Fixes: 3f70ebe63858 ("s390: Enable Rust support") > Signed-off-by: Danilo Krummrich Looks good to me overall. Reviewed-by: Arnd Bergmann One question: > } > +#endif /* CONFIG_HAS_IOMEM */ > > __rust_helper u8 rust_helper_readb(const void __iomem *addr) Can you also hide the actual I/O accessors in this case? While s390 without CONFIG_PCI still provides the asm-generic version of those, that is technically a mistake, and it would be nice not to. I'm guessing that there is enough kernel code that still expects these to be present for C, but if all rust code has the correct HAS_IOMEM dependencies, it would be cleaner not to reference since there is no correct way to call them without ioremap(). Arnd