[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFULd4ZcSY+1WPn2T9dHVJZyyg1p+YaexQMJzAXHnCDy90j2fA@mail.gmail.com>
Date: Thu, 19 Dec 2024 18:03:47 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: Gal Pressman <gal@...dia.com>
Cc: Dennis Zhou <dennis@...nel.org>, Tejun Heo <tj@...nel.org>, Christoph Lameter <cl@...ux.com>,
Nathan Chancellor <nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>,
Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev, netdev@...r.kernel.org
Subject: Re: [PATCH] percpu: Remove intermediate variable in PERCPU_PTR()
On Thu, Dec 19, 2024 at 5:02 PM Uros Bizjak <ubizjak@...il.com> wrote:
> > > The intermediate variable in the PERCPU_PTR() macro results in a kernel
> > > panic on boot [1] due to a compiler bug seen when compiling the kernel
> > > (+ KASAN) with gcc 11.3.1, but not when compiling with latest gcc
> > > (v14.2)/clang(v18.1).
> > >
> > > To solve it, remove the intermediate variable (which is not needed) and
> > > keep the casting that resolves the address space checks.
[...]
> > > include/linux/percpu-defs.h | 3 +--
> > > 1 file changed, 1 insertion(+), 2 deletions(-)
> > >
> > > diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
> > > index 35842d1e3879..573adb643d90 100644
> > > --- a/include/linux/percpu-defs.h
> > > +++ b/include/linux/percpu-defs.h
> > > @@ -222,8 +222,7 @@ do { \
> > >
> > > #define PERCPU_PTR(__p) \
> > > ({ \
> > > - unsigned long __pcpu_ptr = (__force unsigned long)(__p); \
> > > - (typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \
> > > + (typeof(*(__p)) __force __kernel *)((__force unsigned long)(__p)); \
> > > })
>
> Actually, you can simplify the above a bit by writing it as:
>
> #define PERCPU_PTR(__p) \
> ((typeof(*(__p)) __force __kernel *)(__force unsigned long)(__p)) \
Andrew, please find attached a substitute patch "[PATCH 4/6] percpu:
Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors" for your MM tree
relative to the above hotfix. The whole patch series (+ hotfix) has
been re-tested against the current mainline defconfig (+ KASAN),
compiled once with gcc-11.4.1 and once with gcc-14.2.1.
Uros.
View attachment "0004-percpu-Use-TYPEOF_UNQUAL-in-_cpu_ptr-accessors.patch" of type "text/x-patch" (2284 bytes)
Powered by blists - more mailing lists