From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29692 invoked by alias); 1 Jul 2009 21:17:40 -0000 Received: (qmail 29683 invoked by uid 22791); 1 Jul 2009 21:17:39 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_44 X-Spam-Check-By: sourceware.org Received: from tomts36.bellnexxia.net (HELO tomts36-srv.bellnexxia.net) (209.226.175.93) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Jul 2009 21:17:33 +0000 Received: from toip7.srvr.bell.ca ([209.226.175.124]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20090701211731.ULUO1757.tomts36-srv.bellnexxia.net@toip7.srvr.bell.ca> for ; Wed, 1 Jul 2009 17:17:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqcFALxqS0pMQWU3/2dsb2JhbACBUc8dhBEF Received: from bas5-montreal19-1279354167.dsl.bell.ca (HELO krystal.dyndns.org) ([76.65.101.55]) by toip7.srvr.bell.ca with ESMTP; 01 Jul 2009 17:19:48 -0400 Received: from localhost (localhost [127.0.0.1]) (uid 1000) by krystal.dyndns.org with local; Wed, 01 Jul 2009 17:17:30 -0400 id 0001401B.4A4BD26A.00005341 Date: Wed, 01 Jul 2009 21:17:00 -0000 From: Mathieu Desnoyers To: Masami Hiramatsu Cc: Ingo Molnar , lkml , systemtap , DLE Subject: Re: [BUGFIX PATCH -tip] x86: Fix fixmap page order in text_poke() Message-ID: <20090701211730.GG19926@Krystal> References: <20090701210246.22089.65697.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <20090701210246.22089.65697.stgit@localhost.localdomain> X-Editor: vi User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00011.txt.bz2 * Masami Hiramatsu (mhiramat@redhat.com) 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 > Cc: Mathieu Desnoyers > Cc: Ingo Molnar > --- > > 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: mhiramat@redhat.com -- Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68