[tip:x86/process] x86/arch_prctl: Add do_arch_prctl_common()
From: tip-bot for Kyle Huey
Date: Mon Mar 20 2017 - 12:34:24 EST
Commit-ID: b0b9b014016d16ca7a192da986aa8ebae21bb995
Gitweb: http://git.kernel.org/tip/b0b9b014016d16ca7a192da986aa8ebae21bb995
Author: Kyle Huey <me@xxxxxxxxxxxx>
AuthorDate: Mon, 20 Mar 2017 01:16:23 -0700
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitDate: Mon, 20 Mar 2017 16:10:33 +0100
x86/arch_prctl: Add do_arch_prctl_common()
Add do_arch_prctl_common() to handle arch_prctls that are not specific to 64
bit mode. Call it from the syscall entry point, but not any of the other
callsites in the kernel, which all want one of the existing 64 bit only
arch_prctls.
Signed-off-by: Kyle Huey <khuey@xxxxxxxxxxxx>
Cc: Grzegorz Andrejczuk <grzegorz.andrejczuk@xxxxxxxxx>
Cc: kvm@xxxxxxxxxxxxxxx
Cc: Radim KrÄmÃÅ <rkrcmar@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Andi Kleen <andi@xxxxxxxxxxxxxx>
Cc: linux-kselftest@xxxxxxxxxxxxxxx
Cc: Nadav Amit <nadav.amit@xxxxxxxxx>
Cc: Robert O'Callahan <robert@xxxxxxxxxxxxx>
Cc: Richard Weinberger <richard@xxxxxx>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxx>
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
Cc: Len Brown <len.brown@xxxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
Cc: user-mode-linux-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: Jeff Dike <jdike@xxxxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: user-mode-linux-user@xxxxxxxxxxxxxxxxxxxxx
Cc: David Matlack <dmatlack@xxxxxxxxxx>
Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Cc: Dmitry Safonov <dsafonov@xxxxxxxxxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Link: http://lkml.kernel.org/r/20170320081628.18952-6-khuey@xxxxxxxxxxxx
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
arch/x86/include/asm/proto.h | 3 +++
arch/x86/kernel/process.c | 6 ++++++
arch/x86/kernel/process_64.c | 8 +++++++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 4e276f6..8d3964f 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -31,4 +31,7 @@ void x86_report_nx(void);
extern int reboot_force;
+long do_arch_prctl_common(struct task_struct *task, int option,
+ unsigned long cpuid_enabled);
+
#endif /* _ASM_X86_PROTO_H */
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 366db77..b12e95e 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -545,3 +545,9 @@ out:
put_task_stack(p);
return ret;
}
+
+long do_arch_prctl_common(struct task_struct *task, int option,
+ unsigned long cpuid_enabled)
+{
+ return -EINVAL;
+}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e37f764..d81b0a6 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -626,7 +626,13 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
{
- return do_arch_prctl_64(current, option, arg2);
+ long ret;
+
+ ret = do_arch_prctl_64(current, option, arg2);
+ if (ret == -EINVAL)
+ ret = do_arch_prctl_common(current, option, arg2);
+
+ return ret;
}
unsigned long KSTK_ESP(struct task_struct *task)