ia64/xen-unstable

changeset 16756:fa80218de06a

[IA64] vti fault handler clean up: make VMX_DO_SAVE_MIN aware of fault in xen

Current VMX_DO_SAVE_MIN is simplified from DO_SAVE_MIN assuming
that the faults are in VTi guest. Discard the assumption and make
code more generic. Make it able to handle faults in both guest and xen.
Set pKStk and pUStk in VMX_DO_SAVE_MIN and use them to get the correct
place to save registers so that don't overwrite guest mode register
in vmx fault handler.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Fri Dec 14 13:33:01 2007 -0700 (2007-12-14)
parents 8cb29f1083ac
children 9ab95900afec
files xen/arch/ia64/vmx/vmx_minstate.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmx_minstate.h	Fri Dec 14 13:29:42 2007 -0700
     1.2 +++ b/xen/arch/ia64/vmx/vmx_minstate.h	Fri Dec 14 13:33:01 2007 -0700
     1.3 @@ -35,19 +35,21 @@
     1.4  #include "entry.h"
     1.5  
     1.6  #define VMX_MINSTATE_START_SAVE_MIN                                                             \
     1.7 -    mov ar.rsc=0;       /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */             \
     1.8 -    ;;                                                                                          \
     1.9 -    mov.m r28=ar.rnat;                                                                          \
    1.10 -    addl r22=IA64_RBS_OFFSET,r1;                        /* compute base of RBS */               \
    1.11 -    ;;                                                                                          \
    1.12 -    lfetch.fault.excl.nt1 [r22];                                                                \
    1.13 -    addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r1;       /* compute base of memory stack */      \
    1.14 -    mov r23=ar.bspstore;                                /* save ar.bspstore */                  \
    1.15 -    ;;                                                                                          \
    1.16 -    mov ar.bspstore=r22;                                /* switch to kernel RBS */              \
    1.17 -    ;;                                                                                          \
    1.18 -    mov r18=ar.bsp;                                                                             \
    1.19 -    mov ar.rsc=0x3;     /* set eager mode, pl 0, little-endian, loadrs=0 */
    1.20 +(pUStk) mov ar.rsc=0;           /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */     \
    1.21 +        ;;                                                                                      \
    1.22 +(pUStk) mov.m r28=ar.rnat;                                                                      \
    1.23 +(pUStk) addl r22=IA64_RBS_OFFSET,r1;                    /* compute base of RBS */               \
    1.24 +(pKStk) mov r1=sp;                                      /* get sp  */                           \
    1.25 +        ;;                                                                                      \
    1.26 +(pUStk) lfetch.fault.excl.nt1 [r22];                                                            \
    1.27 +(pUStk) addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r1;   /* compute base of memory stack */      \
    1.28 +(pUStk) mov r23=ar.bspstore;                            /* save ar.bspstore */                  \
    1.29 +        ;;                                                                                      \
    1.30 +(pUStk) mov ar.bspstore=r22;                            /* switch to kernel RBS */              \
    1.31 +(pKStk) addl r1=-IA64_PT_REGS_SIZE,r1;                  /* if in kernel mode, use sp (r12) */   \
    1.32 +        ;;                                                                                      \
    1.33 +(pUStk) mov r18=ar.bsp;                                                                         \
    1.34 +(pUStk) mov ar.rsc=0x3;         /* set eager mode, pl 0, little-endian, loadrs=0 */
    1.35  
    1.36  #define VMX_MINSTATE_END_SAVE_MIN                                                               \
    1.37      bsw.1;              /* switch back to bank 1 (must be last in insn group) */                \
    1.38 @@ -55,24 +57,24 @@
    1.39  
    1.40  #define PAL_VSA_SYNC_READ                               \
    1.41      /* begin to call pal vps sync_read */               \
    1.42 -    add r25=IA64_VPD_BASE_OFFSET, r21;                  \
    1.43 -    movl r20=__vsa_base;                                \
    1.44 +(pUStk) add r25=IA64_VPD_BASE_OFFSET, r21;              \
    1.45 +(pUStk) movl r20=__vsa_base;                            \
    1.46      ;;                                                  \
    1.47 -    ld8 r25=[r25];              /* read vpd base */     \
    1.48 -    ld8 r20=[r20];              /* read entry point */  \
    1.49 +(pUStk) ld8 r25=[r25];          /* read vpd base */     \
    1.50 +(pUStk) ld8 r20=[r20];          /* read entry point */  \
    1.51      ;;                                                  \
    1.52 -    add r20=PAL_VPS_SYNC_READ,r20;                      \
    1.53 +(pUStk) add r20=PAL_VPS_SYNC_READ,r20;                  \
    1.54      ;;                                                  \
    1.55  { .mii;                                                 \
    1.56 -    nop 0x0;                                            \
    1.57 -    mov r24=ip;                                         \
    1.58 -    mov b0=r20;                                         \
    1.59 +(pUStk) nop 0x0;                                        \
    1.60 +(pUStk) mov r24=ip;                                     \
    1.61 +(pUStk) mov b0=r20;                                     \
    1.62      ;;                                                  \
    1.63  };                                                      \
    1.64  { .mmb;                                                 \
    1.65 -    add r24 = 0x20, r24;                                \
    1.66 -    nop 0x0;                                            \
    1.67 -    br.cond.sptk b0;        /*  call the service */     \
    1.68 +(pUStk) add r24 = 0x20, r24;                            \
    1.69 +(pUStk) nop 0x0;                                        \
    1.70 +(pUStk) br.cond.sptk b0;        /*  call the service */ \
    1.71      ;;                                                  \
    1.72  };
    1.73  
    1.74 @@ -115,13 +117,14 @@
    1.75      mov r18=cr.isr;                                                                     \
    1.76      COVER;                              /* B;; (or nothing) */                          \
    1.77      ;;                                                                                  \
    1.78 -    tbit.z p6,p0=r29,IA64_PSR_VM_BIT;                                                   \
    1.79 +    cmp.eq p6,p0=r0,r0;                                                                 \
    1.80 +    tbit.z pKStk,pUStk=r29,IA64_PSR_VM_BIT;                                             \
    1.81 +    tbit.z p0,p15=r29,IA64_PSR_I_BIT;                                                   \
    1.82      ;;                                                                                  \
    1.83 -    tbit.nz.or p6,p0 = r18,IA64_ISR_NI_BIT;                                             \
    1.84 +(pUStk) tbit.nz.and p6,p0=r18,IA64_ISR_NI_BIT;                                          \
    1.85      ;;                                                                                  \
    1.86  (p6)br.spnt.few vmx_panic;                                                              \
    1.87 -    tbit.z p0,p15=r29,IA64_PSR_I_BIT;                                                   \
    1.88 -    VMX_MINSTATE_GET_CURRENT(r1);      /* M (or M;;I) */                                \
    1.89 +(pUStk)VMX_MINSTATE_GET_CURRENT(r1);                                                    \
    1.90      /*    mov r21=r16;  */                                                              \
    1.91      /* switch from user to kernel RBS: */                                               \
    1.92      ;;                                                                                  \
    1.93 @@ -140,6 +143,7 @@
    1.94      ;;                                                                                  \
    1.95      adds r16=PT(R8),r1; /* initialize first base pointer */                             \
    1.96      adds r17=PT(R9),r1; /* initialize second base pointer */                            \
    1.97 +(pKStk) mov r18=r0;     /* make sure r18 isn't NaT */                                   \
    1.98      ;;                                                                                  \
    1.99  .mem.offset 0,0; st8.spill [r16]=r8,16;                                                 \
   1.100  .mem.offset 8,0; st8.spill [r17]=r9,16;                                                 \
   1.101 @@ -152,17 +156,19 @@
   1.102      ;;                                                                                  \
   1.103      st8 [r16]=r9,16;    /* save cr.iip */                                               \
   1.104      st8 [r17]=r30,16;   /* save cr.ifs */                                               \
   1.105 -    sub r18=r18,r22;    /* r18=RSE.ndirty*8 */                                          \
   1.106 +(pUStk) sub r18=r18,r22;/* r18=RSE.ndirty*8 */                                          \
   1.107      ;;                                                                                  \
   1.108      st8 [r16]=r25,16;   /* save ar.unat */                                              \
   1.109      st8 [r17]=r26,16;    /* save ar.pfs */                                              \
   1.110      shl r18=r18,16;     /* compute ar.rsc to be used for "loadrs" */                    \
   1.111      ;;                                                                                  \
   1.112      st8 [r16]=r27,16;   /* save ar.rsc */                                               \
   1.113 -    st8 [r17]=r28,16;   /* save ar.rnat */                                              \
   1.114 +(pUStk) st8 [r17]=r28,16;/* save ar.rnat */                                             \
   1.115 +(pKStk) adds r17=16,r17;/* skip over ar_rnat field */                                   \
   1.116      ;;                  /* avoid RAW on r16 & r17 */                                    \
   1.117 -    st8 [r16]=r23,16;   /* save ar.bspstore */                                          \
   1.118 +(pUStk) st8 [r16]=r23,16;   /* save ar.bspstore */                                      \
   1.119      st8 [r17]=r31,16;   /* save predicates */                                           \
   1.120 +(pKStk) adds r16=16,r16;    /* skip over ar_bspstore field */                           \
   1.121      ;;                                                                                  \
   1.122      st8 [r16]=r29,16;   /* save b0 */                                                   \
   1.123      st8 [r17]=r18,16;   /* save ar.rsc value for "loadrs" */                            \
   1.124 @@ -174,22 +180,24 @@
   1.125      ;;                                                                                  \
   1.126  .mem.offset 0,0; st8.spill [r16]=r13,16;                                                \
   1.127  .mem.offset 8,0; st8.spill [r17]=r10,16;        /* save ar.fpsr */                      \
   1.128 -    mov r13=r21;        /* establish `current' */                                       \
   1.129 +(pUStk) VMX_MINSTATE_GET_CURRENT(r13);          /* establish `current' */               \
   1.130 +(pKStk) movl r13=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;/* From MINSTATE_GET_CURRENT */\
   1.131      ;;                                                                                  \
   1.132  .mem.offset 0,0; st8.spill [r16]=r15,16;                                                \
   1.133  .mem.offset 8,0; st8.spill [r17]=r14,16;                                                \
   1.134 +(pKStk) ld8 r13=[r13];                          /* establish `current' */               \
   1.135      ;;                                                                                  \
   1.136  .mem.offset 0,0; st8.spill [r16]=r2,16;                                                 \
   1.137  .mem.offset 8,0; st8.spill [r17]=r3,16;                                                 \
   1.138      adds r2=IA64_PT_REGS_R16_OFFSET,r1;                                                 \
   1.139      ;;                                                                                  \
   1.140 -    adds r16=IA64_VCPU_IIPA_OFFSET,r13;                                                 \
   1.141 -    adds r17=IA64_VCPU_ISR_OFFSET,r13;                                                  \
   1.142 -    mov r26=cr.iipa;                                                                    \
   1.143 -    mov r27=cr.isr;                                                                     \
   1.144 +(pUStk) adds r16=IA64_VCPU_IIPA_OFFSET,r13;                                             \
   1.145 +(pUStk) adds r17=IA64_VCPU_ISR_OFFSET,r13;                                              \
   1.146 +(pUStk) mov r26=cr.iipa;                                                                \
   1.147 +(pUStk) mov r27=cr.isr;                                                                 \
   1.148      ;;                                                                                  \
   1.149 -    st8 [r16]=r26;                                                                      \
   1.150 -    st8 [r17]=r27;                                                                      \
   1.151 +(pUStk) st8 [r16]=r26;                                                                  \
   1.152 +(pUStk) st8 [r17]=r27;                                                                  \
   1.153      ;;                                                                                  \
   1.154      EXTRA;                                                                              \
   1.155      mov r8=ar.ccv;                                                                      \
   1.156 @@ -263,10 +271,10 @@
   1.157      st8 [r24]=r9;       /* ar.csd */    \
   1.158      st8 [r25]=r10;      /* ar.ssd */    \
   1.159      ;;                                  \
   1.160 -    mov r18=ar.unat;                    \
   1.161 -    adds r19=PT(EML_UNAT)-PT(R4),r2;    \
   1.162 +(pUStk)mov r18=ar.unat;                 \
   1.163 +(pUStk)adds r19=PT(EML_UNAT)-PT(R4),r2; \
   1.164      ;;                                  \
   1.165 -    st8 [r19]=r18;      /* eml_unat */
   1.166 +(pUStk)st8 [r19]=r18;      /* eml_unat */
   1.167  
   1.168  #define VMX_SAVE_EXTRA                  \
   1.169  .mem.offset 0,0; st8.spill [r2]=r4,16;  \