[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CY4PR2201MB1272E45CC3592AE4D97EF177C1A70@CY4PR2201MB1272.namprd22.prod.outlook.com>
Date: Sat, 24 Aug 2019 14:12:31 +0000
From: Paul Burton <paul.burton@...s.com>
To: Nick Desaulniers <ndesaulniers@...gle.com>
CC: "ralf@...ux-mips.org" <ralf@...ux-mips.org>,
Paul Burton <pburton@...ecomp.com>,
"jhogan@...nel.org" <jhogan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nathan Chancellor <natechancellor@...il.com>,
Eli Friedman <efriedma@...cinc.com>,
"Maciej W. Rozycki" <macro@...ux-mips.org>,
Hassan Naveed <hnaveed@...ecomp.com>,
Stephen Kitt <steve@....org>,
Serge Semin <fancer.lancer@...il.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Hocko <mhocko@...e.com>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"clang-built-linux@...glegroups.com"
<clang-built-linux@...glegroups.com>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>
Subject: Re: [PATCH] mips: avoid explicit UB in assignment of
mips_io_port_base
Hello,
Nick Desaulniers wrote:
> The code in question is modifying a variable declared const through
> pointer manipulation. Such code is explicitly undefined behavior, and
> is the lone issue preventing malta_defconfig from booting when built
> with Clang:
>
> If an attempt is made to modify an object defined with a const-qualified
> type through use of an lvalue with non-const-qualified type, the
> behavior is undefined.
>
> LLVM is removing such assignments. A simple fix is to not declare
> variables const that you plan on modifying. Limiting the scope would be
> a better method of preventing unwanted writes to such a variable.
>
> Further, the code in question mentions "compiler bugs" without any links
> to bug reports, so it is difficult to know if the issue is resolved in
> GCC. The patch was authored in 2006, which would have been GCC 4.0.3 or
> 4.1.1. The minimal supported version of GCC in the Linux kernel is
> currently 4.6.
>
> For what its worth, there was UB before the commit in question, it just
> added a barrier and got lucky IRT codegen. I don't think there's any
> actual compiler bugs related, just runtime bugs due to UB.
>
> Fixes: 966f4406d903 ("[MIPS] Work around bad code generation for <asm/io.h>.")
Applied to mips-next.
> commit 12051b318bc3
> https://git.kernel.org/mips/c/12051b318bc3
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/610
> Fixes: 966f4406d903 ("[MIPS] Work around bad code generation for <asm/io.h>.")
> Reported-by: Nathan Chancellor <natechancellor@...il.com>
> Debugged-by: Nathan Chancellor <natechancellor@...il.com>
> Suggested-by: Eli Friedman <efriedma@...cinc.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>
> Reviewed-by: Nathan Chancellor <natechancellor@...il.com>
> Tested-by: Nathan Chancellor <natechancellor@...il.com>
> Signed-off-by: Paul Burton <paul.burton@...s.com>
Thanks,
Paul
[ This message was auto-generated; if you believe anything is incorrect
then please email paul.burton@...s.com to report it. ]
Powered by blists - more mailing lists