From: Jiri Slaby <jirislaby@gmail.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -tip] x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y (try 2)
Date: Fri, 03 Oct 2008 20:11:27 +0200 [thread overview]
Message-ID: <48E6604F.8000404@gmail.com> (raw)
In-Reply-To: <20081003155425.GA6112@localhost.localdomain>
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)
next prev parent reply other threads:[~2008-10-03 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-03 14:07 [PATCH -tip] x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y (try 2) Vegard Nossum
2008-10-03 14:23 ` Jiri Slaby
2008-10-03 15:54 ` Vegard Nossum
2008-10-03 18:11 ` Jiri Slaby [this message]
2008-10-04 8:11 ` Ingo Molnar
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=48E6604F.8000404@gmail.com \
--to=jirislaby@gmail.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=vegard.nossum@gmail.com \
/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.