Created
January 20, 2022 03:22
-
-
Save soleen/fdcd501d5df103976245fe84e9535087 to your computer and use it in GitHub Desktop.
page table check panic repro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <fcntl.h> | |
#include <sched.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <sys/mount.h> | |
#include <sys/stat.h> | |
#include <sys/syscall.h> | |
#include <unistd.h> | |
#include <sys/mman.h> | |
#include <linux/perf_event.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
char *addr = (char *)0x20000000ul; | |
struct perf_event_attr *attr = (void *)addr + 1024 * 1024; | |
char *file = "./bus"; | |
char *dir = "./dir"; | |
int fd1, fd2; | |
void *rv_mmap; | |
unshare(CLONE_NEWNS); | |
mkdir(dir, 0777); | |
mount(NULL, dir, "tmpfs", 0, "huge=always"); | |
chdir(dir); | |
fd1 = creat(file, 0); | |
ftruncate(fd1, 2 * 1024 * 1024); | |
close(fd1); | |
fd1 = open(file, 0); | |
rv_mmap = mmap(addr, 2 * 1024 * 1024, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE | MAP_LOCKED, -1, 0ul); | |
attr->type = 6; | |
attr->bp_addr = (uint64_t)file; | |
fd2 = syscall(__NR_perf_event_open, attr, 0, 0ul, -1, 0ul); | |
rv_mmap = mmap(addr, 2 * 1024 * 1024, PROT_READ, MAP_FIXED | MAP_PRIVATE | MAP_LOCKED, fd1, 0ul); | |
close(fd2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment