Skip to content

Commit f832460

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
Pull sparc fixes from David Miller: "I didn't want the release to go out without the statx system call properly hooked up" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc: sparc: Update syscall tables. sparc64: Fill in rest of HAVE_REGS_AND_STACK_ACCESS_API
2 parents 1e2f82d + f6ebf0b commit f832460

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

arch/sparc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

8687
config ARCH_DEFCONFIG
8788
string

arch/sparc/include/asm/ptrace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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

arch/sparc/include/uapi/asm/unistd.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,9 @@
425425
#define __NR_copy_file_range 357
426426
#define __NR_preadv2 358
427427
#define __NR_pwritev2 359
428+
#define __NR_statx 360
428429

429-
#define NR_syscalls 360
430+
#define NR_syscalls 361
430431

431432
/* Bitmask values returned from kern_features system call. */
432433
#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
@@ -442,4 +443,9 @@
442443
#define __IGNORE_getresgid
443444
#endif
444445

446+
/* Sparc doesn't have protection keys. */
447+
#define __IGNORE_pkey_mprotect
448+
#define __IGNORE_pkey_alloc
449+
#define __IGNORE_pkey_free
450+
445451
#endif /* _UAPI_SPARC_UNISTD_H */

arch/sparc/kernel/ptrace_64.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

arch/sparc/kernel/systbls_32.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ sys_call_table:
8989
/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
9090
/*350*/ .long sys_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
9191
/*355*/ .long sys_setsockopt, sys_mlock2, sys_copy_file_range, sys_preadv2, sys_pwritev2
92+
/*360*/ .long sys_statx

arch/sparc/kernel/systbls_64.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ sys_call_table32:
9090
.word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
9191
/*350*/ .word sys32_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
9292
.word compat_sys_setsockopt, sys_mlock2, sys_copy_file_range, compat_sys_preadv2, compat_sys_pwritev2
93+
/*360*/ .word sys_statx
9394

9495
#endif /* CONFIG_COMPAT */
9596

@@ -171,3 +172,4 @@ sys_call_table:
171172
.word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
172173
/*350*/ .word sys64_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
173174
.word sys_setsockopt, sys_mlock2, sys_copy_file_range, sys_preadv2, sys_pwritev2
175+
/*360*/ .word sys_statx

0 commit comments

Comments
 (0)