ia64/xen-unstable

changeset 10382:11f228aa783a

[IA64] do not use interrupt_mask_addr inside Xen

Create current_psr_i_addr per cpu variables.
Inside Xen, do not use interrupt_mask_addr because it can be modified by
the guest.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Thu Jun 15 08:42:34 2006 -0600 (2006-06-15)
parents d33add81096b
children 34bdc8d86f8d
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/hyperprivop.S xen/arch/ia64/xen/xensetup.c
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Wed Jun 14 16:05:45 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Thu Jun 15 08:42:34 2006 -0600
     1.3 @@ -89,6 +89,10 @@ unsigned long context_switch_count = 0;
     1.4  
     1.5  extern struct vcpu *ia64_switch_to (struct vcpu *next_task);
     1.6  
     1.7 +/* Address of vpsr.i (in fact evtchn_upcall_mask) of current vcpu.
     1.8 +   This is a Xen virtual address.  */
     1.9 +DEFINE_PER_CPU(uint8_t *, current_psr_i_addr);
    1.10 +
    1.11  #include <xen/sched-if.h>
    1.12  
    1.13  void schedule_tail(struct vcpu *prev)
    1.14 @@ -104,6 +108,8 @@ void schedule_tail(struct vcpu *prev)
    1.15  		        VHPT_ENABLED);
    1.16  		load_region_regs(current);
    1.17  		vcpu_load_kernel_regs(current);
    1.18 +		__ia64_per_cpu_var(current_psr_i_addr) = &current->domain->
    1.19 +		  shared_info->vcpu_info[current->vcpu_id].evtchn_upcall_mask;
    1.20  	}
    1.21  }
    1.22  
    1.23 @@ -124,12 +130,9 @@ void context_switch(struct vcpu *prev, s
    1.24      /*ia64_psr(ia64_task_regs(next))->dfh = !ia64_is_local_fpu_owner(next);*/
    1.25      prev = ia64_switch_to(next);
    1.26  
    1.27 -    //cpu_set(smp_processor_id(), current->domain->domain_dirty_cpumask);
    1.28 +    /* Note: ia64_switch_to does not return here at vcpu initialization.  */
    1.29  
    1.30 -    if (!VMX_DOMAIN(current)){
    1.31 -	    vcpu_set_next_timer(current);
    1.32 -    }
    1.33 -
    1.34 +    //cpu_set(smp_processor_id(), current->domain->domain_dirty_cpumask);
    1.35  
    1.36  // leave this debug for now: it acts as a heartbeat when more than
    1.37  // one domain is active
    1.38 @@ -140,26 +143,34 @@ int id = ((struct vcpu *)current)->domai
    1.39  if (!cnt[id]--) { cnt[id] = 500000; printk("%x",id); }
    1.40  if (!i--) { i = 1000000; printk("+"); }
    1.41  }
    1.42 -
    1.43 + 
    1.44      if (VMX_DOMAIN(current)){
    1.45 -		vmx_load_all_rr(current);
    1.46 -    }else{
    1.47 +	vmx_load_all_rr(current);
    1.48 +    } else {
    1.49 +	struct domain *nd;
    1.50      	extern char ia64_ivt;
    1.51 +
    1.52      	ia64_set_iva(&ia64_ivt);
    1.53 -    	if (!is_idle_domain(current->domain)) {
    1.54 +
    1.55 +	nd = current->domain;
    1.56 +    	if (!is_idle_domain(nd)) {
    1.57          	ia64_set_pta(VHPT_ADDR | (1 << 8) | (VHPT_SIZE_LOG2 << 2) |
    1.58  			     VHPT_ENABLED);
    1.59  	    	load_region_regs(current);
    1.60  	    	vcpu_load_kernel_regs(current);
    1.61 +		vcpu_set_next_timer(current);
    1.62  		if (vcpu_timer_expired(current))
    1.63  			vcpu_pend_timer(current);
    1.64 -    	}else {
    1.65 +		__ia64_per_cpu_var(current_psr_i_addr) = &nd->shared_info->
    1.66 +		  vcpu_info[current->vcpu_id].evtchn_upcall_mask;
    1.67 +    	} else {
    1.68  		/* When switching to idle domain, only need to disable vhpt
    1.69  		 * walker. Then all accesses happen within idle context will
    1.70  		 * be handled by TR mapping and identity mapping.
    1.71  		 */
    1.72  		pta = ia64_get_pta();
    1.73  		ia64_set_pta(pta & ~VHPT_ENABLED);
    1.74 +		__ia64_per_cpu_var(current_psr_i_addr) = NULL;
    1.75          }
    1.76      }
    1.77      local_irq_restore(spsr);
     2.1 --- a/xen/arch/ia64/xen/hyperprivop.S	Wed Jun 14 16:05:45 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/hyperprivop.S	Thu Jun 15 08:42:34 2006 -0600
     2.3 @@ -107,9 +107,9 @@ GLOBAL_ENTRY(fast_hyperprivop)
     2.4  	or r20=r23,r21;;
     2.5  1:	// when we get to here r20=~=interrupts pending
     2.6  	// Check pending event indication
     2.7 -(p7)	adds r20=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18;;
     2.8 +(p7)	movl r20=THIS_CPU(current_psr_i_addr);;
     2.9  (p7)	ld8 r20=[r20];;
    2.10 -(p7)	adds r20=-1,r20;;
    2.11 +(p7)	adds r20=-1,r20;;	/* evtchn_upcall_pending */
    2.12  (p7)	ld1 r20=[r20];;
    2.13  
    2.14  	// HYPERPRIVOP_RFI?
    2.15 @@ -276,14 +276,14 @@ ENTRY(hyper_ssm_i)
    2.16  	or r30=r30,r28;;
    2.17  	and r30=r30,r27;;
    2.18  	mov r20=1
    2.19 -	adds r22=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18
    2.20 +	movl r22=THIS_CPU(current_psr_i_addr)
    2.21  	adds r21=XSI_IPSR_OFS-XSI_PSR_IC_OFS,r18 ;;
    2.22  	ld8 r22=[r22]
    2.23 -	st8 [r21]=r30 ;;
    2.24 +	st8 [r21]=r30;;
    2.25  	// set shared_mem interrupt_delivery_enabled to 0
    2.26  	// set shared_mem interrupt_collection_enabled to 0
    2.27 -	st1 [r22]=r20;;
    2.28 -	st4 [r18]=r0;;
    2.29 +	st1 [r22]=r20
    2.30 +	st4 [r18]=r0
    2.31  	// cover and set shared_mem precover_ifs to cr.ifs
    2.32  	// set shared_mem ifs and incomplete_regframe to 0
    2.33  	cover ;;
    2.34 @@ -407,7 +407,7 @@ GLOBAL_ENTRY(fast_tick_reflect)
    2.35  	cmp.eq p6,p0=r16,r0;;
    2.36  (p6)	br.cond.spnt.few fast_tick_reflect_done;;
    2.37  	// if guest vpsr.i is off, we're done
    2.38 -	adds r21=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18 ;;
    2.39 +	movl r21=THIS_CPU(current_psr_i_addr);;
    2.40  	ld8 r21=[r21];;
    2.41  	ld1 r21=[r21];;
    2.42  	cmp.eq p0,p6=r21,r0
    2.43 @@ -448,17 +448,16 @@ GLOBAL_ENTRY(fast_tick_reflect)
    2.44  	dep r21=-1,r21,IA64_PSR_CPL1_BIT,1 ;;
    2.45  	or r17=r17,r28;;
    2.46  	and r17=r17,r27;;
    2.47 -	ld4 r16=[r18],XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS;;
    2.48 +	ld4 r16=[r18];;
    2.49  	cmp.ne p6,p0=r16,r0;;
    2.50 -	ld8 r16=[r18],XSI_PSR_IC_OFS-XSI_PSR_I_ADDR_OFS
    2.51 +	movl r22=THIS_CPU(current_psr_i_addr);;
    2.52 +	ld8 r22=[r22]
    2.53  (p6)	dep r17=-1,r17,IA64_PSR_IC_BIT,1 ;;
    2.54 -	ld1 r16=[r16];;
    2.55 +	ld1 r16=[r22];;
    2.56  	cmp.eq p6,p0=r16,r0;;
    2.57  (p6)	dep r17=-1,r17,IA64_PSR_I_BIT,1 ;;
    2.58  	mov r20=1
    2.59 -	adds r22=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18
    2.60  	adds r21=XSI_IPSR_OFS-XSI_PSR_IC_OFS,r18 ;;
    2.61 -	ld8 r22=[r22]
    2.62  	st8 [r21]=r17 ;;
    2.63  	// set shared_mem interrupt_delivery_enabled to 0
    2.64  	// set shared_mem interrupt_collection_enabled to 0
    2.65 @@ -606,7 +605,7 @@ ENTRY(fast_reflect)
    2.66  	// set shared_mem isr
    2.67  	st8 [r21]=r16 ;;
    2.68  	// set cr.ipsr
    2.69 -	adds r21=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18
    2.70 +	movl r21=THIS_CPU(current_psr_i_addr)
    2.71  	mov r29=r30 ;;
    2.72  	ld8 r21=[r21]
    2.73  	movl r28=DELIVER_PSR_SET;;
    2.74 @@ -1077,7 +1076,7 @@ just_do_rfi:
    2.75  	dep r20=0,r20,38,25;; // ensure ifs has no reserved bits set
    2.76  	mov cr.ifs=r20 ;;
    2.77  	// ipsr.cpl == (vcr.ipsr.cpl == 0) 2 : 3;
    2.78 -	adds r20=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18
    2.79 +	movl r20=THIS_CPU(current_psr_i_addr)
    2.80  	dep r21=-1,r21,IA64_PSR_CPL1_BIT,1 ;;
    2.81  	// vpsr.i = vcr.ipsr.i; vpsr.ic = vcr.ipsr.ic
    2.82  	ld8 r20=[r20]
    2.83 @@ -1229,13 +1228,14 @@ ENTRY(rfi_with_interrupt)
    2.84  	extr.u r20=r21,41,2 ;;	// get v(!)psr.ri
    2.85  	dep r16=r20,r16,41,2 ;; // deposit cr.isr.ei
    2.86  	adds r22=XSI_ISR_OFS-XSI_PSR_IC_OFS,r18 ;; 
    2.87 -	st8 [r22]=r16,XSI_PSR_I_ADDR_OFS-XSI_ISR_OFS ;;
    2.88 +	st8 [r22]=r16;;
    2.89 +	movl r22=THIS_CPU(current_psr_i_addr)
    2.90  	// set cr.ipsr (make sure cpl==2!)
    2.91 -	mov r29=r17 ;;
    2.92 +	mov r29=r17
    2.93  	movl r28=DELIVER_PSR_SET;;
    2.94 -	mov r20=1
    2.95 +	mov r20=1;;
    2.96  	ld8 r22=[r22]
    2.97 -	movl r27=~(DELIVER_PSR_CLR|IA64_PSR_CPL0);;
    2.98 +	movl r27=~(DELIVER_PSR_CLR|IA64_PSR_CPL0)
    2.99  	or r29=r29,r28;;
   2.100  	and r29=r29,r27;;
   2.101  	mov cr.ipsr=r29;;
     3.1 --- a/xen/arch/ia64/xen/xensetup.c	Wed Jun 14 16:05:45 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/xensetup.c	Thu Jun 15 08:42:34 2006 -0600
     3.3 @@ -521,7 +521,7 @@ printk("About to call init_trace_bufs()\
     3.4      local_irq_enable();
     3.5  
     3.6      printf("About to call schedulers_start dom0=%p, idle_dom=%p\n",
     3.7 -	   dom0, &idle_domain);
     3.8 +	   dom0, idle_domain);
     3.9      schedulers_start();
    3.10  
    3.11      domain_unpause_by_systemcontroller(dom0);