From patchwork Wed Feb 8 08:09:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 9561893 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 A681F60434 for ; Wed, 8 Feb 2017 08:12:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9953726490 for ; Wed, 8 Feb 2017 08:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DA0428495; Wed, 8 Feb 2017 08:12:02 +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 45D7426490 for ; Wed, 8 Feb 2017 08:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753940AbdBHIJh (ORCPT ); Wed, 8 Feb 2017 03:09:37 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:32814 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbdBHIJf (ORCPT ); Wed, 8 Feb 2017 03:09:35 -0500 Received: by mail-pf0-f193.google.com with SMTP id e4so11141423pfg.0 for ; Wed, 08 Feb 2017 00:09:34 -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=6bAXJ6apaZPCU3kSw6wd9rKfuBSJF5Pm9vzbTJ1ZSo8=; b=BYPZ2cnhODu0YAf7C2X2BXpARqjNHLBHULXz7JnYMYy6MJIf0ej0gfXO5h1HMHRMhc Tx0kYSpnIKVwuqUbConHe9HDkpmBtgfi3SOI6TW8HdPHcv8/Kw1LQAwmjvogXi00SPVR 7iw9tBLAFIbu9a0u7H+Hz38LeHZsgaBNFJyFv3RDBimj6rxA1DpLJZxJFyxd2B+T98ji b1wcok9vd/BHm2e0KSAiR0iO2Uy4MxaOd6Kw2tvxxAx27GaRonMJ9HmMuUxmnqNREGuk Px0Kn9X4f/T9jA056d3IcUy6cD4XJR3ztp0kGfZZgkq++pM8TXVGkd8h42iH1XqP/PbA NAcA== 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=6bAXJ6apaZPCU3kSw6wd9rKfuBSJF5Pm9vzbTJ1ZSo8=; b=X1mAVUnHGMmUXrZnT39uuvwpYJ8Ii/opOK5k89Sg9R1jSTcV4nuUNc53HlERvkn890 LXzkHh53tVGpilfmjiFHR/ZCLutvcCFwnhuV1Tjfznc4i8nkvX/eZx8IScxSQUql4tEC hzTGSNsy4TIg3Vl1jDK5crbKT/t1IqQs7e4ekeotQxlbE2wpgNJi6tTIftPLR9OqC+/e YLF59+TB/cajGYUrKkQQfKa0n9qkVbkF28wM6eqxUVpzcgbjxMk+BU5UlfcE+XVJR+y5 r/tSgXi777/doBTCmdGCIe4tLvzZOlbkKgNl/nSkL3jvsVslCwvC/JeISK+aGK3XbEzg PXdg== X-Gm-Message-State: AIkVDXLmcVXABiL2I83oBKODdWsrSAMor3v02Zs1KyhQsYZSXssJd7o4E+IItJLBZDCdTQ== X-Received: by 10.99.173.14 with SMTP id g14mr25665745pgf.176.1486541374258; Wed, 08 Feb 2017 00:09:34 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Feb 2017 00:09:33 -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 3/9] x86/arch_prctl: Add do_arch_prctl_common Date: Wed, 8 Feb 2017 00:09:11 -0800 Message-Id: <20170208080917.24320-4-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: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 f8e9194e100c..99836d9a893a 100644 --- a/arch/x86/include/asm/proto.h +++ b/arch/x86/include/asm/proto.h @@ -26,9 +26,12 @@ void entry_SYSCALL_compat(void); void entry_INT80_compat(void); #endif void x86_configure_nx(void); void x86_report_nx(void); extern int reboot_force; +long do_arch_prctl_common(struct task_struct *task, int code, + unsigned long cpuid_enabled); + #endif /* _ASM_X86_PROTO_H */ diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 4f76b17045cc..edf645e331d0 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -519,8 +519,14 @@ unsigned long get_wchan(struct task_struct *p) } fp = READ_ONCE_NOCHECK(*(unsigned long *)fp); } while (count++ < 16 && p->state != TASK_RUNNING); out: put_task_stack(p); return ret; } + +long do_arch_prctl_common(struct task_struct *task, int code, + unsigned long cpuid_enabled) +{ + return -EINVAL; +} diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 83e011566db0..4db1ebcf18e0 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -619,15 +619,21 @@ long do_arch_prctl_64(struct task_struct *task, int code, unsigned long arg2) break; } return ret; } SYSCALL_DEFINE2(arch_prctl, int, code, unsigned long, arg2) { - return do_arch_prctl_64(current, code, arg2); + long ret; + + ret = do_arch_prctl_64(current, code, arg2); + if (ret == -EINVAL) + ret = do_arch_prctl_common(current, code, arg2); + + return ret; } unsigned long KSTK_ESP(struct task_struct *task) { return task_pt_regs(task)->sp; }