Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1670247ybh; Thu, 16 Jul 2020 20:06:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHH/tNcqLi7RW3JdhNrttybGCMUsUt43x+V0TE7k5I4Qkkxv8ZjwuqazViYbfWkSpo0c9X X-Received: by 2002:a17:906:60c6:: with SMTP id f6mr6315116ejk.265.1594955196760; Thu, 16 Jul 2020 20:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594955196; cv=none; d=google.com; s=arc-20160816; b=phLNn3Tv05w1GWJo+SjVnQh3YxxQsZdKUITTgDP/vZdgVnsCiIbx5QEysDboc65lhI /PSbLQPByx4SufcHtI665IDFEWwDHRWJeLy+mKLLCIAkcKo1XSmHbDBUQ5mFbmoD8zvN dCCPP/Jutz3COP3f6hkOEFy8uU+lsRrfNDIDgIgv6pKs421N5KFNqyzklC9IHU9Jy302 +Bjji9GoSSLd17O7m6BM8G38d8E9pm4QNx/w2e1wdXl/+f/rPHrcF5CtDcjsi8JHINRq avzFDJYA+PKG9TLEgzJBjMsbZHLnALJQXrKAanbBorRB75MXa9qhcS47X0D8WuaIxJ+Q KHxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=SaaDQsk75k3MuyjoO4Wj5tPGNJm7sIXQZg/AJrRHMXE=; b=odip1VTuYs1DqzcC5DUS+rgBbCAme/e/iNkmgUFWZeuVbi7cBXxEEVEg4wdbWvWTRL CwKTyaRCgpZEbR8uB0w7P/8RfLlmG36QmpnmGtf2pZhjRN6t+7j5DyKoRAaKlOkRkQgN 9B14kMK+IVCKz4NaV2RnEZ116U/o2pa/sMD72i1nDxatwoCIEm6uewyweHulfV7Qw6JC 2ikuCgrFWQlbvFHzk9l4JHbIkR0749aii3p2jfqxefxU+y3q9a5h/NRxmClz9aBj41BB 5XB+g6xYa/hirg9JGkFPujOIBvAnT/SK/V9umdKz7E5UxLryqpD3oBvbqc9W5l4PI3tP zPzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si4684132edu.361.2020.07.16.20.06.13; Thu, 16 Jul 2020 20:06:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727825AbgGQDEv (ORCPT + 99 others); Thu, 16 Jul 2020 23:04:51 -0400 Received: from mga07.intel.com ([134.134.136.100]:27257 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726333AbgGQDEu (ORCPT ); Thu, 16 Jul 2020 23:04:50 -0400 IronPort-SDR: frDmIyvt8bPd8Bu1l1sgSEV1fJFbP5AxUDFHNtzsL9FmxkTAXN9YCs3ftYXPFn6ZJXpK3TkFSz Ni8R8aBkK7zg== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="214253048" X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="214253048" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 #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 */ -- 2.25.1