diff options
author | Kyle Huey <me@kylehuey.com> | 2017-03-20 04:16:22 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-03-20 11:10:32 -0400 |
commit | 17a6e1b8e8e8539f89156643f8c3073f09ec446a (patch) | |
tree | 41e073624efa11350077d84dc5d57f319d669fbf | |
parent | ff3f097eef30151f5ee250859e0fe8a0ec02c160 (diff) |
x86/arch_prctl/64: Rename do_arch_prctl() to do_arch_prctl_64()
In order to introduce new arch_prctls that are not 64 bit only, rename the
existing 64 bit implementation to do_arch_prctl_64(). Also rename the
second argument of that function from 'addr' to 'arg2', because it will no
longer always be an address.
Signed-off-by: Kyle Huey <khuey@kylehuey.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Cc: Grzegorz Andrejczuk <grzegorz.andrejczuk@intel.com>
Cc: kvm@vger.kernel.org
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: linux-kselftest@vger.kernel.org
Cc: Nadav Amit <nadav.amit@gmail.com>
Cc: Robert O'Callahan <robert@ocallahan.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Len Brown <len.brown@intel.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: user-mode-linux-devel@lists.sourceforge.net
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: user-mode-linux-user@lists.sourceforge.net
Cc: David Matlack <dmatlack@google.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Link: http://lkml.kernel.org/r/20170320081628.18952-5-khuey@kylehuey.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/um/include/shared/os.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/proto.h | 3 | ||||
-rw-r--r-- | arch/x86/kernel/process_64.c | 32 | ||||
-rw-r--r-- | arch/x86/kernel/ptrace.c | 8 | ||||
-rw-r--r-- | arch/x86/um/os-Linux/prctl.c | 4 | ||||
-rw-r--r-- | arch/x86/um/syscalls_64.c | 14 |
6 files changed, 32 insertions, 31 deletions
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 32e41c4ef6d3..cd1fa97776c3 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h | |||
@@ -303,7 +303,7 @@ extern void maybe_sigio_broken(int fd, int read); | |||
303 | extern void sigio_broken(int fd, int read); | 303 | extern void sigio_broken(int fd, int read); |
304 | 304 | ||
305 | /* prctl.c */ | 305 | /* prctl.c */ |
306 | extern int os_arch_prctl(int pid, int option, unsigned long *addr); | 306 | extern int os_arch_prctl(int pid, int option, unsigned long *arg2); |
307 | 307 | ||
308 | /* tty.c */ | 308 | /* tty.c */ |
309 | extern int get_pty(void); | 309 | extern int get_pty(void); |
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h index 91675a960391..4e276f6cb1c1 100644 --- a/arch/x86/include/asm/proto.h +++ b/arch/x86/include/asm/proto.h | |||
@@ -9,6 +9,7 @@ void syscall_init(void); | |||
9 | 9 | ||
10 | #ifdef CONFIG_X86_64 | 10 | #ifdef CONFIG_X86_64 |
11 | void entry_SYSCALL_64(void); | 11 | void entry_SYSCALL_64(void); |
12 | long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2); | ||
12 | #endif | 13 | #endif |
13 | 14 | ||
14 | #ifdef CONFIG_X86_32 | 15 | #ifdef CONFIG_X86_32 |
@@ -30,6 +31,4 @@ void x86_report_nx(void); | |||
30 | 31 | ||
31 | extern int reboot_force; | 32 | extern int reboot_force; |
32 | 33 | ||
33 | long do_arch_prctl(struct task_struct *task, int option, unsigned long addr); | ||
34 | |||
35 | #endif /* _ASM_X86_PROTO_H */ | 34 | #endif /* _ASM_X86_PROTO_H */ |
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index bf9d7b6c0223..e37f764c11cc 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c | |||
@@ -205,7 +205,7 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp, | |||
205 | (struct user_desc __user *)tls, 0); | 205 | (struct user_desc __user *)tls, 0); |
206 | else | 206 | else |
207 | #endif | 207 | #endif |
208 | err = do_arch_prctl(p, ARCH_SET_FS, tls); | 208 | err = do_arch_prctl_64(p, ARCH_SET_FS, tls); |
209 | if (err) | 209 | if (err) |
210 | goto out; | 210 | goto out; |
211 | } | 211 | } |
@@ -548,7 +548,7 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr) | |||
548 | } | 548 | } |
549 | #endif | 549 | #endif |
550 | 550 | ||
551 | long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) | 551 | long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2) |
552 | { | 552 | { |
553 | int ret = 0; | 553 | int ret = 0; |
554 | int doit = task == current; | 554 | int doit = task == current; |
@@ -556,62 +556,64 @@ long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) | |||
556 | 556 | ||
557 | switch (option) { | 557 | switch (option) { |
558 | case ARCH_SET_GS: | 558 | case ARCH_SET_GS: |
559 | if (addr >= TASK_SIZE_MAX) | 559 | if (arg2 >= TASK_SIZE_MAX) |
560 | return -EPERM; | 560 | return -EPERM; |
561 | cpu = get_cpu(); | 561 | cpu = get_cpu(); |
562 | task->thread.gsindex = 0; | 562 | task->thread.gsindex = 0; |
563 | task->thread.gsbase = addr; | 563 | task->thread.gsbase = arg2; |
564 | if (doit) { | 564 | if (doit) { |
565 | load_gs_index(0); | 565 | load_gs_index(0); |
566 | ret = wrmsrl_safe(MSR_KERNEL_GS_BASE, addr); | 566 | ret = wrmsrl_safe(MSR_KERNEL_GS_BASE, arg2); |
567 | } | 567 | } |
568 | put_cpu(); | 568 | put_cpu(); |
569 | break; | 569 | break; |
570 | case ARCH_SET_FS: | 570 | case ARCH_SET_FS: |
571 | /* Not strictly needed for fs, but do it for symmetry | 571 | /* Not strictly needed for fs, but do it for symmetry |
572 | with gs */ | 572 | with gs */ |
573 | if (addr >= TASK_SIZE_MAX) | 573 | if (arg2 >= TASK_SIZE_MAX) |
574 | return -EPERM; | 574 | return -EPERM; |
575 | cpu = get_cpu(); | 575 | cpu = get_cpu(); |
576 | task->thread.fsindex = 0; | 576 | task->thread.fsindex = 0; |
577 | task->thread.fsbase = addr; | 577 | task->thread.fsbase = arg2; |
578 | if (doit) { | 578 | if (doit) { |
579 | /* set the selector to 0 to not confuse __switch_to */ | 579 | /* set the selector to 0 to not confuse __switch_to */ |
580 | loadsegment(fs, 0); | 580 | loadsegment(fs, 0); |
581 | ret = wrmsrl_safe(MSR_FS_BASE, addr); | 581 | ret = wrmsrl_safe(MSR_FS_BASE, arg2); |
582 | } | 582 | } |
583 | put_cpu(); | 583 | put_cpu(); |
584 | break; | 584 | break; |
585 | case ARCH_GET_FS: { | 585 | case ARCH_GET_FS: { |
586 | unsigned long base; | 586 | unsigned long base; |
587 | |||
587 | if (doit) | 588 | if (doit) |
588 | rdmsrl(MSR_FS_BASE, base); | 589 | rdmsrl(MSR_FS_BASE, base); |
589 | else | 590 | else |
590 | base = task->thread.fsbase; | 591 | base = task->thread.fsbase; |
591 | ret = put_user(base, (unsigned long __user *)addr); | 592 | ret = put_user(base, (unsigned long __user *)arg2); |
592 | break; | 593 | break; |
593 | } | 594 | } |
594 | case ARCH_GET_GS: { | 595 | case ARCH_GET_GS: { |
595 | unsigned long base; | 596 | unsigned long base; |
597 | |||
596 | if (doit) | 598 | if (doit) |
597 | rdmsrl(MSR_KERNEL_GS_BASE, base); | 599 | rdmsrl(MSR_KERNEL_GS_BASE, base); |
598 | else | 600 | else |
599 | base = task->thread.gsbase; | 601 | base = task->thread.gsbase; |
600 | ret = put_user(base, (unsigned long __user *)addr); | 602 | ret = put_user(base, (unsigned long __user *)arg2); |
601 | break; | 603 | break; |
602 | } | 604 | } |
603 | 605 | ||
604 | #ifdef CONFIG_CHECKPOINT_RESTORE | 606 | #ifdef CONFIG_CHECKPOINT_RESTORE |
605 | # ifdef CONFIG_X86_X32_ABI | 607 | # ifdef CONFIG_X86_X32_ABI |
606 | case ARCH_MAP_VDSO_X32: | 608 | case ARCH_MAP_VDSO_X32: |
607 | return prctl_map_vdso(&vdso_image_x32, addr); | 609 | return prctl_map_vdso(&vdso_image_x32, arg2); |
608 | # endif | 610 | # endif |
609 | # if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION | 611 | # if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION |
610 | case ARCH_MAP_VDSO_32: | 612 | case ARCH_MAP_VDSO_32: |
611 | return prctl_map_vdso(&vdso_image_32, addr); | 613 | return prctl_map_vdso(&vdso_image_32, arg2); |
612 | # endif | 614 | # endif |
613 | case ARCH_MAP_VDSO_64: | 615 | case ARCH_MAP_VDSO_64: |
614 | return prctl_map_vdso(&vdso_image_64, addr); | 616 | return prctl_map_vdso(&vdso_image_64, arg2); |
615 | #endif | 617 | #endif |
616 | 618 | ||
617 | default: | 619 | default: |
@@ -622,9 +624,9 @@ long do_arch_prctl(struct task_struct *task, int option, unsigned long addr) | |||
622 | return ret; | 624 | return ret; |
623 | } | 625 | } |
624 | 626 | ||
625 | SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, addr) | 627 | SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) |
626 | { | 628 | { |
627 | return do_arch_prctl(current, option, addr); | 629 | return do_arch_prctl_64(current, option, arg2); |
628 | } | 630 | } |
629 | 631 | ||
630 | unsigned long KSTK_ESP(struct task_struct *task) | 632 | unsigned long KSTK_ESP(struct task_struct *task) |
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 2364b23ea3e5..f37d18124648 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -396,12 +396,12 @@ static int putreg(struct task_struct *child, | |||
396 | if (value >= TASK_SIZE_MAX) | 396 | if (value >= TASK_SIZE_MAX) |
397 | return -EIO; | 397 | return -EIO; |
398 | /* | 398 | /* |
399 | * When changing the segment base, use do_arch_prctl | 399 | * When changing the segment base, use do_arch_prctl_64 |
400 | * to set either thread.fs or thread.fsindex and the | 400 | * to set either thread.fs or thread.fsindex and the |
401 | * corresponding GDT slot. | 401 | * corresponding GDT slot. |
402 | */ | 402 | */ |
403 | if (child->thread.fsbase != value) | 403 | if (child->thread.fsbase != value) |
404 | return do_arch_prctl(child, ARCH_SET_FS, value); | 404 | return do_arch_prctl_64(child, ARCH_SET_FS, value); |
405 | return 0; | 405 | return 0; |
406 | case offsetof(struct user_regs_struct,gs_base): | 406 | case offsetof(struct user_regs_struct,gs_base): |
407 | /* | 407 | /* |
@@ -410,7 +410,7 @@ static int putreg(struct task_struct *child, | |||
410 | if (value >= TASK_SIZE_MAX) | 410 | if (value >= TASK_SIZE_MAX) |
411 | return -EIO; | 411 | return -EIO; |
412 | if (child->thread.gsbase != value) | 412 | if (child->thread.gsbase != value) |
413 | return do_arch_prctl(child, ARCH_SET_GS, value); | 413 | return do_arch_prctl_64(child, ARCH_SET_GS, value); |
414 | return 0; | 414 | return 0; |
415 | #endif | 415 | #endif |
416 | } | 416 | } |
@@ -869,7 +869,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
869 | Works just like arch_prctl, except that the arguments | 869 | Works just like arch_prctl, except that the arguments |
870 | are reversed. */ | 870 | are reversed. */ |
871 | case PTRACE_ARCH_PRCTL: | 871 | case PTRACE_ARCH_PRCTL: |
872 | ret = do_arch_prctl(child, data, addr); | 872 | ret = do_arch_prctl_64(child, data, addr); |
873 | break; | 873 | break; |
874 | #endif | 874 | #endif |
875 | 875 | ||
diff --git a/arch/x86/um/os-Linux/prctl.c b/arch/x86/um/os-Linux/prctl.c index 0a6e16a35b77..8431e87ac333 100644 --- a/arch/x86/um/os-Linux/prctl.c +++ b/arch/x86/um/os-Linux/prctl.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include <sys/ptrace.h> | 6 | #include <sys/ptrace.h> |
7 | #include <asm/ptrace.h> | 7 | #include <asm/ptrace.h> |
8 | 8 | ||
9 | int os_arch_prctl(int pid, int option, unsigned long *addr) | 9 | int os_arch_prctl(int pid, int option, unsigned long *arg2) |
10 | { | 10 | { |
11 | return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) addr, option); | 11 | return ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) arg2, option); |
12 | } | 12 | } |
diff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c index 42369fa5421f..81b9fe100f7c 100644 --- a/arch/x86/um/syscalls_64.c +++ b/arch/x86/um/syscalls_64.c | |||
@@ -12,10 +12,10 @@ | |||
12 | #include <asm/prctl.h> /* XXX This should get the constants from libc */ | 12 | #include <asm/prctl.h> /* XXX This should get the constants from libc */ |
13 | #include <os.h> | 13 | #include <os.h> |
14 | 14 | ||
15 | long arch_prctl(struct task_struct *task, int option | 15 | long arch_prctl(struct task_struct *task, int option) |
16 | unsigned long __user *addr) | 16 | unsigned long __user *arg2) |
17 | { | 17 | { |
18 | unsigned long *ptr = addr, tmp; | 18 | unsigned long *ptr = arg2, tmp; |
19 | long ret; | 19 | long ret; |
20 | int pid = task->mm->context.id.u.pid; | 20 | int pid = task->mm->context.id.u.pid; |
21 | 21 | ||
@@ -65,19 +65,19 @@ long arch_prctl(struct task_struct *task, int option | |||
65 | ret = save_registers(pid, ¤t->thread.regs.regs); | 65 | ret = save_registers(pid, ¤t->thread.regs.regs); |
66 | break; | 66 | break; |
67 | case ARCH_GET_FS: | 67 | case ARCH_GET_FS: |
68 | ret = put_user(tmp, addr); | 68 | ret = put_user(tmp, arg2); |
69 | break; | 69 | break; |
70 | case ARCH_GET_GS: | 70 | case ARCH_GET_GS: |
71 | ret = put_user(tmp, addr); | 71 | ret = put_user(tmp, arg2); |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | 74 | ||
75 | return ret; | 75 | return ret; |
76 | } | 76 | } |
77 | 77 | ||
78 | SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, addr) | 78 | SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2) |
79 | { | 79 | { |
80 | return arch_prctl(current, option, (unsigned long __user *) addr); | 80 | return arch_prctl(current, option, (unsigned long __user *) arg2); |
81 | } | 81 | } |
82 | 82 | ||
83 | void arch_switch_to(struct task_struct *to) | 83 | void arch_switch_to(struct task_struct *to) |