Re: [PATCH] x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y

From: Jiri Slaby
Date: Wed Oct 01 2008 - 07:06:42 EST


On 10/01/2008 12:47 PM, Vegard Nossum wrote:
> Hi,
>
> Fix for tip/x86/mm-debug (commit 59ea746337c69f6a5f1bc4d5e8544b3cbf12f801).
> I'm not sure if choice of names/structure is entirely correct, comments are
> appreciated.


> From 01613a1949de51c7ab9d0acaaa9a5444722a5cfa Mon Sep 17 00:00:00 2001
> From: Vegard Nossum <vegardno@xxxxxxxxxxxxxx>
> Date: Wed, 1 Oct 2008 12:36:34 +0200
> Subject: [PATCH] x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y
>
> virt_addr_valid() calls __pa(), which calls __phys_addr(). With
> CONFIG_DEBUG_VIRTUAL=y, __phys_addr() will kill the kernel if the
> address *isn't* valid. That's clearly wrong for virt_addr_valid().
>
> Cc: Jiri Slaby <jirislaby@xxxxxxxxx>
> Cc: Andi Kleen <andi@xxxxxxxxxxxxxx>
> Signed-off-by: Vegard Nossum <vegardno@xxxxxxxxxxxxxx>
> ---
> diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
> index 395acb1..1580e0b 100644
> --- a/arch/x86/kernel/doublefault_32.c
> +++ b/arch/x86/kernel/doublefault_32.c
> @@ -66,6 +66,6 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
> .ds = __USER_DS,
> .fs = __KERNEL_PERCPU,
>
> - .__cr3 = __phys_addr_const((unsigned long)swapper_pg_dir)
> + .__cr3 = __phys_addr_nodebug((unsigned long)swapper_pg_dir)

Now, this may be switched back to __pa: __pa_nodebug(swapper_pg_dir);

> }
> };
[...]
> --- a/include/asm-x86/page_64.h
> +++ b/include/asm-x86/page_64.h
> @@ -69,6 +69,7 @@ extern unsigned long max_pfn;
> extern unsigned long phys_base;
>
> extern unsigned long __phys_addr(unsigned long);
> +#define __phys_addr_nodebug(x) __phys_addr(x)
> #define __phys_reloc_hide(x) (x)

x86_64 is screwed in the same way, isn't it?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/