lkml.org 
[lkml]   [2008]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -tip] x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y (try 2)
Vegard Nossum napsal(a):
> Is this what you had in mind? If not, then I don't know how to do it :-)

Yeah, something like that, but I am not the one you need ACK from ;).

Few notes below.

> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> index 835e062..b20389d 100644
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -45,6 +45,28 @@ unsigned long __phys_addr(unsigned long x)
> }
> EXPORT_SYMBOL(__phys_addr);
>
> +bool __virt_addr_valid(unsigned long x)
> +{
> + if (x >= __START_KERNEL_map) {
> + x -= __START_KERNEL_map;
> + if (x >= KERNEL_IMAGE_SIZE)
> + return false;
> + x += phys_base;
> + } else {
> + if (x < PAGE_OFFSET)
> + return false;
> + x -= PAGE_OFFSET;
> + if (system_state == SYSTEM_BOOTING
> + ? x > MAXMEM : !phys_addr_valid(x))
> + {
> + return false;
> + }
> + }
> +
> + return pfn_valid(x >> PAGE_SHIFT);
> +}
> +EXPORT_SYMBOL(__virt_addr_valid);

Just an implementation note. Still don't expect address for which
__virt_addr_valid() returns true to not cause a page fault. If it is called
e.g. for address between __START_KERNEL_map and
__START_KERNEL_map+KERNEL_IMAGE_SIZE and its pte entry has present bit
unset, it will crash when dereferenced -- unused pages above kernel image
are unmapped during boot.

> +
> #else
[...]
> +bool __virt_addr_valid(unsigned long x)
> +{
> + if (x < PAGE_OFFSET)
> + return false;
> + if (system_state != SYSTEM_BOOTING && is_vmalloc_addr((void *) x))
> + return false;
> + return pfn_valid((x - PAGE_OFFSET) >> PAGE_SHIFT);
> +}

Here too, the mappings at the top are probably returned as true? Absolutely
not sure about this (what returns pfn_valid on those corresponding physical
addresses).

> #endif
>
> int page_is_ram(unsigned long pagenr)


\
 
 \ /
  Last update: 2008-10-03 20:15    [W:0.047 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site