From: Rusty Russell In recent -mm kernels, the TSC capability cannot be disabled, resulting in a divide by zero error in the normal sched_clock. The correct fix is to have a special lguest sched_clock implementation: this is as simple as it gets. Signed-off-by: Rusty Russell Signed-off-by: Andrew Morton --- drivers/lguest/lguest.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff -puN drivers/lguest/lguest.c~lguest-the-guest-code-tsc-fix drivers/lguest/lguest.c --- a/drivers/lguest/lguest.c~lguest-the-guest-code-tsc-fix +++ a/drivers/lguest/lguest.c @@ -352,13 +352,20 @@ static void lguest_time_irq(unsigned int update_process_times(user_mode_vm(get_irq_regs())); } +static u64 sched_clock_base; static void lguest_time_init(void) { set_irq_handler(0, lguest_time_irq); hcall(LHCALL_TIMER_READ, 0, 0, 0); + sched_clock_base = jiffies_64; enable_lguest_irq(0); } +static unsigned long long lguest_sched_clock(void) +{ + return (jiffies_64 - sched_clock_base) * (1000000000 / HZ); +} + static void lguest_load_esp0(struct tss_struct *tss, struct thread_struct *thread) { @@ -491,6 +498,7 @@ __init void lguest_init(void) paravirt_ops.time_init = lguest_time_init; paravirt_ops.set_lazy_mode = lguest_lazy_mode; paravirt_ops.wbinvd = lguest_wbinvd; + paravirt_ops.sched_clock = lguest_sched_clock; hcall(LHCALL_LGUEST_INIT, __pa(&lguest_data), 0, 0); strncpy(boot_command_line, boot->cmdline, COMMAND_LINE_SIZE); @@ -506,8 +514,6 @@ __init void lguest_init(void) /* Math is always hard! */ new_cpu_data.hard_math = 1; - tsc_disable = 1; - #ifdef CONFIG_X86_MCE mce_disabled = 1; #endif _