From patchwork Fri Jul 17 03:04:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 11668865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12F3F1392 for ; Fri, 17 Jul 2020 03:04:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D4A232076A for ; Fri, 17 Jul 2020 03:04:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4A232076A 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DEAF38D0003; Thu, 16 Jul 2020 23:04:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,,d41d8cd98f00b204,jarkko.sakkinen@linux.intel.com,,RULES_HIT:30012:30054,0,RBL:192.55.52.88:@linux.intel.com:.lbl8.mailshell.net-64.95.201.95 62.18.0.100;04y81yy47btbxz5zq6fbawst76q4yocztqe8suy99nbnb8igxepghfpjuy871bc.194zprpay7ausw1cratdn7zzy6z9331xbiwh4kmtkb6jgcqu4qdusgjy9u7j4gb.4-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none 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 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 Reported-by: kernel test robot Reported-by: kernel test robot Signed-off-by: Mike Rapoport --- 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 #include @@ -249,4 +250,26 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) int register_vmap_purge_notifier(struct notifier_block *nb); int unregister_vmap_purge_notifier(struct notifier_block *nb); +#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 */