4 * Copyright (C) 1998-2001, 2003 Hewlett-Packard Co
5 * Stephane Eranian <eranian@hpl.hp.com>
6 * David Mosberger <davidm@hpl.hp.com>
7 * Copyright (C) 2000, 2002-2003 Intel Co
8 * Asit Mallick <asit.k.mallick@intel.com>
9 * Suresh Siddha <suresh.b.siddha@intel.com>
10 * Kenneth Chen <kenneth.w.chen@intel.com>
11 * Fenghua Yu <fenghua.yu@intel.com>
14 * 00/08/23 Asit Mallick <asit.k.mallick@intel.com> TLB handling
16 * 00/12/20 David Mosberger-Tang <davidm@hpl.hp.com> DTLB/ITLB
17 * handler now uses virtual PT.
19 * 07/6/20 Xuefei Xu (Anthony Xu) (anthony.xu@intel.com)
20 * Supporting Intel virtualization architecture
25 * This file defines the interruption vector table used by the CPU.
26 * It does not include one entry per possible cause of interruption.
28 * The first 20 entries of the table contain 64 bundles each while the
29 * remaining 48 entries contain only 16 bundles each.
31 * The 64 bundles are used to allow inlining the whole handler for
33 * interruptions like TLB misses.
35 * For each entry, the comment is as follows:
37 * // 0x1c00 Entry 7 (size 64 bundles) Data Key Miss
39 * entry offset ----/ / / /
41 * entry number ---------/ / /
43 * size of the entry -------------/ /
45 * vector name -------------------------------------/
47 * interruptions triggering this vector
48 * ----------------------/
50 * The table is 32KB in size and must be aligned on 32KB
52 * (The CPU ignores the 15 lower bits of the address)
54 * Table is based upon EAS2.6 (Oct 1999)
58 #include <asm/asmmacro.h>
59 #include <asm/cache.h>
60 #include <asm/pgtable.h>
62 #include "asm-offsets.h"
64 #include "kvm_minstate.h"
68 # define PSR_DEFAULT_BITS psr.ac
70 # define PSR_DEFAULT_BITS 0
74 #define KVM_FAULT(n) \
77 br.sptk.many kvm_fault_##n; \
81 #define KVM_REFLECT(n) \
83 mov r19=n; /* prepare to save predicates */ \
86 tbit.z p6,p7=r29,IA64_PSR_VM_BIT; \
87 (p7)br.sptk.many kvm_dispatch_reflection; \
88 br.sptk.many kvm_panic; \
91 GLOBAL_ENTRY(kvm_panic)
92 br.sptk.many kvm_panic
100 .section .text.ivt,"ax"
102 .align 32768 // align on 32KB boundary
105 ///////////////////////////////////////////////////////////////
106 // 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
112 .org kvm_ia64_ivt+0x400
113 ////////////////////////////////////////////////////////////////
114 // 0x0400 Entry 1 (size 64 bundles) ITLB (21)
119 tbit.z p6,p7=r29,IA64_PSR_VM_BIT;
120 (p6) br.sptk kvm_alt_itlb_miss
122 br.sptk kvm_itlb_miss_dispatch
126 .org kvm_ia64_ivt+0x0800
127 //////////////////////////////////////////////////////////////////
128 // 0x0800 Entry 2 (size 64 bundles) DTLB (9,48)
133 tbit.z p6,p7=r29,IA64_PSR_VM_BIT;
134 (p6)br.sptk kvm_alt_dtlb_miss
135 br.sptk kvm_dtlb_miss_dispatch
138 .org kvm_ia64_ivt+0x0c00
139 ////////////////////////////////////////////////////////////////////
140 // 0x0c00 Entry 3 (size 64 bundles) Alt ITLB (19)
141 ENTRY(kvm_alt_itlb_miss)
142 mov r16=cr.ifa // get address that caused the TLB miss
146 movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
148 and r19=r19,r16 // clear ed, reserved bits, and PTE control bits
150 or r19=r17,r19 // insert PTE control bits into r19
152 movl r20=IA64_GRANULE_SHIFT<<2
156 itc.i r19 // insert the TLB entry
159 END(kvm_alt_itlb_miss)
161 .org kvm_ia64_ivt+0x1000
162 /////////////////////////////////////////////////////////////////////
163 // 0x1000 Entry 4 (size 64 bundles) Alt DTLB (7,46)
164 ENTRY(kvm_alt_dtlb_miss)
165 mov r16=cr.ifa // get address that caused the TLB miss
168 movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
171 and r19=r19,r16 // clear ed, reserved bits, and PTE control bits
173 or r19=r19,r17 // insert PTE control bits into r19
175 movl r20=IA64_GRANULE_SHIFT<<2
179 itc.d r19 // insert the TLB entry
182 END(kvm_alt_dtlb_miss)
184 .org kvm_ia64_ivt+0x1400
185 //////////////////////////////////////////////////////////////////////
186 // 0x1400 Entry 5 (size 64 bundles) Data nested TLB (6,45)
187 ENTRY(kvm_nested_dtlb_miss)
189 END(kvm_nested_dtlb_miss)
191 .org kvm_ia64_ivt+0x1800
192 /////////////////////////////////////////////////////////////////////
193 // 0x1800 Entry 6 (size 64 bundles) Instruction Key Miss (24)
198 .org kvm_ia64_ivt+0x1c00
199 /////////////////////////////////////////////////////////////////////
200 // 0x1c00 Entry 7 (size 64 bundles) Data Key Miss (12,51)
205 .org kvm_ia64_ivt+0x2000
206 ////////////////////////////////////////////////////////////////////
207 // 0x2000 Entry 8 (size 64 bundles) Dirty-bit (54)
212 .org kvm_ia64_ivt+0x2400
213 ////////////////////////////////////////////////////////////////////
214 // 0x2400 Entry 9 (size 64 bundles) Instruction Access-bit (27)
215 ENTRY(kvm_iaccess_bit)
219 .org kvm_ia64_ivt+0x2800
220 ///////////////////////////////////////////////////////////////////
221 // 0x2800 Entry 10 (size 64 bundles) Data Access-bit (15,55)
222 ENTRY(kvm_daccess_bit)
226 .org kvm_ia64_ivt+0x2c00
227 /////////////////////////////////////////////////////////////////
228 // 0x2c00 Entry 11 (size 64 bundles) Break instruction (33)
229 ENTRY(kvm_break_fault)
234 KVM_SAVE_MIN_WITH_COVER_R19
236 alloc r14=ar.pfs,0,0,4,0 // now it's safe (must be first in insn group!)
238 mov out2=cr.isr // FIXME: pity to make this slow access twice
239 mov out3=cr.iim // FIXME: pity to make this slow access twice
240 adds r3=8,r2 // set up second base pointer
244 srlz.i // guarantee that interruption collection is on
246 //(p15)ssm psr.i // restore psr.i
247 addl r14=@gprel(ia64_leave_hypervisor),gp
253 br.call.sptk.many b6=kvm_ia64_handle_break
257 .org kvm_ia64_ivt+0x3000
258 /////////////////////////////////////////////////////////////////
259 // 0x3000 Entry 12 (size 64 bundles) External Interrupt (4)
261 mov r31=pr // prepare to save predicates
265 tbit.z p6,p7=r29,IA64_PSR_VM_BIT
266 tbit.z p0,p15=r29,IA64_PSR_I_BIT
268 (p7) br.sptk kvm_dispatch_interrupt
270 mov r27=ar.rsc /* M */
272 mov r25=ar.unat /* M */
273 mov r26=ar.pfs /* I */
274 mov r28=cr.iip /* M */
275 cover /* B (or nothing) */
282 addl r1=-VMM_PT_REGS_SIZE,r1
284 adds r17=2*L1_CACHE_BYTES,r1 /* really: biggest cache-line size */
285 adds r16=PT(CR_IPSR),r1
287 lfetch.fault.excl.nt1 [r17],L1_CACHE_BYTES
288 st8 [r16]=r29 /* save cr.ipsr */
290 lfetch.fault.excl.nt1 [r17]
293 adds r16=PT(R8),r1 /* initialize first base pointer */
294 adds r17=PT(R9),r1 /* initialize second base pointer */
295 mov r18=r0 /* make sure r18 isn't NaT */
297 .mem.offset 0,0; st8.spill [r16]=r8,16
298 .mem.offset 8,0; st8.spill [r17]=r9,16
300 .mem.offset 0,0; st8.spill [r16]=r10,24
301 .mem.offset 8,0; st8.spill [r17]=r11,24
303 st8 [r16]=r28,16 /* save cr.iip */
304 st8 [r17]=r30,16 /* save cr.ifs */
305 mov r8=ar.fpsr /* M */
308 movl r11=FPSR_DEFAULT /* L-unit */
310 st8 [r16]=r25,16 /* save ar.unat */
311 st8 [r17]=r26,16 /* save ar.pfs */
312 shl r18=r18,16 /* compute ar.rsc to be used for "loadrs" */
314 st8 [r16]=r27,16 /* save ar.rsc */
315 adds r17=16,r17 /* skip over ar_rnat field */
317 st8 [r17]=r31,16 /* save predicates */
318 adds r16=16,r16 /* skip over ar_bspstore field */
320 st8 [r16]=r29,16 /* save b0 */
321 st8 [r17]=r18,16 /* save ar.rsc value for "loadrs" */
323 .mem.offset 0,0; st8.spill [r16]=r20,16 /* save original r1 */
324 .mem.offset 8,0; st8.spill [r17]=r12,16
326 /* switch to kernel memory stack (with 16 bytes of scratch) */
328 .mem.offset 0,0; st8.spill [r16]=r13,16
329 .mem.offset 8,0; st8.spill [r17]=r8,16 /* save ar.fpsr */
331 .mem.offset 0,0; st8.spill [r16]=r15,16
332 .mem.offset 8,0; st8.spill [r17]=r14,16
335 .mem.offset 0,0; st8.spill [r16]=r2,16
336 .mem.offset 8,0; st8.spill [r17]=r3,16
337 adds r2=VMM_PT_REGS_R16_OFFSET,r1
338 adds r14 = VMM_VCPU_GP_OFFSET,r13
343 mov r1=r14 /* establish kernel global pointer */
347 alloc r14=ar.pfs,0,0,1,0 // must be first in an insn group
355 adds r3=8,r2 // set up second base pointer for SAVE_REST
356 srlz.i // ensure everybody knows psr.ic is back on
358 .mem.offset 0,0; st8.spill [r2]=r16,16
359 .mem.offset 8,0; st8.spill [r3]=r17,16
361 .mem.offset 0,0; st8.spill [r2]=r18,16
362 .mem.offset 8,0; st8.spill [r3]=r19,16
364 .mem.offset 0,0; st8.spill [r2]=r20,16
365 .mem.offset 8,0; st8.spill [r3]=r21,16
368 .mem.offset 0,0; st8.spill [r2]=r22,16
369 .mem.offset 8,0; st8.spill [r3]=r23,16
372 .mem.offset 0,0; st8.spill [r2]=r24,16
373 .mem.offset 8,0; st8.spill [r3]=r25,16
375 .mem.offset 0,0; st8.spill [r2]=r26,16
376 .mem.offset 8,0; st8.spill [r3]=r27,16
378 .mem.offset 0,0; st8.spill [r2]=r28,16
379 .mem.offset 8,0; st8.spill [r3]=r29,16
381 .mem.offset 0,0; st8.spill [r2]=r30,16
382 .mem.offset 8,0; st8.spill [r3]=r31,32
384 mov ar.fpsr=r11 /* M-unit */
385 st8 [r2]=r8,8 /* ar.ccv */
386 adds r24=PT(B6)-PT(F7),r3
396 adds r25=PT(B7)-PT(F11),r3
398 st8 [r24]=r18,16 /* b6 */
399 st8 [r25]=r19,16 /* b7 */
401 st8 [r24]=r9 /* ar.csd */
402 st8 [r25]=r10 /* ar.ssd */
404 srlz.d // make sure we see the effect of cr.ivr
405 addl r14=@gprel(ia64_leave_nested),gp
408 br.call.sptk.many b6=kvm_ia64_handle_irq
412 .global kvm_dispatch_vexirq
413 .org kvm_ia64_ivt+0x3400
414 //////////////////////////////////////////////////////////////////////
415 // 0x3400 Entry 13 (size 64 bundles) Reserved
416 ENTRY(kvm_virtual_exirq)
424 (p6)add r29 = VMM_VCPU_SAVED_GP_OFFSET,r21
428 KVM_SAVE_MIN_WITH_COVER_R19
429 alloc r14=ar.pfs,0,0,1,0
434 srlz.i // guarantee that interruption collection is on
436 //(p15) ssm psr.i // restore psr.i
437 adds r3=8,r2 // set up second base pointer
440 addl r14=@gprel(ia64_leave_hypervisor),gp
443 br.call.sptk.many b6=kvm_vexirq
444 END(kvm_virtual_exirq)
446 .org kvm_ia64_ivt+0x3800
447 /////////////////////////////////////////////////////////////////////
448 // 0x3800 Entry 14 (size 64 bundles) Reserved
450 // this code segment is from 2.6.16.13
453 .org kvm_ia64_ivt+0x3c00
454 ///////////////////////////////////////////////////////////////////////
455 // 0x3c00 Entry 15 (size 64 bundles) Reserved
459 .org kvm_ia64_ivt+0x4000
460 ///////////////////////////////////////////////////////////////////////
461 // 0x4000 Entry 16 (size 64 bundles) Reserved
464 .org kvm_ia64_ivt+0x4400
465 //////////////////////////////////////////////////////////////////////
466 // 0x4400 Entry 17 (size 64 bundles) Reserved
469 .org kvm_ia64_ivt+0x4800
470 //////////////////////////////////////////////////////////////////////
471 // 0x4800 Entry 18 (size 64 bundles) Reserved
474 .org kvm_ia64_ivt+0x4c00
475 //////////////////////////////////////////////////////////////////////
476 // 0x4c00 Entry 19 (size 64 bundles) Reserved
479 .org kvm_ia64_ivt+0x5000
480 //////////////////////////////////////////////////////////////////////
481 // 0x5000 Entry 20 (size 16 bundles) Page Not Present
482 ENTRY(kvm_page_not_present)
484 END(kvm_page_not_present)
486 .org kvm_ia64_ivt+0x5100
487 ///////////////////////////////////////////////////////////////////////
488 // 0x5100 Entry 21 (size 16 bundles) Key Permission vector
489 ENTRY(kvm_key_permission)
491 END(kvm_key_permission)
493 .org kvm_ia64_ivt+0x5200
494 //////////////////////////////////////////////////////////////////////
495 // 0x5200 Entry 22 (size 16 bundles) Instruction Access Rights (26)
496 ENTRY(kvm_iaccess_rights)
498 END(kvm_iaccess_rights)
500 .org kvm_ia64_ivt+0x5300
501 //////////////////////////////////////////////////////////////////////
502 // 0x5300 Entry 23 (size 16 bundles) Data Access Rights (14,53)
503 ENTRY(kvm_daccess_rights)
505 END(kvm_daccess_rights)
507 .org kvm_ia64_ivt+0x5400
508 /////////////////////////////////////////////////////////////////////
509 // 0x5400 Entry 24 (size 16 bundles) General Exception (5,32,34,36,38,39)
510 ENTRY(kvm_general_exception)
513 END(kvm_general_exception)
515 .org kvm_ia64_ivt+0x5500
516 //////////////////////////////////////////////////////////////////////
517 // 0x5500 Entry 25 (size 16 bundles) Disabled FP-Register (35)
518 ENTRY(kvm_disabled_fp_reg)
520 END(kvm_disabled_fp_reg)
522 .org kvm_ia64_ivt+0x5600
523 ////////////////////////////////////////////////////////////////////
524 // 0x5600 Entry 26 (size 16 bundles) Nat Consumption (11,23,37,50)
525 ENTRY(kvm_nat_consumption)
527 END(kvm_nat_consumption)
529 .org kvm_ia64_ivt+0x5700
530 /////////////////////////////////////////////////////////////////////
531 // 0x5700 Entry 27 (size 16 bundles) Speculation (40)
532 ENTRY(kvm_speculation_vector)
534 END(kvm_speculation_vector)
536 .org kvm_ia64_ivt+0x5800
537 /////////////////////////////////////////////////////////////////////
538 // 0x5800 Entry 28 (size 16 bundles) Reserved
541 .org kvm_ia64_ivt+0x5900
542 ///////////////////////////////////////////////////////////////////
543 // 0x5900 Entry 29 (size 16 bundles) Debug (16,28,56)
544 ENTRY(kvm_debug_vector)
546 END(kvm_debug_vector)
548 .org kvm_ia64_ivt+0x5a00
549 ///////////////////////////////////////////////////////////////
550 // 0x5a00 Entry 30 (size 16 bundles) Unaligned Reference (57)
551 ENTRY(kvm_unaligned_access)
553 END(kvm_unaligned_access)
555 .org kvm_ia64_ivt+0x5b00
556 //////////////////////////////////////////////////////////////////////
557 // 0x5b00 Entry 31 (size 16 bundles) Unsupported Data Reference (57)
558 ENTRY(kvm_unsupported_data_reference)
560 END(kvm_unsupported_data_reference)
562 .org kvm_ia64_ivt+0x5c00
563 ////////////////////////////////////////////////////////////////////
564 // 0x5c00 Entry 32 (size 16 bundles) Floating Point FAULT (65)
565 ENTRY(kvm_floating_point_fault)
567 END(kvm_floating_point_fault)
569 .org kvm_ia64_ivt+0x5d00
570 /////////////////////////////////////////////////////////////////////
571 // 0x5d00 Entry 33 (size 16 bundles) Floating Point Trap (66)
572 ENTRY(kvm_floating_point_trap)
574 END(kvm_floating_point_trap)
576 .org kvm_ia64_ivt+0x5e00
577 //////////////////////////////////////////////////////////////////////
578 // 0x5e00 Entry 34 (size 16 bundles) Lower Privilege Transfer Trap (66)
579 ENTRY(kvm_lower_privilege_trap)
581 END(kvm_lower_privilege_trap)
583 .org kvm_ia64_ivt+0x5f00
584 //////////////////////////////////////////////////////////////////////
585 // 0x5f00 Entry 35 (size 16 bundles) Taken Branch Trap (68)
586 ENTRY(kvm_taken_branch_trap)
588 END(kvm_taken_branch_trap)
590 .org kvm_ia64_ivt+0x6000
591 ////////////////////////////////////////////////////////////////////
592 // 0x6000 Entry 36 (size 16 bundles) Single Step Trap (69)
593 ENTRY(kvm_single_step_trap)
595 END(kvm_single_step_trap)
596 .global kvm_virtualization_fault_back
597 .org kvm_ia64_ivt+0x6100
598 /////////////////////////////////////////////////////////////////////
599 // 0x6100 Entry 37 (size 16 bundles) Virtualization Fault
600 ENTRY(kvm_virtualization_fault)
602 adds r16 = VMM_VCPU_SAVED_GP_OFFSET,r21
605 adds r17 = VMM_VCPU_GP_OFFSET, r21
608 cmp.eq p6,p0=EVENT_MOV_FROM_AR,r24
609 cmp.eq p7,p0=EVENT_MOV_FROM_RR,r24
610 cmp.eq p8,p0=EVENT_MOV_TO_RR,r24
611 cmp.eq p9,p0=EVENT_RSM,r24
612 cmp.eq p10,p0=EVENT_SSM,r24
613 cmp.eq p11,p0=EVENT_MOV_TO_PSR,r24
614 cmp.eq p12,p0=EVENT_THASH,r24
615 (p6) br.dptk.many kvm_asm_mov_from_ar
616 (p7) br.dptk.many kvm_asm_mov_from_rr
617 (p8) br.dptk.many kvm_asm_mov_to_rr
618 (p9) br.dptk.many kvm_asm_rsm
619 (p10) br.dptk.many kvm_asm_ssm
620 (p11) br.dptk.many kvm_asm_mov_to_psr
621 (p12) br.dptk.many kvm_asm_thash
623 kvm_virtualization_fault_back:
624 adds r16 = VMM_VCPU_SAVED_GP_OFFSET,r21
629 adds r16 = VMM_VCPU_CAUSE_OFFSET,r21
630 adds r17 = VMM_VCPU_OPCODE_OFFSET,r21
635 cmp.ne p6,p0=EVENT_RFI, r24
636 (p6) br.sptk kvm_dispatch_virtualization_fault
638 adds r18=VMM_VPD_BASE_OFFSET,r21
642 adds r18=VMM_VPD_VIFS_OFFSET,r18
647 (p6) br.sptk kvm_dispatch_virtualization_fault
649 //if vifs.v=1 desert current register frame
650 alloc r18=ar.pfs,0,0,0,0
651 br.sptk kvm_dispatch_virtualization_fault
652 END(kvm_virtualization_fault)
654 .org kvm_ia64_ivt+0x6200
655 //////////////////////////////////////////////////////////////
656 // 0x6200 Entry 38 (size 16 bundles) Reserved
659 .org kvm_ia64_ivt+0x6300
660 /////////////////////////////////////////////////////////////////
661 // 0x6300 Entry 39 (size 16 bundles) Reserved
664 .org kvm_ia64_ivt+0x6400
665 /////////////////////////////////////////////////////////////////
666 // 0x6400 Entry 40 (size 16 bundles) Reserved
669 .org kvm_ia64_ivt+0x6500
670 //////////////////////////////////////////////////////////////////
671 // 0x6500 Entry 41 (size 16 bundles) Reserved
674 .org kvm_ia64_ivt+0x6600
675 //////////////////////////////////////////////////////////////////
676 // 0x6600 Entry 42 (size 16 bundles) Reserved
679 .org kvm_ia64_ivt+0x6700
680 //////////////////////////////////////////////////////////////////
681 // 0x6700 Entry 43 (size 16 bundles) Reserved
684 .org kvm_ia64_ivt+0x6800
685 //////////////////////////////////////////////////////////////////
686 // 0x6800 Entry 44 (size 16 bundles) Reserved
689 .org kvm_ia64_ivt+0x6900
690 ///////////////////////////////////////////////////////////////////
691 // 0x6900 Entry 45 (size 16 bundles) IA-32 Exeception
692 //(17,18,29,41,42,43,44,58,60,61,62,72,73,75,76,77)
693 ENTRY(kvm_ia32_exception)
695 END(kvm_ia32_exception)
697 .org kvm_ia64_ivt+0x6a00
698 ////////////////////////////////////////////////////////////////////
699 // 0x6a00 Entry 46 (size 16 bundles) IA-32 Intercept (30,31,59,70,71)
700 ENTRY(kvm_ia32_intercept)
702 END(kvm_ia32_intercept)
704 .org kvm_ia64_ivt+0x6c00
705 /////////////////////////////////////////////////////////////////////
706 // 0x6c00 Entry 48 (size 16 bundles) Reserved
709 .org kvm_ia64_ivt+0x6d00
710 //////////////////////////////////////////////////////////////////////
711 // 0x6d00 Entry 49 (size 16 bundles) Reserved
714 .org kvm_ia64_ivt+0x6e00
715 //////////////////////////////////////////////////////////////////////
716 // 0x6e00 Entry 50 (size 16 bundles) Reserved
719 .org kvm_ia64_ivt+0x6f00
720 /////////////////////////////////////////////////////////////////////
721 // 0x6f00 Entry 51 (size 16 bundles) Reserved
724 .org kvm_ia64_ivt+0x7100
725 ////////////////////////////////////////////////////////////////////
726 // 0x7100 Entry 53 (size 16 bundles) Reserved
729 .org kvm_ia64_ivt+0x7200
730 /////////////////////////////////////////////////////////////////////
731 // 0x7200 Entry 54 (size 16 bundles) Reserved
734 .org kvm_ia64_ivt+0x7300
735 ////////////////////////////////////////////////////////////////////
736 // 0x7300 Entry 55 (size 16 bundles) Reserved
739 .org kvm_ia64_ivt+0x7400
740 ////////////////////////////////////////////////////////////////////
741 // 0x7400 Entry 56 (size 16 bundles) Reserved
744 .org kvm_ia64_ivt+0x7500
745 /////////////////////////////////////////////////////////////////////
746 // 0x7500 Entry 57 (size 16 bundles) Reserved
749 .org kvm_ia64_ivt+0x7600
750 /////////////////////////////////////////////////////////////////////
751 // 0x7600 Entry 58 (size 16 bundles) Reserved
754 .org kvm_ia64_ivt+0x7700
755 ////////////////////////////////////////////////////////////////////
756 // 0x7700 Entry 59 (size 16 bundles) Reserved
759 .org kvm_ia64_ivt+0x7800
760 ////////////////////////////////////////////////////////////////////
761 // 0x7800 Entry 60 (size 16 bundles) Reserved
764 .org kvm_ia64_ivt+0x7900
765 /////////////////////////////////////////////////////////////////////
766 // 0x7900 Entry 61 (size 16 bundles) Reserved
769 .org kvm_ia64_ivt+0x7a00
770 /////////////////////////////////////////////////////////////////////
771 // 0x7a00 Entry 62 (size 16 bundles) Reserved
774 .org kvm_ia64_ivt+0x7b00
775 /////////////////////////////////////////////////////////////////////
776 // 0x7b00 Entry 63 (size 16 bundles) Reserved
779 .org kvm_ia64_ivt+0x7c00
780 ////////////////////////////////////////////////////////////////////
781 // 0x7c00 Entry 64 (size 16 bundles) Reserved
784 .org kvm_ia64_ivt+0x7d00
785 /////////////////////////////////////////////////////////////////////
786 // 0x7d00 Entry 65 (size 16 bundles) Reserved
789 .org kvm_ia64_ivt+0x7e00
790 /////////////////////////////////////////////////////////////////////
791 // 0x7e00 Entry 66 (size 16 bundles) Reserved
794 .org kvm_ia64_ivt+0x7f00
795 ////////////////////////////////////////////////////////////////////
796 // 0x7f00 Entry 67 (size 16 bundles) Reserved
799 .org kvm_ia64_ivt+0x8000
800 // There is no particular reason for this code to be here, other than that
801 // there happens to be space here that would go unused otherwise. If this
802 // fault ever gets "unreserved", simply moved the following code to a more
806 ENTRY(kvm_dtlb_miss_dispatch)
808 KVM_SAVE_MIN_WITH_COVER_R19
809 alloc r14=ar.pfs,0,0,3,0
812 adds r3=8,r2 // set up second base pointer
816 srlz.i // guarantee that interruption collection is on
818 //(p15) ssm psr.i // restore psr.i
819 addl r14=@gprel(ia64_leave_hypervisor_prepare),gp
826 br.call.sptk.many b6=kvm_page_fault
827 END(kvm_dtlb_miss_dispatch)
829 ENTRY(kvm_itlb_miss_dispatch)
831 KVM_SAVE_MIN_WITH_COVER_R19
832 alloc r14=ar.pfs,0,0,3,0
835 adds r3=8,r2 // set up second base pointer
839 srlz.i // guarantee that interruption collection is on
841 //(p15) ssm psr.i // restore psr.i
842 addl r14=@gprel(ia64_leave_hypervisor),gp
848 br.call.sptk.many b6=kvm_page_fault
849 END(kvm_itlb_miss_dispatch)
851 ENTRY(kvm_dispatch_reflection)
855 * r19: intr type (offset into ivt, see ia64_int.h)
856 * r31: contains saved predicates (pr)
858 KVM_SAVE_MIN_WITH_COVER_R19
859 alloc r14=ar.pfs,0,0,5,0
864 adds r3=8,r2 // set up second base pointer
868 srlz.i // guarantee that interruption collection is on
870 //(p15) ssm psr.i // restore psr.i
871 addl r14=@gprel(ia64_leave_hypervisor),gp
877 br.call.sptk.many b6=reflect_interruption
878 END(kvm_dispatch_reflection)
880 ENTRY(kvm_dispatch_virtualization_fault)
881 adds r16 = VMM_VCPU_CAUSE_OFFSET,r21
882 adds r17 = VMM_VCPU_OPCODE_OFFSET,r21
887 KVM_SAVE_MIN_WITH_COVER_R19
889 alloc r14=ar.pfs,0,0,2,0 // now it's safe (must be first in insn group!)
891 adds r3=8,r2 // set up second base pointer
895 srlz.i // guarantee that interruption collection is on
897 //(p15) ssm psr.i // restore psr.i
898 addl r14=@gprel(ia64_leave_hypervisor_prepare),gp
904 adds out1=16,sp //regs
905 br.call.sptk.many b6=kvm_emulate
906 END(kvm_dispatch_virtualization_fault)
909 ENTRY(kvm_dispatch_interrupt)
910 KVM_SAVE_MIN_WITH_COVER_R19 // uses r31; defines r2 and r3
912 alloc r14=ar.pfs,0,0,1,0 // must be first in an insn group
913 //mov out0=cr.ivr // pass cr.ivr as first arg
914 adds r3=8,r2 // set up second base pointer for SAVE_REST
921 addl r14=@gprel(ia64_leave_hypervisor),gp
926 mov out0=r13 // pass pointer to pt_regs as second arg
927 br.call.sptk.many b6=kvm_ia64_handle_irq
928 END(kvm_dispatch_interrupt)
933 GLOBAL_ENTRY(ia64_leave_nested)
936 adds r21=PT(PR)+16,r12
938 lfetch [r21],PT(CR_IPSR)-PT(PR)
939 adds r2=PT(B6)+16,r12
940 adds r3=PT(R16)+16,r12
943 ld8 r28=[r2],8 // load b6
944 adds r29=PT(R24)+16,r12
947 adds r3=PT(AR_CSD)-PT(R16),r3
948 adds r30=PT(AR_CCV)+16,r12
951 ld8 r15=[r30] // load ar.ccv
953 ld8 r29=[r2],16 // load b7
954 ld8 r30=[r3],16 // load ar.csd
956 ld8 r31=[r2],16 // load ar.ssd
960 ld8.fill r10=[r3],PT(R17)-PT(R10)
962 ld8.fill r11=[r2],PT(R18)-PT(R11)
974 // initiate turning off of interrupt and interruption collection
975 invala // invalidate ALAT
993 ld8.fill r31=[r2],PT(F9)-PT(R31)
994 adds r3=PT(F10)-PT(F6),r3
996 ldf.fill f9=[r2],PT(F6)-PT(F9)
997 ldf.fill f10=[r3],PT(F8)-PT(F10)
999 ldf.fill f6=[r2],PT(F7)-PT(F6)
1001 ldf.fill f7=[r2],PT(F11)-PT(F7)
1004 srlz.i // ensure interruption collection is off
1007 bsw.0 // switch back to bank 0 (no stop bit required beforehand...)
1012 adds r16=PT(CR_IPSR)+16,r12
1013 adds r17=PT(CR_IIP)+16,r12
1015 ld8 r29=[r16],16 // load cr.ipsr
1016 ld8 r28=[r17],16 // load cr.iip
1018 ld8 r30=[r16],16 // load cr.ifs
1019 ld8 r25=[r17],16 // load ar.unat
1021 ld8 r26=[r16],16 // load ar.pfs
1022 ld8 r27=[r17],16 // load ar.rsc
1024 // set p9 to indicate that we should restore cr.ifs
1026 ld8 r24=[r16],16 // load ar.rnat (may be garbage)
1027 ld8 r23=[r17],16// load ar.bspstore (may be garbage)
1029 ld8 r31=[r16],16 // load predicates
1030 ld8 r22=[r17],16 // load b0
1032 ld8 r19=[r16],16 // load ar.rsc value for "loadrs"
1033 ld8.fill r1=[r17],16 // load r1
1035 ld8.fill r12=[r16],16
1036 ld8.fill r13=[r17],16
1038 ld8 r20=[r16],16 // ar.fpsr
1039 ld8.fill r15=[r17],16
1041 ld8.fill r14=[r16],16
1046 mov r16=ar.bsp // get existing backing store pointer
1059 END(ia64_leave_nested)
1063 GLOBAL_ENTRY(ia64_leave_hypervisor_prepare)
1065 * work.need_resched etc. mustn't get changed
1066 *by this CPU before it returns to
1068 * user- or fsys-mode, hence we disable interrupts early on:
1070 adds r2 = PT(R4)+16,r12
1071 adds r3 = PT(R5)+16,r12
1072 adds r8 = PT(EML_UNAT)+16,r12
1078 ld8.fill r4=[r2],16 //load r4
1079 ld8.fill r5=[r3],16 //load r5
1081 ld8.fill r6=[r2] //load r6
1082 ld8.fill r7=[r3] //load r7
1084 END(ia64_leave_hypervisor_prepare)
1086 GLOBAL_ENTRY(ia64_leave_hypervisor)
1089 br.call.sptk.many b0=leave_hypervisor_tail
1091 adds r20=PT(PR)+16,r12
1092 adds r8=PT(EML_UNAT)+16,r12
1098 lfetch [r20],PT(CR_IPSR)-PT(PR)
1099 adds r2 = PT(B6)+16,r12
1100 adds r3 = PT(B7)+16,r12
1104 ld8 r24=[r2],16 /* B6 */
1105 ld8 r25=[r3],16 /* B7 */
1107 ld8 r26=[r2],16 /* ar_csd */
1108 ld8 r27=[r3],16 /* ar_ssd */
1118 ld8.fill r10=[r2],PT(R15)-PT(R10)
1119 ld8.fill r11=[r3],PT(R14)-PT(R11)
1121 ld8.fill r15=[r2],PT(R16)-PT(R15)
1122 ld8.fill r14=[r3],PT(R17)-PT(R14)
1124 ld8.fill r16=[r2],16
1125 ld8.fill r17=[r3],16
1127 ld8.fill r18=[r2],16
1128 ld8.fill r19=[r3],16
1130 ld8.fill r20=[r2],16
1131 ld8.fill r21=[r3],16
1133 ld8.fill r22=[r2],16
1134 ld8.fill r23=[r3],16
1136 ld8.fill r24=[r2],16
1137 ld8.fill r25=[r3],16
1139 ld8.fill r26=[r2],16
1140 ld8.fill r27=[r3],16
1142 ld8.fill r28=[r2],16
1143 ld8.fill r29=[r3],16
1145 ld8.fill r30=[r2],PT(F6)-PT(R30)
1146 ld8.fill r31=[r3],PT(F7)-PT(R31)
1149 // initiate turning off of interrupt and interruption collection
1150 invala // invalidate ALAT
1152 srlz.i // ensure interruption collection is off
1156 adds r16 = PT(CR_IPSR)+16,r12
1157 adds r17 = PT(CR_IIP)+16,r12
1158 mov r21=r13 // get current
1160 ld8 r31=[r16],16 // load cr.ipsr
1161 ld8 r30=[r17],16 // load cr.iip
1163 ld8 r29=[r16],16 // load cr.ifs
1164 ld8 r28=[r17],16 // load ar.unat
1166 ld8 r27=[r16],16 // load ar.pfs
1167 ld8 r26=[r17],16 // load ar.rsc
1169 ld8 r25=[r16],16 // load ar.rnat
1170 ld8 r24=[r17],16 // load ar.bspstore
1172 ld8 r23=[r16],16 // load predicates
1173 ld8 r22=[r17],16 // load b0
1175 ld8 r20=[r16],16 // load ar.rsc value for "loadrs"
1176 ld8.fill r1=[r17],16 //load r1
1178 ld8.fill r12=[r16],16 //load r12
1179 ld8.fill r13=[r17],PT(R2)-PT(R13) //load r13
1181 ld8 r19=[r16],PT(R3)-PT(AR_FPSR) //load ar_fpsr
1182 ld8.fill r2=[r17],PT(AR_CCV)-PT(R2) //load r2
1184 ld8.fill r3=[r16] //load r3
1185 ld8 r18=[r17] //load ar_ccv
1194 kvm_dont_preserve_current_frame:
1196 * To prevent leaking bits between the hypervisor and guest domain,
1197 * we must clear the stacked registers in the "invalid" partition here.
1198 * 5 registers/cycle on McKinley).
1200 # define pRecurse p6
1204 alloc loc0=ar.pfs,2,Nregs-2,2,0
1205 shr.u loc1=r18,9 // RNaTslots <= floor(dirtySize / (64*8))
1206 sub r19=r19,r18 // r19 = (physStackedSize + 8) - dirtySize
1208 mov ar.rsc=r20 // load ar.rsc to be used for "loadrs"
1209 shladd in0=loc1,3,r19
1213 kvm_rse_clear_invalid:
1214 alloc loc0=ar.pfs,2,Nregs-2,2,0
1215 cmp.lt pRecurse,p0=Nregs*8,in0
1216 // if more than Nregs regs left to clear, (re)curse
1217 add out0=-Nregs*8,in0
1218 add out1=1,in1 // increment recursion count
1227 (pRecurse) br.call.dptk.few b0=kvm_rse_clear_invalid
1231 cmp.ne pReturn,p0=r0,in1
1232 // if recursion count != 0, we need to do a br.ret
1235 (pReturn) br.ret.dptk.many b0
1240 // loadrs has already been shifted
1241 alloc r16=ar.pfs,0,0,0,0 // drop current register frame
1255 adds r18=VMM_VPD_BASE_OFFSET,r21
1258 adds r17=VMM_VCPU_ISR_OFFSET,r21
1261 adds r19=VMM_VPD_VPSR_OFFSET,r18
1263 ld8 r19=[r19] //vpsr
1265 adds r16= VMM_VCPU_GP_OFFSET,r21
1267 ld8 r16= [r16] // Put gp in r24
1268 movl r24=@gprel(ia64_vmm_entry) // calculate return address
1272 br.sptk.many kvm_vps_sync_write // call the service
1274 END(ia64_leave_hypervisor)
1276 GLOBAL_ENTRY(ia64_vmm_entry)
1288 tbit.nz p1,p2 = r19,IA64_PSR_IC_BIT // p1=vpsr.ic
1289 (p1) br.cond.sptk.few kvm_vps_resume_normal
1290 (p2) br.cond.sptk.many kvm_vps_resume_handler
1297 * extern u64 ia64_call_vsa(u64 proc, u64 arg1, u64 arg2,
1298 * u64 arg3, u64 arg4, u64 arg5,
1299 * u64 arg6, u64 arg7);
1301 * XXX: The currently defined services use only 4 args at the max. The
1302 * rest are not consumed.
1304 GLOBAL_ENTRY(ia64_call_vsa)
1313 alloc pfssave=ar.pfs,4,4,0,0
1315 adds entry=VMM_VCPU_VSA_BASE_OFFSET, r13
1319 mov r25=in1 // copy arguments
1324 tbit.nz p6,p0=psrsave,14 // IA64_PSR_I
1325 tbit.nz p7,p0=psrsave,13 // IA64_PSR_IC
1327 add hostret=2f-1b,hostret // calculate return address
1334 br.cond.sptk b6 // call the service
1336 // Architectural sequence for enabling interrupts if necessary
1352 #define INIT_BSPSTORE ((4<<30)-(12<<20)-0x100)
1354 GLOBAL_ENTRY(vmm_reset_entry)
1355 //set up ipsr, iip, vpd.vpsr, dcr
1356 // For IPSR: it/dt/rt=1, i/ic=1, si=1, vm/bn=1
1357 // For DCR: all bits 0
1361 adds r14=-VMM_PT_REGS_SIZE, r12
1363 movl r6=0x501008826000 // IPSR dt/rt/it:1;i/ic:1, si:1, vm/bn:1
1364 movl r10=0x8000000000000000
1365 adds r16=PT(CR_IIP), r14
1366 adds r20=PT(R1), r14
1381 ld8 r4 = [r16] // Set init iip for first run.
1385 adds r16=VMM_VPD_BASE_OFFSET,r13
1389 adds r19=VMM_VPD_VPSR_OFFSET,r18
1395 br.cond.sptk ia64_vmm_entry
1397 END(vmm_reset_entry)