From patchwork Tue Nov 1 01:37:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Huey X-Patchwork-Id: 9406809 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 5F9B9601C0 for ; Tue, 1 Nov 2016 01:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5113F28D62 for ; Tue, 1 Nov 2016 01:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 451BE29396; Tue, 1 Nov 2016 01:41:03 +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=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 C00BF28D62 for ; Tue, 1 Nov 2016 01:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161339AbcKABkh (ORCPT ); Mon, 31 Oct 2016 21:40:37 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36732 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161227AbcKABia (ORCPT ); Mon, 31 Oct 2016 21:38:30 -0400 Received: by mail-pf0-f194.google.com with SMTP id n85so10124825pfi.3 for ; Mon, 31 Oct 2016 18:38:30 -0700 (PDT) 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=i9shIF9B1DqIZab7tJ2Kn6GXku04l/NDjzEEzA0pq5E=; b=X9Dc1CUesMVEW58ydh9finY+vMIcMfK2xyltKcyR/zdM87xKuK6OkDvy9eNNe1+i7+ RMDgXOzFhzXVAzWdsUYVJhpgnC7D72aXhM9rTzxdU4w40XKundL6olrK1lRnT5je4Kbi vtgktFCnxnAbszkELo6uRvz3g6htSU1YMM3y/nBqRVagpMG4o9D55WjiCzuL72HuT/DJ 539AYQ3eTdHLeVQTYKKwI3aoBWLB4QAF7hFJx/FLNFhyeS0ACFy2vJD9tJLHxiwO/UDE Tk2dGbdZ8kHGYggz8DRvaEWjFh8huTzmVvQ2B2d2E0arvFnmnRol/Dd3ciWE6QG6Bpfa O8sQ== 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=i9shIF9B1DqIZab7tJ2Kn6GXku04l/NDjzEEzA0pq5E=; b=f/+CCUnaanDvTC1ziPw3tWulkzhyCdBocbfnHydq/6OcYiY6Ev/3wwB7WpXPYTU+y1 mo3FLKHW112/frnL8B8dsbOscIniNQcYcI0ts8/z6j3waeX/6I43CtmHtnocP9CXiIf3 HNrYeLVCaHKyPTNpJhLdLTlidnOyBKSSa2nUb696sBXIu0KwUpO9f/GTLSDv/6GoBNuO YEDrRM2WG02zVKahxzkNg4WkoLyLi+XtMNdXAM/l9LZNB9PKVRFBZzE40Buo5JdwfSyv qRfNw+J3IREzh6F2DM2xZlcX3pvEKUa3oe+vwz2ub0zghjY1rucUQXC58tqJCB3IfF0k pstg== X-Gm-Message-State: ABUngvdznc/xwjv+AKbWGFNXm07bUdMYqq2jReu6jskkcOzODLa8nSyj+FmnlZtw3goivA== X-Received: by 10.98.106.196 with SMTP id f187mr54520177pfc.91.1477964309591; Mon, 31 Oct 2016 18:38:29 -0700 (PDT) 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 u17sm38188144pfi.1.2016.10.31.18.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Oct 2016 18:38:29 -0700 (PDT) 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 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 v8 3/7] x86/arch_prctl: Add do_arch_prctl_common Date: Mon, 31 Oct 2016 18:37:45 -0700 Message-Id: <20161101013749.4003-4-khuey@kylehuey.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161101013749.4003-1-khuey@kylehuey.com> References: <20161101013749.4003-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 bits. 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 | 1 + arch/x86/kernel/process.c | 5 +++++ arch/x86/kernel/process_64.c | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h index 95c3e51..f72b551 100644 --- a/arch/x86/include/asm/proto.h +++ b/arch/x86/include/asm/proto.h @@ -25,13 +25,14 @@ 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 arg2); #ifdef CONFIG_X86_64 long do_arch_prctl_64(struct task_struct *task, int code, unsigned long arg2); #endif #endif /* _ASM_X86_PROTO_H */ diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 0888a87..d0126b2 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -579,8 +579,13 @@ 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 arg2) +{ + 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; }