From patchwork Wed Feb 8 08:09:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 9561889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD5AE60434 for ; Wed, 8 Feb 2017 08:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8AF28488 for ; Wed, 8 Feb 2017 08:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C32FD2849C; Wed, 8 Feb 2017 08:11:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F92A28488 for ; Wed, 8 Feb 2017 08:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932969AbdBHILi (ORCPT ); Wed, 8 Feb 2017 03:11:38 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34114 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753955AbdBHIJh (ORCPT ); Wed, 8 Feb 2017 03:09:37 -0500 Received: by mail-pf0-f193.google.com with SMTP id y143so11152165pfb.1 for ; Wed, 08 Feb 2017 00:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=16dMaNZD3iTbqojYkbkvucPn4cAYVL3m72UD8VpWshQ=; b=be60LI9dWq+Ni4yaBlfLSBWorDGnU3AfqTBQDj/XWBk8nDsxP61Oa6uIk3fYJnr8BT Q6sl9spTYcbaMlK+0uQ3Qyj1idGCz5lIDwCw+eQHGSzrdpQgOmw8Z1PaKmqZtk3j9hJ5 6+b2ZVbCt35mIxbKnrdGKghUEiMwglT1tBbZgRzUVNFb2NbQMy/m9cgz+VbjBFP8RLJn cUW2fk8HaKTcGhCq7r2lBZaxxzeJz6u6XLu+s9WmMnBSXGbpPgG4TUFRomwjFhR8nmUl CPFqmtkJNwwzJf/xXXriCOD46fHwMHgXphn2WxxpbXnfdyRBLAswqllIXG0nO/9yvgmU YIzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=16dMaNZD3iTbqojYkbkvucPn4cAYVL3m72UD8VpWshQ=; b=OIl7VbuQ7dKM01IsrKcDPxtR19R8/MXtGmXB5LbUjENxbvsFkD33TgjurGsbcWqj2g GHO+VJfcK6wkJ9wFJZNlVsfIkO0rwF0u5++eSYmaOm9LMfrVmkyuUYBodrgc3ivXTRc5 gah9r+dcmmITViz2ZiOkd5+ZIZEtzHssYzX5KVKhPKRxagROUh0JyaDZ/nvl/ifHAVCB vf+evCDsh+aP8EMqUS8WR+OH2cHwYS5MZIw5VJx25trGVF0/2y+fnHMizMbd79UspmDN 4XWk8RCzWW8bug73M5R7m67+zddGbx9MR/y+a9JgxQeiFlWE8Y7rIyQzutWBrCtjwRQk nwGw== X-Gm-Message-State: AIkVDXJvKN0W9xYpPbY8+BF+XeE8VFVmVu6VSVQMEKzMen9NBRcg4sYJqlxHDph6JluktA== X-Received: by 10.99.146.91 with SMTP id s27mr25783773pgn.30.1486541377150; Wed, 08 Feb 2017 00:09:37 -0800 (PST) Received: from minbar.home.kylehuey.com (c-50-150-100-179.hsd1.ca.comcast.net. [50.150.100.179]) by smtp.gmail.com with ESMTPSA id j28sm17585078pfj.2.2017.02.08.00.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Feb 2017 00:09:36 -0800 (PST) From: Kyle Huey X-Google-Original-From: Kyle Huey To: Robert O'Callahan , Thomas Gleixner , Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Jeff Dike , Richard Weinberger , Alexander Viro , Shuah Khan , Dave Hansen , Borislav Petkov , Peter Zijlstra , Boris Ostrovsky , Len Brown , "Rafael J. Wysocki" , Dmitry Safonov , David Matlack , Nadav Amit , Andi Kleen Cc: linux-kernel@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net, user-mode-linux-user@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v14 4/9] x86/syscalls/32: Wire up arch_prctl on x86-32 Date: Wed, 8 Feb 2017 00:09:12 -0800 Message-Id: <20170208080917.24320-5-khuey@kylehuey.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170208080917.24320-1-khuey@kylehuey.com> References: <20170208080917.24320-1-khuey@kylehuey.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hook up arch_prctl to call do_arch_prctl() on x86-32, and in 32 bit compat mode on x86-64. This allows us to have arch_prctls that are not specific to 64 bits. On UML, simply stub out this syscall. Signed-off-by: Kyle Huey --- arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/kernel/process_32.c | 7 +++++++ arch/x86/kernel/process_64.c | 7 +++++++ arch/x86/um/Makefile | 2 +- arch/x86/um/syscalls_32.c | 7 +++++++ include/linux/compat.h | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 arch/x86/um/syscalls_32.c diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 2b3618542544..d78c6b53e9a2 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -384,8 +384,9 @@ 375 i386 membarrier sys_membarrier 376 i386 mlock2 sys_mlock2 377 i386 copy_file_range sys_copy_file_range 378 i386 preadv2 sys_preadv2 compat_sys_preadv2 379 i386 pwritev2 sys_pwritev2 compat_sys_pwritev2 380 i386 pkey_mprotect sys_pkey_mprotect 381 i386 pkey_alloc sys_pkey_alloc 382 i386 pkey_free sys_pkey_free +385 i386 arch_prctl sys_arch_prctl compat_sys_arch_prctl diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index a0ac3e81518a..c24e72d7ce83 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -30,16 +30,17 @@ #include #include #include #include #include #include #include #include +#include #include #include #include #include #include #ifdef CONFIG_MATH_EMULATION #include @@ -49,16 +50,17 @@ #include #include #include #include #include #include #include +#include void __show_regs(struct pt_regs *regs, int all) { unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; unsigned long d0, d1, d2, d3, d6, d7; unsigned long sp; unsigned short ss, gs; @@ -297,8 +299,13 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) this_cpu_write(current_task, next_p); /* Load the Intel cache allocation PQR MSR. */ intel_rdt_sched_in(); return prev_p; } + +SYSCALL_DEFINE2(arch_prctl, int, code, unsigned long, arg2) +{ + return do_arch_prctl_common(current, code, arg2); +} diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 4db1ebcf18e0..e67cd9557ff8 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -628,12 +628,19 @@ SYSCALL_DEFINE2(arch_prctl, int, code, unsigned long, arg2) ret = do_arch_prctl_64(current, code, arg2); if (ret == -EINVAL) ret = do_arch_prctl_common(current, code, arg2); return ret; } +#ifdef CONFIG_IA32_EMULATION +COMPAT_SYSCALL_DEFINE2(arch_prctl, int, code, unsigned long, arg2) +{ + return do_arch_prctl_common(current, code, arg2); +} +#endif + unsigned long KSTK_ESP(struct task_struct *task) { return task_pt_regs(task)->sp; } diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile index e7e7055a8658..69f0827d5f53 100644 --- a/arch/x86/um/Makefile +++ b/arch/x86/um/Makefile @@ -11,17 +11,17 @@ endif obj-y = bug.o bugs_$(BITS).o delay.o fault.o ldt.o \ ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \ stub_$(BITS).o stub_segv.o \ sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \ mem_$(BITS).o subarch.o os-$(OS)/ ifeq ($(CONFIG_X86_32),y) -obj-y += checksum_32.o +obj-y += checksum_32.o syscalls_32.o obj-$(CONFIG_ELF_CORE) += elfcore.o subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o subarch-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += ../lib/rwsem.o else obj-y += syscalls_64.o vdso/ diff --git a/arch/x86/um/syscalls_32.c b/arch/x86/um/syscalls_32.c new file mode 100644 index 000000000000..ccf0598c3fc0 --- /dev/null +++ b/arch/x86/um/syscalls_32.c @@ -0,0 +1,7 @@ +#include +#include + +SYSCALL_DEFINE2(arch_prctl, int, code, unsigned long, arg2) +{ + return -EINVAL; +} diff --git a/include/linux/compat.h b/include/linux/compat.h index 63609398ef9f..0ddfc2ba0d06 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -716,16 +716,18 @@ int __compat_save_altstack(compat_stack_t __user *, unsigned long); } while (0); asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval); asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, int, const char __user *); +asmlinkage long compat_sys_arch_prctl(int code, unsigned long arg2); + /* * For most but not all architectures, "am I in a compat syscall?" and * "am I a compat task?" are the same question. For architectures on which * they aren't the same question, arch code can override in_compat_syscall. */ #ifndef in_compat_syscall static inline bool in_compat_syscall(void) { return is_compat_task(); }