Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2552296ybz; Sun, 19 Apr 2020 04:09:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJ17axHBzldCzcS1X2DQDTXNTZxlJM/q5N+Ek3MZvU0sGJSCFhthbMbOzCL3UdbPxfWKDry X-Received: by 2002:a17:906:48c:: with SMTP id f12mr11435482eja.93.1587294588533; Sun, 19 Apr 2020 04:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587294588; cv=none; d=google.com; s=arc-20160816; b=rHOze6AZzwtkFpMl3QcfoPyEEHGOQXx82BIuwbSDJkr88KO/r2eAOAzhR+bPnKDmcl +xtyhV2MyzkfYQdledeltwOow5G8SjUITUmJBKcuP6jYTbWX43sR0iJ7iClXnHBZ/EF0 DpSXUiaRrdmbt4S6cncMGQJyXyDyMTLOvvjyV2mnF7bhvWBrOVc1CSFOF1SlRJPEbz95 FfIfxZj8+H6mzmrDN76ezo5j2JGA29xe8fEGEAP7bX4W4iSPt14G0P8ZOG6H1OV7NnwW OV5XtboJbmDdBnqCc6BFmcG9aTLx5lRbWfEe+QhILRNB8J0jchVBwaQdbi3+6QtLKFBM rB7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=a0hpRrCjohxzHvPf38IAgCtaSvu3v8WSSLh0hsDEMqw=; b=ATs8TctgoXCZeuzDC7ZqPZ+nRevN3vhF7IK6SFfTAZDYiNPjsCJ+u5cdFrH3myVgJv 3MPYJIdRfNPb7behePhcPWGsgXAXVcIrdwgEY20t0+dwfVsQdVzHihaje1pDMqN+jgsC aHkGxAouBjJVj3rnc90oaxi124qRekGW+hEB+zJiHEJhneKM8Pk+wzyXZCftgNZgUODX gegFUdGPwMevEHW31q3YuO80FmU6N4jOpJyryNyGPkpe5pFf9wxx1YFxU6RZLuXH1+OX ZuKxnrqETYqfCpyzKeN7EOYPb8rsUfg8FGheBVcz/vwgyH90J7agPBCPUu2RFsV9F28J ViKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=WmfvRi3j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt22si17789741edb.437.2020.04.19.04.09.22; Sun, 19 Apr 2020 04:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=WmfvRi3j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725959AbgDSLIM (ORCPT + 99 others); Sun, 19 Apr 2020 07:08:12 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:34864 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgDSLIM (ORCPT ); Sun, 19 Apr 2020 07:08:12 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 079D45C9ADE; Sun, 19 Apr 2020 13:08:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1587294486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0hpRrCjohxzHvPf38IAgCtaSvu3v8WSSLh0hsDEMqw=; b=WmfvRi3jR7d1hRFCgk+w1SXChEMd+jClZqc2hGhn7eZqZyKobXpYwBSYbtGw+JtpTIM/pd bBT20gm7rLpg3P4dnoET5zVECvwL1nlC4d05IZaayjf0Q0vHxNkQpZJp474Av1riOXAIYd PGiZgTsTNn6hlKbpLvauWsxgKc6VTL0= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Sun, 19 Apr 2020 13:08:05 +0200 From: Stefan Agner To: Russell King - ARM Linux admin Cc: Arnd Bergmann , Ard Biesheuvel , Kees Cook , Nick Desaulniers , Kristof Beyls , Stephen Hines , Luis Lozano , Jian Cai , Linus Walleij , Peter Smith , David Howells , Mauro Carvalho Chehab , Manoj Gupta , Benjamin Gaignard , "Joel Fernandes (Google)" , clang-built-linux , Ilie Halip , Masahiro Yamada , Krzysztof Kozlowski , Bartosz Golaszewski , Sami Tolvanen , "Eric W. Biederman" , "Steven Rostedt (VMware)" , Jian Cai , Doug Anderson , Dan Williams , Linux ARM , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Patrick Bellasi , Masami Hiramatsu , Tejun Heo , Andrew Morton Subject: Re: [PATCH] ARM: do not assemble iwmmxt.S with LLVM toolchain In-Reply-To: <20200415144450.GF25745@shell.armlinux.org.uk> References: <20200410123301.GX25745@shell.armlinux.org.uk> <202004141258.6D9CB92507@keescook> <20200415144450.GF25745@shell.armlinux.org.uk> User-Agent: Roundcube Webmail/1.4.1 Message-ID: X-Sender: stefan@agner.ch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-15 16:44, Russell King - ARM Linux admin wrote: > On Wed, Apr 15, 2020 at 02:58:05PM +0200, Arnd Bergmann wrote: >> On Wed, Apr 15, 2020 at 12:32 PM Ard Biesheuvel wrote: >> > >> > On Tue, 14 Apr 2020 at 22:53, Kees Cook wrote: >> > > >> > > I don't know if this will help, but I feel like folks might be talking >> > > past each other a little here. I see two primary issues that are >> > > colliding, and I just want to call them out specifically... >> > >> > To reiterate my point: I strongly prefer minor asm surgery over >> > elaborate Kconfig plumbing if it means we can retain the functionality >> > even when using LLVM tools. In particular, the use of macros to >> > implement missing ISA support should be considered before any other >> > solution, as these are already being used widely across architectures >> > to fill in such gaps. >> >> +1 >> >> > > What's a good middle ground here? For VLAs, I ended up getting akpm's >> > > help by having him add -Wvla to his local builds and send nag emails >> > > to people when they added VLAs. That's not really a thing here, but it >> > > seems like there should be a way to avoid losing ground (in this case, >> > > it's the erosion of attention: repeated known-issue warnings means the >> > > CI gets ignored for the warnings on newly added issues). It does seem >> > > to me like adding the negative depends is a reasonable first step: it >> > > marks what hard things need fixing later without losing coverage for >> > > things that can be more easily fixed now with available resources. >> > > >> > > For the specific iwmmxt.S case, perhaps the solution is the suggested >> > > changes? I imagine it should be possible to do a binary diff to see zero >> > > changes before/after. >> > >> > This code has been around since 2004. It has never been possible to >> > assemble it with Clang's assembler. So the only thing this patch gives >> > you is the ability to switch from a .config where IWMMXT was disabled >> > by hand to one where it gets disabled automatically by Kconfig. >> > >> > So what hard-won ground are we losing here? Did IWMMXT recently get >> > enabled in a defconfig that you care about? >> >> I mainly care about the build testing aspect here, it seems we are getting >> close to having the clang integrated assembler working with all .S files >> in the kernel (it used to work for none), and I'd like to do randconfig and >> allmodconfig tests that include these as well. Disabling the option works >> for me, but your suggestion with the added macros is clearly better. > > However, to me it seems the approach has been "clang doesn't like X, > the kernel has to change to suit clang" - sometimes at the expense > of either functionality or maintainability of the kernel. There are also quite some quirks which work around gcc/binutils weirdness in the kernel. E.g. there are macros to make VFP support work with older binutils versions. I understand, Clang is the newcomer here. Breaking gcc/binutils is a nogo, and functionality or maintainability should not suffer. I think the important thing here is that whatever workarounds are introduced that they are properly documented: Why is this required, how does it work, and under what circumstances can it be removed again. This should be in commit logs as well as inline. > > Some of the changes have been good (provoking modernisation) but that's > not true of everything - and I see nothing happening subsequently to > rectify the situation. And that is true with gcc/binutils work arounds which have been introduced long time ago. From my perspective, the kernel always tried to be very user oriented when it comes to toolchain support: Rather than blacklist a known broken toolchain version, work arounds have been introduced. And I think we should treat Clang no different. That being said, I am not saying we should hack up the kernel to make Clang work no matter what. There are fixes made in Clang so we can avoid introducing hacks in the kernel. There needs to be a balance. Again, I think more important is that when we introduce work arounds in Linux, that we make sure that such changes are properly document. This will make cleanup a *lot* easier and therefor more likely down the road. > > Had we gone down the path of disabling the build of iWMMXT, if anyone > builds a kernel with clang for ARMv5 PXA and relies on iWMMXT, their > userspace suddenly breaks because they used a different compiler and > lost the necessary iWMMXT support in the kernel to allow userspace to > operate, which isn't a nice approach. That is actually a very good point and hasn't really been taken into account in this discussion. Currently the default behavior is that iWMMXT is enabled for all CPUs supporting it. With the patch as-is, users who might try out Clang (with integrated assembler) likely will not notice that iWMMXT is not supported. They will be in for a surprise once they try to use user space applications making use of iWMMXT instructions. Avoiding such surprises would mean we either disable all iWMMXT CPUs/architectures when using Clang's integrated assembler or make sure they work with the integrated assembler. Is there a nice way to print a warning at build time in this case? > > Using macros is the best solution to work around clang, but should not > be done at the expense of GNU AS which has proper support. I guess making the macros a Clang only thing should be doable. > > I'd say this: if clang wants to support building ARMv5, then it needs > to support iWMMXT and stop forcing the kernel to adapt to Clang's > incomplete implementations (which are no direct fault of the clang > developers.) So far I at least did not really look into supporting ARMv5 architectures when building with Clang. I would be fine to just disable ARMv5 architecture when using Clang's integrated assembler, at least for now. However, iWMMXT is also supported by Marvell's PJ4 microarchitecture, which is an ARMv7-A architecture. Hence this file is assembled when building multi_v7_defconfig (since ARCH_DOVE is enabled there). So if we consider iWMMXT mandatory to support an architecture, we would have to disable more than "just" ARMv5. That said, I still would prefer this patch over disabling all the architectures. Keep in mind that integrated assembler needs to be explicitly enabled (using LLVM_IAS=1). While I fear that the asm macro surgery will not be that clean/trivial, I still think its the best option. It side steps the problem of accidentally breaking user space and ultimately allows to build more configurations with Clang's integrated assembler. -- Stefan