]> xenbits.xensource.com Git - people/pauldu/mini-os.git/commitdiff
mini-os: support idle for HVMlite
authorJuergen Gross <jgross@suse.com>
Tue, 23 Aug 2016 14:45:08 +0000 (16:45 +0200)
committerWei Liu <wei.liu2@citrix.com>
Wed, 24 Aug 2016 10:37:05 +0000 (11:37 +0100)
Instead of calling HYPERVISOR_sched_op(SCHEDOP_block, 0) we need to use
the "hlt" instruction with interrupts enabled to switch to idle when
running as HVMlite domain.

This requires to setup a new timer in the timer handler as there is no
guarantee the original timer event we are waiting for won't fire
between enabling interrupts and calling "hlt".

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
arch/x86/time.c

index af45e560db7f6d7a70bd0af460935c1ac4a87fdb..3658142baf5a4091fd9b130d19843da05f4aaa17 100644 (file)
@@ -212,17 +212,20 @@ void block_domain(s_time_t until)
     if(monotonic_clock() < until)
     {
         HYPERVISOR_set_timer_op(until);
+#ifdef CONFIG_PARAVIRT
         HYPERVISOR_sched_op(SCHEDOP_block, 0);
+#else
+        local_irq_enable();
+        asm volatile ( "hlt" : : : "memory" );
+#endif
         local_irq_disable();
+        HYPERVISOR_set_timer_op(0);
     }
 }
 
-
-/*
- * Just a dummy
- */
 static void timer_handler(evtchn_port_t ev, struct pt_regs *regs, void *ign)
 {
+    HYPERVISOR_set_timer_op(monotonic_clock() + MILLISECS(1));
 }