On Thu, Dec 19, 2024 at 5:02 PM Uros Bizjak 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.