| #include <stdio.h> |
| #include <sys/types.h> |
| #include <sys/stat.h> |
| #include <fcntl.h> |
| #include <arch/arch.h> |
| #include <unistd.h> |
| #include <errno.h> |
| #include <dirent.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <ros/syscall.h> |
| |
| unsigned long stack[1024]; |
| |
| static void fail(void) |
| { |
| __asm__ __volatile__("mov $0xdeadbeef, %rbx; mov 5, %rax\n"); |
| } |
| |
| unsigned long long *p512, *p1, *p2m; |
| |
| int main(int argc, char **argv) |
| { |
| int fd = open("#c/sysctl", O_RDWR), ret; |
| static char cmd[512]; |
| if (fd < 0) { |
| perror("#c/sysctl"); |
| exit(1); |
| } |
| ret = syscall(33, 1); |
| if (ret < 0) { |
| perror("vm setup"); |
| exit(1); |
| } |
| ret = posix_memalign((void **)&p512, 4096, 3*4096); |
| if (ret) { |
| perror("ptp alloc"); |
| exit(1); |
| } |
| p1 = &p512[512]; |
| p2m = &p512[1024]; |
| p512[0] = (unsigned long long)p1 | 7; |
| p1[0] = /*0x87; */(unsigned long long)p2m | 7; |
| p2m[0] = 0x87; |
| p2m[1] = 0x200000 | 0x87; |
| p2m[2] = 0x400000 | 0x87; |
| p2m[3] = 0x600000 | 0x87; |
| |
| printf("p512 %p p512[0] is 0x%lx p1 %p p1[0] is 0x%x\n", p512, p512[0], p1, p1[0]); |
| sprintf(cmd, "V 0x%x 0x%x 0x%x", (unsigned long long)fail, (unsigned long long) stack, (unsigned long long) p512); |
| printf("Writing command :%s:\n", cmd); |
| ret = write(fd, cmd, strlen(cmd)); |
| if (ret != strlen(cmd)) { |
| perror(cmd); |
| } |
| |
| return 0; |
| } |