Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3139644rdb; Sat, 9 Dec 2023 13:06:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7FxufYCSczN8OVCCpkgRGbg0Y7/xRhNKta8Fmh8Q8wR/NknYiFS2uav9jmlZYS+eYZO+D X-Received: by 2002:a17:902:e5c5:b0:1d0:700b:3f77 with SMTP id u5-20020a170902e5c500b001d0700b3f77mr3827240plf.49.1702155980340; Sat, 09 Dec 2023 13:06:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702155980; cv=none; d=google.com; s=arc-20160816; b=gE24i4JUelhbSNDEfxvsjx3RCazkHZYFlhpMgfMDh4VnveMeN6Vq2A0iIQoSp+I78E 9NuKzJTVMAAEE8ZGZU+bIml+7I7OXr+1ZSWJizyJsqsLNT8Ecm0RBKhIm9uwQ5i4PwGF KqPEx0kv2XUus5S4bRSC34d8gzxo3QY/cQOY/1TKsRxVo+TOyf7ur2uAZZgJVY9oSw9X 0ipCRBuomn51EyLVW6H+OmAiMuR1kdsuBmFRpQQMyXlbMcnBPD5G5L4xRjA7jvsImWaG LnRDkdKogbOYLiuc+IocldlnwH/NBn35O+87YWPFRxDJoEn6+cFfeG04SyiO5H39dhFN vakA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JGdm/SInpYuSkBQOnpcnQXaOmoQNJJOyQqfUb9ghY7s=; fh=+L4iH9pb27ebFP4IspWfQkiKmpROcx1iZ1w7qKd164s=; b=IJ8Q6p8U36X5CIa88pdoHdwgaEfafl3EOO3ck6NoqtMSy7yVYnZx5p4flBPMV+Mlhd dWzGex2fsCs7Y6QvZnxPfSYy/93dic/V/gzxHnAHcKIXeF8zxxL2afm+C0OCUnjHDSgO sigRLsalpv6N9E0P7aVB34H3388u7gI/rzJNO4YPHZizcv78YWuE2gmJwvGWOLe6WCIn 7uJZ6rID/XC7odOLZYTQpjzHaPRchDT3IYOfI9Zu7ZrpgPk1HUZtnP0bRIt5qnIRF7UC FXDnKbWCUOs8XimsGHdf6gUVd4DZf4aCEC2Ujio3vYK+H/dhrTEJOqZzme8v4LYQ7xLt slEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UtVvWRod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s16-20020a170902989000b001d066271702si3470092plp.318.2023.12.09.13.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 13:06:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UtVvWRod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 41F3E806D807; Sat, 9 Dec 2023 13:06:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbjLIVFu (ORCPT + 99 others); Sat, 9 Dec 2023 16:05:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbjLIVFt (ORCPT ); Sat, 9 Dec 2023 16:05:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 367E6FD for ; Sat, 9 Dec 2023 13:05:55 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E156AC433C7; Sat, 9 Dec 2023 21:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702155954; bh=BJt4m1bj3PQ1OsNq1UDFooL7gV/55KHr0BR1gtXR+gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UtVvWRodKeN0gQJaq3t6lkrJmKokthC622qiFgmGF3k7L7Erz/HEiQiOWpIB/teLj O4TFUdPeq4WjpjOxi9dlO/K0f8pw9SYhHcuZY9rI+FGC9bZC+BBXbzZU6eQdIXG4oH sAqDXgtjCvOG5Qy66lCVxnlbYQsDTj0IKfHugYP2DKcTTUPH+4paF+ScrmoKmPL/hC yS/pE3A3oZINtp3hBBad1yJRDAJcpPVtdZnVhcPt0YXJnD83a34g103i/g2tDP9gwa M0UvsCNazoBYdTiEOv2l92weUSP9840VjJ39kktBPiACNfHOoo7UlYJEZNPM4BSNiH rkE1Rfv9p3Kdw== From: Miguel Ojeda To: gregkh@linuxfoundation.org Cc: aliceryhl@google.com, arve@android.com, christian@brauner.io, cmllamas@google.com, dualli@google.com, joel@joelfernandes.org, kernel-team@android.com, linux-kernel@vger.kernel.org, maco@android.com, rust-for-linux@vger.kernel.org, surenb@google.com, tkjos@android.com, jbaublitz@redhat.com, aaron@aaronballman.com, emilio@crisal.io, christian.poveda@ferrous-systems.com, Miguel Ojeda Subject: Re: [PATCH] binder: use enum for binder ioctls Date: Sat, 9 Dec 2023 22:05:44 +0100 Message-ID: <20231209210544.139181-1-ojeda@kernel.org> In-Reply-To: <2023120936-decency-engraved-5346@gregkh> References: <2023120936-decency-engraved-5346@gregkh> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 09 Dec 2023 13:06:05 -0800 (PST) > Does this mean that we will have to wrap every ioctl definition in an > enum just to get access to it in rust code? Currently, yes (or one can build them on the Rust side using the `_IO*` const functions that are in mainline at `rust/kernel/ioctl.rs`). > What makes these defines so magical that bindgen can't decode them? Is > it just the complexity of the C preprocessor logic involved? Any plans > for bindgen to resolve this? Yeah, currently bindgen only resolves "trivial" object-like macros. As soon as a macro is more complex it does not work, even if it would still resolve into a constant. The upstream issue for this particular case (a macro that uses other function-like macros) uses `_IO*`s as the example, in fact, and is at: https://github.com/rust-lang/rust-bindgen/issues/753 which we track in our bindgen list at: https://github.com/Rust-for-Linux/linux/issues/353 There are several ways forward for bindgen here. Ideally, libclang would give the resolved value to bindgen. This may require changes in upstream Clang. I contacted Aaron Ballman (the Clang maintainer, Cc'd) a while ago and he kindly offered to review the changes if they were eventually needed. Otherwise (or meanwhile), it is also possible to implement a workaround that stores the information in a way that can be retrieved by bindgen by using the macro in some way (e.g. initializing a variable and asking for the value of the variable). It is ugly, but it should work (at least for many cases -- there may be other compounding issues with e.g. 128-bit integers). John Baublitz (Cc'd) has spent some time on this and, from what I can tell from the issue, we may be waiting on an answer from bindgen (Cc'ing Emilio and Christian, the bindgen maintainers) on whether the workaround is OK for them. The workaround would be nice to have even if we change upstream Clang, because it would help in many cases we care about, without having to wait until we get a new LLVM released and so on. Hope that helps! Cheers, Miguel