int __init vsyscall_init(void) { printk("VSYSCALL: consistency checks..."); if ((unsigned long) &vgettimeofday != VSYSCALL_ADDR(__NR_vgettimeofday)) { printk("vgettimeofday link addr broken\n"); printk("VSYSCALL: vsyscall_init failed!\n"); return -EFAULT; } if ((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime)) { printk("vtime link addr broken\n"); printk("VSYSCALL: vsyscall_init failed!\n"); return -EFAULT; } if (VSYSCALL_ADDR(0) != __fix_to_virt(FIX_VSYSCALL_GTOD_FIRST_PAGE)) { printk("fixmap first vsyscall 0x%lx should be 0x%x\n", __fix_to_virt(FIX_VSYSCALL_GTOD_FIRST_PAGE), VSYSCALL_ADDR(0)); printk("VSYSCALL: vsyscall_init failed!\n"); return -EFAULT; } printk("passed...mapping..."); map_vsyscall(); printk("done.\n"); vsyscall_mapped = 1; printk("VSYSCALL: fixmap virt addr: 0x%lx\n", __fix_to_virt(FIX_VSYSCALL_GTOD_FIRST_PAGE)); return 0; }
static int __init vsyscall_init(void) { if ((unsigned long) &vgettimeofday != VSYSCALL_ADDR(__NR_vgettimeofday)) panic("vgettimeofday link addr broken"); if ((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime)) panic("vtime link addr broken"); if (VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)) panic("fixmap first vsyscall %lx should be %lx", __fix_to_virt(VSYSCALL_FIRST_PAGE), VSYSCALL_ADDR(0)); map_vsyscall(); return 0; }
static int __init vsyscall_init(void) { BUG_ON(VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)); on_each_cpu(cpu_vsyscall_init, NULL, 1); /* notifier priority > KVM */ hotcpu_notifier(cpu_vsyscall_notifier, 30); return 0; }
/* Get the current time of day and timezone information, putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. Returns 0 on success, -1 on errors. */ int __gettimeofday (struct timeval *tv, struct timezone *tz) { /* We're using a virtual syscall here. */ int (*__vgettimeofday)(struct timeval *, struct timezone *) = (int (*)(struct timeval *, struct timezone *)) VSYSCALL_ADDR (__NR_vgettimeofday); return __vgettimeofday (tv, tz); }
// This can go away when RHEL5 support is no longer needed int sched_getcpu(void) { getcpu_p getcpu = (getcpu_p)VSYSCALL_ADDR(__NR_vgetcpu); unsigned cpu = 0; int status = -1; status = getcpu(&cpu, NULL, NULL); return (status == -1) ? status : (int)cpu; }
static int __init vsyscall_init(void) { // L4Linux: This is all wrong, and will probably trigger with the // first user using this... #ifndef CONFIG_L4 BUG_ON(VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)); #endif on_each_cpu(cpu_vsyscall_init, NULL, 1); /* notifier priority > KVM */ hotcpu_notifier(cpu_vsyscall_notifier, 30); return 0; }