diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/alpha/kernel/osf_sys.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/alpha/kernel/osf_sys.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/alpha/kernel/osf_sys.c 2006-05-11 16:06:22 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/alpha/kernel/osf_sys.c 2006-05-29 16:49:23 +0200 @@ -887,7 +887,7 @@ osf_gettimeofday(struct timeval32 __user { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/ia64/ia32/sys_ia32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/ia64/ia32/sys_ia32.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/ia64/ia32/sys_ia32.c 2006-04-28 05:07:10 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/ia64/ia32/sys_ia32.c 2006-05-29 16:49:39 +0200 @@ -1191,7 +1191,7 @@ sys32_gettimeofday (struct compat_timeva { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/mips/kernel/linux32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/mips/kernel/linux32.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/mips/kernel/linux32.c 2006-04-26 19:06:59 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/mips/kernel/linux32.c 2006-05-29 16:49:44 +0200 @@ -300,7 +300,7 @@ sys32_gettimeofday(struct compat_timeval { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/parisc/kernel/sys_parisc32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/parisc/kernel/sys_parisc32.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/parisc/kernel/sys_parisc32.c 2006-04-26 19:06:59 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/parisc/kernel/sys_parisc32.c 2006-05-29 16:50:03 +0200 @@ -203,11 +203,11 @@ static inline long get_ts32(struct times asmlinkage int sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz) { - extern void do_gettimeofday(struct timeval *tv); + extern void vx_gettimeofday(struct timeval *tv); if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_compat_timeval(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/powerpc/kernel/sys_ppc32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/powerpc/kernel/sys_ppc32.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/powerpc/kernel/sys_ppc32.c 2006-04-09 13:49:43 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/powerpc/kernel/sys_ppc32.c 2006-05-29 16:50:23 +0200 @@ -340,7 +340,7 @@ asmlinkage long compat_sys_gettimeofday( { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/s390/kernel/compat_linux.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/s390/kernel/compat_linux.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/s390/kernel/compat_linux.c 2006-02-18 14:39:48 +0100 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/s390/kernel/compat_linux.c 2006-05-29 16:53:03 +0200 @@ -595,7 +595,7 @@ asmlinkage long sys32_gettimeofday(struc { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/sparc64/kernel/sys_sparc32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/sparc64/kernel/sys_sparc32.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/sparc64/kernel/sys_sparc32.c 2006-02-18 14:39:49 +0100 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/sparc64/kernel/sys_sparc32.c 2006-05-29 16:53:09 +0200 @@ -788,7 +788,7 @@ asmlinkage long sys32_gettimeofday(struc { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/x86_64/ia32/sys_ia32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/x86_64/ia32/sys_ia32.c --- linux-2.6.16.17-vs2.1.1-rc21.1/arch/x86_64/ia32/sys_ia32.c 2006-04-26 19:07:00 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/x86_64/ia32/sys_ia32.c 2006-05-29 16:53:21 +0200 @@ -461,7 +461,7 @@ sys32_gettimeofday(struct compat_timeval { if (tv) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (put_tv32(tv, &ktv)) return -EFAULT; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/fs/exec.c linux-2.6.16.17-vs2.1.1-rc21.2/fs/exec.c --- linux-2.6.16.17-vs2.1.1-rc21.1/fs/exec.c 2006-04-26 19:07:00 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/fs/exec.c 2006-05-29 16:54:23 +0200 @@ -1323,7 +1323,7 @@ static void format_corename(char *corena /* UNIX time of coredump */ case 't': { struct timeval tv; - do_gettimeofday(&tv); + vx_gettimeofday(&tv); rc = snprintf(out_ptr, out_end - out_ptr, "%lu", tv.tv_sec); if (rc > out_end - out_ptr) diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/time.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/time.h --- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/time.h 2006-02-15 13:54:35 +0100 +++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/time.h 2006-05-29 17:31:53 +0200 @@ -147,6 +147,8 @@ extern struct timespec ns_to_timespec(co */ extern struct timeval ns_to_timeval(const nsec_t nsec); +#include + #endif /* __KERNEL__ */ #define NFDBITS __NFDBITS diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vs_time.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vs_time.h --- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vs_time.h 1970-01-01 01:00:00 +0100 +++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vs_time.h 2006-05-29 18:03:54 +0200 @@ -0,0 +1,19 @@ +#ifndef _VX_VS_TIME_H +#define _VX_VS_TIME_H + + +/* time faking stuff */ + +#ifdef CONFIG_VSERVER_VTIME + +extern void vx_gettimeofday(struct timeval *tv); +extern int vx_settimeofday(struct timeval *tv); + +#else +#define vx_gettimeofday(t) do_gettimeofday(t) +#define vx_settimeofday(t) do_settimeofday(t) +#endif + +#else +#warning duplicate inclusion +#endif diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/context.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/context.h --- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/context.h 2006-05-02 02:06:16 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/context.h 2006-05-29 17:49:04 +0200 @@ -35,6 +35,7 @@ #define VXF_VIRT_UPTIME 0x00020000 #define VXF_VIRT_CPU 0x00040000 #define VXF_VIRT_LOAD 0x00080000 +#define VXF_VIRT_TIME 0x00100000 #define VXF_HIDE_MOUNT 0x01000000 #define VXF_HIDE_NETIF 0x02000000 diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/cvirt_def.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/cvirt_def.h --- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/cvirt_def.h 2006-04-26 19:07:00 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/cvirt_def.h 2006-05-29 17:36:22 +0200 @@ -43,6 +43,7 @@ struct _vx_cvirt { atomic_t nr_onhold; /* processes on hold */ uint32_t onhold_last; /* jiffies when put on hold */ + struct timeval bias_tv; /* time offset to the host */ struct timespec bias_idle; struct timespec bias_uptime; /* context creation point */ uint64_t bias_clock; /* offset in clock_t */ diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/compat.c linux-2.6.16.17-vs2.1.1-rc21.2/kernel/compat.c --- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/compat.c 2006-02-18 14:40:37 +0100 +++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/compat.c 2006-05-29 16:58:56 +0200 @@ -841,7 +841,7 @@ asmlinkage long compat_sys_time(compat_t compat_time_t i; struct timeval tv; - do_gettimeofday(&tv); + vx_gettimeofday(&tv); i = tv.tv_sec; if (tloc) { @@ -865,7 +865,7 @@ asmlinkage long compat_sys_stime(compat_ if (err) return err; - do_settimeofday(&tv); + vx_settimeofday(&tv); return 0; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/time.c linux-2.6.16.17-vs2.1.1-rc21.2/kernel/time.c --- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/time.c 2006-02-18 14:40:38 +0100 +++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/time.c 2006-05-29 16:59:20 +0200 @@ -61,7 +61,7 @@ asmlinkage long sys_time(time_t __user * time_t i; struct timeval tv; - do_gettimeofday(&tv); + vx_gettimeofday(&tv); i = tv.tv_sec; if (tloc) { @@ -92,7 +92,7 @@ asmlinkage long sys_stime(time_t __user if (err) return err; - do_settimeofday(&tv); + vx_settimeofday(&tv); return 0; } @@ -102,7 +102,7 @@ asmlinkage long sys_gettimeofday(struct { if (likely(tv != NULL)) { struct timeval ktv; - do_gettimeofday(&ktv); + vx_gettimeofday(&ktv); if (copy_to_user(tv, &ktv, sizeof(ktv))) return -EFAULT; } @@ -176,7 +176,7 @@ int do_sys_settimeofday(struct timespec /* SMP safe, again the code in arch/foo/time.c should * globally block out interrupts when it runs. */ - return do_settimeofday(tv); + return vx_settimeofday(tv); } return 0; } @@ -558,7 +558,7 @@ void getnstimeofday(struct timespec *tv) { struct timeval x; - do_gettimeofday(&x); + vx_gettimeofday(&x); tv->tv_sec = x.tv_sec; tv->tv_nsec = x.tv_usec * NSEC_PER_USEC; } diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/Kconfig linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/Kconfig --- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/Kconfig 2006-05-11 21:00:03 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/Kconfig 2006-05-29 18:02:20 +0200 @@ -66,6 +66,16 @@ config VSERVER_COWBL when writing to them (which will implicitely break the link and create a copy of the unified file) +config VSERVER_VTIME + bool "Enable Virtualized Guest Time" + depends on EXPERIMENTAL + default n + help + This enables per guest time offsets to allow for + adjusting the system clock individually per guest. + this adds some overhead to the time functions and + therefore should not be enabled without good reason. + config VSERVER_PROC_SECURE bool "Enable Proc Security" depends on PROC_FS diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt.c linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt.c --- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt.c 2006-04-26 19:07:00 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt.c 2006-05-29 18:04:24 +0200 @@ -255,3 +255,43 @@ out_put: put_vx_info(vxi); return (name ? 0 : -EFAULT); } + +#ifdef CONFIG_VSERVER_VTIME + +/* virtualized time base */ + +void vx_gettimeofday(struct timeval *tv) +{ + do_gettimeofday(tv); + if (!vx_flags(VXF_VIRT_TIME, 0)) + return; + + tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec; + tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec; + + if (tv->tv_usec >= USEC_PER_SEC) { + tv->tv_sec++; + tv->tv_usec -= USEC_PER_SEC; + } else if (tv->tv_usec < 0) { + tv->tv_sec--; + tv->tv_usec += USEC_PER_SEC; + } +} + +int vx_settimeofday(struct timeval *tv) +{ + struct timeval tvs; + + if (!vx_flags(VXF_VIRT_TIME, 0)) + return do_settimeofday(tv); + + do_gettimeofday(&tvs); + current->vx_info->cvirt.bias_tv.tv_sec = + tv->tv_sec - tvs.tv_sec; + current->vx_info->cvirt.bias_tv.tv_usec = + tv->tv_usec - tvs.tv_usec; + return 0; +} + +#endif + diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt_init.h linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt_init.h --- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt_init.h 2006-04-26 19:07:00 +0200 +++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt_init.h 2006-05-29 17:38:33 +0200 @@ -11,6 +11,8 @@ static inline void vx_info_init_cvirt(st nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec; cvirt->bias_clock = nsec_to_clock_t(nsuptime); + cvirt->bias_tv.tv_sec = 0; + cvirt->bias_tv.tv_usec = 0; jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle); atomic_set(&cvirt->nr_threads, 0);