* [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
[not found] <20200717030422.679972-1-jarkko.sakkinen@linux.intel.com>
@ 2020-07-17 3:04 ` Jarkko Sakkinen
2020-07-17 5:33 ` kernel test robot
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Jarkko Sakkinen @ 2020-07-17 3:04 UTC (permalink / raw)
To: linux-kernel
Cc: Jarkko Sakkinen, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
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 <ak@linux.intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
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 <asm/page.h> /* pgprot_t */
#include <linux/rbtree.h>
#include <linux/overflow.h>
+#include <linux/moduleloader.h>
#include <asm/vmalloc.h>
@@ -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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-17 3:04 ` [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Jarkko Sakkinen
@ 2020-07-17 5:33 ` kernel test robot
2020-07-17 5:33 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-07-17 5:33 UTC (permalink / raw)
To: Jarkko Sakkinen, linux-kernel
Cc: kbuild-all, Jarkko Sakkinen, Andi Kleen, Masami Hiramatsu,
Peter Zijlstra, Andrew Morton, Linux Memory Management List
[-- Attachment #1: Type: text/plain, Size: 6005 bytes --]
Hi Jarkko,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.8-rc5 next-20200716]
[cannot apply to tip/x86/core tip/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/arch-x86-kprobes-Remove-MODULES-dependency/20200717-110947
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 07a56bb875afbe39dabbf6ba7b83783d166863db
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
WARNING: unmet direct dependencies detected for FRAME_POINTER
Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
Selected by
- FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86
scripts/Makefile.build:65: 'arch/ia64/kernel/palinfo.ko' 'arch/ia64/kernel/mca_recovery.ko' 'arch/ia64/kernel/err_inject.ko' will not be built even though obj-m is specified.
scripts/Makefile.build:66: You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.
In file included from include/asm-generic/percpu.h:7,
from arch/ia64/include/asm/percpu.h:46,
from arch/ia64/include/asm/processor.h:76,
from arch/ia64/include/asm/thread_info.h:12,
from include/linux/thread_info.h:38,
from include/asm-generic/preempt.h:5,
from ./arch/ia64/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/rcupdate.h:27,
from include/linux/rculist.h:11,
from include/linux/sched/signal.h:5,
from arch/ia64/kernel/asm-offsets.c:10:
include/linux/topology.h: In function 'cpu_smt_mask':
>> arch/ia64/include/asm/topology.h:45:50: error: 'cpu_sibling_map' undeclared (first use in this function)
45 | #define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
| ^~~~~~~~~~~~~~~
include/linux/percpu-defs.h:219:47: note: in definition of macro '__verify_pcpu_ptr'
219 | const void __percpu = (typeof((ptr) + 0))NULL; | ^~~
include/linux/percpu-defs.h:269:29: note: in expansion of macro 'per_cpu_ptr'
269 | #define per_cpu(var, cpu) cpu))
| ^~~~~~~~~~~
arch/ia64/include/asm/topology.h:45:42: note: in expansion of macro 'per_cpu'
45 | #define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
| ^~~~~~~
include/linux/topology.h:204:9: note: in expansion of macro 'topology_sibling_cpumask'
204 | return topology_sibling_cpumask(cpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/ia64/include/asm/topology.h:45:50: note: each undeclared identifier is reported only once for each function it appears in
45 | #define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
| ^~~~~~~~~~~~~~~
include/linux/percpu-defs.h:219:47: note: in definition of macro '__verify_pcpu_ptr'
219 | const void __percpu = (typeof((ptr) + 0))NULL; | ^~~
include/linux/percpu-defs.h:269:29: note: in expansion of macro 'per_cpu_ptr'
269 | #define per_cpu(var, cpu) cpu))
| ^~~~~~~~~~~
arch/ia64/include/asm/topology.h:45:42: note: in expansion of macro 'per_cpu'
45 | #define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
| ^~~~~~~
include/linux/topology.h:204:9: note: in expansion of macro 'topology_sibling_cpumask'
204 | return topology_sibling_cpumask(cpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/ia64/kernel/asm-offsets.c: At top level:
arch/ia64/kernel/asm-offsets.c:23:6: warning: no previous prototype for 'foo'
23 | void foo(void)
| ^~~
Makefile arch block certs crypto drivers fs include init ipc kernel lib mm net scripts security sound source usr virt [scripts/Makefile.build:114: arch/ia64/kernel/asm-offsets.s] Error 1
Target '__build' not remade because of errors.
Makefile arch block certs crypto drivers fs include init ipc kernel lib mm net scripts security sound source usr virt [Makefile:1175: prepare0] Error 2
Target 'prepare' not remade because of errors.
make: Makefile arch block certs crypto drivers fs include init ipc kernel lib mm net scripts security sound source usr virt [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +/cpu_sibling_map +45 arch/ia64/include/asm/topology.h
^1da177e4c3f41 include/asm-ia64/topology.h Linus Torvalds 2005-04-16 40
69dcc99199fe29 include/asm-ia64/topology.h Zhang, Yanmin 2006-02-03 41 #ifdef CONFIG_SMP
69dcc99199fe29 include/asm-ia64/topology.h Zhang, Yanmin 2006-02-03 42 #define topology_physical_package_id(cpu) (cpu_data(cpu)->socket_id)
69dcc99199fe29 include/asm-ia64/topology.h Zhang, Yanmin 2006-02-03 43 #define topology_core_id(cpu) (cpu_data(cpu)->core_id)
333af15341b2f6 arch/ia64/include/asm/topology.h Rusty Russell 2009-01-01 44 #define topology_core_cpumask(cpu) (&cpu_core_map[cpu])
06931e62246844 arch/ia64/include/asm/topology.h Bartosz Golaszewski 2015-05-26 @45 #define topology_sibling_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
69dcc99199fe29 include/asm-ia64/topology.h Zhang, Yanmin 2006-02-03 46 #endif
69dcc99199fe29 include/asm-ia64/topology.h Zhang, Yanmin 2006-02-03 47
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 61105 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-17 3:04 ` [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Jarkko Sakkinen
2020-07-17 5:33 ` kernel test robot
@ 2020-07-17 5:33 ` kernel test robot
2020-07-17 8:52 ` Masami Hiramatsu
2020-07-18 16:23 ` Mike Rapoport
3 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-07-17 5:33 UTC (permalink / raw)
To: Jarkko Sakkinen, linux-kernel
Cc: kbuild-all, Jarkko Sakkinen, Andi Kleen, Masami Hiramatsu,
Peter Zijlstra, Andrew Morton, Linux Memory Management List
[-- Attachment #1: Type: text/plain, Size: 38780 bytes --]
Hi Jarkko,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on jeyu/modules-next v5.8-rc5 next-20200716]
[cannot apply to tip/x86/core tip/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/arch-x86-kprobes-Remove-MODULES-dependency/20200717-110947
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 07a56bb875afbe39dabbf6ba7b83783d166863db
config: sparc-randconfig-s031-20200717 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-49-g707c5017-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from arch/sparc/include/asm/page.h:10,
from arch/sparc/include/asm/string_32.h:13,
from arch/sparc/include/asm/string.h:7,
from include/linux/string.h:20,
from include/linux/bitmap.h:9,
from include/linux/cpumask.h:12,
from arch/sparc/include/asm/smp_32.h:15,
from arch/sparc/include/asm/smp.h:7,
from arch/sparc/include/asm/switch_to_32.h:5,
from arch/sparc/include/asm/switch_to.h:7,
from arch/sparc/include/asm/ptrace.h:120,
from arch/sparc/include/asm/thread_info_32.h:19,
from arch/sparc/include/asm/thread_info.h:7,
from include/linux/thread_info.h:38,
from include/asm-generic/preempt.h:5,
from ./arch/sparc/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:16,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
>> include/linux/mmzone.h:1317:29: error: expected identifier or '(' before 'unsigned'
1317 | static inline int pfn_valid(unsigned long pfn)
| ^~~~~~~~
arch/sparc/include/asm/page_32.h:133:28: note: in definition of macro 'pfn_valid'
133 | #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
| ^~~
>> arch/sparc/include/asm/page_32.h:133:33: error: expected ')' before '>=' token
133 | #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
| ^~
include/linux/mmzone.h:1317:19: note: in expansion of macro 'pfn_valid'
1317 | static inline int pfn_valid(unsigned long pfn)
| ^~~~~~~~~
arch/sparc/include/asm/page_32.h:133:48: error: expected ')' before '&&' token
133 | #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
| ^~
include/linux/mmzone.h:1317:19: note: in expansion of macro 'pfn_valid'
1317 | static inline int pfn_valid(unsigned long pfn)
| ^~~~~~~~~
In file included from include/linux/page-flags-layout.h:28,
from include/linux/mmzone.h:19,
from include/linux/gfp.h:6,
from include/linux/umh.h:4,
from include/linux/kmod.h:9,
from include/linux/module.h:16,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/mmzone.h: In function 'pfn_in_present_section':
>> arch/sparc/include/asm/sparsemem.h:11:33: error: 'MAX_PHYS_ADDRESS_BITS' undeclared (first use in this function); did you mean 'MAX_PHYSADDR_BITS'?
11 | #define MAX_PHYSMEM_BITS MAX_PHYS_ADDRESS_BITS
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/page-flags-layout.h:31:25: note: in expansion of macro 'MAX_PHYSMEM_BITS'
31 | #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
| ^~~~~~~~~~~~~~~~
include/linux/mmzone.h:1104:34: note: in expansion of macro 'SECTIONS_SHIFT'
1104 | #define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT)
| ^~~~~~~~~~~~~~
include/linux/mmzone.h:1336:32: note: in expansion of macro 'NR_MEM_SECTIONS'
1336 | if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
| ^~~~~~~~~~~~~~~
arch/sparc/include/asm/sparsemem.h:11:33: note: each undeclared identifier is reported only once for each function it appears in
11 | #define MAX_PHYSMEM_BITS MAX_PHYS_ADDRESS_BITS
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/page-flags-layout.h:31:25: note: in expansion of macro 'MAX_PHYSMEM_BITS'
31 | #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
| ^~~~~~~~~~~~~~~~
include/linux/mmzone.h:1104:34: note: in expansion of macro 'SECTIONS_SHIFT'
1104 | #define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT)
| ^~~~~~~~~~~~~~
include/linux/mmzone.h:1336:32: note: in expansion of macro 'NR_MEM_SECTIONS'
1336 | if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
| ^~~~~~~~~~~~~~~
In file included from include/linux/local_lock.h:5,
from include/linux/radix-tree.h:19,
from include/linux/idr.h:15,
from include/linux/kernfs.h:13,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/local_lock_internal.h: In function 'local_lock_acquire':
>> include/linux/local_lock_internal.h:41:13: error: 'current' undeclared (first use in this function)
41 | l->owner = current;
| ^~~~~~~
In file included from include/linux/kernel.h:11,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:15,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/local_lock_internal.h: In function 'local_lock_release':
include/linux/local_lock_internal.h:46:34: error: 'current' undeclared (first use in this function)
46 | DEBUG_LOCKS_WARN_ON(l->owner != current);
| ^~~~~~~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/local_lock_internal.h:46:2: note: in expansion of macro 'DEBUG_LOCKS_WARN_ON'
46 | DEBUG_LOCKS_WARN_ON(l->owner != current);
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/sched/signal.h:7,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/sched.h: In function 'is_percpu_thread':
>> include/linux/sched.h:1552:10: error: 'current' undeclared (first use in this function)
1552 | return (current->flags & PF_NO_SETAFFINITY) &&
| ^~~~~~~
include/linux/sched.h: In function 'current_restore_flags':
include/linux/sched.h:1613:2: error: 'current' undeclared (first use in this function)
1613 | current->flags &= ~flags;
| ^~~~~~~
In file included from arch/sparc/include/asm/uaccess.h:7,
from include/linux/uaccess.h:11,
from include/linux/sched/task.h:11,
from include/linux/sched/signal.h:9,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
arch/sparc/include/asm/uaccess_32.h: In function 'clear_user':
>> arch/sparc/include/asm/uaccess_32.h:28:19: error: 'current' undeclared (first use in this function)
28 | #define get_fs() (current->thread.current_ds)
| ^~~~~~~
arch/sparc/include/asm/uaccess_32.h:38:49: note: in definition of macro '__user_ok'
38 | #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
| ^~~~
arch/sparc/include/asm/uaccess_32.h:40:53: note: in expansion of macro 'get_fs'
40 | #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
| ^~~~~~
arch/sparc/include/asm/uaccess_32.h:273:11: note: in expansion of macro '__access_ok'
273 | if (n && __access_ok((unsigned long) addr, n))
| ^~~~~~~~~~~
In file included from include/linux/kernel.h:11,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:15,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/uaccess.h: In function '_copy_from_user':
>> arch/sparc/include/asm/uaccess_32.h:28:19: error: 'current' undeclared (first use in this function)
28 | #define get_fs() (current->thread.current_ds)
| ^~~~~~~
include/linux/compiler.h:77:40: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
arch/sparc/include/asm/uaccess_32.h:40:34: note: in expansion of macro '__user_ok'
40 | #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
| ^~~~~~~~~
arch/sparc/include/asm/uaccess_32.h:40:53: note: in expansion of macro 'get_fs'
40 | #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
| ^~~~~~
arch/sparc/include/asm/uaccess_32.h:41:31: note: in expansion of macro '__access_ok'
41 | #define access_ok(addr, size) __access_ok((unsigned long)(addr), size)
| ^~~~~~~~~~~
include/linux/uaccess.h:111:13: note: in expansion of macro 'access_ok'
111 | if (likely(access_ok(from, n))) {
| ^~~~~~~~~
In file included from arch/sparc/include/asm/uaccess.h:7,
from include/linux/uaccess.h:11,
from include/linux/sched/task.h:11,
from include/linux/sched/signal.h:9,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/uaccess.h: In function '_copy_to_user':
>> arch/sparc/include/asm/uaccess_32.h:28:19: error: 'current' undeclared (first use in this function)
28 | #define get_fs() (current->thread.current_ds)
| ^~~~~~~
arch/sparc/include/asm/uaccess_32.h:38:49: note: in definition of macro '__user_ok'
38 | #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
| ^~~~
arch/sparc/include/asm/uaccess_32.h:40:53: note: in expansion of macro 'get_fs'
40 | #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
| ^~~~~~
arch/sparc/include/asm/uaccess_32.h:41:31: note: in expansion of macro '__access_ok'
41 | #define access_ok(addr, size) __access_ok((unsigned long)(addr), size)
| ^~~~~~~~~~~
include/linux/uaccess.h:129:6: note: in expansion of macro 'access_ok'
129 | if (access_ok(to, n)) {
| ^~~~~~~~~
include/linux/uaccess.h: In function 'copy_in_user':
>> arch/sparc/include/asm/uaccess_32.h:28:19: error: 'current' undeclared (first use in this function)
28 | #define get_fs() (current->thread.current_ds)
| ^~~~~~~
arch/sparc/include/asm/uaccess_32.h:38:49: note: in definition of macro '__user_ok'
38 | #define __user_ok(addr, size) ({ (void)(size); (addr) < STACK_TOP; })
| ^~~~
arch/sparc/include/asm/uaccess_32.h:40:53: note: in expansion of macro 'get_fs'
40 | #define __access_ok(addr, size) (__user_ok((addr) & get_fs().seg, (size)))
| ^~~~~~
arch/sparc/include/asm/uaccess_32.h:41:31: note: in expansion of macro '__access_ok'
41 | #define access_ok(addr, size) __access_ok((unsigned long)(addr), size)
| ^~~~~~~~~~~
include/linux/uaccess.h:160:6: note: in expansion of macro 'access_ok'
160 | if (access_ok(to, n) && access_ok(from, n))
| ^~~~~~~~~
In file included from include/linux/sched/task.h:11,
from include/linux/sched/signal.h:9,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
>> include/linux/uaccess.h:161:7: error: implicit declaration of function 'raw_copy_in_user'; did you mean 'raw_copy_to_user'? [-Werror=implicit-function-declaration]
161 | n = raw_copy_in_user(to, from, n);
| ^~~~~~~~~~~~~~~~
| raw_copy_to_user
include/linux/uaccess.h: In function 'pagefault_disabled_inc':
>> include/linux/uaccess.h:168:2: error: 'current' undeclared (first use in this function)
168 | current->pagefault_disabled++;
| ^~~~~~~
include/linux/uaccess.h: In function 'pagefault_disabled_dec':
include/linux/uaccess.h:173:2: error: 'current' undeclared (first use in this function)
173 | current->pagefault_disabled--;
| ^~~~~~~
include/linux/uaccess.h: In function 'pagefault_disabled':
include/linux/uaccess.h:208:9: error: 'current' undeclared (first use in this function)
208 | return current->pagefault_disabled != 0;
| ^~~~~~~
In file included from include/linux/kernel.h:15,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:15,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/ratelimit.h: In function 'ratelimit_state_exit':
>> include/linux/ratelimit.h:63:4: error: 'current' undeclared (first use in this function)
63 | current->comm, rs->missed);
| ^~~~~~~
include/linux/printk.h:348:37: note: in definition of macro 'pr_warn'
348 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~
In file included from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/sched/signal.h: In function 'kernel_dequeue_signal':
>> include/linux/sched/signal.h:280:29: error: 'current' undeclared (first use in this function)
280 | struct task_struct *task = current;
| ^~~~~~~
include/linux/sched/signal.h: In function 'kernel_signal_stop':
include/linux/sched/signal.h:293:17: error: 'current' undeclared (first use in this function)
293 | spin_lock_irq(¤t->sighand->siglock);
| ^~~~~~~
include/linux/sched/signal.h: In function 'restart_syscall':
include/linux/sched/signal.h:352:22: error: 'current' undeclared (first use in this function)
352 | set_tsk_thread_flag(current, TIF_SIGPENDING);
| ^~~~~~~
In file included from include/linux/kernel.h:11,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:15,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/sched/signal.h: In function 'fault_signal_pending':
include/linux/sched/signal.h:391:26: error: 'current' undeclared (first use in this function)
391 | (fatal_signal_pending(current) ||
| ^~~~~~~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
In file included from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/sched/signal.h: In function 'restore_saved_sigmask':
include/linux/sched/signal.h:497:26: error: 'current' undeclared (first use in this function)
497 | __set_current_blocked(¤t->saved_sigmask);
| ^~~~~~~
include/linux/sched/signal.h: In function 'sigmask_to_save':
include/linux/sched/signal.h:512:19: error: 'current' undeclared (first use in this function)
512 | sigset_t *res = ¤t->blocked;
| ^~~~~~~
include/linux/sched/signal.h: In function 'on_sig_stack':
include/linux/sched/signal.h:541:6: error: 'current' undeclared (first use in this function)
541 | if (current->sas_ss_flags & SS_AUTODISARM)
| ^~~~~~~
include/linux/sched/signal.h: In function 'sas_ss_flags':
include/linux/sched/signal.h:555:7: error: 'current' undeclared (first use in this function)
555 | if (!current->sas_ss_size)
| ^~~~~~~
include/linux/sched/signal.h: In function 'sigsp':
include/linux/sched/signal.h:574:10: error: 'current' undeclared (first use in this function)
574 | return current->sas_ss_sp + current->sas_ss_size;
| ^~~~~~~
include/linux/sched/signal.h: In function 'rlimit':
include/linux/sched/signal.h:710:21: error: 'current' undeclared (first use in this function)
710 | return task_rlimit(current, limit);
| ^~~~~~~
include/linux/sched/signal.h: In function 'rlimit_max':
include/linux/sched/signal.h:715:25: error: 'current' undeclared (first use in this function)
715 | return task_rlimit_max(current, limit);
| ^~~~~~~
In file included from include/linux/rbtree.h:22,
from include/linux/vmalloc.h:10,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/rcuwait.h: In function 'prepare_to_rcuwait':
>> include/linux/rcuwait.h:47:30: error: 'current' undeclared (first use in this function)
47 | rcu_assign_pointer(w->task, current);
| ^~~~~~~
include/linux/rcupdate.h:409:36: note: in definition of macro 'rcu_assign_pointer'
409 | uintptr_t _r_a_p__v = (uintptr_t)(v); \
| ^
In file included from include/linux/sched/signal.h:7,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/rcuwait.h: In function 'finish_rcuwait':
include/linux/sched.h:133:3: error: 'current' undeclared (first use in this function)
133 | current->task_state_change = _THIS_IP_; \
| ^~~~~~~
include/linux/rcuwait.h:53:2: note: in expansion of macro '__set_current_state'
53 | __set_current_state(TASK_RUNNING);
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/fs.h:38,
from include/linux/proc_fs.h:10,
from arch/sparc/include/asm/prom.h:18,
from include/linux/of.h:250,
from arch/sparc/include/asm/openprom.h:15,
from arch/sparc/include/asm/oplib_32.h:12,
from arch/sparc/include/asm/oplib.h:7,
from arch/sparc/include/asm/pgtable_32.h:32,
from arch/sparc/include/asm/pgtable.h:7,
from arch/sparc/include/asm/viking.h:13,
from arch/sparc/include/asm/mbus.h:12,
from arch/sparc/include/asm/elf_32.h:94,
from arch/sparc/include/asm/elf.h:7,
from include/linux/elf.h:6,
from include/linux/module.h:18,
from include/linux/moduleloader.h:6,
from include/linux/vmalloc.h:12,
from include/asm-generic/io.h:911,
from arch/sparc/include/asm/io_32.h:14,
from arch/sparc/include/asm/io.h:7,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:18,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
include/linux/ioprio.h: In function 'get_current_ioprio':
>> include/linux/ioprio.h:79:27: error: 'current' undeclared (first use in this function)
79 | struct io_context *ioc = current->io_context;
| ^~~~~~~
In file included from arch/sparc/include/asm/page_32.h:136,
from arch/sparc/include/asm/page.h:10,
from arch/sparc/include/asm/string_32.h:13,
from arch/sparc/include/asm/string.h:7,
from include/linux/string.h:20,
from include/linux/bitmap.h:9,
from include/linux/cpumask.h:12,
from arch/sparc/include/asm/smp_32.h:15,
from arch/sparc/include/asm/smp.h:7,
from arch/sparc/include/asm/switch_to_32.h:5,
from arch/sparc/include/asm/switch_to.h:7,
from arch/sparc/include/asm/ptrace.h:120,
from arch/sparc/include/asm/thread_info_32.h:19,
from arch/sparc/include/asm/thread_info.h:7,
from include/linux/thread_info.h:38,
from include/asm-generic/preempt.h:5,
from ./arch/sparc/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:16,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
arch/sparc/include/asm/pgtable_32.h: In function 'pmd_page':
include/asm-generic/memory_model.h:54:29: error: 'vmemmap' undeclared (first use in this function); did you mean 'mem_map'?
54 | #define __pfn_to_page(pfn) (vmemmap + (pfn))
| ^~~~~~~
include/asm-generic/memory_model.h:82:21: note: in expansion of macro '__pfn_to_page'
82 | #define pfn_to_page __pfn_to_page
| ^~~~~~~~~~~~~
arch/sparc/include/asm/pgtable_32.h:135:9: note: in expansion of macro 'pfn_to_page'
135 | return pfn_to_page((pmd_val(pmd) & SRMMU_PTD_PMASK) >> (PAGE_SHIFT-4));
| ^~~~~~~~~~~
In file included from arch/sparc/include/asm/page.h:10,
from arch/sparc/include/asm/string_32.h:13,
from arch/sparc/include/asm/string.h:7,
from include/linux/string.h:20,
from include/linux/bitmap.h:9,
from include/linux/cpumask.h:12,
from arch/sparc/include/asm/smp_32.h:15,
from arch/sparc/include/asm/smp.h:7,
from arch/sparc/include/asm/switch_to_32.h:5,
from arch/sparc/include/asm/switch_to.h:7,
from arch/sparc/include/asm/ptrace.h:120,
from arch/sparc/include/asm/thread_info_32.h:19,
from arch/sparc/include/asm/thread_info.h:7,
from include/linux/thread_info.h:38,
from include/asm-generic/preempt.h:5,
from ./arch/sparc/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from arch/sparc/vdso/vdso32/../vclock_gettime.c:16,
from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
arch/sparc/include/asm/pgtable_32.h: In function 'mk_pte':
include/asm-generic/memory_model.h:55:54: error: 'vmemmap' undeclared (first use in this function); did you mean 'mem_map'?
55 | #define __page_to_pfn(page) (unsigned long)((page) - vmemmap)
| ^~~~~~~
arch/sparc/include/asm/page_32.h:99:19: note: in definition of macro '__pte'
99 | #define __pte(x) (x)
| ^
include/asm-generic/memory_model.h:81:21: note: in expansion of macro '__page_to_pfn'
81 | #define page_to_pfn __page_to_pfn
| ^~~~~~~~~~~~~
arch/sparc/include/asm/pgtable_32.h:297:16: note: in expansion of macro 'page_to_pfn'
297 | return __pte((page_to_pfn(page) << (PAGE_SHIFT-4)) | pgprot_val(pgprot));
| ^~~~~~~~~~~
In file included from arch/sparc/vdso/vdso32/vclock_gettime.c:22:
arch/sparc/vdso/vdso32/../vclock_gettime.c: At top level:
arch/sparc/vdso/vdso32/../vclock_gettime.c:254:1: warning: no previous prototype for '__vdso_clock_gettime' [-Wmissing-prototypes]
254 | __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~
arch/sparc/vdso/vdso32/../vclock_gettime.c:282:1: warning: no previous prototype for '__vdso_clock_gettime_stick' [-Wmissing-prototypes]
282 | __vdso_clock_gettime_stick(clockid_t clock, struct __kernel_old_timespec *ts)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/sparc/vdso/vdso32/../vclock_gettime.c:307:1: warning: no previous prototype for '__vdso_gettimeofday' [-Wmissing-prototypes]
307 | __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
| ^~~~~~~~~~~~~~~~~~~
arch/sparc/vdso/vdso32/../vclock_gettime.c:343:1: warning: no previous prototype for '__vdso_gettimeofday_stick' [-Wmissing-prototypes]
343 | __vdso_gettimeofday_stick(struct __kernel_old_timeval *tv, struct timezone *tz)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +1317 include/linux/mmzone.h
f46edbd1b1516d Dan Williams 2019-07-18 1315
7b7bf499f79de3 Will Deacon 2011-05-19 1316 #ifndef CONFIG_HAVE_ARCH_PFN_VALID
d41dee369bff3b Andy Whitcroft 2005-06-23 @1317 static inline int pfn_valid(unsigned long pfn)
d41dee369bff3b Andy Whitcroft 2005-06-23 1318 {
f46edbd1b1516d Dan Williams 2019-07-18 1319 struct mem_section *ms;
f46edbd1b1516d Dan Williams 2019-07-18 1320
d41dee369bff3b Andy Whitcroft 2005-06-23 1321 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
d41dee369bff3b Andy Whitcroft 2005-06-23 1322 return 0;
f46edbd1b1516d Dan Williams 2019-07-18 1323 ms = __nr_to_section(pfn_to_section_nr(pfn));
f46edbd1b1516d Dan Williams 2019-07-18 1324 if (!valid_section(ms))
f46edbd1b1516d Dan Williams 2019-07-18 1325 return 0;
f46edbd1b1516d Dan Williams 2019-07-18 1326 /*
f46edbd1b1516d Dan Williams 2019-07-18 1327 * Traditionally early sections always returned pfn_valid() for
f46edbd1b1516d Dan Williams 2019-07-18 1328 * the entire section-sized span.
f46edbd1b1516d Dan Williams 2019-07-18 1329 */
f46edbd1b1516d Dan Williams 2019-07-18 1330 return early_section(ms) || pfn_section_valid(ms, pfn);
d41dee369bff3b Andy Whitcroft 2005-06-23 1331 }
7b7bf499f79de3 Will Deacon 2011-05-19 1332 #endif
d41dee369bff3b Andy Whitcroft 2005-06-23 1333
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31687 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-17 3:04 ` [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Jarkko Sakkinen
2020-07-17 5:33 ` kernel test robot
2020-07-17 5:33 ` kernel test robot
@ 2020-07-17 8:52 ` Masami Hiramatsu
2020-07-23 22:24 ` Jarkko Sakkinen
2020-07-18 16:23 ` Mike Rapoport
3 siblings, 1 reply; 11+ messages in thread
From: Masami Hiramatsu @ 2020-07-17 8:52 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: linux-kernel, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
On Fri, 17 Jul 2020 06:04:17 +0300
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:
> 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().
Doesn't it depend on CONFIG_MODULE?
Thank you,
>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> 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 <asm/page.h> /* pgprot_t */
> #include <linux/rbtree.h>
> #include <linux/overflow.h>
> +#include <linux/moduleloader.h>
>
> #include <asm/vmalloc.h>
>
> @@ -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
>
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-17 3:04 ` [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Jarkko Sakkinen
` (2 preceding siblings ...)
2020-07-17 8:52 ` Masami Hiramatsu
@ 2020-07-18 16:23 ` Mike Rapoport
2020-07-20 12:01 ` Masami Hiramatsu
2020-07-23 22:28 ` Jarkko Sakkinen
3 siblings, 2 replies; 11+ messages in thread
From: Mike Rapoport @ 2020-07-18 16:23 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: linux-kernel, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
On Fri, Jul 17, 2020 at 06:04:17AM +0300, Jarkko Sakkinen wrote:
> 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 <ak@linux.intel.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> 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 <asm/page.h> /* pgprot_t */
> #include <linux/rbtree.h>
> #include <linux/overflow.h>
> +#include <linux/moduleloader.h>
>
> #include <asm/vmalloc.h>
>
> @@ -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);
> +}
Using module_alloc() as the default implementation of generic
text_alloc() does not sound right to me.
I would suggest rename module_alloc() to text_alloc() on x86, as Peter
proposed and then add text_alloc_kprobes() that can be overridden by the
architectures. x86 could use text_alloc(), arm64 vmalloc() with options
of their choice and the fallback would remain module_alloc(). Something
like (untested) patch below:
From 928b6903e76ebf5790fc415f9eed390e400e5bc3 Mon Sep 17 00:00:00 2001
From: Mike Rapoport <rppt@linux.ibm.com>
Date: Sat, 18 Jul 2020 19:13:02 +0300
Subject: [PATCH] kprobes: introduce text_alloc_kprobes() and
text_free_kprobes()
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
arch/Kconfig | 5 ++++-
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/probes/kprobes.c | 10 ++++++++--
arch/x86/Kconfig | 3 ++-
arch/x86/kernel/kprobes/core.c | 9 ++++-----
include/linux/kprobes.h | 17 +++++++++++++++--
kernel/kprobes.c | 8 ++++----
7 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 8cc35dc556c7..c0589b3b3225 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -61,7 +61,7 @@ config OPROFILE_NMI_TIMER
config KPROBES
bool "Kprobes"
- depends on MODULES
+ depends on MODULES || HAVE_KPROBES_TEXT_ALLOC
depends on HAVE_KPROBES
select KALLSYMS
help
@@ -186,6 +186,9 @@ config HAVE_IOREMAP_PROT
config HAVE_KPROBES
bool
+config HAVE_KPROBES_TEXT_ALLOC
+ bool
+
config HAVE_KRETPROBES
bool
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 66dc41fd49f2..abc0538b13ef 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -177,6 +177,7 @@ config ARM64
select HAVE_STACKPROTECTOR
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_KPROBES
+ select HAVE_KPROBES_TEXT_ALLOC
select HAVE_KRETPROBES
select HAVE_GENERIC_VDSO
select IOMMU_DMA if IOMMU_SUPPORT
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 5290f17a4d80..fac8c6020040 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -118,13 +118,19 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
return 0;
}
-void *alloc_insn_page(void)
+void *text_alloc_kprobes(unsigned long size)
{
- return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
+ return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
GFP_KERNEL, PAGE_KERNEL_ROX, VM_FLUSH_RESET_PERMS,
NUMA_NO_NODE, __builtin_return_address(0));
}
+void text_free_kprobes(void *mem)
+{
+ lockdep_assert_irqs_enabled();
+ vfree(mem);
+}
+
/* arm kprobe: install breakpoint in text */
void __kprobes arch_arm_kprobe(struct kprobe *p)
{
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 883da0abf779..d08b92f91531 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -190,6 +190,7 @@ config X86
select HAVE_KERNEL_XZ
select HAVE_KPROBES
select HAVE_KPROBES_ON_FTRACE
+ select HAVE_KPROBES_TEXT_ALLOC
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_KRETPROBES
select HAVE_KVM
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index ada39ddbc922..a3e8f01c62d4 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -418,12 +418,11 @@ static int prepare_boost(kprobe_opcode_t *buf, struct kprobe *p,
return len;
}
-/* Make page to RO mode when allocate it */
-void *alloc_insn_page(void)
+void *text_alloc_kprobes(unsigned long size)
{
void *page;
- page = module_alloc(PAGE_SIZE);
+ page = text_alloc(size);
if (!page)
return NULL;
@@ -444,9 +443,9 @@ void *alloc_insn_page(void)
}
/* Recover page to RW mode before releasing it */
-void free_insn_page(void *page)
+void text_free_kprobes(void *page)
{
- module_memfree(page);
+ text_free(page);
}
static int arch_copy_kprobe(struct kprobe *p)
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 6adf90f248d7..dbc9c71d4ec4 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -27,6 +27,7 @@
#include <linux/rcupdate.h>
#include <linux/mutex.h>
#include <linux/ftrace.h>
+#include <linux/moduleloader.h>
#include <asm/kprobes.h>
#ifdef CONFIG_KPROBES
@@ -374,8 +375,20 @@ int enable_kprobe(struct kprobe *kp);
void dump_kprobe(struct kprobe *kp);
-void *alloc_insn_page(void);
-void free_insn_page(void *page);
+#ifdef CONFIG_HAVE_KPROBES_TEXT_ALLOC
+void *text_alloc_kprobes(unsigned long size);
+void text_free_kprobes(void *page);
+#else
+static inline void *text_alloc_kprobes(unsigned long size)
+{
+ return module_alloc(size);
+}
+
+static inline void text_free_kprobes(void *page)
+{
+ module_memfree(page);
+}
+#endif
#else /* !CONFIG_KPROBES: */
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 2e97febeef77..c4f107682250 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -109,14 +109,14 @@ enum kprobe_slot_state {
SLOT_USED = 2,
};
-void __weak *alloc_insn_page(void)
+static void *alloc_insn_page(void)
{
- return module_alloc(PAGE_SIZE);
+ return text_alloc_kprobes(PAGE_SIZE);
}
-void __weak free_insn_page(void *page)
+static void free_insn_page(void *page)
{
- module_memfree(page);
+ text_free_kprobes(page);
}
struct kprobe_insn_cache kprobe_insn_slots = {
--
2.26.2
> +#endif
> +
> #endif /* _LINUX_VMALLOC_H */
> --
> 2.25.1
>
--
Sincerely yours,
Mike.
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-18 16:23 ` Mike Rapoport
@ 2020-07-20 12:01 ` Masami Hiramatsu
2020-07-23 22:28 ` Jarkko Sakkinen
1 sibling, 0 replies; 11+ messages in thread
From: Masami Hiramatsu @ 2020-07-20 12:01 UTC (permalink / raw)
To: Mike Rapoport
Cc: Jarkko Sakkinen, linux-kernel, Andi Kleen, Masami Hiramatsu,
Peter Zijlstra, Andrew Morton, open list:MEMORY MANAGEMENT
On Sat, 18 Jul 2020 19:23:59 +0300
Mike Rapoport <rppt@kernel.org> wrote:
> On Fri, Jul 17, 2020 at 06:04:17AM +0300, Jarkko Sakkinen wrote:
> > 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 <ak@linux.intel.com>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> > 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 <asm/page.h> /* pgprot_t */
> > #include <linux/rbtree.h>
> > #include <linux/overflow.h>
> > +#include <linux/moduleloader.h>
> >
> > #include <asm/vmalloc.h>
> >
> > @@ -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);
> > +}
>
> Using module_alloc() as the default implementation of generic
> text_alloc() does not sound right to me.
>
> I would suggest rename module_alloc() to text_alloc() on x86, as Peter
> proposed and then add text_alloc_kprobes() that can be overridden by the
> architectures. x86 could use text_alloc(), arm64 vmalloc() with options
> of their choice and the fallback would remain module_alloc(). Something
> like (untested) patch below:
Hmm, of course we need some more work on this patch (e.g. MODULE_STATE_*
for callbacks), but basically, this direction seems good to me for the
first step.
If other dynamic trampoline code (ftrace and bpf) are interested in replacing
the module_alloc() with text_alloc_*(), we should revisit how we can unify
it (or at least share the common parts.)
BTW, this changes CONFIG_MODULES dependency according to the architecture
implementation. It also should be noted somewhere.
Thank you,
> From 928b6903e76ebf5790fc415f9eed390e400e5bc3 Mon Sep 17 00:00:00 2001
> From: Mike Rapoport <rppt@linux.ibm.com>
> Date: Sat, 18 Jul 2020 19:13:02 +0300
> Subject: [PATCH] kprobes: introduce text_alloc_kprobes() and
> text_free_kprobes()
>
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
> arch/Kconfig | 5 ++++-
> arch/arm64/Kconfig | 1 +
> arch/arm64/kernel/probes/kprobes.c | 10 ++++++++--
> arch/x86/Kconfig | 3 ++-
> arch/x86/kernel/kprobes/core.c | 9 ++++-----
> include/linux/kprobes.h | 17 +++++++++++++++--
> kernel/kprobes.c | 8 ++++----
> 7 files changed, 38 insertions(+), 15 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 8cc35dc556c7..c0589b3b3225 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -61,7 +61,7 @@ config OPROFILE_NMI_TIMER
>
> config KPROBES
> bool "Kprobes"
> - depends on MODULES
> + depends on MODULES || HAVE_KPROBES_TEXT_ALLOC
> depends on HAVE_KPROBES
> select KALLSYMS
> help
> @@ -186,6 +186,9 @@ config HAVE_IOREMAP_PROT
> config HAVE_KPROBES
> bool
>
> +config HAVE_KPROBES_TEXT_ALLOC
> + bool
> +
> config HAVE_KRETPROBES
> bool
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 66dc41fd49f2..abc0538b13ef 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -177,6 +177,7 @@ config ARM64
> select HAVE_STACKPROTECTOR
> select HAVE_SYSCALL_TRACEPOINTS
> select HAVE_KPROBES
> + select HAVE_KPROBES_TEXT_ALLOC
> select HAVE_KRETPROBES
> select HAVE_GENERIC_VDSO
> select IOMMU_DMA if IOMMU_SUPPORT
> diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
> index 5290f17a4d80..fac8c6020040 100644
> --- a/arch/arm64/kernel/probes/kprobes.c
> +++ b/arch/arm64/kernel/probes/kprobes.c
> @@ -118,13 +118,19 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
> return 0;
> }
>
> -void *alloc_insn_page(void)
> +void *text_alloc_kprobes(unsigned long size)
> {
> - return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
> + return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
> GFP_KERNEL, PAGE_KERNEL_ROX, VM_FLUSH_RESET_PERMS,
> NUMA_NO_NODE, __builtin_return_address(0));
> }
>
> +void text_free_kprobes(void *mem)
> +{
> + lockdep_assert_irqs_enabled();
> + vfree(mem);
> +}
> +
> /* arm kprobe: install breakpoint in text */
> void __kprobes arch_arm_kprobe(struct kprobe *p)
> {
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 883da0abf779..d08b92f91531 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -190,6 +190,7 @@ config X86
> select HAVE_KERNEL_XZ
> select HAVE_KPROBES
> select HAVE_KPROBES_ON_FTRACE
> + select HAVE_KPROBES_TEXT_ALLOC
> select HAVE_FUNCTION_ERROR_INJECTION
> select HAVE_KRETPROBES
> select HAVE_KVM
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index ada39ddbc922..a3e8f01c62d4 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -418,12 +418,11 @@ static int prepare_boost(kprobe_opcode_t *buf, struct kprobe *p,
> return len;
> }
>
> -/* Make page to RO mode when allocate it */
> -void *alloc_insn_page(void)
> +void *text_alloc_kprobes(unsigned long size)
> {
> void *page;
>
> - page = module_alloc(PAGE_SIZE);
> + page = text_alloc(size);
> if (!page)
> return NULL;
>
> @@ -444,9 +443,9 @@ void *alloc_insn_page(void)
> }
>
> /* Recover page to RW mode before releasing it */
> -void free_insn_page(void *page)
> +void text_free_kprobes(void *page)
> {
> - module_memfree(page);
> + text_free(page);
> }
>
> static int arch_copy_kprobe(struct kprobe *p)
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index 6adf90f248d7..dbc9c71d4ec4 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -27,6 +27,7 @@
> #include <linux/rcupdate.h>
> #include <linux/mutex.h>
> #include <linux/ftrace.h>
> +#include <linux/moduleloader.h>
> #include <asm/kprobes.h>
>
> #ifdef CONFIG_KPROBES
> @@ -374,8 +375,20 @@ int enable_kprobe(struct kprobe *kp);
>
> void dump_kprobe(struct kprobe *kp);
>
> -void *alloc_insn_page(void);
> -void free_insn_page(void *page);
> +#ifdef CONFIG_HAVE_KPROBES_TEXT_ALLOC
> +void *text_alloc_kprobes(unsigned long size);
> +void text_free_kprobes(void *page);
> +#else
> +static inline void *text_alloc_kprobes(unsigned long size)
> +{
> + return module_alloc(size);
> +}
> +
> +static inline void text_free_kprobes(void *page)
> +{
> + module_memfree(page);
> +}
> +#endif
>
> #else /* !CONFIG_KPROBES: */
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 2e97febeef77..c4f107682250 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -109,14 +109,14 @@ enum kprobe_slot_state {
> SLOT_USED = 2,
> };
>
> -void __weak *alloc_insn_page(void)
> +static void *alloc_insn_page(void)
> {
> - return module_alloc(PAGE_SIZE);
> + return text_alloc_kprobes(PAGE_SIZE);
> }
>
> -void __weak free_insn_page(void *page)
> +static void free_insn_page(void *page)
> {
> - module_memfree(page);
> + text_free_kprobes(page);
> }
>
> struct kprobe_insn_cache kprobe_insn_slots = {
> --
> 2.26.2
>
>
> > +#endif
> > +
> > #endif /* _LINUX_VMALLOC_H */
> > --
> > 2.25.1
> >
>
> --
> Sincerely yours,
> Mike.
--
Masami Hiramatsu <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-17 8:52 ` Masami Hiramatsu
@ 2020-07-23 22:24 ` Jarkko Sakkinen
0 siblings, 0 replies; 11+ messages in thread
From: Jarkko Sakkinen @ 2020-07-23 22:24 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: linux-kernel, Andi Kleen, Peter Zijlstra, Andrew Morton,
open list:MEMORY MANAGEMENT
On Fri, Jul 17, 2020 at 05:52:45PM +0900, Masami Hiramatsu wrote:
> On Fri, 17 Jul 2020 06:04:17 +0300
> Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote:
>
> > 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().
>
> Doesn't it depend on CONFIG_MODULE?
The idea would be that arch specifically promotes that it has text
allocator that is not dependent on module subsystem.
E.g. like the patch set does for x86.
/Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-18 16:23 ` Mike Rapoport
2020-07-20 12:01 ` Masami Hiramatsu
@ 2020-07-23 22:28 ` Jarkko Sakkinen
2020-07-24 10:13 ` Mike Rapoport
1 sibling, 1 reply; 11+ messages in thread
From: Jarkko Sakkinen @ 2020-07-23 22:28 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-kernel, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
On Sat, Jul 18, 2020 at 07:23:59PM +0300, Mike Rapoport wrote:
> On Fri, Jul 17, 2020 at 06:04:17AM +0300, Jarkko Sakkinen wrote:
> > 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 <ak@linux.intel.com>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> > 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 <asm/page.h> /* pgprot_t */
> > #include <linux/rbtree.h>
> > #include <linux/overflow.h>
> > +#include <linux/moduleloader.h>
> >
> > #include <asm/vmalloc.h>
> >
> > @@ -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);
> > +}
>
> Using module_alloc() as the default implementation of generic
> text_alloc() does not sound right to me.
>
> I would suggest rename module_alloc() to text_alloc() on x86, as Peter
> proposed and then add text_alloc_kprobes() that can be overridden by the
> architectures. x86 could use text_alloc(), arm64 vmalloc() with options
> of their choice and the fallback would remain module_alloc(). Something
> like (untested) patch below:
I'm not exactly sure which of the below is relevant as the patch set
includes the exact same changes with maybe different phrasing:
https://lore.kernel.org/lkml/20200717030422.679972-1-jarkko.sakkinen@linux.intel.com/
If there is something that these patches are missing, please do remark
but these seven patches have been at least tested and split in
reasonable manner.
/Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-23 22:28 ` Jarkko Sakkinen
@ 2020-07-24 10:13 ` Mike Rapoport
2020-07-24 23:31 ` Jarkko Sakkinen
0 siblings, 1 reply; 11+ messages in thread
From: Mike Rapoport @ 2020-07-24 10:13 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: linux-kernel, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
On Fri, Jul 24, 2020 at 01:28:35AM +0300, Jarkko Sakkinen wrote:
> On Sat, Jul 18, 2020 at 07:23:59PM +0300, Mike Rapoport wrote:
> > On Fri, Jul 17, 2020 at 06:04:17AM +0300, Jarkko Sakkinen wrote:
> > > 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 <ak@linux.intel.com>
> > > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > ---
> > > 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 <asm/page.h> /* pgprot_t */
> > > #include <linux/rbtree.h>
> > > #include <linux/overflow.h>
> > > +#include <linux/moduleloader.h>
> > >
> > > #include <asm/vmalloc.h>
> > >
> > > @@ -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);
> > > +}
> >
> > Using module_alloc() as the default implementation of generic
> > text_alloc() does not sound right to me.
> >
> > I would suggest rename module_alloc() to text_alloc() on x86, as Peter
> > proposed and then add text_alloc_kprobes() that can be overridden by the
> > architectures. x86 could use text_alloc(), arm64 vmalloc() with options
> > of their choice and the fallback would remain module_alloc(). Something
> > like (untested) patch below:
>
> I'm not exactly sure which of the below is relevant as the patch set
> includes the exact same changes with maybe different phrasing:
The difference in parsing is what differentiates semantically clean code
from duct tape.
As several people pointed out, a single text_alloc(), and apprently a
single ARCH_HAS_TEXT_ALLOC, would not fit all architectures and some
ground work required to implement a generic text allocation.
Your patch works aroung this for x86 with broken semantics of
text_alloc() when ARCH_HAS_TEXT_ALLOC is not defined.
My suggestion does not make text_alloc() a special case of
module_alloc() but rather makes text_alloc_kprobes() to fallback to
module_alloc() when architecture does not provide its implementation.
> https://lore.kernel.org/lkml/20200717030422.679972-1-jarkko.sakkinen@linux.intel.com/
>
> If there is something that these patches are missing, please do remark
> but these seven patches have been at least tested and split in
> reasonable manner.
My patch is not tested because I only wanted to help with
transiontion from module_alloc() in kprobes to a new clean interface, I
don't really care if kprobes will depend on MODULES...
> /Jarkko
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-24 10:13 ` Mike Rapoport
@ 2020-07-24 23:31 ` Jarkko Sakkinen
2020-07-24 23:40 ` Jarkko Sakkinen
0 siblings, 1 reply; 11+ messages in thread
From: Jarkko Sakkinen @ 2020-07-24 23:31 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-kernel, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
On Fri, Jul 24, 2020 at 01:13:02PM +0300, Mike Rapoport wrote:
> On Fri, Jul 24, 2020 at 01:28:35AM +0300, Jarkko Sakkinen wrote:
> > On Sat, Jul 18, 2020 at 07:23:59PM +0300, Mike Rapoport wrote:
> > > On Fri, Jul 17, 2020 at 06:04:17AM +0300, Jarkko Sakkinen wrote:
> > > > 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 <ak@linux.intel.com>
> > > > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > > > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > ---
> > > > 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 <asm/page.h> /* pgprot_t */
> > > > #include <linux/rbtree.h>
> > > > #include <linux/overflow.h>
> > > > +#include <linux/moduleloader.h>
> > > >
> > > > #include <asm/vmalloc.h>
> > > >
> > > > @@ -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);
> > > > +}
> > >
> > > Using module_alloc() as the default implementation of generic
> > > text_alloc() does not sound right to me.
> > >
> > > I would suggest rename module_alloc() to text_alloc() on x86, as Peter
> > > proposed and then add text_alloc_kprobes() that can be overridden by the
> > > architectures. x86 could use text_alloc(), arm64 vmalloc() with options
> > > of their choice and the fallback would remain module_alloc(). Something
> > > like (untested) patch below:
> >
> > I'm not exactly sure which of the below is relevant as the patch set
> > includes the exact same changes with maybe different phrasing:
>
> The difference in parsing is what differentiates semantically clean code
> from duct tape.
>
> As several people pointed out, a single text_alloc(), and apprently a
> single ARCH_HAS_TEXT_ALLOC, would not fit all architectures and some
> ground work required to implement a generic text allocation.
>
> Your patch works aroung this for x86 with broken semantics of
> text_alloc() when ARCH_HAS_TEXT_ALLOC is not defined.
>
> My suggestion does not make text_alloc() a special case of
> module_alloc() but rather makes text_alloc_kprobes() to fallback to
> module_alloc() when architecture does not provide its implementation.
OK, I see your point now. I'll response in detail to v5 comments.
Thank you.
/Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free()
2020-07-24 23:31 ` Jarkko Sakkinen
@ 2020-07-24 23:40 ` Jarkko Sakkinen
0 siblings, 0 replies; 11+ messages in thread
From: Jarkko Sakkinen @ 2020-07-24 23:40 UTC (permalink / raw)
To: Mike Rapoport
Cc: linux-kernel, Andi Kleen, Masami Hiramatsu, Peter Zijlstra,
Andrew Morton, open list:MEMORY MANAGEMENT
On Sat, Jul 25, 2020 at 02:31:16AM +0300, Jarkko Sakkinen wrote:
> On Fri, Jul 24, 2020 at 01:13:02PM +0300, Mike Rapoport wrote:
> > On Fri, Jul 24, 2020 at 01:28:35AM +0300, Jarkko Sakkinen wrote:
> > > On Sat, Jul 18, 2020 at 07:23:59PM +0300, Mike Rapoport wrote:
> > > > On Fri, Jul 17, 2020 at 06:04:17AM +0300, Jarkko Sakkinen wrote:
> > > > > 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 <ak@linux.intel.com>
> > > > > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > > > > Suggested-by: Peter Zijlstra <peterz@infradead.org>
> > > > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > ---
> > > > > 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 <asm/page.h> /* pgprot_t */
> > > > > #include <linux/rbtree.h>
> > > > > #include <linux/overflow.h>
> > > > > +#include <linux/moduleloader.h>
> > > > >
> > > > > #include <asm/vmalloc.h>
> > > > >
> > > > > @@ -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);
> > > > > +}
> > > >
> > > > Using module_alloc() as the default implementation of generic
> > > > text_alloc() does not sound right to me.
> > > >
> > > > I would suggest rename module_alloc() to text_alloc() on x86, as Peter
> > > > proposed and then add text_alloc_kprobes() that can be overridden by the
> > > > architectures. x86 could use text_alloc(), arm64 vmalloc() with options
> > > > of their choice and the fallback would remain module_alloc(). Something
> > > > like (untested) patch below:
> > >
> > > I'm not exactly sure which of the below is relevant as the patch set
> > > includes the exact same changes with maybe different phrasing:
> >
> > The difference in parsing is what differentiates semantically clean code
> > from duct tape.
> >
> > As several people pointed out, a single text_alloc(), and apprently a
> > single ARCH_HAS_TEXT_ALLOC, would not fit all architectures and some
> > ground work required to implement a generic text allocation.
> >
> > Your patch works aroung this for x86 with broken semantics of
> > text_alloc() when ARCH_HAS_TEXT_ALLOC is not defined.
> >
> > My suggestion does not make text_alloc() a special case of
> > module_alloc() but rather makes text_alloc_kprobes() to fallback to
> > module_alloc() when architecture does not provide its implementation.
>
> OK, I see your point now. I'll response in detail to v5 comments.
>
> Thank you.
I also extended the explicit CC list heavily for follow up version.
Apologies if this have been somewhat confusing so far (e.g. getting
only a subportion of patches).
/Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-07-24 23:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200717030422.679972-1-jarkko.sakkinen@linux.intel.com>
2020-07-17 3:04 ` [PATCH v4 3/7] vmalloc: Add text_alloc() and text_free() Jarkko Sakkinen
2020-07-17 5:33 ` kernel test robot
2020-07-17 5:33 ` kernel test robot
2020-07-17 8:52 ` Masami Hiramatsu
2020-07-23 22:24 ` Jarkko Sakkinen
2020-07-18 16:23 ` Mike Rapoport
2020-07-20 12:01 ` Masami Hiramatsu
2020-07-23 22:28 ` Jarkko Sakkinen
2020-07-24 10:13 ` Mike Rapoport
2020-07-24 23:31 ` Jarkko Sakkinen
2020-07-24 23:40 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).