From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: ehabkost@redhat.com, x86@kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Make PFN_PHYS return a properly-formed physical address
Date: Thu, 07 Aug 2008 15:10:11 -0700 [thread overview]
Message-ID: <489B72C3.30603@goop.org> (raw)
In-Reply-To: <20080807145648.ab3dfa90.akpm@linux-foundation.org>
Andrew Morton wrote:
> On Thu, 07 Aug 2008 14:38:08 -0700
> Jeremy Fitzhardinge <jeremy@goop.org> wrote:
>
>
>> PFN_PHYS, as its name suggests, turns a pfn into a physical address.
>> However, it is a macro which just operates on its argument without
>> modifying its type. pfns are typed unsigned long, but an unsigned
>> long may not be long enough to hold a physical address (32-bit systems
>> with more than 32 bits of physcial address). This means that the
>> resulting address could be truncated if it doesn't fit within an
>> unsigned long. This isn't generally a problem because most users end
>> up using it for "low" memory, but there's no reason why PFN_PHYS
>> couldn't be used for any possible pfn.
>>
>
> Please copy a mailing list on patches. So you can get your titties
> toasted off ;)
>
Oops. Forgot.
>> Fortunately, resource_size_t is the right size, and has approximately
>> the right meaning. It's 64-bits on platforms where that's
>> appropriate, but 32-bits where the extra bits are not needed.
>>
>
> aww maaan. Hack or what?
>
I don't know. Is it? It's what linux/ioport.h:struct resource uses to
hold "start" and "end", which presumably means its intended to hold
arbitrary physical addresses.
>> #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
>> #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
>> #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
>> -#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
>> +#define PFN_PHYS(x) ((resource_size_t)(x) << PAGE_SHIFT)
>>
>
> Busted on PAE with CONFIG_RESOURCES_64BIT=n, surely?
>
Not an option:
config X86_PAE
def_bool n
prompt "PAE (Physical Address Extension) Support"
depends on X86_32 && !HIGHMEM4G
select RESOURCES_64BIT
And if you don't enable RESOURCES_64BIT, then I guess it's reasonable
for PFN_PHYS to discount the possibility of high pages?
> Can we please do this properly, whatever that is? Even a dumb
> always-return-u64 would be better?
>
I had that originally, but someone (hpa?) suggested resource_size_t.
The sad thing is that most users don't really care; they're either
64-bit anyway, or immediately truncate the result to 32-bit.
"Properly" would be to define a phys_addr_t which can always represent a
physical address. We have one in x86-land, but I hesitate to add it for
everyone else.
>> printk("initrd extends beyond end of memory "
>> - "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
>> + "(0x%08lx > 0x%08llx)\ndisabling initrd\n",
>> INITRD_START + INITRD_SIZE,
>> PFN_PHYS(max_low_pfn));
>>
>
> that'll generate a compile warning if m32r can set CONFIG_RESOURCES_64BIT=n.
>
(u64) cast, I guess.
J
next parent reply other threads:[~2008-08-07 22:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <489B6B40.5050705@goop.org>
[not found] ` <20080807145648.ab3dfa90.akpm@linux-foundation.org>
2008-08-07 22:10 ` Jeremy Fitzhardinge [this message]
2008-08-07 23:27 ` [PATCH] Make PFN_PHYS return a properly-formed physical address Andrew Morton
2008-08-07 23:45 ` Jeremy Fitzhardinge
2008-08-08 0:06 ` Andrew Morton
2008-08-08 0:16 ` Jeremy Fitzhardinge
2008-08-11 19:38 ` [PATCH 1/2] add phys_addr_t for holding physical addresses Jeremy Fitzhardinge
2008-08-11 21:58 ` Benjamin Herrenschmidt
2008-08-11 22:15 ` Jeremy Fitzhardinge
2008-08-11 22:32 ` Benjamin Herrenschmidt
2008-08-11 22:50 ` Jeremy Fitzhardinge
2008-08-11 22:53 ` Benjamin Herrenschmidt
2008-08-11 23:02 ` Jeremy Fitzhardinge
2008-08-11 23:17 ` Benjamin Herrenschmidt
2008-08-11 19:38 ` [PATCH 2/2] make PFN_PHYS explicitly return phys_addr_t Jeremy Fitzhardinge
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=489B72C3.30603@goop.org \
--to=jeremy@goop.org \
--cc=akpm@linux-foundation.org \
--cc=ehabkost@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/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