From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 B5F57C433EA for ; Fri, 17 Jul 2020 03:04:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 822DB2076A for ; Fri, 17 Jul 2020 03:04:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 822DB2076A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E3B508D0009; Thu, 16 Jul 2020 23:04:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEAF38D0003; Thu, 16 Jul 2020 23:04:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D00628D0009; Thu, 16 Jul 2020 23:04:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id BB0318D0003 for ; Thu, 16 Jul 2020 23:04:53 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 49520824999B for ; Fri, 17 Jul 2020 03:04:53 +0000 (UTC) X-FDA: 77046075666.04.toys23_060745926f07 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 25801800B505 for ; Fri, 17 Jul 2020 03:04:53 +0000 (UTC) X-HE-Tag: toys23_060745926f07 X-Filterd-Recvd-Size: 3382 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Jul 2020 03:04:52 +0000 (UTC) IronPort-SDR: amXz+L1tmj32WkVsLqudHuREiheUA/rwJHkZ3UCrUwmRfX/SwQ2alZbenSKcVpn3mi9kvWOD8R ZpJh1awi9z/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="167664111" X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="167664111" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 20:04:47 -0700 IronPort-SDR: uOu7cDqrL7+h5l+5Fn+h1S/hkwpsAu3mNfFB15mMGo34p9NETnRqPy7GMfFMXihLf5C3f6k9GL 0dvnImOzaUIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="286686891" Received: from pgerasim-mobl1.ccr.corp.intel.com (HELO localhost) ([10.249.34.31]) by orsmga006.jf.intel.com with ESMTP; 16 Jul 2020 20:04:43 -0700 From: Jarkko Sakkinen To: linux-kernel@vger.kernel.org Cc: Jarkko Sakkinen , Andi Kleen , Masami Hiramatsu , Peter Zijlstra , Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT) Subject: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Date: Fri, 17 Jul 2020 06:04:17 +0300 Message-Id: <20200717030422.679972-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200717030422.679972-1-jarkko.sakkinen@linux.intel.com> References: <20200717030422.679972-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 25801800B505 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Introduce functions for allocating memory for dynamic trampolines, such as kprobes. An arch can promote the availability of these functions with CONFIG_ARCH_HAS_TEXT_ALLOC. Provide default/fallback implementation wrapping module_alloc() and module_memfree(). Cc: Andi Kleen Cc: Masami Hiramatsu Suggested-by: Peter Zijlstra Signed-off-by: Jarkko Sakkinen --- include/linux/vmalloc.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 0221f852a7e1..e981436e30b6 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -9,6 +9,7 @@ #include /* pgprot_t */ #include #include +#include =20 #include =20 @@ -249,4 +250,26 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vm= s) int register_vmap_purge_notifier(struct notifier_block *nb); int unregister_vmap_purge_notifier(struct notifier_block *nb); =20 +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC +/* + * Allocate memory to be used for dynamic trampoline code. + */ +void *text_alloc(unsigned long size); + +/* + * Free memory returned from text_alloc(). + */ +void text_free(void *region); +#else +static inline void *text_alloc(unsigned long size) +{ + return module_alloc(size); +} + +static inline void text_free(void *region) +{ + module_memfree(region); +} +#endif + #endif /* _LINUX_VMALLOC_H */ --=20 2.25.1