Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8068776ybn; Tue, 1 Oct 2019 02:41:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0YGs25inX1UaBRWmLx1jHoW63SH4wBq2ZXcw0U0kUh/NIsD51frw2Z2XLlin/JuVMRWbS X-Received: by 2002:a17:907:211c:: with SMTP id qn28mr23258459ejb.244.1569922910974; Tue, 01 Oct 2019 02:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569922910; cv=none; d=google.com; s=arc-20160816; b=RxjMKs8K8LR4kasjB/abfzWEiJvUbbvG2ZfDlDnm241t4HSLiaZG7nEw81dMPauAMX 1KE9+ZPkphL9We2Df4uE4TCjUpFzH00DtMxLeszERp9zWLPXNB27fEbdZpb4kYLMCjjJ gazBVwCoD2Ee/eHbienlq0DTzI539nOdm6J8VzGINfgeJgeCAunwJRPIwac4abB+NECD JK3bJkYBxYrruhpydNPEND/TVkk6vTKo4pgkgRgkYooXWlD4FcEFI0Bsa3pzw8fP3XIg RwDnAcnRis/m9O0WFcEuUta6oSJhuSnF4n7gO8v22KfUC2zNPot18xL8UNA+JF815FUE +adA== 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:dkim-filter; bh=3V7aaYqhxC5BWbE2V8bCYYqxY61b5KQqAWJ0GbYioNA=; b=G6t/+VPtsLtIvKtq3cjMH1/9bw1ZmKTuuMmsYpnYzL3VgpjGTYYn9jkTP0Vfyv7KKA ofzrrC0X9zrc1JFN0EhhCkcCBWjgKKl4wCK57/JY6yfNcHFcoyFpetsih/SrSMZlS5m6 YOSXoF5PVwoDzBRy4KuSGzr+lEpknYvkhTsw+mn6eQ2hVBoexLV0rE4jNR+HXHcFDqAw L2UrMnth16Z4IqTQxv7Kf3bA32/lWwOnlC3d3n1upmD9p6HUDva9AabS+oqfa7ixtBSt F9BlDmF8iJno/iFLulgPWvpyv2oAW9pRbbhXcY/XHyarT3JiUAaHRhO0k+DFa0eO1bOE uZlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=vEt6vx8v; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si8088666edq.221.2019.10.01.02.41.25; Tue, 01 Oct 2019 02:41:50 -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=@nifty.com header.s=dec2015msa header.b=vEt6vx8v; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729639AbfJAJkX (ORCPT + 99 others); Tue, 1 Oct 2019 05:40:23 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:16399 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfJAJkX (ORCPT ); Tue, 1 Oct 2019 05:40:23 -0400 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (authenticated) by conssluserg-05.nifty.com with ESMTP id x919eCmr022885; Tue, 1 Oct 2019 18:40:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com x919eCmr022885 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569922813; bh=3V7aaYqhxC5BWbE2V8bCYYqxY61b5KQqAWJ0GbYioNA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=vEt6vx8vIiQic53N8LCpChPBKKv5IuD8NQ3zcaLelBpc4Xx0eQns8R18kxyNYLZFd gS0oNQhqjIyWvytM4eIbTESY1A/9nJ89GneqpeVi8MSgWTsnkRMzONhbVv6DT9kYU5 7dr5pJxeEcyj4/UY4eYhbcn52rOI471oWQAKivQiIanUjDnV7ou4JYLMhkiV5NR5Wu LJTJkoyP5lmtq9wUNlgwJkZq1ZvA/zJP9fsxFjxax0lAEhYb1kvr0hTvPkk25gLlDN y/j2qQfrBgj4pUqVdJZsBtmS/aZrlcmpFj9txRGAEgf1OPWwxb8EdoHZzB86qXFwNr vEjnc/eKFb9lg== X-Nifty-SrcIP: [209.85.222.175] Received: by mail-qk1-f175.google.com with SMTP id 4so10538038qki.6; Tue, 01 Oct 2019 02:40:12 -0700 (PDT) X-Gm-Message-State: APjAAAWMsojs4df0obyqQtXM8MwSqcH+amvxt4c1Jq58PQ6BzVIis4YU hqjwRAdewcfRPCJgdVM5DSXlU2pVMMF+IhsSVnM= X-Received: by 2002:a05:620a:7da:: with SMTP id 26mr4584394qkb.119.1569922811597; Tue, 01 Oct 2019 02:40:11 -0700 (PDT) MIME-Version: 1.0 References: <20190830034304.24259-1-yamada.masahiro@socionext.com> <20190930112636.vx2qxo4hdysvxibl@willie-the-truck> <20190930121803.n34i63scet2ec7ll@willie-the-truck> In-Reply-To: <20190930121803.n34i63scet2ec7ll@willie-the-truck> From: Masahiro Yamada Date: Tue, 1 Oct 2019 18:39:34 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] compiler: enable CONFIG_OPTIMIZE_INLINING forcibly To: Will Deacon 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 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 Hi Will, On Mon, Sep 30, 2019 at 9:18 PM Will Deacon wrote: > > 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. You are just looking at the result, not the cause. > 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 am totally fine with double-checking the output from the compiler. > > > 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 ;) Not always. You showed a compiler bug case for arm64. The 32bit ARM is not the case. > > > I think we discussed this already. > > We did? https://www.spinics.net/lists/arm-kernel/msg754567.html This is a bug in the kernel code. > > - 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 You put multiple references here and there, but they are all about arch_atomic64_dec_if_positive(). -- Best Regards Masahiro Yamada