lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 23 Mar 2015 09:09:56 +0100
From:	Ingo Molnar <mingo@...nel.org>
To:	Jim Kukunas <james.t.kukunas@...ux.intel.com>
Cc:	Linux Kernel <linux-kernel@...r.kernel.org>,
	tom.zanussi@...ux.intel.com,
	Arjan van de Ven <arjan@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>, tglx@...utronix.de,
	mingo@...hat.com, x86@...nel.org, Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH 11/11] x86/xip: update _va() and _pa() macros


* Jim Kukunas <james.t.kukunas@...ux.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@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ