From patchwork Mon Nov 28 03:05:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 9449013 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 311166071B for ; Mon, 28 Nov 2016 03:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20A5D2074F for ; Mon, 28 Nov 2016 03:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1416523201; Mon, 28 Nov 2016 03:06:43 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham 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 7D74E2074F for ; Mon, 28 Nov 2016 03:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754278AbcK1DGG (ORCPT ); Sun, 27 Nov 2016 22:06:06 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35312 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754142AbcK1DFt (ORCPT ); Sun, 27 Nov 2016 22:05:49 -0500 Received: by mail-pg0-f66.google.com with SMTP id p66so11720736pga.2 for ; Sun, 27 Nov 2016 19:05:48 -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=wkE09GjBWIkdtumOj5NzPWAAawmYjz0K0Xik1quhZ10=; b=eFXMy1AhNocUtZXQUu+y7NUqS0bo2E8SrhxvlU7B9c9Giza0DgIKiChtIDQs2c25N7 fUDrrsTpK3TtIt3g3w16ATt3us9Kg7rLqr8dLTwihhZjrktWPWTO9NiC83oQuuEHv6bx SI6pncmTU+KiUg7bnb5PDP8LQcAoSPO0HPY4pzHwDA6OmWjxTBOLi5FBSy5VyylyjaOr s4OjXUnDhlurdnXUfKv6lJMOU2sI3oOq6MfaLo/cJtClwLVZUhm8GVh3PPtMps79v0DM Dfwm9+szGZwDm1vSGvGthrpxzQ0aIxI7+BvAfegGV25GZYjpTkM+Om3K41QzP2Pispoy DvMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wkE09GjBWIkdtumOj5NzPWAAawmYjz0K0Xik1quhZ10=; b=lHLVSZz1rs/LlLKV6mLZCiaK08uAN+LOpTxbsdAV3LhPPRYYfvqFvyVrNF3UQ48SXF hvx6ZpR9lHU3rDhNOYZtrF/2sDwswUhqkm4Rn1KQ0C+rRkNri3OUEefc/alqFqdlYbPT jZyfFBbhcUj2Pnj1Y8DrA/CyY2csjX/Np12khB1SkMRH89fu0b1piIkZb4mFMjnbrzkr EqJz/BEaZUgyzycxSvmZ1NITeyE3Kb4fDmZxPwbL3rsBKKDL5wKTMFH3eP912w5ksdq4 NFCWI/PUJy8a5RIg7EjBbthyfr9X3JrNRxHrnJp3Ai/PAguAvlDZnVIk4r5DoiXXZipA f/5Q== X-Gm-Message-State: AKaTC01i7C/e/08QEptVqVgN92zefU2qvFsPqLWqitYbdeyIHR4z38Pk4wdfLa3bkVi1Vw== X-Received: by 10.84.141.129 with SMTP id 1mr44745102plv.102.1480302348223; Sun, 27 Nov 2016 19:05:48 -0800 (PST) Received: from minbar.hsd1.ca.comcast.net (c-73-162-102-141.hsd1.ca.comcast.net. [73.162.102.141]) by smtp.gmail.com with ESMTPSA id l7sm82734316pfg.35.2016.11.27.19.05.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 27 Nov 2016 19:05:47 -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 v13 3/8] x86/arch_prctl: Add do_arch_prctl_common Date: Sun, 27 Nov 2016 19:05:16 -0800 Message-Id: <20161128030521.4423-4-khuey@kylehuey.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161128030521.4423-1-khuey@kylehuey.com> References: <20161128030521.4423-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 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 f8e9194..99836d9 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 0888a87..5ac20b5 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -579,8 +579,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 611df20..bf75d26 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -612,15 +612,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; }