kprobes.c (3a07362fab1653d3aca31a9155c8cc776138fd02) | kprobes.c (12af2b83d0b17ec8b379b721dd4a8fbcd5d791f3) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Kernel Probes (KProbes) 4 * 5 * Copyright (C) IBM Corporation, 2002, 2004 6 * 7 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel 8 * Probes initial implementation (includes suggestions from --- 12 unchanged lines hidden (view full) --- 21#define pr_fmt(fmt) "kprobes: " fmt 22 23#include <linux/kprobes.h> 24#include <linux/hash.h> 25#include <linux/init.h> 26#include <linux/slab.h> 27#include <linux/stddef.h> 28#include <linux/export.h> | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Kernel Probes (KProbes) 4 * 5 * Copyright (C) IBM Corporation, 2002, 2004 6 * 7 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel 8 * Probes initial implementation (includes suggestions from --- 12 unchanged lines hidden (view full) --- 21#define pr_fmt(fmt) "kprobes: " fmt 22 23#include <linux/kprobes.h> 24#include <linux/hash.h> 25#include <linux/init.h> 26#include <linux/slab.h> 27#include <linux/stddef.h> 28#include <linux/export.h> |
29#include <linux/moduleloader.h> | |
30#include <linux/kallsyms.h> 31#include <linux/freezer.h> 32#include <linux/seq_file.h> 33#include <linux/debugfs.h> 34#include <linux/sysctl.h> 35#include <linux/kdebug.h> 36#include <linux/memory.h> 37#include <linux/ftrace.h> 38#include <linux/cpu.h> 39#include <linux/jump_label.h> 40#include <linux/static_call.h> 41#include <linux/perf_event.h> | 29#include <linux/kallsyms.h> 30#include <linux/freezer.h> 31#include <linux/seq_file.h> 32#include <linux/debugfs.h> 33#include <linux/sysctl.h> 34#include <linux/kdebug.h> 35#include <linux/memory.h> 36#include <linux/ftrace.h> 37#include <linux/cpu.h> 38#include <linux/jump_label.h> 39#include <linux/static_call.h> 40#include <linux/perf_event.h> |
41#include <linux/execmem.h> |
|
42 43#include <asm/sections.h> 44#include <asm/cacheflush.h> 45#include <asm/errno.h> 46#include <linux/uaccess.h> 47 48#define KPROBE_HASH_BITS 6 49#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) --- 58 unchanged lines hidden (view full) --- 108 SLOT_CLEAN = 0, 109 SLOT_DIRTY = 1, 110 SLOT_USED = 2, 111}; 112 113void __weak *alloc_insn_page(void) 114{ 115 /* | 42 43#include <asm/sections.h> 44#include <asm/cacheflush.h> 45#include <asm/errno.h> 46#include <linux/uaccess.h> 47 48#define KPROBE_HASH_BITS 6 49#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) --- 58 unchanged lines hidden (view full) --- 108 SLOT_CLEAN = 0, 109 SLOT_DIRTY = 1, 110 SLOT_USED = 2, 111}; 112 113void __weak *alloc_insn_page(void) 114{ 115 /* |
116 * Use module_alloc() so this page is within +/- 2GB of where the | 116 * Use execmem_alloc() so this page is within +/- 2GB of where the |
117 * kernel image and loaded module images reside. This is required 118 * for most of the architectures. 119 * (e.g. x86-64 needs this to handle the %rip-relative fixups.) 120 */ | 117 * kernel image and loaded module images reside. This is required 118 * for most of the architectures. 119 * (e.g. x86-64 needs this to handle the %rip-relative fixups.) 120 */ |
121 return module_alloc(PAGE_SIZE); | 121 return execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE); |
122} 123 124static void free_insn_page(void *page) 125{ | 122} 123 124static void free_insn_page(void *page) 125{ |
126 module_memfree(page); | 126 execmem_free(page); |
127} 128 129struct kprobe_insn_cache kprobe_insn_slots = { 130 .mutex = __MUTEX_INITIALIZER(kprobe_insn_slots.mutex), 131 .alloc = alloc_insn_page, 132 .free = free_insn_page, 133 .sym = KPROBE_INSN_PAGE_SYM, 134 .pages = LIST_HEAD_INIT(kprobe_insn_slots.pages), --- 2900 unchanged lines hidden --- | 127} 128 129struct kprobe_insn_cache kprobe_insn_slots = { 130 .mutex = __MUTEX_INITIALIZER(kprobe_insn_slots.mutex), 131 .alloc = alloc_insn_page, 132 .free = free_insn_page, 133 .sym = KPROBE_INSN_PAGE_SYM, 134 .pages = LIST_HEAD_INIT(kprobe_insn_slots.pages), --- 2900 unchanged lines hidden --- |