ia64/xen-unstable
changeset 11268:65042393b3e9
[IA64] pal_halt_light emulatefor domU
Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com>
Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com>
author | awilliam@xenbuild.aw |
---|---|
date | Thu Aug 24 11:48:35 2006 -0600 (2006-08-24) |
parents | c1261ca0d321 |
children | 1612675ca4cf |
files | xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/hypercall.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/vcpu.h |
line diff
1.1 --- a/xen/arch/ia64/xen/domain.c Thu Aug 24 11:42:24 2006 -0600 1.2 +++ b/xen/arch/ia64/xen/domain.c Thu Aug 24 11:48:35 2006 -0600 1.3 @@ -239,6 +239,12 @@ void startup_cpu_idle_loop(void) 1.4 # error "XMAPPEDREGS_SHIFT doesn't match sizeof(mapped_regs_t)." 1.5 #endif 1.6 1.7 +void hlt_timer_fn(void *data) 1.8 +{ 1.9 + struct vcpu *v = data; 1.10 + vcpu_unblock(v); 1.11 +} 1.12 + 1.13 struct vcpu *alloc_vcpu_struct(struct domain *d, unsigned int vcpu_id) 1.14 { 1.15 struct vcpu *v; 1.16 @@ -298,6 +304,9 @@ struct vcpu *alloc_vcpu_struct(struct do 1.17 v->arch.breakimm = d->arch.breakimm; 1.18 v->arch.last_processor = INVALID_PROCESSOR; 1.19 } 1.20 + if (!VMX_DOMAIN(v)){ 1.21 + init_timer(&v->arch.hlt_timer, hlt_timer_fn, v, v->processor); 1.22 + } 1.23 1.24 return v; 1.25 } 1.26 @@ -309,6 +318,7 @@ void relinquish_vcpu_resources(struct vc 1.27 get_order_from_shift(XMAPPEDREGS_SHIFT)); 1.28 v->arch.privregs = NULL; 1.29 } 1.30 + kill_timer(&v->arch.hlt_timer); 1.31 } 1.32 1.33 void free_vcpu_struct(struct vcpu *v)
2.1 --- a/xen/arch/ia64/xen/hypercall.c Thu Aug 24 11:42:24 2006 -0600 2.2 +++ b/xen/arch/ia64/xen/hypercall.c Thu Aug 24 11:48:35 2006 -0600 2.3 @@ -235,7 +235,12 @@ fw_hypercall (struct pt_regs *regs) 2.4 } 2.5 else { 2.6 perfc_incrc(pal_halt_light); 2.7 - do_sched_op_compat(SCHEDOP_yield, 0); 2.8 + migrate_timer(&v->arch.hlt_timer, 2.9 + v->processor); 2.10 + set_timer(&v->arch.hlt_timer, 2.11 + vcpu_get_next_timer_ns(v)); 2.12 + do_sched_op_compat(SCHEDOP_block, 0); 2.13 + stop_timer(&v->arch.hlt_timer); 2.14 } 2.15 regs->r8 = 0; 2.16 regs->r9 = 0;
3.1 --- a/xen/include/asm-ia64/domain.h Thu Aug 24 11:42:24 2006 -0600 3.2 +++ b/xen/include/asm-ia64/domain.h Thu Aug 24 11:48:35 2006 -0600 3.3 @@ -198,6 +198,7 @@ struct arch_vcpu { 3.4 unsigned long old_rsc; 3.5 int mode_flags; 3.6 fpswa_ret_t fpswa_ret; /* save return values of FPSWA emulation */ 3.7 + struct timer hlt_timer; 3.8 struct arch_vmx_struct arch_vmx; /* Virtual Machine Extensions */ 3.9 3.10 #define INVALID_PROCESSOR INT_MAX
4.1 --- a/xen/include/asm-ia64/vcpu.h Thu Aug 24 11:42:24 2006 -0600 4.2 +++ b/xen/include/asm-ia64/vcpu.h Thu Aug 24 11:48:35 2006 -0600 4.3 @@ -4,6 +4,7 @@ 4.4 // TODO: Many (or perhaps most) of these should eventually be 4.5 // static inline functions 4.6 4.7 +#include <asm/delay.h> 4.8 #include <asm/fpu.h> 4.9 #include <asm/tlb.h> 4.10 #include <asm/ia64_int.h> 4.11 @@ -15,6 +16,7 @@ typedef int BOOLEAN; 4.12 struct vcpu; 4.13 typedef struct vcpu VCPU; 4.14 typedef cpu_user_regs_t REGS; 4.15 +extern u64 cycle_to_ns(u64 cycle); 4.16 4.17 /* Note: PSCB stands for Privilegied State Communication Block. */ 4.18 #define VCPU(_v,_x) (_v->arch.privregs->_x) 4.19 @@ -183,6 +185,21 @@ itir_mask(UINT64 itir) 4.20 return (~((1UL << itir_ps(itir)) - 1)); 4.21 } 4.22 4.23 +static inline s64 4.24 +vcpu_get_next_timer_ns(VCPU *vcpu) 4.25 +{ 4.26 + s64 vcpu_get_next_timer_ns; 4.27 + u64 d = PSCBX(vcpu, domain_itm); 4.28 + u64 now = ia64_get_itc(); 4.29 + 4.30 + if (d > now) 4.31 + vcpu_get_next_timer_ns = cycle_to_ns(d - now) + NOW(); 4.32 + else 4.33 + vcpu_get_next_timer_ns = cycle_to_ns(local_cpu_data->itm_delta) + NOW(); 4.34 + 4.35 + return vcpu_get_next_timer_ns; 4.36 +} 4.37 + 4.38 #define verbose(a...) do {if (vcpu_verbose) printf(a);} while(0) 4.39 4.40 //#define vcpu_quick_region_check(_tr_regions,_ifa) 1