From patchwork Mon Jan 25 22:24:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 8116291 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 184609F818 for ; Mon, 25 Jan 2016 22:24:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AE9820398 for ; Mon, 25 Jan 2016 22:24:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70EE2203AA for ; Mon, 25 Jan 2016 22:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932805AbcAYWYu (ORCPT ); Mon, 25 Jan 2016 17:24:50 -0500 Received: from mail.kernel.org ([198.145.29.136]:49769 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932756AbcAYWYo (ORCPT ); Mon, 25 Jan 2016 17:24:44 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E1F820389; Mon, 25 Jan 2016 22:24:42 +0000 (UTC) Received: from localhost (199-83-221-254.PUBLIC.monkeybrains.net [199.83.221.254]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A264D20376; Mon, 25 Jan 2016 22:24:41 +0000 (UTC) From: Andy Lutomirski To: Andrew Morton Cc: Andy Lutomirski , Al Viro , Linus Torvalds , x86@kernel.org, linux-arch , David Miller , "linux-s390@vger.kernel.org" , Chris Metcalf , linux-parisc@vger.kernel.org, linux-mips@linux-mips.org, sparclinux@vger.kernel.org Subject: [PATCH v2 01/16] compat: Add in_compat_syscall to ask whether we're in a compat syscall Date: Mon, 25 Jan 2016 14:24:15 -0800 Message-Id: <4cd121066a85fe57356569e3bae28fe9d7098806.1453759363.git.luto@kernel.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A lot of code currently abuses is_compat_task to determine this. Signed-off-by: Andy Lutomirski --- include/linux/compat.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/compat.h b/include/linux/compat.h index a76c9172b2eb..f911bcec618f 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -5,6 +5,8 @@ * syscall compatibility layer. */ +#include + #ifdef CONFIG_COMPAT #include @@ -713,9 +715,22 @@ asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, int, const char __user *); + +/* + * 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(); } +#endif + #else #define is_compat_task() (0) +static inline bool in_compat_syscall(void) { return false; } #endif /* CONFIG_COMPAT */ + #endif /* _LINUX_COMPAT_H */