Skip to contentSkip to conversation

PAGE_SIZE and native vs. emulated 32-bit SPARC ABI

DISCUSSION William Lee Irwin III 3 participants 5 messages Dec 30, 2004 – Jan 4, 2005

lore
Share & tools
lore
#0 lore raw

It seems that most/all 32-bit SPARC programs are written and compiled for emulated 32-bit on sun4u, which has an 8KB PAGE_SIZE, and returns 8KB for getpagesize(). This is unfortunately causing spectacular failures on some of my favorite regression tests for memory management, which are interpreters using memory protection-based garbage collectors.

In particular, with a simple LD_PRELOAD to return a falsified 8KB PAGE_SIZE, sbcl (a Common Lisp interpreter and compiler) may be made to run, where it can't without such. The installation procedure runs the interpreter, which is basically the extent of what I do with the ones that run themselves during the installation procedure. For others just starting up the interpreter serves as a simple testcase.

So, the question arises as to what to do about these ABI breakages. It's unclear that changing the page size to 8192 unconditionally will work, as there are suspected breakages in the other direction, as another of those interpreters with protection-based GC that is strongly suspected of being hardwired to a 4KB PAGE_SIZE.

Any ideas?

-- wli

#1 lore raw
Quoted 4 lines · William Lee Irwin III

It seems that most/all 32-bit SPARC programs are written and compiled for emulated 32-bit on sun4u, which has an 8KB PAGE_SIZE, and returns 8KB for getpagesize(). This is unfortunately causing spectacular failures

This sounds like a bug to me.
A 32 bit program should see the same kernel environment on 32 and 64 bit machines. There may be a case for saying that the compiler should also be aware of such issues when building a 32 bit model.
Also see the kernel config stuff - the page size for ramdisks defaults to 4096.

#2 lore raw
In reply to William Lee Irwin III
Quoted 4 lines · William Lee Irwin III
Quoted 4 lines

It seems that most/all 32-bit SPARC programs are written and compiled for emulated 32-bit on sun4u, which has an 8KB PAGE_SIZE, and returns 8KB for getpagesize(). This is unfortunately causing spectacular failures

Quoted 6 lines · C.Newport

This sounds like a bug to me.
A 32 bit program should see the same kernel environment on 32 and 64 bit machines. There may be a case for saying that the compiler should also be aware of such issues when building a 32 bit model.
Also see the kernel config stuff - the page size for ramdisks defaults to 4096.

IMHO this is ABI emulation QOI. I personally just use the things for ABI torture tests, and affected programs are somewhat uncommon. I think dealing with this would involve personality handling in sparc32, since it by and large is stuck bearing the burden of being compatible with common usage on more modern 32-bit environments and not vice-versa, which may very well be impossible.

-- wli

#3 lore raw
In reply to William Lee Irwin III
Quoted 5 lines · On Thu, 30 Dec 2004 03:07:07 -0800 William Lee Irwin III <[email protected]>…

It seems that most/all 32-bit SPARC programs are written and compiled for emulated 32-bit on sun4u, which has an 8KB PAGE_SIZE, and returns 8KB for getpagesize(). This is unfortunately causing spectacular failures on some of my favorite regression tests for memory management, which are interpreters using memory protection-based garbage collectors.

The Sparc ABI states that one may make no assumptions about the PAGE_SIZE in any way. That's why 32-bit Sparc ELF binaries compiled before sun4u even existed can execute properly on 8KB PAGE_SIZE systems.

Not using getpagesize() is a pretty serious programming error.

There are even facilities in the Sparc ELF specification that allow the binaries to work just fine for up to a 64KB page size. A long time ago, Kanoj Sarcar played around with changing the default PAGE_SIZE of sparc64 to be 64K and all 32-bit binaries worked just fine.

#4 lore raw
In reply to William Lee Irwin III
Quoted 9 lines · David S. Miller

The Sparc ABI states that one may make no assumptions about the PAGE_SIZE in any way. That's why 32-bit Sparc ELF binaries compiled before sun4u even existed can execute properly on 8KB PAGE_SIZE systems.
Not using getpagesize() is a pretty serious programming error. There are even facilities in the Sparc ELF specification that allow the binaries to work just fine for up to a 64KB page size. A long time ago, Kanoj Sarcar played around with changing the default PAGE_SIZE of sparc64 to be 64K and all 32-bit binaries worked just fine.

I'll have to reiterate the hard answer I told the maintainers of one of these cases. One of the other cases hasn't been diagnosed or resolved yet but they are more willing/able to fix it in userspace.

-- wli