ia64/xen-unstable

changeset 10685:8ad37880564d

[IA64] emulate PAL_HALT_LIGHT on domU

This patch emulates Guest PAL_HALT_LIGHT on domU by using do_block and timer.
It also adds the function of the timer interrupt to domU at the vcpu woke up.

Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com>
[warning fixes and static inlining]
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild.aw
date Mon Jul 10 13:12:41 2006 -0600 (2006-07-10)
parents a1482fd74530
children e5c7350b8cbb
files xen/arch/ia64/vmx/vlsapic.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/hypercall.c xen/arch/ia64/xen/xentime.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/time.h xen/include/asm-ia64/vcpu.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vlsapic.c	Sun Jul 09 22:50:43 2006 -0600
     1.2 +++ b/xen/arch/ia64/vmx/vlsapic.c	Mon Jul 10 13:12:41 2006 -0600
     1.3 @@ -165,8 +165,6 @@ void vtm_set_itc(VCPU *vcpu, uint64_t ne
     1.4  
     1.5  
     1.6  #define TIMER_SLOP (50*1000) /* ns */  /* copy from timer.c */
     1.7 -extern u64 cycle_to_ns(u64 cyle);
     1.8 -
     1.9  
    1.10  void vtm_set_itm(VCPU *vcpu, uint64_t val)
    1.11  {
     2.1 --- a/xen/arch/ia64/xen/domain.c	Sun Jul 09 22:50:43 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Mon Jul 10 13:12:41 2006 -0600
     2.3 @@ -248,6 +248,14 @@ void startup_cpu_idle_loop(void)
     2.4  	continue_cpu_idle_loop();
     2.5  }
     2.6  
     2.7 +void hlt_timer_fn(void *data)
     2.8 +{
     2.9 +	struct vcpu *v = data;
    2.10 +	if (vcpu_timer_expired(v))
    2.11 +		vcpu_pend_timer(v);
    2.12 +	vcpu_unblock(v);   
    2.13 +}
    2.14 +
    2.15  struct vcpu *alloc_vcpu_struct(struct domain *d, unsigned int vcpu_id)
    2.16  {
    2.17  	struct vcpu *v;
    2.18 @@ -303,6 +311,8 @@ struct vcpu *alloc_vcpu_struct(struct do
    2.19  	    v->arch.breakimm = d->arch.breakimm;
    2.20  	    v->arch.last_processor = INVALID_PROCESSOR;
    2.21  	}
    2.22 +	if (!VMX_DOMAIN(v))
    2.23 +		init_timer(&v->arch.hlt_timer, hlt_timer_fn, v, v->processor);
    2.24  
    2.25  	return v;
    2.26  }
    2.27 @@ -315,6 +325,7 @@ void free_vcpu_struct(struct vcpu *v)
    2.28  		if (v->arch.privregs != NULL)
    2.29  			free_xenheap_pages(v->arch.privregs,
    2.30  			              get_order_from_shift(XMAPPEDREGS_SHIFT));
    2.31 +		kill_timer(&v->arch.hlt_timer);
    2.32  	}
    2.33  
    2.34  	free_xenheap_pages(v, KERNEL_STACK_SIZE_ORDER);
     3.1 --- a/xen/arch/ia64/xen/hypercall.c	Sun Jul 09 22:50:43 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/hypercall.c	Mon Jul 10 13:12:41 2006 -0600
     3.3 @@ -220,7 +220,9 @@ fw_hypercall (struct pt_regs *regs)
     3.4  			}
     3.5  			else {
     3.6  				pal_halt_light_count++;
     3.7 -				do_sched_op_compat(SCHEDOP_yield, 0);
     3.8 +				set_timer(&v->arch.hlt_timer,
     3.9 +				          vcpu_get_next_timer_ns(v));
    3.10 +				do_sched_op_compat(SCHEDOP_block, 0);
    3.11  			}
    3.12  			regs->r8 = 0;
    3.13  			regs->r9 = 0;
     4.1 --- a/xen/arch/ia64/xen/xentime.c	Sun Jul 09 22:50:43 2006 -0600
     4.2 +++ b/xen/arch/ia64/xen/xentime.c	Mon Jul 10 13:12:41 2006 -0600
     4.3 @@ -42,20 +42,6 @@ static s_time_t        stime_irq = 0x0; 
     4.4  unsigned long itc_scale, ns_scale;
     4.5  unsigned long itc_at_irq;
     4.6  
     4.7 -/* We don't expect an absolute cycle value here, since then no way
     4.8 - * to prevent overflow for large norminator. Normally this conversion
     4.9 - * is used for relative offset.
    4.10 - */
    4.11 -u64 cycle_to_ns(u64 cycle)
    4.12 -{
    4.13 -    return (cycle * itc_scale) >> 32;
    4.14 -}
    4.15 -
    4.16 -u64 ns_to_cycle(u64 ns)
    4.17 -{
    4.18 -    return (ns * ns_scale) >> 32;
    4.19 -}
    4.20 -
    4.21  static inline u64 get_time_delta(void)
    4.22  {
    4.23      s64      delta_itc;
     5.1 --- a/xen/include/asm-ia64/domain.h	Sun Jul 09 22:50:43 2006 -0600
     5.2 +++ b/xen/include/asm-ia64/domain.h	Mon Jul 10 13:12:41 2006 -0600
     5.3 @@ -170,6 +170,7 @@ struct arch_vcpu {
     5.4      unsigned long old_rsc;
     5.5      int mode_flags;
     5.6      fpswa_ret_t fpswa_ret;	/* save return values of FPSWA emulation */
     5.7 +    struct timer hlt_timer;
     5.8      struct arch_vmx_struct arch_vmx; /* Virtual Machine Extensions */
     5.9  
    5.10  #define INVALID_PROCESSOR       INT_MAX
     6.1 --- a/xen/include/asm-ia64/time.h	Sun Jul 09 22:50:43 2006 -0600
     6.2 +++ b/xen/include/asm-ia64/time.h	Mon Jul 10 13:12:41 2006 -0600
     6.3 @@ -1,2 +1,26 @@
     6.4 +#ifndef _XEN_IA64_TIME_H
     6.5 +#define _XEN_IA64_TIME_H
     6.6 +
     6.7  #include <asm/linux/time.h>
     6.8  #include <asm/timex.h>
     6.9 +
    6.10 +extern unsigned long itc_scale;
    6.11 +extern unsigned long ns_scale;
    6.12 +
    6.13 +/* We don't expect an absolute cycle value here, since then no way
    6.14 + * to prevent overflow for large norminator. Normally this conversion
    6.15 + * is used for relative offset.
    6.16 + */
    6.17 +static inline u64
    6.18 +cycle_to_ns(u64 cycle)
    6.19 +{
    6.20 +    return (cycle * itc_scale) >> 32;
    6.21 +}
    6.22 +
    6.23 +static inline u64
    6.24 +ns_to_cycle(u64 ns)
    6.25 +{
    6.26 +    return (ns * ns_scale) >> 32;
    6.27 +}
    6.28 +
    6.29 +#endif /* _XEN_IA64_TIME_H */
     7.1 --- a/xen/include/asm-ia64/vcpu.h	Sun Jul 09 22:50:43 2006 -0600
     7.2 +++ b/xen/include/asm-ia64/vcpu.h	Mon Jul 10 13:12:41 2006 -0600
     7.3 @@ -4,9 +4,11 @@
     7.4  // TODO: Many (or perhaps most) of these should eventually be
     7.5  // static inline functions
     7.6  
     7.7 +#include <asm/delay.h>
     7.8  #include <asm/fpu.h>
     7.9  #include <asm/tlb.h>
    7.10  #include <asm/ia64_int.h>
    7.11 +#include <asm/time.h>
    7.12  #include <public/arch-ia64.h>
    7.13  typedef	unsigned long UINT64;
    7.14  typedef	unsigned int UINT;
    7.15 @@ -177,6 +179,12 @@ itir_mask(UINT64 itir)
    7.16      return (~((1UL << itir_ps(itir)) - 1));
    7.17  }
    7.18  
    7.19 +static inline u64
    7.20 +vcpu_get_next_timer_ns(VCPU *vcpu)
    7.21 +{
    7.22 +    return cycle_to_ns(PSCBX(vcpu, domain_itm) - ia64_get_itc()) + NOW();
    7.23 +}
    7.24 +
    7.25  #define verbose(a...) do {if (vcpu_verbose) printf(a);} while(0)
    7.26  
    7.27  //#define vcpu_quick_region_check(_tr_regions,_ifa) 1