linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, bp@alien8.de,
	mingo@kernel.org, tglx@linutronix.de
Subject: Re: [PATCH 1/2] add helper for highmem checks
Date: Fri, 08 Feb 2013 15:16:18 -0800	[thread overview]
Message-ID: <51158742.4030803@linux.vnet.ibm.com> (raw)
In-Reply-To: <51156507.50900@zytor.com>

On 02/08/2013 12:50 PM, H. Peter Anvin wrote:
> On 02/08/2013 12:28 PM, Dave Hansen wrote:
>> +static inline phys_addr_t last_lowmem_phys_addr(void)
>> +{
>> +    /*
>> +     * 'high_memory' is not a pointer that can be dereferenced, so
>> +     * avoid calling __pa() on it directly.
>> +     */
>> +    return __pa(high_memory - 1);
>> +}
>> +static inline bool phys_addr_is_highmem(phys_addr_t addr)
>> +{
>> +    return addr > last_lowmem_paddr();
>> +}
>> +
> 
> Are we sure that high_memory - 1 is always a valid reference?  Consider
> especially the case where there is MMIO beyond end of memory on a system
> which has less RAM than the HIGHMEM boundary...

Yeah, I think it is.  "high_memory" should point at either the end of
RAM, or the end of the linear map, whichever is lower.  See setup_arch():

        max_pfn = e820_end_of_ram_pfn();
	...
        high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;

or in the highmem init code:

        high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-02-08 23:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 20:28 Dave Hansen
2013-02-08 20:28 ` [PATCH 2/2] make /dev/kmem return error for highmem Dave Hansen
2013-02-08 20:48   ` H. Peter Anvin
2013-02-08 20:50 ` [PATCH 1/2] add helper for highmem checks H. Peter Anvin
2013-02-08 23:16   ` Dave Hansen [this message]
2013-02-09  9:41 ` Borislav Petkov
2013-02-09 10:47   ` Borislav Petkov
2013-02-11 17:32     ` Dave Hansen
2013-02-11 18:09       ` H. Peter Anvin
2013-02-11 18:28       ` Borislav Petkov
2013-02-11 19:44         ` H. Peter Anvin
2013-02-11 22:34           ` Borislav Petkov
2013-02-11 22:46             ` H. Peter Anvin
2013-02-11 23:00               ` Borislav Petkov
2013-02-11 23:02                 ` H. Peter Anvin

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=51158742.4030803@linux.vnet.ibm.com \
    --to=dave@linux.vnet.ibm.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox