|
From: Mathieu D. <mat...@po...> - 2009-07-01 22:58:15
|
* Masami Hiramatsu (mhi...@re...) wrote: > Since the fixmap pages are assigned higher address to lower, text_poke() > has to use it with inverted order (FIX_TEXT_POKE1 to FIX_TEXT_POKE0). > Hrm, is that only true for x86_32 or also for x86_64 ? Reading arch/x86/include/asm/fixmap.h : * for x86_32: We allocate these special addresses * from the end of virtual memory (0xfffff000) backwards. * Also this lets us do fail-safe vmalloc(), we * can guarantee that these special addresses and * vmalloc()-ed addresses never overlap. Mathieu > Signed-off-by: Masami Hiramatsu <mhi...@re...> > Cc: Mathieu Desnoyers <mat...@po...> > Cc: Ingo Molnar <mi...@el...> > --- > > arch/x86/kernel/alternative.c | 14 +++++++++----- > 1 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c > index f576587..4d8b40b 100644 > --- a/arch/x86/kernel/alternative.c > +++ b/arch/x86/kernel/alternative.c > @@ -527,14 +527,18 @@ void *__kprobes text_poke(void *addr, const void *opcode, size_t len) > } > BUG_ON(!pages[0]); > local_irq_save(flags); > - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0])); > + /* > + * Since the fixmaps are assinged from higher address to lower, > + * we use FIX_TEXT_POKE1 first, and FIX_TEXT_POKE0 second. > + */ > + set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[0])); > if (pages[1]) > - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1])); > - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0); > + set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[1])); > + vaddr = (char *)fix_to_virt(FIX_TEXT_POKE1); > memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len); > - clear_fixmap(FIX_TEXT_POKE0); > + clear_fixmap(FIX_TEXT_POKE1); > if (pages[1]) > - clear_fixmap(FIX_TEXT_POKE1); > + clear_fixmap(FIX_TEXT_POKE0); > local_flush_tlb(); > sync_core(); > /* Could also do a CLFLUSH here to speed up CPU recovery; but > > > -- > Masami Hiramatsu > > Software Engineer > Hitachi Computer Products (America), Inc. > Software Solutions Division > > e-mail: mhi...@re... -- Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 |