Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1156514rdg; Fri, 13 Oct 2023 11:55:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxp9bGbYe6MtNWF1pss+yvCbkB9nSLdURHAxS22D6rGKik/4uvl2F8hsGrUFaz+wrKRUrp X-Received: by 2002:a17:902:bd47:b0:1bc:2188:ef88 with SMTP id b7-20020a170902bd4700b001bc2188ef88mr24303240plx.3.1697223321606; Fri, 13 Oct 2023 11:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697223321; cv=none; d=google.com; s=arc-20160816; b=ZNNY4R2wjKPiMuY94jQqVJ4VKktRismmifYCCn/BCjCR0ZzkWk+xUeXQTQusVoG+py PMdFD0rZ4yNGXT0fWS8TUP788LyEKu/hog1clOz7j5QCjXIFX20ieb7JBSjgFCNXemOp wXMGCycUqMPBL5xIdhTIxCVG0OhlC/1FI1KdEkA285FLhW9Ep/r8ACzhecP3Cb5J6oWy ISJQjRpGHePK8eH2CQk/ojTmIB3/hsYFE8PD6wGZlkYeFWi38Dz1vCq8fQm1YYwxFnRu FdN4otOfC4E7gueqDxQcn9uwqRs6N+Umm6cxhUKDM2lllI04SbDph4wiCMT5r3LXYPUZ 1B3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vTnCuQhHu4vMJ5ozMAEPYZByiFfPswag7KkaGVloQKk=; fh=888KojSBLALdZP24vYThh+u2S7kPG+hDNNb8pKq4b70=; b=nxJ3CFmbFi+IxbAbjMpmjtsHN47ahQSzXh6H19InGnbdkLZLaUgat16Q1Yxwv2mLX9 P9NJ2cMz5gNbYAsZM/O8FiF92JlcDif9+XyAQFW8UgOLTThHS4GBbZwgnoJjNOqn+OCy tG2nJhNgR/5zwk55nqFvKouekr/raG34zt7RuhND43aWe0dwq2hKZFHQE2MMxlzY/OSX tIAyaTFi3EvT7dEa+pg/LnVCkwdweM1hPN5KigzezzjM47KH9flffIor+lMTN+nvX1Mg qLZZ/4ARq/aCsJ6SnngUwpDl3+LTkYAndfOJnKwmPPLg4TA2u+0NuUuu0ePm0/XXOcuJ 7E+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bqDpJuar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id p6-20020a170902a40600b001c62cfff795si4780897plq.429.2023.10.13.11.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 11:55:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=bqDpJuar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CDCD981354BD; Fri, 13 Oct 2023 11:55:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbjJMSzI (ORCPT + 99 others); Fri, 13 Oct 2023 14:55:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJMSzH (ORCPT ); Fri, 13 Oct 2023 14:55:07 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E650BB for ; Fri, 13 Oct 2023 11:55:05 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9be3b66f254so34305666b.3 for ; Fri, 13 Oct 2023 11:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1697223304; x=1697828104; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vTnCuQhHu4vMJ5ozMAEPYZByiFfPswag7KkaGVloQKk=; b=bqDpJuarTe0xYUp8E2Z8K31fSWhh6FFn+zDQZbfbeCNjT8ztCg7jUYLlZelh1MOYs2 fZFfNifMRfUL/ZFcdJ7yxHzbvacHBmn/vVPEsgl3NyCogHTh2bIUl7HE0mImJ2Z033r4 7sGm1pIlttsm+tunGIRtoAhPelsRlZ1oE+65U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697223304; x=1697828104; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vTnCuQhHu4vMJ5ozMAEPYZByiFfPswag7KkaGVloQKk=; b=h+KlB7JkAvvY1tAMpeXwiR8TbMlFYyYmGSpPBbiTmkwj9iC4dm63iA/77BSthK3RSt VbsHL/imM12wINUJCuxx77PpDpvGySe+Ogbje7bjw8AoYmPmJfzcWkJ2nzIbiPNFRTJh lOhfgRStGhzDRbntThUoYPuETdPxk1We4tsoG9xA0ZDW7WmTPBPMTw8ddmjygl1oyM62 CJ5/7YQANQ63p0s1JzLRSAo4nQiCXzKRpoUtICmo26nreS1ZRjYIdYkTB9oow/uUiUla T4wLhkoAKup79ZwnHPguBljFldwxBWgo8N28Fa32TBtvFahsec7YR1U9iICvAwOgToA5 WzfQ== X-Gm-Message-State: AOJu0YzS9sKSe5z61AommyBAl38eTv59ZRTRHC3v9JJQs8Kj58zJt6Ng C8L+iqthS2h0rsHFcrVWcoZqBX3wKflDYdoBLF122w== X-Received: by 2002:a17:907:778e:b0:9a1:bd82:de24 with SMTP id ky14-20020a170907778e00b009a1bd82de24mr24120517ejc.12.1697223304048; Fri, 13 Oct 2023 11:55:04 -0700 (PDT) Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com. [209.85.218.51]) by smtp.gmail.com with ESMTPSA id rn4-20020a170906d92400b0099bc038eb2bsm12651044ejb.58.2023.10.13.11.55.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Oct 2023 11:55:03 -0700 (PDT) Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-99c3c8adb27so382521266b.1 for ; Fri, 13 Oct 2023 11:55:03 -0700 (PDT) X-Received: by 2002:a17:906:2189:b0:9ae:6ad0:f6db with SMTP id 9-20020a170906218900b009ae6ad0f6dbmr23995223eju.71.1697223303355; Fri, 13 Oct 2023 11:55:03 -0700 (PDT) MIME-Version: 1.0 References: <20220927131518.30000-1-ojeda@kernel.org> <20220927131518.30000-26-ojeda@kernel.org> <20231012104741.GN6307@noisy.programming.kicks-ass.net> <202310121130.256F581823@keescook> <20231013075005.GB12118@noisy.programming.kicks-ass.net> In-Reply-To: From: Linus Torvalds Date: Fri, 13 Oct 2023 11:54:46 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 25/27] x86: enable initial Rust support To: Ramon de C Valle Cc: Peter Zijlstra , Kees Cook , Sami Tolvanen , Miguel Ojeda , Miguel Ojeda , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Alex Gaynor , Wedson Almeida Filho , David Gow , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 13 Oct 2023 11:55:18 -0700 (PDT) On Fri, 13 Oct 2023 at 05:18, Ramon de C Valle wrote: > > Both C and repr(C) Rust structs have this encoding, but I understand > the problems with doing this in C since it doesn't have > repr(transparent) structs so there would be a lot of casting back and > forth. Maybe there is an alternative or this could be done for less > used function pairs? We actually have some C variations of what I think people want to use "repr(transparent) struct" for in Rust. Of course, that is depending on what kind of context you want to use it for, and I might have lost some background. But I'm assuming you're talking about the situation where you want to treat two or more types as being "compatible" within certain contexts. There's the actual standard C "_Generic()" alternative, which allows you to make macros etc that use different types transparently. It's not very widely used in the kernel, because we only fairly recently moved to require recent enough compiler versions, but we do use it now in a couple of places. And there's the much more traditional gcc extension in the form of the __attribute__((__transparent_union__)) thing. In the kernel, that one is even less used, and that one use is likely going away since the need for it is going away. But while it's not standard C, it's actually been supported by relevant compilers for much longer than "_Generic" has, and is designed exactly for the "I have a function that can take arguments of different types", either because the types are bitwise identical (even if _conceptually_ not the same), or simply because you have a different argument that describes the type (the traditional C union model). I suspect, for example, that we *should* have used those transparent unions for the "this function can take either a folio or a page" case, instead of duplicating functions for the two uses. But probably because few people aren familiar with the syntax, that's not what happened. Linus