File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ config SPARC64
8282 select HAVE_ARCH_AUDITSYSCALL
8383 select ARCH_SUPPORTS_ATOMIC_RMW
8484 select HAVE_NMI
85+ select HAVE_REGS_AND_STACK_ACCESS_API
8586
8687config ARCH_DEFCONFIG
8788 string
Original file line number Diff line number Diff line change @@ -83,7 +83,8 @@ unsigned long profile_pc(struct pt_regs *);
8383
8484#define MAX_REG_OFFSET (offsetof(struct pt_regs, magic))
8585
86- extern int regs_query_register_offset (const char * name );
86+ int regs_query_register_offset (const char * name );
87+ unsigned long regs_get_kernel_stack_nth (struct pt_regs * regs , unsigned int n );
8788
8889/**
8990 * regs_get_register() - get register value from its offset
Original file line number Diff line number Diff line change @@ -1162,3 +1162,39 @@ int regs_query_register_offset(const char *name)
11621162 return roff -> offset ;
11631163 return - EINVAL ;
11641164}
1165+
1166+ /**
1167+ * regs_within_kernel_stack() - check the address in the stack
1168+ * @regs: pt_regs which contains kernel stack pointer.
1169+ * @addr: address which is checked.
1170+ *
1171+ * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
1172+ * If @addr is within the kernel stack, it returns true. If not, returns false.
1173+ */
1174+ static inline int regs_within_kernel_stack (struct pt_regs * regs ,
1175+ unsigned long addr )
1176+ {
1177+ unsigned long ksp = kernel_stack_pointer (regs ) + STACK_BIAS ;
1178+ return ((addr & ~(THREAD_SIZE - 1 )) ==
1179+ (ksp & ~(THREAD_SIZE - 1 )));
1180+ }
1181+
1182+ /**
1183+ * regs_get_kernel_stack_nth() - get Nth entry of the stack
1184+ * @regs: pt_regs which contains kernel stack pointer.
1185+ * @n: stack entry number.
1186+ *
1187+ * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
1188+ * is specified by @regs. If the @n th entry is NOT in the kernel stack,
1189+ * this returns 0.
1190+ */
1191+ unsigned long regs_get_kernel_stack_nth (struct pt_regs * regs , unsigned int n )
1192+ {
1193+ unsigned long ksp = kernel_stack_pointer (regs ) + STACK_BIAS ;
1194+ unsigned long * addr = (unsigned long * )ksp ;
1195+ addr += n ;
1196+ if (regs_within_kernel_stack (regs , (unsigned long )addr ))
1197+ return * addr ;
1198+ else
1199+ return 0 ;
1200+ }
You can’t perform that action at this time.
0 commit comments