+ kprobes-unify-insn-caches.patch added to -mm tree
Subject: + kprobes-unify-insn-caches.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Wed, 21 Aug 2013 13:28:17 -0700
The patch titled
Subject: kprobes: unify insn caches
has been added to the -mm tree. Its filename is
kprobes-unify-insn-caches.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/kprobes-unify-insn-caches.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/kprobes-unify-insn-caches.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Heiko Carstens <[email protected]>
Subject: kprobes: unify insn caches
The current kpropes insn caches allocate memory areas for insn slots with module_alloc(). The assumption is that the kernel image and module area are both within the same +/- 2GB memory area.
This however is not true for s390 where the kernel image resides within the first 2GB (DMA memory area), but the module area is far away in the vmalloc area, usually somewhere close below the 4TB area.
For new pc relative instructions s390 needs insn slots that are within +/- 2GB of each area. That way we can patch displacements of pc-relative instructions within the insn slots just like x86 and powerpc.
The module area works already with the normal insn slot allocator, however there is currently no way to get insn slots that are within the first 2GB on s390 (aka DMA area).
Therefore this patch set introduces a third insn slot cache besides the normal insn and optinsn slot caches: the dmainsn slot cache. Slots can be allocated and freed with get_dmainsn_slot() and free_dmainsn_slot().
Patch 1 unifies the current insn and optinsn caches implementation so we don't end up with a lot of code duplication when adding a third cache.
Patch 2 simply adds the new dmainsn slot cache.
Patch 3 is the s390 usage of the new cache.
This patch (of 3):
The two insn caches (insn, and optinsn) each have an own mutex and alloc/free functions (get_[opt]insn_slot() / free_[opt]insn_slot()).
Since I need yet another insn cache which satifies dma allocations, unify and simplify the current implementation:
- Move the per insn cache mutex into struct kprobe_insn_cache.
- Move the alloc/free functions to kprobe.h so they are simply wrappers for the generic __get_insn_slot/__free_insn_slot. The implementation is done with a DEFINE_INSN_CACHE_OPS() macro which provides the alloc/free functions for each cache if needed.
---
include/linux/kprobes.h | 26 +++++++++++--- kernel/kprobes.c | 70 +++++++++++--------------------------- 2 files changed, 44 insertions(+), 52 deletions(-)
include/linux/kprobes.h renamed from include/linux/kprobes.h~kprobes-unify-insn-caches +22 -4
@@ -264,10 +264,28 @@ extern void arch_arm_kprobe(struct kprobextern void arch_disarm_kprobe (struct kprobe *p);extern int arch_init_kprobes (void );extern void show_registers (struct pt_regs *regs); -extern kprobe_opcode_t *get_insn_slot (void ); -extern void free_insn_slot (kprobe_opcode_t *slot,int dirty);extern void kprobes_inc_nmissed_count (struct kprobe *p); +struct kprobe_insn_cache ; +extern kprobe_opcode_t *__get_insn_slot (struct kprobe_insn_cache *c); +extern void __free_insn_slot (struct kprobe_insn_cache *c, +kprobe_opcode_t *slot,int dirty); + +#define DEFINE_INSN_CACHE_OPS (__name) \ +extern struct kprobe_insn_cache kprobe_##__name##_slots; \ + \ +static inline kprobe_opcode_t *get_##__name##_slot(void) \ +{ \ + return __get_insn_slot(&kprobe_##__name##_slots); \ +} \ + \ +static inline void free_##__name##_slot(kprobe_opcode_t *slot, int dirty)\ +{ \ + __free_insn_slot(&kprobe_##__name##_slots, slot, dirty); \ +} \ + +DEFINE_INSN_CACHE_OPS (insn); +#ifdef CONFIG_OPTPROBES /* * Internal structure for direct jump optimized probe
@@ -287,13 +305,13 @@ extern void arch_optimize_kprobes(structextern void arch_unoptimize_kprobes (struct list_head *oplist,struct list_head *done_list);extern void arch_unoptimize_kprobe (struct optimized_kprobe *op); -extern kprobe_opcode_t *get_optinsn_slot (void ); -extern void free_optinsn_slot (kprobe_opcode_t *slot,int dirty);extern int arch_within_optimized_kprobe (struct optimized_kprobe *op,unsigned long addr);extern void opt_pre_handler (struct kprobe *p,struct pt_regs *regs); +DEFINE_INSN_CACHE_OPS (optinsn); +#ifdef CONFIG_SYSCTL extern int sysctl_kprobes_optimization; extern int proc_kprobes_optimization_handler(struct ctl_table *table,
kernel/kprobes.c renamed from kernel/kprobes.c~kprobes-unify-insn-caches +22 -41
132 lines not on this page · raw message