OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [ia64/] [kernel/] [ivt.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * arch/ia64/kernel/ivt.S
3
 *
4
 * Copyright (C) 2002-2003 Intel Co
5
 *      Suresh Siddha 
6
 *      Kenneth Chen 
7
 *      Fenghua Yu 
8
 * Copyright (C) 1998-2001 Hewlett-Packard Co
9
 *      Stephane Eranian 
10
 *      David Mosberger 
11
 *
12
 * 00/08/23 Asit Mallick  TLB handling for SMP
13
 * 00/12/20 David Mosberger-Tang  DTLB/ITLB handler now uses virtual PT.
14
 */
15
/*
16
 * This file defines the interruption vector table used by the CPU.
17
 * It does not include one entry per possible cause of interruption.
18
 *
19
 * The first 20 entries of the table contain 64 bundles each while the
20
 * remaining 48 entries contain only 16 bundles each.
21
 *
22
 * The 64 bundles are used to allow inlining the whole handler for critical
23
 * interruptions like TLB misses.
24
 *
25
 *  For each entry, the comment is as follows:
26
 *
27
 *              // 0x1c00 Entry 7 (size 64 bundles) Data Key Miss (12,51)
28
 *  entry offset ----/     /         /                  /          /
29
 *  entry number ---------/         /                  /          /
30
 *  size of the entry -------------/                  /          /
31
 *  vector name -------------------------------------/          /
32
 *  interruptions triggering this vector ----------------------/
33
 *
34
 * The table is 32KB in size and must be aligned on 32KB boundary.
35
 * (The CPU ignores the 15 lower bits of the address)
36
 *
37
 * Table is based upon EAS2.6 (Oct 1999)
38
 */
39
 
40
#include 
41
 
42
#include 
43
#include 
44
#include 
45
#include 
46
#include 
47
#include 
48
#include 
49
#include 
50
#include 
51
 
52
#if 1
53
# define PSR_DEFAULT_BITS       psr.ac
54
#else
55
# define PSR_DEFAULT_BITS       0
56
#endif
57
 
58
#if 0
59
  /*
60
   * This lets you track the last eight faults that occurred on the CPU.  Make sure ar.k2 isn't
61
   * needed for something else before enabling this...
62
   */
63
# define DBG_FAULT(i)   mov r16=ar.k2;; shl r16=r16,8;; add r16=(i),r16;;mov ar.k2=r16
64
#else
65
# define DBG_FAULT(i)
66
#endif
67
 
68
#define MINSTATE_VIRT   /* needed by minstate.h */
69
#include "minstate.h"
70
 
71
#define FAULT(n)                                                                        \
72
        mov r31=pr;                                                                     \
73
        mov r19=n;;                     /* prepare to save predicates */                \
74
        br.sptk.many dispatch_to_fault_handler
75
 
76
/*
77
 * As we don't (hopefully) use the space available, we need to fill it with
78
 * nops. the parameter may be used for debugging and is representing the entry
79
 * number
80
 */
81
#define BREAK_BUNDLE(a) break.m (a); \
82
                                break.i (a); \
83
                                break.i (a)
84
/*
85
 * 4 breaks bundles all together
86
 */
87
#define BREAK_BUNDLE4(a); BREAK_BUNDLE(a); BREAK_BUNDLE(a); BREAK_BUNDLE(a); BREAK_BUNDLE(a)
88
 
89
/*
90
 * 8 bundles all together (too lazy to use only 4 at a time !)
91
 */
92
#define BREAK_BUNDLE8(a); BREAK_BUNDLE4(a); BREAK_BUNDLE4(a)
93
 
94
        .section .text.ivt,"ax"
95
 
96
        .align 32768    // align on 32KB boundary
97
        .global ia64_ivt
98
ia64_ivt:
99
/////////////////////////////////////////////////////////////////////////////////////////
100
// 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
101
ENTRY(vhpt_miss)
102
        DBG_FAULT(0)
103
        /*
104
         * The VHPT vector is invoked when the TLB entry for the virtual page table
105
         * is missing.  This happens only as a result of a previous
106
         * (the "original") TLB miss, which may either be caused by an instruction
107
         * fetch or a data access (or non-access).
108
         *
109
         * What we do here is normal TLB miss handing for the _original_ miss, followed
110
         * by inserting the TLB entry for the virtual page table page that the VHPT
111
         * walker was attempting to access.  The latter gets inserted as long
112
         * as both L1 and L2 have valid mappings for the faulting address.
113
         * The TLB entry for the original miss gets inserted only if
114
         * the L3 entry indicates that the page is present.
115
         *
116
         * do_page_fault gets invoked in the following cases:
117
         *      - the faulting virtual address uses unimplemented address bits
118
         *      - the faulting virtual address has no L1, L2, or L3 mapping
119
         */
120
        mov r16=cr.ifa                          // get address that caused the TLB miss
121
#ifdef CONFIG_HUGETLB_PAGE
122
        movl r18=PAGE_SHIFT
123
        mov r25=cr.itir
124
#endif
125
        ;;
126
        rsm psr.dt                              // use physical addressing for data
127
        mov r31=pr                              // save the predicate registers
128
        mov r19=IA64_KR(PT_BASE)                // get page table base address
129
        shl r21=r16,3                           // shift bit 60 into sign bit
130
        shr.u r17=r16,61                        // get the region number into r17
131
        ;;
132
        shr r22=r21,3
133
#ifdef CONFIG_HUGETLB_PAGE
134
        extr.u r26=r25,2,6
135
        ;;
136
        cmp.eq p8,p0=HPAGE_SHIFT,r26
137
        ;;
138
(p8)    dep r25=r18,r25,2,6
139
(p8)    shr r22=r22,HPAGE_SHIFT-PAGE_SHIFT
140
#endif
141
        ;;
142
        cmp.eq p6,p7=5,r17                      // is IFA pointing into to region 5?
143
        shr.u r18=r22,PGDIR_SHIFT               // get bits 33-63 of the faulting address
144
        ;;
145
(p7)    dep r17=r17,r19,(PAGE_SHIFT-3),3        // put region number bits in place
146
        srlz.d                                  // ensure "rsm psr.dt" has taken effect
147
(p6)    movl r19=__pa(swapper_pg_dir)           // region 5 is rooted at swapper_pg_dir
148
(p6)    shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
149
(p7)    shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
150
        ;;
151
(p6)    dep r17=r18,r19,3,(PAGE_SHIFT-3)        // r17=PTA + IFA(33,42)*8
152
(p7)    dep r17=r18,r17,3,(PAGE_SHIFT-6)        // r17=PTA + (((IFA(61,63) << 7) | IFA(33,39))*8)
153
        cmp.eq p7,p6=0,r21                      // unused address bits all zeroes?
154
        shr.u r18=r22,PMD_SHIFT                 // shift L2 index into position
155
        ;;
156
        ld8 r17=[r17]                           // fetch the L1 entry (may be 0)
157
        ;;
158
(p7)    cmp.eq p6,p7=r17,r0                     // was L1 entry NULL?
159
        dep r17=r18,r17,3,(PAGE_SHIFT-3)        // compute address of L2 page table entry
160
        ;;
161
(p7)    ld8 r20=[r17]                           // fetch the L2 entry (may be 0)
162
        shr.u r19=r22,PAGE_SHIFT                // shift L3 index into position
163
        ;;
164
(p7)    cmp.eq.or.andcm p6,p7=r20,r0            // was L2 entry NULL?
165
        dep r21=r19,r20,3,(PAGE_SHIFT-3)        // compute address of L3 page table entry
166
        ;;
167
(p7)    ld8 r18=[r21]                           // read the L3 PTE
168
        mov r19=cr.isr                          // cr.isr bit 0 tells us if this is an insn miss
169
        ;;
170
(p7)    tbit.z p6,p7=r18,_PAGE_P_BIT            // page present bit cleared?
171
        mov r22=cr.iha                          // get the VHPT address that caused the TLB miss
172
        ;;                                      // avoid RAW on p7
173
(p7)    tbit.nz.unc p10,p11=r19,32              // is it an instruction TLB miss?
174
        dep r23=0,r20,0,PAGE_SHIFT              // clear low bits to get page address
175
        ;;
176
(p10)   itc.i r18                               // insert the instruction TLB entry
177
(p11)   itc.d r18                               // insert the data TLB entry
178
(p6)    br.cond.spnt.many page_fault            // handle bad address/page not present (page fault)
179
        mov cr.ifa=r22
180
 
181
#ifdef CONFIG_HUGETLB_PAGE
182
(p8)    mov cr.itir=r25                         // change to default page-size for VHPT
183
#endif
184
 
185
        /*
186
         * Now compute and insert the TLB entry for the virtual page table.  We never
187
         * execute in a page table page so there is no need to set the exception deferral
188
         * bit.
189
         */
190
        adds r24=__DIRTY_BITS_NO_ED|_PAGE_PL_0|_PAGE_AR_RW,r23
191
        ;;
192
(p7)    itc.d r24
193
        ;;
194
#ifdef CONFIG_SMP
195
        /*
196
         * Re-check L2 and L3 pagetable.  If they changed, we may have received a ptc.g
197
         * between reading the pagetable and the "itc".  If so, flush the entry we
198
         * inserted and retry.
199
         */
200
        ld8 r25=[r21]                           // read L3 PTE again
201
        ld8 r26=[r17]                           // read L2 entry again
202
        ;;
203
        cmp.ne p6,p7=r26,r20                    // did L2 entry change
204
        mov r27=PAGE_SHIFT<<2
205
        ;;
206
(p6)    ptc.l r22,r27                           // purge PTE page translation
207
(p7)    cmp.ne.or.andcm p6,p7=r25,r18           // did L3 PTE change
208
        ;;
209
(p6)    ptc.l r16,r27                           // purge translation
210
#endif
211
 
212
        mov pr=r31,-1                           // restore predicate registers
213
        rfi
214
END(vhpt_miss)
215
 
216
        .align 1024
217
/////////////////////////////////////////////////////////////////////////////////////////
218
// 0x0400 Entry 1 (size 64 bundles) ITLB (21)
219
ENTRY(itlb_miss)
220
        DBG_FAULT(1)
221
        /*
222
         * The ITLB handler accesses the L3 PTE via the virtually mapped linear
223
         * page table.  If a nested TLB miss occurs, we switch into physical
224
         * mode, walk the page table, and then re-execute the L3 PTE read
225
         * and go on normally after that.
226
         */
227
        mov r16=cr.ifa                          // get virtual address
228
        mov r29=b0                              // save b0
229
        mov r31=pr                              // save predicates
230
itlb_fault:
231
        mov r17=cr.iha                          // get virtual address of L3 PTE
232
        movl r30=1f                             // load nested fault continuation point
233
        ;;
234
1:      ld8 r18=[r17]                           // read L3 PTE
235
        ;;
236
        mov b0=r29
237
        tbit.z p6,p0=r18,_PAGE_P_BIT            // page present bit cleared?
238
(p6)    br.cond.spnt page_fault
239
        ;;
240
        itc.i r18
241
        ;;
242
#ifdef CONFIG_SMP
243
        ld8 r19=[r17]                           // read L3 PTE again and see if same
244
        mov r20=PAGE_SHIFT<<2                   // setup page size for purge
245
        ;;
246
        cmp.ne p7,p0=r18,r19
247
        ;;
248
(p7)    ptc.l r16,r20
249
#endif
250
        mov pr=r31,-1
251
        rfi
252
END(itlb_miss)
253
 
254
        .align 1024
255
/////////////////////////////////////////////////////////////////////////////////////////
256
// 0x0800 Entry 2 (size 64 bundles) DTLB (9,48)
257
ENTRY(dtlb_miss)
258
        DBG_FAULT(2)
259
        /*
260
         * The DTLB handler accesses the L3 PTE via the virtually mapped linear
261
         * page table.  If a nested TLB miss occurs, we switch into physical
262
         * mode, walk the page table, and then re-execute the L3 PTE read
263
         * and go on normally after that.
264
         */
265
        mov r16=cr.ifa                          // get virtual address
266
        mov r29=b0                              // save b0
267
        mov r31=pr                              // save predicates
268
dtlb_fault:
269
        mov r17=cr.iha                          // get virtual address of L3 PTE
270
        movl r30=1f                             // load nested fault continuation point
271
        ;;
272
1:      ld8 r18=[r17]                           // read L3 PTE
273
        ;;
274
        mov b0=r29
275
        tbit.z p6,p0=r18,_PAGE_P_BIT            // page present bit cleared?
276
(p6)    br.cond.spnt page_fault
277
        ;;
278
        itc.d r18
279
        ;;
280
#ifdef CONFIG_SMP
281
        ld8 r19=[r17]                           // read L3 PTE again and see if same
282
        mov r20=PAGE_SHIFT<<2                   // setup page size for purge
283
        ;;
284
        cmp.ne p7,p0=r18,r19
285
        ;;
286
(p7)    ptc.l r16,r20
287
#endif
288
        mov pr=r31,-1
289
        rfi
290
END(dtlb_miss)
291
 
292
        .align 1024
293
/////////////////////////////////////////////////////////////////////////////////////////
294
// 0x0c00 Entry 3 (size 64 bundles) Alt ITLB (19)
295
ENTRY(alt_itlb_miss)
296
        DBG_FAULT(3)
297
        mov r16=cr.ifa          // get address that caused the TLB miss
298
        movl r17=PAGE_KERNEL
299
        mov r21=cr.ipsr
300
        movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
301
        mov r31=pr
302
        ;;
303
#ifdef CONFIG_DISABLE_VHPT
304
        shr.u r22=r16,61                        // get the region number into r21
305
        ;;
306
        cmp.gt p8,p0=6,r22                      // user mode
307
        ;;
308
(p8)    thash r17=r16
309
        ;;
310
(p8)    mov cr.iha=r17
311
(p8)    mov r29=b0                              // save b0
312
(p8)    br.cond.dptk itlb_fault
313
#endif
314
        extr.u r23=r21,IA64_PSR_CPL0_BIT,2      // extract psr.cpl
315
        and r19=r19,r16         // clear ed, reserved bits, and PTE control bits
316
        shr.u r18=r16,57        // move address bit 61 to bit 4
317
        ;;
318
        andcm r18=0x10,r18      // bit 4=~address-bit(61)
319
        cmp.ne p8,p0=r0,r23     // psr.cpl != 0?
320
        or r19=r17,r19          // insert PTE control bits into r19
321
        ;;
322
        or r19=r19,r18          // set bit 4 (uncached) if the access was to region 6
323
(p8)    br.cond.spnt page_fault
324
        ;;
325
        itc.i r19               // insert the TLB entry
326
        mov pr=r31,-1
327
        rfi
328
END(alt_itlb_miss)
329
 
330
        .align 1024
331
/////////////////////////////////////////////////////////////////////////////////////////
332
// 0x1000 Entry 4 (size 64 bundles) Alt DTLB (7,46)
333
ENTRY(alt_dtlb_miss)
334
        DBG_FAULT(4)
335
        mov r16=cr.ifa          // get address that caused the TLB miss
336
        movl r17=PAGE_KERNEL
337
        mov r20=cr.isr
338
        movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
339
        mov r21=cr.ipsr
340
        mov r31=pr
341
        ;;
342
#ifdef CONFIG_DISABLE_VHPT
343
        shr.u r22=r16,61                        // get the region number into r21
344
        ;;
345
        cmp.gt p8,p0=6,r22                      // access to region 0-5
346
        ;;
347
(p8)    thash r17=r16
348
        ;;
349
(p8)    mov cr.iha=r17
350
(p8)    mov r29=b0                              // save b0
351
(p8)    br.cond.dptk dtlb_fault
352
#endif
353
        extr.u r23=r21,IA64_PSR_CPL0_BIT,2      // extract psr.cpl
354
        and r22=IA64_ISR_CODE_MASK,r20          // get the isr.code field
355
        tbit.nz p6,p7=r20,IA64_ISR_SP_BIT       // is speculation bit on?
356
        shr.u r18=r16,57                        // move address bit 61 to bit 4
357
        and r19=r19,r16                         // clear ed, reserved bits, and PTE control bits
358
        tbit.nz p9,p0=r20,IA64_ISR_NA_BIT       // is non-access bit on?
359
        ;;
360
        andcm r18=0x10,r18      // bit 4=~address-bit(61)
361
        cmp.ne p8,p0=r0,r23
362
(p9)    cmp.eq.or.andcm p6,p7=IA64_ISR_CODE_LFETCH,r22  // check isr.code field
363
(p8)    br.cond.spnt page_fault
364
 
365
        dep r21=-1,r21,IA64_PSR_ED_BIT,1
366
        or r19=r19,r17          // insert PTE control bits into r19
367
        ;;
368
        or r19=r19,r18          // set bit 4 (uncached) if the access was to region 6
369
(p6)    mov cr.ipsr=r21
370
        ;;
371
(p7)    itc.d r19               // insert the TLB entry
372
        mov pr=r31,-1
373
        rfi
374
END(alt_dtlb_miss)
375
 
376
        //-----------------------------------------------------------------------------------
377
        // call do_page_fault (predicates are in r31, psr.dt may be off, r16 is faulting address)
378
ENTRY(page_fault)
379
        ssm psr.dt
380
        ;;
381
        srlz.i
382
        ;;
383
        SAVE_MIN_WITH_COVER
384
        alloc r15=ar.pfs,0,0,3,0
385
        mov out0=cr.ifa
386
        mov out1=cr.isr
387
        adds r3=8,r2                            // set up second base pointer
388
        ;;
389
        ssm psr.ic | PSR_DEFAULT_BITS
390
        ;;
391
        srlz.i                                  // guarantee that interruption collectin is on
392
        ;;
393
(p15)   ssm psr.i                               // restore psr.i
394
        movl r14=ia64_leave_kernel
395
        ;;
396
        SAVE_REST
397
        mov rp=r14
398
        ;;
399
        adds out2=16,r12                        // out2 = pointer to pt_regs
400
        br.call.sptk.many b6=ia64_do_page_fault // ignore return address
401
END(page_fault)
402
 
403
        .align 1024
404
/////////////////////////////////////////////////////////////////////////////////////////
405
// 0x1400 Entry 5 (size 64 bundles) Data nested TLB (6,45)
406
ENTRY(nested_dtlb_miss)
407
        /*
408
         * In the absence of kernel bugs, we get here when the virtually mapped linear
409
         * page table is accessed non-speculatively (e.g., in the Dirty-bit, Instruction
410
         * Access-bit, or Data Access-bit faults).  If the DTLB entry for the virtual page
411
         * table is missing, a nested TLB miss fault is triggered and control is
412
         * transferred to this point.  When this happens, we lookup the pte for the
413
         * faulting address by walking the page table in physical mode and return to the
414
         * continuation point passed in register r30 (or call page_fault if the address is
415
         * not mapped).
416
         *
417
         * Input:       r16:    faulting address
418
         *              r29:    saved b0
419
         *              r30:    continuation address
420
         *              r31:    saved pr
421
         *
422
         * Output:      r17:    physical address of L3 PTE of faulting address
423
         *              r29:    saved b0
424
         *              r30:    continuation address
425
         *              r31:    saved pr
426
         *
427
         * Clobbered:   b0, r18, r19, r21, psr.dt (cleared)
428
         */
429
        rsm psr.dt                              // switch to using physical data addressing
430
        mov r19=IA64_KR(PT_BASE)                // get the page table base address
431
        shl r21=r16,3                           // shift bit 60 into sign bit
432
        ;;
433
        shr.u r17=r16,61                        // get the region number into r17
434
        ;;
435
        cmp.eq p6,p7=5,r17                      // is faulting address in region 5?
436
        shr.u r18=r16,PGDIR_SHIFT               // get bits 33-63 of faulting address
437
        ;;
438
(p7)    dep r17=r17,r19,(PAGE_SHIFT-3),3        // put region number bits in place
439
        srlz.d
440
(p6)    movl r19=__pa(swapper_pg_dir)           // region 5 is rooted at swapper_pg_dir
441
(p6)    shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
442
(p7)    shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
443
        ;;
444
(p6)    dep r17=r18,r19,3,(PAGE_SHIFT-3)        // r17=PTA + IFA(33,42)*8
445
(p7)    dep r17=r18,r17,3,(PAGE_SHIFT-6)        // r17=PTA + (((IFA(61,63) << 7) | IFA(33,39))*8)
446
        cmp.eq p7,p6=0,r21                      // unused address bits all zeroes?
447
        shr.u r18=r16,PMD_SHIFT                 // shift L2 index into position
448
        ;;
449
        ld8 r17=[r17]                           // fetch the L1 entry (may be 0)
450
        ;;
451
(p7)    cmp.eq p6,p7=r17,r0                     // was L1 entry NULL?
452
        dep r17=r18,r17,3,(PAGE_SHIFT-3)        // compute address of L2 page table entry
453
        ;;
454
(p7)    ld8 r17=[r17]                           // fetch the L2 entry (may be 0)
455
        shr.u r19=r16,PAGE_SHIFT                // shift L3 index into position
456
        ;;
457
(p7)    cmp.eq.or.andcm p6,p7=r17,r0            // was L2 entry NULL?
458
        dep r17=r19,r17,3,(PAGE_SHIFT-3)        // compute address of L3 page table entry
459
(p6)    br.cond.spnt page_fault
460
        mov b0=r30
461
        br.sptk.many b0                         // return to continuation point
462
END(nested_dtlb_miss)
463
 
464
        .align 1024
465
/////////////////////////////////////////////////////////////////////////////////////////
466
// 0x1800 Entry 6 (size 64 bundles) Instruction Key Miss (24)
467
ENTRY(ikey_miss)
468
        DBG_FAULT(6)
469
        FAULT(6)
470
END(ikey_miss)
471
 
472
        .align 1024
473
/////////////////////////////////////////////////////////////////////////////////////////
474
// 0x1c00 Entry 7 (size 64 bundles) Data Key Miss (12,51)
475
ENTRY(dkey_miss)
476
        DBG_FAULT(7)
477
        FAULT(7)
478
END(dkey_miss)
479
 
480
        .align 1024
481
/////////////////////////////////////////////////////////////////////////////////////////
482
// 0x2000 Entry 8 (size 64 bundles) Dirty-bit (54)
483
ENTRY(dirty_bit)
484
        DBG_FAULT(8)
485
        /*
486
         * What we do here is to simply turn on the dirty bit in the PTE.  We need to
487
         * update both the page-table and the TLB entry.  To efficiently access the PTE,
488
         * we address it through the virtual page table.  Most likely, the TLB entry for
489
         * the relevant virtual page table page is still present in the TLB so we can
490
         * normally do this without additional TLB misses.  In case the necessary virtual
491
         * page table TLB entry isn't present, we take a nested TLB miss hit where we look
492
         * up the physical address of the L3 PTE and then continue at label 1 below.
493
         */
494
        mov r16=cr.ifa                          // get the address that caused the fault
495
        movl r30=1f                             // load continuation point in case of nested fault
496
        ;;
497
        thash r17=r16                           // compute virtual address of L3 PTE
498
        mov r29=b0                              // save b0 in case of nested fault
499
        mov r31=pr                              // save pr
500
#ifdef CONFIG_SMP
501
        mov r28=ar.ccv                          // save ar.ccv
502
        ;;
503
1:      ld8 r18=[r17]
504
        ;;                                      // avoid RAW on r18
505
        mov ar.ccv=r18                          // set compare value for cmpxchg
506
        or r25=_PAGE_D|_PAGE_A,r18              // set the dirty and accessed bits
507
        ;;
508
        cmpxchg8.acq r26=[r17],r25,ar.ccv
509
        mov r24=PAGE_SHIFT<<2
510
        ;;
511
        cmp.eq p6,p7=r26,r18
512
        ;;
513
(p6)    itc.d r25                               // install updated PTE
514
        ;;
515
        ld8 r18=[r17]                           // read PTE again
516
        ;;
517
        cmp.eq p6,p7=r18,r25                    // is it same as the newly installed
518
        ;;
519
(p7)    ptc.l r16,r24
520
        mov b0=r29                              // restore b0
521
        mov ar.ccv=r28
522
#else
523
        ;;
524
1:      ld8 r18=[r17]
525
        ;;                                      // avoid RAW on r18
526
        or r18=_PAGE_D|_PAGE_A,r18              // set the dirty and accessed bits
527
        mov b0=r29                              // restore b0
528
        ;;
529
        st8 [r17]=r18                           // store back updated PTE
530
        itc.d r18                               // install updated PTE
531
#endif
532
        mov pr=r31,-1                           // restore pr
533
        rfi
534
END(idirty_bit)
535
 
536
        .align 1024
537
/////////////////////////////////////////////////////////////////////////////////////////
538
// 0x2400 Entry 9 (size 64 bundles) Instruction Access-bit (27)
539
ENTRY(iaccess_bit)
540
        DBG_FAULT(9)
541
        // Like Entry 8, except for instruction access
542
        mov r16=cr.ifa                          // get the address that caused the fault
543
        movl r30=1f                             // load continuation point in case of nested fault
544
        mov r31=pr                              // save predicates
545
#ifdef CONFIG_ITANIUM
546
        /*
547
         * Erratum 10 (IFA may contain incorrect address) has "NoFix" status.
548
         */
549
        mov r17=cr.ipsr
550
        ;;
551
        mov r18=cr.iip
552
        tbit.z p6,p0=r17,IA64_PSR_IS_BIT        // IA64 instruction set?
553
        ;;
554
(p6)    mov r16=r18                             // if so, use cr.iip instead of cr.ifa
555
#endif /* CONFIG_ITANIUM */
556
        ;;
557
        thash r17=r16                           // compute virtual address of L3 PTE
558
        mov r29=b0                              // save b0 in case of nested fault)
559
#ifdef CONFIG_SMP
560
        mov r28=ar.ccv                          // save ar.ccv
561
        ;;
562
1:      ld8 r18=[r17]
563
        ;;
564
        mov ar.ccv=r18                          // set compare value for cmpxchg
565
        or r25=_PAGE_A,r18                      // set the accessed bit
566
        ;;
567
        cmpxchg8.acq r26=[r17],r25,ar.ccv
568
        mov r24=PAGE_SHIFT<<2
569
        ;;
570
        cmp.eq p6,p7=r26,r18
571
        ;;
572
(p6)    itc.i r25                               // install updated PTE
573
        ;;
574
        ld8 r18=[r17]                           // read PTE again
575
        ;;
576
        cmp.eq p6,p7=r18,r25                    // is it same as the newly installed
577
        ;;
578
(p7)    ptc.l r16,r24
579
        mov b0=r29                              // restore b0
580
        mov ar.ccv=r28
581
#else /* !CONFIG_SMP */
582
        ;;
583
1:      ld8 r18=[r17]
584
        ;;
585
        or r18=_PAGE_A,r18                      // set the accessed bit
586
        mov b0=r29                              // restore b0
587
        ;;
588
        st8 [r17]=r18                           // store back updated PTE
589
        itc.i r18                               // install updated PTE
590
#endif /* !CONFIG_SMP */
591
        mov pr=r31,-1
592
        rfi
593
END(iaccess_bit)
594
 
595
        .align 1024
596
/////////////////////////////////////////////////////////////////////////////////////////
597
// 0x2800 Entry 10 (size 64 bundles) Data Access-bit (15,55)
598
ENTRY(daccess_bit)
599
        DBG_FAULT(10)
600
        // Like Entry 8, except for data access
601
        mov r16=cr.ifa                          // get the address that caused the fault
602
        movl r30=1f                             // load continuation point in case of nested fault
603
        ;;
604
        thash r17=r16                           // compute virtual address of L3 PTE
605
        mov r31=pr
606
        mov r29=b0                              // save b0 in case of nested fault)
607
#ifdef CONFIG_SMP
608
        mov r28=ar.ccv                          // save ar.ccv
609
        ;;
610
1:      ld8 r18=[r17]
611
        ;;                                      // avoid RAW on r18
612
        mov ar.ccv=r18                          // set compare value for cmpxchg
613
        or r25=_PAGE_A,r18                      // set the dirty bit
614
        ;;
615
        cmpxchg8.acq r26=[r17],r25,ar.ccv
616
        mov r24=PAGE_SHIFT<<2
617
        ;;
618
        cmp.eq p6,p7=r26,r18
619
        ;;
620
(p6)    itc.d r25                               // install updated PTE
621
        ;;
622
        ld8 r18=[r17]                           // read PTE again
623
        ;;
624
        cmp.eq p6,p7=r18,r25                    // is it same as the newly installed
625
        ;;
626
(p7)    ptc.l r16,r24
627
        mov ar.ccv=r28
628
#else
629
        ;;
630
1:      ld8 r18=[r17]
631
        ;;                                      // avoid RAW on r18
632
        or r18=_PAGE_A,r18                      // set the accessed bit
633
        ;;
634
        st8 [r17]=r18                           // store back updated PTE
635
        itc.d r18                               // install updated PTE
636
#endif
637
        mov b0=r29                              // restore b0
638
        mov pr=r31,-1
639
        rfi
640
END(daccess_bit)
641
 
642
        .align 1024
643
/////////////////////////////////////////////////////////////////////////////////////////
644
// 0x2c00 Entry 11 (size 64 bundles) Break instruction (33)
645
ENTRY(break_fault)
646
 
647
/* System call entry/exit only saves/restores part of pt_regs, i.e. no scratch registers
648
 * are saved/restored except r15 which contains syscall number and needs to be saved in the
649
 * entry. This optimization is based on the assumption that applications only call glibc
650
 * system call interface which doesn't use scratch registers after break into kernel.
651
 * Registers saved/restored during system call entry/exit are listed as follows:
652
 *
653
 *   Registers to be saved & restored:
654
 *      CR registers: cr_ipsr, cr_iip, cr_ifs
655
 *      AR registers: ar_unat, ar_pfs, ar_rsc, ar_rnat, ar_bspstore, ar_fpsr
656
 *      others: pr, b0, loadrs, r1, r12, r13, r15
657
 *   Registers to be restored only:
658
 *      r8~r11: output value from the system call.
659
 *
660
 * During system call exit, scratch registers (including r15) are modified/cleared to
661
 * prevent leaking bits from kernel to user level.
662
 */
663
        DBG_FAULT(11)
664
        mov r16=cr.iim
665
        mov r17=__IA64_BREAK_SYSCALL
666
        mov r31=pr              // prepare to save predicates
667
        ;;
668
        cmp.eq p0,p7=r16,r17    // is this a system call? (p7 <- false, if so)
669
(p7)    br.cond.spnt non_syscall
670
 
671
        mov r21=ar.fpsr;
672
        mov r29=cr.ipsr;
673
        mov r20=r1;
674
        mov r25=ar.unat;
675
        mov r27=ar.rsc;
676
        mov r26=ar.pfs;
677
        mov r28=cr.iip;
678
        mov r1=IA64_KR(CURRENT);                /* r1 = current (physical) */
679
        ;;
680
        invala;
681
        extr.u r16=r29,32,2;                    /* extract psr.cpl */
682
        ;;
683
        cmp.eq pKern,pUser=r0,r16;              /* are we in kernel mode already? (psr.cpl==0) */
684
        /* switch from user to kernel RBS: */
685
        ;;
686
        mov r30=r0
687
        MINSTATE_START_SAVE_MIN_VIRT
688
        br.call.sptk.many b7=ia64_syscall_setup
689
        ;;
690
        mov r3=255
691
        adds r15=-1024,r15                      // r15 contains the syscall number---subtract 1024
692
        adds r2=IA64_TASK_PTRACE_OFFSET,r13     // r2 = ¤t->ptrace
693
        ;;
694
        cmp.geu p6,p7=r3,r15            // (syscall > 0 && syscall <= 1024+255) ?
695
        movl r16=sys_call_table
696
        ;;
697
(p6)    shladd r16=r15,3,r16
698
        movl r15=ia64_ret_from_syscall
699
(p7)    adds r16=(__NR_ni_syscall-1024)*8,r16   // force __NR_ni_syscall
700
        ;;
701
        ld8 r16=[r16]                           // load address of syscall entry point
702
        mov rp=r15                              // set the real return addr
703
        ;;
704
        ld8 r2=[r2]                             // r2 = current->ptrace
705
        mov b6=r16
706
 
707
        // arrange things so we skip over break instruction when returning:
708
 
709
        adds r16=PT(CR_IPSR)+16,sp                      // get pointer to cr_ipsr
710
        adds r17=PT(CR_IIP)+16,sp                       // get pointer to cr_iip
711
        ;;
712
        ld8 r18=[r16]                           // fetch cr_ipsr
713
        tbit.z p8,p0=r2,PT_TRACESYS_BIT         // (current->ptrace & PF_TRACESYS) == 0?
714
        ;;
715
        ld8 r19=[r17]                           // fetch cr_iip
716
        extr.u r20=r18,41,2                     // extract ei field
717
        ;;
718
        cmp.eq p6,p7=2,r20                      // isr.ei==2?
719
        adds r19=16,r19                         // compute address of next bundle
720
        ;;
721
(p6)    mov r20=0                               // clear ei to 0
722
(p7)    adds r20=1,r20                          // increment ei to next slot
723
        ;;
724
(p6)    st8 [r17]=r19                           // store new cr.iip if cr.isr.ei wrapped around
725
        dep r18=r20,r18,41,2                    // insert new ei into cr.isr
726
        ;;
727
        st8 [r16]=r18                           // store new value for cr.isr
728
 
729
(p8)    br.call.sptk.many b6=b6                 // ignore this return addr
730
 
731
        br.cond.sptk ia64_trace_syscall
732
        // NOT REACHED
733
END(break_fault)
734
 
735
 
736
        .align 1024
737
/////////////////////////////////////////////////////////////////////////////////////////
738
// 0x3000 Entry 12 (size 64 bundles) External Interrupt (4)
739
ENTRY(interrupt)
740
        DBG_FAULT(12)
741
        mov r31=pr              // prepare to save predicates
742
        ;;
743
        SAVE_MIN_WITH_COVER     // uses r31; defines r2 and r3
744
        ssm psr.ic | PSR_DEFAULT_BITS
745
        ;;
746
        adds r3=8,r2            // set up second base pointer for SAVE_REST
747
        srlz.i                  // ensure everybody knows psr.ic is back on
748
        ;;
749
        SAVE_REST
750
        ;;
751
        alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group
752
        mov out0=cr.ivr         // pass cr.ivr as first arg
753
        add out1=16,sp          // pass pointer to pt_regs as second arg
754
        ;;
755
        srlz.d                  // make  sure we see the effect of cr.ivr
756
        movl r14=ia64_leave_kernel
757
        ;;
758
        mov rp=r14
759
        br.call.sptk.many b6=ia64_handle_irq
760
END(interrupt)
761
 
762
        .align 1024
763
/////////////////////////////////////////////////////////////////////////////////////////
764
// 0x3400 Entry 13 (size 64 bundles) Reserved
765
        DBG_FAULT(13)
766
        FAULT(13)
767
 
768
        .align 1024
769
/////////////////////////////////////////////////////////////////////////////////////////
770
// 0x3800 Entry 14 (size 64 bundles) Reserved
771
        DBG_FAULT(14)
772
        FAULT(14)
773
 
774
        /*
775
         * There is no particular reason for this code to be here, other than that
776
         * there happens to be space here that would go unused otherwise.  If this
777
         * fault ever gets "unreserved", simply moved the following code to a more
778
         * suitable spot...
779
         *
780
         * ia64_syscall_setup() is a separate subroutine so that it can
781
         *      allocate stacked registers so it can safely demine any
782
         *      potential NaT values from the input registers.
783
         *
784
         * On entry:
785
         *      - executing on bank 0 or bank 1 register set (doesn't matter)
786
         *      -  r1: stack pointer
787
         *      -  r2: current task pointer
788
         *      -  r3: preserved
789
         *      - r12: original contents (sp to be saved)
790
         *      - r13: original contents (tp to be saved)
791
         *      - r15: original contents (syscall # to be saved)
792
         *      - r18: saved bsp (after switching to kernel stack)
793
         *      - r20: saved r1 (gp)
794
         *      - r21: saved ar.fpsr
795
         *      - r22: kernel's register backing store base (krbs_base)
796
         *      - r23: saved ar.bspstore
797
         *      - r24: saved ar.rnat
798
         *      - r25: saved ar.unat
799
         *      - r26: saved ar.pfs
800
         *      - r27: saved ar.rsc
801
         *      - r28: saved cr.iip
802
         *      - r29: saved cr.ipsr
803
         *      - r31: saved pr
804
         *      -  b0: original contents (to be saved)
805
         * On exit:
806
         *      - executing on bank 1 registers
807
         *      - psr.ic enabled, interrupts restored
808
         *      -  r1: kernel's gp
809
         *      -  r3: preserved (same as on entry)
810
         *      - r12: points to kernel stack
811
         *      - r13: points to current task
812
         *      - p15: TRUE if interrupts need to be re-enabled
813
         *      - ar.fpsr: set to kernel settings
814
         */
815
ENTRY(ia64_syscall_setup)
816
        alloc r19=ar.pfs,8,0,0,0
817
        tnat.nz p8,p0=in0
818
        add r16=PT(CR_IPSR),r1  /* initialize first base pointer */
819
        ;;
820
        st8 [r16]=r29,16;       /* save cr.ipsr */
821
        adds r17=PT(CR_IIP),r1; /* initialize second base pointer */
822
        ;;
823
(p8)    mov in0=-1
824
        tnat.nz p9,p0=in1
825
        st8 [r17]=r28,16;       /* save cr.iip */
826
        mov r28=b0;
827
(pKern) mov r18=r0;             /* make sure r18 isn't NaT */
828
        ;;
829
(p9)    mov in1=-1
830
        tnat.nz p10,p0=in2
831
        st8 [r16]=r30,16;       /* save cr.ifs */
832
        st8 [r17]=r25,16;       /* save ar.unat */
833
(pUser) sub r18=r18,r22;        /* r18=RSE.ndirty*8 */
834
        ;;
835
        st8 [r16]=r26,16;       /* save ar.pfs */
836
        st8 [r17]=r27,16;       /* save ar.rsc */
837
        tbit.nz p15,p0=r29,IA64_PSR_I_BIT
838
        ;;                      /* avoid RAW on r16 & r17 */
839
(p10)   mov in2=-1
840
        nop.f 0
841
        tnat.nz p11,p0=in3
842
(pKern) adds r16=16,r16;        /* skip over ar_rnat field */
843
(pKern) adds r17=16,r17;        /* skip over ar_bspstore field */
844
        shl r18=r18,16;         /* compute ar.rsc to be used for "loadrs" */
845
        ;;
846
(p11)   mov in3=-1
847
        tnat.nz p12,p0=in4
848
(pUser) st8 [r16]=r24,16;       /* save ar.rnat */
849
(pUser) st8 [r17]=r23,16;       /* save ar.bspstore */
850
        ;;
851
(p12)   mov in4=-1
852
        tnat.nz p13,p0=in5
853
        st8 [r16]=r31,16;       /* save predicates */
854
        st8 [r17]=r28,16;       /* save b0 */
855
        dep r14=-1,r0,61,3;
856
        ;;
857
        st8 [r16]=r18,16;       /* save ar.rsc value for "loadrs" */
858
        st8.spill [r17]=r20,16; /* save original r1 */
859
        adds r2=IA64_PT_REGS_R16_OFFSET,r1;
860
        ;;
861
(p13)   mov in5=-1
862
        tnat.nz p14,p0=in6
863
.mem.offset 0,0;                st8.spill [r16]=r12,16;
864
.mem.offset 8,0;                st8.spill [r17]=r13,16;
865
        cmp.eq pNonSys,pSys=r0,r0       /* initialize pSys=0, pNonSys=1 */
866
        ;;
867
(p14)   mov in6=-1
868
        tnat.nz p8,p0=in7
869
.mem.offset 0,0;                st8 [r16]=r21,16;    /* ar.fpsr */
870
.mem.offset 8,0;                st8.spill [r17]=r15,16;
871
        adds r12=-16,r1;        /* switch to kernel memory stack (with 16 bytes of scratch) */
872
        ;;
873
        mov r13=IA64_KR(CURRENT);       /* establish `current' */
874
        movl r1=__gp;           /* establish kernel global pointer */
875
        ;;
876
        MINSTATE_END_SAVE_MIN_VIRT
877
 
878
        tnat.nz p9,p0=r15
879
(p8)    mov in7=-1
880
        ssm psr.ic | PSR_DEFAULT_BITS
881
        movl r17=FPSR_DEFAULT
882
        adds r8=(IA64_PT_REGS_R8_OFFSET-IA64_PT_REGS_R16_OFFSET),r2
883
        ;;
884
        srlz.i                                  // guarantee that interruption collection is on
885
        cmp.eq pSys,pNonSys=r0,r0               // set pSys=1, pNonSys=0
886
(p9)    mov r15=-1
887
(p15)   ssm psr.i               // restore psr.i
888
        mov.m ar.fpsr=r17
889
        stf8 [r8]=f1            // ensure pt_regs.r8 != 0 (see handle_syscall_error)
890
        br.ret.sptk.many b7
891
END(ia64_syscall_setup)
892
 
893
        .align 1024
894
/////////////////////////////////////////////////////////////////////////////////////////
895
// 0x3c00 Entry 15 (size 64 bundles) Reserved
896
        DBG_FAULT(15)
897
        FAULT(15)
898
 
899
        /*
900
         * Squatting in this space ...
901
         *
902
         * This special case dispatcher for illegal operation faults allows preserved
903
         * registers to be modified through a callback function (asm only) that is handed
904
         * back from the fault handler in r8. Up to three arguments can be passed to the
905
         * callback function by returning an aggregate with the callback as its first
906
         * element, followed by the arguments.
907
         */
908
ENTRY(dispatch_illegal_op_fault)
909
        SAVE_MIN_WITH_COVER
910
        ssm psr.ic | PSR_DEFAULT_BITS
911
        ;;
912
        srlz.i          // guarantee that interruption collection is on
913
        ;;
914
(p15)   ssm psr.i       // restore psr.i
915
        adds r3=8,r2    // set up second base pointer for SAVE_REST
916
        ;;
917
        alloc r14=ar.pfs,0,0,1,0        // must be first in insn group
918
        mov out0=ar.ec
919
        ;;
920
        SAVE_REST
921
        ;;
922
        br.call.sptk.many rp=ia64_illegal_op_fault
923
.ret0:  ;;
924
        alloc r14=ar.pfs,0,0,3,0        // must be first in insn group
925
        mov out0=r9
926
        mov out1=r10
927
        mov out2=r11
928
        movl r15=ia64_leave_kernel
929
        ;;
930
        mov rp=r15
931
        mov b6=r8
932
        ;;
933
        cmp.ne p6,p0=0,r8
934
(p6)    br.call.dpnt.many b6=b6         // call returns to ia64_leave_kernel
935
        br.sptk.many ia64_leave_kernel
936
END(dispatch_illegal_op_fault)
937
 
938
        .align 1024
939
/////////////////////////////////////////////////////////////////////////////////////////
940
// 0x4000 Entry 16 (size 64 bundles) Reserved
941
        DBG_FAULT(16)
942
        FAULT(16)
943
 
944
        .align 1024
945
/////////////////////////////////////////////////////////////////////////////////////////
946
// 0x4400 Entry 17 (size 64 bundles) Reserved
947
        DBG_FAULT(17)
948
        FAULT(17)
949
 
950
ENTRY(non_syscall)
951
        SAVE_MIN_WITH_COVER
952
 
953
        // There is no particular reason for this code to be here, other than that
954
        // there happens to be space here that would go unused otherwise.  If this
955
        // fault ever gets "unreserved", simply moved the following code to a more
956
        // suitable spot...
957
 
958
        alloc r14=ar.pfs,0,0,2,0
959
        mov out0=cr.iim
960
        add out1=16,sp
961
        adds r3=8,r2                    // set up second base pointer for SAVE_REST
962
 
963
        ssm psr.ic | PSR_DEFAULT_BITS
964
        ;;
965
        srlz.i                          // guarantee that interruption collection is on
966
        ;;
967
(p15)   ssm psr.i                       // restore psr.i
968
        movl r15=ia64_leave_kernel
969
        ;;
970
        SAVE_REST
971
        mov rp=r15
972
        ;;
973
        br.call.sptk.many b6=ia64_bad_break     // avoid WAW on CFM and ignore return addr
974
END(non_syscall)
975
 
976
        .align 1024
977
/////////////////////////////////////////////////////////////////////////////////////////
978
// 0x4800 Entry 18 (size 64 bundles) Reserved
979
        DBG_FAULT(18)
980
        FAULT(18)
981
 
982
        /*
983
         * There is no particular reason for this code to be here, other than that
984
         * there happens to be space here that would go unused otherwise.  If this
985
         * fault ever gets "unreserved", simply moved the following code to a more
986
         * suitable spot...
987
         */
988
 
989
ENTRY(dispatch_unaligned_handler)
990
        SAVE_MIN_WITH_COVER
991
        ;;
992
        alloc r14=ar.pfs,0,0,2,0                // now it's safe (must be first in insn group!)
993
        mov out0=cr.ifa
994
        adds out1=16,sp
995
 
996
        ssm psr.ic | PSR_DEFAULT_BITS
997
        ;;
998
        srlz.i                                  // guarantee that interruption collection is on
999
        ;;
1000
(p15)   ssm psr.i                               // restore psr.i
1001
        adds r3=8,r2                            // set up second base pointer
1002
        ;;
1003
        SAVE_REST
1004
        movl r14=ia64_leave_kernel
1005
        ;;
1006
        mov rp=r14
1007
        br.sptk.many ia64_prepare_handle_unaligned
1008
END(dispatch_unaligned_handler)
1009
 
1010
        .align 1024
1011
/////////////////////////////////////////////////////////////////////////////////////////
1012
// 0x4c00 Entry 19 (size 64 bundles) Reserved
1013
        DBG_FAULT(19)
1014
        FAULT(19)
1015
 
1016
        /*
1017
         * There is no particular reason for this code to be here, other than that
1018
         * there happens to be space here that would go unused otherwise.  If this
1019
         * fault ever gets "unreserved", simply moved the following code to a more
1020
         * suitable spot...
1021
         */
1022
 
1023
ENTRY(dispatch_to_fault_handler)
1024
        /*
1025
         * Input:
1026
         *      psr.ic: off
1027
         *      r19:    fault vector number (e.g., 24 for General Exception)
1028
         *      r31:    contains saved predicates (pr)
1029
         */
1030
        SAVE_MIN_WITH_COVER_R19
1031
        alloc r14=ar.pfs,0,0,5,0
1032
        mov out0=r15
1033
        mov out1=cr.isr
1034
        mov out2=cr.ifa
1035
        mov out3=cr.iim
1036
        mov out4=cr.itir
1037
        ;;
1038
        ssm psr.ic | PSR_DEFAULT_BITS
1039
        ;;
1040
        srlz.i                                  // guarantee that interruption collection is on
1041
        ;;
1042
(p15)   ssm psr.i                               // restore psr.i
1043
        adds r3=8,r2                            // set up second base pointer for SAVE_REST
1044
        ;;
1045
        SAVE_REST
1046
        movl r14=ia64_leave_kernel
1047
        ;;
1048
        mov rp=r14
1049
        br.call.sptk.many b6=ia64_fault
1050
END(dispatch_to_fault_handler)
1051
 
1052
//
1053
// --- End of long entries, Beginning of short entries
1054
//
1055
 
1056
        .align 1024
1057
/////////////////////////////////////////////////////////////////////////////////////////
1058
// 0x5000 Entry 20 (size 16 bundles) Page Not Present (10,22,49)
1059
ENTRY(page_not_present)
1060
        DBG_FAULT(20)
1061
        mov r16=cr.ifa
1062
        rsm psr.dt
1063
        /*
1064
         * The Linux page fault handler doesn't expect non-present pages to be in
1065
         * the TLB.  Flush the existing entry now, so we meet that expectation.
1066
         */
1067
        mov r17=PAGE_SHIFT<<2
1068
        ;;
1069
        ptc.l r16,r17
1070
        ;;
1071
        mov r31=pr
1072
        srlz.d
1073
        br.sptk.many page_fault
1074
END(page_not_present)
1075
 
1076
        .align 256
1077
/////////////////////////////////////////////////////////////////////////////////////////
1078
// 0x5100 Entry 21 (size 16 bundles) Key Permission (13,25,52)
1079
ENTRY(key_permission)
1080
        DBG_FAULT(21)
1081
        mov r16=cr.ifa
1082
        rsm psr.dt
1083
        mov r31=pr
1084
        ;;
1085
        srlz.d
1086
        br.sptk.many page_fault
1087
END(key_permission)
1088
 
1089
        .align 256
1090
/////////////////////////////////////////////////////////////////////////////////////////
1091
// 0x5200 Entry 22 (size 16 bundles) Instruction Access Rights (26)
1092
ENTRY(iaccess_rights)
1093
        DBG_FAULT(22)
1094
        mov r16=cr.ifa
1095
        rsm psr.dt
1096
        mov r31=pr
1097
        ;;
1098
        srlz.d
1099
        br.sptk.many page_fault
1100
END(iaccess_rights)
1101
 
1102
        .align 256
1103
/////////////////////////////////////////////////////////////////////////////////////////
1104
// 0x5300 Entry 23 (size 16 bundles) Data Access Rights (14,53)
1105
ENTRY(daccess_rights)
1106
        DBG_FAULT(23)
1107
        mov r16=cr.ifa
1108
        rsm psr.dt
1109
        mov r31=pr
1110
        ;;
1111
        srlz.d
1112
        br.sptk.many page_fault
1113
END(daccess_rights)
1114
 
1115
        .align 256
1116
/////////////////////////////////////////////////////////////////////////////////////////
1117
// 0x5400 Entry 24 (size 16 bundles) General Exception (5,32,34,36,38,39)
1118
ENTRY(general_exception)
1119
        DBG_FAULT(24)
1120
        mov r16=cr.isr
1121
        mov r31=pr
1122
        ;;
1123
        cmp4.eq p6,p0=0,r16
1124
(p6)    br.sptk.many dispatch_illegal_op_fault
1125
        ;;
1126
        mov r19=24              // fault number
1127
        br.sptk.many dispatch_to_fault_handler
1128
END(general_exception)
1129
 
1130
        .align 256
1131
/////////////////////////////////////////////////////////////////////////////////////////
1132
// 0x5500 Entry 25 (size 16 bundles) Disabled FP-Register (35)
1133
ENTRY(disabled_fp_reg)
1134
        DBG_FAULT(25)
1135
        rsm psr.dfh             // ensure we can access fph
1136
        ;;
1137
        srlz.d
1138
        mov r31=pr
1139
        mov r19=25
1140
        br.sptk.many dispatch_to_fault_handler
1141
END(disabled_fp_reg)
1142
 
1143
        .align 256
1144
/////////////////////////////////////////////////////////////////////////////////////////
1145
// 0x5600 Entry 26 (size 16 bundles) Nat Consumption (11,23,37,50)
1146
ENTRY(nat_consumption)
1147
        DBG_FAULT(26)
1148
        FAULT(26)
1149
END(nat_consumption)
1150
 
1151
        .align 256
1152
/////////////////////////////////////////////////////////////////////////////////////////
1153
// 0x5700 Entry 27 (size 16 bundles) Speculation (40)
1154
ENTRY(speculation_vector)
1155
        DBG_FAULT(27)
1156
        /*
1157
         * A [f]chk.[as] instruction needs to take the branch to the recovery code but
1158
         * this part of the architecture is not implemented in hardware on some CPUs, such
1159
         * as Itanium.  Thus, in general we need to emulate the behavior.  IIM contains
1160
         * the relative target (not yet sign extended).  So after sign extending it we
1161
         * simply add it to IIP.  We also need to reset the EI field of the IPSR to zero,
1162
         * i.e., the slot to restart into.
1163
         *
1164
         * cr.imm contains zero_ext(imm21)
1165
         */
1166
        mov r18=cr.iim
1167
        ;;
1168
        mov r17=cr.iip
1169
        shl r18=r18,43                  // put sign bit in position (43=64-21)
1170
        ;;
1171
 
1172
        mov r16=cr.ipsr
1173
        shr r18=r18,39                  // sign extend (39=43-4)
1174
        ;;
1175
 
1176
        add r17=r17,r18                 // now add the offset
1177
        ;;
1178
        mov cr.iip=r17
1179
        dep r16=0,r16,41,2              // clear EI
1180
        ;;
1181
 
1182
        mov cr.ipsr=r16
1183
        ;;
1184
 
1185
        rfi                             // and go back
1186
END(speculation_vector)
1187
 
1188
        .align 256
1189
/////////////////////////////////////////////////////////////////////////////////////////
1190
// 0x5800 Entry 28 (size 16 bundles) Reserved
1191
        DBG_FAULT(28)
1192
        FAULT(28)
1193
 
1194
        .align 256
1195
/////////////////////////////////////////////////////////////////////////////////////////
1196
// 0x5900 Entry 29 (size 16 bundles) Debug (16,28,56)
1197
ENTRY(debug_vector)
1198
        DBG_FAULT(29)
1199
        FAULT(29)
1200
END(debug_vector)
1201
 
1202
        .align 256
1203
/////////////////////////////////////////////////////////////////////////////////////////
1204
// 0x5a00 Entry 30 (size 16 bundles) Unaligned Reference (57)
1205
ENTRY(unaligned_access)
1206
        DBG_FAULT(30)
1207
        mov r16=cr.ipsr
1208
        mov r31=pr              // prepare to save predicates
1209
        ;;
1210
        br.sptk.many dispatch_unaligned_handler
1211
END(unaligned_access)
1212
 
1213
        .align 256
1214
/////////////////////////////////////////////////////////////////////////////////////////
1215
// 0x5b00 Entry 31 (size 16 bundles) Unsupported Data Reference (57)
1216
        DBG_FAULT(31)
1217
        FAULT(31)
1218
 
1219
        .align 256
1220
/////////////////////////////////////////////////////////////////////////////////////////
1221
// 0x5c00 Entry 32 (size 16 bundles) Floating-Point Fault (64)
1222
        DBG_FAULT(32)
1223
        FAULT(32)
1224
 
1225
        .align 256
1226
/////////////////////////////////////////////////////////////////////////////////////////
1227
// 0x5d00 Entry 33 (size 16 bundles) Floating Point Trap (66)
1228
        DBG_FAULT(33)
1229
        FAULT(33)
1230
 
1231
        .align 256
1232
/////////////////////////////////////////////////////////////////////////////////////////
1233
// 0x5e00 Entry 34 (size 16 bundles) Lower Privilege Tranfer Trap (66)
1234
        DBG_FAULT(34)
1235
        FAULT(34)
1236
 
1237
        .align 256
1238
/////////////////////////////////////////////////////////////////////////////////////////
1239
// 0x5f00 Entry 35 (size 16 bundles) Taken Branch Trap (68)
1240
        DBG_FAULT(35)
1241
        FAULT(35)
1242
 
1243
        .align 256
1244
/////////////////////////////////////////////////////////////////////////////////////////
1245
// 0x6000 Entry 36 (size 16 bundles) Single Step Trap (69)
1246
        DBG_FAULT(36)
1247
        FAULT(36)
1248
 
1249
        .align 256
1250
/////////////////////////////////////////////////////////////////////////////////////////
1251
// 0x6100 Entry 37 (size 16 bundles) Reserved
1252
        DBG_FAULT(37)
1253
        FAULT(37)
1254
 
1255
        .align 256
1256
/////////////////////////////////////////////////////////////////////////////////////////
1257
// 0x6200 Entry 38 (size 16 bundles) Reserved
1258
        DBG_FAULT(38)
1259
        FAULT(38)
1260
 
1261
        .align 256
1262
/////////////////////////////////////////////////////////////////////////////////////////
1263
// 0x6300 Entry 39 (size 16 bundles) Reserved
1264
        DBG_FAULT(39)
1265
        FAULT(39)
1266
 
1267
        .align 256
1268
/////////////////////////////////////////////////////////////////////////////////////////
1269
// 0x6400 Entry 40 (size 16 bundles) Reserved
1270
        DBG_FAULT(40)
1271
        FAULT(40)
1272
 
1273
        .align 256
1274
/////////////////////////////////////////////////////////////////////////////////////////
1275
// 0x6500 Entry 41 (size 16 bundles) Reserved
1276
        DBG_FAULT(41)
1277
        FAULT(41)
1278
 
1279
        .align 256
1280
/////////////////////////////////////////////////////////////////////////////////////////
1281
// 0x6600 Entry 42 (size 16 bundles) Reserved
1282
        DBG_FAULT(42)
1283
        FAULT(42)
1284
 
1285
        .align 256
1286
/////////////////////////////////////////////////////////////////////////////////////////
1287
// 0x6700 Entry 43 (size 16 bundles) Reserved
1288
        DBG_FAULT(43)
1289
        FAULT(43)
1290
 
1291
        .align 256
1292
/////////////////////////////////////////////////////////////////////////////////////////
1293
// 0x6800 Entry 44 (size 16 bundles) Reserved
1294
        DBG_FAULT(44)
1295
        FAULT(44)
1296
 
1297
        .align 256
1298
/////////////////////////////////////////////////////////////////////////////////////////
1299
// 0x6900 Entry 45 (size 16 bundles) IA-32 Exeception (17,18,29,41,42,43,44,58,60,61,62,72,73,75,76,77)
1300
ENTRY(ia32_exception)
1301
        DBG_FAULT(45)
1302
        FAULT(45)
1303
END(ia32_exception)
1304
 
1305
        .align 256
1306
/////////////////////////////////////////////////////////////////////////////////////////
1307
// 0x6a00 Entry 46 (size 16 bundles) IA-32 Intercept  (30,31,59,70,71)
1308
ENTRY(ia32_intercept)
1309
        DBG_FAULT(46)
1310
#ifdef  CONFIG_IA32_SUPPORT
1311
        mov r31=pr
1312
        mov r16=cr.isr
1313
        ;;
1314
        extr.u r17=r16,16,8     // get ISR.code
1315
        mov r18=ar.eflag
1316
        mov r19=cr.iim          // old eflag value
1317
        ;;
1318
        cmp.ne p6,p0=2,r17
1319
(p6)    br.cond.spnt 1f         // not a system flag fault
1320
        xor r16=r18,r19
1321
        ;;
1322
        extr.u r17=r16,18,1     // get the eflags.ac bit
1323
        ;;
1324
        cmp.eq p6,p0=0,r17
1325
(p6)    br.cond.spnt 1f         // eflags.ac bit didn't change
1326
        ;;
1327
        mov pr=r31,-1           // restore predicate registers
1328
        rfi
1329
 
1330
1:
1331
#endif  // CONFIG_IA32_SUPPORT
1332
        FAULT(46)
1333
END(ia32_intercept)
1334
 
1335
        .align 256
1336
/////////////////////////////////////////////////////////////////////////////////////////
1337
// 0x6b00 Entry 47 (size 16 bundles) IA-32 Interrupt  (74)
1338
ENTRY(ia32_interrupt)
1339
        DBG_FAULT(47)
1340
#ifdef CONFIG_IA32_SUPPORT
1341
        mov r31=pr
1342
        br.sptk.many dispatch_to_ia32_handler
1343
#else
1344
        FAULT(47)
1345
#endif
1346
END(ia32_interrupt)
1347
 
1348
        .align 256
1349
/////////////////////////////////////////////////////////////////////////////////////////
1350
// 0x6c00 Entry 48 (size 16 bundles) Reserved
1351
        DBG_FAULT(48)
1352
        FAULT(48)
1353
 
1354
        .align 256
1355
/////////////////////////////////////////////////////////////////////////////////////////
1356
// 0x6d00 Entry 49 (size 16 bundles) Reserved
1357
        DBG_FAULT(49)
1358
        FAULT(49)
1359
 
1360
        .align 256
1361
/////////////////////////////////////////////////////////////////////////////////////////
1362
// 0x6e00 Entry 50 (size 16 bundles) Reserved
1363
        DBG_FAULT(50)
1364
        FAULT(50)
1365
 
1366
        .align 256
1367
/////////////////////////////////////////////////////////////////////////////////////////
1368
// 0x6f00 Entry 51 (size 16 bundles) Reserved
1369
        DBG_FAULT(51)
1370
        FAULT(51)
1371
 
1372
        .align 256
1373
/////////////////////////////////////////////////////////////////////////////////////////
1374
// 0x7000 Entry 52 (size 16 bundles) Reserved
1375
        DBG_FAULT(52)
1376
        FAULT(52)
1377
 
1378
        .align 256
1379
/////////////////////////////////////////////////////////////////////////////////////////
1380
// 0x7100 Entry 53 (size 16 bundles) Reserved
1381
        DBG_FAULT(53)
1382
        FAULT(53)
1383
 
1384
        .align 256
1385
/////////////////////////////////////////////////////////////////////////////////////////
1386
// 0x7200 Entry 54 (size 16 bundles) Reserved
1387
        DBG_FAULT(54)
1388
        FAULT(54)
1389
 
1390
        .align 256
1391
/////////////////////////////////////////////////////////////////////////////////////////
1392
// 0x7300 Entry 55 (size 16 bundles) Reserved
1393
        DBG_FAULT(55)
1394
        FAULT(55)
1395
 
1396
        .align 256
1397
/////////////////////////////////////////////////////////////////////////////////////////
1398
// 0x7400 Entry 56 (size 16 bundles) Reserved
1399
        DBG_FAULT(56)
1400
        FAULT(56)
1401
 
1402
        .align 256
1403
/////////////////////////////////////////////////////////////////////////////////////////
1404
// 0x7500 Entry 57 (size 16 bundles) Reserved
1405
        DBG_FAULT(57)
1406
        FAULT(57)
1407
 
1408
        .align 256
1409
/////////////////////////////////////////////////////////////////////////////////////////
1410
// 0x7600 Entry 58 (size 16 bundles) Reserved
1411
        DBG_FAULT(58)
1412
        FAULT(58)
1413
 
1414
        .align 256
1415
/////////////////////////////////////////////////////////////////////////////////////////
1416
// 0x7700 Entry 59 (size 16 bundles) Reserved
1417
        DBG_FAULT(59)
1418
        FAULT(59)
1419
 
1420
        .align 256
1421
/////////////////////////////////////////////////////////////////////////////////////////
1422
// 0x7800 Entry 60 (size 16 bundles) Reserved
1423
        DBG_FAULT(60)
1424
        FAULT(60)
1425
 
1426
        .align 256
1427
/////////////////////////////////////////////////////////////////////////////////////////
1428
// 0x7900 Entry 61 (size 16 bundles) Reserved
1429
        DBG_FAULT(61)
1430
        FAULT(61)
1431
 
1432
        .align 256
1433
/////////////////////////////////////////////////////////////////////////////////////////
1434
// 0x7a00 Entry 62 (size 16 bundles) Reserved
1435
        DBG_FAULT(62)
1436
        FAULT(62)
1437
 
1438
        .align 256
1439
/////////////////////////////////////////////////////////////////////////////////////////
1440
// 0x7b00 Entry 63 (size 16 bundles) Reserved
1441
        DBG_FAULT(63)
1442
        FAULT(63)
1443
 
1444
        .align 256
1445
/////////////////////////////////////////////////////////////////////////////////////////
1446
// 0x7c00 Entry 64 (size 16 bundles) Reserved
1447
        DBG_FAULT(64)
1448
        FAULT(64)
1449
 
1450
        .align 256
1451
/////////////////////////////////////////////////////////////////////////////////////////
1452
// 0x7d00 Entry 65 (size 16 bundles) Reserved
1453
        DBG_FAULT(65)
1454
        FAULT(65)
1455
 
1456
        .align 256
1457
/////////////////////////////////////////////////////////////////////////////////////////
1458
// 0x7e00 Entry 66 (size 16 bundles) Reserved
1459
        DBG_FAULT(66)
1460
        FAULT(66)
1461
 
1462
        .align 256
1463
/////////////////////////////////////////////////////////////////////////////////////////
1464
// 0x7f00 Entry 67 (size 16 bundles) Reserved
1465
        DBG_FAULT(67)
1466
        FAULT(67)
1467
 
1468
#ifdef CONFIG_IA32_SUPPORT
1469
 
1470
        /*
1471
         * There is no particular reason for this code to be here, other than that
1472
         * there happens to be space here that would go unused otherwise.  If this
1473
         * fault ever gets "unreserved", simply moved the following code to a more
1474
         * suitable spot...
1475
         */
1476
 
1477
        // IA32 interrupt entry point
1478
 
1479
ENTRY(dispatch_to_ia32_handler)
1480
        SAVE_MIN
1481
        ;;
1482
        mov r14=cr.isr
1483
        ssm psr.ic | PSR_DEFAULT_BITS
1484
        ;;
1485
        srlz.i                                  // guarantee that interruption collection is on
1486
        ;;
1487
(p15)   ssm psr.i
1488
        adds r3=8,r2            // Base pointer for SAVE_REST
1489
        ;;
1490
        SAVE_REST
1491
        ;;
1492
        mov r15=0x80
1493
        shr r14=r14,16          // Get interrupt number
1494
        ;;
1495
        cmp.ne p6,p0=r14,r15
1496
(p6)    br.call.dpnt.many b6=non_ia32_syscall
1497
 
1498
        adds r14=IA64_PT_REGS_R8_OFFSET + 16,sp // 16 byte hole per SW conventions
1499
        adds r15=IA64_PT_REGS_R1_OFFSET + 16,sp
1500
        ;;
1501
        cmp.eq pSys,pNonSys=r0,r0 // set pSys=1, pNonSys=0
1502
        ld8 r8=[r14]            // get r8
1503
        ;;
1504
        st8 [r15]=r8            // save original EAX in r1 (IA32 procs don't use the GP)
1505
        ;;
1506
        alloc r15=ar.pfs,0,0,6,0        // must first in an insn group
1507
        ;;
1508
        ld4 r8=[r14],8          // r8 == eax (syscall number)
1509
        mov r15=230             // number of entries in ia32 system call table
1510
        ;;
1511
        cmp.ltu.unc p6,p7=r8,r15
1512
        ld4 out1=[r14],8        // r9 == ecx
1513
        ;;
1514
        ld4 out2=[r14],8        // r10 == edx
1515
        ;;
1516
        ld4 out0=[r14]          // r11 == ebx
1517
        adds r14=(IA64_PT_REGS_R13_OFFSET) + 16,sp
1518
        ;;
1519
        ld4 out5=[r14],PT(R14)-PT(R13)  // r13 == ebp
1520
        ;;
1521
        ld4 out3=[r14],PT(R15)-PT(R14)  // r14 == esi
1522
        adds r2=IA64_TASK_PTRACE_OFFSET,r13     // r2 = ¤t->ptrace
1523
        ;;
1524
        ld4 out4=[r14]          // r15 == edi
1525
        movl r16=ia32_syscall_table
1526
        ;;
1527
(p6)    shladd r16=r8,3,r16     // force ni_syscall if not valid syscall number
1528
        ld8 r2=[r2]             // r2 = current->ptrace
1529
        ;;
1530
        ld8 r16=[r16]
1531
        tbit.z p8,p0=r2,PT_TRACESYS_BIT // (current->ptrace & PT_TRACESYS) == 0?
1532
        ;;
1533
        mov b6=r16
1534
        movl r15=ia32_ret_from_syscall
1535
        ;;
1536
        mov rp=r15
1537
(p8)    br.call.sptk.many b6=b6
1538
        br.cond.sptk ia32_trace_syscall
1539
 
1540
non_ia32_syscall:
1541
        alloc r15=ar.pfs,0,0,2,0
1542
        mov out0=r14                            // interrupt #
1543
        add out1=16,sp                          // pointer to pt_regs
1544
        ;;                      // avoid WAW on CFM
1545
        br.call.sptk.many rp=ia32_bad_interrupt
1546
.ret1:  movl r15=ia64_leave_kernel
1547
        ;;
1548
        mov rp=r15
1549
        br.ret.sptk.many rp
1550
END(dispatch_to_ia32_handler)
1551
 
1552
#endif /* CONFIG_IA32_SUPPORT */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.