All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Jim Kukunas <james.t.kukunas@linux.intel.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
	tom.zanussi@linux.intel.com,
	Arjan van de Ven <arjan@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	tglx@linutronix.de, mingo@redhat.com, x86@kernel.org,
	Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH 11/11] x86/xip: update _va() and _pa() macros
Date: Mon, 23 Mar 2015 09:09:56 +0100	[thread overview]
Message-ID: <20150323080956.GC25620@gmail.com> (raw)
In-Reply-To: <1427096800-30452-12-git-send-email-james.t.kukunas@linux.intel.com>


* Jim Kukunas <james.t.kukunas@linux.intel.com> 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 <james.t.kukunas@linux.intel.com>
> ---
>  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 <asm/page_types.h>
> +#include <asm/pgtable_types.h>
>  
>  #ifdef CONFIG_X86_64
>  #include <asm/page_64.h>
> @@ -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

  reply	other threads:[~2015-03-23  8:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23  7:46 [RFC] x86 XIP Jim Kukunas
2015-03-23  7:46 ` [PATCH 01/11] x86/xip: add XIP_KERNEL and XIP_BASE options Jim Kukunas
2015-03-23  7:46 ` [PATCH 02/11] x86/xip: Update address of sections in linker script Jim Kukunas
2015-03-23  7:46 ` [PATCH 03/11] x86/xip: copy writable sections into RAM Jim Kukunas
2015-03-23  7:46 ` [PATCH 04/11] x86/xip: XIP boot trampoline page tables Jim Kukunas
2015-03-23  7:46 ` [PATCH 05/11] x86/xip: reserve memblock for only data Jim Kukunas
2015-03-23  7:46 ` [PATCH 06/11] x86/xip: after paging trampoline, discard PMDs above _brk Jim Kukunas
2015-03-23  7:46 ` [PATCH 07/11] x86/xip: make e820_add_kernel_range() a NOP Jim Kukunas
2015-03-23  7:46 ` [PATCH 08/11] x86/xip: in setup_arch(), handle resource physical addr Jim Kukunas
2015-03-23  7:46 ` [PATCH 09/11] x86/xip: snip the kernel text out of the memory mapping Jim Kukunas
2015-03-23  7:46 ` [PATCH 10/11] x86/xip: resolve alternative instructions at build Jim Kukunas
2015-03-23  8:33   ` Borislav Petkov
2015-03-23  8:38     ` Borislav Petkov
2015-03-25  0:50     ` Jim Kukunas
2015-03-25  8:44       ` Borislav Petkov
2015-03-23 22:40   ` Paul Bolle
2015-03-23  7:46 ` [PATCH 11/11] x86/xip: update _va() and _pa() macros Jim Kukunas
2015-03-23  8:09   ` Ingo Molnar [this message]
2015-03-23 15:09     ` Borislav Petkov
2015-03-23  8:07 ` [RFC] x86 XIP Ingo Molnar
2015-03-25  0:14   ` Jim Kukunas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150323080956.GC25620@gmail.com \
    --to=mingo@kernel.org \
    --cc=arjan@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=james.t.kukunas@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tom.zanussi@linux.intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.