Messages in this thread | | | Date | Thu, 8 May 2008 16:39:33 +0200 | From | Hans Rosenfeld <> | Subject | Re: [PATCH] x86: fix PAE pmd_bad bootup warning |
| |
On Thu, May 08, 2008 at 04:34:53PM +0200, Hans Rosenfeld wrote: > A stripped-down program exposing the leak is attached.
It is now :)
-- %SYSTEM-F-ANARCHISM, The operating system has been overthrown #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <inttypes.h> #include <signal.h> #include <string.h> #include <strings.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>
#define HUGEPAGES "/proc/sys/vm/nr_hugepages" #define HUGE_FILE "/mnt/huge/foobar"
void *huge;
int main(int argc, char **argv) { uint64_t ppte; int fd, maps;
if ((fd = open(HUGEPAGES, O_WRONLY, 0)) == -1) { perror(HUGEPAGES); return 1; } write(fd, "20\n", 3); close(fd);
if ((fd = open(HUGE_FILE, O_RDWR | O_CREAT, 0)) == -1) { perror(HUGE_FILE); return 1; }
huge = mmap((void *) 0x1000000, 0x400000, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0);
if (huge == MAP_FAILED) { perror(HUGE_FILE); return 1; }
fprintf(stderr, "huge: 0x%0.*" PRIxPTR "\n", sizeof(huge) * 2, huge); memset(huge, 1, 12345);
if ((maps = open("/proc/self/pagemap", O_RDONLY, 0)) < 0) { perror("/proc/self/pagemap"); return 1; }
if (pread(maps, &ppte, sizeof(ppte), ((uintptr_t) huge) >> 9) < 0) { perror("pread"); return 1; }
fprintf(stderr, "ppte: 0x%0.16" PRIx64 "\n", ppte);
return 0; }
| |