From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752123AbbCWIKF (ORCPT ); Mon, 23 Mar 2015 04:10:05 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:36805 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbbCWIKB (ORCPT ); Mon, 23 Mar 2015 04:10:01 -0400 Date: Mon, 23 Mar 2015 09:09:56 +0100 From: Ingo Molnar To: Jim Kukunas Cc: Linux Kernel , tom.zanussi@linux.intel.com, Arjan van de Ven , "H. Peter Anvin" , tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, Borislav Petkov Subject: Re: [PATCH 11/11] x86/xip: update _va() and _pa() macros Message-ID: <20150323080956.GC25620@gmail.com> References: <1427096800-30452-1-git-send-email-james.t.kukunas@linux.intel.com> <1427096800-30452-12-git-send-email-james.t.kukunas@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427096800-30452-12-git-send-email-james.t.kukunas@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Jim Kukunas wrote: > For obtaining the physical address, we always take the slow path > of slow_virt_to_phys(). In the future, we should probably special > case data addresses to avoid walking the page table. For obtaining > a virtual address, this patch introduces a slow path of > slow_xip_phys_to_virt(). > > Signed-off-by: Jim Kukunas > --- > arch/x86/include/asm/page.h | 15 +++++++++++++++ > arch/x86/mm/pageattr.c | 11 +++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h > index 802dde3..b54c7be 100644 > --- a/arch/x86/include/asm/page.h > +++ b/arch/x86/include/asm/page.h > @@ -6,6 +6,7 @@ > #ifdef __KERNEL__ > > #include > +#include > > #ifdef CONFIG_X86_64 > #include > @@ -37,8 +38,15 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr, > alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) > #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE > > + > +#ifdef CONFIG_XIP_KERNEL /* TODO special case text translations */ > +#define __pa(x) slow_virt_to_phys((void *)(x)) > +#define __pa_nodebug slow_virt_to_phys((void *)(x)) > +#else > #define __pa(x) __phys_addr((unsigned long)(x)) > #define __pa_nodebug(x) __phys_addr_nodebug((unsigned long)(x)) > +#endif Ugh. This needs to be fixed properly. slow_virt_to_phys() is very painful. > +#ifdef CONFIG_XIP_KERNEL > +unsigned long slow_xip_phys_to_virt(phys_addr_t x) > +{ > + if (x >= CONFIG_XIP_BASE && x <= (phys_addr_t)phys_sdata) { > + unsigned long off = x - CONFIG_XIP_BASE; > + return PAGE_OFFSET + off; > + } > + return x + PAGE_OFFSET; > +} > +#endif So why not relocate the kernel properly before loading it into flash, instead of hacking these runtime translations into va/pa? Thanks, Ingo