lkml.org 
[lkml]   [2008]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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;
}
\
 
 \ /
  Last update: 2008-05-08 16:43    [W:0.071 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site