Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6877882ybn; Mon, 30 Sep 2019 05:21:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqz32lmVJT1IQU8M8ac1cyFgakLc8IFyVKG2zkSx6H9j7O/L9t02/1HVU6coi5iizvpFmuyX X-Received: by 2002:a50:ac0d:: with SMTP id v13mr19042881edc.189.1569846067756; Mon, 30 Sep 2019 05:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569846067; cv=none; d=google.com; s=arc-20160816; b=yTPz5DxDslwrOxZ8sP0wY+WiYTBQVlJEWBSIvxrDJmPL2PiBGoNlq/WfEQAOsKXwYt UAiqP01ywrJFjn4Homh626M8Jqg8/p2jZZCfbze+Be7RA7gjmzu4zuJ3cEf2jYREiPh3 4/dyKuhprX+afHeOW6R2Nf5XsYqNenRl4ddqvByt0QXEpPlZZDnqhWy9zKgiOwwa4eRB BKSEUk0lD4E50yLB8Ty/0KPdbQqB9xBScivalbmEG9gP1SgiJ/DXXlc66y7Z3sdMIzdm QN/wjVxA1v7BHnRPvB6mS59fOGENoACMPQs2IbljrqPd8dnSwvs1RFduGSflMpYzzGa9 7kCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Yepo4O6gOHrYPEzpXLNbdwYSdvOka384vGQkkc2MG24=; b=T8ioL1JbbUvtvwrPO4wXVJDd2KKBOHHBKnSoNkEH7N9Y+TGro5QdfKqM+MvYF/speN zhZNDqaWeWvUXHTM2DMHAg5jyGtzaLP0zHimtB0oOkmlyDPxGU5tpVXVCfMUQtpC/EvE 4ZXuJuePb06VNXOPB5X+moGO47eIXH+NUeJ3DMStR0/AHaUgz+xm3AgP0Qr/DX83xgoq f8XIlmAk59B/HDSRaAIVdw4Xks+YX2KOkq4BM83z9H6ApLJOpru8+aktF/ijIhNIayhz yDUMyoc/E3AaUj8ZUzLkuDr1BPovyiJ2kbSUoGW5Zb1LWTwJr2SuXX+dYQuTli+xqZO0 OPbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pa580s/w"; 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 z35si6976646edb.146.2019.09.30.05.20.43; Mon, 30 Sep 2019 05:21:07 -0700 (PDT) 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="pa580s/w"; 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 S1730456AbfI3MSL (ORCPT + 99 others); Mon, 30 Sep 2019 08:18:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:57272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729649AbfI3MSL (ORCPT ); Mon, 30 Sep 2019 08:18:11 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 762D62054F; Mon, 30 Sep 2019 12:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569845889; bh=c2OUYeKYbDh5+GWE2NV/OFHkpMhJmyVCeS5+QVpDpqw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pa580s/woPLR4Dgg5jdNQ+yBigWHsZgIUlbw6ahDCv3DyWkNlG37VVXX9e1Iif3NU Xlrfa/addvc1VsJY6kzFvJY+U6eXAM/MFIIU3wimHEDZF34bVMz3qrZ5kGlZGeVL22 wrx0r1+WH1cdYgaa7BdvYoqzhbo849gnBS1Gqzmo= Date: Mon, 30 Sep 2019 13:18:04 +0100 From: Will Deacon To: Masahiro Yamada Cc: Linus Torvalds , Nick Desaulniers , Nicolas Saenz Julienne , Andrew Morton , Ingo Molnar , Borislav Petkov , Miguel Ojeda , linux-arch , LKML , Catalin Marinas , Russell King , Stefan Wahren , Kees Cook Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly Message-ID: <20190930121803.n34i63scet2ec7ll@willie-the-truck> References: <20190830034304.24259-1-yamada.masahiro@socionext.com> <20190930112636.vx2qxo4hdysvxibl@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 30, 2019 at 09:05:11PM +0900, Masahiro Yamada wrote: > On Mon, Sep 30, 2019 at 8:26 PM Will Deacon wrote: > > On Fri, Sep 27, 2019 at 03:38:44PM -0700, Linus Torvalds wrote: > > > Soem of that code is pretty subtle. They have fixed register usage > > > (but the asm macros actually check them). And the inline asms clobber > > > the link register, but they do seem to clearly _state_ that they > > > clobber it, so who knows. > > > > > > Just based on the EFAULT, I'd _guess_ that it's some interaction with > > > the domain access control register (so that get/set_domain() thing). > > > But I'm not even sure that code is enabled for the Rpi2, so who > > > knows.. > > > > FWIW, we've run into issues with CONFIG_OPTIMIZE_INLINING and local > > variables marked as 'register' where GCC would do crazy things and end > > up corrupting data, so I suspect the use of fixed registers in the arm > > uaccess functions is hitting something similar: > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91111 > > No. Not similar at all. They're similar in that enabling CONFIG_OPTIMIZE_INLINING causes register variables to go wrong. I agree that the ARM code looks dodgy with that call to uaccess_save_and_enable(), but there are __asmeq macros in there to try to catch that, so it's still very fishy. > I fixed it already. See > https://lore.kernel.org/patchwork/patch/1132459/ You fixed the specific case above for 32-bit ARM, but the arm64 case is due to a compiler bug. As it happens, we've reworked our atomics in 5.4 so that particular issue no longer triggers, but the fact remains that GCC has been shown to screw up explicit register allocation for perfectly legitimate code when giving the flexibility to move code out of line. > The problems are fixable by writing correct code. Right, in the compiler ;) > I think we discussed this already. We did? > - There is nothing arch-specific in CONFIG_OPTIMIZE_INLINING Apart from the bugs... and even then, that's just based on reports. > - 'inline' is just a hint. It does not guarantee function inlining. > This is standard. > > - The kernel macrofies 'inline' to add __attribute__((__always_inline__)) > This terrible hack must end. I'm all for getting rid of hacks, but not at the cost of correctness. > - __attribute__((__always_inline__)) takes aways compiler's freedom, > and prevents it from optimizing the code for -O2, -Os, or whatever. s/whatever/miscompiling the code/ If it helps, here is more information about the arm64 failure which triggered the GCC bugzilla: https://www.spinics.net/lists/arm-kernel/msg730329.html Will