Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FED8C169C4 for ; Thu, 31 Jan 2019 11:32:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1ED0B218E2 for ; Thu, 31 Jan 2019 11:32:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="hIqk/gmI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732387AbfAaLcV (ORCPT ); Thu, 31 Jan 2019 06:32:21 -0500 Received: from forwardcorp1o.cmail.yandex.net ([37.9.109.47]:55165 "EHLO forwardcorp1o.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbfAaLcV (ORCPT ); Thu, 31 Jan 2019 06:32:21 -0500 X-Greylist: delayed 613 seconds by postgrey-1.27 at vger.kernel.org; Thu, 31 Jan 2019 06:32:19 EST Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id BC8862187D; Thu, 31 Jan 2019 14:22:04 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7UXWJllN0T-M4xGf0rb; Thu, 31 Jan 2019 14:22:04 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1548933724; bh=dwYcjTpkMEkVweQjkOCtLB1Up3ohjnMfb4Dcnq/XcDk=; h=Subject:From:To:Date:Message-ID; b=hIqk/gmIcJfDvtPcp1WEEvyVUjpefyUiVt2YIyNx2IfQdP3GRhoLzlMZgu0KzuQIW qXpplcnBsMD7DIKv9+8JOL2vxs+0lSbgIRAZBNT98CJsEew4lzmY9YJQr9JefTyV8O zugyB9lRQwGL8iiizXIjcoh7QwcimhhPICXuhdXk= Authentication-Results: mxbackcorp1g.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ccb1:d36:e945:f357]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id HuqxsctleA-M44mYtu3; Thu, 31 Jan 2019 14:22:04 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH 4.4] mm/gup: add compat macro for get_user_pages From: Konstantin Khlebnikov To: Greg Kroah-Hartman , Ben Hutchings , Lorenzo Stoakes , stable@vger.kernel.org Date: Thu, 31 Jan 2019 14:22:01 +0300 Message-ID: <154893372158.59047.15701214929637353941.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This fixes API breakage introduced in v4.4.168 commit 8e50b8b07f46 ("mm: replace get_user_pages() write/force parameters with gup_flags"). For example odious nvidia out-of-tree modules does not compile. After that commit prototype of get_user_pages() looks like: long get_user_pages(task, mm, start, nr_pages, gup_flags, pages, vmas) that's incompatible neither with v4.4 and before: long get_user_pages(task, mm, start, nr_pages, write, force, pages, vmas) nor with v4.6 and later: long get_user_pages(start, nr_pages, gup_flags, pages, vmas) This patch uses the same va-args macro magic as commit cde70140fed8 ("mm/gup: Overload get_user_pages() functions"). The alternative is upgrading GUP API to modern state. Signed-off-by: Konstantin Khlebnikov --- include/linux/mm.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 77066c96f5e9..5337d4b59052 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2334,5 +2334,28 @@ void __init setup_nr_node_ids(void); static inline void setup_nr_node_ids(void) {} #endif +#ifdef MODULE + +/* Compat API for external modules */ + +static inline __deprecated +long get_user_pages8(struct task_struct *tsk, struct mm_struct *mm, + unsigned long start, unsigned long nr_pages, + int write, int force, struct page **pages, + struct vm_area_struct **vmas) +{ + return get_user_pages(tsk, mm, start, nr_pages, + (write ? FOLL_WRITE : 0) | + (force ? FOLL_FORCE : 0), + pages, vmas); +} + +#define GUP_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, gup, ...) gup + +#define get_user_pages(...) GUP_MACRO(__VA_ARGS__, \ + get_user_pages8, get_user_pages, x, x, x, x, x, x)(__VA_ARGS__) + +#endif /* MODULE */ + #endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */