public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* MIPS: getpagesize, PAGE_SHIFT, and PAGE_SIZE
@ 2010-11-23 20:32 Matt Turner
  2010-11-26 16:45 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Turner @ 2010-11-23 20:32 UTC (permalink / raw)
  To: libc-ports; +Cc: Maciej W. Rozycki, andrew.pinski

MIPS' getpagesize.c includes the ia64 implementation. [1] The ia64
implementation is the generic Linux implementation if
__ASSUME_AT_PAGESIZE is defined, and __ASSUME_AT_PAGESIZE looks to me
to be defined for all platforms and kernels post-2.4.0-pre-something
in kernel-features.h.

Can someone explain what having __ASSUME_AT_PAGESIZE defined actually
means? Is it correct that it's defined on MIPS? If so, can't we just
#include the generic Linux implementation instead of ia64, or better
yet, just delete MIPS' getpagesize.c?

Also, PAGE_SHIFT (and by extension PAGE_SIZE) are defined as constants
on MIPS. This is clearly wrong, as MIPS supports multiple pagesizes.
What can we do about this?

Thanks,
Matt

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=1047

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MIPS: getpagesize, PAGE_SHIFT, and PAGE_SIZE
  2010-11-23 20:32 MIPS: getpagesize, PAGE_SHIFT, and PAGE_SIZE Matt Turner
@ 2010-11-26 16:45 ` Richard Henderson
  2010-11-26 17:20   ` Maciej W. Rozycki
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2010-11-26 16:45 UTC (permalink / raw)
  To: Matt Turner; +Cc: libc-ports, Maciej W. Rozycki, andrew.pinski

On 11/23/2010 12:24 PM, Matt Turner wrote:
> Can someone explain what having __ASSUME_AT_PAGESIZE defined actually
> means? Is it correct that it's defined on MIPS? If so, can't we just
> #include the generic Linux implementation instead of ia64, or better
> yet, just delete MIPS' getpagesize.c?

_ASSUME_AT_PAGESIZE means "assume the kernel has included the AT_PAGESZ
entry in the auxv area that lives above argc+argv+env at program start".

Given that this entry is added by generic code in binfmt_elf.c, yes it
is correct that it's defined on MIPS.

> Also, PAGE_SHIFT (and by extension PAGE_SIZE) are defined as constants
> on MIPS. This is clearly wrong, as MIPS supports multiple pagesizes.
> What can we do about this?

Delete the relevant entries?  That's what ia64, sparc, powerpc seem to do.


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MIPS: getpagesize, PAGE_SHIFT, and PAGE_SIZE
  2010-11-26 16:45 ` Richard Henderson
@ 2010-11-26 17:20   ` Maciej W. Rozycki
  2010-11-27  9:30     ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Maciej W. Rozycki @ 2010-11-26 17:20 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Matt Turner, libc-ports, andrew.pinski

On Fri, 26 Nov 2010, Richard Henderson wrote:

> > Also, PAGE_SHIFT (and by extension PAGE_SIZE) are defined as constants
> > on MIPS. This is clearly wrong, as MIPS supports multiple pagesizes.
> > What can we do about this?
> 
> Delete the relevant entries?  That's what ia64, sparc, powerpc seem to do.

 At the point I was fiddling with this code it did not rely on the kernel 
macros; in fact I built the library with the macros deliberately 
undefined, i.e. using unconfigured kernel headers by means of a recipe 
like this:

$ make -C linux distclean include/linux/version.h
$ ln -s asm-mips linux/include/asm
$ echo "#define AUTOCONF_INCLUDED" > linux/include/linux/autoconf.h

during the build and then installed in $includedir for further use -- that 
leaves all the kernel's CONFIG_PAGE_SIZE_* macros undefined and hence 
there's no PAGE_SHIFT definition to catch buggy software.

 It was many years ago though and things may have got broken meanwhile of 
course, but the version around the time I submitted dl-static.c should be 
a good starting point.  For one you'll need to adjust paths for the 
changed location of the asm headers in the Linux tree these days.

 Note I'm considering the C library only here -- if any piece of user code 
bypasses libc interfaces and goes straight through down to the kernel 
macros, then it deserves its fate.  The PAGE_SHIFT and PAGE_SIZE macros 
are not a part of the user API; the getpagesize() function is (it's up to 
the C library implementation for a given port to define it as a static 
inline function returning a constant if applicable).

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MIPS: getpagesize, PAGE_SHIFT, and PAGE_SIZE
  2010-11-26 17:20   ` Maciej W. Rozycki
@ 2010-11-27  9:30     ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2010-11-27  9:30 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Richard Henderson, Matt Turner, libc-ports, andrew.pinski

"Maciej W. Rozycki" <macro@linux-mips.org> writes:

>  At the point I was fiddling with this code it did not rely on the kernel 
> macros; in fact I built the library with the macros deliberately 
> undefined, i.e. using unconfigured kernel headers by means of a recipe 
> like this:
>
> $ make -C linux distclean include/linux/version.h
> $ ln -s asm-mips linux/include/asm
> $ echo "#define AUTOCONF_INCLUDED" > linux/include/linux/autoconf.h
>
> during the build and then installed in $includedir for further use -- that 
> leaves all the kernel's CONFIG_PAGE_SIZE_* macros undefined and hence 
> there's no PAGE_SHIFT definition to catch buggy software.

Noadays the correct way to install the kernel headers is to run "make
headers_install" and use the cleaned up headers it generates.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-27  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-23 20:32 MIPS: getpagesize, PAGE_SHIFT, and PAGE_SIZE Matt Turner
2010-11-26 16:45 ` Richard Henderson
2010-11-26 17:20   ` Maciej W. Rozycki
2010-11-27  9:30     ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).