[Devel] [PATCH RHEL10 COMMIT] ms/percpu: cast percpu pointer in PERCPU_PTR() via unsigned long

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 21 19:42:18 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.6.vz10
------>
commit 739f9b240ca3de6d8ead88a2990724be26366f13
Author: Uros Bizjak <ubizjak at gmail.com>
Date:   Fri Aug 21 18:37:02 2026 +0200

    ms/percpu: cast percpu pointer in PERCPU_PTR() via unsigned long
    
    Cast pointer from percpu address space to generic (kernel) address space
    in PERCPU_PTR() macro via unsigned long intermediate cast [1].  This
    intermediate cast is also required to avoid build failure when GCC's
    strict named address space checks for x86 targets [2] are enabled.
    
    Found by GCC's named address space checks.
    
    [1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name
    [2] https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#x86-Named-Address-Spaces
    
    Link: https://lkml.kernel.org/r/20241021080856.48746-3-ubizjak@gmail.com
    Signed-off-by: Uros Bizjak <ubizjak at gmail.com>
    Acked-by: Christoph Lameter <cl at linux.com>
    Cc: Dennis Zhou <dennis at kernel.org>
    Cc: Tejun Heo <tj at kernel.org>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    (cherry picked from commit dabddd687c9e1a06241d6b4d1f66b9f2b60b3ad1)
    
    Conflict resolution: the previous patch of the same upstream series had
    to drop the stray trailing semicolon of PERCPU_PTR() to stay buildable
    here, so only the body of the macro is replaced.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-134732
    Feature: fix rh/sched
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 include/linux/percpu-defs.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 02bcd74afc6c6..ee236ee0bed6c 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -221,7 +221,10 @@ do {									\
 } while (0)
 
 #define PERCPU_PTR(__p)							\
-	(typeof(*(__p)) __force __kernel *)(__p)
+({									\
+	unsigned long __pcpu_ptr = (__force unsigned long)(__p);	\
+	(typeof(*(__p)) __force __kernel *)(__pcpu_ptr);		\
+})
 
 #ifdef CONFIG_SMP
 


More information about the Devel mailing list