Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/uaccess: avoid mvcos jump label

If the kernel is compiled for z10 or later machines the uaccess
code inlines the mvcos instruction. The facility bit 27 which
indicates the availability of MVCOS has to be set. The have_mvcos
jump label will always be true.

Make the generation of the have_mvcos jump label conditional on
!CONFIG_HAVE_MARCH_Z10_FEATURES.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

+26 -12
+26 -12
arch/s390/lib/uaccess.c
··· 15 15 #include <asm/mmu_context.h> 16 16 #include <asm/facility.h> 17 17 18 + #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES 18 19 static DEFINE_STATIC_KEY_FALSE(have_mvcos); 20 + 21 + static int __init uaccess_init(void) 22 + { 23 + if (test_facility(27)) 24 + static_branch_enable(&have_mvcos); 25 + return 0; 26 + } 27 + early_initcall(uaccess_init); 28 + 29 + static inline int copy_with_mvcos(void) 30 + { 31 + if (static_branch_likely(&have_mvcos)) 32 + return 1; 33 + return 0; 34 + } 35 + #else 36 + static inline int copy_with_mvcos(void) 37 + { 38 + return 1; 39 + } 40 + #endif 19 41 20 42 static inline unsigned long copy_from_user_mvcos(void *x, const void __user *ptr, 21 43 unsigned long size) ··· 106 84 107 85 unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n) 108 86 { 109 - if (static_branch_likely(&have_mvcos)) 87 + if (copy_with_mvcos()) 110 88 return copy_from_user_mvcos(to, from, n); 111 89 return copy_from_user_mvcp(to, from, n); 112 90 } ··· 179 157 180 158 unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n) 181 159 { 182 - if (static_branch_likely(&have_mvcos)) 160 + if (copy_with_mvcos()) 183 161 return copy_to_user_mvcos(to, from, n); 184 162 return copy_to_user_mvcs(to, from, n); 185 163 } ··· 242 220 243 221 unsigned long raw_copy_in_user(void __user *to, const void __user *from, unsigned long n) 244 222 { 245 - if (static_branch_likely(&have_mvcos)) 223 + if (copy_with_mvcos()) 246 224 return copy_in_user_mvcos(to, from, n); 247 225 return copy_in_user_mvc(to, from, n); 248 226 } ··· 314 292 315 293 unsigned long __clear_user(void __user *to, unsigned long size) 316 294 { 317 - if (static_branch_likely(&have_mvcos)) 295 + if (copy_with_mvcos()) 318 296 return clear_user_mvcos(to, size); 319 297 return clear_user_xc(to, size); 320 298 } ··· 371 349 return done; 372 350 } 373 351 EXPORT_SYMBOL(__strncpy_from_user); 374 - 375 - static int __init uaccess_init(void) 376 - { 377 - if (test_facility(27)) 378 - static_branch_enable(&have_mvcos); 379 - return 0; 380 - } 381 - early_initcall(uaccess_init);