2.4 64bits MAX_ADDRESS ?
Hi all,
Being at the very begining of my study of the Mel Goramn' thesis and so comparing parisc linux vm implementation, I just try to figure out some cst values. I so write I small case:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
/* ifdef __LP64__ */
#define PT_NLEVELS 3
#define PT_INITIAL 4 /* Number of initial page tables */ /*
#else __LP64__
#define PT_NLEVELS 2
#define PT_INITIAL 2
#endif
*/
#define MAX_ADDRBITS (PAGE_SHIFT + (PT_NLEVELS)*(PAGE_SHIFT - PT_NLEVELS)) #define MAX_ADDRESS (1UL << MAX_ADDRBITS)
int main(int argc, char * * argv, char * * env) {
printf("For remainder:\n");
printf("Int size: %d,\n", sizeof(int));
printf("Long size: %d,\n", sizeof(long));
printf("LongLong size: %d.\n\n", sizeof(long long));
printf("Some VM cst into parisc 64bits:\n");
printf("PAGE_SHIFT: %#010x (%u)\n\n", PAGE_SHIFT, PAGE_SHIFT);
printf("PAGE_SIZE (1UL << PAGE_SHIFT)\n");
printf("PAGE_SIZE: %#010x (%u)\n\n", PAGE_SIZE, PAGE_SIZE);
printf(" PAGE_MASK (~(PAGE_SIZE-1))\n");
printf("PAGE_MASK: %#010x (%u) (%d)\n\n", PAGE_MASK, PAGE_MASK, PAGE_MASK);
printf("PT_NLEVELS: %#010x (%u)\n\n", PT_NLEVELS, PT_NLEVELS);
printf("PT_INITIAL: %#010x (%u)\n\n", PT_INITIAL, PT_INITIAL);
printf("MAX_ADDRBITS (PAGE_SHIFT + (PT_NLEVELS)*(PAGE_SHIFT -
PT_NLEVELS))\n");
printf("MAX_ADDRBITS: %#010x (%u)\n\n", MAX_ADDRBITS, MAX_ADDRBITS);
printf("MAX_ADDRESS (1UL << MAX_ADDRBITS)\n");
printf("MAX_ADDRESS: %#010Lx (%ul)\n\n", MAX_ADDRESS, MAX_ADDRESS);
}which correctly warm me about some 'overflow':
foo.c: In function `main':
foo.c:42: warning: left shift count >= width of type foo.c:42: warning: left shift count >= width of type
afaik MAX_ADDRBITS==39 against a long contains only 32bits?
So is this patch make sense for all (I trust if we want a day managing the some 15 Exabytes of vm available with pa-2.0 processors):
---------><---------
asm-parisc/pgtable.h renamed from asm-parisc/pgtable.h.orig +4 -0
@@ -72,7 +72,11 @@#endif #define MAX_ADDRBITS (PAGE_SHIFT + (PT_NLEVELS)*(PAGE_SHIFT - PT_NLEVELS)) +#ifdef __LP64__ +#define MAX_ADDRESS (1ULL << MAX_ADDRBITS) +#else #define MAX_ADDRESS (1UL << MAX_ADDRBITS) +#endif #define SPACEID_SHIFT (MAX_ADDRBITS - 32)
---------><---------
And may be is this not the only change. Please advise.
Thanks inadvance,
Joel
Quoted 7 lines · Joel Soete
which correctly warm me about some 'overflow':
foo.c: In function `main':
foo.c:42: warning: left shift count >= width of type foo.c:42: warning: left shift count >= width of typeafaik MAX_ADDRBITS==39 against a long contains only 32bits?
no, long is 64-bit in LP64. that's what LP64 means.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 1 line · Matthew Wilcox
no, long is 64-bit in LP64. that's what LP64 means.
What Matthew says is correct for the kernel. You got your error because you look to have compiled your program in userspace with kernel headers. Since userspace is currently only 32 bit, that's why you get the problems.
If you want to try out 64 bit userspace, which is the only way userspace will see a virtual address longer than 32 bits, then there's a preliminary test environment at
http://parisc-linux.org/~jejb/64bit.tar.gz
The mini library may be sufficient to compile your program.
James