ia64/xen-unstable

changeset 16759:2d0193702170

[IA64] vti fault handler clean up: fix vmx_break_fault and vmx_ia64_handle_break

vmx_break_fault and vmx_ia64_handle_break() should check cr.ipsr.vm bit
so that they can handle break fault in xen.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Fri Dec 14 13:44:06 2007 -0700 (2007-12-14)
parents 5ab3288e5b0f
children 38c73bd5e02d
files xen/arch/ia64/vmx/vmx_fault.c xen/arch/ia64/vmx/vmx_ivt.S xen/arch/ia64/xen/xenmisc.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/vmx.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmx_fault.c	Fri Dec 14 13:40:29 2007 -0700
     1.2 +++ b/xen/arch/ia64/vmx/vmx_fault.c	Fri Dec 14 13:44:06 2007 -0700
     1.3 @@ -56,7 +56,6 @@
     1.4  #define INITIAL_PSR_VALUE_AT_INTERRUPTION 0x0000001808028034
     1.5  
     1.6  
     1.7 -extern void die_if_kernel(char *str, struct pt_regs *regs, long err);
     1.8  extern void rnat_consumption (VCPU *vcpu);
     1.9  extern void alt_itlb (VCPU *vcpu, u64 vadr);
    1.10  extern void itlb_fault (VCPU *vcpu, u64 vadr);
    1.11 @@ -177,7 +176,7 @@ vmx_ia64_handle_break (unsigned long ifa
    1.12  
    1.13      perfc_incr(vmx_ia64_handle_break);
    1.14  #ifdef CRASH_DEBUG
    1.15 -    if ((iim == 0 || iim == CDB_BREAK_NUM) && !guest_mode(regs) &&
    1.16 +    if ((iim == 0 || iim == CDB_BREAK_NUM) && !vmx_user_mode(regs) &&
    1.17          IS_VMM_ADDRESS(regs->cr_iip)) {
    1.18          if (iim == 0)
    1.19              show_registers(regs);
    1.20 @@ -185,17 +184,20 @@ vmx_ia64_handle_break (unsigned long ifa
    1.21      } else
    1.22  #endif
    1.23      {
    1.24 -        if (iim == 0) 
    1.25 -            vmx_die_if_kernel("Break 0 in Hypervisor.", regs, iim);
    1.26 +        if (!vmx_user_mode(regs)) {
    1.27 +            show_registers(regs);
    1.28 +            gdprintk(XENLOG_DEBUG, "%s:%d imm %lx\n", __func__, __LINE__, iim);
    1.29 +            ia64_fault(11 /* break fault */, isr, ifa, iim,
    1.30 +                       0 /* cr.itir */, 0, 0, 0, (unsigned long)regs);
    1.31 +        }
    1.32  
    1.33          if (ia64_psr(regs)->cpl == 0) {
    1.34              /* Allow hypercalls only when cpl = 0.  */
    1.35 -            if (iim == d->arch.breakimm) {
    1.36 -                ia64_hypercall(regs);
    1.37 -                vcpu_increment_iip(v);
    1.38 -                return IA64_NO_FAULT;
    1.39 -            }
    1.40 -            else if (iim == DOMN_PAL_REQUEST) {
    1.41 +
    1.42 +            /* normal hypercalls are handled by vmx_break_fault */
    1.43 +            BUG_ON(iim == d->arch.breakimm);
    1.44 +
    1.45 +            if (iim == DOMN_PAL_REQUEST) {
    1.46                  pal_emul(v);
    1.47                  vcpu_increment_iip(v);
    1.48                  return IA64_NO_FAULT;
     2.1 --- a/xen/arch/ia64/vmx/vmx_ivt.S	Fri Dec 14 13:40:29 2007 -0700
     2.2 +++ b/xen/arch/ia64/vmx/vmx_ivt.S	Fri Dec 14 13:44:06 2007 -0700
     2.3 @@ -461,14 +461,10 @@ ENTRY(vmx_break_fault)
     2.4      mov r31=pr
     2.5      mov r19=11
     2.6      mov r17=cr.iim
     2.7 +    mov r29=cr.ipsr
     2.8      ;;
     2.9 -#ifdef VTI_DEBUG
    2.10 -    // break 0 is already handled in vmx_ia64_handle_break.
    2.11 -    cmp.eq p6,p7=r17,r0
    2.12 -    (p6) br.sptk vmx_fault_11
    2.13 -    ;;
    2.14 -#endif
    2.15 -    mov r29=cr.ipsr
    2.16 +    tbit.z p6,p0=r29,IA64_PSR_VM_BIT
    2.17 +(p6)br.sptk.many vmx_dispatch_break_fault /* make sure before access [r21] */
    2.18      adds r22=IA64_VCPU_BREAKIMM_OFFSET, r21
    2.19      ;;
    2.20      ld4 r22=[r22]
    2.21 @@ -1426,7 +1422,7 @@ ENTRY(vmx_dispatch_tlb_miss)
    2.22  END(vmx_dispatch_tlb_miss)
    2.23  
    2.24  ENTRY(vmx_dispatch_break_fault)
    2.25 -    VMX_SAVE_MIN_WITH_COVER
    2.26 +    VMX_SAVE_MIN_WITH_COVER_NO_PANIC
    2.27      ;;
    2.28      alloc r14=ar.pfs,0,0,4,0 // now it's safe (must be first in insn group!)
    2.29      mov out0=cr.ifa
    2.30 @@ -1439,12 +1435,12 @@ ENTRY(vmx_dispatch_break_fault)
    2.31      srlz.i                  // guarantee that interruption collection is on
    2.32      ;;
    2.33      (p15)ssm psr.i               // restore psr.i
    2.34 -    movl r14=ia64_leave_hypervisor
    2.35 +(pUStk)movl r14=ia64_leave_hypervisor
    2.36      ;;
    2.37 +(pKStk)movl r14=ia64_leave_nested
    2.38      VMX_SAVE_REST
    2.39      mov rp=r14
    2.40      ;;
    2.41 -    P6_BR_CALL_PANIC(.Lvmx_dispatch_break_fault_string)
    2.42      adds out1=16,sp
    2.43      br.call.sptk.many b6=vmx_ia64_handle_break
    2.44      ;;
    2.45 @@ -1478,5 +1474,3 @@ END(vmx_dispatch_interrupt)
    2.46      .asciz "vmx_dispatch_vexirq\n"
    2.47  .Lvmx_dispatch_tlb_miss_string:
    2.48      .asciz "vmx_dispatch_tlb_miss\n"
    2.49 -.Lvmx_dispatch_break_fault_string:
    2.50 -    .asciz "vmx_dispatch_break_fault\n"
     3.1 --- a/xen/arch/ia64/xen/xenmisc.c	Fri Dec 14 13:40:29 2007 -0700
     3.2 +++ b/xen/arch/ia64/xen/xenmisc.c	Fri Dec 14 13:44:06 2007 -0700
     3.3 @@ -69,17 +69,6 @@ void die_if_kernel(char *str, struct pt_
     3.4  	domain_crash_synchronous();
     3.5  }
     3.6  
     3.7 -void vmx_die_if_kernel(char *str, struct pt_regs *regs, long err)
     3.8 -{
     3.9 -	if (vmx_user_mode(regs))
    3.10 -		return;
    3.11 -
    3.12 -	printk("%s: %s %ld\n", __func__, str, err);
    3.13 -	debugtrace_dump();
    3.14 -	show_registers(regs);
    3.15 -	domain_crash_synchronous();
    3.16 -}
    3.17 -
    3.18  long
    3.19  ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
    3.20  	   unsigned long user_rbs_end, unsigned long addr, long *val)
     4.1 --- a/xen/include/asm-ia64/domain.h	Fri Dec 14 13:40:29 2007 -0700
     4.2 +++ b/xen/include/asm-ia64/domain.h	Fri Dec 14 13:44:06 2007 -0700
     4.3 @@ -306,6 +306,11 @@ int
     4.4  do_perfmon_op(unsigned long cmd,
     4.5                XEN_GUEST_HANDLE(void) arg1, unsigned long arg2);
     4.6  
     4.7 +void
     4.8 +ia64_fault(unsigned long vector, unsigned long isr, unsigned long ifa,
     4.9 +           unsigned long iim, unsigned long itir, unsigned long arg5,
    4.10 +           unsigned long arg6, unsigned long arg7, unsigned long stack);
    4.11 +
    4.12  #endif /* __ASM_DOMAIN_H__ */
    4.13  
    4.14  /*
     5.1 --- a/xen/include/asm-ia64/vmx.h	Fri Dec 14 13:40:29 2007 -0700
     5.2 +++ b/xen/include/asm-ia64/vmx.h	Fri Dec 14 13:44:06 2007 -0700
     5.3 @@ -52,7 +52,6 @@ extern void set_rsv_reg_field_isr (struc
     5.4  extern void rsv_reg_field (struct vcpu *vcpu);
     5.5  extern void vmx_relinquish_guest_resources(struct domain *d);
     5.6  extern void vmx_relinquish_vcpu_resources(struct vcpu *v);
     5.7 -extern void vmx_die_if_kernel(char *str, struct pt_regs *regs, long err);
     5.8  extern void vmx_send_assist_req(struct vcpu *v);
     5.9  extern void deliver_pal_init(struct vcpu *vcpu);
    5.10  extern void vmx_pend_pal_init(struct domain *d);