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

Configure Feed

Select the types of activity you want to include in your feed.

s390/ptrace: Convert function macros to inline functions

Convert the function macros user_mode(), instruction_pointer(), and
user_stack_pointer() to inline functions, to align their definition
with x86 and arm64.

Use const qualifier on struct pt_regs pointer parameters to prevent
compiler warnings:

arch/s390/kernel/stacktrace.c: In function ‘arch_stack_walk_user_common’:
arch/s390/kernel/stacktrace.c:114:34: warning: passing argument 1 of
‘instruction_pointer’ discards ‘const’ qualifier from pointer target
type [-Wdiscarded-qualifiers]
...
arch/s390/kernel/stacktrace.c:117:48: warning: passing argument 1 of
‘user_stack_pointer’ discards ‘const’ qualifier from pointer target
type [-Wdiscarded-qualifiers]
...

While at it add const qualifier to all struct pt_regs pointer parameters
that are accessed read-only and use __always_inline instead of inline to
harmonize the helper functions.

[hca@linux.ibm.com: Use psw_bits() helper]

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

authored by

Jens Remus and committed by
Heiko Carstens
afa8fa52 b4780fe4

+26 -11
+26 -11
arch/s390/include/asm/ptrace.h
··· 214 214 #define arch_has_single_step() (1) 215 215 #define arch_has_block_step() (1) 216 216 217 - #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) 218 - #define instruction_pointer(regs) ((regs)->psw.addr) 219 - #define user_stack_pointer(regs)((regs)->gprs[15]) 220 217 #define profile_pc(regs) instruction_pointer(regs) 221 218 222 - static inline long regs_return_value(struct pt_regs *regs) 219 + static __always_inline bool user_mode(const struct pt_regs *regs) 220 + { 221 + return psw_bits(regs->psw).pstate; 222 + } 223 + 224 + static inline long regs_return_value(const struct pt_regs *regs) 223 225 { 224 226 return regs->gprs[2]; 227 + } 228 + 229 + static __always_inline unsigned long instruction_pointer(const struct pt_regs *regs) 230 + { 231 + return regs->psw.addr; 225 232 } 226 233 227 234 static inline void instruction_pointer_set(struct pt_regs *regs, ··· 240 233 int regs_query_register_offset(const char *name); 241 234 const char *regs_query_register_name(unsigned int offset); 242 235 243 - static __always_inline unsigned long kernel_stack_pointer(struct pt_regs *regs) 236 + static __always_inline unsigned long kernel_stack_pointer(const struct pt_regs *regs) 244 237 { 245 238 return regs->gprs[15]; 246 239 } 247 240 248 - static __always_inline unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset) 241 + static __always_inline unsigned long user_stack_pointer(const struct pt_regs *regs) 242 + { 243 + return regs->gprs[15]; 244 + } 245 + 246 + static __always_inline unsigned long regs_get_register(const struct pt_regs *regs, 247 + unsigned int offset) 249 248 { 250 249 if (offset >= NUM_GPRS) 251 250 return 0; 252 251 return regs->gprs[offset]; 253 252 } 254 253 255 - static __always_inline int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr) 254 + static __always_inline int regs_within_kernel_stack(const struct pt_regs *regs, 255 + unsigned long addr) 256 256 { 257 257 unsigned long ksp = kernel_stack_pointer(regs); 258 258 ··· 275 261 * is specifined by @regs. If the @n th entry is NOT in the kernel stack, 276 262 * this returns 0. 277 263 */ 278 - static __always_inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n) 264 + static __always_inline unsigned long regs_get_kernel_stack_nth(const struct pt_regs *regs, 265 + unsigned int n) 279 266 { 280 267 unsigned long addr; 281 268 ··· 293 278 * 294 279 * regs_get_kernel_argument() returns @n th argument of the function call. 295 280 */ 296 - static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, 297 - unsigned int n) 281 + static __always_inline unsigned long regs_get_kernel_argument(const struct pt_regs *regs, 282 + unsigned int n) 298 283 { 299 284 unsigned int argoffset = STACK_FRAME_OVERHEAD / sizeof(long); 300 285 ··· 305 290 return regs_get_kernel_stack_nth(regs, argoffset + n); 306 291 } 307 292 308 - static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) 293 + static __always_inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) 309 294 { 310 295 regs->gprs[2] = rc; 311 296 }