Messages in this thread | | | Date | Fri, 10 Aug 2007 15:00:12 -0400 | From | Mathieu Desnoyers <> | Subject | Re: new text patching for review |
| |
* Andi Kleen (ak@suse.de) wrote: > > Hallo, > > I had some second thoughts about the text patching of DEBUG_RODATA kernels > using change_page_attr(). Change_page_attr is intrusive and slow and using > a separate mapping is a little more gentle. I came up with this patch. > For your review and testing pleasure. > > The main quirk is that it doesn't fully follow the cross-modifying code > recommendations; but i'm not sure that's really needed. > > Also I admit nop_out is quite inefficient, but that's a very slow path > and it was easier to do it this way than handle all the corner cases > explicitely. > > Comments, > > -Andi > > x86: Fix alternatives and kprobes to remap write-protected kernel text > > Signed-off-by: Andi Kleen <ak@suse.de> > > +/* > + * RED-PEN Intel recommends stopping the other CPUs for such > + * "cross-modifying code". > + */ > +void __kprobes text_poke(void *oaddr, u8 opcode) > +{ > + u8 *addr = oaddr; > + if (!pte_write(*lookup_address((unsigned long)addr))) { > + struct page *p = virt_to_page(addr); > + addr = vmap(&p, 1, VM_MAP, PAGE_KERNEL); > + if (!addr) > + return; > + addr += ((unsigned long)oaddr) % PAGE_SIZE; > + } > + *addr = opcode; > + /* Not strictly needed, but can speed CPU recovery up */ > + if (cpu_has_clflush) > + asm("clflush (%0) " :: "r" (addr) : "memory"); > + if (addr != oaddr) > + vunmap(addr); > +}
Hi Andi,
I was trying to make this work, but I find out that it seems incredibly slow when I call it multiple times. Trying to understand why, I come with a few questions:
- Is this supposed to work with large pages ? - Is this supposed to work module text ?
Thanks,
Mathieu
-- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |