Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2050882imu; Wed, 12 Dec 2018 08:41:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/W9bitukGwWzBKoDZjmbF8z3c9ssQaDK26s4OwwekFssV7wUXWmq8Nrt/FiOgBQ4iYRTk18 X-Received: by 2002:a17:902:654a:: with SMTP id d10mr20060329pln.324.1544632910554; Wed, 12 Dec 2018 08:41:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544632910; cv=none; d=google.com; s=arc-20160816; b=Dao/SXvaNr1zExZg459pJc8CsgF85ywZHnEMom6X1fh0kQink1ofXosW+Opr+7GuEe Hayti9MiZMcN/7iM3bxDbDBmqtemWw3+CL6lJeHIbaHOsjDHDhBlYzN6uxtD/3LPfr/7 DowL/BU2qfRGfeRtJ09OkcdVZlMJwdJ0VL+sxHXWEbs2RHPzTB0Sk2lNI0Ka/T3jYbrz bsBqQXIp/5vIK5BJqzBtTF/ZrQ7L1YZBn7Lox3bjKCyCGza1yrBNI+d7NzY6fnYtH64X 0pPLfBDu2zfu6mEuNLEe37wfhRbqWFZQF3ASH51Hp+9fYelWwYJRS9CWvCNuUbSYV/RI DbsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=q3rIjF5M05IHQcTJ3GC4/EWcMW+isBH0QiKihm3d2Zs=; b=StiqfKVH1/MzX7wWiIt+rpXyJRN9cC1Wtyhqro6StMzCUu7Oasksvjid62gWiJcIk4 aeV9ziWv1LntcDUrYmnPXL0kI2QYlZZn/14GJXWHxVjSDGXosYYDy5DDKy+CuIFp1e2o b+H1zcZybtLU3Pj4BFhBMrEf6PWRTyY3LLfRTah90fc6KaxLVDiWzOJFBVVx7GzA4JLn Ehc9uLThoRADGakILDXanfZuqNP/kIsKWPgKz0muqmSy4Bn5iQqXGlpPfWYj4p8I1Fec r1PO3I5Y2NLivkdwAR/Tx5dVRpM8jrez/hJm28QBcb7/LD+Phdqzv14GS4b9wsO1ynZX HXIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zsEEYEnJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si15193875pgk.165.2018.12.12.08.41.11; Wed, 12 Dec 2018 08:41:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zsEEYEnJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbeLLQkK (ORCPT + 99 others); Wed, 12 Dec 2018 11:40:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:48196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbeLLQkJ (ORCPT ); Wed, 12 Dec 2018 11:40:09 -0500 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9DF6A21479 for ; Wed, 12 Dec 2018 16:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544632807; bh=NLt/dpgAytp9E9jLUtvgCUNLUuBvdWuL08dEXZhw+dw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=zsEEYEnJYRLtgkgXkcDnPQRXgVYHgGYJ95ONwNJVI4C79Idh7LGt4YPGPhufM8X2d yC3QGTcggiTszxU4gufEECshLCJVplcu1MOtOI9ODhMp4vEY3BNzotWYBF3q4rNPpU hOtWewYxs3wk/X2bD7C1DLJdFhpFcjdpaaBY9/fI= Received: by mail-wr1-f45.google.com with SMTP id l9so18315188wrt.13 for ; Wed, 12 Dec 2018 08:40:07 -0800 (PST) X-Gm-Message-State: AA+aEWbUfSY8oFRd5sTXyqL+zVKHBWFJhZY5lTfsl0jDTjRPBw10dOnz 2mSSHZUba6FFeihcNr0/FmNGcveYU3mimKsBBBEY3g== X-Received: by 2002:adf:f0c5:: with SMTP id x5mr17124755wro.77.1544632805891; Wed, 12 Dec 2018 08:40:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Wed, 12 Dec 2018 08:39:53 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Can we drop upstream Linux x32 support? To: tg@mirbsd.de Cc: Andrew Lutomirski , Linus Torvalds , X86 ML , LKML , Linux API , "H. Peter Anvin" , Peter Zijlstra , Borislav Petkov , Florian Weimer , Mike Frysinger , "H. J. Lu" , Rich Felker , x32@buildd.debian.org, Arnd Bergmann , Will Deacon , Catalin Marinas Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Dec 11, 2018, at 6:33 PM, Thorsten Glaser wrote: > > Andy Lutomirski dixit: > > >> IMO the real right solution would be to push the whole problem to >> userspace: get an ILP32 system working with almost or entirely LP64 > > Is this a reflex of Linux kernel developers? ;-) > > I doubt that userspace is the right place for this, remember > the recent glibc vs. syscalls debate. It would also need to > multiply across various libcs. > >> How hard would it be to have __attribute__((ilp64)), with an optional >> warning if any embedded structs are not ilp64? This plus a wrapper to > > You mean LP64. Impossible, because LP64 vs. ILP32 is not the only > difference between amd64 and x32. I mean LP64. And I'm not suggesting that ILP32 is the only difference between x32 and x86_64, nor am I suggesting that a technique like this would implement x32 -- I'm suggesting it would implement something better than x32. The kernel, as a practical matter, supports two ABIs on 64-bit builds: LP64 and ILP32. ILP32 is what the kernel calls "compat". ("compat" comes with other baggage -- it generally has a 32-bit signal frame, syscall arguments are mostly limited to 32 bits, etc.) Allowing a user program that runs in 64-bit mode to issue compat syscalls is not really a big deal. x86_64 has allowed this forever using int $0x80 -- it's just slow. Adding a faster mechanism would be straightforward. As I understand it, the arm64 ilp32 proposal involves using a genuine ILP32 model for user code, so the syscalls will all (except for signal handling) go through the compat path. x32 is not this at all. The kernel ABI part of x32 isn't ILP32. It's IP32, 32-bit size_t, and *64-bit* long. The core kernel doesn't really support this. The only good things I can think of about it are that (a) it proves that somewhat odd ABIs are possible, at least in principle, and (b) three users have come out of the woodwork to say that they use it. I'm proposing another alternative. Given that x32 already proves that the user bitness model doesn't have to match the kernel model (in x32, user "long" is 32-bit but the kernel ABI "long" is 64-bit), I'm proposing extending this to just make the kernel ABI be LP64. So __kernel_size_t would be 64-bit and pointers in kernel data structures would be 64-bit. In other words, most or all of the kernel ABI would just match x86_64. As far as I can tell, the only thing that really needs unusual toolchain features here is that C doesn't have an extra-wide pointer type. The kernel headers would need a way to say "this pointer is still logically a pointer, and user code may assume that it's 32 bits, but it has 8-byte alignment." So I guess I'm proposing that people who really like x32 and are willing to invest effort it in instead invest some effort into getting something similar to work using the normal x86_64 syscalls. And I'm hinting to the ARM folks on the thread that they consider this approach for arm64. There's an added benefit to my proposal over x32. With my proposal, an ILP32 program could plausibly call into a true 64-bit C library using a straightforward FFI translation. > > bye, > //mirabilos > -- > I believe no one can invent an algorithm. One just happens to hit upon it > when God enlightens him. Or only God invents algorithms, we merely copy them. > If you don't believe in God, just consider God as Nature if you won't deny > existence. -- Coywolf Qi Hunt