direct-io.hg

changeset 4740:79b7835ac75d

bitkeeper revision 1.1396 (4277318fhBrWTxIQcLWvjKyF4aX-_w)

Merge
author xenbk@gandalf.hpl.hp.com
date Tue May 03 08:08:47 2005 +0000 (2005-05-03)
parents 8f212349ae57 32475149e395
children 356fb3de6e7b
files .rootkeys BitKeeper/etc/logging_ok freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c freebsd-5.3-xen-sparse/i386-xen/i386-xen/exception.s freebsd-5.3-xen-sparse/i386-xen/i386-xen/genassym.c freebsd-5.3-xen-sparse/i386-xen/i386-xen/local_apic.c freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c freebsd-5.3-xen-sparse/i386-xen/i386-xen/trap.c freebsd-5.3-xen-sparse/i386-xen/include/frame.h freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h freebsd-5.3-xen-sparse/i386-xen/include/pcpu.h freebsd-5.3-xen-sparse/i386-xen/include/ucontext.h freebsd-5.3-xen-sparse/i386-xen/include/xen_intr.h freebsd-5.3-xen-sparse/i386-xen/include/xenpmap.h freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c freebsd-5.3-xen-sparse/kern/kern_shutdown.c linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64 tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c tools/ioemu/iodev/Makefile tools/libxc/Makefile tools/libxc/xc.h tools/libxc/xc_core.c tools/libxc/xc_ptrace.c tools/libxc/xc_ptrace_core.c tools/libxc/xc_vmx_build.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendRoot.py xen/Rules.mk xen/arch/ia64/Makefile xen/arch/ia64/hypercall.c xen/arch/ia64/ivt.S xen/arch/ia64/lib/Makefile xen/arch/ia64/patch/linux-2.6.11/bootmem.h xen/arch/ia64/patch/linux-2.6.11/cpumask.h xen/arch/ia64/patch/linux-2.6.11/current.h xen/arch/ia64/patch/linux-2.6.11/efi.c xen/arch/ia64/patch/linux-2.6.11/entry.S xen/arch/ia64/patch/linux-2.6.11/hardirq.h xen/arch/ia64/patch/linux-2.6.11/head.S xen/arch/ia64/patch/linux-2.6.11/hpsim_irq.c xen/arch/ia64/patch/linux-2.6.11/hpsim_ssc.h xen/arch/ia64/patch/linux-2.6.11/irq.h xen/arch/ia64/patch/linux-2.6.11/irq_ia64.c xen/arch/ia64/patch/linux-2.6.11/ivt.S xen/arch/ia64/patch/linux-2.6.11/kernel-time.c xen/arch/ia64/patch/linux-2.6.11/lds.S xen/arch/ia64/patch/linux-2.6.11/linuxextable.c xen/arch/ia64/patch/linux-2.6.11/linuxhardirq.h xen/arch/ia64/patch/linux-2.6.11/linuxtime.h xen/arch/ia64/patch/linux-2.6.11/mm_contig.c xen/arch/ia64/patch/linux-2.6.11/mmzone.h xen/arch/ia64/patch/linux-2.6.11/page.h xen/arch/ia64/patch/linux-2.6.11/pgalloc.h xen/arch/ia64/patch/linux-2.6.11/sal.h xen/arch/ia64/patch/linux-2.6.11/setup.c xen/arch/ia64/patch/linux-2.6.11/slab.h xen/arch/ia64/patch/linux-2.6.11/swiotlb.c xen/arch/ia64/patch/linux-2.6.11/system.h xen/arch/ia64/patch/linux-2.6.11/time.c xen/arch/ia64/patch/linux-2.6.11/tlb.c xen/arch/ia64/patch/linux-2.6.11/unaligned.c xen/arch/ia64/patch/linux-2.6.11/wait.h xen/arch/ia64/process.c xen/arch/ia64/tools/mkbuildtree xen/arch/ia64/vcpu.c xen/arch/ia64/vhpt.c xen/arch/ia64/xenasm.S xen/arch/ia64/xenirq.c xen/arch/ia64/xenmem.c xen/arch/ia64/xenmisc.c xen/arch/ia64/xensetup.c xen/arch/ia64/xentime.c xen/include/asm-ia64/config.h xen/include/asm-x86/debugger.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/.rootkeys	Fri Apr 29 16:49:15 2005 +0000
     1.2 +++ b/.rootkeys	Tue May 03 08:08:47 2005 +0000
     1.3 @@ -95,7 +95,6 @@ 423e7e8ac9Zkao6o8lF_dpdwz6FoXg freebsd-5
     1.4  423e7e8aVYTynjpZsJxUsFSlIDhpJw freebsd-5.3-xen-sparse/i386-xen/include/cpufunc.h
     1.5  423e7e8avrrUxDugrwq_GJp499DkJw freebsd-5.3-xen-sparse/i386-xen/include/ctrl_if.h
     1.6  423e7e8apY1r9Td-S0eZITNZZbfNTQ freebsd-5.3-xen-sparse/i386-xen/include/evtchn.h
     1.7 -423e7e8aL9DsObEegCwtILrF6SWcAQ freebsd-5.3-xen-sparse/i386-xen/include/frame.h
     1.8  4266317eOVvN00XdcqRfDRFIrbqgvg freebsd-5.3-xen-sparse/i386-xen/include/gnttab.h
     1.9  423e7e8btv8Gojq50ggnP5A1Dkc4kA freebsd-5.3-xen-sparse/i386-xen/include/hypervisor-ifs.h
    1.10  423e7e8buhTLVFLZ33-5s8-UdADSZg freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h
    1.11 @@ -108,7 +107,6 @@ 423e7e8bI1dvek3ZR7BKw7dMkVAEkA freebsd-5
    1.12  423e7e8bVOoPguCLyNj7pil-PT7Vcw freebsd-5.3-xen-sparse/i386-xen/include/segments.h
    1.13  423e7e8c9AuwksRrt0ptRKHnNVWuNQ freebsd-5.3-xen-sparse/i386-xen/include/synch_bitops.h
    1.14  423e7e8csdWimnMBI2HxEDJ30L42kQ freebsd-5.3-xen-sparse/i386-xen/include/trap.h
    1.15 -423e7e8cgVgn9W8sZWwfh_4938fSJQ freebsd-5.3-xen-sparse/i386-xen/include/ucontext.h
    1.16  423e7e8cdsEhPyad2ppDoSiBR4eB9g freebsd-5.3-xen-sparse/i386-xen/include/vmparam.h
    1.17  423e7e8ccGI7kzIlRcEVziGZzm46wg freebsd-5.3-xen-sparse/i386-xen/include/xen-os.h
    1.18  423e7e8cVSqLIOp5vH4ADvAL_MF6Qg freebsd-5.3-xen-sparse/i386-xen/include/xen_intr.h
    1.19 @@ -121,6 +119,7 @@ 423e7e8d4LBg7lzjHtssnxcZwezLJQ freebsd-5
    1.20  423e7e8dVX2QkuzWwB2rtZDxD5Y_-w freebsd-5.3-xen-sparse/i386-xen/xen/misc/npx.c
    1.21  423e7e8d_PdWXjQeRg75twh7TleJhQ freebsd-5.3-xen-sparse/i386-xen/xen/netfront/xn_netfront.c
    1.22  423e7e8dlsc1oCW_ul57w0AHY5jZjQ freebsd-5.3-xen-sparse/kern/kern_fork.c
    1.23 +427346bfHJQldVgD-acDy_2toKMhTA freebsd-5.3-xen-sparse/kern/kern_shutdown.c
    1.24  423e7e8dVDL1WLfbmQWuXMbetYk4jA freebsd-5.3-xen-sparse/mkbuildtree
    1.25  423e7e8dBrOrAbydK6h49bY0VvDgPw freebsd-5.3-xen-sparse/xenfbsd_kernel_build
    1.26  4187ca95_eQN62ugV1zliQcfzXrHnw install.sh
    1.27 @@ -550,6 +549,7 @@ 423d3a7b_HtKYGocoTS1adeOpqDFnw tools/gdb
    1.28  423d3a7b2vJq86I8FbYm6up5BsCwfA tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/configure.in
    1.29  423d3a7bQPownmVb63qOoyq89ebBVA tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/configure.srv
    1.30  423d3a7bHtqhyOgiRWhjWt-S-6wbYg tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
    1.31 +4273458dYPghQKVnj_xu5-fC38CcOg tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c
    1.32  423d3a7b2ENk2IskDZYZ98pe5NsvIA tools/gdb/gdb-6.2.1-xen-sparse/mkbuildtree
    1.33  423d3a7buANO_q-kgxIRffUu7lMnUw tools/gdb/gdbbuild
    1.34  41e2ff6dNPgvIrdIF6dC1azdex1U3A tools/ioemu/Makefile
    1.35 @@ -720,6 +720,7 @@ 41cc934abX-QLXJXW_clV_wRjM0zYg tools/lib
    1.36  3fbba6dc1uU7U3IFeF6A-XEOYF2MkQ tools/libxc/rpm.spec
    1.37  3fbba6dcrNxtygEcgJYAJJ1gCQqfsA tools/libxc/xc.h
    1.38  3fbba6dbEVkVMX0JuDFzap9jeaucGA tools/libxc/xc_bvtsched.c
    1.39 +4273458dyF2_sKA6CFkNJQYb8eY2dA tools/libxc/xc_core.c
    1.40  3fbba6dbasJQV-MVElDC0DGSHMiL5w tools/libxc/xc_domain.c
    1.41  40278d99BLsfUv3qxv0I8C1sClZ0ow tools/libxc/xc_elf.h
    1.42  403e0977Bjsm_e82pwvl9VvaJxh8Gg tools/libxc/xc_evtchn.c
    1.43 @@ -735,6 +736,7 @@ 41cc934aO1m6NxEh_8eDr9bJIMoLFA tools/lib
    1.44  3fbba6dctWRWlFJkYb6hdix2X4WMuw tools/libxc/xc_private.c
    1.45  3fbba6dcbVrG2hPzEzwdeV_UC8kydQ tools/libxc/xc_private.h
    1.46  42337174PxyzzPk62raDiYCIsfStDg tools/libxc/xc_ptrace.c
    1.47 +4273458duzL--nsTfT6e_q6Kfij48g tools/libxc/xc_ptrace_core.c
    1.48  41dde8b0pLfAKMs_L9Uri2hnzHiCRQ tools/libxc/xc_vmx_build.c
    1.49  40e1b09dMYB4ItGCqcMIzirdMd9I-w tools/libxutil/Makefile
    1.50  40e033325Sjqs-_4TuzeUEprP_gYFg tools/libxutil/allocate.c
    1.51 @@ -1100,47 +1102,34 @@ 421098b2ZlaBcyiuuPr3WpzaSDwg6Q xen/arch/
    1.52  4239e98a_HX-FCIcXtVqY0BbrDqVug xen/arch/ia64/hypercall.c
    1.53  421098b3LYAS8xJkQiGP7tiTlyBt0Q xen/arch/ia64/idle0_task.c
    1.54  421098b3ys5GAr4z6_H1jD33oem82g xen/arch/ia64/irq.c
    1.55 +4272a8e4lavI6DrTvqaIhXeR5RuKBw xen/arch/ia64/ivt.S
    1.56  421098b3Heh72KuoVlND3CH6c0B0aA xen/arch/ia64/lib/Makefile
    1.57  421098b3O0MYMUsmYVFy84VV_1gFwQ xen/arch/ia64/mm_init.c
    1.58 -425ae516skiHBZU-Kfwxv2YWXfNRWQ xen/arch/ia64/patch/linux-2.6.11/bootmem.h
    1.59  425ae516maKAsHBJVSzs19cdRgt3Nw xen/arch/ia64/patch/linux-2.6.11/cpumask.h
    1.60 -425ae516rHybgKj6KsvBOE0c_Hruxg xen/arch/ia64/patch/linux-2.6.11/current.h
    1.61  425ae516cGqvMzGtihTEsQXAXsuOhQ xen/arch/ia64/patch/linux-2.6.11/efi.c
    1.62  425ae516Y1A4q4_Kfre3qnDj7lbHJg xen/arch/ia64/patch/linux-2.6.11/entry.S
    1.63 -425ae516RoFheL-Ua-EOtFqmLxoc9g xen/arch/ia64/patch/linux-2.6.11/hardirq.h
    1.64 +425ae516txAP-owjzpTJ7ThfzWR8nw xen/arch/ia64/patch/linux-2.6.11/hardirq.h
    1.65  425ae516PDO1ESDHXHVeDNvlqUfmdQ xen/arch/ia64/patch/linux-2.6.11/head.S
    1.66 -425ae5163aiWdc1IZNsON6ruE2-n9g xen/arch/ia64/patch/linux-2.6.11/hpsim_irq.c
    1.67  425ae516JR7HWvt1zxJ-wLvEWmJGgg xen/arch/ia64/patch/linux-2.6.11/hpsim_ssc.h
    1.68  425ae516AHRNmaVuZjJY-9YjmKRDqg xen/arch/ia64/patch/linux-2.6.11/interrupt.h
    1.69  425ae516U2wFUzrUJQUpy3z38jZHsQ xen/arch/ia64/patch/linux-2.6.11/io.h
    1.70 -425ae516nXL2iTzpziIaSLi3N257qQ xen/arch/ia64/patch/linux-2.6.11/irq.h
    1.71  425ae516GGRmXijPBLC5ii6yWOn0rg xen/arch/ia64/patch/linux-2.6.11/irq_ia64.c
    1.72 -425ae516qQA5dHuIybqfN3nEzM_Zvg xen/arch/ia64/patch/linux-2.6.11/ivt.S
    1.73 -425ae516_UhrTa3Y8wDG7fTgX6pNYA xen/arch/ia64/patch/linux-2.6.11/kernel-time.c
    1.74  425ae516atiECmpn_6nZDw4kkmbJ6g xen/arch/ia64/patch/linux-2.6.11/kregs.h
    1.75 -425ae516lwlYwHG1Jv93kC3tfU5caw xen/arch/ia64/patch/linux-2.6.11/lds.S
    1.76 -425ae516UGTH2xC56DEIlHSrPH4oxg xen/arch/ia64/patch/linux-2.6.11/linuxextable.c
    1.77 -425ae516txAP-owjzpTJ7ThfzWR8nw xen/arch/ia64/patch/linux-2.6.11/linuxhardirq.h
    1.78 -425ae516kNsO5yYnBHvAISdvCkQ2-g xen/arch/ia64/patch/linux-2.6.11/linuxtime.h
    1.79  425ae516Je2zI-Iw30_uGhvUYdlCZQ xen/arch/ia64/patch/linux-2.6.11/mca_asm.h
    1.80  425ae5160-9wHxh0tOnIjavEjt6W0A xen/arch/ia64/patch/linux-2.6.11/minstate.h
    1.81  425ae516N7SaORdbodDr90tmtCzYXw xen/arch/ia64/patch/linux-2.6.11/mm_contig.c
    1.82 -425ae516YcBgoZ3xCTEmhCrgX8CjCA xen/arch/ia64/patch/linux-2.6.11/mmzone.h
    1.83  425ae516WDLrfEA4zr40d00z0VIWPg xen/arch/ia64/patch/linux-2.6.11/page.h
    1.84  425ae516pVQ75NhdItT593SiWI0lbQ xen/arch/ia64/patch/linux-2.6.11/pal.S
    1.85  425ae516QfmjiF_a-mabAXqV8Imzkg xen/arch/ia64/patch/linux-2.6.11/pgalloc.h
    1.86  425ae516EWaNOBEnc1xnphTbRmNZsw xen/arch/ia64/patch/linux-2.6.11/processor.h
    1.87 -425ae5165sks4NwRldZOV_p63fspYw xen/arch/ia64/patch/linux-2.6.11/sal.h
    1.88  425ae516LecDyXlwh3NLBtHZKXmMcA xen/arch/ia64/patch/linux-2.6.11/series
    1.89  425ae516RFiPn2CGkpJ21LM-1lJcQg xen/arch/ia64/patch/linux-2.6.11/setup.c
    1.90 -425ae516-xgihgqPEv-Aq8-9cNoCXg xen/arch/ia64/patch/linux-2.6.11/slab.h
    1.91  425ae516FX_10YaKGMU8Ysf7kkdm_A xen/arch/ia64/patch/linux-2.6.11/swiotlb.c
    1.92  425ae516p4ICTkjqNYEfYFxqULj4dw xen/arch/ia64/patch/linux-2.6.11/system.h
    1.93  425ae516juUB257qrwUdsL9AsswrqQ xen/arch/ia64/patch/linux-2.6.11/time.c
    1.94  425ae5167zQn7zYcgKtDUDX2v-e8mw xen/arch/ia64/patch/linux-2.6.11/tlb.c
    1.95  425ae5162bIl2Dgd19x-FceB4L9oGw xen/arch/ia64/patch/linux-2.6.11/types.h
    1.96  425ae516cFUNY2jHD46bujcF5NJheA xen/arch/ia64/patch/linux-2.6.11/unaligned.c
    1.97 -425ae516viTtlyQjWHf6kBmq8KcwiQ xen/arch/ia64/patch/linux-2.6.11/wait.h
    1.98  421098b39QFMC-1t1r38CA7NxAYBPA xen/arch/ia64/patch/linux-2.6.7/bootmem.h
    1.99  421098b3SIA1vZX9fFUjo1T3o_jMCQ xen/arch/ia64/patch/linux-2.6.7/current.h
   1.100  421098b3ZBl80iPuSeDU_Id5AgZl0w xen/arch/ia64/patch/linux-2.6.7/efi.c
   1.101 @@ -1201,8 +1190,11 @@ 4252ace74lKUPFnO8PmF0Dtpk7Xkng xen/arch/
   1.102  41a26ebc--sjlYZQxmIxyCx3jw70qA xen/arch/ia64/vcpu.c
   1.103  421098b6M2WhsJ_ZMzFamAQcdc5gzw xen/arch/ia64/vhpt.c
   1.104  41a26ebc4jSBGQOuyNIPDST58mNbBw xen/arch/ia64/xenasm.S
   1.105 +4272adaeit9raZ9KnjO_wR4Ii9LJNQ xen/arch/ia64/xenirq.c
   1.106 +427162263zDUiPmTj-lP4eGyXs5eIg xen/arch/ia64/xenmem.c
   1.107  421098b6mWyFPtkhPz9h1LCmKpoCLg xen/arch/ia64/xenmisc.c
   1.108  421098b6lY2JzrV1oFDbrt7XQhtElg xen/arch/ia64/xensetup.c
   1.109 +427664f5eygrc3nEhI3RKf0Y37PzyA xen/arch/ia64/xentime.c
   1.110  3ddb79bcZbRBzT3elFWSX7u6NtMagQ xen/arch/x86/Makefile
   1.111  3ddb79bcBQF85CfLS4i1WGZ4oLLaCA xen/arch/x86/Rules.mk
   1.112  3e5636e5FAYZ5_vQnmgwFJfSdmO5Mw xen/arch/x86/acpi.c
     2.1 --- a/BitKeeper/etc/logging_ok	Fri Apr 29 16:49:15 2005 +0000
     2.2 +++ b/BitKeeper/etc/logging_ok	Tue May 03 08:08:47 2005 +0000
     2.3 @@ -55,6 +55,7 @@ kaf24@scramble.cl.cam.ac.uk
     2.4  kaf24@striker.cl.cam.ac.uk
     2.5  kaf24@viper.(none)
     2.6  katzj@redhat.com
     2.7 +kmacy@netapp.com
     2.8  kmacy@shemp.lab.netapp.com
     2.9  kraxel@bytesex.org
    2.10  laudney@eclipse.(none)
     3.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c	Fri Apr 29 16:49:15 2005 +0000
     3.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/evtchn.c	Tue May 03 08:08:47 2005 +0000
     3.3 @@ -31,8 +31,9 @@ static struct mtx irq_mapping_update_loc
     3.4  static int evtchn_to_irq[NR_EVENT_CHANNELS];
     3.5  static int irq_to_evtchn[NR_IRQS];
     3.6  
     3.7 -/* IRQ <-> VIRQ mapping. */
     3.8 -static int virq_to_irq[NR_VIRQS];
     3.9 +static int virq_to_irq[MAX_VIRT_CPUS][NR_VIRQS];
    3.10 +static int ipi_to_evtchn[MAX_VIRT_CPUS][NR_VIRQS];
    3.11 +
    3.12  
    3.13  /* Reference counts for bindings to IRQs. */
    3.14  static int irq_bindcount[NR_IRQS];
    3.15 @@ -120,7 +121,7 @@ bind_virq_to_irq(int virq)
    3.16  
    3.17      mtx_lock(&irq_mapping_update_lock);
    3.18  
    3.19 -    if ( (irq = virq_to_irq[virq]) == -1 )
    3.20 +    if ( (irq = PCPU_GET(virq_to_irq)[virq]) == -1 )
    3.21      {
    3.22          op.cmd              = EVTCHNOP_bind_virq;
    3.23          op.u.bind_virq.virq = virq;
    3.24 @@ -132,7 +133,7 @@ bind_virq_to_irq(int virq)
    3.25          evtchn_to_irq[evtchn] = irq;
    3.26          irq_to_evtchn[irq]    = evtchn;
    3.27  
    3.28 -        virq_to_irq[virq] = irq;
    3.29 +        PCPU_GET(virq_to_irq)[virq] = irq;
    3.30      }
    3.31  
    3.32      irq_bindcount[irq]++;
    3.33 @@ -146,7 +147,7 @@ void
    3.34  unbind_virq_from_irq(int virq)
    3.35  {
    3.36      evtchn_op_t op;
    3.37 -    int irq    = virq_to_irq[virq];
    3.38 +    int irq    = PCPU_GET(virq_to_irq)[virq];
    3.39      int evtchn = irq_to_evtchn[irq];
    3.40  
    3.41      mtx_lock(&irq_mapping_update_lock);
    3.42 @@ -161,7 +162,64 @@ unbind_virq_from_irq(int virq)
    3.43  
    3.44          evtchn_to_irq[evtchn] = -1;
    3.45          irq_to_evtchn[irq]    = -1;
    3.46 -        virq_to_irq[virq]     = -1;
    3.47 +        PCPU_GET(virq_to_irq)[virq]     = -1;
    3.48 +    }
    3.49 +
    3.50 +    mtx_unlock(&irq_mapping_update_lock);
    3.51 +}
    3.52 +
    3.53 +
    3.54 +int 
    3.55 +bind_ipi_on_cpu_to_irq(int cpu, int ipi)
    3.56 +{
    3.57 +    evtchn_op_t op;
    3.58 +    int evtchn, irq;
    3.59 +
    3.60 +    mtx_lock(&irq_mapping_update_lock);
    3.61 +
    3.62 +    if ( (evtchn = PCPU_GET(ipi_to_evtchn)[ipi]) == 0 )
    3.63 +    {
    3.64 +        op.cmd                 = EVTCHNOP_bind_ipi;
    3.65 +        op.u.bind_ipi.ipi_edom = cpu;
    3.66 +        if ( HYPERVISOR_event_channel_op(&op) != 0 )
    3.67 +            panic("Failed to bind virtual IPI %d on cpu %d\n", ipi, cpu);
    3.68 +        evtchn = op.u.bind_ipi.port;
    3.69 +
    3.70 +        irq = find_unbound_irq();
    3.71 +        evtchn_to_irq[evtchn] = irq;
    3.72 +        irq_to_evtchn[irq]    = evtchn;
    3.73 +
    3.74 +        PCPU_GET(ipi_to_evtchn)[ipi] = evtchn;
    3.75 +    } else
    3.76 +	irq = evtchn_to_irq[evtchn];
    3.77 +
    3.78 +    irq_bindcount[irq]++;
    3.79 +
    3.80 +    mtx_unlock(&irq_mapping_update_lock);
    3.81 +
    3.82 +    return irq;
    3.83 +}
    3.84 +
    3.85 +void 
    3.86 +unbind_ipi_on_cpu_from_irq(int cpu, int ipi)
    3.87 +{
    3.88 +    evtchn_op_t op;
    3.89 +    int evtchn = PCPU_GET(ipi_to_evtchn)[ipi];
    3.90 +    int irq    = irq_to_evtchn[evtchn];
    3.91 +
    3.92 +    mtx_lock(&irq_mapping_update_lock);
    3.93 +
    3.94 +    if ( --irq_bindcount[irq] == 0 )
    3.95 +    {
    3.96 +	op.cmd          = EVTCHNOP_close;
    3.97 +	op.u.close.dom  = DOMID_SELF;
    3.98 +	op.u.close.port = evtchn;
    3.99 +	if ( HYPERVISOR_event_channel_op(&op) != 0 )
   3.100 +	    panic("Failed to unbind virtual IPI %d on cpu %d\n", ipi, cpu);
   3.101 +
   3.102 +        evtchn_to_irq[evtchn] = -1;
   3.103 +        irq_to_evtchn[irq]    = -1;
   3.104 +	PCPU_GET(ipi_to_evtchn)[ipi] = 0;
   3.105      }
   3.106  
   3.107      mtx_unlock(&irq_mapping_update_lock);
   3.108 @@ -464,7 +522,7 @@ void irq_suspend(void)
   3.109      /* Unbind VIRQs from event channels. */
   3.110      for ( virq = 0; virq < NR_VIRQS; virq++ )
   3.111      {
   3.112 -        if ( (irq = virq_to_irq[virq]) == -1 )
   3.113 +        if ( (irq = PCPU_GET(virq_to_irq)[virq]) == -1 )
   3.114              continue;
   3.115          evtchn = irq_to_evtchn[irq];
   3.116  
   3.117 @@ -493,7 +551,7 @@ void irq_resume(void)
   3.118  
   3.119      for ( virq = 0; virq < NR_VIRQS; virq++ )
   3.120      {
   3.121 -        if ( (irq = virq_to_irq[virq]) == -1 )
   3.122 +        if ( (irq = PCPU_GET(virq_to_irq)[virq]) == -1 )
   3.123              continue;
   3.124  
   3.125          /* Get a new binding from Xen. */
   3.126 @@ -512,6 +570,20 @@ void irq_resume(void)
   3.127      }
   3.128  }
   3.129  
   3.130 +void
   3.131 +ap_evtchn_init(int cpu)
   3.132 +{
   3.133 +    int i;
   3.134 +
   3.135 +    /* XXX -- expedience hack */
   3.136 +    PCPU_SET(virq_to_irq, (int  *)&virq_to_irq[cpu]);
   3.137 +    PCPU_SET(ipi_to_evtchn, (int *)&ipi_to_evtchn[cpu]);
   3.138 +
   3.139 +    /* No VIRQ -> IRQ mappings. */
   3.140 +    for ( i = 0; i < NR_VIRQS; i++ )
   3.141 +        PCPU_GET(virq_to_irq)[i] = -1;
   3.142 +}
   3.143 +
   3.144  static void 
   3.145  evtchn_init(void *dummy __unused)
   3.146  {
   3.147 @@ -527,9 +599,13 @@ evtchn_init(void *dummy __unused)
   3.148       */
   3.149      mtx_init(&irq_mapping_update_lock, "xp", NULL, MTX_DEF);
   3.150  
   3.151 +    /* XXX -- expedience hack */
   3.152 +    PCPU_SET(virq_to_irq, (int *)&virq_to_irq[0]);
   3.153 +    PCPU_SET(ipi_to_evtchn, (int *)&ipi_to_evtchn[0]);
   3.154 +
   3.155      /* No VIRQ -> IRQ mappings. */
   3.156      for ( i = 0; i < NR_VIRQS; i++ )
   3.157 -        virq_to_irq[i] = -1;
   3.158 +        PCPU_GET(virq_to_irq)[i] = -1;
   3.159  
   3.160      /* No event-channel -> IRQ mappings. */
   3.161      for ( i = 0; i < NR_EVENT_CHANNELS; i++ )
     4.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/exception.s	Fri Apr 29 16:49:15 2005 +0000
     4.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/exception.s	Tue May 03 08:08:47 2005 +0000
     4.3 @@ -91,47 +91,52 @@ MCOUNT_LABEL(user)
     4.4  MCOUNT_LABEL(btrap)
     4.5  
     4.6  IDTVEC(div)
     4.7 -	pushl $0; pushl $0; TRAP(T_DIVIDE)
     4.8 +	pushl $0; TRAP(T_DIVIDE)
     4.9  IDTVEC(dbg)
    4.10 -	pushl $0; pushl $0; TRAP(T_TRCTRAP)
    4.11 +	pushl $0; TRAP(T_TRCTRAP)
    4.12  IDTVEC(nmi)
    4.13 -	pushl $0; pushl $0; TRAP(T_NMI)
    4.14 +	pushl $0; TRAP(T_NMI)
    4.15  IDTVEC(bpt)
    4.16 -	pushl $0; pushl $0; TRAP(T_BPTFLT)
    4.17 +	pushl $0; TRAP(T_BPTFLT)
    4.18  IDTVEC(ofl)
    4.19 -	pushl $0; pushl $0; TRAP(T_OFLOW)
    4.20 +	pushl $0; TRAP(T_OFLOW)
    4.21  IDTVEC(bnd)
    4.22 -	pushl $0; pushl $0; TRAP(T_BOUND)
    4.23 +	pushl $0; TRAP(T_BOUND)
    4.24  IDTVEC(ill)
    4.25 -	pushl $0; pushl $0; TRAP(T_PRIVINFLT)
    4.26 +	pushl $0; TRAP(T_PRIVINFLT)
    4.27  IDTVEC(dna)
    4.28 -	pushl $0; pushl $0; TRAP(T_DNA)
    4.29 +	pushl $0; TRAP(T_DNA)
    4.30  IDTVEC(fpusegm)
    4.31 -	pushl $0; pushl $0; TRAP(T_FPOPFLT)
    4.32 +	pushl $0; TRAP(T_FPOPFLT)
    4.33  IDTVEC(tss)
    4.34 -	pushl $0; TRAP(T_TSSFLT)
    4.35 +	TRAP(T_TSSFLT)
    4.36  IDTVEC(missing)
    4.37 -	pushl $0; TRAP(T_SEGNPFLT)
    4.38 +	TRAP(T_SEGNPFLT)
    4.39  IDTVEC(stk)
    4.40 -	pushl $0; TRAP(T_STKFLT)
    4.41 +	TRAP(T_STKFLT)
    4.42  IDTVEC(prot)
    4.43 -	pushl $0; TRAP(T_PROTFLT)
    4.44 +	TRAP(T_PROTFLT)
    4.45  IDTVEC(page)
    4.46 +	pushl %eax 
    4.47 +	movl  4(%esp),%eax
    4.48 +	movl  %eax,-44(%esp)	# move cr2 after trap frame
    4.49 +	popl %eax
    4.50 +	addl $4,%esp
    4.51  	TRAP(T_PAGEFLT)
    4.52  IDTVEC(mchk)
    4.53 -	pushl $0; pushl $0; TRAP(T_MCHK)
    4.54 +	pushl $0; TRAP(T_MCHK)
    4.55  IDTVEC(rsvd)
    4.56 -	pushl $0; pushl $0; TRAP(T_RESERVED)
    4.57 +	pushl $0; TRAP(T_RESERVED)
    4.58  IDTVEC(fpu)
    4.59 -	pushl $0; pushl $0; TRAP(T_ARITHTRAP)
    4.60 +	pushl $0; TRAP(T_ARITHTRAP)
    4.61  IDTVEC(align)
    4.62 -	pushl $0; TRAP(T_ALIGNFLT)
    4.63 +	TRAP(T_ALIGNFLT)
    4.64  
    4.65  IDTVEC(xmm)
    4.66 -	pushl $0; pushl $0; TRAP(T_XMMFLT)
    4.67 +	pushl $0; TRAP(T_XMMFLT)
    4.68  
    4.69  IDTVEC(hypervisor_callback)
    4.70 -	 pushl $T_HYPCALLBACK;  pushl %eax; TRAP(T_HYPCALLBACK)
    4.71 +	pushl %eax; TRAP(T_HYPCALLBACK)
    4.72  
    4.73  hypervisor_callback_pending:
    4.74  	movl	$T_HYPCALLBACK,TF_TRAPNO(%esp)
    4.75 @@ -161,6 +166,12 @@ alltraps_with_regs_pushed:
    4.76  	movl	$KPSEL,%eax
    4.77  	movl	%eax,%fs
    4.78  	FAKE_MCOUNT(TF_EIP(%esp))
    4.79 +save_cr2:
    4.80 +	movl	TF_TRAPNO(%esp),%eax
    4.81 +	cmpl	$T_PAGEFLT,%eax
    4.82 +	jne	calltrap
    4.83 +	movl	-4(%esp),%eax
    4.84 +	movl	%eax,PCPU(CR2)
    4.85  calltrap:
    4.86  	movl	TF_EIP(%esp),%eax
    4.87  	cmpl	$scrit,%eax
    4.88 @@ -217,8 +228,7 @@ IDTVEC(lcall_syscall)
    4.89  	SUPERALIGN_TEXT
    4.90  IDTVEC(int0x80_syscall)
    4.91  	pushl	$2			/* sizeof "int 0x80" */
    4.92 -	pushl	$0xCAFE
    4.93 -	pushl	$0xDEAD
    4.94 +	pushl	$0xBEEF
    4.95  	pushal
    4.96  	pushl	%ds
    4.97  	pushl	%es
    4.98 @@ -324,7 +334,7 @@ doreti_popl_es:
    4.99  doreti_popl_ds:
   4.100  	popl	%ds
   4.101  	POPA
   4.102 -	addl	$12,%esp
   4.103 +	addl	$8,%esp
   4.104  	.globl	doreti_iret
   4.105  doreti_iret:
   4.106  	iret
   4.107 @@ -341,7 +351,7 @@ ecrit:
   4.108  	ALIGN_TEXT
   4.109  	.globl	doreti_iret_fault
   4.110  doreti_iret_fault:
   4.111 -	subl	$12,%esp
   4.112 +	subl	$8,%esp
   4.113  	pushal
   4.114  	pushl	%ds
   4.115  	.globl	doreti_popl_ds_fault
   4.116 @@ -376,7 +386,7 @@ critical_region_fixup:
   4.117          movl  %esp,%esi
   4.118          add  %eax,%esi        # %esi points at end of src region
   4.119          movl  %esp,%edi
   4.120 -        add  $0x44,%edi       # %edi points at end of dst region
   4.121 +        add  $0x40,%edi       # %edi points at end of dst region
   4.122          movl  %eax,%ecx
   4.123          shr  $2,%ecx          # convert bytes to words
   4.124          je   16f              # skip loop if nothing to copy
   4.125 @@ -403,8 +413,8 @@ critical_fixup_table:
   4.126  .byte   0x20	                        #pop    %edx
   4.127  .byte   0x24	                        #pop    %ecx
   4.128  .byte   0x28	                        #pop    %eax
   4.129 -.byte   0x2c,0x2c,0x2c                  #add    $0xc,%esp
   4.130 -.byte   0x38	                        #iret   
   4.131 +.byte   0x2c,0x2c,0x2c                  #add    $0x8,%esp
   4.132 +.byte   0x34	                        #iret   
   4.133  
   4.134  	
   4.135  /* # Hypervisor uses this for application faults while it executes.*/
   4.136 @@ -412,17 +422,17 @@ ENTRY(failsafe_callback)
   4.137  	pushal
   4.138  	call xen_failsafe_handler
   4.139  /*#	call install_safe_pf_handler */
   4.140 -        movl 32(%esp),%ebx
   4.141 +        movl 28(%esp),%ebx
   4.142  1:      movl %ebx,%ds
   4.143 -        movl 36(%esp),%ebx
   4.144 +        movl 32(%esp),%ebx
   4.145  2:      movl %ebx,%es
   4.146 -        movl 40(%esp),%ebx
   4.147 +        movl 36(%esp),%ebx
   4.148  3:      movl %ebx,%fs
   4.149 -        movl 44(%esp),%ebx
   4.150 +        movl 40(%esp),%ebx
   4.151  4:      movl %ebx,%gs
   4.152  /*#        call install_normal_pf_handler */
   4.153  	popal
   4.154 -	addl $16,%esp
   4.155 +	addl $12,%esp
   4.156  	iret
   4.157  
   4.158  
     5.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/genassym.c	Fri Apr 29 16:49:15 2005 +0000
     5.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/genassym.c	Tue May 03 08:08:47 2005 +0000
     5.3 @@ -200,8 +200,7 @@ ASSYM(PC_TSS_GDT, offsetof(struct pcpu, 
     5.4  ASSYM(PC_CURRENTLDT, offsetof(struct pcpu, pc_currentldt));
     5.5  ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
     5.6  ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
     5.7 -ASSYM(PC_TRAP_NESTING, offsetof(struct pcpu, pc_trap_nesting));
     5.8 -
     5.9 +ASSYM(PC_CR2, offsetof(struct pcpu, pc_cr2));
    5.10  ASSYM(PC_CR3, offsetof(struct pcpu, pc_pdir));
    5.11  
    5.12  #ifdef DEV_APIC
     6.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/local_apic.c	Fri Apr 29 16:49:15 2005 +0000
     6.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/local_apic.c	Tue May 03 08:08:47 2005 +0000
     6.3 @@ -545,7 +545,6 @@ apic_register_enumerator(struct apic_enu
     6.4  static void
     6.5  apic_init(void *dummy __unused)
     6.6  {
     6.7 -	struct apic_enumerator *enumerator;
     6.8  	uint64_t apic_base;
     6.9  	int retval, best;
    6.10  
    6.11 @@ -560,6 +559,7 @@ apic_init(void *dummy __unused)
    6.12  	/* First, probe all the enumerators to find the best match. */
    6.13  	best_enum = NULL;
    6.14  	best = 0;
    6.15 +#ifndef XEN
    6.16  	SLIST_FOREACH(enumerator, &enumerators, apic_next) {
    6.17  		retval = enumerator->apic_probe();
    6.18  		if (retval > 0)
    6.19 @@ -569,6 +569,7 @@ apic_init(void *dummy __unused)
    6.20  			best = retval;
    6.21  		}
    6.22  	}
    6.23 +#endif
    6.24  	if (best_enum == NULL) {
    6.25  		if (bootverbose)
    6.26  			printf("APIC: Could not find any APICs.\n");
     7.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c	Fri Apr 29 16:49:15 2005 +0000
     7.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/machdep.c	Tue May 03 08:08:47 2005 +0000
     7.3 @@ -1386,6 +1386,7 @@ initvalues(start_info_t *startinfo)
     7.4  { 
     7.5      int i;
     7.6      vm_paddr_t pdir_shadow_ma, KPTphys;
     7.7 +    vm_offset_t *pdir_shadow;
     7.8  #ifdef WRITABLE_PAGETABLES
     7.9      printk("using writable pagetables\n");
    7.10      HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
    7.11 @@ -1424,6 +1425,27 @@ initvalues(start_info_t *startinfo)
    7.12      /* allocate page for ldt */
    7.13      ldt = (union descriptor *)(KERNBASE + (tmpindex << PAGE_SHIFT));
    7.14      tmpindex++; 
    7.15 +
    7.16 +    /* initialize page directory shadow page */
    7.17 +    pdir_shadow = (vm_offset_t *)(KERNBASE + (tmpindex << PAGE_SHIFT));
    7.18 +    i686_pagezero(pdir_shadow);
    7.19 +    pdir_shadow_ma = xpmap_ptom(tmpindex << PAGE_SHIFT);
    7.20 +    PT_SET_MA(pdir_shadow, pdir_shadow_ma | PG_V | PG_A);
    7.21 +    tmpindex++;
    7.22 +
    7.23 +    /* setup shadow mapping first so vtomach will work */
    7.24 +    xen_pt_pin((vm_paddr_t)pdir_shadow_ma);
    7.25 +    xen_queue_pt_update((vm_paddr_t)(IdlePTD + PTDPTDI), 
    7.26 +			pdir_shadow_ma | PG_V | PG_A | PG_RW | PG_M);
    7.27 +    xen_queue_pt_update(pdir_shadow_ma + PTDPTDI*sizeof(vm_paddr_t), 
    7.28 +			((vm_paddr_t)IdlePTD) | PG_V | PG_A);
    7.29 +    xen_queue_pt_update(pdir_shadow_ma + KPTDI*sizeof(vm_paddr_t), 
    7.30 +			KPTphys | PG_V | PG_A);
    7.31 +
    7.32 +    xen_flush_queue();
    7.33 +    /* allocate remainder of NKPT pages */
    7.34 +
    7.35 +
    7.36  #ifdef SMP
    7.37      /* allocate cpu0 private page */
    7.38      cpu0prvpage = (KERNBASE + (tmpindex << PAGE_SHIFT));
    7.39 @@ -1458,18 +1480,6 @@ initvalues(start_info_t *startinfo)
    7.40  	xen_queue_pt_update(KPTphys + i*sizeof(vm_paddr_t), 0);
    7.41      xen_flush_queue();
    7.42      
    7.43 -    pdir_shadow_ma = xpmap_ptom(tmpindex << PAGE_SHIFT);
    7.44 -    tmpindex++;
    7.45 -
    7.46 -    /* setup shadow mapping first so vtomach will work */
    7.47 -    xen_pt_pin((vm_paddr_t)pdir_shadow_ma);
    7.48 -    xen_queue_pt_update((vm_paddr_t)(IdlePTD + PTDPTDI), 
    7.49 -			pdir_shadow_ma | PG_V | PG_A | PG_RW | PG_M);
    7.50 -    xen_queue_pt_update(pdir_shadow_ma + PTDPTDI*sizeof(vm_paddr_t), 
    7.51 -			((vm_paddr_t)IdlePTD) | PG_V | PG_A);
    7.52 -    xen_queue_pt_update(pdir_shadow_ma + KPTDI*sizeof(vm_paddr_t), 
    7.53 -			KPTphys | PG_V | PG_A);
    7.54 -
    7.55      /* allocate remainder of NKPT pages */
    7.56      for (i = 0; i < NKPT-1; i++, tmpindex++) {
    7.57  	xen_queue_pt_update((vm_paddr_t)(IdlePTD + KPTDI + i + 1), 
     8.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/trap.c	Fri Apr 29 16:49:15 2005 +0000
     8.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/trap.c	Tue May 03 08:08:47 2005 +0000
     8.3 @@ -181,11 +181,6 @@ trap(struct trapframe frame)
     8.4  	u_int sticks = 0;
     8.5  	int i = 0, ucode = 0, type, code;
     8.6  	vm_offset_t eva;
     8.7 -#ifdef STACK_DEBUGGING
     8.8 -	int nesting, current_sp;
     8.9 -	static int prev_csp = 0, prev_ssp = 0;
    8.10 -	nesting = PCPU_GET(trap_nesting);
    8.11 -#endif
    8.12  
    8.13  #ifdef POWERFAIL_NMI
    8.14  	static int lastalert = 0;
    8.15 @@ -227,7 +222,7 @@ trap(struct trapframe frame)
    8.16  		 * kernel can print out a useful trap message and even get
    8.17  		 * to the debugger.
    8.18  		 */
    8.19 -	        eva = frame.tf_cr2;
    8.20 +	        eva = PCPU_GET(cr2);
    8.21  
    8.22  		if (td->td_critnest != 0)			
    8.23  		    trap_fatal(&frame, eva);
    8.24 @@ -613,9 +608,6 @@ user:
    8.25  	mtx_assert(&Giant, MA_NOTOWNED);
    8.26  userout:
    8.27  out:
    8.28 -#ifdef STACK_DEBUGGING 
    8.29 -	PCPU_SET(trap_nesting, nesting);
    8.30 -#endif
    8.31  	return;
    8.32  }
    8.33  
     9.1 --- a/freebsd-5.3-xen-sparse/i386-xen/include/frame.h	Fri Apr 29 16:49:15 2005 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,129 +0,0 @@
     9.4 -/*-
     9.5 - * Copyright (c) 1990 The Regents of the University of California.
     9.6 - * All rights reserved.
     9.7 - *
     9.8 - * This code is derived from software contributed to Berkeley by
     9.9 - * William Jolitz.
    9.10 - *
    9.11 - * Redistribution and use in source and binary forms, with or without
    9.12 - * modification, are permitted provided that the following conditions
    9.13 - * are met:
    9.14 - * 1. Redistributions of source code must retain the above copyright
    9.15 - *    notice, this list of conditions and the following disclaimer.
    9.16 - * 2. Redistributions in binary form must reproduce the above copyright
    9.17 - *    notice, this list of conditions and the following disclaimer in the
    9.18 - *    documentation and/or other materials provided with the distribution.
    9.19 - * 3. All advertising materials mentioning features or use of this software
    9.20 - *    must display the following acknowledgement:
    9.21 - *	This product includes software developed by the University of
    9.22 - *	California, Berkeley and its contributors.
    9.23 - * 4. Neither the name of the University nor the names of its contributors
    9.24 - *    may be used to endorse or promote products derived from this software
    9.25 - *    without specific prior written permission.
    9.26 - *
    9.27 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    9.28 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    9.29 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    9.30 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    9.31 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    9.32 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    9.33 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    9.34 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    9.35 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    9.36 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    9.37 - * SUCH DAMAGE.
    9.38 - *
    9.39 - *	from: @(#)frame.h	5.2 (Berkeley) 1/18/91
    9.40 - * $FreeBSD: src/sys/i386/include/frame.h,v 1.23 2003/07/22 08:11:15 peter Exp $
    9.41 - */
    9.42 -
    9.43 -#ifndef _MACHINE_FRAME_H_
    9.44 -#define _MACHINE_FRAME_H_ 1
    9.45 -
    9.46 -/*
    9.47 - * System stack frames.
    9.48 - */
    9.49 -
    9.50 -/*
    9.51 - * Exception/Trap Stack Frame
    9.52 - */
    9.53 -
    9.54 -struct trapframe {
    9.55 -	int	tf_fs;
    9.56 -	int	tf_es;
    9.57 -	int	tf_ds;
    9.58 -	int	tf_edi;
    9.59 -	int	tf_esi;
    9.60 -	int	tf_ebp;
    9.61 -	int	tf_isp;
    9.62 -	int	tf_ebx;
    9.63 -	int	tf_edx;
    9.64 -	int	tf_ecx;
    9.65 -	int	tf_eax;
    9.66 -	int	tf_trapno;
    9.67 -        int     tf_cr2; 
    9.68 -	/* below portion defined in 386 hardware */
    9.69 -	int	tf_err;
    9.70 -	int	tf_eip;
    9.71 -	int	tf_cs;
    9.72 -	int	tf_eflags;
    9.73 -	/* below only when crossing rings (e.g. user to kernel) */
    9.74 -	int	tf_esp;
    9.75 -	int	tf_ss;
    9.76 -};
    9.77 -
    9.78 -/* Interrupt stack frame */
    9.79 -
    9.80 -struct intrframe {
    9.81 -	int	if_fs;
    9.82 -	int	if_es;
    9.83 -	int	if_ds;
    9.84 -	int	if_edi;
    9.85 -	int	if_esi;
    9.86 -	int	if_ebp;
    9.87 -	int	:32;
    9.88 -	int	if_ebx;
    9.89 -	int	if_edx;
    9.90 -	int	if_ecx;
    9.91 -	int	if_eax;
    9.92 -	int	:32;		/* for compat with trap frame - trapno */
    9.93 -        int     if_vec;         /* cr2 in trap frame */
    9.94 -	int	:32;		/* for compat with trap frame - err */
    9.95 -	/* below portion defined in 386 hardware */
    9.96 -	int	if_eip;
    9.97 -	int	if_cs;
    9.98 -	int	if_eflags;
    9.99 -	/* below only when crossing rings (e.g. user to kernel) */
   9.100 -	int	if_esp;
   9.101 -	int	if_ss;
   9.102 -};
   9.103 -
   9.104 -/* frame of clock (same as interrupt frame) */
   9.105 -
   9.106 -struct clockframe {
   9.107 -	int	cf_fs;
   9.108 -	int	cf_es;
   9.109 -	int	cf_ds;
   9.110 -	int	cf_edi;
   9.111 -	int	cf_esi;
   9.112 -	int	cf_ebp;
   9.113 -	int	:32;
   9.114 -	int	cf_ebx;
   9.115 -	int	cf_edx;
   9.116 -	int	cf_ecx;
   9.117 -	int	cf_eax;
   9.118 -	int	:32;		/* for compat with trap frame - trapno */
   9.119 -        int     cf_vec;         /* cr2 in trap frame */ 
   9.120 -	int	:32;		/* for compat with trap frame - err */
   9.121 -	/* below portion defined in 386 hardware */
   9.122 -	int	cf_eip;
   9.123 -	int	cf_cs;
   9.124 -	int	cf_eflags;
   9.125 -	/* below only when crossing rings (e.g. user to kernel) */
   9.126 -	int	cf_esp;
   9.127 -	int	cf_ss;
   9.128 -};
   9.129 -
   9.130 -#define	INTR_TO_TRAPFRAME(frame) ((struct trapframe *)&(frame)->if_fs)
   9.131 -
   9.132 -#endif /* _MACHINE_FRAME_H_ */
    10.1 --- a/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h	Fri Apr 29 16:49:15 2005 +0000
    10.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h	Tue May 03 08:08:47 2005 +0000
    10.3 @@ -22,6 +22,7 @@ extern start_info_t *xen_start_info;
    10.4   * be MACHINE addresses.
    10.5   */
    10.6  
    10.7 +static inline void HYPERVISOR_crash(void) __dead2;
    10.8  
    10.9  void MULTICALL_flush_page_update_queue(void);
   10.10  
   10.11 @@ -201,6 +202,23 @@ HYPERVISOR_suspend(unsigned long srec)
   10.12      return ret;
   10.13  }
   10.14  
   10.15 +
   10.16 +static inline void
   10.17 +HYPERVISOR_crash(void) 
   10.18 +{
   10.19 +    int ret;
   10.20 +    unsigned long ign1;
   10.21 +    __asm__ __volatile__ (
   10.22 +        TRAP_INSTR
   10.23 +        : "=a" (ret), "=b" (ign1)
   10.24 +        : "0" (__HYPERVISOR_sched_op),
   10.25 +	"1" (SCHEDOP_shutdown | (SHUTDOWN_crash << SCHEDOP_reasonshift))
   10.26 +        : "memory" );
   10.27 +
   10.28 +	for (;;) ; /* eliminate noreturn error */ 
   10.29 +
   10.30 +}
   10.31 +
   10.32  static inline long 
   10.33  HYPERVISOR_set_timer_op(uint64_t timeout)
   10.34  {
    11.1 --- a/freebsd-5.3-xen-sparse/i386-xen/include/pcpu.h	Fri Apr 29 16:49:15 2005 +0000
    11.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/include/pcpu.h	Tue May 03 08:08:47 2005 +0000
    11.3 @@ -50,8 +50,9 @@
    11.4  	int	pc_currentldt;						\
    11.5  	u_int	pc_acpi_id;						\
    11.6  	u_int	pc_apic_id;                                             \
    11.7 -        u_int   pc_faultaddr;                                           \
    11.8 -        u_int   pc_trap_nesting;                                        \
    11.9 +        int     *pc_ipi_to_evtchn;                                      \
   11.10 +        int     *pc_virq_to_irq;                                        \
   11.11 +        u_int   pc_cr2;                                                 \
   11.12          u_int   pc_pdir                                        
   11.13  
   11.14  #if defined(lint)
    12.1 --- a/freebsd-5.3-xen-sparse/i386-xen/include/ucontext.h	Fri Apr 29 16:49:15 2005 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,105 +0,0 @@
    12.4 -/*-
    12.5 - * Copyright (c) 1999 Marcel Moolenaar
    12.6 - * All rights reserved.
    12.7 - *
    12.8 - * Redistribution and use in source and binary forms, with or without
    12.9 - * modification, are permitted provided that the following conditions
   12.10 - * are met:
   12.11 - * 1. Redistributions of source code must retain the above copyright
   12.12 - *    notice, this list of conditions and the following disclaimer 
   12.13 - *    in this position and unchanged.
   12.14 - * 2. Redistributions in binary form must reproduce the above copyright
   12.15 - *    notice, this list of conditions and the following disclaimer in the
   12.16 - *    documentation and/or other materials provided with the distribution.
   12.17 - * 3. The name of the author may not be used to endorse or promote products
   12.18 - *    derived from this software without specific prior written permission.
   12.19 - *
   12.20 - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   12.21 - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   12.22 - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   12.23 - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   12.24 - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   12.25 - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   12.26 - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   12.27 - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   12.28 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   12.29 - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   12.30 - *
   12.31 - * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.10 2002/12/02 19:58:55 deischen Exp $
   12.32 - */
   12.33 -
   12.34 -#ifndef _MACHINE_UCONTEXT_H_
   12.35 -#define	_MACHINE_UCONTEXT_H_
   12.36 -
   12.37 -typedef struct __mcontext {
   12.38 -	/*
   12.39 -	 * The first 20 fields must match the definition of
   12.40 -	 * sigcontext. So that we can support sigcontext
   12.41 -	 * and ucontext_t at the same time.
   12.42 -	 */
   12.43 -	int	mc_onstack;		/* XXX - sigcontext compat. */
   12.44 -	int	mc_gs;			/* machine state (struct trapframe) */
   12.45 -	int	mc_fs;
   12.46 -	int	mc_es;
   12.47 -	int	mc_ds;
   12.48 -	int	mc_edi;
   12.49 -	int	mc_esi;
   12.50 -	int	mc_ebp;
   12.51 -	int	mc_isp;
   12.52 -	int	mc_ebx;
   12.53 -	int	mc_edx;
   12.54 -	int	mc_ecx;
   12.55 -	int	mc_eax;
   12.56 -	int	mc_trapno;
   12.57 -        int     mc_cr2;
   12.58 -	int	mc_err;
   12.59 -	int	mc_eip;
   12.60 -	int	mc_cs;
   12.61 -	int	mc_eflags;
   12.62 -	int	mc_esp;
   12.63 -	int	mc_ss;
   12.64 -
   12.65 -	int	mc_len;			/* sizeof(mcontext_t) */
   12.66 -#define	_MC_FPFMT_NODEV		0x10000	/* device not present or configured */
   12.67 -#define	_MC_FPFMT_387		0x10001
   12.68 -#define	_MC_FPFMT_XMM		0x10002
   12.69 -	int	mc_fpformat;
   12.70 -#define	_MC_FPOWNED_NONE	0x20000	/* FP state not used */
   12.71 -#define	_MC_FPOWNED_FPU		0x20001	/* FP state came from FPU */
   12.72 -#define	_MC_FPOWNED_PCB		0x20002	/* FP state came from PCB */
   12.73 -	int	mc_ownedfp;
   12.74 -	/*
   12.75 -	 * See <machine/npx.h> for the internals of mc_fpstate[].
   12.76 -	 */
   12.77 -	int	mc_fpstate[128] __aligned(16);
   12.78 -	int	mc_spare2[8];
   12.79 -} mcontext_t;
   12.80 -
   12.81 -#if defined(_KERNEL) && defined(COMPAT_FREEBSD4)
   12.82 -struct mcontext4 {
   12.83 -	int	mc_onstack;		/* XXX - sigcontext compat. */
   12.84 -	int	mc_gs;			/* machine state (struct trapframe) */
   12.85 -	int	mc_fs;
   12.86 -	int	mc_es;
   12.87 -	int	mc_ds;
   12.88 -	int	mc_edi;
   12.89 -	int	mc_esi;
   12.90 -	int	mc_ebp;
   12.91 -	int	mc_isp;
   12.92 -	int	mc_ebx;
   12.93 -	int	mc_edx;
   12.94 -	int	mc_ecx;
   12.95 -	int	mc_eax;
   12.96 -	int	mc_trapno;
   12.97 -	int	mc_err;
   12.98 -	int	mc_eip;
   12.99 -	int	mc_cs;
  12.100 -	int	mc_eflags;
  12.101 -	int	mc_esp;			/* machine state */
  12.102 -	int	mc_ss;
  12.103 -	int	mc_fpregs[28];		/* env87 + fpacc87 + u_long */
  12.104 -	int	__spare__[17];
  12.105 -};
  12.106 -#endif
  12.107 -
  12.108 -#endif /* !_MACHINE_UCONTEXT_H_ */
    13.1 --- a/freebsd-5.3-xen-sparse/i386-xen/include/xen_intr.h	Fri Apr 29 16:49:15 2005 +0000
    13.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/include/xen_intr.h	Tue May 03 08:08:47 2005 +0000
    13.3 @@ -31,6 +31,9 @@ extern int  bind_virq_to_irq(int virq);
    13.4  extern void unbind_virq_from_irq(int virq);
    13.5  extern int  bind_evtchn_to_irq(int evtchn);
    13.6  extern void unbind_evtchn_from_irq(int evtchn);
    13.7 +extern int bind_ipi_on_cpu_to_irq(int cpu, int ipi);
    13.8 +extern void unbind_ipi_on_cpu_from_irq(int cpu, int ipi);
    13.9 +extern void ap_evtchn_init(int cpu);
   13.10  
   13.11  static __inline__ int irq_cannonicalize(int irq)
   13.12  {
    14.1 --- a/freebsd-5.3-xen-sparse/i386-xen/include/xenpmap.h	Fri Apr 29 16:49:15 2005 +0000
    14.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/include/xenpmap.h	Tue May 03 08:08:47 2005 +0000
    14.3 @@ -59,7 +59,9 @@ void pmap_ref(pt_entry_t *pte, unsigned 
    14.4  #define PMAP_DEC_REF_PAGE(a)
    14.5  #endif
    14.6  
    14.7 +#if 0
    14.8  #define WRITABLE_PAGETABLES
    14.9 +#endif
   14.10  #define ALWAYS_SYNC 0
   14.11  
   14.12  #ifdef PT_DEBUG
   14.13 @@ -118,18 +120,18 @@ void pd_set(struct pmap *pmap, vm_paddr_
   14.14  
   14.15  #define PT_SET_VA(_ptp,_npte,sync) do {				\
   14.16          PMAP_REF((_ptp), xpmap_ptom(_npte));                    \
   14.17 -	xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), 	\
   14.18 +	xen_queue_pt_update(vtomach(_ptp), 	                \
   14.19  			    xpmap_ptom(_npte)); 		\
   14.20  	if (sync || ALWAYS_SYNC) xen_flush_queue();		\
   14.21  } while (/*CONSTCOND*/0)
   14.22  #define PT_SET_VA_MA(_ptp,_npte,sync) do {		        \
   14.23          PMAP_REF((_ptp), (_npte));                              \
   14.24 -	xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), _npte);\
   14.25 +	xen_queue_pt_update(vtomach(_ptp), _npte);              \
   14.26  	if (sync || ALWAYS_SYNC) xen_flush_queue();		\
   14.27  } while (/*CONSTCOND*/0)
   14.28  #define PT_CLEAR_VA(_ptp, sync) do {				\
   14.29          PMAP_REF((pt_entry_t *)(_ptp), 0);                      \
   14.30 -	xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), 0);	\
   14.31 +	xen_queue_pt_update(vtomach(_ptp), 0);	                \
   14.32  	if (sync || ALWAYS_SYNC)				\
   14.33  		xen_flush_queue();				\
   14.34  } while (/*CONSTCOND*/0)
    15.1 --- a/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c	Fri Apr 29 16:49:15 2005 +0000
    15.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c	Tue May 03 08:08:47 2005 +0000
    15.3 @@ -68,6 +68,7 @@ struct xb_softc {
    15.4      void		 *xb_resp_handler;
    15.5      int			  xb_unit;
    15.6      int			  xb_flags;
    15.7 +    struct xb_softc      *xb_next_blocked;
    15.8  #define XB_OPEN	(1<<0)		/* drive is open (can't shut down) */
    15.9  };
   15.10  
   15.11 @@ -118,6 +119,9 @@ static grant_ref_t gref_head, gref_termi
   15.12      (BLKIF_MAX_SEGMENTS_PER_REQUEST * BLKIF_RING_SIZE)
   15.13  #endif
   15.14  
   15.15 +static struct xb_softc *xb_kick_pending_head = NULL;
   15.16 +static struct xb_softc *xb_kick_pending_tail = NULL;
   15.17 +static struct mtx blkif_io_block_lock;
   15.18  
   15.19  static unsigned long rec_ring_free;		
   15.20  blkif_request_t rec_ring[BLK_RING_SIZE];
   15.21 @@ -246,6 +250,7 @@ xb_response_intr(void *xsc)
   15.22      /* sometimes we seem to lose i/o.  stay in the interrupt handler while
   15.23       * there is stuff to process: continually recheck the response producer.
   15.24       */
   15.25 + process_rcvd:
   15.26      for ( i = blk_ring.rsp_cons; i != (rp = blk_ring.sring->rsp_prod); i++ ) {
   15.27  	unsigned long id;
   15.28          bret = RING_GET_RESPONSE(&blk_ring, i);
   15.29 @@ -298,9 +303,28 @@ xb_response_intr(void *xsc)
   15.30      
   15.31      blk_ring.rsp_cons = i;
   15.32  
   15.33 -    if (sc && xb_kick_pending) {
   15.34 -    	xb_kick_pending = FALSE;
   15.35 -	xb_startio(sc);
   15.36 +    if (xb_kick_pending) {
   15.37 +	unsigned long flags;
   15.38 +	mtx_lock_irqsave(&blkif_io_block_lock, flags);
   15.39 +   	xb_kick_pending = FALSE;
   15.40 +	/* Run as long as there are blocked devs or queue fills again */
   15.41 +	while ((NULL != xb_kick_pending_head) && (FALSE == xb_kick_pending)) {
   15.42 +	    struct xb_softc *xb_cur = xb_kick_pending_head;
   15.43 +	    xb_kick_pending_head = xb_cur->xb_next_blocked;
   15.44 +	    if(NULL == xb_kick_pending_head) {
   15.45 +		xb_kick_pending_tail = NULL;
   15.46 +	    }
   15.47 +	    xb_cur->xb_next_blocked = NULL;
   15.48 +	    mtx_unlock_irqrestore(&blkif_io_block_lock, flags);
   15.49 +	    xb_startio(xb_cur);
   15.50 +	    mtx_lock_irqsave(&blkif_io_block_lock, flags);
   15.51 +	}
   15.52 +	mtx_unlock_irqrestore(&blkif_io_block_lock, flags);
   15.53 +
   15.54 +	if(blk_ring.rsp_cons != blk_ring.sring->rsp_prod) {
   15.55 +	    /* Consume those, too */
   15.56 +	    goto process_rcvd;
   15.57 +	}
   15.58      }
   15.59  
   15.60      mtx_unlock_irqrestore(&blkif_io_lock, flags);
   15.61 @@ -448,8 +472,22 @@ xb_startio(struct xb_softc *sc)
   15.62  
   15.63      }
   15.64  
   15.65 -    if (RING_FULL(&blk_ring))
   15.66 +    if (RING_FULL(&blk_ring)) {
   15.67 +	unsigned long flags;
   15.68 +	mtx_lock_irqsave(&blkif_io_block_lock, flags);
   15.69  	xb_kick_pending = TRUE;
   15.70 +        /* If we are not already on blocked list, add us */
   15.71 +        if((NULL == sc->xb_next_blocked) && (xb_kick_pending_tail != sc)) {
   15.72 +
   15.73 +            if(NULL == xb_kick_pending_head) {
   15.74 +                xb_kick_pending_head = xb_kick_pending_tail = sc;
   15.75 +            } else {
   15.76 +                xb_kick_pending_tail->xb_next_blocked = sc;
   15.77 +                xb_kick_pending_tail = sc;
   15.78 +            }
   15.79 +        }
   15.80 +        mtx_unlock_irqrestore(&blkif_io_block_lock, flags);
   15.81 +    }
   15.82      
   15.83      if (queued != 0) 
   15.84  	flush_requests();
   15.85 @@ -501,6 +539,7 @@ xb_create(int unit)
   15.86      
   15.87      sc = (struct xb_softc *)malloc(sizeof(*sc), M_DEVBUF, M_WAITOK);
   15.88      sc->xb_unit = unit;
   15.89 +    sc->xb_next_blocked = NULL;
   15.90  
   15.91      memset(&sc->xb_disk, 0, sizeof(sc->xb_disk)); 
   15.92      sc->xb_disk.d_unit = unit;
   15.93 @@ -947,7 +986,10 @@ xb_init(void *unused)
   15.94          return;
   15.95      printk("Blkif frontend is using grant tables.\n");
   15.96  #endif
   15.97 -
   15.98 + 
   15.99 +    xb_kick_pending = FALSE;
  15.100 +    xb_kick_pending_head = NULL;
  15.101 +    xb_kick_pending_tail = NULL;
  15.102  
  15.103      rec_ring_free = 0;
  15.104      for (i = 0; i < BLK_RING_SIZE; i++) {
  15.105 @@ -1002,4 +1044,5 @@ blkif_completion(blkif_request_t *req)
  15.106  #endif    
  15.107  }
  15.108  MTX_SYSINIT(ioreq, &blkif_io_lock, "BIO LOCK", MTX_SPIN | MTX_NOWITNESS); /* XXX how does one enroll a lock? */
  15.109 + MTX_SYSINIT(ioreq_block, &blkif_io_block_lock, "BIO BLOCK LOCK", MTX_SPIN | MTX_NOWITNESS);
  15.110  SYSINIT(xbdev, SI_SUB_PSEUDO, SI_ORDER_ANY, xb_init, NULL)
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/freebsd-5.3-xen-sparse/kern/kern_shutdown.c	Tue May 03 08:08:47 2005 +0000
    16.3 @@ -0,0 +1,635 @@
    16.4 +/*-
    16.5 + * Copyright (c) 1986, 1988, 1991, 1993
    16.6 + *	The Regents of the University of California.  All rights reserved.
    16.7 + * (c) UNIX System Laboratories, Inc.
    16.8 + * All or some portions of this file are derived from material licensed
    16.9 + * to the University of California by American Telephone and Telegraph
   16.10 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   16.11 + * the permission of UNIX System Laboratories, Inc.
   16.12 + *
   16.13 + * Redistribution and use in source and binary forms, with or without
   16.14 + * modification, are permitted provided that the following conditions
   16.15 + * are met:
   16.16 + * 1. Redistributions of source code must retain the above copyright
   16.17 + *    notice, this list of conditions and the following disclaimer.
   16.18 + * 2. Redistributions in binary form must reproduce the above copyright
   16.19 + *    notice, this list of conditions and the following disclaimer in the
   16.20 + *    documentation and/or other materials provided with the distribution.
   16.21 + * 4. Neither the name of the University nor the names of its contributors
   16.22 + *    may be used to endorse or promote products derived from this software
   16.23 + *    without specific prior written permission.
   16.24 + *
   16.25 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   16.26 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16.27 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   16.28 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   16.29 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   16.30 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   16.31 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   16.32 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   16.33 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   16.34 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   16.35 + * SUCH DAMAGE.
   16.36 + *
   16.37 + *	@(#)kern_shutdown.c	8.3 (Berkeley) 1/21/94
   16.38 + */
   16.39 +
   16.40 +#include <sys/cdefs.h>
   16.41 +__FBSDID("$FreeBSD: src/sys/kern/kern_shutdown.c,v 1.163.2.2 2004/09/10 00:04:17 scottl Exp $");
   16.42 +
   16.43 +#include "opt_kdb.h"
   16.44 +#include "opt_hw_wdog.h"
   16.45 +#include "opt_mac.h"
   16.46 +#include "opt_panic.h"
   16.47 +#include "opt_show_busybufs.h"
   16.48 +#include "opt_sched.h"
   16.49 +
   16.50 +#include <sys/param.h>
   16.51 +#include <sys/systm.h>
   16.52 +#include <sys/bio.h>
   16.53 +#include <sys/buf.h>
   16.54 +#include <sys/conf.h>
   16.55 +#include <sys/cons.h>
   16.56 +#include <sys/eventhandler.h>
   16.57 +#include <sys/kdb.h>
   16.58 +#include <sys/kernel.h>
   16.59 +#include <sys/kthread.h>
   16.60 +#include <sys/mac.h>
   16.61 +#include <sys/malloc.h>
   16.62 +#include <sys/mount.h>
   16.63 +#include <sys/proc.h>
   16.64 +#include <sys/reboot.h>
   16.65 +#include <sys/resourcevar.h>
   16.66 +#include <sys/smp.h>		/* smp_active */
   16.67 +#include <sys/sysctl.h>
   16.68 +#include <sys/sysproto.h>
   16.69 +#include <sys/vnode.h>
   16.70 +
   16.71 +#include <machine/cpu.h>
   16.72 +#include <machine/pcb.h>
   16.73 +#include <machine/smp.h>
   16.74 +
   16.75 +#include <sys/signalvar.h>
   16.76 +
   16.77 +#ifndef PANIC_REBOOT_WAIT_TIME
   16.78 +#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */
   16.79 +#endif
   16.80 +
   16.81 +/*
   16.82 + * Note that stdarg.h and the ANSI style va_start macro is used for both
   16.83 + * ANSI and traditional C compilers.
   16.84 + */
   16.85 +#include <machine/stdarg.h>
   16.86 +
   16.87 +#ifdef KDB
   16.88 +#ifdef KDB_UNATTENDED
   16.89 +int debugger_on_panic = 0;
   16.90 +#else
   16.91 +int debugger_on_panic = 1;
   16.92 +#endif
   16.93 +SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW,
   16.94 +	&debugger_on_panic, 0, "Run debugger on kernel panic");
   16.95 +
   16.96 +#ifdef KDB_TRACE
   16.97 +int trace_on_panic = 1;
   16.98 +#else
   16.99 +int trace_on_panic = 0;
  16.100 +#endif
  16.101 +SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, CTLFLAG_RW,
  16.102 +	&trace_on_panic, 0, "Print stack trace on kernel panic");
  16.103 +#endif /* KDB */
  16.104 +
  16.105 +int sync_on_panic = 0;
  16.106 +SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW,
  16.107 +	&sync_on_panic, 0, "Do a sync before rebooting from a panic");
  16.108 +
  16.109 +SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment");
  16.110 +
  16.111 +#ifdef	HW_WDOG
  16.112 +/*
  16.113 + * If there is a hardware watchdog, point this at the function needed to
  16.114 + * hold it off.
  16.115 + * It's needed when the kernel needs to do some lengthy operations.
  16.116 + * e.g. in wd.c when dumping core.. It's most annoying to have
  16.117 + * your precious core-dump only half written because the wdog kicked in.
  16.118 + */
  16.119 +watchdog_tickle_fn wdog_tickler = NULL;
  16.120 +#endif	/* HW_WDOG */
  16.121 +
  16.122 +/*
  16.123 + * Variable panicstr contains argument to first call to panic; used as flag
  16.124 + * to indicate that the kernel has already called panic.
  16.125 + */
  16.126 +const char *panicstr;
  16.127 +
  16.128 +int dumping;				/* system is dumping */
  16.129 +static struct dumperinfo dumper;	/* our selected dumper */
  16.130 +
  16.131 +/* Context information for dump-debuggers. */
  16.132 +static struct pcb dumppcb;		/* Registers. */
  16.133 +static lwpid_t dumptid;			/* Thread ID. */
  16.134 +
  16.135 +static void boot(int) __dead2;
  16.136 +static void poweroff_wait(void *, int);
  16.137 +static void shutdown_halt(void *junk, int howto);
  16.138 +static void shutdown_panic(void *junk, int howto);
  16.139 +static void shutdown_reset(void *junk, int howto);
  16.140 +
  16.141 +/* register various local shutdown events */
  16.142 +static void
  16.143 +shutdown_conf(void *unused)
  16.144 +{
  16.145 +
  16.146 +	EVENTHANDLER_REGISTER(shutdown_final, poweroff_wait, NULL,
  16.147 +	    SHUTDOWN_PRI_FIRST);
  16.148 +	EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL,
  16.149 +	    SHUTDOWN_PRI_LAST + 100);
  16.150 +	EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL,
  16.151 +	    SHUTDOWN_PRI_LAST + 100);
  16.152 +	EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL,
  16.153 +	    SHUTDOWN_PRI_LAST + 200);
  16.154 +}
  16.155 +
  16.156 +SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL)
  16.157 +
  16.158 +/*
  16.159 + * The system call that results in a reboot
  16.160 + *
  16.161 + * MPSAFE
  16.162 + */
  16.163 +/* ARGSUSED */
  16.164 +int
  16.165 +reboot(struct thread *td, struct reboot_args *uap)
  16.166 +{
  16.167 +	int error;
  16.168 +
  16.169 +	error = 0;
  16.170 +#ifdef MAC
  16.171 +	error = mac_check_system_reboot(td->td_ucred, uap->opt);
  16.172 +#endif
  16.173 +	if (error == 0)
  16.174 +		error = suser(td);
  16.175 +	if (error == 0) {
  16.176 +		mtx_lock(&Giant);
  16.177 +		boot(uap->opt);
  16.178 +		mtx_unlock(&Giant);
  16.179 +	}
  16.180 +	return (error);
  16.181 +}
  16.182 +
  16.183 +/*
  16.184 + * Called by events that want to shut down.. e.g  <CTL><ALT><DEL> on a PC
  16.185 + */
  16.186 +static int shutdown_howto = 0;
  16.187 +
  16.188 +void
  16.189 +shutdown_nice(int howto)
  16.190 +{
  16.191 +
  16.192 +	shutdown_howto = howto;
  16.193 +
  16.194 +	/* Send a signal to init(8) and have it shutdown the world */
  16.195 +	if (initproc != NULL) {
  16.196 +		PROC_LOCK(initproc);
  16.197 +		psignal(initproc, SIGINT);
  16.198 +		PROC_UNLOCK(initproc);
  16.199 +	} else {
  16.200 +		/* No init(8) running, so simply reboot */
  16.201 +		boot(RB_NOSYNC);
  16.202 +	}
  16.203 +	return;
  16.204 +}
  16.205 +static int	waittime = -1;
  16.206 +
  16.207 +static void
  16.208 +print_uptime(void)
  16.209 +{
  16.210 +	int f;
  16.211 +	struct timespec ts;
  16.212 +
  16.213 +	getnanouptime(&ts);
  16.214 +	printf("Uptime: ");
  16.215 +	f = 0;
  16.216 +	if (ts.tv_sec >= 86400) {
  16.217 +		printf("%ldd", (long)ts.tv_sec / 86400);
  16.218 +		ts.tv_sec %= 86400;
  16.219 +		f = 1;
  16.220 +	}
  16.221 +	if (f || ts.tv_sec >= 3600) {
  16.222 +		printf("%ldh", (long)ts.tv_sec / 3600);
  16.223 +		ts.tv_sec %= 3600;
  16.224 +		f = 1;
  16.225 +	}
  16.226 +	if (f || ts.tv_sec >= 60) {
  16.227 +		printf("%ldm", (long)ts.tv_sec / 60);
  16.228 +		ts.tv_sec %= 60;
  16.229 +		f = 1;
  16.230 +	}
  16.231 +	printf("%lds\n", (long)ts.tv_sec);
  16.232 +}
  16.233 +
  16.234 +static void
  16.235 +doadump(void)
  16.236 +{
  16.237 +
  16.238 +	/*
  16.239 +	 * Sometimes people have to call this from the kernel debugger. 
  16.240 +	 * (if 'panic' can not dump)
  16.241 +	 * Give them a clue as to why they can't dump.
  16.242 +	 */
  16.243 +	if (dumper.dumper == NULL) {
  16.244 +		printf("Cannot dump. No dump device defined.\n");
  16.245 +		return;
  16.246 +	}
  16.247 +
  16.248 +	savectx(&dumppcb);
  16.249 +	dumptid = curthread->td_tid;
  16.250 +	dumping++;
  16.251 +	dumpsys(&dumper);
  16.252 +}
  16.253 +
  16.254 +/*
  16.255 + *  Go through the rigmarole of shutting down..
  16.256 + * this used to be in machdep.c but I'll be dammned if I could see
  16.257 + * anything machine dependant in it.
  16.258 + */
  16.259 +static void
  16.260 +boot(int howto)
  16.261 +{
  16.262 +	static int first_buf_printf = 1;
  16.263 +
  16.264 +	/* collect extra flags that shutdown_nice might have set */
  16.265 +	howto |= shutdown_howto;
  16.266 +
  16.267 +	/* We are out of the debugger now. */
  16.268 +	kdb_active = 0;
  16.269 +
  16.270 +#ifdef SMP
  16.271 +	if (smp_active)
  16.272 +		printf("boot() called on cpu#%d\n", PCPU_GET(cpuid));
  16.273 +#endif
  16.274 +	/*
  16.275 +	 * Do any callouts that should be done BEFORE syncing the filesystems.
  16.276 +	 */
  16.277 +	EVENTHANDLER_INVOKE(shutdown_pre_sync, howto);
  16.278 +
  16.279 +	/* 
  16.280 +	 * Now sync filesystems
  16.281 +	 */
  16.282 +	if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
  16.283 +		register struct buf *bp;
  16.284 +		int iter, nbusy, pbusy;
  16.285 +#ifndef PREEMPTION
  16.286 +		int subiter;
  16.287 +#endif
  16.288 +
  16.289 +		waittime = 0;
  16.290 +
  16.291 +		sync(&thread0, NULL);
  16.292 +
  16.293 +		/*
  16.294 +		 * With soft updates, some buffers that are
  16.295 +		 * written will be remarked as dirty until other
  16.296 +		 * buffers are written.
  16.297 +		 */
  16.298 +		for (iter = pbusy = 0; iter < 20; iter++) {
  16.299 +			nbusy = 0;
  16.300 +			for (bp = &buf[nbuf]; --bp >= buf; ) {
  16.301 +				if ((bp->b_flags & B_INVAL) == 0 &&
  16.302 +				    BUF_REFCNT(bp) > 0) {
  16.303 +					nbusy++;
  16.304 +				} else if ((bp->b_flags & (B_DELWRI | B_INVAL))
  16.305 +						== B_DELWRI) {
  16.306 +					/* bawrite(bp);*/
  16.307 +					nbusy++;
  16.308 +				}
  16.309 +			}
  16.310 +			if (nbusy == 0) {
  16.311 +				if (first_buf_printf)
  16.312 +					printf("No buffers busy after final sync");
  16.313 +				break;
  16.314 +			}
  16.315 +			if (first_buf_printf) {
  16.316 +				printf("Syncing disks, buffers remaining... ");
  16.317 +				first_buf_printf = 0;
  16.318 +			}
  16.319 +			printf("%d ", nbusy);
  16.320 +			if (nbusy < pbusy)
  16.321 +				iter = 0;
  16.322 +			pbusy = nbusy;
  16.323 +			sync(&thread0, NULL);
  16.324 +
  16.325 +#ifdef PREEMPTION
  16.326 +			/*
  16.327 +			 * Drop Giant and spin for a while to allow
  16.328 +			 * interrupt threads to run.
  16.329 +			 */
  16.330 +			DROP_GIANT();
  16.331 +			DELAY(50000 * iter);
  16.332 +			PICKUP_GIANT();
  16.333 +#else
  16.334 +			/*
  16.335 +			 * Drop Giant and context switch several times to
  16.336 +			 * allow interrupt threads to run.
  16.337 +			 */
  16.338 +			DROP_GIANT();
  16.339 +			for (subiter = 0; subiter < 50 * iter; subiter++) {
  16.340 +				mtx_lock_spin(&sched_lock);
  16.341 +				mi_switch(SW_VOL, NULL);
  16.342 +				mtx_unlock_spin(&sched_lock);
  16.343 +				DELAY(1000);
  16.344 +			}
  16.345 +			PICKUP_GIANT();
  16.346 +#endif
  16.347 +		}
  16.348 +		printf("\n");
  16.349 +		/*
  16.350 +		 * Count only busy local buffers to prevent forcing 
  16.351 +		 * a fsck if we're just a client of a wedged NFS server
  16.352 +		 */
  16.353 +		nbusy = 0;
  16.354 +		for (bp = &buf[nbuf]; --bp >= buf; ) {
  16.355 +			if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) ||
  16.356 +			    ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) {
  16.357 +				if (bp->b_dev == NULL) {
  16.358 +					TAILQ_REMOVE(&mountlist,
  16.359 +					    bp->b_vp->v_mount, mnt_list);
  16.360 +					continue;
  16.361 +				}
  16.362 +				nbusy++;
  16.363 +#if defined(SHOW_BUSYBUFS) || defined(DIAGNOSTIC)
  16.364 +				printf(
  16.365 +			    "%d: dev:%s, flags:%0x, blkno:%ld, lblkno:%ld\n",
  16.366 +				    nbusy, devtoname(bp->b_dev),
  16.367 +				    bp->b_flags, (long)bp->b_blkno,
  16.368 +				    (long)bp->b_lblkno);
  16.369 +#endif
  16.370 +			}
  16.371 +		}
  16.372 +		if (nbusy) {
  16.373 +			/*
  16.374 +			 * Failed to sync all blocks. Indicate this and don't
  16.375 +			 * unmount filesystems (thus forcing an fsck on reboot).
  16.376 +			 */
  16.377 +			printf("Giving up on %d buffers\n", nbusy);
  16.378 +			DELAY(5000000);	/* 5 seconds */
  16.379 +		} else {
  16.380 +			if (!first_buf_printf)
  16.381 +				printf("Final sync complete\n");
  16.382 +			/*
  16.383 +			 * Unmount filesystems
  16.384 +			 */
  16.385 +			if (panicstr == 0)
  16.386 +				vfs_unmountall();
  16.387 +		}
  16.388 +		DELAY(100000);		/* wait for console output to finish */
  16.389 +	}
  16.390 +
  16.391 +	print_uptime();
  16.392 +
  16.393 +	/*
  16.394 +	 * Ok, now do things that assume all filesystem activity has
  16.395 +	 * been completed.
  16.396 +	 */
  16.397 +	EVENTHANDLER_INVOKE(shutdown_post_sync, howto);
  16.398 +	splhigh();
  16.399 +	if ((howto & (RB_HALT|RB_DUMP)) == RB_DUMP && !cold && !dumping) 
  16.400 +		doadump();
  16.401 +
  16.402 +	/* Now that we're going to really halt the system... */
  16.403 +	EVENTHANDLER_INVOKE(shutdown_final, howto);
  16.404 +
  16.405 +	for(;;) ;	/* safety against shutdown_reset not working */
  16.406 +	/* NOTREACHED */
  16.407 +}
  16.408 +
  16.409 +/*
  16.410 + * If the shutdown was a clean halt, behave accordingly.
  16.411 + */
  16.412 +static void
  16.413 +shutdown_halt(void *junk, int howto)
  16.414 +{
  16.415 +
  16.416 +	if (howto & RB_HALT) {
  16.417 +		printf("\n");
  16.418 +		printf("The operating system has halted.\n");
  16.419 +		printf("Please press any key to reboot.\n\n");
  16.420 +		switch (cngetc()) {
  16.421 +		case -1:		/* No console, just die */
  16.422 +			cpu_halt();
  16.423 +			/* NOTREACHED */
  16.424 +		default:
  16.425 +			howto &= ~RB_HALT;
  16.426 +			break;
  16.427 +		}
  16.428 +	}
  16.429 +}
  16.430 +
  16.431 +/*
  16.432 + * Check to see if the system paniced, pause and then reboot
  16.433 + * according to the specified delay.
  16.434 + */
  16.435 +static void
  16.436 +shutdown_panic(void *junk, int howto)
  16.437 +{
  16.438 +	int loop;
  16.439 +
  16.440 +	if (howto & RB_DUMP) {
  16.441 +		if (PANIC_REBOOT_WAIT_TIME != 0) {
  16.442 +			if (PANIC_REBOOT_WAIT_TIME != -1) {
  16.443 +				printf("Automatic reboot in %d seconds - "
  16.444 +				       "press a key on the console to abort\n",
  16.445 +					PANIC_REBOOT_WAIT_TIME);
  16.446 +				for (loop = PANIC_REBOOT_WAIT_TIME * 10;
  16.447 +				     loop > 0; --loop) {
  16.448 +					DELAY(1000 * 100); /* 1/10th second */
  16.449 +					/* Did user type a key? */
  16.450 +					if (cncheckc() != -1)
  16.451 +						break;
  16.452 +				}
  16.453 +				if (!loop)
  16.454 +					return;
  16.455 +			}
  16.456 +		} else { /* zero time specified - reboot NOW */
  16.457 +			return;
  16.458 +		}
  16.459 +		printf("--> Press a key on the console to reboot,\n");
  16.460 +		printf("--> or switch off the system now.\n");
  16.461 +		cngetc();
  16.462 +	}
  16.463 +}
  16.464 +
  16.465 +/*
  16.466 + * Everything done, now reset
  16.467 + */
  16.468 +static void
  16.469 +shutdown_reset(void *junk, int howto)
  16.470 +{
  16.471 +
  16.472 +	printf("Rebooting...\n");
  16.473 +	DELAY(1000000);	/* wait 1 sec for printf's to complete and be read */
  16.474 +	/* cpu_boot(howto); */ /* doesn't do anything at the moment */
  16.475 +	cpu_reset();
  16.476 +	/* NOTREACHED */ /* assuming reset worked */
  16.477 +}
  16.478 +
  16.479 +#ifdef SMP
  16.480 +static u_int panic_cpu = NOCPU;
  16.481 +#endif
  16.482 +
  16.483 +/*
  16.484 + * Panic is called on unresolvable fatal errors.  It prints "panic: mesg",
  16.485 + * and then reboots.  If we are called twice, then we avoid trying to sync
  16.486 + * the disks as this often leads to recursive panics.
  16.487 + *
  16.488 + * MPSAFE
  16.489 + */
  16.490 +void
  16.491 +panic(const char *fmt, ...)
  16.492 +{
  16.493 +	struct thread *td = curthread;
  16.494 +	int bootopt, newpanic;
  16.495 +	va_list ap;
  16.496 +	static char buf[256];
  16.497 +
  16.498 +#ifdef SMP
  16.499 +	/*
  16.500 +	 * We don't want multiple CPU's to panic at the same time, so we
  16.501 +	 * use panic_cpu as a simple spinlock.  We have to keep checking
  16.502 +	 * panic_cpu if we are spinning in case the panic on the first
  16.503 +	 * CPU is canceled.
  16.504 +	 */
  16.505 +	if (panic_cpu != PCPU_GET(cpuid))
  16.506 +		while (atomic_cmpset_int(&panic_cpu, NOCPU,
  16.507 +		    PCPU_GET(cpuid)) == 0)
  16.508 +			while (panic_cpu != NOCPU)
  16.509 +				; /* nothing */
  16.510 +#endif
  16.511 +
  16.512 +	bootopt = RB_AUTOBOOT | RB_DUMP;
  16.513 +	newpanic = 0;
  16.514 +	if (panicstr)
  16.515 +		bootopt |= RB_NOSYNC;
  16.516 +	else {
  16.517 +		panicstr = fmt;
  16.518 +		newpanic = 1;
  16.519 +	}
  16.520 +
  16.521 +	va_start(ap, fmt);
  16.522 +	if (newpanic) {
  16.523 +		(void)vsnprintf(buf, sizeof(buf), fmt, ap);
  16.524 +		panicstr = buf;
  16.525 +		printf("panic: %s\n", buf);
  16.526 +	} else {
  16.527 +		printf("panic: ");
  16.528 +		vprintf(fmt, ap);
  16.529 +		printf("\n");
  16.530 +	}
  16.531 +	va_end(ap);
  16.532 +#ifdef SMP
  16.533 +	printf("cpuid = %d\n", PCPU_GET(cpuid));
  16.534 +#endif
  16.535 +
  16.536 +#ifdef KDB
  16.537 +	if (newpanic && trace_on_panic)
  16.538 +		kdb_backtrace();
  16.539 +	if (debugger_on_panic)
  16.540 +		kdb_enter("panic");
  16.541 +#ifdef RESTARTABLE_PANICS
  16.542 +	/* See if the user aborted the panic, in which case we continue. */
  16.543 +	if (panicstr == NULL) {
  16.544 +#ifdef SMP
  16.545 +		atomic_store_rel_int(&panic_cpu, NOCPU);
  16.546 +#endif
  16.547 +		return;
  16.548 +	}
  16.549 +#endif
  16.550 +#endif
  16.551 +	mtx_lock_spin(&sched_lock);
  16.552 +	td->td_flags |= TDF_INPANIC;
  16.553 +	mtx_unlock_spin(&sched_lock);
  16.554 +	if (!sync_on_panic)
  16.555 +		bootopt |= RB_NOSYNC;
  16.556 +#ifdef XEN
  16.557 +	HYPERVISOR_crash();
  16.558 +#else
  16.559 +	boot(bootopt);
  16.560 +#endif
  16.561 +}
  16.562 +
  16.563 +/*
  16.564 + * Support for poweroff delay.
  16.565 + */
  16.566 +#ifndef POWEROFF_DELAY
  16.567 +# define POWEROFF_DELAY 5000
  16.568 +#endif
  16.569 +static int poweroff_delay = POWEROFF_DELAY;
  16.570 +
  16.571 +SYSCTL_INT(_kern_shutdown, OID_AUTO, poweroff_delay, CTLFLAG_RW,
  16.572 +	&poweroff_delay, 0, "");
  16.573 +
  16.574 +static void
  16.575 +poweroff_wait(void *junk, int howto)
  16.576 +{
  16.577 +
  16.578 +	if (!(howto & RB_POWEROFF) || poweroff_delay <= 0)
  16.579 +		return;
  16.580 +	DELAY(poweroff_delay * 1000);
  16.581 +}
  16.582 +
  16.583 +/*
  16.584 + * Some system processes (e.g. syncer) need to be stopped at appropriate
  16.585 + * points in their main loops prior to a system shutdown, so that they
  16.586 + * won't interfere with the shutdown process (e.g. by holding a disk buf
  16.587 + * to cause sync to fail).  For each of these system processes, register
  16.588 + * shutdown_kproc() as a handler for one of shutdown events.
  16.589 + */
  16.590 +static int kproc_shutdown_wait = 60;
  16.591 +SYSCTL_INT(_kern_shutdown, OID_AUTO, kproc_shutdown_wait, CTLFLAG_RW,
  16.592 +    &kproc_shutdown_wait, 0, "");
  16.593 +
  16.594 +void
  16.595 +kproc_shutdown(void *arg, int howto)
  16.596 +{
  16.597 +	struct proc *p;
  16.598 +	char procname[MAXCOMLEN + 1];
  16.599 +	int error;
  16.600 +
  16.601 +	if (panicstr)
  16.602 +		return;
  16.603 +
  16.604 +	p = (struct proc *)arg;
  16.605 +	strlcpy(procname, p->p_comm, sizeof(procname));
  16.606 +	printf("Waiting (max %d seconds) for system process `%s' to stop...",
  16.607 +	    kproc_shutdown_wait, procname);
  16.608 +	error = kthread_suspend(p, kproc_shutdown_wait * hz);
  16.609 +
  16.610 +	if (error == EWOULDBLOCK)
  16.611 +		printf("timed out\n");
  16.612 +	else
  16.613 +		printf("done\n");
  16.614 +}
  16.615 +
  16.616 +/* Registration of dumpers */
  16.617 +int
  16.618 +set_dumper(struct dumperinfo *di)
  16.619 +{
  16.620 +
  16.621 +	if (di == NULL) {
  16.622 +		bzero(&dumper, sizeof dumper);
  16.623 +		return (0);
  16.624 +	}
  16.625 +	if (dumper.dumper != NULL)
  16.626 +		return (EBUSY);
  16.627 +	dumper = *di;
  16.628 +	return (0);
  16.629 +}
  16.630 +
  16.631 +#if defined(__powerpc__)
  16.632 +void
  16.633 +dumpsys(struct dumperinfo *di __unused)
  16.634 +{
  16.635 +
  16.636 +	printf("Kernel dumps not implemented on this architecture\n");
  16.637 +}
  16.638 +#endif
    17.1 --- a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Fri Apr 29 16:49:15 2005 +0000
    17.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Tue May 03 08:08:47 2005 +0000
    17.3 @@ -598,7 +598,7 @@ CONFIG_NETDEVICES=y
    17.4  # CONFIG_DUMMY is not set
    17.5  # CONFIG_BONDING is not set
    17.6  # CONFIG_EQUALIZER is not set
    17.7 -# CONFIG_TUN is not set
    17.8 +CONFIG_TUN=y
    17.9  
   17.10  #
   17.11  # ARCnet devices
    18.1 --- a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Fri Apr 29 16:49:15 2005 +0000
    18.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Tue May 03 08:08:47 2005 +0000
    18.3 @@ -515,7 +515,7 @@ CONFIG_NETDEVICES=y
    18.4  # CONFIG_DUMMY is not set
    18.5  # CONFIG_BONDING is not set
    18.6  # CONFIG_EQUALIZER is not set
    18.7 -# CONFIG_TUN is not set
    18.8 +CONFIG_TUN=y
    18.9  
   18.10  #
   18.11  # ARCnet devices
    19.1 --- a/tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in	Fri Apr 29 16:49:15 2005 +0000
    19.2 +++ b/tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/Makefile.in	Tue May 03 08:08:47 2005 +0000
    19.3 @@ -83,7 +83,7 @@ READLINE_DEP = $$(READLINE_DIR)
    19.4  # -I. for config files.
    19.5  # -I${srcdir} for our headers.
    19.6  # -I$(srcdir)/../regformats for regdef.h.
    19.7 -INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../regformats -I$(INCLUDE_DIR)
    19.8 +INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../regformats -I$(INCLUDE_DIR)  -I../../../../libxc/ -I../../../../libxutil/
    19.9  
   19.10  # M{H,T}_CFLAGS, if defined, has host- and target-dependent CFLAGS
   19.11  # from the config/ directory.
    20.1 --- a/tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c	Fri Apr 29 16:49:15 2005 +0000
    20.2 +++ b/tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c	Tue May 03 08:08:47 2005 +0000
    20.3 @@ -35,12 +35,11 @@
    20.4  #include <stdlib.h>
    20.5  #include <unistd.h>
    20.6  #include <errno.h>
    20.7 -
    20.8 +#include <xc.h>
    20.9  #define TRACE_ENTER /* printf("enter %s\n", __FUNCTION__) */
   20.10 -#define ptrace xc_ptrace
   20.11 -long xc_ptrace(enum __ptrace_request request, ...);
   20.12 +long (*myptrace)(enum __ptrace_request, pid_t, long, long);
   20.13 +int (*myxcwait)(int domain, int *status, int options) ;
   20.14  
   20.15 -int waitdomain(int domain, int *status, int options);
   20.16  
   20.17  #define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
   20.18  #define DOMFLAGS_CRASHED   (1<<1) /* Crashed domain; frozen for postmortem.  */
   20.19 @@ -61,6 +60,8 @@ static void linux_resume (struct thread_
   20.20  
   20.21  int debug_threads;
   20.22  int using_threads;
   20.23 +extern int isfile;
   20.24 +
   20.25  struct pending_signals
   20.26  {
   20.27    int signal;
   20.28 @@ -150,7 +151,7 @@ linux_attach (int domain)
   20.29  {
   20.30      struct process_info *new_process;
   20.31      current_domain = domain;
   20.32 -    if (ptrace (PTRACE_ATTACH, domain, 0, 0) != 0) {
   20.33 +    if (myptrace (PTRACE_ATTACH, domain, 0, 0) != 0) {
   20.34  	fprintf (stderr, "Cannot attach to domain %d: %s (%d)\n", domain,
   20.35  		 strerror (errno), errno);
   20.36  	fflush (stderr);
   20.37 @@ -173,7 +174,7 @@ linux_kill_one_process (struct inferior_
   20.38  {
   20.39    struct thread_info *thread = (struct thread_info *) entry;
   20.40    struct process_info *process = get_thread_process (thread);
   20.41 -  ptrace (PTRACE_KILL, pid_of (process), 0, 0);
   20.42 +  myptrace (PTRACE_KILL, pid_of (process), 0, 0);
   20.43  
   20.44  }
   20.45  
   20.46 @@ -190,7 +191,7 @@ linux_detach_one_process (struct inferio
   20.47    struct thread_info *thread = (struct thread_info *) entry;
   20.48    struct process_info *process = get_thread_process (thread);
   20.49  
   20.50 -  ptrace (PTRACE_DETACH, pid_of (process), 0, 0);
   20.51 +  myptrace (PTRACE_DETACH, pid_of (process), 0, 0);
   20.52  }
   20.53  
   20.54  
   20.55 @@ -216,8 +217,7 @@ static unsigned char
   20.56  linux_wait (char *status)
   20.57  {
   20.58    int w;
   20.59 -  TRACE_ENTER;
   20.60 -  if (waitdomain(current_domain, &w, 0))
   20.61 +  if (myxcwait(current_domain, &w, 0))
   20.62        return -1;
   20.63    
   20.64    if (w & (DOMFLAGS_CRASHED|DOMFLAGS_DYING)) {
   20.65 @@ -242,7 +242,7 @@ linux_resume (struct thread_resume *resu
   20.66    expect_signal = resume_info->sig;
   20.67    for_each_inferior(&all_threads, regcache_invalidate_one);
   20.68  
   20.69 -  ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, current_domain, 0, 0);
   20.70 +  myptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, current_domain, 0, 0);
   20.71  
   20.72  }
   20.73  
   20.74 @@ -266,7 +266,7 @@ regsets_fetch_inferior_registers ()
   20.75  	}
   20.76  
   20.77        buf = malloc (regset->size);
   20.78 -      res = ptrace (regset->get_request, inferior_pid, 0, buf);
   20.79 +      res = myptrace (regset->get_request, inferior_pid, 0, (PTRACE_XFER_TYPE)buf);
   20.80        if (res < 0)
   20.81  	{
   20.82  	  if (errno == EIO)
   20.83 @@ -318,7 +318,7 @@ regsets_store_inferior_registers ()
   20.84  
   20.85        buf = malloc (regset->size);
   20.86        regset->fill_function (buf);
   20.87 -      res = ptrace (regset->set_request, inferior_pid, 0, buf);
   20.88 +      res = myptrace (regset->set_request, inferior_pid, 0, (PTRACE_XFER_TYPE)buf);
   20.89        if (res < 0)
   20.90  	{
   20.91  	  if (errno == EIO)
   20.92 @@ -395,7 +395,7 @@ linux_read_memory (CORE_ADDR memaddr, ch
   20.93    for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
   20.94      {
   20.95        errno = 0;
   20.96 -      buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
   20.97 +      buffer[i] = myptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
   20.98        if (errno)
   20.99  	return errno;
  20.100      }
  20.101 @@ -428,13 +428,13 @@ linux_write_memory (CORE_ADDR memaddr, c
  20.102  
  20.103    /* Fill start and end extra bytes of buffer with existing memory data.  */
  20.104  
  20.105 -  buffer[0] = ptrace (PTRACE_PEEKTEXT, inferior_pid,
  20.106 +  buffer[0] = myptrace (PTRACE_PEEKTEXT, inferior_pid,
  20.107  		      (PTRACE_ARG3_TYPE) addr, 0);
  20.108  
  20.109    if (count > 1)
  20.110      {
  20.111        buffer[count - 1]
  20.112 -	= ptrace (PTRACE_PEEKTEXT, inferior_pid,
  20.113 +	= myptrace (PTRACE_PEEKTEXT, inferior_pid,
  20.114  		  (PTRACE_ARG3_TYPE) (addr + (count - 1)
  20.115  				      * sizeof (PTRACE_XFER_TYPE)),
  20.116  		  0);
  20.117 @@ -448,7 +448,7 @@ linux_write_memory (CORE_ADDR memaddr, c
  20.118    for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
  20.119      {
  20.120        errno = 0;
  20.121 -      ptrace (PTRACE_POKETEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
  20.122 +      myptrace (PTRACE_POKETEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
  20.123        if (errno)
  20.124  	return errno;
  20.125      }
  20.126 @@ -545,4 +545,12 @@ initialize_low (void)
  20.127  		       the_low_target.breakpoint_len);
  20.128    init_registers ();
  20.129    linux_init_signals ();
  20.130 +  if (isfile) {
  20.131 +      myptrace = xc_ptrace_core;
  20.132 +      myxcwait = xc_waitdomain_core;
  20.133 +  } else {
  20.134 +      myptrace = xc_ptrace;
  20.135 +      myxcwait = xc_waitdomain;
  20.136 +  }
  20.137 +
  20.138  }
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/tools/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c	Tue May 03 08:08:47 2005 +0000
    21.3 @@ -0,0 +1,639 @@
    21.4 +/* Main code for remote server for GDB.
    21.5 +   Copyright 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004
    21.6 +   Free Software Foundation, Inc.
    21.7 +
    21.8 +   This file is part of GDB.
    21.9 +
   21.10 +   This program is free software; you can redistribute it and/or modify
   21.11 +   it under the terms of the GNU General Public License as published by
   21.12 +   the Free Software Foundation; either version 2 of the License, or
   21.13 +   (at your option) any later version.
   21.14 +
   21.15 +   This program is distributed in the hope that it will be useful,
   21.16 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.17 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21.18 +   GNU General Public License for more details.
   21.19 +
   21.20 +   You should have received a copy of the GNU General Public License
   21.21 +   along with this program; if not, write to the Free Software
   21.22 +   Foundation, Inc., 59 Temple Place - Suite 330,
   21.23 +   Boston, MA 02111-1307, USA.  */
   21.24 +
   21.25 +#include "server.h"
   21.26 +
   21.27 +#include <unistd.h>
   21.28 +#include <signal.h>
   21.29 +#include <sys/wait.h>
   21.30 +#include <sys/types.h>
   21.31 +#include <sys/stat.h>
   21.32 +#include <fcntl.h>
   21.33 +
   21.34 +int cont_thread;
   21.35 +int general_thread;
   21.36 +int step_thread;
   21.37 +int thread_from_wait;
   21.38 +int old_thread_from_wait;
   21.39 +int extended_protocol;
   21.40 +int server_waiting;
   21.41 +int isfile = 0;
   21.42 +
   21.43 +jmp_buf toplevel;
   21.44 +
   21.45 +/* The PID of the originally created or attached inferior.  Used to
   21.46 +   send signals to the process when GDB sends us an asynchronous interrupt
   21.47 +   (user hitting Control-C in the client), and to wait for the child to exit
   21.48 +   when no longer debugging it.  */
   21.49 +
   21.50 +int signal_pid;
   21.51 +
   21.52 +static unsigned char
   21.53 +start_inferior (char *argv[], char *statusptr)
   21.54 +{
   21.55 +  signal (SIGTTOU, SIG_DFL);
   21.56 +  signal (SIGTTIN, SIG_DFL);
   21.57 +
   21.58 +  signal_pid = create_inferior (argv[0], argv);
   21.59 +
   21.60 +  fprintf (stderr, "Process %s created; pid = %d\n", argv[0],
   21.61 +	   signal_pid);
   21.62 +
   21.63 +  signal (SIGTTOU, SIG_IGN);
   21.64 +  signal (SIGTTIN, SIG_IGN);
   21.65 +  tcsetpgrp (fileno (stderr), signal_pid);
   21.66 +
   21.67 +  /* Wait till we are at 1st instruction in program, return signal number.  */
   21.68 +  return mywait (statusptr, 0);
   21.69 +}
   21.70 +
   21.71 +static int
   21.72 +attach_inferior (int pid, char *statusptr, unsigned char *sigptr)
   21.73 +{
   21.74 +  /* myattach should return -1 if attaching is unsupported,
   21.75 +     0 if it succeeded, and call error() otherwise.  */
   21.76 +
   21.77 +  if (myattach (pid) != 0)
   21.78 +    return -1;
   21.79 +
   21.80 +  fprintf (stderr, "Attached; pid = %d\n", pid);
   21.81 +
   21.82 +  /* FIXME - It may be that we should get the SIGNAL_PID from the
   21.83 +     attach function, so that it can be the main thread instead of
   21.84 +     whichever we were told to attach to.  */
   21.85 +  signal_pid = pid;
   21.86 +
   21.87 +  *sigptr = mywait (statusptr, 0);
   21.88 +
   21.89 +  return 0;
   21.90 +}
   21.91 +
   21.92 +extern int remote_debug;
   21.93 +
   21.94 +/* Handle all of the extended 'q' packets.  */
   21.95 +void
   21.96 +handle_query (char *own_buf)
   21.97 +{
   21.98 +  static struct inferior_list_entry *thread_ptr;
   21.99 +
  21.100 +  if (strcmp ("qSymbol::", own_buf) == 0)
  21.101 +    {
  21.102 +      if (the_target->look_up_symbols != NULL)
  21.103 +	(*the_target->look_up_symbols) ();
  21.104 +
  21.105 +      strcpy (own_buf, "OK");
  21.106 +      return;
  21.107 +    }
  21.108 +
  21.109 +  if (strcmp ("qfThreadInfo", own_buf) == 0)
  21.110 +    {
  21.111 +      thread_ptr = all_threads.head;
  21.112 +      sprintf (own_buf, "m%x", thread_ptr->id);
  21.113 +      thread_ptr = thread_ptr->next;
  21.114 +      return;
  21.115 +    }
  21.116 +
  21.117 +  if (strcmp ("qsThreadInfo", own_buf) == 0)
  21.118 +    {
  21.119 +      if (thread_ptr != NULL)
  21.120 +	{
  21.121 +	  sprintf (own_buf, "m%x", thread_ptr->id);
  21.122 +	  thread_ptr = thread_ptr->next;
  21.123 +	  return;
  21.124 +	}
  21.125 +      else
  21.126 +	{
  21.127 +	  sprintf (own_buf, "l");
  21.128 +	  return;
  21.129 +	}
  21.130 +    }
  21.131 +
  21.132 +  if (the_target->read_auxv != NULL
  21.133 +      && strncmp ("qPart:auxv:read::", own_buf, 17) == 0)
  21.134 +    {
  21.135 +      char data[(PBUFSIZ - 1) / 2];
  21.136 +      CORE_ADDR ofs;
  21.137 +      unsigned int len;
  21.138 +      int n;
  21.139 +      decode_m_packet (&own_buf[17], &ofs, &len); /* "OFS,LEN" */
  21.140 +      if (len > sizeof data)
  21.141 +	len = sizeof data;
  21.142 +      n = (*the_target->read_auxv) (ofs, data, len);
  21.143 +      if (n == 0)
  21.144 +	write_ok (own_buf);
  21.145 +      else if (n < 0)
  21.146 +	write_enn (own_buf);
  21.147 +      else
  21.148 +	convert_int_to_ascii (data, own_buf, n);
  21.149 +      return;
  21.150 +    }
  21.151 +
  21.152 +  /* Otherwise we didn't know what packet it was.  Say we didn't
  21.153 +     understand it.  */
  21.154 +  own_buf[0] = 0;
  21.155 +}
  21.156 +
  21.157 +/* Parse vCont packets.  */
  21.158 +void
  21.159 +handle_v_cont (char *own_buf, char *status, unsigned char *signal)
  21.160 +{
  21.161 +  char *p, *q;
  21.162 +  int n = 0, i = 0;
  21.163 +  struct thread_resume *resume_info, default_action;
  21.164 +
  21.165 +  /* Count the number of semicolons in the packet.  There should be one
  21.166 +     for every action.  */
  21.167 +  p = &own_buf[5];
  21.168 +  while (p)
  21.169 +    {
  21.170 +      n++;
  21.171 +      p++;
  21.172 +      p = strchr (p, ';');
  21.173 +    }
  21.174 +  /* Allocate room for one extra action, for the default remain-stopped
  21.175 +     behavior; if no default action is in the list, we'll need the extra
  21.176 +     slot.  */
  21.177 +  resume_info = malloc ((n + 1) * sizeof (resume_info[0]));
  21.178 +
  21.179 +  default_action.thread = -1;
  21.180 +  default_action.leave_stopped = 1;
  21.181 +  default_action.step = 0;
  21.182 +  default_action.sig = 0;
  21.183 +
  21.184 +  p = &own_buf[5];
  21.185 +  i = 0;
  21.186 +  while (*p)
  21.187 +    {
  21.188 +      p++;
  21.189 +
  21.190 +      resume_info[i].leave_stopped = 0;
  21.191 +
  21.192 +      if (p[0] == 's' || p[0] == 'S')
  21.193 +	resume_info[i].step = 1;
  21.194 +      else if (p[0] == 'c' || p[0] == 'C')
  21.195 +	resume_info[i].step = 0;
  21.196 +      else
  21.197 +	goto err;
  21.198 +
  21.199 +      if (p[0] == 'S' || p[0] == 'C')
  21.200 +	{
  21.201 +	  int sig;
  21.202 +	  sig = strtol (p + 1, &q, 16);
  21.203 +	  if (p == q)
  21.204 +	    goto err;
  21.205 +	  p = q;
  21.206 +
  21.207 +	  if (!target_signal_to_host_p (sig))
  21.208 +	    goto err;
  21.209 +	  resume_info[i].sig = target_signal_to_host (sig);
  21.210 +	}
  21.211 +      else
  21.212 +	{
  21.213 +	  resume_info[i].sig = 0;
  21.214 +	  p = p + 1;
  21.215 +	}
  21.216 +
  21.217 +      if (p[0] == 0)
  21.218 +	{
  21.219 +	  resume_info[i].thread = -1;
  21.220 +	  default_action = resume_info[i];
  21.221 +
  21.222 +	  /* Note: we don't increment i here, we'll overwrite this entry
  21.223 +	     the next time through.  */
  21.224 +	}
  21.225 +      else if (p[0] == ':')
  21.226 +	{
  21.227 +	  resume_info[i].thread = strtol (p + 1, &q, 16);
  21.228 +	  if (p == q)
  21.229 +	    goto err;
  21.230 +	  p = q;
  21.231 +	  if (p[0] != ';' && p[0] != 0)
  21.232 +	    goto err;
  21.233 +
  21.234 +	  i++;
  21.235 +	}
  21.236 +    }
  21.237 +
  21.238 +  resume_info[i] = default_action;
  21.239 +
  21.240 +  /* Still used in occasional places in the backend.  */
  21.241 +  if (n == 1 && resume_info[0].thread != -1)
  21.242 +    cont_thread = resume_info[0].thread;
  21.243 +  else
  21.244 +    cont_thread = -1;
  21.245 +  set_desired_inferior (0);
  21.246 +
  21.247 +  (*the_target->resume) (resume_info);
  21.248 +
  21.249 +  free (resume_info);
  21.250 +
  21.251 +  *signal = mywait (status, 1);
  21.252 +  prepare_resume_reply (own_buf, *status, *signal);
  21.253 +  return;
  21.254 +
  21.255 +err:
  21.256 +  /* No other way to report an error... */
  21.257 +  strcpy (own_buf, "");
  21.258 +  free (resume_info);
  21.259 +  return;
  21.260 +}
  21.261 +
  21.262 +/* Handle all of the extended 'v' packets.  */
  21.263 +void
  21.264 +handle_v_requests (char *own_buf, char *status, unsigned char *signal)
  21.265 +{
  21.266 +  if (strncmp (own_buf, "vCont;", 6) == 0)
  21.267 +    {
  21.268 +      handle_v_cont (own_buf, status, signal);
  21.269 +      return;
  21.270 +    }
  21.271 +
  21.272 +  if (strncmp (own_buf, "vCont?", 6) == 0)
  21.273 +    {
  21.274 +      strcpy (own_buf, "vCont;c;C;s;S");
  21.275 +      return;
  21.276 +    }
  21.277 +
  21.278 +  /* Otherwise we didn't know what packet it was.  Say we didn't
  21.279 +     understand it.  */
  21.280 +  own_buf[0] = 0;
  21.281 +  return;
  21.282 +}
  21.283 +
  21.284 +void
  21.285 +myresume (int step, int sig)
  21.286 +{
  21.287 +  struct thread_resume resume_info[2];
  21.288 +  int n = 0;
  21.289 +
  21.290 +  if (step || sig || cont_thread > 0)
  21.291 +    {
  21.292 +      resume_info[0].thread
  21.293 +	= ((struct inferior_list_entry *) current_inferior)->id;
  21.294 +      resume_info[0].step = step;
  21.295 +      resume_info[0].sig = sig;
  21.296 +      resume_info[0].leave_stopped = 0;
  21.297 +      n++;
  21.298 +    }
  21.299 +  resume_info[n].thread = -1;
  21.300 +  resume_info[n].step = 0;
  21.301 +  resume_info[n].sig = 0;
  21.302 +  resume_info[n].leave_stopped = (cont_thread > 0);
  21.303 +
  21.304 +  (*the_target->resume) (resume_info);
  21.305 +}
  21.306 +
  21.307 +static int attached;
  21.308 +
  21.309 +static void
  21.310 +gdbserver_usage (void)
  21.311 +{
  21.312 +  error ("Usage:\tgdbserver COMM PROG [ARGS ...]\n"
  21.313 +	 "\tgdbserver COMM --attach PID\n"
  21.314 +	 "\tgdbserver COMM --file COREFILE\n"
  21.315 +	 "\n"
  21.316 +	 "COMM may either be a tty device (for serial debugging), or \n"
  21.317 +	 "HOST:PORT to listen for a TCP connection.\n");
  21.318 +}
  21.319 +
  21.320 +int
  21.321 +main (int argc, char *argv[])
  21.322 +{
  21.323 +  char ch, status, *own_buf, mem_buf[2000];
  21.324 +  int i = 0;
  21.325 +  unsigned char signal;
  21.326 +  unsigned int len;
  21.327 +  CORE_ADDR mem_addr;
  21.328 +  int bad_attach;
  21.329 +  int pid;
  21.330 +  char *arg_end;
  21.331 +
  21.332 +  if (setjmp (toplevel))
  21.333 +    {
  21.334 +      fprintf (stderr, "Exiting\n");
  21.335 +      exit (1);
  21.336 +    }
  21.337 +
  21.338 +  bad_attach = 0;
  21.339 +  pid = 0;
  21.340 +  attached = 0;
  21.341 +  if (argc >= 3 && strcmp (argv[2], "--attach") == 0)
  21.342 +    {
  21.343 +      if (argc == 4
  21.344 +	  && argv[3] != '\0'
  21.345 +	  && (pid = strtoul (argv[3], &arg_end, 10)) != 0
  21.346 +	  && *arg_end == '\0')
  21.347 +	{
  21.348 +	  ;
  21.349 +	}
  21.350 +      else
  21.351 +	bad_attach = 1;
  21.352 +    }
  21.353 +  else if (argc >= 3 && strcmp (argv[2], "--file") == 0)
  21.354 +    {
  21.355 +      if (argc == 4
  21.356 +	  && argv[3] != '\0')
  21.357 +	{
  21.358 +	  if ((pid = open(argv[3], O_RDONLY)) <= 0) 
  21.359 +	    bad_attach = 1;
  21.360 +	  else 
  21.361 +	    isfile = 1;
  21.362 +	}
  21.363 +      else
  21.364 +	bad_attach = 1;
  21.365 +    }
  21.366 +
  21.367 +  if (argc < 3 || bad_attach)
  21.368 +    gdbserver_usage();
  21.369 +
  21.370 +  initialize_low ();
  21.371 +
  21.372 +  own_buf = malloc (PBUFSIZ);
  21.373 +
  21.374 +  if (pid == 0)
  21.375 +    {
  21.376 +      /* Wait till we are at first instruction in program.  */
  21.377 +      signal = start_inferior (&argv[2], &status);
  21.378 +
  21.379 +      /* We are now stopped at the first instruction of the target process */
  21.380 +    }
  21.381 +  else
  21.382 +    {
  21.383 +      switch (attach_inferior (pid, &status, &signal))
  21.384 +	{
  21.385 +	case -1:
  21.386 +	  error ("Attaching not supported on this target");
  21.387 +	  break;
  21.388 +	default:
  21.389 +	  attached = 1;
  21.390 +	  break;
  21.391 +	}
  21.392 +    }
  21.393 +
  21.394 +  while (1)
  21.395 +    {
  21.396 +      remote_open (argv[1]);
  21.397 +
  21.398 +    restart:
  21.399 +      setjmp (toplevel);
  21.400 +      while (getpkt (own_buf) > 0)
  21.401 +	{
  21.402 +	  unsigned char sig;
  21.403 +	  i = 0;
  21.404 +	  ch = own_buf[i++];
  21.405 +	  switch (ch)
  21.406 +	    {
  21.407 +	    case 'q':
  21.408 +	      handle_query (own_buf);
  21.409 +	      break;
  21.410 +	    case 'd':
  21.411 +	      remote_debug = !remote_debug;
  21.412 +	      break;
  21.413 +	    case 'D':
  21.414 +	      fprintf (stderr, "Detaching from inferior\n");
  21.415 +	      detach_inferior ();
  21.416 +	      write_ok (own_buf);
  21.417 +	      putpkt (own_buf);
  21.418 +	      remote_close ();
  21.419 +
  21.420 +	      /* If we are attached, then we can exit.  Otherwise, we need to
  21.421 +		 hang around doing nothing, until the child is gone.  */
  21.422 +	      if (!attached)
  21.423 +		{
  21.424 +		  int status, ret;
  21.425 +
  21.426 +		  do {
  21.427 +		    ret = waitpid (signal_pid, &status, 0);
  21.428 +		    if (WIFEXITED (status) || WIFSIGNALED (status))
  21.429 +		      break;
  21.430 +		  } while (ret != -1 || errno != ECHILD);
  21.431 +		}
  21.432 +
  21.433 +	      exit (0);
  21.434 +
  21.435 +	    case '!':
  21.436 +	      if (attached == 0)
  21.437 +		{
  21.438 +		  extended_protocol = 1;
  21.439 +		  prepare_resume_reply (own_buf, status, signal);
  21.440 +		}
  21.441 +	      else
  21.442 +		{
  21.443 +		  /* We can not use the extended protocol if we are
  21.444 +		     attached, because we can not restart the running
  21.445 +		     program.  So return unrecognized.  */
  21.446 +		  own_buf[0] = '\0';
  21.447 +		}
  21.448 +	      break;
  21.449 +	    case '?':
  21.450 +	      prepare_resume_reply (own_buf, status, signal);
  21.451 +	      break;
  21.452 +	    case 'H':
  21.453 +	      switch (own_buf[1])
  21.454 +		{
  21.455 +		case 'g':
  21.456 +		  general_thread = strtol (&own_buf[2], NULL, 16);
  21.457 +		  write_ok (own_buf);
  21.458 +		  set_desired_inferior (1);
  21.459 +		  break;
  21.460 +		case 'c':
  21.461 +		  cont_thread = strtol (&own_buf[2], NULL, 16);
  21.462 +		  write_ok (own_buf);
  21.463 +		  break;
  21.464 +		case 's':
  21.465 +		  step_thread = strtol (&own_buf[2], NULL, 16);
  21.466 +		  write_ok (own_buf);
  21.467 +		  break;
  21.468 +		default:
  21.469 +		  /* Silently ignore it so that gdb can extend the protocol
  21.470 +		     without compatibility headaches.  */
  21.471 +		  own_buf[0] = '\0';
  21.472 +		  break;
  21.473 +		}
  21.474 +	      break;
  21.475 +	    case 'g':
  21.476 +	      set_desired_inferior (1);
  21.477 +	      registers_to_string (own_buf);
  21.478 +	      break;
  21.479 +	    case 'G':
  21.480 +	      set_desired_inferior (1);
  21.481 +	      registers_from_string (&own_buf[1]);
  21.482 +	      write_ok (own_buf);
  21.483 +	      break;
  21.484 +	    case 'm':
  21.485 +	      decode_m_packet (&own_buf[1], &mem_addr, &len);
  21.486 +	      if (read_inferior_memory (mem_addr, mem_buf, len) == 0)
  21.487 +		convert_int_to_ascii (mem_buf, own_buf, len);
  21.488 +	      else
  21.489 +		write_enn (own_buf);
  21.490 +	      break;
  21.491 +	    case 'M':
  21.492 +	      decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf);
  21.493 +	      if (write_inferior_memory (mem_addr, mem_buf, len) == 0)
  21.494 +		write_ok (own_buf);
  21.495 +	      else
  21.496 +		write_enn (own_buf);
  21.497 +	      break;
  21.498 +	    case 'C':
  21.499 +	      convert_ascii_to_int (own_buf + 1, &sig, 1);
  21.500 +	      if (target_signal_to_host_p (sig))
  21.501 +		signal = target_signal_to_host (sig);
  21.502 +	      else
  21.503 +		signal = 0;
  21.504 +	      set_desired_inferior (0);
  21.505 +	      myresume (0, signal);
  21.506 +	      signal = mywait (&status, 1);
  21.507 +	      prepare_resume_reply (own_buf, status, signal);
  21.508 +	      break;
  21.509 +	    case 'S':
  21.510 +	      convert_ascii_to_int (own_buf + 1, &sig, 1);
  21.511 +	      if (target_signal_to_host_p (sig))
  21.512 +		signal = target_signal_to_host (sig);
  21.513 +	      else
  21.514 +		signal = 0;
  21.515 +	      set_desired_inferior (0);
  21.516 +	      myresume (1, signal);
  21.517 +	      signal = mywait (&status, 1);
  21.518 +	      prepare_resume_reply (own_buf, status, signal);
  21.519 +	      break;
  21.520 +	    case 'c':
  21.521 +	      set_desired_inferior (0);
  21.522 +	      myresume (0, 0);
  21.523 +	      signal = mywait (&status, 1);
  21.524 +	      prepare_resume_reply (own_buf, status, signal);
  21.525 +	      break;
  21.526 +	    case 's':
  21.527 +	      set_desired_inferior (0);
  21.528 +	      myresume (1, 0);
  21.529 +	      signal = mywait (&status, 1);
  21.530 +	      prepare_resume_reply (own_buf, status, signal);
  21.531 +	      break;
  21.532 +	    case 'k':
  21.533 +	      fprintf (stderr, "Killing inferior\n");
  21.534 +	      kill_inferior ();
  21.535 +	      /* When using the extended protocol, we start up a new
  21.536 +	         debugging session.   The traditional protocol will
  21.537 +	         exit instead.  */
  21.538 +	      if (extended_protocol)
  21.539 +		{
  21.540 +		  write_ok (own_buf);
  21.541 +		  fprintf (stderr, "GDBserver restarting\n");
  21.542 +
  21.543 +		  /* Wait till we are at 1st instruction in prog.  */
  21.544 +		  signal = start_inferior (&argv[2], &status);
  21.545 +		  goto restart;
  21.546 +		  break;
  21.547 +		}
  21.548 +	      else
  21.549 +		{
  21.550 +		  exit (0);
  21.551 +		  break;
  21.552 +		}
  21.553 +	    case 'T':
  21.554 +	      if (mythread_alive (strtol (&own_buf[1], NULL, 16)))
  21.555 +		write_ok (own_buf);
  21.556 +	      else
  21.557 +		write_enn (own_buf);
  21.558 +	      break;
  21.559 +	    case 'R':
  21.560 +	      /* Restarting the inferior is only supported in the
  21.561 +	         extended protocol.  */
  21.562 +	      if (extended_protocol)
  21.563 +		{
  21.564 +		  kill_inferior ();
  21.565 +		  write_ok (own_buf);
  21.566 +		  fprintf (stderr, "GDBserver restarting\n");
  21.567 +
  21.568 +		  /* Wait till we are at 1st instruction in prog.  */
  21.569 +		  signal = start_inferior (&argv[2], &status);
  21.570 +		  goto restart;
  21.571 +		  break;
  21.572 +		}
  21.573 +	      else
  21.574 +		{
  21.575 +		  /* It is a request we don't understand.  Respond with an
  21.576 +		     empty packet so that gdb knows that we don't support this
  21.577 +		     request.  */
  21.578 +		  own_buf[0] = '\0';
  21.579 +		  break;
  21.580 +		}
  21.581 +	    case 'v':
  21.582 +	      /* Extended (long) request.  */
  21.583 +	      handle_v_requests (own_buf, &status, &signal);
  21.584 +	      break;
  21.585 +	    default:
  21.586 +	      /* It is a request we don't understand.  Respond with an
  21.587 +	         empty packet so that gdb knows that we don't support this
  21.588 +	         request.  */
  21.589 +	      own_buf[0] = '\0';
  21.590 +	      break;
  21.591 +	    }
  21.592 +
  21.593 +	  putpkt (own_buf);
  21.594 +
  21.595 +	  if (status == 'W')
  21.596 +	    fprintf (stderr,
  21.597 +		     "\nChild exited with status %d\n", signal);
  21.598 +	  if (status == 'X')
  21.599 +	    fprintf (stderr, "\nChild terminated with signal = 0x%x\n",
  21.600 +		     signal);
  21.601 +	  if (status == 'W' || status == 'X')
  21.602 +	    {
  21.603 +	      if (extended_protocol)
  21.604 +		{
  21.605 +		  fprintf (stderr, "Killing inferior\n");
  21.606 +		  kill_inferior ();
  21.607 +		  write_ok (own_buf);
  21.608 +		  fprintf (stderr, "GDBserver restarting\n");
  21.609 +
  21.610 +		  /* Wait till we are at 1st instruction in prog.  */
  21.611 +		  signal = start_inferior (&argv[2], &status);
  21.612 +		  goto restart;
  21.613 +		  break;
  21.614 +		}
  21.615 +	      else
  21.616 +		{
  21.617 +		  fprintf (stderr, "GDBserver exiting\n");
  21.618 +		  exit (0);
  21.619 +		}
  21.620 +	    }
  21.621 +	}
  21.622 +
  21.623 +      /* We come here when getpkt fails.
  21.624 +
  21.625 +         For the extended remote protocol we exit (and this is the only
  21.626 +         way we gracefully exit!).
  21.627 +
  21.628 +         For the traditional remote protocol close the connection,
  21.629 +         and re-open it at the top of the loop.  */
  21.630 +      if (extended_protocol)
  21.631 +	{
  21.632 +	  remote_close ();
  21.633 +	  exit (0);
  21.634 +	}
  21.635 +      else
  21.636 +	{
  21.637 +	  fprintf (stderr, "Remote side has terminated connection.  "
  21.638 +			   "GDBserver will reopen the connection.\n");
  21.639 +	  remote_close ();
  21.640 +	}
  21.641 +    }
  21.642 +}
    22.1 --- a/tools/ioemu/iodev/Makefile	Fri Apr 29 16:49:15 2005 +0000
    22.2 +++ b/tools/ioemu/iodev/Makefile	Tue May 03 08:08:47 2005 +0000
    22.3 @@ -4,8 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
    22.4  TOPDIR= ..
    22.5  CXXFLAGS=-I. -I../include -I..
    22.6  
    22.7 -ARCH=$(shell uname -i)
    22.8 -ifeq ($(ARCH), i386)
    22.9 +ifeq ($(XEN_TARGET_ARCH), x86_32)
   22.10  CXXFLAGS+=-D_FILE_OFFSET_BITS=64
   22.11  endif
   22.12  
    23.1 --- a/tools/libxc/Makefile	Fri Apr 29 16:49:15 2005 +0000
    23.2 +++ b/tools/libxc/Makefile	Tue May 03 08:08:47 2005 +0000
    23.3 @@ -17,6 +17,7 @@ INCLUDES += -I $(XEN_LIBXUTIL)
    23.4  
    23.5  SRCS     :=
    23.6  SRCS     += xc_bvtsched.c
    23.7 +SRCS     += xc_core.c
    23.8  SRCS     += xc_domain.c
    23.9  SRCS     += xc_evtchn.c
   23.10  SRCS     += xc_gnttab.c
   23.11 @@ -29,6 +30,7 @@ SRCS     += xc_misc.c
   23.12  SRCS     += xc_physdev.c
   23.13  SRCS     += xc_private.c
   23.14  SRCS     += xc_ptrace.c
   23.15 +SRCS     += xc_ptrace_core.c
   23.16  SRCS     += xc_vmx_build.c
   23.17  
   23.18  CFLAGS   += -Wall
    24.1 --- a/tools/libxc/xc.h	Fri Apr 29 16:49:15 2005 +0000
    24.2 +++ b/tools/libxc/xc.h	Tue May 03 08:08:47 2005 +0000
    24.3 @@ -20,6 +20,7 @@ typedef int16_t            s16;
    24.4  typedef int32_t            s32;
    24.5  typedef int64_t            s64;
    24.6  
    24.7 +#include <sys/ptrace.h>
    24.8  #include <xen/xen.h>
    24.9  #include <xen/dom0_ops.h>
   24.10  #include <xen/event_channel.h>
   24.11 @@ -72,6 +73,38 @@ int xc_interface_open(void);
   24.12  int xc_interface_close(int xc_handle);
   24.13  
   24.14  /*
   24.15 + * DOMAIN DEBUGGING FUNCTIONS
   24.16 + */
   24.17 +
   24.18 +typedef struct xc_core_header {
   24.19 +    unsigned int xch_magic;
   24.20 +    unsigned int xch_nr_vcpus;
   24.21 +    unsigned int xch_nr_pages;
   24.22 +    unsigned int xch_ctxt_offset;
   24.23 +    unsigned int xch_index_offset;
   24.24 +    unsigned int xch_pages_offset;
   24.25 +} xc_core_header_t;
   24.26 +
   24.27 +
   24.28 +long xc_ptrace(enum __ptrace_request request, 
   24.29 +	       u32  domid,
   24.30 +	       long addr, 
   24.31 +	       long data);
   24.32 +
   24.33 +long xc_ptrace_core(enum __ptrace_request request, 
   24.34 +		    u32 domid, 
   24.35 +		    long addr, 
   24.36 +		    long data);
   24.37 +
   24.38 +int xc_waitdomain(int domain, 
   24.39 +		  int *status, 
   24.40 +		  int options);
   24.41 +
   24.42 +int xc_waitdomain_core(int domain, 
   24.43 +		       int *status, 
   24.44 +		       int options);
   24.45 +
   24.46 +/*
   24.47   * DOMAIN MANAGEMENT FUNCTIONS
   24.48   */
   24.49  
   24.50 @@ -94,6 +127,12 @@ int xc_domain_create(int xc_handle,
   24.51                       float cpu_weight,
   24.52                       u32 *pdomid);
   24.53  
   24.54 +
   24.55 +int xc_domain_dumpcore(int xc_handle, 
   24.56 +		       u32 domid,
   24.57 +		       const char *corename);
   24.58 +
   24.59 +
   24.60  /**
   24.61   * This function pauses a domain. A paused domain still exists in memory
   24.62   * however it does not receive any timeslices from the hypervisor.
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/tools/libxc/xc_core.c	Tue May 03 08:08:47 2005 +0000
    25.3 @@ -0,0 +1,99 @@
    25.4 +#include "xc_private.h"
    25.5 +#define ELFSIZE 32
    25.6 +#include "xc_elf.h"
    25.7 +#include <stdlib.h>
    25.8 +#include <zlib.h>
    25.9 +
   25.10 +/* number of pages to write at a time */
   25.11 +#define DUMP_INCREMENT 4 * 1024
   25.12 +#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
   25.13 +static int
   25.14 +copy_from_domain_page(int xc_handle,
   25.15 +		      u32 domid,
   25.16 +		      unsigned long *page_array,
   25.17 +		      unsigned long src_pfn,
   25.18 +		      void *dst_page)
   25.19 +{
   25.20 +    void *vaddr = xc_map_foreign_range(
   25.21 +        xc_handle, domid, PAGE_SIZE, PROT_READ, page_array[src_pfn]);
   25.22 +    if ( vaddr == NULL )
   25.23 +        return -1;
   25.24 +    memcpy(dst_page, vaddr, PAGE_SIZE);
   25.25 +    munmap(vaddr, PAGE_SIZE);
   25.26 +    return 0;
   25.27 +}
   25.28 +
   25.29 +int 
   25.30 +xc_domain_dumpcore(int xc_handle,
   25.31 +		   u32 domid,
   25.32 +		   const char *corename)
   25.33 +{
   25.34 +	vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
   25.35 +	unsigned long nr_pages;
   25.36 +	unsigned long *page_array;
   25.37 +	xc_domaininfo_t st_info, *info = &st_info;
   25.38 +	int i, dump_fd;
   25.39 +	char *dump_mem, *dump_mem_start = NULL;
   25.40 +	struct xc_core_header header;
   25.41 +	
   25.42 +	if ((dump_fd = open(corename, O_CREAT|O_RDWR, S_IWUSR|S_IRUSR)) < 0) {
   25.43 +		PERROR("Could not open corefile %s: %s", corename, strerror(errno));
   25.44 +		goto error_out;
   25.45 +	}
   25.46 +	
   25.47 +	if ((dump_mem_start = malloc(DUMP_INCREMENT*PAGE_SIZE)) == 0) {
   25.48 +		PERROR("Could not allocate dump_mem");
   25.49 +		goto error_out;
   25.50 +	}
   25.51 +	
   25.52 +	if (xc_domain_getfullinfo(xc_handle, domid, 0/* XXX hardcode */, info, ctxt)) {
   25.53 +		PERROR("Could not get full info for domain");
   25.54 +		goto error_out;
   25.55 +	}
   25.56 +
   25.57 +	nr_pages = info->tot_pages;
   25.58 +	header.xch_magic = 0xF00FEBED; 
   25.59 +	header.xch_nr_vcpus = 1; /* no interface to query at the moment */
   25.60 +	header.xch_nr_pages = nr_pages;
   25.61 +	header.xch_ctxt_offset = sizeof(struct xc_core_header);
   25.62 +	header.xch_index_offset = sizeof(struct xc_core_header) +
   25.63 +	    sizeof(vcpu_guest_context_t);
   25.64 +	header.xch_pages_offset = round_pgup(sizeof(struct xc_core_header) +
   25.65 +	    sizeof(vcpu_guest_context_t) + nr_pages * sizeof(unsigned long));
   25.66 +
   25.67 +	write(dump_fd, &header, sizeof(struct xc_core_header));
   25.68 +	write(dump_fd, ctxt, sizeof(st_ctxt));
   25.69 +
   25.70 +	if ((page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL) {
   25.71 +	    printf("Could not allocate memory\n");
   25.72 +	    goto error_out;
   25.73 +	}
   25.74 +	if (xc_get_pfn_list(xc_handle, domid, page_array, nr_pages) != nr_pages) {
   25.75 +	    printf("Could not get the page frame list\n");
   25.76 +	    goto error_out;
   25.77 +	}
   25.78 +	write(dump_fd, page_array, nr_pages * sizeof(unsigned long));
   25.79 +	lseek(dump_fd, header.xch_pages_offset, SEEK_SET);
   25.80 +	for (dump_mem = dump_mem_start, i = 0; i < nr_pages; i++) {
   25.81 +		copy_from_domain_page(xc_handle, domid, page_array, i, dump_mem);
   25.82 +		dump_mem += PAGE_SIZE;
   25.83 +		if (((i + 1) % DUMP_INCREMENT == 0) || (i + 1) == nr_pages) {
   25.84 +			if (write(dump_fd, dump_mem_start, dump_mem - dump_mem_start) < 
   25.85 +			    dump_mem - dump_mem_start) {
   25.86 +				PERROR("Partial write, file system full?");
   25.87 +				goto error_out;
   25.88 +			}
   25.89 +			dump_mem = dump_mem_start;
   25.90 +		}
   25.91 +	}
   25.92 +
   25.93 +	close(dump_fd);
   25.94 +	free(dump_mem_start);
   25.95 +	return 0;
   25.96 + error_out:
   25.97 +	if (dump_fd)
   25.98 +		close(dump_fd);
   25.99 +	if (dump_mem_start)
  25.100 +		free(dump_mem_start);
  25.101 +	return -1;
  25.102 +}
    26.1 --- a/tools/libxc/xc_ptrace.c	Fri Apr 29 16:49:15 2005 +0000
    26.2 +++ b/tools/libxc/xc_ptrace.c	Tue May 03 08:08:47 2005 +0000
    26.3 @@ -17,8 +17,7 @@
    26.4   * ptrace(enum __ptrace_request request, pid_t pid, void *addr, void *data);
    26.5   */
    26.6  
    26.7 -long xc_ptrace(enum __ptrace_request request, 
    26.8 -	       pid_t pid, void *addr, void *data);
    26.9 +
   26.10  int waitdomain(int domain, int *status, int options);
   26.11  
   26.12  char * ptrace_names[] = {
   26.13 @@ -181,7 +180,8 @@ map_domain_va(unsigned long domid, int c
   26.14      } 
   26.15      if ((pde = cr3_virt[cpu][vtopdi(va)]) == 0) /* logical address */
   26.16  	goto error_out;
   26.17 -    pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
   26.18 +    if (ctxt[cpu].flags & VGCF_VMX_GUEST)
   26.19 +        pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
   26.20      if (pde != pde_phys[cpu]) 
   26.21      {
   26.22  	pde_phys[cpu] = pde;
   26.23 @@ -194,7 +194,8 @@ map_domain_va(unsigned long domid, int c
   26.24      }
   26.25      if ((page = pde_virt[cpu][vtopti(va)]) == 0) /* logical address */
   26.26  	goto error_out;
   26.27 -    page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
   26.28 +    if (ctxt[cpu].flags & VGCF_VMX_GUEST)
   26.29 +        page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
   26.30      if (page != page_phys[cpu] || perm != prev_perm[cpu]) 
   26.31      {
   26.32  	page_phys[cpu] = page;
   26.33 @@ -216,7 +217,7 @@ map_domain_va(unsigned long domid, int c
   26.34  }
   26.35  
   26.36  int 
   26.37 -waitdomain(int domain, int *status, int options)
   26.38 +xc_waitdomain(int domain, int *status, int options)
   26.39  {
   26.40      dom0_op_t op;
   26.41      int retval;
   26.42 @@ -258,7 +259,7 @@ waitdomain(int domain, int *status, int 
   26.43  }
   26.44  
   26.45  long
   26.46 -xc_ptrace(enum __ptrace_request request, pid_t domid, void *addr, void *data)
   26.47 +xc_ptrace(enum __ptrace_request request, u32 domid, long eaddr, long edata)
   26.48  {
   26.49      dom0_op_t       op;
   26.50      int             status = 0;
   26.51 @@ -266,6 +267,8 @@ xc_ptrace(enum __ptrace_request request,
   26.52      long            retval = 0;
   26.53      unsigned long  *guest_va;
   26.54      int             cpu = VCPU;
   26.55 +    void           *addr = (char *)eaddr;
   26.56 +    void           *data = (char *)edata;
   26.57  
   26.58      op.interface_version = DOM0_INTERFACE_VERSION;
   26.59      
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/tools/libxc/xc_ptrace_core.c	Tue May 03 08:08:47 2005 +0000
    27.3 @@ -0,0 +1,287 @@
    27.4 +#include <sys/ptrace.h>
    27.5 +#include <sys/wait.h>
    27.6 +#include "xc_private.h"
    27.7 +#include <asm/elf.h>
    27.8 +#include <time.h>
    27.9 +
   27.10 +
   27.11 +#define BSD_PAGE_MASK	(PAGE_SIZE-1)
   27.12 +#define	PG_FRAME	(~((unsigned long)BSD_PAGE_MASK)
   27.13 +#define PDRSHIFT        22
   27.14 +#define	PSL_T		0x00000100	/* trace enable bit */
   27.15 +
   27.16 +#define VCPU            0               /* XXX */
   27.17 +
   27.18 +/*
   27.19 + * long  
   27.20 + * ptrace(enum __ptrace_request request, pid_t pid, void *addr, void *data);
   27.21 + */
   27.22 +
   27.23 +
   27.24 +struct gdb_regs {
   27.25 +    long ebx; /* 0 */
   27.26 +    long ecx; /* 4 */
   27.27 +    long edx; /* 8 */
   27.28 +    long esi; /* 12 */
   27.29 +    long edi; /* 16 */
   27.30 +    long ebp; /* 20 */
   27.31 +    long eax; /* 24 */ 
   27.32 +    int  xds; /* 28 */
   27.33 +    int  xes; /* 32 */
   27.34 +    int  xfs; /* 36 */
   27.35 +    int  xgs; /* 40 */
   27.36 +    long orig_eax; /* 44 */
   27.37 +    long eip;    /* 48 */
   27.38 +    int  xcs;    /* 52 */
   27.39 +    long eflags; /* 56 */
   27.40 +    long esp;    /* 60 */     
   27.41 +    int  xss;    /* 64 */
   27.42 +};
   27.43 +
   27.44 +#define printval(x) printf("%s = %lx\n", #x, (long)x);
   27.45 +#define SET_PT_REGS(pt, xc) \
   27.46 +{ \
   27.47 +    pt.ebx = xc.ebx; \
   27.48 +    pt.ecx = xc.ecx; \
   27.49 +    pt.edx = xc.edx; \
   27.50 +    pt.esi = xc.esi; \
   27.51 +    pt.edi = xc.edi; \
   27.52 +    pt.ebp = xc.ebp; \
   27.53 +    pt.eax = xc.eax; \
   27.54 +    pt.eip = xc.eip; \
   27.55 +    pt.xcs = xc.cs; \
   27.56 +    pt.eflags = xc.eflags; \
   27.57 +    pt.esp = xc.esp; \
   27.58 +    pt.xss = xc.ss; \
   27.59 +    pt.xes = xc.es; \
   27.60 +    pt.xds = xc.ds; \
   27.61 +    pt.xfs = xc.fs; \
   27.62 +    pt.xgs = xc.gs; \
   27.63 +}
   27.64 +
   27.65 +#define SET_XC_REGS(pt, xc) \
   27.66 +{ \
   27.67 +    xc.ebx = pt->ebx; \
   27.68 +    xc.ecx = pt->ecx; \
   27.69 +    xc.edx = pt->edx; \
   27.70 +    xc.esi = pt->esi; \
   27.71 +    xc.edi = pt->edi; \
   27.72 +    xc.ebp = pt->ebp; \
   27.73 +    xc.eax = pt->eax; \
   27.74 +    xc.eip = pt->eip; \
   27.75 +    xc.cs = pt->xcs; \
   27.76 +    xc.eflags = pt->eflags; \
   27.77 +    xc.esp = pt->esp; \
   27.78 +    xc.ss = pt->xss; \
   27.79 +    xc.es = pt->xes; \
   27.80 +    xc.ds = pt->xds; \
   27.81 +    xc.fs = pt->xfs; \
   27.82 +    xc.gs = pt->xgs; \
   27.83 +}
   27.84 +
   27.85 +
   27.86 +#define vtopdi(va) ((va) >> PDRSHIFT)
   27.87 +#define vtopti(va) (((va) >> PAGE_SHIFT) & 0x3ff)
   27.88 +
   27.89 +/* XXX application state */
   27.90 +
   27.91 +
   27.92 +static long			nr_pages = 0;
   27.93 +static unsigned long		*p2m_array = NULL;
   27.94 +static unsigned long		*m2p_array = NULL;
   27.95 +static unsigned long            pages_offset;
   27.96 +static unsigned long            cr3[MAX_VIRT_CPUS];
   27.97 +static vcpu_guest_context_t     ctxt[MAX_VIRT_CPUS];
   27.98 +
   27.99 +/* --------------------- */
  27.100 +
  27.101 +static unsigned long
  27.102 +map_mtop_offset(unsigned long ma)
  27.103 +{
  27.104 +    return pages_offset + (m2p_array[ma >> PAGE_SHIFT] << PAGE_SHIFT);
  27.105 +}
  27.106 +
  27.107 +
  27.108 +static void *
  27.109 +map_domain_va(unsigned long domfd, int cpu, void * guest_va)
  27.110 +{
  27.111 +    unsigned long pde, page;
  27.112 +    unsigned long va = (unsigned long)guest_va;
  27.113 +
  27.114 +    static unsigned long  cr3_phys[MAX_VIRT_CPUS];
  27.115 +    static unsigned long *cr3_virt[MAX_VIRT_CPUS];
  27.116 +    static unsigned long  pde_phys[MAX_VIRT_CPUS];
  27.117 +    static unsigned long *pde_virt[MAX_VIRT_CPUS];
  27.118 +    static unsigned long  page_phys[MAX_VIRT_CPUS];
  27.119 +    static unsigned long *page_virt[MAX_VIRT_CPUS];
  27.120 +
  27.121 +    if (cr3[cpu] != cr3_phys[cpu]) 
  27.122 +    {
  27.123 +	cr3_phys[cpu] = cr3[cpu];
  27.124 +	if (cr3_virt[cpu])
  27.125 +	    munmap(cr3_virt[cpu], PAGE_SIZE);
  27.126 +	if ((cr3_virt[cpu] = mmap(NULL, PAGE_SIZE, PROT_READ, 
  27.127 +				  MAP_PRIVATE, domfd, map_mtop_offset(cr3_phys[cpu]))) == 
  27.128 +	    (unsigned long*)0xffffffff)
  27.129 +	{
  27.130 +	    perror("mmap failed");
  27.131 +	    goto error_out;
  27.132 +	}
  27.133 +    } 
  27.134 +    if ((pde = cr3_virt[cpu][vtopdi(va)]) == 0) /* logical address */
  27.135 +	goto error_out;
  27.136 +    if (ctxt[cpu].flags & VGCF_VMX_GUEST)
  27.137 +	pde = p2m_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
  27.138 +    if (pde != pde_phys[cpu]) 
  27.139 +    {
  27.140 +	pde_phys[cpu] = pde;
  27.141 +	if (pde_virt[cpu])
  27.142 +	    munmap(pde_virt[cpu], PAGE_SIZE);
  27.143 +	if ((pde_virt[cpu] =  mmap(NULL, PAGE_SIZE, PROT_READ, 
  27.144 +				  MAP_PRIVATE, domfd, map_mtop_offset(pde_phys[cpu]))) == NULL)
  27.145 +	    goto error_out;
  27.146 +    }
  27.147 +    if ((page = pde_virt[cpu][vtopti(va)]) == 0) /* logical address */
  27.148 +	goto error_out;
  27.149 +    if (ctxt[cpu].flags & VGCF_VMX_GUEST)
  27.150 +	page = p2m_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
  27.151 +    if (page != page_phys[cpu]) 
  27.152 +    {
  27.153 +	page_phys[cpu] = page;
  27.154 +	if (page_virt[cpu])
  27.155 +	    munmap(page_virt[cpu], PAGE_SIZE);
  27.156 +	if ((page_virt[cpu] = mmap(NULL, PAGE_SIZE, PROT_READ, 
  27.157 +				  MAP_PRIVATE, domfd, map_mtop_offset(page_phys[cpu]))) == NULL) {
  27.158 +	    printf("cr3 %lx pde %lx page %lx pti %lx\n", cr3[cpu], pde, page, vtopti(va));
  27.159 +	    page_phys[cpu] = 0;
  27.160 +	    goto error_out;
  27.161 +	}
  27.162 +    }	
  27.163 +    return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
  27.164 +
  27.165 + error_out:
  27.166 +    return 0;
  27.167 +}
  27.168 +
  27.169 +int 
  27.170 +xc_waitdomain_core(int domfd, int *status, int options)
  27.171 +{
  27.172 +    int retval = -1;
  27.173 +    int nr_vcpus;
  27.174 +    int i;
  27.175 +    xc_core_header_t header;
  27.176 +
  27.177 +    if (nr_pages == 0) {
  27.178 +
  27.179 +	if (read(domfd, &header, sizeof(header)) != sizeof(header))
  27.180 +	    return -1;
  27.181 +
  27.182 +	nr_pages = header.xch_nr_pages;
  27.183 +	nr_vcpus = header.xch_nr_vcpus;
  27.184 +	pages_offset = header.xch_pages_offset;
  27.185 +
  27.186 +	if (read(domfd, ctxt, sizeof(vcpu_guest_context_t)*nr_vcpus) != 
  27.187 +	    sizeof(vcpu_guest_context_t)*nr_vcpus)
  27.188 +	    return -1;
  27.189 +
  27.190 +	for (i = 0; i < nr_vcpus; i++) {
  27.191 +	    cr3[i] = ctxt[i].pt_base;
  27.192 +	}
  27.193 +	if ((p2m_array = malloc(nr_pages * sizeof(unsigned long))) == NULL) {
  27.194 +	    printf("Could not allocate p2m_array\n");
  27.195 +	    goto error_out;
  27.196 +	}
  27.197 +	if (read(domfd, p2m_array, sizeof(unsigned long)*nr_pages) != 
  27.198 +	    sizeof(unsigned long)*nr_pages)
  27.199 +	    return -1;
  27.200 +
  27.201 +	if ((m2p_array = malloc((1<<20) * sizeof(unsigned long))) == NULL) {
  27.202 +	    printf("Could not allocate m2p array\n");
  27.203 +	    goto error_out;
  27.204 +	}
  27.205 +	bzero(m2p_array, sizeof(unsigned long)* 1 << 20);
  27.206 +
  27.207 +	for (i = 0; i < nr_pages; i++) {
  27.208 +	    m2p_array[p2m_array[i]] = i;
  27.209 +	}
  27.210 +
  27.211 +    }
  27.212 +    retval = 0;
  27.213 + error_out:
  27.214 +    return retval;
  27.215 +
  27.216 +}
  27.217 +
  27.218 +long
  27.219 +xc_ptrace_core(enum __ptrace_request request, u32 domfd, long eaddr, long edata)
  27.220 +{
  27.221 +    int             status = 0;
  27.222 +    struct gdb_regs pt;
  27.223 +    long            retval = 0;
  27.224 +    unsigned long  *guest_va;
  27.225 +    int             cpu = VCPU;
  27.226 +    void           *addr = (char *)eaddr;
  27.227 +    void           *data = (char *)edata;
  27.228 +
  27.229 +#if 0
  27.230 +    printf("%20s %d, %p, %p \n", ptrace_names[request], domid, addr, data);
  27.231 +#endif
  27.232 +    switch (request) {	
  27.233 +    case PTRACE_PEEKTEXT:
  27.234 +    case PTRACE_PEEKDATA:
  27.235 +	if ((guest_va = (unsigned long *)map_domain_va(domfd, cpu, addr)) == NULL) {
  27.236 +	    status = EFAULT;
  27.237 +	    goto error_out;
  27.238 +	}
  27.239 +
  27.240 +	retval = *guest_va;
  27.241 +	break;
  27.242 +    case PTRACE_POKETEXT:
  27.243 +    case PTRACE_POKEDATA:
  27.244 +	if ((guest_va = (unsigned long *)map_domain_va(domfd, cpu, addr)) == NULL) {
  27.245 +	    status = EFAULT;
  27.246 +	    goto error_out;
  27.247 +	}
  27.248 +	*guest_va = (unsigned long)data;
  27.249 +	break;
  27.250 +    case PTRACE_GETREGS:
  27.251 +    case PTRACE_GETFPREGS:
  27.252 +    case PTRACE_GETFPXREGS:
  27.253 +	if (request == PTRACE_GETREGS) {
  27.254 +		SET_PT_REGS(pt, ctxt[cpu].user_regs); 
  27.255 +		memcpy(data, &pt, sizeof(elf_gregset_t));
  27.256 +	} else if (request == PTRACE_GETFPREGS)
  27.257 +	    memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof(ctxt[cpu].fpu_ctxt));
  27.258 +	else /*if (request == PTRACE_GETFPXREGS)*/
  27.259 +	    memcpy(data, &ctxt[cpu].fpu_ctxt, sizeof(ctxt[cpu].fpu_ctxt));
  27.260 +	break;
  27.261 +    case PTRACE_ATTACH:
  27.262 +	retval = 0;
  27.263 +	break;
  27.264 +    case PTRACE_SETREGS:
  27.265 +    case PTRACE_SINGLESTEP:
  27.266 +    case PTRACE_CONT:
  27.267 +    case PTRACE_DETACH:
  27.268 +    case PTRACE_SETFPREGS:
  27.269 +    case PTRACE_SETFPXREGS:
  27.270 +    case PTRACE_PEEKUSER:
  27.271 +    case PTRACE_POKEUSER:
  27.272 +    case PTRACE_SYSCALL:
  27.273 +    case PTRACE_KILL:
  27.274 +#ifdef DEBUG
  27.275 +	printf("unsupported xc_ptrace request %s\n", ptrace_names[request]);
  27.276 +#endif
  27.277 +	status = ENOSYS;
  27.278 +	break;
  27.279 +    case PTRACE_TRACEME:
  27.280 +	printf("PTRACE_TRACEME is an invalid request under Xen\n");
  27.281 +	status = EINVAL;
  27.282 +    }
  27.283 +    
  27.284 +    if (status) {
  27.285 +	errno = status;
  27.286 +	retval = -1;
  27.287 +    }
  27.288 + error_out:
  27.289 +    return retval;
  27.290 +}
    28.1 --- a/tools/libxc/xc_vmx_build.c	Fri Apr 29 16:49:15 2005 +0000
    28.2 +++ b/tools/libxc/xc_vmx_build.c	Tue May 03 08:08:47 2005 +0000
    28.3 @@ -313,6 +313,16 @@ static int setup_guest(int xc_handle,
    28.4      munmap(vl1tab, PAGE_SIZE);
    28.5      munmap(vl2tab, PAGE_SIZE);
    28.6  
    28.7 +    /* Write the machine->phys table entries. */
    28.8 +    for ( count = 0; count < nr_pages; count++ )
    28.9 +    {
   28.10 +        if ( add_mmu_update(xc_handle, mmu,
   28.11 +                            (page_array[count] << PAGE_SHIFT) | 
   28.12 +                            MMU_MACHPHYS_UPDATE, count) )
   28.13 +	    goto error_out;
   28.14 +    }
   28.15 +    
   28.16 +
   28.17      if ((boot_paramsp = xc_map_foreign_range(
   28.18  		xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   28.19  		page_array[(vboot_params_start-dsi.v_start)>>PAGE_SHIFT])) == 0)
    29.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Apr 29 16:49:15 2005 +0000
    29.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue May 03 08:08:47 2005 +0000
    29.3 @@ -36,6 +36,33 @@ typedef struct {
    29.4   * Definitions for the 'xc' object type.
    29.5   */
    29.6  
    29.7 +static PyObject *pyxc_domain_dumpcore(PyObject *self,
    29.8 +				      PyObject *args,
    29.9 +				      PyObject *kwds)
   29.10 +{
   29.11 +    XcObject *xc = (XcObject *)self;
   29.12 +
   29.13 +    u32 dom;
   29.14 +    char *corefile;
   29.15 +
   29.16 +    static char *kwd_list[] = { "dom", "corefile", NULL };
   29.17 +
   29.18 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list, &dom, &corefile) )
   29.19 +        goto exit;
   29.20 +
   29.21 +    if ( (corefile == NULL) || (corefile[0] == '\0') )
   29.22 +        goto exit;
   29.23 +
   29.24 +    if ( xc_domain_dumpcore(xc->xc_handle, dom, corefile) != 0 )
   29.25 +        return PyErr_SetFromErrno(xc_error);
   29.26 +    
   29.27 +    Py_INCREF(zero);
   29.28 +    return zero;
   29.29 +
   29.30 + exit:
   29.31 +    return NULL;
   29.32 +}
   29.33 +
   29.34  static PyObject *pyxc_domain_create(PyObject *self,
   29.35                                      PyObject *args,
   29.36                                      PyObject *kwds)
   29.37 @@ -854,6 +881,14 @@ static PyMethodDef pyxc_methods[] = {
   29.38        " mem_kb [int, 0]:        Memory allocation, in kilobytes.\n"
   29.39        "Returns: [int] new domain identifier; -1 on error.\n" },
   29.40  
   29.41 +    { "domain_dumpcore", 
   29.42 +      (PyCFunction)pyxc_domain_dumpcore, 
   29.43 +      METH_VARARGS | METH_KEYWORDS, "\n"
   29.44 +      "dump core of a domain.\n"
   29.45 +      " dom [int]: Identifier of domain to be paused.\n\n"
   29.46 +      " corefile [string]: Name of corefile to be created.\n\n"
   29.47 +      "Returns: [int] 0 on success; -1 on error.\n" },
   29.48 +
   29.49      { "domain_pause", 
   29.50        (PyCFunction)pyxc_domain_pause, 
   29.51        METH_VARARGS | METH_KEYWORDS, "\n"
    30.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Apr 29 16:49:15 2005 +0000
    30.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue May 03 08:08:47 2005 +0000
    30.3 @@ -309,7 +309,9 @@ class XendDomain:
    30.4                      eserver.inject('xend.domain.exit', [name, id, reason])
    30.5                      self.domain_restart_schedule(id, reason)
    30.6              else:
    30.7 -               eserver.inject('xend.domain.exit', [name, id, 'crash'])
    30.8 +               if xroot.get_enable_dump() == 'true':
    30.9 +                   xc.domain_dumpcore(dom = int(id), corefile = "/var/xen/dump/%s.%s.core"%(name,id))
   30.10 +               eserver.inject('xend.domain.exit', [name, id, 'crash']) 
   30.11              destroyed += 1
   30.12              self.final_domain_destroy(id)
   30.13          if self.domain_restarts_exist():
    31.1 --- a/tools/python/xen/xend/XendRoot.py	Fri Apr 29 16:49:15 2005 +0000
    31.2 +++ b/tools/python/xen/xend/XendRoot.py	Tue May 03 08:08:47 2005 +0000
    31.3 @@ -296,6 +296,9 @@ class XendRoot:
    31.4      def get_network_script(self):
    31.5          return self.get_config_value('network-script', 'network')
    31.6  
    31.7 +    def get_enable_dump(self):
    31.8 +        return self.get_config_value('enable-dump', 'false')
    31.9 +
   31.10      def get_vif_bridge(self):
   31.11          return self.get_config_value('vif-bridge', 'xen-br0')
   31.12  
    32.1 --- a/xen/Rules.mk	Fri Apr 29 16:49:15 2005 +0000
    32.2 +++ b/xen/Rules.mk	Tue May 03 08:08:47 2005 +0000
    32.3 @@ -42,7 +42,7 @@ ifeq ($(verbose),y)
    32.4  CFLAGS += -DVERBOSE
    32.5  endif
    32.6  else
    32.7 -CFLAGS += -DVERBOSE
    32.8 +CFLAGS += -g -DVERBOSE
    32.9  endif
   32.10  
   32.11  ifeq ($(domu_debug),y)
    33.1 --- a/xen/arch/ia64/Makefile	Fri Apr 29 16:49:15 2005 +0000
    33.2 +++ b/xen/arch/ia64/Makefile	Tue May 03 08:08:47 2005 +0000
    33.3 @@ -6,10 +6,10 @@ OBJS = xensetup.o setup.o time.o irq.o i
    33.4  	xenmisc.o pdb-stub.o acpi.o hypercall.o \
    33.5  	machvec.o dom0_ops.o domain.o \
    33.6  	idle0_task.o pal.o hpsim.o efi.o efi_stub.o ivt.o mm_contig.o \
    33.7 -	sal.o cmdline.o mm_init.o tlb.o smpboot.o \
    33.8 -	extable.o linuxextable.o \
    33.9 +	xenmem.o sal.o cmdline.o mm_init.o tlb.o smpboot.o \
   33.10 +	extable.o linuxextable.o xenirq.o xentime.o \
   33.11  	regionreg.o entry.o unaligned.o privop.o vcpu.o \
   33.12 -	irq_ia64.o irq_lsapic.o hpsim_irq.o vhpt.o xenasm.o dom_fw.o
   33.13 +	irq_ia64.o irq_lsapic.o vhpt.o xenasm.o dom_fw.o
   33.14  # perfmon.o
   33.15  # unwind.o needed for kernel unwinding (rare)
   33.16  
    34.1 --- a/xen/arch/ia64/hypercall.c	Fri Apr 29 16:49:15 2005 +0000
    34.2 +++ b/xen/arch/ia64/hypercall.c	Tue May 03 08:08:47 2005 +0000
    34.3 @@ -32,6 +32,14 @@ ia64_hypercall (struct pt_regs *regs)
    34.4  	    case FW_HYPERCALL_PAL_CALL:
    34.5  		//printf("*** PAL hypercall: index=%d\n",regs->r28);
    34.6  		//FIXME: This should call a C routine
    34.7 +#if 1
    34.8 +		// This is very conservative, but avoids a possible
    34.9 +		// (and deadly) freeze in paravirtualized domains due
   34.10 +		// to a yet-to-be-found bug where pending_interruption
   34.11 +		// is zero when it shouldn't be. Since PAL is called
   34.12 +		// in the idle loop, this should resolve it
   34.13 +		ed->vcpu_info->arch.pending_interruption = 1;
   34.14 +#endif
   34.15  		x = pal_emulator_static(regs->r28);
   34.16  		regs->r8 = x.status; regs->r9 = x.v0;
   34.17  		regs->r10 = x.v1; regs->r11 = x.v2;
   34.18 @@ -61,7 +69,6 @@ ia64_hypercall (struct pt_regs *regs)
   34.19  #endif
   34.20  		break;
   34.21  	    case FW_HYPERCALL_EFI_GET_TIME:
   34.22 -		fooefi();
   34.23  		tv = vcpu_get_gr(ed,32);
   34.24  		tc = vcpu_get_gr(ed,33);
   34.25  		//printf("efi_get_time(%p,%p) called...",tv,tc);
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/xen/arch/ia64/ivt.S	Tue May 03 08:08:47 2005 +0000
    35.3 @@ -0,0 +1,1870 @@
    35.4 +
    35.5 +#ifdef XEN
    35.6 +//#define CONFIG_DISABLE_VHPT	// FIXME: change when VHPT is enabled??
    35.7 +// these are all hacked out for now as the entire IVT
    35.8 +// will eventually be replaced... just want to use it
    35.9 +// for startup code to handle TLB misses
   35.10 +//#define ia64_leave_kernel 0
   35.11 +//#define ia64_ret_from_syscall 0
   35.12 +//#define ia64_handle_irq 0
   35.13 +//#define ia64_fault 0
   35.14 +#define ia64_illegal_op_fault 0
   35.15 +#define ia64_prepare_handle_unaligned 0
   35.16 +#define ia64_bad_break 0
   35.17 +#define ia64_trace_syscall 0
   35.18 +#define sys_call_table 0
   35.19 +#define sys_ni_syscall 0
   35.20 +#include <asm/vhpt.h>
   35.21 +#endif
   35.22 +/*
   35.23 + * arch/ia64/kernel/ivt.S
   35.24 + *
   35.25 + * Copyright (C) 1998-2001, 2003 Hewlett-Packard Co
   35.26 + *	Stephane Eranian <eranian@hpl.hp.com>
   35.27 + *	David Mosberger <davidm@hpl.hp.com>
   35.28 + * Copyright (C) 2000, 2002-2003 Intel Co
   35.29 + *	Asit Mallick <asit.k.mallick@intel.com>
   35.30 + *      Suresh Siddha <suresh.b.siddha@intel.com>
   35.31 + *      Kenneth Chen <kenneth.w.chen@intel.com>
   35.32 + *      Fenghua Yu <fenghua.yu@intel.com>
   35.33 + *
   35.34 + * 00/08/23 Asit Mallick <asit.k.mallick@intel.com> TLB handling for SMP
   35.35 + * 00/12/20 David Mosberger-Tang <davidm@hpl.hp.com> DTLB/ITLB handler now uses virtual PT.
   35.36 + */
   35.37 +/*
   35.38 + * This file defines the interruption vector table used by the CPU.
   35.39 + * It does not include one entry per possible cause of interruption.
   35.40 + *
   35.41 + * The first 20 entries of the table contain 64 bundles each while the
   35.42 + * remaining 48 entries contain only 16 bundles each.
   35.43 + *
   35.44 + * The 64 bundles are used to allow inlining the whole handler for critical
   35.45 + * interruptions like TLB misses.
   35.46 + *
   35.47 + *  For each entry, the comment is as follows:
   35.48 + *
   35.49 + *		// 0x1c00 Entry 7 (size 64 bundles) Data Key Miss (12,51)
   35.50 + *  entry offset ----/     /         /                  /          /
   35.51 + *  entry number ---------/         /                  /          /
   35.52 + *  size of the entry -------------/                  /          /
   35.53 + *  vector name -------------------------------------/          /
   35.54 + *  interruptions triggering this vector ----------------------/
   35.55 + *
   35.56 + * The table is 32KB in size and must be aligned on 32KB boundary.
   35.57 + * (The CPU ignores the 15 lower bits of the address)
   35.58 + *
   35.59 + * Table is based upon EAS2.6 (Oct 1999)
   35.60 + */
   35.61 +
   35.62 +#include <linux/config.h>
   35.63 +
   35.64 +#include <asm/asmmacro.h>
   35.65 +#include <asm/break.h>
   35.66 +#include <asm/ia32.h>
   35.67 +#include <asm/kregs.h>
   35.68 +#include <asm/offsets.h>
   35.69 +#include <asm/pgtable.h>
   35.70 +#include <asm/processor.h>
   35.71 +#include <asm/ptrace.h>
   35.72 +#include <asm/system.h>
   35.73 +#include <asm/thread_info.h>
   35.74 +#include <asm/unistd.h>
   35.75 +#include <asm/errno.h>
   35.76 +
   35.77 +#if 1
   35.78 +# define PSR_DEFAULT_BITS	psr.ac
   35.79 +#else
   35.80 +# define PSR_DEFAULT_BITS	0
   35.81 +#endif
   35.82 +
   35.83 +#if 0
   35.84 +  /*
   35.85 +   * This lets you track the last eight faults that occurred on the CPU.  Make sure ar.k2 isn't
   35.86 +   * needed for something else before enabling this...
   35.87 +   */
   35.88 +# define DBG_FAULT(i)	mov r16=ar.k2;;	shl r16=r16,8;;	add r16=(i),r16;;mov ar.k2=r16
   35.89 +#else
   35.90 +# define DBG_FAULT(i)
   35.91 +#endif
   35.92 +
   35.93 +#define MINSTATE_VIRT	/* needed by minstate.h */
   35.94 +#include "minstate.h"
   35.95 +
   35.96 +#define FAULT(n)									\
   35.97 +	mov r31=pr;									\
   35.98 +	mov r19=n;;			/* prepare to save predicates */		\
   35.99 +	br.sptk.many dispatch_to_fault_handler
  35.100 +
  35.101 +#ifdef XEN
  35.102 +#define REFLECT(n)									\
  35.103 +	mov r31=pr;									\
  35.104 +	mov r19=n;;			/* prepare to save predicates */		\
  35.105 +	br.sptk.many dispatch_reflection
  35.106 +#endif
  35.107 +
  35.108 +	.section .text.ivt,"ax"
  35.109 +
  35.110 +	.align 32768	// align on 32KB boundary
  35.111 +	.global ia64_ivt
  35.112 +ia64_ivt:
  35.113 +/////////////////////////////////////////////////////////////////////////////////////////
  35.114 +// 0x0000 Entry 0 (size 64 bundles) VHPT Translation (8,20,47)
  35.115 +ENTRY(vhpt_miss)
  35.116 +	DBG_FAULT(0)
  35.117 +	/*
  35.118 +	 * The VHPT vector is invoked when the TLB entry for the virtual page table
  35.119 +	 * is missing.  This happens only as a result of a previous
  35.120 +	 * (the "original") TLB miss, which may either be caused by an instruction
  35.121 +	 * fetch or a data access (or non-access).
  35.122 +	 *
  35.123 +	 * What we do here is normal TLB miss handing for the _original_ miss, followed
  35.124 +	 * by inserting the TLB entry for the virtual page table page that the VHPT
  35.125 +	 * walker was attempting to access.  The latter gets inserted as long
  35.126 +	 * as both L1 and L2 have valid mappings for the faulting address.
  35.127 +	 * The TLB entry for the original miss gets inserted only if
  35.128 +	 * the L3 entry indicates that the page is present.
  35.129 +	 *
  35.130 +	 * do_page_fault gets invoked in the following cases:
  35.131 +	 *	- the faulting virtual address uses unimplemented address bits
  35.132 +	 *	- the faulting virtual address has no L1, L2, or L3 mapping
  35.133 +	 */
  35.134 +	mov r16=cr.ifa				// get address that caused the TLB miss
  35.135 +#ifdef CONFIG_HUGETLB_PAGE
  35.136 +	movl r18=PAGE_SHIFT
  35.137 +	mov r25=cr.itir
  35.138 +#endif
  35.139 +	;;
  35.140 +	rsm psr.dt				// use physical addressing for data
  35.141 +	mov r31=pr				// save the predicate registers
  35.142 +	mov r19=IA64_KR(PT_BASE)		// get page table base address
  35.143 +	shl r21=r16,3				// shift bit 60 into sign bit
  35.144 +	shr.u r17=r16,61			// get the region number into r17
  35.145 +	;;
  35.146 +	shr r22=r21,3
  35.147 +#ifdef CONFIG_HUGETLB_PAGE
  35.148 +	extr.u r26=r25,2,6
  35.149 +	;;
  35.150 +	cmp.ne p8,p0=r18,r26
  35.151 +	sub r27=r26,r18
  35.152 +	;;
  35.153 +(p8)	dep r25=r18,r25,2,6
  35.154 +(p8)	shr r22=r22,r27
  35.155 +#endif
  35.156 +	;;
  35.157 +	cmp.eq p6,p7=5,r17			// is IFA pointing into to region 5?
  35.158 +	shr.u r18=r22,PGDIR_SHIFT		// get bits 33-63 of the faulting address
  35.159 +	;;
  35.160 +(p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
  35.161 +
  35.162 +	srlz.d
  35.163 +	LOAD_PHYSICAL(p6, r19, swapper_pg_dir)	// region 5 is rooted at swapper_pg_dir
  35.164 +
  35.165 +	.pred.rel "mutex", p6, p7
  35.166 +(p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
  35.167 +(p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
  35.168 +	;;
  35.169 +(p6)	dep r17=r18,r19,3,(PAGE_SHIFT-3)	// r17=PTA + IFA(33,42)*8
  35.170 +(p7)	dep r17=r18,r17,3,(PAGE_SHIFT-6)	// r17=PTA + (((IFA(61,63) << 7) | IFA(33,39))*8)
  35.171 +	cmp.eq p7,p6=0,r21			// unused address bits all zeroes?
  35.172 +	shr.u r18=r22,PMD_SHIFT			// shift L2 index into position
  35.173 +	;;
  35.174 +	ld8 r17=[r17]				// fetch the L1 entry (may be 0)
  35.175 +	;;
  35.176 +(p7)	cmp.eq p6,p7=r17,r0			// was L1 entry NULL?
  35.177 +	dep r17=r18,r17,3,(PAGE_SHIFT-3)	// compute address of L2 page table entry
  35.178 +	;;
  35.179 +(p7)	ld8 r20=[r17]				// fetch the L2 entry (may be 0)
  35.180 +	shr.u r19=r22,PAGE_SHIFT		// shift L3 index into position
  35.181 +	;;
  35.182 +(p7)	cmp.eq.or.andcm p6,p7=r20,r0		// was L2 entry NULL?
  35.183 +	dep r21=r19,r20,3,(PAGE_SHIFT-3)	// compute address of L3 page table entry
  35.184 +	;;
  35.185 +(p7)	ld8 r18=[r21]				// read the L3 PTE
  35.186 +	mov r19=cr.isr				// cr.isr bit 0 tells us if this is an insn miss
  35.187 +	;;
  35.188 +(p7)	tbit.z p6,p7=r18,_PAGE_P_BIT		// page present bit cleared?
  35.189 +	mov r22=cr.iha				// get the VHPT address that caused the TLB miss
  35.190 +	;;					// avoid RAW on p7
  35.191 +(p7)	tbit.nz.unc p10,p11=r19,32		// is it an instruction TLB miss?
  35.192 +	dep r23=0,r20,0,PAGE_SHIFT		// clear low bits to get page address
  35.193 +	;;
  35.194 +(p10)	itc.i r18				// insert the instruction TLB entry
  35.195 +(p11)	itc.d r18				// insert the data TLB entry
  35.196 +(p6)	br.cond.spnt.many page_fault		// handle bad address/page not present (page fault)
  35.197 +	mov cr.ifa=r22
  35.198 +
  35.199 +#ifdef CONFIG_HUGETLB_PAGE
  35.200 +(p8)	mov cr.itir=r25				// change to default page-size for VHPT
  35.201 +#endif
  35.202 +
  35.203 +	/*
  35.204 +	 * Now compute and insert the TLB entry for the virtual page table.  We never
  35.205 +	 * execute in a page table page so there is no need to set the exception deferral
  35.206 +	 * bit.
  35.207 +	 */
  35.208 +	adds r24=__DIRTY_BITS_NO_ED|_PAGE_PL_0|_PAGE_AR_RW,r23
  35.209 +	;;
  35.210 +(p7)	itc.d r24
  35.211 +	;;
  35.212 +#ifdef CONFIG_SMP
  35.213 +	/*
  35.214 +	 * Tell the assemblers dependency-violation checker that the above "itc" instructions
  35.215 +	 * cannot possibly affect the following loads:
  35.216 +	 */
  35.217 +	dv_serialize_data
  35.218 +
  35.219 +	/*
  35.220 +	 * Re-check L2 and L3 pagetable.  If they changed, we may have received a ptc.g
  35.221 +	 * between reading the pagetable and the "itc".  If so, flush the entry we
  35.222 +	 * inserted and retry.
  35.223 +	 */
  35.224 +	ld8 r25=[r21]				// read L3 PTE again
  35.225 +	ld8 r26=[r17]				// read L2 entry again
  35.226 +	;;
  35.227 +	cmp.ne p6,p7=r26,r20			// did L2 entry change
  35.228 +	mov r27=PAGE_SHIFT<<2
  35.229 +	;;
  35.230 +(p6)	ptc.l r22,r27				// purge PTE page translation
  35.231 +(p7)	cmp.ne.or.andcm p6,p7=r25,r18		// did L3 PTE change
  35.232 +	;;
  35.233 +(p6)	ptc.l r16,r27				// purge translation
  35.234 +#endif
  35.235 +
  35.236 +	mov pr=r31,-1				// restore predicate registers
  35.237 +	rfi
  35.238 +END(vhpt_miss)
  35.239 +
  35.240 +	.org ia64_ivt+0x400
  35.241 +/////////////////////////////////////////////////////////////////////////////////////////
  35.242 +// 0x0400 Entry 1 (size 64 bundles) ITLB (21)
  35.243 +ENTRY(itlb_miss)
  35.244 +	DBG_FAULT(1)
  35.245 +#ifdef XEN
  35.246 +	VHPT_CCHAIN_LOOKUP(itlb_miss,i)
  35.247 +#ifdef VHPT_GLOBAL
  35.248 +	br.cond.sptk page_fault
  35.249 +	;;
  35.250 +#endif
  35.251 +#endif
  35.252 +	/*
  35.253 +	 * The ITLB handler accesses the L3 PTE via the virtually mapped linear
  35.254 +	 * page table.  If a nested TLB miss occurs, we switch into physical
  35.255 +	 * mode, walk the page table, and then re-execute the L3 PTE read
  35.256 +	 * and go on normally after that.
  35.257 +	 */
  35.258 +	mov r16=cr.ifa				// get virtual address
  35.259 +	mov r29=b0				// save b0
  35.260 +	mov r31=pr				// save predicates
  35.261 +.itlb_fault:
  35.262 +	mov r17=cr.iha				// get virtual address of L3 PTE
  35.263 +	movl r30=1f				// load nested fault continuation point
  35.264 +	;;
  35.265 +1:	ld8 r18=[r17]				// read L3 PTE
  35.266 +	;;
  35.267 +	mov b0=r29
  35.268 +	tbit.z p6,p0=r18,_PAGE_P_BIT		// page present bit cleared?
  35.269 +(p6)	br.cond.spnt page_fault
  35.270 +	;;
  35.271 +	itc.i r18
  35.272 +	;;
  35.273 +#ifdef CONFIG_SMP
  35.274 +	/*
  35.275 +	 * Tell the assemblers dependency-violation checker that the above "itc" instructions
  35.276 +	 * cannot possibly affect the following loads:
  35.277 +	 */
  35.278 +	dv_serialize_data
  35.279 +
  35.280 +	ld8 r19=[r17]				// read L3 PTE again and see if same
  35.281 +	mov r20=PAGE_SHIFT<<2			// setup page size for purge
  35.282 +	;;
  35.283 +	cmp.ne p7,p0=r18,r19
  35.284 +	;;
  35.285 +(p7)	ptc.l r16,r20
  35.286 +#endif
  35.287 +	mov pr=r31,-1
  35.288 +	rfi
  35.289 +END(itlb_miss)
  35.290 +
  35.291 +	.org ia64_ivt+0x0800
  35.292 +/////////////////////////////////////////////////////////////////////////////////////////
  35.293 +// 0x0800 Entry 2 (size 64 bundles) DTLB (9,48)
  35.294 +ENTRY(dtlb_miss)
  35.295 +	DBG_FAULT(2)
  35.296 +#ifdef XEN
  35.297 +	VHPT_CCHAIN_LOOKUP(dtlb_miss,d)
  35.298 +#ifdef VHPT_GLOBAL
  35.299 +	br.cond.sptk page_fault
  35.300 +	;;
  35.301 +#endif
  35.302 +#endif
  35.303 +	/*
  35.304 +	 * The DTLB handler accesses the L3 PTE via the virtually mapped linear
  35.305 +	 * page table.  If a nested TLB miss occurs, we switch into physical
  35.306 +	 * mode, walk the page table, and then re-execute the L3 PTE read
  35.307 +	 * and go on normally after that.
  35.308 +	 */
  35.309 +	mov r16=cr.ifa				// get virtual address
  35.310 +	mov r29=b0				// save b0
  35.311 +	mov r31=pr				// save predicates
  35.312 +dtlb_fault:
  35.313 +	mov r17=cr.iha				// get virtual address of L3 PTE
  35.314 +	movl r30=1f				// load nested fault continuation point
  35.315 +	;;
  35.316 +1:	ld8 r18=[r17]				// read L3 PTE
  35.317 +	;;
  35.318 +	mov b0=r29
  35.319 +	tbit.z p6,p0=r18,_PAGE_P_BIT		// page present bit cleared?
  35.320 +(p6)	br.cond.spnt page_fault
  35.321 +	;;
  35.322 +	itc.d r18
  35.323 +	;;
  35.324 +#ifdef CONFIG_SMP
  35.325 +	/*
  35.326 +	 * Tell the assemblers dependency-violation checker that the above "itc" instructions
  35.327 +	 * cannot possibly affect the following loads:
  35.328 +	 */
  35.329 +	dv_serialize_data
  35.330 +
  35.331 +	ld8 r19=[r17]				// read L3 PTE again and see if same
  35.332 +	mov r20=PAGE_SHIFT<<2			// setup page size for purge
  35.333 +	;;
  35.334 +	cmp.ne p7,p0=r18,r19
  35.335 +	;;
  35.336 +(p7)	ptc.l r16,r20
  35.337 +#endif
  35.338 +	mov pr=r31,-1
  35.339 +	rfi
  35.340 +END(dtlb_miss)
  35.341 +
  35.342 +	.org ia64_ivt+0x0c00
  35.343 +/////////////////////////////////////////////////////////////////////////////////////////
  35.344 +// 0x0c00 Entry 3 (size 64 bundles) Alt ITLB (19)
  35.345 +ENTRY(alt_itlb_miss)
  35.346 +	DBG_FAULT(3)
  35.347 +#ifdef XEN
  35.348 +//#ifdef VHPT_GLOBAL
  35.349 +//	VHPT_CCHAIN_LOOKUP(alt_itlb_miss,i)
  35.350 +//	br.cond.sptk page_fault
  35.351 +//	;;
  35.352 +//#endif
  35.353 +#endif
  35.354 +	mov r16=cr.ifa		// get address that caused the TLB miss
  35.355 +	movl r17=PAGE_KERNEL
  35.356 +	mov r21=cr.ipsr
  35.357 +	movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
  35.358 +	mov r31=pr
  35.359 +	;;
  35.360 +#ifdef CONFIG_DISABLE_VHPT
  35.361 +	shr.u r22=r16,61			// get the region number into r21
  35.362 +	;;
  35.363 +	cmp.gt p8,p0=6,r22			// user mode
  35.364 +	;;
  35.365 +(p8)	thash r17=r16
  35.366 +	;;
  35.367 +(p8)	mov cr.iha=r17
  35.368 +(p8)	mov r29=b0				// save b0
  35.369 +(p8)	br.cond.dptk .itlb_fault
  35.370 +#endif
  35.371 +	extr.u r23=r21,IA64_PSR_CPL0_BIT,2	// extract psr.cpl
  35.372 +	and r19=r19,r16		// clear ed, reserved bits, and PTE control bits
  35.373 +	shr.u r18=r16,57	// move address bit 61 to bit 4
  35.374 +	;;
  35.375 +	andcm r18=0x10,r18	// bit 4=~address-bit(61)
  35.376 +	cmp.ne p8,p0=r0,r23	// psr.cpl != 0?
  35.377 +	or r19=r17,r19		// insert PTE control bits into r19
  35.378 +	;;
  35.379 +	or r19=r19,r18		// set bit 4 (uncached) if the access was to region 6
  35.380 +(p8)	br.cond.spnt page_fault
  35.381 +	;;
  35.382 +	itc.i r19		// insert the TLB entry
  35.383 +	mov pr=r31,-1
  35.384 +	rfi
  35.385 +END(alt_itlb_miss)
  35.386 +
  35.387 +	.org ia64_ivt+0x1000
  35.388 +/////////////////////////////////////////////////////////////////////////////////////////
  35.389 +// 0x1000 Entry 4 (size 64 bundles) Alt DTLB (7,46)
  35.390 +ENTRY(alt_dtlb_miss)
  35.391 +	DBG_FAULT(4)
  35.392 +#ifdef XEN
  35.393 +//#ifdef VHPT_GLOBAL
  35.394 +//	VHPT_CCHAIN_LOOKUP(alt_dtlb_miss,d)
  35.395 +//	br.cond.sptk page_fault
  35.396 +//	;;
  35.397 +//#endif
  35.398 +#endif
  35.399 +	mov r16=cr.ifa		// get address that caused the TLB miss
  35.400 +	movl r17=PAGE_KERNEL
  35.401 +	mov r20=cr.isr
  35.402 +	movl r19=(((1 << IA64_MAX_PHYS_BITS) - 1) & ~0xfff)
  35.403 +	mov r21=cr.ipsr
  35.404 +	mov r31=pr
  35.405 +	;;
  35.406 +#ifdef CONFIG_DISABLE_VHPT
  35.407 +	shr.u r22=r16,61			// get the region number into r21
  35.408 +	;;
  35.409 +	cmp.gt p8,p0=6,r22			// access to region 0-5
  35.410 +	;;
  35.411 +(p8)	thash r17=r16
  35.412 +	;;
  35.413 +(p8)	mov cr.iha=r17
  35.414 +(p8)	mov r29=b0				// save b0
  35.415 +(p8)	br.cond.dptk dtlb_fault
  35.416 +#endif
  35.417 +	extr.u r23=r21,IA64_PSR_CPL0_BIT,2	// extract psr.cpl
  35.418 +	and r22=IA64_ISR_CODE_MASK,r20		// get the isr.code field
  35.419 +	tbit.nz p6,p7=r20,IA64_ISR_SP_BIT	// is speculation bit on?
  35.420 +	shr.u r18=r16,57			// move address bit 61 to bit 4
  35.421 +	and r19=r19,r16				// clear ed, reserved bits, and PTE control bits
  35.422 +	tbit.nz p9,p0=r20,IA64_ISR_NA_BIT	// is non-access bit on?
  35.423 +	;;
  35.424 +	andcm r18=0x10,r18	// bit 4=~address-bit(61)
  35.425 +	cmp.ne p8,p0=r0,r23
  35.426 +(p9)	cmp.eq.or.andcm p6,p7=IA64_ISR_CODE_LFETCH,r22	// check isr.code field
  35.427 +(p8)	br.cond.spnt page_fault
  35.428 +#ifdef XEN
  35.429 +	;;
  35.430 +	// FIXME: inadequate test, this is where we test for Xen address
  35.431 +	// note that 0xf000 (cached) and 0xd000 (uncached) addresses
  35.432 +	// should be OK.  (Though no I/O is done in Xen, EFI needs uncached
  35.433 +	// addresses and some domain EFI calls are passed through)
  35.434 +	tbit.nz p0,p8=r16,60
  35.435 +(p8)	br.cond.spnt page_fault
  35.436 +//(p8)	br.cond.spnt 0
  35.437 +	;;
  35.438 +#endif
  35.439 +
  35.440 +	dep r21=-1,r21,IA64_PSR_ED_BIT,1
  35.441 +	or r19=r19,r17		// insert PTE control bits into r19
  35.442 +	;;
  35.443 +	or r19=r19,r18		// set bit 4 (uncached) if the access was to region 6
  35.444 +(p6)	mov cr.ipsr=r21
  35.445 +	;;
  35.446 +(p7)	itc.d r19		// insert the TLB entry
  35.447 +	mov pr=r31,-1
  35.448 +	rfi
  35.449 +END(alt_dtlb_miss)
  35.450 +
  35.451 +	.org ia64_ivt+0x1400
  35.452 +/////////////////////////////////////////////////////////////////////////////////////////
  35.453 +// 0x1400 Entry 5 (size 64 bundles) Data nested TLB (6,45)
  35.454 +ENTRY(nested_dtlb_miss)
  35.455 +	/*
  35.456 +	 * In the absence of kernel bugs, we get here when the virtually mapped linear
  35.457 +	 * page table is accessed non-speculatively (e.g., in the Dirty-bit, Instruction
  35.458 +	 * Access-bit, or Data Access-bit faults).  If the DTLB entry for the virtual page
  35.459 +	 * table is missing, a nested TLB miss fault is triggered and control is
  35.460 +	 * transferred to this point.  When this happens, we lookup the pte for the
  35.461 +	 * faulting address by walking the page table in physical mode and return to the
  35.462 +	 * continuation point passed in register r30 (or call page_fault if the address is
  35.463 +	 * not mapped).
  35.464 +	 *
  35.465 +	 * Input:	r16:	faulting address
  35.466 +	 *		r29:	saved b0
  35.467 +	 *		r30:	continuation address
  35.468 +	 *		r31:	saved pr
  35.469 +	 *
  35.470 +	 * Output:	r17:	physical address of L3 PTE of faulting address
  35.471 +	 *		r29:	saved b0
  35.472 +	 *		r30:	continuation address
  35.473 +	 *		r31:	saved pr
  35.474 +	 *
  35.475 +	 * Clobbered:	b0, r18, r19, r21, psr.dt (cleared)
  35.476 +	 */
  35.477 +	rsm psr.dt				// switch to using physical data addressing
  35.478 +	mov r19=IA64_KR(PT_BASE)		// get the page table base address
  35.479 +	shl r21=r16,3				// shift bit 60 into sign bit
  35.480 +	;;
  35.481 +	shr.u r17=r16,61			// get the region number into r17
  35.482 +	;;
  35.483 +	cmp.eq p6,p7=5,r17			// is faulting address in region 5?
  35.484 +	shr.u r18=r16,PGDIR_SHIFT		// get bits 33-63 of faulting address
  35.485 +	;;
  35.486 +(p7)	dep r17=r17,r19,(PAGE_SHIFT-3),3	// put region number bits in place
  35.487 +
  35.488 +	srlz.d
  35.489 +	LOAD_PHYSICAL(p6, r19, swapper_pg_dir)	// region 5 is rooted at swapper_pg_dir
  35.490 +
  35.491 +	.pred.rel "mutex", p6, p7
  35.492 +(p6)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT
  35.493 +(p7)	shr.u r21=r21,PGDIR_SHIFT+PAGE_SHIFT-3
  35.494 +	;;
  35.495 +(p6)	dep r17=r18,r19,3,(PAGE_SHIFT-3)	// r17=PTA + IFA(33,42)*8
  35.496 +(p7)	dep r17=r18,r17,3,(PAGE_SHIFT-6)	// r17=PTA + (((IFA(61,63) << 7) | IFA(33,39))*8)
  35.497 +	cmp.eq p7,p6=0,r21			// unused address bits all zeroes?
  35.498 +	shr.u r18=r16,PMD_SHIFT			// shift L2 index into position
  35.499 +	;;
  35.500 +	ld8 r17=[r17]				// fetch the L1 entry (may be 0)
  35.501 +	;;
  35.502 +(p7)	cmp.eq p6,p7=r17,r0			// was L1 entry NULL?
  35.503 +	dep r17=r18,r17,3,(PAGE_SHIFT-3)	// compute address of L2 page table entry
  35.504 +	;;
  35.505 +(p7)	ld8 r17=[r17]				// fetch the L2 entry (may be 0)
  35.506 +	shr.u r19=r16,PAGE_SHIFT		// shift L3 index into position
  35.507 +	;;
  35.508 +(p7)	cmp.eq.or.andcm p6,p7=r17,r0		// was L2 entry NULL?
  35.509 +	dep r17=r19,r17,3,(PAGE_SHIFT-3)	// compute address of L3 page table entry
  35.510 +(p6)	br.cond.spnt page_fault
  35.511 +	mov b0=r30
  35.512 +	br.sptk.many b0				// return to continuation point
  35.513 +END(nested_dtlb_miss)
  35.514 +
  35.515 +	.org ia64_ivt+0x1800
  35.516 +/////////////////////////////////////////////////////////////////////////////////////////
  35.517 +// 0x1800 Entry 6 (size 64 bundles) Instruction Key Miss (24)
  35.518 +ENTRY(ikey_miss)
  35.519 +#ifdef XEN
  35.520 +	REFLECT(6)
  35.521 +#endif
  35.522 +	DBG_FAULT(6)
  35.523 +	FAULT(6)
  35.524 +END(ikey_miss)
  35.525 +
  35.526 +	//-----------------------------------------------------------------------------------
  35.527 +	// call do_page_fault (predicates are in r31, psr.dt may be off, r16 is faulting address)
  35.528 +ENTRY(page_fault)
  35.529 +	ssm psr.dt
  35.530 +	;;
  35.531 +	srlz.i
  35.532 +	;;
  35.533 +	SAVE_MIN_WITH_COVER
  35.534 +#ifdef XEN
  35.535 +	alloc r15=ar.pfs,0,0,4,0
  35.536 +	mov out0=cr.ifa
  35.537 +	mov out1=cr.isr
  35.538 +	mov out3=cr.itir
  35.539 +#else
  35.540 +	alloc r15=ar.pfs,0,0,3,0
  35.541 +	mov out0=cr.ifa
  35.542 +	mov out1=cr.isr
  35.543 +#endif
  35.544 +	adds r3=8,r2				// set up second base pointer
  35.545 +	;;
  35.546 +	ssm psr.ic | PSR_DEFAULT_BITS
  35.547 +	;;
  35.548 +	srlz.i					// guarantee that interruption collectin is on
  35.549 +	;;
  35.550 +(p15)	ssm psr.i				// restore psr.i
  35.551 +	movl r14=ia64_leave_kernel
  35.552 +	;;
  35.553 +	SAVE_REST
  35.554 +	mov rp=r14
  35.555 +	;;
  35.556 +	adds out2=16,r12			// out2 = pointer to pt_regs
  35.557 +	br.call.sptk.many b6=ia64_do_page_fault	// ignore return address
  35.558 +END(page_fault)
  35.559 +
  35.560 +	.org ia64_ivt+0x1c00
  35.561 +/////////////////////////////////////////////////////////////////////////////////////////
  35.562 +// 0x1c00 Entry 7 (size 64 bundles) Data Key Miss (12,51)
  35.563 +ENTRY(dkey_miss)
  35.564 +#ifdef XEN
  35.565 +	REFLECT(7)
  35.566 +#endif
  35.567 +	DBG_FAULT(7)
  35.568 +	FAULT(7)
  35.569 +END(dkey_miss)
  35.570 +
  35.571 +	.org ia64_ivt+0x2000
  35.572 +/////////////////////////////////////////////////////////////////////////////////////////
  35.573 +// 0x2000 Entry 8 (size 64 bundles) Dirty-bit (54)
  35.574 +ENTRY(dirty_bit)
  35.575 +#ifdef XEN
  35.576 +	REFLECT(8)
  35.577 +#endif
  35.578 +	DBG_FAULT(8)
  35.579 +	/*
  35.580 +	 * What we do here is to simply turn on the dirty bit in the PTE.  We need to
  35.581 +	 * update both the page-table and the TLB entry.  To efficiently access the PTE,
  35.582 +	 * we address it through the virtual page table.  Most likely, the TLB entry for
  35.583 +	 * the relevant virtual page table page is still present in the TLB so we can
  35.584 +	 * normally do this without additional TLB misses.  In case the necessary virtual
  35.585 +	 * page table TLB entry isn't present, we take a nested TLB miss hit where we look
  35.586 +	 * up the physical address of the L3 PTE and then continue at label 1 below.
  35.587 +	 */
  35.588 +	mov r16=cr.ifa				// get the address that caused the fault
  35.589 +	movl r30=1f				// load continuation point in case of nested fault
  35.590 +	;;
  35.591 +	thash r17=r16				// compute virtual address of L3 PTE
  35.592 +	mov r29=b0				// save b0 in case of nested fault
  35.593 +	mov r31=pr				// save pr
  35.594 +#ifdef CONFIG_SMP
  35.595 +	mov r28=ar.ccv				// save ar.ccv
  35.596 +	;;
  35.597 +1:	ld8 r18=[r17]
  35.598 +	;;					// avoid RAW on r18
  35.599 +	mov ar.ccv=r18				// set compare value for cmpxchg
  35.600 +	or r25=_PAGE_D|_PAGE_A,r18		// set the dirty and accessed bits
  35.601 +	;;
  35.602 +	cmpxchg8.acq r26=[r17],r25,ar.ccv
  35.603 +	mov r24=PAGE_SHIFT<<2
  35.604 +	;;
  35.605 +	cmp.eq p6,p7=r26,r18
  35.606 +	;;
  35.607 +(p6)	itc.d r25				// install updated PTE
  35.608 +	;;
  35.609 +	/*
  35.610 +	 * Tell the assemblers dependency-violation checker that the above "itc" instructions
  35.611 +	 * cannot possibly affect the following loads:
  35.612 +	 */
  35.613 +	dv_serialize_data
  35.614 +
  35.615 +	ld8 r18=[r17]				// read PTE again
  35.616 +	;;
  35.617 +	cmp.eq p6,p7=r18,r25			// is it same as the newly installed
  35.618 +	;;
  35.619 +(p7)	ptc.l r16,r24
  35.620 +	mov b0=r29				// restore b0
  35.621 +	mov ar.ccv=r28
  35.622 +#else
  35.623 +	;;
  35.624 +1:	ld8 r18=[r17]
  35.625 +	;;					// avoid RAW on r18
  35.626 +	or r18=_PAGE_D|_PAGE_A,r18		// set the dirty and accessed bits
  35.627 +	mov b0=r29				// restore b0
  35.628 +	;;
  35.629 +	st8 [r17]=r18				// store back updated PTE
  35.630 +	itc.d r18				// install updated PTE
  35.631 +#endif
  35.632 +	mov pr=r31,-1				// restore pr
  35.633 +	rfi
  35.634 +END(dirty_bit)
  35.635 +
  35.636 +	.org ia64_ivt+0x2400
  35.637 +/////////////////////////////////////////////////////////////////////////////////////////
  35.638 +// 0x2400 Entry 9 (size 64 bundles) Instruction Access-bit (27)
  35.639 +ENTRY(iaccess_bit)
  35.640 +#ifdef XEN
  35.641 +	REFLECT(9)
  35.642 +#endif
  35.643 +	DBG_FAULT(9)
  35.644 +	// Like Entry 8, except for instruction access
  35.645 +	mov r16=cr.ifa				// get the address that caused the fault
  35.646 +	movl r30=1f				// load continuation point in case of nested fault
  35.647 +	mov r31=pr				// save predicates
  35.648 +#ifdef CONFIG_ITANIUM
  35.649 +	/*
  35.650 +	 * Erratum 10 (IFA may contain incorrect address) has "NoFix" status.
  35.651 +	 */
  35.652 +	mov r17=cr.ipsr
  35.653 +	;;
  35.654 +	mov r18=cr.iip
  35.655 +	tbit.z p6,p0=r17,IA64_PSR_IS_BIT	// IA64 instruction set?
  35.656 +	;;
  35.657 +(p6)	mov r16=r18				// if so, use cr.iip instead of cr.ifa
  35.658 +#endif /* CONFIG_ITANIUM */
  35.659 +	;;
  35.660 +	thash r17=r16				// compute virtual address of L3 PTE
  35.661 +	mov r29=b0				// save b0 in case of nested fault)
  35.662 +#ifdef CONFIG_SMP
  35.663 +	mov r28=ar.ccv				// save ar.ccv
  35.664 +	;;
  35.665 +1:	ld8 r18=[r17]
  35.666 +	;;
  35.667 +	mov ar.ccv=r18				// set compare value for cmpxchg
  35.668 +	or r25=_PAGE_A,r18			// set the accessed bit
  35.669 +	;;
  35.670 +	cmpxchg8.acq r26=[r17],r25,ar.ccv
  35.671 +	mov r24=PAGE_SHIFT<<2
  35.672 +	;;
  35.673 +	cmp.eq p6,p7=r26,r18
  35.674 +	;;
  35.675 +(p6)	itc.i r25				// install updated PTE
  35.676 +	;;
  35.677 +	/*
  35.678 +	 * Tell the assemblers dependency-violation checker that the above "itc" instructions
  35.679 +	 * cannot possibly affect the following loads:
  35.680 +	 */
  35.681 +	dv_serialize_data
  35.682 +
  35.683 +	ld8 r18=[r17]				// read PTE again
  35.684 +	;;
  35.685 +	cmp.eq p6,p7=r18,r25			// is it same as the newly installed
  35.686 +	;;
  35.687 +(p7)	ptc.l r16,r24
  35.688 +	mov b0=r29				// restore b0
  35.689 +	mov ar.ccv=r28
  35.690 +#else /* !CONFIG_SMP */
  35.691 +	;;
  35.692 +1:	ld8 r18=[r17]
  35.693 +	;;
  35.694 +	or r18=_PAGE_A,r18			// set the accessed bit
  35.695 +	mov b0=r29				// restore b0
  35.696 +	;;
  35.697 +	st8 [r17]=r18				// store back updated PTE
  35.698 +	itc.i r18				// install updated PTE
  35.699 +#endif /* !CONFIG_SMP */
  35.700 +	mov pr=r31,-1
  35.701 +	rfi
  35.702 +END(iaccess_bit)
  35.703 +
  35.704 +	.org ia64_ivt+0x2800
  35.705 +/////////////////////////////////////////////////////////////////////////////////////////
  35.706 +// 0x2800 Entry 10 (size 64 bundles) Data Access-bit (15,55)
  35.707 +ENTRY(daccess_bit)
  35.708 +#ifdef XEN
  35.709 +	REFLECT(10)
  35.710 +#endif
  35.711 +	DBG_FAULT(10)
  35.712 +	// Like Entry 8, except for data access
  35.713 +	mov r16=cr.ifa				// get the address that caused the fault
  35.714 +	movl r30=1f				// load continuation point in case of nested fault
  35.715 +	;;
  35.716 +	thash r17=r16				// compute virtual address of L3 PTE
  35.717 +	mov r31=pr
  35.718 +	mov r29=b0				// save b0 in case of nested fault)
  35.719 +#ifdef CONFIG_SMP
  35.720 +	mov r28=ar.ccv				// save ar.ccv
  35.721 +	;;
  35.722 +1:	ld8 r18=[r17]
  35.723 +	;;					// avoid RAW on r18
  35.724 +	mov ar.ccv=r18				// set compare value for cmpxchg
  35.725 +	or r25=_PAGE_A,r18			// set the dirty bit
  35.726 +	;;
  35.727 +	cmpxchg8.acq r26=[r17],r25,ar.ccv
  35.728 +	mov r24=PAGE_SHIFT<<2
  35.729 +	;;
  35.730 +	cmp.eq p6,p7=r26,r18
  35.731 +	;;
  35.732 +(p6)	itc.d r25				// install updated PTE
  35.733 +	/*
  35.734 +	 * Tell the assemblers dependency-violation checker that the above "itc" instructions
  35.735 +	 * cannot possibly affect the following loads:
  35.736 +	 */
  35.737 +	dv_serialize_data
  35.738 +	;;
  35.739 +	ld8 r18=[r17]				// read PTE again
  35.740 +	;;
  35.741 +	cmp.eq p6,p7=r18,r25			// is it same as the newly installed
  35.742 +	;;
  35.743 +(p7)	ptc.l r16,r24
  35.744 +	mov ar.ccv=r28
  35.745 +#else
  35.746 +	;;
  35.747 +1:	ld8 r18=[r17]
  35.748 +	;;					// avoid RAW on r18
  35.749 +	or r18=_PAGE_A,r18			// set the accessed bit
  35.750 +	;;
  35.751 +	st8 [r17]=r18				// store back updated PTE
  35.752 +	itc.d r18				// install updated PTE
  35.753 +#endif
  35.754 +	mov b0=r29				// restore b0
  35.755 +	mov pr=r31,-1
  35.756 +	rfi
  35.757 +END(daccess_bit)
  35.758 +
  35.759 +	.org ia64_ivt+0x2c00
  35.760 +/////////////////////////////////////////////////////////////////////////////////////////
  35.761 +// 0x2c00 Entry 11 (size 64 bundles) Break instruction (33)
  35.762 +ENTRY(break_fault)
  35.763 +	/*
  35.764 +	 * The streamlined system call entry/exit paths only save/restore the initial part
  35.765 +	 * of pt_regs.  This implies that the callers of system-calls must adhere to the
  35.766 +	 * normal procedure calling conventions.
  35.767 +	 *
  35.768 +	 *   Registers to be saved & restored:
  35.769 +	 *	CR registers: cr.ipsr, cr.iip, cr.ifs
  35.770 +	 *	AR registers: ar.unat, ar.pfs, ar.rsc, ar.rnat, ar.bspstore, ar.fpsr
  35.771 +	 * 	others: pr, b0, b6, loadrs, r1, r11, r12, r13, r15
  35.772 +	 *   Registers to be restored only:
  35.773 +	 * 	r8-r11: output value from the system call.
  35.774 +	 *
  35.775 +	 * During system call exit, scratch registers (including r15) are modified/cleared
  35.776 +	 * to prevent leaking bits from kernel to user level.
  35.777 +	 */
  35.778 +	DBG_FAULT(11)
  35.779 +#ifdef XEN
  35.780 +	mov r16=cr.isr
  35.781 +	mov r17=cr.iim
  35.782 +	mov r31=pr
  35.783 +	;;
  35.784 +	cmp.eq p7,p0=r0,r17			// is this a psuedo-cover?
  35.785 +	// FIXME: may also need to check slot==2?
  35.786 +(p7)	br.sptk.many dispatch_privop_fault
  35.787 +	br.sptk.many dispatch_break_fault
  35.788 +#endif
  35.789 +	mov r16=IA64_KR(CURRENT)		// r16 = current task; 12 cycle read lat.
  35.790 +	mov r17=cr.iim
  35.791 +	mov r18=__IA64_BREAK_SYSCALL
  35.792 +	mov r21=ar.fpsr
  35.793 +	mov r29=cr.ipsr
  35.794 +	mov r19=b6
  35.795 +	mov r25=ar.unat
  35.796 +	mov r27=ar.rsc
  35.797 +	mov r26=ar.pfs
  35.798 +	mov r28=cr.iip
  35.799 +#ifndef XEN
  35.800 +	mov r31=pr				// prepare to save predicates
  35.801 +#endif
  35.802 +	mov r20=r1
  35.803 +	;;
  35.804 +	adds r16=IA64_TASK_THREAD_ON_USTACK_OFFSET,r16
  35.805 +	cmp.eq p0,p7=r18,r17			// is this a system call? (p7 <- false, if so)
  35.806 +(p7)	br.cond.spnt non_syscall
  35.807 +	;;
  35.808 +	ld1 r17=[r16]				// load current->thread.on_ustack flag
  35.809 +	st1 [r16]=r0				// clear current->thread.on_ustack flag
  35.810 +	add r1=-IA64_TASK_THREAD_ON_USTACK_OFFSET,r16	// set r1 for MINSTATE_START_SAVE_MIN_VIRT
  35.811 +	;;
  35.812 +	invala
  35.813 +
  35.814 +	/* adjust return address so we skip over the break instruction: */
  35.815 +
  35.816 +	extr.u r8=r29,41,2			// extract ei field from cr.ipsr
  35.817 +	;;
  35.818 +	cmp.eq p6,p7=2,r8			// isr.ei==2?
  35.819 +	mov r2=r1				// setup r2 for ia64_syscall_setup
  35.820 +	;;
  35.821 +(p6)	mov r8=0				// clear ei to 0
  35.822 +(p6)	adds r28=16,r28				// switch cr.iip to next bundle cr.ipsr.ei wrapped
  35.823 +(p7)	adds r8=1,r8				// increment ei to next slot
  35.824 +	;;
  35.825 +	cmp.eq pKStk,pUStk=r0,r17		// are we in kernel mode already?
  35.826 +	dep r29=r8,r29,41,2			// insert new ei into cr.ipsr
  35.827 +	;;
  35.828 +
  35.829 +	// switch from user to kernel RBS:
  35.830 +	MINSTATE_START_SAVE_MIN_VIRT
  35.831 +	br.call.sptk.many b7=ia64_syscall_setup
  35.832 +	;;
  35.833 +	MINSTATE_END_SAVE_MIN_VIRT		// switch to bank 1
  35.834 +	ssm psr.ic | PSR_DEFAULT_BITS
  35.835 +	;;
  35.836 +	srlz.i					// guarantee that interruption collection is on
  35.837 +	mov r3=NR_syscalls - 1
  35.838 +	;;
  35.839 +(p15)	ssm psr.i				// restore psr.i
  35.840 +	// p10==true means out registers are more than 8 or r15's Nat is true
  35.841 +(p10)	br.cond.spnt.many ia64_ret_from_syscall
  35.842 +	;;
  35.843 +	movl r16=sys_call_table
  35.844 +
  35.845 +	adds r15=-1024,r15			// r15 contains the syscall number---subtract 1024
  35.846 +	movl r2=ia64_ret_from_syscall
  35.847 +	;;
  35.848 +	shladd r20=r15,3,r16			// r20 = sys_call_table + 8*(syscall-1024)
  35.849 +	cmp.leu p6,p7=r15,r3			// (syscall > 0 && syscall < 1024 + NR_syscalls) ?
  35.850 +	mov rp=r2				// set the real return addr
  35.851 +	;;
  35.852 +(p6)	ld8 r20=[r20]				// load address of syscall entry point
  35.853 +(p7)	movl r20=sys_ni_syscall
  35.854 +
  35.855 +	add r2=TI_FLAGS+IA64_TASK_SIZE,r13
  35.856 +	;;
  35.857 +	ld4 r2=[r2]				// r2 = current_thread_info()->flags
  35.858 +	;;
  35.859 +	and r2=_TIF_SYSCALL_TRACEAUDIT,r2	// mask trace or audit
  35.860 +	;;
  35.861 +	cmp.eq p8,p0=r2,r0
  35.862 +	mov b6=r20
  35.863 +	;;
  35.864 +(p8)	br.call.sptk.many b6=b6			// ignore this return addr
  35.865 +	br.cond.sptk ia64_trace_syscall
  35.866 +	// NOT REACHED
  35.867 +END(break_fault)
  35.868 +
  35.869 +	.org ia64_ivt+0x3000
  35.870 +/////////////////////////////////////////////////////////////////////////////////////////
  35.871 +// 0x3000 Entry 12 (size 64 bundles) External Interrupt (4)
  35.872 +ENTRY(interrupt)
  35.873 +	DBG_FAULT(12)
  35.874 +	mov r31=pr		// prepare to save predicates
  35.875 +	;;
  35.876 +	SAVE_MIN_WITH_COVER	// uses r31; defines r2 and r3
  35.877 +	ssm psr.ic | PSR_DEFAULT_BITS
  35.878 +	;;
  35.879 +	adds r3=8,r2		// set up second base pointer for SAVE_REST
  35.880 +	srlz.i			// ensure everybody knows psr.ic is back on
  35.881 +	;;
  35.882 +	SAVE_REST
  35.883 +	;;
  35.884 +	alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group
  35.885 +	mov out0=cr.ivr		// pass cr.ivr as first arg
  35.886 +	add out1=16,sp		// pass pointer to pt_regs as second arg
  35.887 +	;;
  35.888 +	srlz.d			// make sure we see the effect of cr.ivr
  35.889 +	movl r14=ia64_leave_kernel
  35.890 +	;;
  35.891 +	mov rp=r14
  35.892 +	br.call.sptk.many b6=ia64_handle_irq
  35.893 +END(interrupt)
  35.894 +
  35.895 +	.org ia64_ivt+0x3400
  35.896 +/////////////////////////////////////////////////////////////////////////////////////////
  35.897 +// 0x3400 Entry 13 (size 64 bundles) Reserved
  35.898 +	DBG_FAULT(13)
  35.899 +	FAULT(13)
  35.900 +
  35.901 +#ifdef XEN
  35.902 +	// There is no particular reason for this code to be here, other than that
  35.903 +	// there happens to be space here that would go unused otherwise.  If this
  35.904 +	// fault ever gets "unreserved", simply moved the following code to a more
  35.905 +	// suitable spot...
  35.906 +
  35.907 +ENTRY(dispatch_break_fault)
  35.908 +	SAVE_MIN_WITH_COVER
  35.909 +	;;
  35.910 +	alloc r14=ar.pfs,0,0,4,0 // now it's safe (must be first in insn group!)
  35.911 +	mov out0=cr.ifa
  35.912 +	adds out1=16,sp
  35.913 +	mov out2=cr.isr		// FIXME: pity to make this slow access twice
  35.914 +	mov out3=cr.iim		// FIXME: pity to make this slow access twice
  35.915 +
  35.916 +	ssm psr.ic | PSR_DEFAULT_BITS
  35.917 +	;;
  35.918 +	srlz.i					// guarantee that interruption collection is on
  35.919 +	;;
  35.920 +(p15)	ssm psr.i				// restore psr.i
  35.921 +	adds r3=8,r2				// set up second base pointer
  35.922 +	;;
  35.923 +	SAVE_REST
  35.924 +	movl r14=ia64_leave_kernel
  35.925 +	;;
  35.926 +	mov rp=r14
  35.927 +	br.sptk.many ia64_prepare_handle_break
  35.928 +END(dispatch_break_fault)
  35.929 +#endif
  35.930 +
  35.931 +	.org ia64_ivt+0x3800
  35.932 +/////////////////////////////////////////////////////////////////////////////////////////
  35.933 +// 0x3800 Entry 14 (size 64 bundles) Reserved
  35.934 +	DBG_FAULT(14)
  35.935 +	FAULT(14)
  35.936 +
  35.937 +	/*
  35.938 +	 * There is no particular reason for this code to be here, other than that
  35.939 +	 * there happens to be space here that would go unused otherwise.  If this
  35.940 +	 * fault ever gets "unreserved", simply moved the following code to a more
  35.941 +	 * suitable spot...
  35.942 +	 *
  35.943 +	 * ia64_syscall_setup() is a separate subroutine so that it can
  35.944 +	 *	allocate stacked registers so it can safely demine any
  35.945 +	 *	potential NaT values from the input registers.
  35.946 +	 *
  35.947 +	 * On entry:
  35.948 +	 *	- executing on bank 0 or bank 1 register set (doesn't matter)
  35.949 +	 *	-  r1: stack pointer
  35.950 +	 *	-  r2: current task pointer
  35.951 +	 *	-  r3: preserved
  35.952 +	 *	- r11: original contents (saved ar.pfs to be saved)
  35.953 +	 *	- r12: original contents (sp to be saved)
  35.954 +	 *	- r13: original contents (tp to be saved)
  35.955 +	 *	- r15: original contents (syscall # to be saved)
  35.956 +	 *	- r18: saved bsp (after switching to kernel stack)
  35.957 +	 *	- r19: saved b6
  35.958 +	 *	- r20: saved r1 (gp)
  35.959 +	 *	- r21: saved ar.fpsr
  35.960 +	 *	- r22: kernel's register backing store base (krbs_base)
  35.961 +	 *	- r23: saved ar.bspstore
  35.962 +	 *	- r24: saved ar.rnat
  35.963 +	 *	- r25: saved ar.unat
  35.964 +	 *	- r26: saved ar.pfs
  35.965 +	 *	- r27: saved ar.rsc
  35.966 +	 *	- r28: saved cr.iip
  35.967 +	 *	- r29: saved cr.ipsr
  35.968 +	 *	- r31: saved pr
  35.969 +	 *	-  b0: original contents (to be saved)
  35.970 +	 * On exit:
  35.971 +	 *	- executing on bank 1 registers
  35.972 +	 *	- psr.ic enabled, interrupts restored
  35.973 +	 *	-  p10: TRUE if syscall is invoked with more than 8 out
  35.974 +	 *		registers or r15's Nat is true
  35.975 +	 *	-  r1: kernel's gp
  35.976 +	 *	-  r3: preserved (same as on entry)
  35.977 +	 *	-  r8: -EINVAL if p10 is true
  35.978 +	 *	- r12: points to kernel stack
  35.979 +	 *	- r13: points to current task
  35.980 +	 *	- p15: TRUE if interrupts need to be re-enabled
  35.981 +	 *	- ar.fpsr: set to kernel settings
  35.982 +	 */
  35.983 +GLOBAL_ENTRY(ia64_syscall_setup)
  35.984 +#ifndef XEN
  35.985 +#if PT(B6) != 0
  35.986 +# error This code assumes that b6 is the first field in pt_regs.
  35.987 +#endif
  35.988 +#endif
  35.989 +	st8 [r1]=r19				// save b6
  35.990 +	add r16=PT(CR_IPSR),r1			// initialize first base pointer
  35.991 +	add r17=PT(R11),r1			// initialize second base pointer
  35.992 +	;;
  35.993 +	alloc r19=ar.pfs,8,0,0,0		// ensure in0-in7 are writable
  35.994 +	st8 [r16]=r29,PT(AR_PFS)-PT(CR_IPSR)	// save cr.ipsr
  35.995 +	tnat.nz p8,p0=in0
  35.996 +
  35.997 +	st8.spill [r17]=r11,PT(CR_IIP)-PT(R11)	// save r11
  35.998 +	tnat.nz p9,p0=in1
  35.999 +(pKStk)	mov r18=r0				// make sure r18 isn't NaT
 35.1000 +	;;
 35.1001 +
 35.1002 +	st8 [r16]=r26,PT(CR_IFS)-PT(AR_PFS)	// save ar.pfs
 35.1003 +	st8 [r17]=r28,PT(AR_UNAT)-PT(CR_IIP)	// save cr.iip
 35.1004 +	mov r28=b0				// save b0 (2 cyc)
 35.1005 +	;;
 35.1006 +
 35.1007 +	st8 [r17]=r25,PT(AR_RSC)-PT(AR_UNAT)	// save ar.unat
 35.1008 +	dep r19=0,r19,38,26			// clear all bits but 0..37 [I0]
 35.1009 +(p8)	mov in0=-1
 35.1010 +	;;
 35.1011 +
 35.1012 +	st8 [r16]=r19,PT(AR_RNAT)-PT(CR_IFS)	// store ar.pfs.pfm in cr.ifs
 35.1013 +	extr.u r11=r19,7,7	// I0		// get sol of ar.pfs
 35.1014 +	and r8=0x7f,r19		// A		// get sof of ar.pfs
 35.1015 +
 35.1016 +	st8 [r17]=r27,PT(AR_BSPSTORE)-PT(AR_RSC)// save ar.rsc
 35.1017 +	tbit.nz p15,p0=r29,IA64_PSR_I_BIT // I0
 35.1018 +(p9)	mov in1=-1
 35.1019 +	;;
 35.1020 +
 35.1021 +(pUStk) sub r18=r18,r22				// r18=RSE.ndirty*8
 35.1022 +	tnat.nz p10,p0=in2
 35.1023 +	add r11=8,r11
 35.1024 +	;;
 35.1025 +(pKStk) adds r16=PT(PR)-PT(AR_RNAT),r16		// skip over ar_rnat field
 35.1026 +(pKStk) adds r17=PT(B0)-PT(AR_BSPSTORE),r17	// skip over ar_bspstore field
 35.1027 +	tnat.nz p11,p0=in3
 35.1028 +	;;
 35.1029 +(p10)	mov in2=-1
 35.1030 +	tnat.nz p12,p0=in4				// [I0]
 35.1031 +(p11)	mov in3=-1
 35.1032 +	;;
 35.1033 +(pUStk) st8 [r16]=r24,PT(PR)-PT(AR_RNAT)	// save ar.rnat
 35.1034 +(pUStk) st8 [r17]=r23,PT(B0)-PT(AR_BSPSTORE)	// save ar.bspstore
 35.1035 +	shl r18=r18,16				// compute ar.rsc to be used for "loadrs"
 35.1036 +	;;
 35.1037 +	st8 [r16]=r31,PT(LOADRS)-PT(PR)		// save predicates
 35.1038 +	st8 [r17]=r28,PT(R1)-PT(B0)		// save b0
 35.1039 +	tnat.nz p13,p0=in5				// [I0]
 35.1040 +	;;
 35.1041 +	st8 [r16]=r18,PT(R12)-PT(LOADRS)	// save ar.rsc value for "loadrs"
 35.1042 +	st8.spill [r17]=r20,PT(R13)-PT(R1)	// save original r1
 35.1043 +(p12)	mov in4=-1
 35.1044 +	;;
 35.1045 +
 35.1046 +.mem.offset 0,0; st8.spill [r16]=r12,PT(AR_FPSR)-PT(R12)	// save r12
 35.1047 +.mem.offset 8,0; st8.spill [r17]=r13,PT(R15)-PT(R13)		// save r13
 35.1048 +(p13)	mov in5=-1
 35.1049 +	;;
 35.1050 +	st8 [r16]=r21,PT(R8)-PT(AR_FPSR)	// save ar.fpsr
 35.1051 +	tnat.nz p14,p0=in6
 35.1052 +	cmp.lt p10,p9=r11,r8	// frame size can't be more than local+8
 35.1053 +	;;
 35.1054 +	stf8 [r16]=f1		// ensure pt_regs.r8 != 0 (see handle_syscall_error)
 35.1055 +(p9)	tnat.nz p10,p0=r15
 35.1056 +	adds r12=-16,r1		// switch to kernel memory stack (with 16 bytes of scratch)
 35.1057 +
 35.1058 +	st8.spill [r17]=r15			// save r15
 35.1059 +	tnat.nz p8,p0=in7
 35.1060 +	nop.i 0
 35.1061 +
 35.1062 +	mov r13=r2				// establish `current'
 35.1063 +	movl r1=__gp				// establish kernel global pointer
 35.1064 +	;;
 35.1065 +(p14)	mov in6=-1
 35.1066 +(p8)	mov in7=-1
 35.1067 +	nop.i 0
 35.1068 +
 35.1069 +	cmp.eq pSys,pNonSys=r0,r0		// set pSys=1, pNonSys=0
 35.1070 +	movl r17=FPSR_DEFAULT
 35.1071 +	;;
 35.1072 +	mov.m ar.fpsr=r17			// set ar.fpsr to kernel default value
 35.1073 +(p10)	mov r8=-EINVAL
 35.1074 +	br.ret.sptk.many b7
 35.1075 +END(ia64_syscall_setup)
 35.1076 +
 35.1077 +	.org ia64_ivt+0x3c00
 35.1078 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1079 +// 0x3c00 Entry 15 (size 64 bundles) Reserved
 35.1080 +	DBG_FAULT(15)
 35.1081 +	FAULT(15)
 35.1082 +
 35.1083 +	/*
 35.1084 +	 * Squatting in this space ...
 35.1085 +	 *
 35.1086 +	 * This special case dispatcher for illegal operation faults allows preserved
 35.1087 +	 * registers to be modified through a callback function (asm only) that is handed
 35.1088 +	 * back from the fault handler in r8. Up to three arguments can be passed to the
 35.1089 +	 * callback function by returning an aggregate with the callback as its first
 35.1090 +	 * element, followed by the arguments.
 35.1091 +	 */
 35.1092 +ENTRY(dispatch_illegal_op_fault)
 35.1093 +	SAVE_MIN_WITH_COVER
 35.1094 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1095 +	;;
 35.1096 +	srlz.i		// guarantee that interruption collection is on
 35.1097 +	;;
 35.1098 +(p15)	ssm psr.i	// restore psr.i
 35.1099 +	adds r3=8,r2	// set up second base pointer for SAVE_REST
 35.1100 +	;;
 35.1101 +	alloc r14=ar.pfs,0,0,1,0	// must be first in insn group
 35.1102 +	mov out0=ar.ec
 35.1103 +	;;
 35.1104 +	SAVE_REST
 35.1105 +	;;
 35.1106 +	br.call.sptk.many rp=ia64_illegal_op_fault
 35.1107 +.ret0:	;;
 35.1108 +	alloc r14=ar.pfs,0,0,3,0	// must be first in insn group
 35.1109 +	mov out0=r9
 35.1110 +	mov out1=r10
 35.1111 +	mov out2=r11
 35.1112 +	movl r15=ia64_leave_kernel
 35.1113 +	;;
 35.1114 +	mov rp=r15
 35.1115 +	mov b6=r8
 35.1116 +	;;
 35.1117 +	cmp.ne p6,p0=0,r8
 35.1118 +(p6)	br.call.dpnt.many b6=b6		// call returns to ia64_leave_kernel
 35.1119 +	br.sptk.many ia64_leave_kernel
 35.1120 +END(dispatch_illegal_op_fault)
 35.1121 +
 35.1122 +	.org ia64_ivt+0x4000
 35.1123 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1124 +// 0x4000 Entry 16 (size 64 bundles) Reserved
 35.1125 +	DBG_FAULT(16)
 35.1126 +	FAULT(16)
 35.1127 +
 35.1128 +#ifdef XEN
 35.1129 +	// There is no particular reason for this code to be here, other than that
 35.1130 +	// there happens to be space here that would go unused otherwise.  If this
 35.1131 +	// fault ever gets "unreserved", simply moved the following code to a more
 35.1132 +	// suitable spot...
 35.1133 +
 35.1134 +ENTRY(dispatch_privop_fault)
 35.1135 +	SAVE_MIN_WITH_COVER
 35.1136 +	;;
 35.1137 +	alloc r14=ar.pfs,0,0,4,0		// now it's safe (must be first in insn group!)
 35.1138 +	mov out0=cr.ifa
 35.1139 +	adds out1=16,sp
 35.1140 +	mov out2=cr.isr		// FIXME: pity to make this slow access twice
 35.1141 +	mov out3=cr.itir
 35.1142 +
 35.1143 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1144 +	;;
 35.1145 +	srlz.i					// guarantee that interruption collection is on
 35.1146 +	;;
 35.1147 +(p15)	ssm psr.i				// restore psr.i
 35.1148 +	adds r3=8,r2				// set up second base pointer
 35.1149 +	;;
 35.1150 +	SAVE_REST
 35.1151 +	movl r14=ia64_leave_kernel
 35.1152 +	;;
 35.1153 +	mov rp=r14
 35.1154 +	br.sptk.many ia64_prepare_handle_privop
 35.1155 +END(dispatch_privop_fault)
 35.1156 +#endif
 35.1157 +
 35.1158 +
 35.1159 +	.org ia64_ivt+0x4400
 35.1160 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1161 +// 0x4400 Entry 17 (size 64 bundles) Reserved
 35.1162 +	DBG_FAULT(17)
 35.1163 +	FAULT(17)
 35.1164 +
 35.1165 +ENTRY(non_syscall)
 35.1166 +	SAVE_MIN_WITH_COVER
 35.1167 +
 35.1168 +	// There is no particular reason for this code to be here, other than that
 35.1169 +	// there happens to be space here that would go unused otherwise.  If this
 35.1170 +	// fault ever gets "unreserved", simply moved the following code to a more
 35.1171 +	// suitable spot...
 35.1172 +
 35.1173 +	alloc r14=ar.pfs,0,0,2,0
 35.1174 +	mov out0=cr.iim
 35.1175 +	add out1=16,sp
 35.1176 +	adds r3=8,r2			// set up second base pointer for SAVE_REST
 35.1177 +
 35.1178 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1179 +	;;
 35.1180 +	srlz.i				// guarantee that interruption collection is on
 35.1181 +	;;
 35.1182 +(p15)	ssm psr.i			// restore psr.i
 35.1183 +	movl r15=ia64_leave_kernel
 35.1184 +	;;
 35.1185 +	SAVE_REST
 35.1186 +	mov rp=r15
 35.1187 +	;;
 35.1188 +	br.call.sptk.many b6=ia64_bad_break	// avoid WAW on CFM and ignore return addr
 35.1189 +END(non_syscall)
 35.1190 +
 35.1191 +	.org ia64_ivt+0x4800
 35.1192 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1193 +// 0x4800 Entry 18 (size 64 bundles) Reserved
 35.1194 +	DBG_FAULT(18)
 35.1195 +	FAULT(18)
 35.1196 +
 35.1197 +	/*
 35.1198 +	 * There is no particular reason for this code to be here, other than that
 35.1199 +	 * there happens to be space here that would go unused otherwise.  If this
 35.1200 +	 * fault ever gets "unreserved", simply moved the following code to a more
 35.1201 +	 * suitable spot...
 35.1202 +	 */
 35.1203 +
 35.1204 +ENTRY(dispatch_unaligned_handler)
 35.1205 +	SAVE_MIN_WITH_COVER
 35.1206 +	;;
 35.1207 +	alloc r14=ar.pfs,0,0,2,0		// now it's safe (must be first in insn group!)
 35.1208 +	mov out0=cr.ifa
 35.1209 +	adds out1=16,sp
 35.1210 +
 35.1211 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1212 +	;;
 35.1213 +	srlz.i					// guarantee that interruption collection is on
 35.1214 +	;;
 35.1215 +(p15)	ssm psr.i				// restore psr.i
 35.1216 +	adds r3=8,r2				// set up second base pointer
 35.1217 +	;;
 35.1218 +	SAVE_REST
 35.1219 +	movl r14=ia64_leave_kernel
 35.1220 +	;;
 35.1221 +	mov rp=r14
 35.1222 +	br.sptk.many ia64_prepare_handle_unaligned
 35.1223 +END(dispatch_unaligned_handler)
 35.1224 +
 35.1225 +	.org ia64_ivt+0x4c00
 35.1226 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1227 +// 0x4c00 Entry 19 (size 64 bundles) Reserved
 35.1228 +	DBG_FAULT(19)
 35.1229 +	FAULT(19)
 35.1230 +
 35.1231 +	/*
 35.1232 +	 * There is no particular reason for this code to be here, other than that
 35.1233 +	 * there happens to be space here that would go unused otherwise.  If this
 35.1234 +	 * fault ever gets "unreserved", simply moved the following code to a more
 35.1235 +	 * suitable spot...
 35.1236 +	 */
 35.1237 +
 35.1238 +ENTRY(dispatch_to_fault_handler)
 35.1239 +	/*
 35.1240 +	 * Input:
 35.1241 +	 *	psr.ic:	off
 35.1242 +	 *	r19:	fault vector number (e.g., 24 for General Exception)
 35.1243 +	 *	r31:	contains saved predicates (pr)
 35.1244 +	 */
 35.1245 +	SAVE_MIN_WITH_COVER_R19
 35.1246 +	alloc r14=ar.pfs,0,0,5,0
 35.1247 +	mov out0=r15
 35.1248 +	mov out1=cr.isr
 35.1249 +	mov out2=cr.ifa
 35.1250 +	mov out3=cr.iim
 35.1251 +	mov out4=cr.itir
 35.1252 +	;;
 35.1253 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1254 +	;;
 35.1255 +	srlz.i					// guarantee that interruption collection is on
 35.1256 +	;;
 35.1257 +(p15)	ssm psr.i				// restore psr.i
 35.1258 +	adds r3=8,r2				// set up second base pointer for SAVE_REST
 35.1259 +	;;
 35.1260 +	SAVE_REST
 35.1261 +	movl r14=ia64_leave_kernel
 35.1262 +	;;
 35.1263 +	mov rp=r14
 35.1264 +	br.call.sptk.many b6=ia64_fault
 35.1265 +END(dispatch_to_fault_handler)
 35.1266 +
 35.1267 +//
 35.1268 +// --- End of long entries, Beginning of short entries
 35.1269 +//
 35.1270 +
 35.1271 +	.org ia64_ivt+0x5000
 35.1272 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1273 +// 0x5000 Entry 20 (size 16 bundles) Page Not Present (10,22,49)
 35.1274 +ENTRY(page_not_present)
 35.1275 +#ifdef XEN
 35.1276 +	REFLECT(20)
 35.1277 +#endif
 35.1278 +	DBG_FAULT(20)
 35.1279 +	mov r16=cr.ifa
 35.1280 +	rsm psr.dt
 35.1281 +	/*
 35.1282 +	 * The Linux page fault handler doesn't expect non-present pages to be in
 35.1283 +	 * the TLB.  Flush the existing entry now, so we meet that expectation.
 35.1284 +	 */
 35.1285 +	mov r17=PAGE_SHIFT<<2
 35.1286 +	;;
 35.1287 +	ptc.l r16,r17
 35.1288 +	;;
 35.1289 +	mov r31=pr
 35.1290 +	srlz.d
 35.1291 +	br.sptk.many page_fault
 35.1292 +END(page_not_present)
 35.1293 +
 35.1294 +	.org ia64_ivt+0x5100
 35.1295 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1296 +// 0x5100 Entry 21 (size 16 bundles) Key Permission (13,25,52)
 35.1297 +ENTRY(key_permission)
 35.1298 +#ifdef XEN
 35.1299 +	REFLECT(21)
 35.1300 +#endif
 35.1301 +	DBG_FAULT(21)
 35.1302 +	mov r16=cr.ifa
 35.1303 +	rsm psr.dt
 35.1304 +	mov r31=pr
 35.1305 +	;;
 35.1306 +	srlz.d
 35.1307 +	br.sptk.many page_fault
 35.1308 +END(key_permission)
 35.1309 +
 35.1310 +	.org ia64_ivt+0x5200
 35.1311 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1312 +// 0x5200 Entry 22 (size 16 bundles) Instruction Access Rights (26)
 35.1313 +ENTRY(iaccess_rights)
 35.1314 +#ifdef XEN
 35.1315 +	REFLECT(22)
 35.1316 +#endif
 35.1317 +	DBG_FAULT(22)
 35.1318 +	mov r16=cr.ifa
 35.1319 +	rsm psr.dt
 35.1320 +	mov r31=pr
 35.1321 +	;;
 35.1322 +	srlz.d
 35.1323 +	br.sptk.many page_fault
 35.1324 +END(iaccess_rights)
 35.1325 +
 35.1326 +	.org ia64_ivt+0x5300
 35.1327 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1328 +// 0x5300 Entry 23 (size 16 bundles) Data Access Rights (14,53)
 35.1329 +ENTRY(daccess_rights)
 35.1330 +#ifdef XEN
 35.1331 +	REFLECT(23)
 35.1332 +#endif
 35.1333 +	DBG_FAULT(23)
 35.1334 +	mov r16=cr.ifa
 35.1335 +	rsm psr.dt
 35.1336 +	mov r31=pr
 35.1337 +	;;
 35.1338 +	srlz.d
 35.1339 +	br.sptk.many page_fault
 35.1340 +END(daccess_rights)
 35.1341 +
 35.1342 +	.org ia64_ivt+0x5400
 35.1343 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1344 +// 0x5400 Entry 24 (size 16 bundles) General Exception (5,32,34,36,38,39)
 35.1345 +ENTRY(general_exception)
 35.1346 +	DBG_FAULT(24)
 35.1347 +	mov r16=cr.isr
 35.1348 +	mov r31=pr
 35.1349 +	;;
 35.1350 +#ifdef XEN
 35.1351 +	cmp4.ge p6,p0=0x20,r16
 35.1352 +(p6)	br.sptk.many dispatch_privop_fault
 35.1353 +#else
 35.1354 +	cmp4.eq p6,p0=0,r16
 35.1355 +(p6)	br.sptk.many dispatch_illegal_op_fault
 35.1356 +#endif
 35.1357 +	;;
 35.1358 +	mov r19=24		// fault number
 35.1359 +	br.sptk.many dispatch_to_fault_handler
 35.1360 +END(general_exception)
 35.1361 +
 35.1362 +	.org ia64_ivt+0x5500
 35.1363 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1364 +// 0x5500 Entry 25 (size 16 bundles) Disabled FP-Register (35)
 35.1365 +ENTRY(disabled_fp_reg)
 35.1366 +#ifdef XEN
 35.1367 +	REFLECT(25)
 35.1368 +#endif
 35.1369 +	DBG_FAULT(25)
 35.1370 +	rsm psr.dfh		// ensure we can access fph
 35.1371 +	;;
 35.1372 +	srlz.d
 35.1373 +	mov r31=pr
 35.1374 +	mov r19=25
 35.1375 +	br.sptk.many dispatch_to_fault_handler
 35.1376 +END(disabled_fp_reg)
 35.1377 +
 35.1378 +	.org ia64_ivt+0x5600
 35.1379 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1380 +// 0x5600 Entry 26 (size 16 bundles) Nat Consumption (11,23,37,50)
 35.1381 +ENTRY(nat_consumption)
 35.1382 +#ifdef XEN
 35.1383 +	REFLECT(26)
 35.1384 +#endif
 35.1385 +	DBG_FAULT(26)
 35.1386 +	FAULT(26)
 35.1387 +END(nat_consumption)
 35.1388 +
 35.1389 +	.org ia64_ivt+0x5700
 35.1390 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1391 +// 0x5700 Entry 27 (size 16 bundles) Speculation (40)
 35.1392 +ENTRY(speculation_vector)
 35.1393 +#ifdef XEN
 35.1394 +	// this probably need not reflect...
 35.1395 +	REFLECT(27)
 35.1396 +#endif
 35.1397 +	DBG_FAULT(27)
 35.1398 +	/*
 35.1399 +	 * A [f]chk.[as] instruction needs to take the branch to the recovery code but
 35.1400 +	 * this part of the architecture is not implemented in hardware on some CPUs, such
 35.1401 +	 * as Itanium.  Thus, in general we need to emulate the behavior.  IIM contains
 35.1402 +	 * the relative target (not yet sign extended).  So after sign extending it we
 35.1403 +	 * simply add it to IIP.  We also need to reset the EI field of the IPSR to zero,
 35.1404 +	 * i.e., the slot to restart into.
 35.1405 +	 *
 35.1406 +	 * cr.imm contains zero_ext(imm21)
 35.1407 +	 */
 35.1408 +	mov r18=cr.iim
 35.1409 +	;;
 35.1410 +	mov r17=cr.iip
 35.1411 +	shl r18=r18,43			// put sign bit in position (43=64-21)
 35.1412 +	;;
 35.1413 +
 35.1414 +	mov r16=cr.ipsr
 35.1415 +	shr r18=r18,39			// sign extend (39=43-4)
 35.1416 +	;;
 35.1417 +
 35.1418 +	add r17=r17,r18			// now add the offset
 35.1419 +	;;
 35.1420 +	mov cr.iip=r17
 35.1421 +	dep r16=0,r16,41,2		// clear EI
 35.1422 +	;;
 35.1423 +
 35.1424 +	mov cr.ipsr=r16
 35.1425 +	;;
 35.1426 +
 35.1427 +	rfi				// and go back
 35.1428 +END(speculation_vector)
 35.1429 +
 35.1430 +	.org ia64_ivt+0x5800
 35.1431 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1432 +// 0x5800 Entry 28 (size 16 bundles) Reserved
 35.1433 +	DBG_FAULT(28)
 35.1434 +	FAULT(28)
 35.1435 +
 35.1436 +	.org ia64_ivt+0x5900
 35.1437 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1438 +// 0x5900 Entry 29 (size 16 bundles) Debug (16,28,56)
 35.1439 +ENTRY(debug_vector)
 35.1440 +#ifdef XEN
 35.1441 +	REFLECT(29)
 35.1442 +#endif
 35.1443 +	DBG_FAULT(29)
 35.1444 +	FAULT(29)
 35.1445 +END(debug_vector)
 35.1446 +
 35.1447 +	.org ia64_ivt+0x5a00
 35.1448 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1449 +// 0x5a00 Entry 30 (size 16 bundles) Unaligned Reference (57)
 35.1450 +ENTRY(unaligned_access)
 35.1451 +#ifdef XEN
 35.1452 +	REFLECT(30)
 35.1453 +#endif
 35.1454 +	DBG_FAULT(30)
 35.1455 +	mov r16=cr.ipsr
 35.1456 +	mov r31=pr		// prepare to save predicates
 35.1457 +	;;
 35.1458 +	br.sptk.many dispatch_unaligned_handler
 35.1459 +END(unaligned_access)
 35.1460 +
 35.1461 +	.org ia64_ivt+0x5b00
 35.1462 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1463 +// 0x5b00 Entry 31 (size 16 bundles) Unsupported Data Reference (57)
 35.1464 +ENTRY(unsupported_data_reference)
 35.1465 +#ifdef XEN
 35.1466 +	REFLECT(31)
 35.1467 +#endif
 35.1468 +	DBG_FAULT(31)
 35.1469 +	FAULT(31)
 35.1470 +END(unsupported_data_reference)
 35.1471 +
 35.1472 +	.org ia64_ivt+0x5c00
 35.1473 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1474 +// 0x5c00 Entry 32 (size 16 bundles) Floating-Point Fault (64)
 35.1475 +ENTRY(floating_point_fault)
 35.1476 +#ifdef XEN
 35.1477 +	REFLECT(32)
 35.1478 +#endif
 35.1479 +	DBG_FAULT(32)
 35.1480 +	FAULT(32)
 35.1481 +END(floating_point_fault)
 35.1482 +
 35.1483 +	.org ia64_ivt+0x5d00
 35.1484 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1485 +// 0x5d00 Entry 33 (size 16 bundles) Floating Point Trap (66)
 35.1486 +ENTRY(floating_point_trap)
 35.1487 +#ifdef XEN
 35.1488 +	REFLECT(33)
 35.1489 +#endif
 35.1490 +	DBG_FAULT(33)
 35.1491 +	FAULT(33)
 35.1492 +END(floating_point_trap)
 35.1493 +
 35.1494 +	.org ia64_ivt+0x5e00
 35.1495 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1496 +// 0x5e00 Entry 34 (size 16 bundles) Lower Privilege Transfer Trap (66)
 35.1497 +ENTRY(lower_privilege_trap)
 35.1498 +#ifdef XEN
 35.1499 +	REFLECT(34)
 35.1500 +#endif
 35.1501 +	DBG_FAULT(34)
 35.1502 +	FAULT(34)
 35.1503 +END(lower_privilege_trap)
 35.1504 +
 35.1505 +	.org ia64_ivt+0x5f00
 35.1506 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1507 +// 0x5f00 Entry 35 (size 16 bundles) Taken Branch Trap (68)
 35.1508 +ENTRY(taken_branch_trap)
 35.1509 +#ifdef XEN
 35.1510 +	REFLECT(35)
 35.1511 +#endif
 35.1512 +	DBG_FAULT(35)
 35.1513 +	FAULT(35)
 35.1514 +END(taken_branch_trap)
 35.1515 +
 35.1516 +	.org ia64_ivt+0x6000
 35.1517 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1518 +// 0x6000 Entry 36 (size 16 bundles) Single Step Trap (69)
 35.1519 +ENTRY(single_step_trap)
 35.1520 +#ifdef XEN
 35.1521 +	REFLECT(36)
 35.1522 +#endif
 35.1523 +	DBG_FAULT(36)
 35.1524 +	FAULT(36)
 35.1525 +END(single_step_trap)
 35.1526 +
 35.1527 +	.org ia64_ivt+0x6100
 35.1528 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1529 +// 0x6100 Entry 37 (size 16 bundles) Reserved
 35.1530 +	DBG_FAULT(37)
 35.1531 +	FAULT(37)
 35.1532 +
 35.1533 +	.org ia64_ivt+0x6200
 35.1534 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1535 +// 0x6200 Entry 38 (size 16 bundles) Reserved
 35.1536 +	DBG_FAULT(38)
 35.1537 +	FAULT(38)
 35.1538 +
 35.1539 +	.org ia64_ivt+0x6300
 35.1540 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1541 +// 0x6300 Entry 39 (size 16 bundles) Reserved
 35.1542 +	DBG_FAULT(39)
 35.1543 +	FAULT(39)
 35.1544 +
 35.1545 +	.org ia64_ivt+0x6400
 35.1546 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1547 +// 0x6400 Entry 40 (size 16 bundles) Reserved
 35.1548 +	DBG_FAULT(40)
 35.1549 +	FAULT(40)
 35.1550 +
 35.1551 +	.org ia64_ivt+0x6500
 35.1552 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1553 +// 0x6500 Entry 41 (size 16 bundles) Reserved
 35.1554 +	DBG_FAULT(41)
 35.1555 +	FAULT(41)
 35.1556 +
 35.1557 +	.org ia64_ivt+0x6600
 35.1558 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1559 +// 0x6600 Entry 42 (size 16 bundles) Reserved
 35.1560 +	DBG_FAULT(42)
 35.1561 +	FAULT(42)
 35.1562 +
 35.1563 +	.org ia64_ivt+0x6700
 35.1564 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1565 +// 0x6700 Entry 43 (size 16 bundles) Reserved
 35.1566 +	DBG_FAULT(43)
 35.1567 +	FAULT(43)
 35.1568 +
 35.1569 +	.org ia64_ivt+0x6800
 35.1570 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1571 +// 0x6800 Entry 44 (size 16 bundles) Reserved
 35.1572 +	DBG_FAULT(44)
 35.1573 +	FAULT(44)
 35.1574 +
 35.1575 +	.org ia64_ivt+0x6900
 35.1576 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1577 +// 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)
 35.1578 +ENTRY(ia32_exception)
 35.1579 +#ifdef XEN
 35.1580 +	REFLECT(45)
 35.1581 +#endif
 35.1582 +	DBG_FAULT(45)
 35.1583 +	FAULT(45)
 35.1584 +END(ia32_exception)
 35.1585 +
 35.1586 +	.org ia64_ivt+0x6a00
 35.1587 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1588 +// 0x6a00 Entry 46 (size 16 bundles) IA-32 Intercept  (30,31,59,70,71)
 35.1589 +ENTRY(ia32_intercept)
 35.1590 +#ifdef XEN
 35.1591 +	REFLECT(46)
 35.1592 +#endif
 35.1593 +	DBG_FAULT(46)
 35.1594 +#ifdef	CONFIG_IA32_SUPPORT
 35.1595 +	mov r31=pr
 35.1596 +	mov r16=cr.isr
 35.1597 +	;;
 35.1598 +	extr.u r17=r16,16,8	// get ISR.code
 35.1599 +	mov r18=ar.eflag
 35.1600 +	mov r19=cr.iim		// old eflag value
 35.1601 +	;;
 35.1602 +	cmp.ne p6,p0=2,r17
 35.1603 +(p6)	br.cond.spnt 1f		// not a system flag fault
 35.1604 +	xor r16=r18,r19
 35.1605 +	;;
 35.1606 +	extr.u r17=r16,18,1	// get the eflags.ac bit
 35.1607 +	;;
 35.1608 +	cmp.eq p6,p0=0,r17
 35.1609 +(p6)	br.cond.spnt 1f		// eflags.ac bit didn't change
 35.1610 +	;;
 35.1611 +	mov pr=r31,-1		// restore predicate registers
 35.1612 +	rfi
 35.1613 +
 35.1614 +1:
 35.1615 +#endif	// CONFIG_IA32_SUPPORT
 35.1616 +	FAULT(46)
 35.1617 +END(ia32_intercept)
 35.1618 +
 35.1619 +	.org ia64_ivt+0x6b00
 35.1620 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1621 +// 0x6b00 Entry 47 (size 16 bundles) IA-32 Interrupt  (74)
 35.1622 +ENTRY(ia32_interrupt)
 35.1623 +#ifdef XEN
 35.1624 +	REFLECT(47)
 35.1625 +#endif
 35.1626 +	DBG_FAULT(47)
 35.1627 +#ifdef CONFIG_IA32_SUPPORT
 35.1628 +	mov r31=pr
 35.1629 +	br.sptk.many dispatch_to_ia32_handler
 35.1630 +#else
 35.1631 +	FAULT(47)
 35.1632 +#endif
 35.1633 +END(ia32_interrupt)
 35.1634 +
 35.1635 +	.org ia64_ivt+0x6c00
 35.1636 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1637 +// 0x6c00 Entry 48 (size 16 bundles) Reserved
 35.1638 +	DBG_FAULT(48)
 35.1639 +	FAULT(48)
 35.1640 +
 35.1641 +	.org ia64_ivt+0x6d00
 35.1642 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1643 +// 0x6d00 Entry 49 (size 16 bundles) Reserved
 35.1644 +	DBG_FAULT(49)
 35.1645 +	FAULT(49)
 35.1646 +
 35.1647 +	.org ia64_ivt+0x6e00
 35.1648 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1649 +// 0x6e00 Entry 50 (size 16 bundles) Reserved
 35.1650 +	DBG_FAULT(50)
 35.1651 +	FAULT(50)
 35.1652 +
 35.1653 +	.org ia64_ivt+0x6f00
 35.1654 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1655 +// 0x6f00 Entry 51 (size 16 bundles) Reserved
 35.1656 +	DBG_FAULT(51)
 35.1657 +	FAULT(51)
 35.1658 +
 35.1659 +	.org ia64_ivt+0x7000
 35.1660 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1661 +// 0x7000 Entry 52 (size 16 bundles) Reserved
 35.1662 +	DBG_FAULT(52)
 35.1663 +	FAULT(52)
 35.1664 +
 35.1665 +	.org ia64_ivt+0x7100
 35.1666 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1667 +// 0x7100 Entry 53 (size 16 bundles) Reserved
 35.1668 +	DBG_FAULT(53)
 35.1669 +	FAULT(53)
 35.1670 +
 35.1671 +	.org ia64_ivt+0x7200
 35.1672 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1673 +// 0x7200 Entry 54 (size 16 bundles) Reserved
 35.1674 +	DBG_FAULT(54)
 35.1675 +	FAULT(54)
 35.1676 +
 35.1677 +	.org ia64_ivt+0x7300
 35.1678 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1679 +// 0x7300 Entry 55 (size 16 bundles) Reserved
 35.1680 +	DBG_FAULT(55)
 35.1681 +	FAULT(55)
 35.1682 +
 35.1683 +	.org ia64_ivt+0x7400
 35.1684 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1685 +// 0x7400 Entry 56 (size 16 bundles) Reserved
 35.1686 +	DBG_FAULT(56)
 35.1687 +	FAULT(56)
 35.1688 +
 35.1689 +	.org ia64_ivt+0x7500
 35.1690 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1691 +// 0x7500 Entry 57 (size 16 bundles) Reserved
 35.1692 +	DBG_FAULT(57)
 35.1693 +	FAULT(57)
 35.1694 +
 35.1695 +	.org ia64_ivt+0x7600
 35.1696 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1697 +// 0x7600 Entry 58 (size 16 bundles) Reserved
 35.1698 +	DBG_FAULT(58)
 35.1699 +	FAULT(58)
 35.1700 +
 35.1701 +	.org ia64_ivt+0x7700
 35.1702 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1703 +// 0x7700 Entry 59 (size 16 bundles) Reserved
 35.1704 +	DBG_FAULT(59)
 35.1705 +	FAULT(59)
 35.1706 +
 35.1707 +	.org ia64_ivt+0x7800
 35.1708 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1709 +// 0x7800 Entry 60 (size 16 bundles) Reserved
 35.1710 +	DBG_FAULT(60)
 35.1711 +	FAULT(60)
 35.1712 +
 35.1713 +	.org ia64_ivt+0x7900
 35.1714 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1715 +// 0x7900 Entry 61 (size 16 bundles) Reserved
 35.1716 +	DBG_FAULT(61)
 35.1717 +	FAULT(61)
 35.1718 +
 35.1719 +	.org ia64_ivt+0x7a00
 35.1720 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1721 +// 0x7a00 Entry 62 (size 16 bundles) Reserved
 35.1722 +	DBG_FAULT(62)
 35.1723 +	FAULT(62)
 35.1724 +
 35.1725 +	.org ia64_ivt+0x7b00
 35.1726 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1727 +// 0x7b00 Entry 63 (size 16 bundles) Reserved
 35.1728 +	DBG_FAULT(63)
 35.1729 +	FAULT(63)
 35.1730 +
 35.1731 +	.org ia64_ivt+0x7c00
 35.1732 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1733 +// 0x7c00 Entry 64 (size 16 bundles) Reserved
 35.1734 +	DBG_FAULT(64)
 35.1735 +	FAULT(64)
 35.1736 +
 35.1737 +	.org ia64_ivt+0x7d00
 35.1738 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1739 +// 0x7d00 Entry 65 (size 16 bundles) Reserved
 35.1740 +	DBG_FAULT(65)
 35.1741 +	FAULT(65)
 35.1742 +
 35.1743 +	.org ia64_ivt+0x7e00
 35.1744 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1745 +// 0x7e00 Entry 66 (size 16 bundles) Reserved
 35.1746 +	DBG_FAULT(66)
 35.1747 +	FAULT(66)
 35.1748 +
 35.1749 +	.org ia64_ivt+0x7f00
 35.1750 +/////////////////////////////////////////////////////////////////////////////////////////
 35.1751 +// 0x7f00 Entry 67 (size 16 bundles) Reserved
 35.1752 +	DBG_FAULT(67)
 35.1753 +	FAULT(67)
 35.1754 +
 35.1755 +#ifdef XEN
 35.1756 +	.org ia64_ivt+0x8000
 35.1757 +ENTRY(dispatch_reflection)
 35.1758 +	/*
 35.1759 +	 * Input:
 35.1760 +	 *	psr.ic:	off
 35.1761 +	 *	r19:	intr type (offset into ivt, see ia64_int.h)
 35.1762 +	 *	r31:	contains saved predicates (pr)
 35.1763 +	 */
 35.1764 +	SAVE_MIN_WITH_COVER_R19
 35.1765 +	alloc r14=ar.pfs,0,0,5,0
 35.1766 +	mov out4=r15
 35.1767 +	mov out0=cr.ifa
 35.1768 +	adds out1=16,sp
 35.1769 +	mov out2=cr.isr
 35.1770 +	mov out3=cr.iim
 35.1771 +//	mov out3=cr.itir
 35.1772 +
 35.1773 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1774 +	;;
 35.1775 +	srlz.i					// guarantee that interruption collection is on
 35.1776 +	;;
 35.1777 +(p15)	ssm psr.i				// restore psr.i
 35.1778 +	adds r3=8,r2				// set up second base pointer
 35.1779 +	;;
 35.1780 +	SAVE_REST
 35.1781 +	movl r14=ia64_leave_kernel
 35.1782 +	;;
 35.1783 +	mov rp=r14
 35.1784 +	br.sptk.many ia64_prepare_handle_reflection
 35.1785 +END(dispatch_reflection)
 35.1786 +#endif
 35.1787 +
 35.1788 +#ifdef CONFIG_IA32_SUPPORT
 35.1789 +
 35.1790 +	/*
 35.1791 +	 * There is no particular reason for this code to be here, other than that
 35.1792 +	 * there happens to be space here that would go unused otherwise.  If this
 35.1793 +	 * fault ever gets "unreserved", simply moved the following code to a more
 35.1794 +	 * suitable spot...
 35.1795 +	 */
 35.1796 +
 35.1797 +	// IA32 interrupt entry point
 35.1798 +
 35.1799 +ENTRY(dispatch_to_ia32_handler)
 35.1800 +	SAVE_MIN
 35.1801 +	;;
 35.1802 +	mov r14=cr.isr
 35.1803 +	ssm psr.ic | PSR_DEFAULT_BITS
 35.1804 +	;;
 35.1805 +	srlz.i					// guarantee that interruption collection is on
 35.1806 +	;;
 35.1807 +(p15)	ssm psr.i
 35.1808 +	adds r3=8,r2		// Base pointer for SAVE_REST
 35.1809 +	;;
 35.1810 +	SAVE_REST
 35.1811 +	;;
 35.1812 +	mov r15=0x80
 35.1813 +	shr r14=r14,16		// Get interrupt number
 35.1814 +	;;
 35.1815 +	cmp.ne p6,p0=r14,r15
 35.1816 +(p6)	br.call.dpnt.many b6=non_ia32_syscall
 35.1817 +
 35.1818 +	adds r14=IA64_PT_REGS_R8_OFFSET + 16,sp	// 16 byte hole per SW conventions
 35.1819 +	adds r15=IA64_PT_REGS_R1_OFFSET + 16,sp
 35.1820 +	;;
 35.1821 +	cmp.eq pSys,pNonSys=r0,r0 // set pSys=1, pNonSys=0
 35.1822 +	ld8 r8=[r14]		// get r8
 35.1823 +	;;
 35.1824 +	st8 [r15]=r8		// save original EAX in r1 (IA32 procs don't use the GP)
 35.1825 +	;;
 35.1826 +	alloc r15=ar.pfs,0,0,6,0	// must first in an insn group
 35.1827 +	;;
 35.1828 +	ld4 r8=[r14],8		// r8 == eax (syscall number)
 35.1829 +	mov r15=IA32_NR_syscalls
 35.1830 +	;;
 35.1831 +	cmp.ltu.unc p6,p7=r8,r15
 35.1832 +	ld4 out1=[r14],8	// r9 == ecx
 35.1833 +	;;
 35.1834 +	ld4 out2=[r14],8	// r10 == edx
 35.1835 +	;;
 35.1836 +	ld4 out0=[r14]		// r11 == ebx
 35.1837 +	adds r14=(IA64_PT_REGS_R13_OFFSET) + 16,sp
 35.1838 +	;;
 35.1839 +	ld4 out5=[r14],PT(R14)-PT(R13)	// r13 == ebp
 35.1840 +	;;
 35.1841 +	ld4 out3=[r14],PT(R15)-PT(R14)	// r14 == esi
 35.1842 +	adds r2=TI_FLAGS+IA64_TASK_SIZE,r13
 35.1843 +	;;
 35.1844 +	ld4 out4=[r14]		// r15 == edi
 35.1845 +	movl r16=ia32_syscall_table
 35.1846 +	;;
 35.1847 +(p6)	shladd r16=r8,3,r16	// force ni_syscall if not valid syscall number
 35.1848 +	ld4 r2=[r2]		// r2 = current_thread_info()->flags
 35.1849 +	;;
 35.1850 +	ld8 r16=[r16]
 35.1851 +	and r2=_TIF_SYSCALL_TRACEAUDIT,r2	// mask trace or audit
 35.1852 +	;;
 35.1853 +	mov b6=r16
 35.1854 +	movl r15=ia32_ret_from_syscall
 35.1855 +	cmp.eq p8,p0=r2,r0
 35.1856 +	;;
 35.1857 +	mov rp=r15
 35.1858 +(p8)	br.call.sptk.many b6=b6
 35.1859 +	br.cond.sptk ia32_trace_syscall
 35.1860 +
 35.1861 +non_ia32_syscall:
 35.1862 +	alloc r15=ar.pfs,0,0,2,0
 35.1863 +	mov out0=r14				// interrupt #
 35.1864 +	add out1=16,sp				// pointer to pt_regs
 35.1865 +	;;			// avoid WAW on CFM
 35.1866 +	br.call.sptk.many rp=ia32_bad_interrupt
 35.1867 +.ret1:	movl r15=ia64_leave_kernel
 35.1868 +	;;
 35.1869 +	mov rp=r15
 35.1870 +	br.ret.sptk.many rp
 35.1871 +END(dispatch_to_ia32_handler)
 35.1872 +
 35.1873 +#endif /* CONFIG_IA32_SUPPORT */
    37.1 --- a/xen/arch/ia64/patch/linux-2.6.11/bootmem.h	Fri Apr 29 16:49:15 2005 +0000
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,17 +0,0 @@
    37.4 - bootmem.h |    2 ++
    37.5 - 1 files changed, 2 insertions(+)
    37.6 -
    37.7 -Index: linux-2.6.11/include/linux/bootmem.h
    37.8 -===================================================================
    37.9 ---- linux-2.6.11.orig/include/linux/bootmem.h	2005-03-02 01:38:25.000000000 -0600
   37.10 -+++ linux-2.6.11/include/linux/bootmem.h	2005-03-19 12:39:36.915887729 -0600
   37.11 -@@ -41,7 +41,9 @@ extern unsigned long __init init_bootmem
   37.12 - extern void __init free_bootmem (unsigned long addr, unsigned long size);
   37.13 - extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
   37.14 - #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
   37.15 -+#ifndef XEN
   37.16 - extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
   37.17 -+#endif
   37.18 - #define alloc_bootmem(x) \
   37.19 - 	__alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
   37.20 - #define alloc_bootmem_low(x) \
    38.1 --- a/xen/arch/ia64/patch/linux-2.6.11/cpumask.h	Fri Apr 29 16:49:15 2005 +0000
    38.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/cpumask.h	Tue May 03 08:08:47 2005 +0000
    38.3 @@ -1,20 +1,12 @@
    38.4 - cpumask.h |    2 +-
    38.5 - 1 files changed, 1 insertion(+), 1 deletion(-)
    38.6 -
    38.7 -Index: linux-2.6.11-xendiffs/include/linux/cpumask.h
    38.8 -===================================================================
    38.9 ---- linux-2.6.11-xendiffs.orig/include/linux/cpumask.h	2005-03-02 01:38:00.000000000 -0600
   38.10 -+++ linux-2.6.11-xendiffs/include/linux/cpumask.h	2005-03-24 15:06:18.408145243 -0600
   38.11 -@@ -341,11 +341,11 @@ static inline int __cpumask_parse(const 
   38.12 -  *        main(){ set1(3); set2(5); }
   38.13 +--- ../../linux-2.6.11/include/linux/cpumask.h	2005-03-02 00:38:00.000000000 -0700
   38.14 ++++ include/asm-ia64/linux/cpumask.h	2005-04-28 13:21:20.000000000 -0600
   38.15 +@@ -342,7 +342,9 @@
   38.16    */
   38.17   
   38.18 -+#if NR_CPUS > 1
   38.19   extern cpumask_t cpu_possible_map;
   38.20 ++#ifndef XEN
   38.21   extern cpumask_t cpu_online_map;
   38.22 ++#endif
   38.23   extern cpumask_t cpu_present_map;
   38.24   
   38.25 --#if NR_CPUS > 1
   38.26 - #define num_online_cpus()	cpus_weight(cpu_online_map)
   38.27 - #define num_possible_cpus()	cpus_weight(cpu_possible_map)
   38.28 - #define num_present_cpus()	cpus_weight(cpu_present_map)
   38.29 + #if NR_CPUS > 1
    39.1 --- a/xen/arch/ia64/patch/linux-2.6.11/current.h	Fri Apr 29 16:49:15 2005 +0000
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,22 +0,0 @@
    39.4 - current.h |    8 ++++++++
    39.5 - 1 files changed, 8 insertions(+)
    39.6 -
    39.7 -Index: linux-2.6.11/include/asm-ia64/current.h
    39.8 -===================================================================
    39.9 ---- linux-2.6.11.orig/include/asm-ia64/current.h	2005-03-02 01:38:19.000000000 -0600
   39.10 -+++ linux-2.6.11/include/asm-ia64/current.h	2005-03-19 12:39:41.410955288 -0600
   39.11 -@@ -12,6 +12,14 @@
   39.12 -  * In kernel mode, thread pointer (r13) is used to point to the current task
   39.13 -  * structure.
   39.14 -  */
   39.15 -+#ifdef XEN
   39.16 -+struct domain;
   39.17 -+#define get_current()	((struct exec_domain *) ia64_getreg(_IA64_REG_TP))
   39.18 -+#define current get_current()
   39.19 -+//#define set_current(d)	ia64_setreg(_IA64_REG_TP,(void *)d);
   39.20 -+#define set_current(d)		(ia64_r13 = (void *)d)
   39.21 -+#else
   39.22 - #define current	((struct task_struct *) ia64_getreg(_IA64_REG_TP))
   39.23 -+#endif
   39.24 - 
   39.25 - #endif /* _ASM_IA64_CURRENT_H */
    40.1 --- a/xen/arch/ia64/patch/linux-2.6.11/efi.c	Fri Apr 29 16:49:15 2005 +0000
    40.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/efi.c	Tue May 03 08:08:47 2005 +0000
    40.3 @@ -1,29 +1,6 @@
    40.4 - efi.c |   32 ++++++++++++++++++++++++++++++++
    40.5 - 1 files changed, 32 insertions(+)
    40.6 -
    40.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/efi.c
    40.8 -===================================================================
    40.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/efi.c	2005-04-07 12:22:08.230781400 -0500
   40.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/efi.c	2005-04-07 12:25:11.875195997 -0500
   40.11 -@@ -25,6 +25,9 @@
   40.12 - #include <linux/types.h>
   40.13 - #include <linux/time.h>
   40.14 - #include <linux/efi.h>
   40.15 -+#ifdef XEN
   40.16 -+#include <xen/sched.h>
   40.17 -+#endif
   40.18 - 
   40.19 - #include <asm/io.h>
   40.20 - #include <asm/kregs.h>
   40.21 -@@ -218,6 +221,7 @@ efi_gettimeofday (struct timespec *ts)
   40.22 - 	if ((*efi.get_time)(&tm, NULL) != EFI_SUCCESS)
   40.23 - 		return;
   40.24 - 
   40.25 -+	dummy();
   40.26 - 	ts->tv_sec = mktime(tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second);
   40.27 - 	ts->tv_nsec = tm.nanosecond;
   40.28 - }
   40.29 -@@ -320,6 +324,10 @@ efi_memmap_walk (efi_freemem_callback_t 
   40.30 +--- ../../linux-2.6.11/arch/ia64/kernel/efi.c	2005-03-02 00:37:47.000000000 -0700
   40.31 ++++ arch/ia64/efi.c	2005-04-29 14:09:24.000000000 -0600
   40.32 +@@ -320,6 +320,10 @@
   40.33   		if (!(md->attribute & EFI_MEMORY_WB))
   40.34   			continue;
   40.35   
   40.36 @@ -34,7 +11,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
   40.37   		/*
   40.38   		 * granule_addr is the base of md's first granule.
   40.39   		 * [granule_addr - first_non_wb_addr) is guaranteed to
   40.40 -@@ -719,6 +727,30 @@ efi_get_iobase (void)
   40.41 +@@ -719,6 +723,30 @@
   40.42   	return 0;
   40.43   }
   40.44   
    41.1 --- a/xen/arch/ia64/patch/linux-2.6.11/entry.S	Fri Apr 29 16:49:15 2005 +0000
    41.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/entry.S	Tue May 03 08:08:47 2005 +0000
    41.3 @@ -1,86 +1,34 @@
    41.4 - entry.S |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
    41.5 - 1 files changed, 85 insertions(+), 1 deletion(-)
    41.6 -
    41.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/entry.S
    41.8 -===================================================================
    41.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/entry.S	2005-04-08 13:32:07.636308237 -0500
   41.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/entry.S	2005-04-08 13:37:04.612542509 -0500
   41.11 -@@ -35,7 +35,9 @@
   41.12 - 
   41.13 - #include <asm/asmmacro.h>
   41.14 - #include <asm/cache.h>
   41.15 -+#ifndef XEN
   41.16 - #include <asm/errno.h>
   41.17 -+#endif
   41.18 - #include <asm/kregs.h>
   41.19 - #include <asm/offsets.h>
   41.20 - #include <asm/pgtable.h>
   41.21 -@@ -46,6 +48,25 @@
   41.22 +--- ../../linux-2.6.11/arch/ia64/kernel/entry.S	2005-03-02 00:37:50.000000000 -0700
   41.23 ++++ arch/ia64/entry.S	2005-04-29 14:54:13.000000000 -0600
   41.24 +@@ -46,6 +46,7 @@
   41.25   
   41.26   #include "minstate.h"
   41.27   
   41.28 -+#ifdef XEN
   41.29 -+#define	sys_execve 0
   41.30 -+#define do_fork 0
   41.31 -+#define	syscall_trace_enter 0
   41.32 -+#define	syscall_trace_leave 0
   41.33 -+#define schedule 0
   41.34 -+#define do_notify_resume_user 0
   41.35 -+#define ia64_rt_sigsuspend 0
   41.36 -+#define ia64_rt_sigreturn 0
   41.37 -+#define	ia64_handle_unaligned 0
   41.38 -+#define	errno 0
   41.39 -+#define	sys_ni_syscall 0
   41.40 -+#define unw_init_frame_info 0
   41.41 -+#define sys_call_table 0
   41.42 -+#define do_sigdelayed 0
   41.43 -+#endif
   41.44 -+
   41.45 -+	/*
   41.46 -+
   41.47 ++#ifndef XEN
   41.48   	/*
   41.49   	 * execve() is special because in case of success, we need to
   41.50   	 * setup a null register window frame.
   41.51 -@@ -187,11 +208,14 @@ GLOBAL_ENTRY(ia64_switch_to)
   41.52 - 	DO_SAVE_SWITCH_STACK
   41.53 - 	.body
   41.54 +@@ -174,6 +175,7 @@
   41.55 + 	mov rp=loc0
   41.56 + 	br.ret.sptk.many rp
   41.57 + END(sys_clone)
   41.58 ++#endif /* !XEN */
   41.59   
   41.60 -+#ifdef XEN
   41.61 -+//#undef IA64_TASK_THREAD_KSP_OFFSET
   41.62 -+//#define	IA64_TASK_THREAD_KSP_OFFSET	0x38
   41.63 - 	adds r22=IA64_TASK_THREAD_KSP_OFFSET,r13
   41.64 + /*
   41.65 +  * prev_task <- ia64_switch_to(struct task_struct *next)
   41.66 +@@ -191,7 +193,11 @@
   41.67   	movl r25=init_task
   41.68   	mov r27=IA64_KR(CURRENT_STACK)
   41.69   	adds r21=IA64_TASK_THREAD_KSP_OFFSET,in0
   41.70 --	dep r20=0,in0,61,3		// physical address of "next"
   41.71 ++#ifdef XEN
   41.72  +	dep r20=0,in0,60,4		// physical address of "next"
   41.73 ++#else
   41.74 + 	dep r20=0,in0,61,3		// physical address of "next"
   41.75 ++#endif
   41.76   	;;
   41.77   	st8 [r22]=sp			// save kernel stack pointer of old task
   41.78   	shr.u r26=r20,IA64_GRANULE_SHIFT
   41.79 -@@ -203,6 +227,22 @@ GLOBAL_ENTRY(ia64_switch_to)
   41.80 - (p6)	cmp.eq p7,p6=r26,r27
   41.81 - (p6)	br.cond.dpnt .map
   41.82 - 	;;
   41.83 -+#else
   41.84 -+	adds r22=IA64_TASK_THREAD_KSP_OFFSET,r13
   41.85 -+	mov r27=IA64_KR(CURRENT_STACK)
   41.86 -+	dep r20=0,in0,61,3		// physical address of "current"
   41.87 -+	;;
   41.88 -+	st8 [r22]=sp			// save kernel stack pointer of old task
   41.89 -+	shr.u r26=r20,IA64_GRANULE_SHIFT
   41.90 -+	adds r21=IA64_TASK_THREAD_KSP_OFFSET,in0
   41.91 -+	;;
   41.92 -+	/*
   41.93 -+	 * If we've already mapped this task's page, we can skip doing it again.
   41.94 -+	 */
   41.95 -+	cmp.eq p7,p6=r26,r27
   41.96 -+(p6)	br.cond.dpnt .map
   41.97 -+	;;
   41.98 -+#endif
   41.99 - .done:
  41.100 - (p6)	ssm psr.ic			// if we had to map, reenable the psr.ic bit FIRST!!!
  41.101 - 	;;
  41.102 -@@ -220,6 +260,16 @@ GLOBAL_ENTRY(ia64_switch_to)
  41.103 +@@ -220,6 +226,16 @@
  41.104   	br.ret.sptk.many rp		// boogie on out in new context
  41.105   
  41.106   .map:
  41.107 @@ -97,7 +45,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.108   	rsm psr.ic			// interrupts (psr.i) are already disabled here
  41.109   	movl r25=PAGE_KERNEL
  41.110   	;;
  41.111 -@@ -376,7 +426,11 @@ END(save_switch_stack)
  41.112 +@@ -376,7 +392,11 @@
  41.113    *	- b7 holds address to return to
  41.114    *	- must not touch r8-r11
  41.115    */
  41.116 @@ -109,7 +57,23 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.117   	.prologue
  41.118   	.altrp b7
  41.119   
  41.120 -@@ -604,6 +658,11 @@ GLOBAL_ENTRY(ia64_ret_from_clone)
  41.121 +@@ -470,6 +490,7 @@
  41.122 + 	br.cond.sptk.many b7
  41.123 + END(load_switch_stack)
  41.124 + 
  41.125 ++#ifndef XEN
  41.126 + GLOBAL_ENTRY(__ia64_syscall)
  41.127 + 	.regstk 6,0,0,0
  41.128 + 	mov r15=in5				// put syscall number in place
  41.129 +@@ -588,6 +609,7 @@
  41.130 + }
  41.131 + .ret4:	br.cond.sptk ia64_leave_kernel
  41.132 + END(ia64_strace_leave_kernel)
  41.133 ++#endif
  41.134 + 
  41.135 + GLOBAL_ENTRY(ia64_ret_from_clone)
  41.136 + 	PT_REGS_UNWIND_INFO(0)
  41.137 +@@ -604,6 +626,11 @@
  41.138   	 */
  41.139   	br.call.sptk.many rp=ia64_invoke_schedule_tail
  41.140   }
  41.141 @@ -121,7 +85,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.142   .ret8:
  41.143   	adds r2=TI_FLAGS+IA64_TASK_SIZE,r13
  41.144   	;;
  41.145 -@@ -614,6 +673,7 @@ GLOBAL_ENTRY(ia64_ret_from_clone)
  41.146 +@@ -614,6 +641,7 @@
  41.147   	;;
  41.148   	cmp.ne p6,p0=r2,r0
  41.149   (p6)	br.cond.spnt .strace_check_retval
  41.150 @@ -129,14 +93,11 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.151   	;;					// added stop bits to prevent r8 dependency
  41.152   END(ia64_ret_from_clone)
  41.153   	// fall through
  41.154 -@@ -700,9 +760,14 @@ ENTRY(ia64_leave_syscall)
  41.155 +@@ -700,19 +728,25 @@
  41.156   .work_processed_syscall:
  41.157   	adds r2=PT(LOADRS)+16,r12
  41.158   	adds r3=PT(AR_BSPSTORE)+16,r12
  41.159 -+#ifdef XEN
  41.160 -+	mov r31=r0
  41.161 -+	;;
  41.162 -+#else
  41.163 ++#ifndef XEN
  41.164   	adds r18=TI_FLAGS+IA64_TASK_SIZE,r13
  41.165   	;;
  41.166   (p6)	ld4 r31=[r18]				// load current_thread_info()->flags
  41.167 @@ -144,7 +105,21 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.168   	ld8 r19=[r2],PT(B6)-PT(LOADRS)		// load ar.rsc value for "loadrs"
  41.169   	mov b7=r0		// clear b7
  41.170   	;;
  41.171 -@@ -757,7 +822,11 @@ ENTRY(ia64_leave_syscall)
  41.172 + 	ld8 r23=[r3],PT(R11)-PT(AR_BSPSTORE)	// load ar.bspstore (may be garbage)
  41.173 + 	ld8 r18=[r2],PT(R9)-PT(B6)		// load b6
  41.174 ++#ifndef XEN
  41.175 + (p6)	and r15=TIF_WORK_MASK,r31		// any work other than TIF_SYSCALL_TRACE?
  41.176 ++#endif
  41.177 + 	;;
  41.178 + 	mov r16=ar.bsp				// M2  get existing backing store pointer
  41.179 ++#ifndef XEN
  41.180 + (p6)	cmp4.ne.unc p6,p0=r15, r0		// any special work pending?
  41.181 + (p6)	br.cond.spnt .work_pending_syscall
  41.182 ++#endif
  41.183 + 	;;
  41.184 + 	// start restoring the state saved on the kernel stack (struct pt_regs):
  41.185 + 	ld8 r9=[r2],PT(CR_IPSR)-PT(R9)
  41.186 +@@ -757,7 +791,11 @@
  41.187   	;;
  41.188   	ld8.fill r12=[r2]	// restore r12 (sp)
  41.189   	ld8.fill r15=[r3]	// restore r15
  41.190 @@ -156,7 +131,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.191   	;;
  41.192   (pUStk)	ld4 r3=[r3]		// r3 = cpu_data->phys_stacked_size_p8
  41.193   (pUStk) st1 [r14]=r17
  41.194 -@@ -814,9 +883,18 @@ GLOBAL_ENTRY(ia64_leave_kernel)
  41.195 +@@ -814,9 +852,18 @@
  41.196   (pUStk)	cmp.eq.unc p6,p0=r0,r0		// p6 <- pUStk
  41.197   #endif
  41.198   .work_processed_kernel:
  41.199 @@ -175,7 +150,17 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.200   	adds r21=PT(PR)+16,r12
  41.201   	;;
  41.202   
  41.203 -@@ -934,7 +1012,11 @@ GLOBAL_ENTRY(ia64_leave_kernel)
  41.204 +@@ -838,7 +885,9 @@
  41.205 + 	;;
  41.206 + 	ld8 r29=[r2],16		// load b7
  41.207 + 	ld8 r30=[r3],16		// load ar.csd
  41.208 ++#ifndef XEN
  41.209 + (p6)	br.cond.spnt .work_pending
  41.210 ++#endif
  41.211 + 	;;
  41.212 + 	ld8 r31=[r2],16		// load ar.ssd
  41.213 + 	ld8.fill r8=[r3],16
  41.214 +@@ -934,7 +983,11 @@
  41.215   	shr.u r18=r19,16	// get byte size of existing "dirty" partition
  41.216   	;;
  41.217   	mov r16=ar.bsp		// get existing backing store pointer
  41.218 @@ -187,15 +172,47 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  41.219   	;;
  41.220   	ld4 r17=[r17]		// r17 = cpu_data->phys_stacked_size_p8
  41.221   (pKStk)	br.cond.dpnt skip_rbs_switch
  41.222 -@@ -1323,6 +1405,7 @@ GLOBAL_ENTRY(unw_init_running)
  41.223 +@@ -1069,6 +1122,7 @@
  41.224 + 	mov pr=r31,-1		// I0
  41.225 + 	rfi			// B
  41.226 + 
  41.227 ++#ifndef XEN
  41.228 + 	/*
  41.229 + 	 * On entry:
  41.230 + 	 *	r20 = &current->thread_info->pre_count (if CONFIG_PREEMPT)
  41.231 +@@ -1130,6 +1184,7 @@
  41.232 + 	ld8 r8=[r2]
  41.233 + 	ld8 r10=[r3]
  41.234 + 	br.cond.sptk.many .work_processed_syscall	// re-check
  41.235 ++#endif
  41.236 + 
  41.237 + END(ia64_leave_kernel)
  41.238 + 
  41.239 +@@ -1166,6 +1221,7 @@
  41.240   	br.ret.sptk.many rp
  41.241 - END(unw_init_running)
  41.242 + END(ia64_invoke_schedule_tail)
  41.243   
  41.244  +#ifndef XEN
  41.245 - 	.rodata
  41.246 - 	.align 8
  41.247 - 	.globl sys_call_table
  41.248 -@@ -1585,3 +1668,4 @@ sys_call_table:
  41.249 + 	/*
  41.250 + 	 * Setup stack and call do_notify_resume_user().  Note that pSys and pNonSys need to
  41.251 + 	 * be set up by the caller.  We declare 8 input registers so the system call
  41.252 +@@ -1264,6 +1320,7 @@
  41.253 + 	mov ar.unat=r9
  41.254 + 	br.many b7
  41.255 + END(sys_rt_sigreturn)
  41.256 ++#endif
  41.257 + 
  41.258 + GLOBAL_ENTRY(ia64_prepare_handle_unaligned)
  41.259 + 	.prologue
  41.260 +@@ -1278,6 +1335,7 @@
  41.261 + 	br.cond.sptk.many rp				// goes to ia64_leave_kernel
  41.262 + END(ia64_prepare_handle_unaligned)
  41.263 + 
  41.264 ++#ifndef XEN
  41.265 + 	//
  41.266 + 	// unw_init_running(void (*callback)(info, arg), void *arg)
  41.267 + 	//
  41.268 +@@ -1585,3 +1643,4 @@
  41.269   	data8 sys_ni_syscall
  41.270   
  41.271   	.org sys_call_table + 8*NR_syscalls	// guard against failures to increase NR_syscalls
    42.1 --- a/xen/arch/ia64/patch/linux-2.6.11/hardirq.h	Fri Apr 29 16:49:15 2005 +0000
    42.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/hardirq.h	Tue May 03 08:08:47 2005 +0000
    42.3 @@ -1,15 +1,14 @@
    42.4 - hardirq.h |    1 +
    42.5 - 1 files changed, 1 insertion(+)
    42.6 -
    42.7 -Index: linux-2.6.11-xendiffs/include/asm-ia64/hardirq.h
    42.8 -===================================================================
    42.9 ---- linux-2.6.11-xendiffs.orig/include/asm-ia64/hardirq.h	2005-03-24 15:59:37.210502749 -0600
   42.10 -+++ linux-2.6.11-xendiffs/include/asm-ia64/hardirq.h	2005-03-24 16:00:19.439540961 -0600
   42.11 -@@ -20,6 +20,7 @@
   42.12 - #define __ARCH_IRQ_STAT	1
   42.13 +--- ../../linux-2.6.11/include/linux/hardirq.h	2005-03-02 00:38:00.000000000 -0700
   42.14 ++++ include/asm-ia64/linux/hardirq.h	2005-04-28 16:34:39.000000000 -0600
   42.15 +@@ -60,7 +60,11 @@
   42.16 +  */
   42.17 + #define in_irq()		(hardirq_count())
   42.18 + #define in_softirq()		(softirq_count())
   42.19 ++#ifndef XEN
   42.20 + #define in_interrupt()		(irq_count())
   42.21 ++#else
   42.22 ++#define in_interrupt()		0		// FIXME LATER
   42.23 ++#endif
   42.24   
   42.25 - #define local_softirq_pending()		(local_cpu_data->softirq_pending)
   42.26 -+#define softirq_pending(cpu)			(cpu_data(cpu)->softirq_pending)
   42.27 - 
   42.28 - #define HARDIRQ_BITS	14
   42.29 - 
   42.30 + #if defined(CONFIG_PREEMPT) && !defined(CONFIG_PREEMPT_BKL)
   42.31 + # define in_atomic()	((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
    43.1 --- a/xen/arch/ia64/patch/linux-2.6.11/head.S	Fri Apr 29 16:49:15 2005 +0000
    43.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/head.S	Tue May 03 08:08:47 2005 +0000
    43.3 @@ -1,20 +1,6 @@
    43.4 - head.S |   34 ++++++++++++++++++++++++++++++++++
    43.5 - 1 files changed, 34 insertions(+)
    43.6 -
    43.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/head.S
    43.8 -===================================================================
    43.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/head.S	2005-04-07 10:56:19.225128582 -0500
   43.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/head.S	2005-04-07 11:00:21.718513399 -0500
   43.11 -@@ -1,3 +1,8 @@
   43.12 -+#ifdef XEN
   43.13 -+#define	console_print	printf
   43.14 -+#define kernel_thread_helper 0
   43.15 -+#define sys_exit 0
   43.16 -+#endif
   43.17 - /*
   43.18 -  * Here is where the ball gets rolling as far as the kernel is concerned.
   43.19 -  * When control is transferred to _start, the bootload has already
   43.20 -@@ -187,7 +192,11 @@ start_ap:
   43.21 +--- ../../linux-2.6.11/arch/ia64/kernel/head.S	2005-03-02 00:38:13.000000000 -0700
   43.22 ++++ arch/ia64/head.S	2005-04-28 10:51:19.000000000 -0600
   43.23 +@@ -187,7 +187,11 @@
   43.24   	dep r18=0,r3,0,12
   43.25   	;;
   43.26   	or r18=r17,r18
   43.27 @@ -26,7 +12,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
   43.28   	;;
   43.29   	mov r17=rr[r2]
   43.30   	shr.u r16=r3,IA64_GRANULE_SHIFT
   43.31 -@@ -227,7 +236,11 @@ start_ap:
   43.32 +@@ -227,7 +231,11 @@
   43.33   	;;
   43.34   	mov ar.rsc=0x3		// place RSE in eager mode
   43.35   
   43.36 @@ -38,29 +24,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
   43.37   (isBP)	movl r2=ia64_boot_param
   43.38   	;;
   43.39   (isBP)	st8 [r2]=r28		// save the address of the boot param area passed by the bootloader
   43.40 -@@ -245,7 +258,21 @@ start_ap:
   43.41 - 	br.call.sptk.many rp=sys_fw_init
   43.42 - .ret1:
   43.43 - #endif
   43.44 -+#ifdef XEN
   43.45 -+	alloc r2=ar.pfs,8,0,2,0
   43.46 -+	;;
   43.47 -+#define fake_mbi_magic 0
   43.48 -+#define MULTIBOOT_INFO_SIZE	1024
   43.49 -+	.rodata
   43.50 -+fake_mbi:
   43.51 -+	.skip MULTIBOOT_INFO_SIZE
   43.52 -+	.previous
   43.53 -+	movl out0=fake_mbi
   43.54 -+	;;
   43.55 -+	br.call.sptk.many rp=cmain
   43.56 -+#else
   43.57 - 	br.call.sptk.many rp=start_kernel
   43.58 -+#endif
   43.59 - .ret2:	addl r3=@ltoff(halt_msg),gp
   43.60 - 	;;
   43.61 - 	alloc r2=ar.pfs,8,0,2,0
   43.62 -@@ -254,7 +281,9 @@ start_ap:
   43.63 +@@ -254,7 +262,9 @@
   43.64   	br.call.sptk.many b0=console_print
   43.65   
   43.66   self:	hint @pause
   43.67 @@ -70,13 +34,12 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
   43.68   END(_start)
   43.69   
   43.70   GLOBAL_ENTRY(ia64_save_debug_regs)
   43.71 -@@ -850,7 +879,12 @@ END(ia64_delay_loop)
   43.72 +@@ -850,7 +860,11 @@
   43.73    * intermediate precision so that we can produce a full 64-bit result.
   43.74    */
   43.75   GLOBAL_ENTRY(sched_clock)
   43.76  +#ifdef XEN
   43.77 -+	break 0;;	// FIX IA64_CPUINFO_NSEC_PER_CYC_OFFSET
   43.78 -+	//movl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET
   43.79 ++	movl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET
   43.80  +#else
   43.81   	addl r8=THIS_CPU(cpu_info) + IA64_CPUINFO_NSEC_PER_CYC_OFFSET,r0
   43.82  +#endif
    44.1 --- a/xen/arch/ia64/patch/linux-2.6.11/hpsim_irq.c	Fri Apr 29 16:49:15 2005 +0000
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,41 +0,0 @@
    44.4 - hpsim_irq.c |   15 +++++++++++++++
    44.5 - 1 files changed, 15 insertions(+)
    44.6 -
    44.7 -Index: linux-2.6.11/arch/ia64/hp/sim/hpsim_irq.c
    44.8 -===================================================================
    44.9 ---- linux-2.6.11.orig/arch/ia64/hp/sim/hpsim_irq.c	2005-03-02 01:38:33.000000000 -0600
   44.10 -+++ linux-2.6.11/arch/ia64/hp/sim/hpsim_irq.c	2005-03-19 13:33:57.312014806 -0600
   44.11 -@@ -9,7 +9,17 @@
   44.12 - #include <linux/kernel.h>
   44.13 - #include <linux/sched.h>
   44.14 - #include <linux/irq.h>
   44.15 -+#ifdef XEN
   44.16 -+#include <asm/hw_irq.h>
   44.17 -+#endif
   44.18 - 
   44.19 -+#if 1
   44.20 -+void __init
   44.21 -+hpsim_irq_init (void)
   44.22 -+{
   44.23 -+	printf("*** hpsim_irq_init called: NOT NEEDED?!?!?\n");
   44.24 -+}
   44.25 -+#else
   44.26 - static unsigned int
   44.27 - hpsim_irq_startup (unsigned int irq)
   44.28 - {
   44.29 -@@ -19,6 +29,10 @@ hpsim_irq_startup (unsigned int irq)
   44.30 - static void
   44.31 - hpsim_irq_noop (unsigned int irq)
   44.32 - {
   44.33 -+#if 1
   44.34 -+printf("hpsim_irq_noop: irq=%d\n",irq);
   44.35 -+while(irq);
   44.36 -+#endif
   44.37 - }
   44.38 - 
   44.39 - static void
   44.40 -@@ -49,3 +63,4 @@ hpsim_irq_init (void)
   44.41 - 			idesc->handler = &irq_type_hp_sim;
   44.42 - 	}
   44.43 - }
   44.44 -+#endif
    46.1 --- a/xen/arch/ia64/patch/linux-2.6.11/irq.h	Fri Apr 29 16:49:15 2005 +0000
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,23 +0,0 @@
    46.4 - irq.h |    9 +++++++++
    46.5 - 1 files changed, 9 insertions(+)
    46.6 -
    46.7 -Index: linux-2.6.11/include/asm-ia64/irq.h
    46.8 -===================================================================
    46.9 ---- linux-2.6.11.orig/include/asm-ia64/irq.h	2005-03-02 01:38:33.000000000 -0600
   46.10 -+++ linux-2.6.11/include/asm-ia64/irq.h	2005-03-19 13:42:27.957677364 -0600
   46.11 -@@ -30,6 +30,15 @@ extern void disable_irq_nosync (unsigned
   46.12 - extern void enable_irq (unsigned int);
   46.13 - extern void set_irq_affinity_info (unsigned int irq, int dest, int redir);
   46.14 - 
   46.15 -+#ifdef XEN
   46.16 -+// dup'ed from signal.h to avoid changes to includes
   46.17 -+#define	SA_NOPROFILE	0x02000000
   46.18 -+#define	SA_SHIRQ	0x04000000
   46.19 -+#define	SA_RESTART	0x10000000
   46.20 -+#define	SA_INTERRUPT	0x20000000
   46.21 -+#define	SA_SAMPLE_RANDOM	SA_RESTART
   46.22 -+#endif
   46.23 -+
   46.24 - #ifdef CONFIG_SMP
   46.25 - extern void move_irq(int irq);
   46.26 - #else
    47.1 --- a/xen/arch/ia64/patch/linux-2.6.11/irq_ia64.c	Fri Apr 29 16:49:15 2005 +0000
    47.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/irq_ia64.c	Tue May 03 08:08:47 2005 +0000
    47.3 @@ -1,111 +1,22 @@
    47.4 - irq_ia64.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    47.5 - 1 files changed, 67 insertions(+)
    47.6 -
    47.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/irq_ia64.c
    47.8 -===================================================================
    47.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/irq_ia64.c	2005-04-08 13:30:16.777174938 -0500
   47.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/irq_ia64.c	2005-04-08 14:15:47.398616472 -0500
   47.11 -@@ -17,18 +17,26 @@
   47.12 - #include <linux/config.h>
   47.13 - #include <linux/module.h>
   47.14 - 
   47.15 -+#ifndef XEN
   47.16 - #include <linux/jiffies.h>
   47.17 -+#endif
   47.18 - #include <linux/errno.h>
   47.19 - #include <linux/init.h>
   47.20 - #include <linux/interrupt.h>
   47.21 - #include <linux/ioport.h>
   47.22 -+#ifndef XEN
   47.23 - #include <linux/kernel_stat.h>
   47.24 -+#endif
   47.25 - #include <linux/slab.h>
   47.26 -+#ifndef XEN
   47.27 - #include <linux/ptrace.h>
   47.28 - #include <linux/random.h>	/* for rand_initialize_irq() */
   47.29 - #include <linux/signal.h>
   47.30 -+#endif
   47.31 - #include <linux/smp.h>
   47.32 -+#ifndef XEN
   47.33 - #include <linux/smp_lock.h>
   47.34 -+#endif
   47.35 - #include <linux/threads.h>
   47.36 - #include <linux/bitops.h>
   47.37 - 
   47.38 -@@ -104,6 +112,24 @@ void
   47.39 - ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
   47.40 - {
   47.41 +--- ../../linux-2.6.11/arch/ia64/kernel/irq_ia64.c	2005-03-02 00:38:07.000000000 -0700
   47.42 ++++ arch/ia64/irq_ia64.c	2005-04-29 16:05:30.000000000 -0600
   47.43 +@@ -106,6 +106,9 @@
   47.44   	unsigned long saved_tpr;
   47.45 -+#if 0
   47.46 -+//FIXME: For debug only, can be removed
   47.47 -+	static char firstirq = 1;
   47.48 -+	static char firsttime[256];
   47.49 -+	static char firstpend[256];
   47.50 -+	if (firstirq) {
   47.51 -+		int i;
   47.52 -+		for (i=0;i<256;i++) firsttime[i] = 1;
   47.53 -+		for (i=0;i<256;i++) firstpend[i] = 1;
   47.54 -+		firstirq = 0;
   47.55 -+	}
   47.56 -+	if (firsttime[vector]) {
   47.57 -+		printf("**** (entry) First received int on vector=%d,itc=%lx\n",
   47.58 -+			(unsigned long) vector, ia64_get_itc());
   47.59 -+		firsttime[vector] = 0;
   47.60 -+	}
   47.61 -+#endif
   47.62 -+
   47.63   
   47.64   #if IRQ_DEBUG
   47.65 ++#ifdef XEN
   47.66 ++	xen_debug_irq(vector, regs);
   47.67 ++#endif
   47.68   	{
   47.69 -@@ -148,6 +174,27 @@ ia64_handle_irq (ia64_vector vector, str
   47.70 + 		unsigned long bsp, sp;
   47.71 + 
   47.72 +@@ -148,6 +151,9 @@
   47.73   			ia64_setreg(_IA64_REG_CR_TPR, vector);
   47.74   			ia64_srlz_d();
   47.75   
   47.76  +#ifdef XEN
   47.77 -+	if (vector != 0xef) {
   47.78 -+		extern void vcpu_pend_interrupt(void *, int);
   47.79 -+#if 0
   47.80 -+		if (firsttime[vector]) {
   47.81 -+			printf("**** (iterate) First received int on vector=%d,itc=%lx\n",
   47.82 -+			(unsigned long) vector, ia64_get_itc());
   47.83 -+			firsttime[vector] = 0;
   47.84 -+		}
   47.85 -+		if (firstpend[vector]) {
   47.86 -+			printf("**** First pended int on vector=%d,itc=%lx\n",
   47.87 -+				(unsigned long) vector,ia64_get_itc());
   47.88 -+			firstpend[vector] = 0;
   47.89 -+		}
   47.90 -+#endif
   47.91 -+		//FIXME: TEMPORARY HACK!!!!
   47.92 -+		vcpu_pend_interrupt(dom0->exec_domain[0],vector);
   47.93 -+		domain_wake(dom0->exec_domain[0]);
   47.94 -+	}
   47.95 -+	else
   47.96 ++			if (!xen_do_IRQ(vector))
   47.97  +#endif
   47.98   			__do_IRQ(local_vector_to_irq(vector), regs);
   47.99   
  47.100   			/*
  47.101 -@@ -276,3 +323,23 @@ ia64_send_ipi (int cpu, int vector, int 
  47.102 - 
  47.103 - 	writeq(ipi_data, ipi_addr);
  47.104 - }
  47.105 -+
  47.106 -+/* From linux/kernel/softirq.c */
  47.107 -+#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED
  47.108 -+# define invoke_softirq()	__do_softirq()
  47.109 -+#else
  47.110 -+# define invoke_softirq()	do_softirq()
  47.111 -+#endif
  47.112 -+
  47.113 -+/*
  47.114 -+ * Exit an interrupt context. Process softirqs if needed and possible:
  47.115 -+ */
  47.116 -+void irq_exit(void)
  47.117 -+{
  47.118 -+	account_system_vtime(current);
  47.119 -+	sub_preempt_count(IRQ_EXIT_OFFSET);
  47.120 -+	if (!in_interrupt() && local_softirq_pending())
  47.121 -+		invoke_softirq();
  47.122 -+	preempt_enable_no_resched();
  47.123 -+}
  47.124 -+/* end from linux/kernel/softirq.c */
    48.1 --- a/xen/arch/ia64/patch/linux-2.6.11/ivt.S	Fri Apr 29 16:49:15 2005 +0000
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,533 +0,0 @@
    48.4 - ivt.S |  254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    48.5 - 1 files changed, 254 insertions(+)
    48.6 -
    48.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/ivt.S
    48.8 -===================================================================
    48.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/ivt.S	2005-04-07 10:29:00.565766924 -0500
   48.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/ivt.S	2005-04-07 10:29:50.923594750 -0500
   48.11 -@@ -1,3 +1,21 @@
   48.12 -+
   48.13 -+#ifdef XEN
   48.14 -+//#define CONFIG_DISABLE_VHPT	// FIXME: change when VHPT is enabled??
   48.15 -+// these are all hacked out for now as the entire IVT
   48.16 -+// will eventually be replaced... just want to use it
   48.17 -+// for startup code to handle TLB misses
   48.18 -+//#define ia64_leave_kernel 0
   48.19 -+//#define ia64_ret_from_syscall 0
   48.20 -+//#define ia64_handle_irq 0
   48.21 -+//#define ia64_fault 0
   48.22 -+#define ia64_illegal_op_fault 0
   48.23 -+#define ia64_prepare_handle_unaligned 0
   48.24 -+#define ia64_bad_break 0
   48.25 -+#define ia64_trace_syscall 0
   48.26 -+#define sys_call_table 0
   48.27 -+#define sys_ni_syscall 0
   48.28 -+#include <asm/vhpt.h>
   48.29 -+#endif
   48.30 - /*
   48.31 -  * arch/ia64/kernel/ivt.S
   48.32 -  *
   48.33 -@@ -77,6 +95,13 @@
   48.34 - 	mov r19=n;;			/* prepare to save predicates */		\
   48.35 - 	br.sptk.many dispatch_to_fault_handler
   48.36 - 
   48.37 -+#ifdef XEN
   48.38 -+#define REFLECT(n)									\
   48.39 -+	mov r31=pr;									\
   48.40 -+	mov r19=n;;			/* prepare to save predicates */		\
   48.41 -+	br.sptk.many dispatch_reflection
   48.42 -+#endif
   48.43 -+
   48.44 - 	.section .text.ivt,"ax"
   48.45 - 
   48.46 - 	.align 32768	// align on 32KB boundary
   48.47 -@@ -214,6 +239,13 @@ END(vhpt_miss)
   48.48 - // 0x0400 Entry 1 (size 64 bundles) ITLB (21)
   48.49 - ENTRY(itlb_miss)
   48.50 - 	DBG_FAULT(1)
   48.51 -+#ifdef XEN
   48.52 -+	VHPT_CCHAIN_LOOKUP(itlb_miss,i)
   48.53 -+#ifdef VHPT_GLOBAL
   48.54 -+	br.cond.sptk page_fault
   48.55 -+	;;
   48.56 -+#endif
   48.57 -+#endif
   48.58 - 	/*
   48.59 - 	 * The ITLB handler accesses the L3 PTE via the virtually mapped linear
   48.60 - 	 * page table.  If a nested TLB miss occurs, we switch into physical
   48.61 -@@ -258,6 +290,13 @@ END(itlb_miss)
   48.62 - // 0x0800 Entry 2 (size 64 bundles) DTLB (9,48)
   48.63 - ENTRY(dtlb_miss)
   48.64 - 	DBG_FAULT(2)
   48.65 -+#ifdef XEN
   48.66 -+	VHPT_CCHAIN_LOOKUP(dtlb_miss,d)
   48.67 -+#ifdef VHPT_GLOBAL
   48.68 -+	br.cond.sptk page_fault
   48.69 -+	;;
   48.70 -+#endif
   48.71 -+#endif
   48.72 - 	/*
   48.73 - 	 * The DTLB handler accesses the L3 PTE via the virtually mapped linear
   48.74 - 	 * page table.  If a nested TLB miss occurs, we switch into physical
   48.75 -@@ -302,6 +341,13 @@ END(dtlb_miss)
   48.76 - // 0x0c00 Entry 3 (size 64 bundles) Alt ITLB (19)
   48.77 - ENTRY(alt_itlb_miss)
   48.78 - 	DBG_FAULT(3)
   48.79 -+#ifdef XEN
   48.80 -+//#ifdef VHPT_GLOBAL
   48.81 -+//	VHPT_CCHAIN_LOOKUP(alt_itlb_miss,i)
   48.82 -+//	br.cond.sptk page_fault
   48.83 -+//	;;
   48.84 -+//#endif
   48.85 -+#endif
   48.86 - 	mov r16=cr.ifa		// get address that caused the TLB miss
   48.87 - 	movl r17=PAGE_KERNEL
   48.88 - 	mov r21=cr.ipsr
   48.89 -@@ -340,6 +386,13 @@ END(alt_itlb_miss)
   48.90 - // 0x1000 Entry 4 (size 64 bundles) Alt DTLB (7,46)
   48.91 - ENTRY(alt_dtlb_miss)
   48.92 - 	DBG_FAULT(4)
   48.93 -+#ifdef XEN
   48.94 -+//#ifdef VHPT_GLOBAL
   48.95 -+//	VHPT_CCHAIN_LOOKUP(alt_dtlb_miss,d)
   48.96 -+//	br.cond.sptk page_fault
   48.97 -+//	;;
   48.98 -+//#endif
   48.99 -+#endif
  48.100 - 	mov r16=cr.ifa		// get address that caused the TLB miss
  48.101 - 	movl r17=PAGE_KERNEL
  48.102 - 	mov r20=cr.isr
  48.103 -@@ -369,6 +422,17 @@ ENTRY(alt_dtlb_miss)
  48.104 - 	cmp.ne p8,p0=r0,r23
  48.105 - (p9)	cmp.eq.or.andcm p6,p7=IA64_ISR_CODE_LFETCH,r22	// check isr.code field
  48.106 - (p8)	br.cond.spnt page_fault
  48.107 -+#ifdef XEN
  48.108 -+	;;
  48.109 -+	// FIXME: inadequate test, this is where we test for Xen address
  48.110 -+	// note that 0xf000 (cached) and 0xd000 (uncached) addresses
  48.111 -+	// should be OK.  (Though no I/O is done in Xen, EFI needs uncached
  48.112 -+	// addresses and some domain EFI calls are passed through)
  48.113 -+	tbit.nz p0,p8=r16,60
  48.114 -+(p8)	br.cond.spnt page_fault
  48.115 -+//(p8)	br.cond.spnt 0
  48.116 -+	;;
  48.117 -+#endif
  48.118 - 
  48.119 - 	dep r21=-1,r21,IA64_PSR_ED_BIT,1
  48.120 - 	or r19=r19,r17		// insert PTE control bits into r19
  48.121 -@@ -449,6 +513,9 @@ END(nested_dtlb_miss)
  48.122 - /////////////////////////////////////////////////////////////////////////////////////////
  48.123 - // 0x1800 Entry 6 (size 64 bundles) Instruction Key Miss (24)
  48.124 - ENTRY(ikey_miss)
  48.125 -+#ifdef XEN
  48.126 -+	REFLECT(6)
  48.127 -+#endif
  48.128 - 	DBG_FAULT(6)
  48.129 - 	FAULT(6)
  48.130 - END(ikey_miss)
  48.131 -@@ -461,9 +528,16 @@ ENTRY(page_fault)
  48.132 - 	srlz.i
  48.133 - 	;;
  48.134 - 	SAVE_MIN_WITH_COVER
  48.135 -+#ifdef XEN
  48.136 -+	alloc r15=ar.pfs,0,0,4,0
  48.137 -+	mov out0=cr.ifa
  48.138 -+	mov out1=cr.isr
  48.139 -+	mov out3=cr.itir
  48.140 -+#else
  48.141 - 	alloc r15=ar.pfs,0,0,3,0
  48.142 - 	mov out0=cr.ifa
  48.143 - 	mov out1=cr.isr
  48.144 -+#endif
  48.145 - 	adds r3=8,r2				// set up second base pointer
  48.146 - 	;;
  48.147 - 	ssm psr.ic | PSR_DEFAULT_BITS
  48.148 -@@ -484,6 +558,9 @@ END(page_fault)
  48.149 - /////////////////////////////////////////////////////////////////////////////////////////
  48.150 - // 0x1c00 Entry 7 (size 64 bundles) Data Key Miss (12,51)
  48.151 - ENTRY(dkey_miss)
  48.152 -+#ifdef XEN
  48.153 -+	REFLECT(7)
  48.154 -+#endif
  48.155 - 	DBG_FAULT(7)
  48.156 - 	FAULT(7)
  48.157 - END(dkey_miss)
  48.158 -@@ -492,6 +569,9 @@ END(dkey_miss)
  48.159 - /////////////////////////////////////////////////////////////////////////////////////////
  48.160 - // 0x2000 Entry 8 (size 64 bundles) Dirty-bit (54)
  48.161 - ENTRY(dirty_bit)
  48.162 -+#ifdef XEN
  48.163 -+	REFLECT(8)
  48.164 -+#endif
  48.165 - 	DBG_FAULT(8)
  48.166 - 	/*
  48.167 - 	 * What we do here is to simply turn on the dirty bit in the PTE.  We need to
  48.168 -@@ -554,6 +634,9 @@ END(dirty_bit)
  48.169 - /////////////////////////////////////////////////////////////////////////////////////////
  48.170 - // 0x2400 Entry 9 (size 64 bundles) Instruction Access-bit (27)
  48.171 - ENTRY(iaccess_bit)
  48.172 -+#ifdef XEN
  48.173 -+	REFLECT(9)
  48.174 -+#endif
  48.175 - 	DBG_FAULT(9)
  48.176 - 	// Like Entry 8, except for instruction access
  48.177 - 	mov r16=cr.ifa				// get the address that caused the fault
  48.178 -@@ -619,6 +702,9 @@ END(iaccess_bit)
  48.179 - /////////////////////////////////////////////////////////////////////////////////////////
  48.180 - // 0x2800 Entry 10 (size 64 bundles) Data Access-bit (15,55)
  48.181 - ENTRY(daccess_bit)
  48.182 -+#ifdef XEN
  48.183 -+	REFLECT(10)
  48.184 -+#endif
  48.185 - 	DBG_FAULT(10)
  48.186 - 	// Like Entry 8, except for data access
  48.187 - 	mov r16=cr.ifa				// get the address that caused the fault
  48.188 -@@ -687,6 +773,16 @@ ENTRY(break_fault)
  48.189 - 	 * to prevent leaking bits from kernel to user level.
  48.190 - 	 */
  48.191 - 	DBG_FAULT(11)
  48.192 -+#ifdef XEN
  48.193 -+	mov r16=cr.isr
  48.194 -+	mov r17=cr.iim
  48.195 -+	mov r31=pr
  48.196 -+	;;
  48.197 -+	cmp.eq p7,p0=r0,r17			// is this a psuedo-cover?
  48.198 -+	// FIXME: may also need to check slot==2?
  48.199 -+(p7)	br.sptk.many dispatch_privop_fault
  48.200 -+	br.sptk.many dispatch_break_fault
  48.201 -+#endif
  48.202 - 	mov r16=IA64_KR(CURRENT)		// r16 = current task; 12 cycle read lat.
  48.203 - 	mov r17=cr.iim
  48.204 - 	mov r18=__IA64_BREAK_SYSCALL
  48.205 -@@ -697,7 +793,9 @@ ENTRY(break_fault)
  48.206 - 	mov r27=ar.rsc
  48.207 - 	mov r26=ar.pfs
  48.208 - 	mov r28=cr.iip
  48.209 -+#ifndef XEN
  48.210 - 	mov r31=pr				// prepare to save predicates
  48.211 -+#endif
  48.212 - 	mov r20=r1
  48.213 - 	;;
  48.214 - 	adds r16=IA64_TASK_THREAD_ON_USTACK_OFFSET,r16
  48.215 -@@ -797,6 +895,36 @@ END(interrupt)
  48.216 - 	DBG_FAULT(13)
  48.217 - 	FAULT(13)
  48.218 - 
  48.219 -+#ifdef XEN
  48.220 -+	// There is no particular reason for this code to be here, other than that
  48.221 -+	// there happens to be space here that would go unused otherwise.  If this
  48.222 -+	// fault ever gets "unreserved", simply moved the following code to a more
  48.223 -+	// suitable spot...
  48.224 -+
  48.225 -+ENTRY(dispatch_break_fault)
  48.226 -+	SAVE_MIN_WITH_COVER
  48.227 -+	;;
  48.228 -+	alloc r14=ar.pfs,0,0,4,0 // now it's safe (must be first in insn group!)
  48.229 -+	mov out0=cr.ifa
  48.230 -+	adds out1=16,sp
  48.231 -+	mov out2=cr.isr		// FIXME: pity to make this slow access twice
  48.232 -+	mov out3=cr.iim		// FIXME: pity to make this slow access twice
  48.233 -+
  48.234 -+	ssm psr.ic | PSR_DEFAULT_BITS
  48.235 -+	;;
  48.236 -+	srlz.i					// guarantee that interruption collection is on
  48.237 -+	;;
  48.238 -+(p15)	ssm psr.i				// restore psr.i
  48.239 -+	adds r3=8,r2				// set up second base pointer
  48.240 -+	;;
  48.241 -+	SAVE_REST
  48.242 -+	movl r14=ia64_leave_kernel
  48.243 -+	;;
  48.244 -+	mov rp=r14
  48.245 -+	br.sptk.many ia64_prepare_handle_break
  48.246 -+END(dispatch_break_fault)
  48.247 -+#endif
  48.248 -+
  48.249 - 	.org ia64_ivt+0x3800
  48.250 - /////////////////////////////////////////////////////////////////////////////////////////
  48.251 - // 0x3800 Entry 14 (size 64 bundles) Reserved
  48.252 -@@ -850,9 +978,11 @@ END(interrupt)
  48.253 - 	 *	- ar.fpsr: set to kernel settings
  48.254 - 	 */
  48.255 - GLOBAL_ENTRY(ia64_syscall_setup)
  48.256 -+#ifndef XEN
  48.257 - #if PT(B6) != 0
  48.258 - # error This code assumes that b6 is the first field in pt_regs.
  48.259 - #endif
  48.260 -+#endif
  48.261 - 	st8 [r1]=r19				// save b6
  48.262 - 	add r16=PT(CR_IPSR),r1			// initialize first base pointer
  48.263 - 	add r17=PT(R11),r1			// initialize second base pointer
  48.264 -@@ -992,6 +1122,37 @@ END(dispatch_illegal_op_fault)
  48.265 - 	DBG_FAULT(16)
  48.266 - 	FAULT(16)
  48.267 - 
  48.268 -+#ifdef XEN
  48.269 -+	// There is no particular reason for this code to be here, other than that
  48.270 -+	// there happens to be space here that would go unused otherwise.  If this
  48.271 -+	// fault ever gets "unreserved", simply moved the following code to a more
  48.272 -+	// suitable spot...
  48.273 -+
  48.274 -+ENTRY(dispatch_privop_fault)
  48.275 -+	SAVE_MIN_WITH_COVER
  48.276 -+	;;
  48.277 -+	alloc r14=ar.pfs,0,0,4,0		// now it's safe (must be first in insn group!)
  48.278 -+	mov out0=cr.ifa
  48.279 -+	adds out1=16,sp
  48.280 -+	mov out2=cr.isr		// FIXME: pity to make this slow access twice
  48.281 -+	mov out3=cr.itir
  48.282 -+
  48.283 -+	ssm psr.ic | PSR_DEFAULT_BITS
  48.284 -+	;;
  48.285 -+	srlz.i					// guarantee that interruption collection is on
  48.286 -+	;;
  48.287 -+(p15)	ssm psr.i				// restore psr.i
  48.288 -+	adds r3=8,r2				// set up second base pointer
  48.289 -+	;;
  48.290 -+	SAVE_REST
  48.291 -+	movl r14=ia64_leave_kernel
  48.292 -+	;;
  48.293 -+	mov rp=r14
  48.294 -+	br.sptk.many ia64_prepare_handle_privop
  48.295 -+END(dispatch_privop_fault)
  48.296 -+#endif
  48.297 -+
  48.298 -+
  48.299 - 	.org ia64_ivt+0x4400
  48.300 - /////////////////////////////////////////////////////////////////////////////////////////
  48.301 - // 0x4400 Entry 17 (size 64 bundles) Reserved
  48.302 -@@ -1108,6 +1269,9 @@ END(dispatch_to_fault_handler)
  48.303 - /////////////////////////////////////////////////////////////////////////////////////////
  48.304 - // 0x5000 Entry 20 (size 16 bundles) Page Not Present (10,22,49)
  48.305 - ENTRY(page_not_present)
  48.306 -+#ifdef XEN
  48.307 -+	REFLECT(20)
  48.308 -+#endif
  48.309 - 	DBG_FAULT(20)
  48.310 - 	mov r16=cr.ifa
  48.311 - 	rsm psr.dt
  48.312 -@@ -1128,6 +1292,9 @@ END(page_not_present)
  48.313 - /////////////////////////////////////////////////////////////////////////////////////////
  48.314 - // 0x5100 Entry 21 (size 16 bundles) Key Permission (13,25,52)
  48.315 - ENTRY(key_permission)
  48.316 -+#ifdef XEN
  48.317 -+	REFLECT(21)
  48.318 -+#endif
  48.319 - 	DBG_FAULT(21)
  48.320 - 	mov r16=cr.ifa
  48.321 - 	rsm psr.dt
  48.322 -@@ -1141,6 +1308,9 @@ END(key_permission)
  48.323 - /////////////////////////////////////////////////////////////////////////////////////////
  48.324 - // 0x5200 Entry 22 (size 16 bundles) Instruction Access Rights (26)
  48.325 - ENTRY(iaccess_rights)
  48.326 -+#ifdef XEN
  48.327 -+	REFLECT(22)
  48.328 -+#endif
  48.329 - 	DBG_FAULT(22)
  48.330 - 	mov r16=cr.ifa
  48.331 - 	rsm psr.dt
  48.332 -@@ -1154,6 +1324,9 @@ END(iaccess_rights)
  48.333 - /////////////////////////////////////////////////////////////////////////////////////////
  48.334 - // 0x5300 Entry 23 (size 16 bundles) Data Access Rights (14,53)
  48.335 - ENTRY(daccess_rights)
  48.336 -+#ifdef XEN
  48.337 -+	REFLECT(23)
  48.338 -+#endif
  48.339 - 	DBG_FAULT(23)
  48.340 - 	mov r16=cr.ifa
  48.341 - 	rsm psr.dt
  48.342 -@@ -1171,8 +1344,13 @@ ENTRY(general_exception)
  48.343 - 	mov r16=cr.isr
  48.344 - 	mov r31=pr
  48.345 - 	;;
  48.346 -+#ifdef XEN
  48.347 -+	cmp4.ge p6,p0=0x20,r16
  48.348 -+(p6)	br.sptk.many dispatch_privop_fault
  48.349 -+#else
  48.350 - 	cmp4.eq p6,p0=0,r16
  48.351 - (p6)	br.sptk.many dispatch_illegal_op_fault
  48.352 -+#endif
  48.353 - 	;;
  48.354 - 	mov r19=24		// fault number
  48.355 - 	br.sptk.many dispatch_to_fault_handler
  48.356 -@@ -1182,6 +1360,9 @@ END(general_exception)
  48.357 - /////////////////////////////////////////////////////////////////////////////////////////
  48.358 - // 0x5500 Entry 25 (size 16 bundles) Disabled FP-Register (35)
  48.359 - ENTRY(disabled_fp_reg)
  48.360 -+#ifdef XEN
  48.361 -+	REFLECT(25)
  48.362 -+#endif
  48.363 - 	DBG_FAULT(25)
  48.364 - 	rsm psr.dfh		// ensure we can access fph
  48.365 - 	;;
  48.366 -@@ -1195,6 +1376,9 @@ END(disabled_fp_reg)
  48.367 - /////////////////////////////////////////////////////////////////////////////////////////
  48.368 - // 0x5600 Entry 26 (size 16 bundles) Nat Consumption (11,23,37,50)
  48.369 - ENTRY(nat_consumption)
  48.370 -+#ifdef XEN
  48.371 -+	REFLECT(26)
  48.372 -+#endif
  48.373 - 	DBG_FAULT(26)
  48.374 - 	FAULT(26)
  48.375 - END(nat_consumption)
  48.376 -@@ -1203,6 +1387,10 @@ END(nat_consumption)
  48.377 - /////////////////////////////////////////////////////////////////////////////////////////
  48.378 - // 0x5700 Entry 27 (size 16 bundles) Speculation (40)
  48.379 - ENTRY(speculation_vector)
  48.380 -+#ifdef XEN
  48.381 -+	// this probably need not reflect...
  48.382 -+	REFLECT(27)
  48.383 -+#endif
  48.384 - 	DBG_FAULT(27)
  48.385 - 	/*
  48.386 - 	 * A [f]chk.[as] instruction needs to take the branch to the recovery code but
  48.387 -@@ -1246,6 +1434,9 @@ END(speculation_vector)
  48.388 - /////////////////////////////////////////////////////////////////////////////////////////
  48.389 - // 0x5900 Entry 29 (size 16 bundles) Debug (16,28,56)
  48.390 - ENTRY(debug_vector)
  48.391 -+#ifdef XEN
  48.392 -+	REFLECT(29)
  48.393 -+#endif
  48.394 - 	DBG_FAULT(29)
  48.395 - 	FAULT(29)
  48.396 - END(debug_vector)
  48.397 -@@ -1254,6 +1445,9 @@ END(debug_vector)
  48.398 - /////////////////////////////////////////////////////////////////////////////////////////
  48.399 - // 0x5a00 Entry 30 (size 16 bundles) Unaligned Reference (57)
  48.400 - ENTRY(unaligned_access)
  48.401 -+#ifdef XEN
  48.402 -+	REFLECT(30)
  48.403 -+#endif
  48.404 - 	DBG_FAULT(30)
  48.405 - 	mov r16=cr.ipsr
  48.406 - 	mov r31=pr		// prepare to save predicates
  48.407 -@@ -1265,6 +1459,9 @@ END(unaligned_access)
  48.408 - /////////////////////////////////////////////////////////////////////////////////////////
  48.409 - // 0x5b00 Entry 31 (size 16 bundles) Unsupported Data Reference (57)
  48.410 - ENTRY(unsupported_data_reference)
  48.411 -+#ifdef XEN
  48.412 -+	REFLECT(31)
  48.413 -+#endif
  48.414 - 	DBG_FAULT(31)
  48.415 - 	FAULT(31)
  48.416 - END(unsupported_data_reference)
  48.417 -@@ -1273,6 +1470,9 @@ END(unsupported_data_reference)
  48.418 - /////////////////////////////////////////////////////////////////////////////////////////
  48.419 - // 0x5c00 Entry 32 (size 16 bundles) Floating-Point Fault (64)
  48.420 - ENTRY(floating_point_fault)
  48.421 -+#ifdef XEN
  48.422 -+	REFLECT(32)
  48.423 -+#endif
  48.424 - 	DBG_FAULT(32)
  48.425 - 	FAULT(32)
  48.426 - END(floating_point_fault)
  48.427 -@@ -1281,6 +1481,9 @@ END(floating_point_fault)
  48.428 - /////////////////////////////////////////////////////////////////////////////////////////
  48.429 - // 0x5d00 Entry 33 (size 16 bundles) Floating Point Trap (66)
  48.430 - ENTRY(floating_point_trap)
  48.431 -+#ifdef XEN
  48.432 -+	REFLECT(33)
  48.433 -+#endif
  48.434 - 	DBG_FAULT(33)
  48.435 - 	FAULT(33)
  48.436 - END(floating_point_trap)
  48.437 -@@ -1289,6 +1492,9 @@ END(floating_point_trap)
  48.438 - /////////////////////////////////////////////////////////////////////////////////////////
  48.439 - // 0x5e00 Entry 34 (size 16 bundles) Lower Privilege Transfer Trap (66)
  48.440 - ENTRY(lower_privilege_trap)
  48.441 -+#ifdef XEN
  48.442 -+	REFLECT(34)
  48.443 -+#endif
  48.444 - 	DBG_FAULT(34)
  48.445 - 	FAULT(34)
  48.446 - END(lower_privilege_trap)
  48.447 -@@ -1297,6 +1503,9 @@ END(lower_privilege_trap)
  48.448 - /////////////////////////////////////////////////////////////////////////////////////////
  48.449 - // 0x5f00 Entry 35 (size 16 bundles) Taken Branch Trap (68)
  48.450 - ENTRY(taken_branch_trap)
  48.451 -+#ifdef XEN
  48.452 -+	REFLECT(35)
  48.453 -+#endif
  48.454 - 	DBG_FAULT(35)
  48.455 - 	FAULT(35)
  48.456 - END(taken_branch_trap)
  48.457 -@@ -1305,6 +1514,9 @@ END(taken_branch_trap)
  48.458 - /////////////////////////////////////////////////////////////////////////////////////////
  48.459 - // 0x6000 Entry 36 (size 16 bundles) Single Step Trap (69)
  48.460 - ENTRY(single_step_trap)
  48.461 -+#ifdef XEN
  48.462 -+	REFLECT(36)
  48.463 -+#endif
  48.464 - 	DBG_FAULT(36)
  48.465 - 	FAULT(36)
  48.466 - END(single_step_trap)
  48.467 -@@ -1361,6 +1573,9 @@ END(single_step_trap)
  48.468 - /////////////////////////////////////////////////////////////////////////////////////////
  48.469 - // 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)
  48.470 - ENTRY(ia32_exception)
  48.471 -+#ifdef XEN
  48.472 -+	REFLECT(45)
  48.473 -+#endif
  48.474 - 	DBG_FAULT(45)
  48.475 - 	FAULT(45)
  48.476 - END(ia32_exception)
  48.477 -@@ -1369,6 +1584,9 @@ END(ia32_exception)
  48.478 - /////////////////////////////////////////////////////////////////////////////////////////
  48.479 - // 0x6a00 Entry 46 (size 16 bundles) IA-32 Intercept  (30,31,59,70,71)
  48.480 - ENTRY(ia32_intercept)
  48.481 -+#ifdef XEN
  48.482 -+	REFLECT(46)
  48.483 -+#endif
  48.484 - 	DBG_FAULT(46)
  48.485 - #ifdef	CONFIG_IA32_SUPPORT
  48.486 - 	mov r31=pr
  48.487 -@@ -1399,6 +1617,9 @@ END(ia32_intercept)
  48.488 - /////////////////////////////////////////////////////////////////////////////////////////
  48.489 - // 0x6b00 Entry 47 (size 16 bundles) IA-32 Interrupt  (74)
  48.490 - ENTRY(ia32_interrupt)
  48.491 -+#ifdef XEN
  48.492 -+	REFLECT(47)
  48.493 -+#endif
  48.494 - 	DBG_FAULT(47)
  48.495 - #ifdef CONFIG_IA32_SUPPORT
  48.496 - 	mov r31=pr
  48.497 -@@ -1528,6 +1749,39 @@ END(ia32_interrupt)
  48.498 - 	DBG_FAULT(67)
  48.499 - 	FAULT(67)
  48.500 - 
  48.501 -+#ifdef XEN
  48.502 -+	.org ia64_ivt+0x8000
  48.503 -+ENTRY(dispatch_reflection)
  48.504 -+	/*
  48.505 -+	 * Input:
  48.506 -+	 *	psr.ic:	off
  48.507 -+	 *	r19:	intr type (offset into ivt, see ia64_int.h)
  48.508 -+	 *	r31:	contains saved predicates (pr)
  48.509 -+	 */
  48.510 -+	SAVE_MIN_WITH_COVER_R19
  48.511 -+	alloc r14=ar.pfs,0,0,5,0
  48.512 -+	mov out4=r15
  48.513 -+	mov out0=cr.ifa
  48.514 -+	adds out1=16,sp
  48.515 -+	mov out2=cr.isr
  48.516 -+	mov out3=cr.iim
  48.517 -+//	mov out3=cr.itir
  48.518 -+
  48.519 -+	ssm psr.ic | PSR_DEFAULT_BITS
  48.520 -+	;;
  48.521 -+	srlz.i					// guarantee that interruption collection is on
  48.522 -+	;;
  48.523 -+(p15)	ssm psr.i				// restore psr.i
  48.524 -+	adds r3=8,r2				// set up second base pointer
  48.525 -+	;;
  48.526 -+	SAVE_REST
  48.527 -+	movl r14=ia64_leave_kernel
  48.528 -+	;;
  48.529 -+	mov rp=r14
  48.530 -+	br.sptk.many ia64_prepare_handle_reflection
  48.531 -+END(dispatch_reflection)
  48.532 -+#endif
  48.533 -+
  48.534 - #ifdef CONFIG_IA32_SUPPORT
  48.535 - 
  48.536 - 	/*
    49.1 --- a/xen/arch/ia64/patch/linux-2.6.11/kernel-time.c	Fri Apr 29 16:49:15 2005 +0000
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,44 +0,0 @@
    49.4 - time.c |    7 ++++++-
    49.5 - 1 files changed, 6 insertions(+), 1 deletion(-)
    49.6 -
    49.7 -Index: linux-2.6.11/kernel/time.c
    49.8 -===================================================================
    49.9 ---- linux-2.6.11.orig/kernel/time.c	2005-03-02 01:37:50.000000000 -0600
   49.10 -+++ linux-2.6.11/kernel/time.c	2005-03-19 14:56:40.767870674 -0600
   49.11 -@@ -495,6 +495,7 @@ void getnstimeofday (struct timespec *tv
   49.12 - 	tv->tv_nsec = nsec;
   49.13 - }
   49.14 - 
   49.15 -+#ifndef XEN
   49.16 - int do_settimeofday (struct timespec *tv)
   49.17 - {
   49.18 - 	time_t wtm_sec, sec = tv->tv_sec;
   49.19 -@@ -503,7 +504,9 @@ int do_settimeofday (struct timespec *tv
   49.20 - 	if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
   49.21 - 		return -EINVAL;
   49.22 - 
   49.23 -+#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
   49.24 - 	write_seqlock_irq(&xtime_lock);
   49.25 -+#endif
   49.26 - 	{
   49.27 - 		/*
   49.28 - 		 * This is revolting. We need to set "xtime" correctly. However, the value
   49.29 -@@ -525,7 +528,9 @@ int do_settimeofday (struct timespec *tv
   49.30 - 		time_esterror = NTP_PHASE_LIMIT;
   49.31 - 		time_interpolator_reset();
   49.32 - 	}
   49.33 -+#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
   49.34 - 	write_sequnlock_irq(&xtime_lock);
   49.35 -+#endif
   49.36 - 	clock_was_set();
   49.37 - 	return 0;
   49.38 - }
   49.39 -@@ -552,7 +557,7 @@ void do_gettimeofday (struct timeval *tv
   49.40 - }
   49.41 - 
   49.42 - EXPORT_SYMBOL(do_gettimeofday);
   49.43 --
   49.44 -+#endif
   49.45 - 
   49.46 - #else
   49.47 - /*
    50.1 --- a/xen/arch/ia64/patch/linux-2.6.11/lds.S	Fri Apr 29 16:49:15 2005 +0000
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,22 +0,0 @@
    50.4 - vmlinux.lds.S |    2 ++
    50.5 - 1 files changed, 2 insertions(+)
    50.6 -
    50.7 -Index: linux-2.6.11/arch/ia64/kernel/vmlinux.lds.S
    50.8 -===================================================================
    50.9 ---- linux-2.6.11.orig/arch/ia64/kernel/vmlinux.lds.S	2005-03-02 01:38:25.000000000 -0600
   50.10 -+++ linux-2.6.11/arch/ia64/kernel/vmlinux.lds.S	2005-03-19 13:44:28.746368232 -0600
   50.11 -@@ -11,12 +11,14 @@
   50.12 - OUTPUT_FORMAT("elf64-ia64-little")
   50.13 - OUTPUT_ARCH(ia64)
   50.14 - ENTRY(phys_start)
   50.15 -+#ifndef XEN
   50.16 - jiffies = jiffies_64;
   50.17 - PHDRS {
   50.18 -   code   PT_LOAD;
   50.19 -   percpu PT_LOAD;
   50.20 -   data   PT_LOAD;
   50.21 - }
   50.22 -+#endif
   50.23 - SECTIONS
   50.24 - {
   50.25 -   /* Sections to be discarded */
    51.1 --- a/xen/arch/ia64/patch/linux-2.6.11/linuxextable.c	Fri Apr 29 16:49:15 2005 +0000
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,16 +0,0 @@
    51.4 - extable.c |    2 ++
    51.5 - 1 files changed, 2 insertions(+)
    51.6 -
    51.7 -Index: linux-2.6.11-xendiffs/kernel/extable.c
    51.8 -===================================================================
    51.9 ---- linux-2.6.11-xendiffs.orig/kernel/extable.c	2005-03-02 01:37:54.000000000 -0600
   51.10 -+++ linux-2.6.11-xendiffs/kernel/extable.c	2005-04-08 14:30:46.283360881 -0500
   51.11 -@@ -20,6 +20,8 @@
   51.12 - #include <asm/uaccess.h>
   51.13 - #include <asm/sections.h>
   51.14 - 
   51.15 -+#define __module_text_address(addr)	(NULL)
   51.16 -+
   51.17 - extern struct exception_table_entry __start___ex_table[];
   51.18 - extern struct exception_table_entry __stop___ex_table[];
   51.19 - 
    52.1 --- a/xen/arch/ia64/patch/linux-2.6.11/linuxhardirq.h	Fri Apr 29 16:49:15 2005 +0000
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,29 +0,0 @@
    52.4 - hardirq.h |    6 ++++++
    52.5 - 1 files changed, 6 insertions(+)
    52.6 -
    52.7 -Index: linux-2.6.11-xendiffs/include/linux/hardirq.h
    52.8 -===================================================================
    52.9 ---- linux-2.6.11-xendiffs.orig/include/linux/hardirq.h	2005-03-02 01:38:00.000000000 -0600
   52.10 -+++ linux-2.6.11-xendiffs/include/linux/hardirq.h	2005-03-25 08:49:57.301998663 -0600
   52.11 -@@ -2,7 +2,9 @@
   52.12 - #define LINUX_HARDIRQ_H
   52.13 - 
   52.14 - #include <linux/config.h>
   52.15 -+#ifndef XEN
   52.16 - #include <linux/smp_lock.h>
   52.17 -+#endif
   52.18 - #include <asm/hardirq.h>
   52.19 - #include <asm/system.h>
   52.20 - 
   52.21 -@@ -60,7 +62,11 @@
   52.22 -  */
   52.23 - #define in_irq()		(hardirq_count())
   52.24 - #define in_softirq()		(softirq_count())
   52.25 -+#ifndef XEN
   52.26 - #define in_interrupt()		(irq_count())
   52.27 -+#else
   52.28 -+#define in_interrupt()		0		// FIXME LATER
   52.29 -+#endif
   52.30 - 
   52.31 - #if defined(CONFIG_PREEMPT) && !defined(CONFIG_PREEMPT_BKL)
   52.32 - # define in_atomic()	((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
    53.1 --- a/xen/arch/ia64/patch/linux-2.6.11/linuxtime.h	Fri Apr 29 16:49:15 2005 +0000
    53.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.3 @@ -1,36 +0,0 @@
    53.4 - time.h |    9 +++++++++
    53.5 - 1 files changed, 9 insertions(+)
    53.6 -
    53.7 -Index: linux-2.6.11/include/linux/time.h
    53.8 -===================================================================
    53.9 ---- linux-2.6.11.orig/include/linux/time.h	2005-03-02 01:38:12.000000000 -0600
   53.10 -+++ linux-2.6.11/include/linux/time.h	2005-03-19 13:46:27.987225234 -0600
   53.11 -@@ -1,11 +1,18 @@
   53.12 - #ifndef _LINUX_TIME_H
   53.13 - #define _LINUX_TIME_H
   53.14 - 
   53.15 -+#ifdef XEN
   53.16 -+typedef	s64 time_t;
   53.17 -+typedef	s64 suseconds_t;
   53.18 -+#endif
   53.19 -+
   53.20 - #include <linux/types.h>
   53.21 - 
   53.22 -+#ifndef XEN
   53.23 - #ifdef __KERNEL__
   53.24 - #include <linux/seqlock.h>
   53.25 - #endif
   53.26 -+#endif
   53.27 - 
   53.28 - #ifndef _STRUCT_TIMESPEC
   53.29 - #define _STRUCT_TIMESPEC
   53.30 -@@ -80,7 +87,9 @@ mktime (unsigned int year, unsigned int 
   53.31 - 
   53.32 - extern struct timespec xtime;
   53.33 - extern struct timespec wall_to_monotonic;
   53.34 -+#ifndef XEN
   53.35 - extern seqlock_t xtime_lock;
   53.36 -+#endif
   53.37 - 
   53.38 - static inline unsigned long get_seconds(void)
   53.39 - { 
    54.1 --- a/xen/arch/ia64/patch/linux-2.6.11/mm_contig.c	Fri Apr 29 16:49:15 2005 +0000
    54.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/mm_contig.c	Tue May 03 08:08:47 2005 +0000
    54.3 @@ -1,220 +1,47 @@
    54.4 - contig.c |  172 +++++++++++++++++----------------------------------------------
    54.5 - 1 files changed, 48 insertions(+), 124 deletions(-)
    54.6 -
    54.7 -Index: linux-2.6.11-xendiffs/arch/ia64/mm/contig.c
    54.8 -===================================================================
    54.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/mm/contig.c	2005-04-07 11:02:50.227598140 -0500
   54.10 -+++ linux-2.6.11-xendiffs/arch/ia64/mm/contig.c	2005-04-07 11:05:21.724931959 -0500
   54.11 -@@ -15,11 +15,21 @@
   54.12 -  * memory.
   54.13 +--- ../../linux-2.6.11/arch/ia64/mm/contig.c	2005-03-02 00:37:55.000000000 -0700
   54.14 ++++ arch/ia64/mm_contig.c	2005-04-28 16:13:52.000000000 -0600
   54.15 +@@ -35,6 +35,7 @@
   54.16 +  *
   54.17 +  * Just walks the pages in the system and describes where they're allocated.
   54.18    */
   54.19 - #include <linux/config.h>
   54.20 -+#ifdef XEN
   54.21 -+#include <xen/sched.h>
   54.22 -+#endif
   54.23 - #include <linux/bootmem.h>
   54.24 - #include <linux/efi.h>
   54.25 - #include <linux/mm.h>
   54.26 - #include <linux/swap.h>
   54.27 - 
   54.28 -+#ifdef XEN
   54.29 -+#undef reserve_bootmem
   54.30 -+extern struct page *zero_page_memmap_ptr;
   54.31 -+struct page *mem_map;
   54.32 -+#define MAX_DMA_ADDRESS ~0UL	// FIXME???
   54.33 -+#endif
   54.34 -+
   54.35 - #include <asm/meminit.h>
   54.36 - #include <asm/pgalloc.h>
   54.37 - #include <asm/pgtable.h>
   54.38 -@@ -38,30 +48,7 @@ static unsigned long num_dma_physpages;
   54.39 ++#ifndef XEN
   54.40   void
   54.41   show_mem (void)
   54.42   {
   54.43 --	int i, total = 0, reserved = 0;
   54.44 --	int shared = 0, cached = 0;
   54.45 --
   54.46 --	printk("Mem-info:\n");
   54.47 --	show_free_areas();
   54.48 --
   54.49 --	printk("Free swap:       %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
   54.50 --	i = max_mapnr;
   54.51 --	while (i-- > 0) {
   54.52 --		if (!pfn_valid(i))
   54.53 --			continue;
   54.54 --		total++;
   54.55 --		if (PageReserved(mem_map+i))
   54.56 --			reserved++;
   54.57 --		else if (PageSwapCache(mem_map+i))
   54.58 --			cached++;
   54.59 --		else if (page_count(mem_map + i))
   54.60 --			shared += page_count(mem_map + i) - 1;
   54.61 --	}
   54.62 --	printk("%d pages of RAM\n", total);
   54.63 --	printk("%d reserved pages\n", reserved);
   54.64 --	printk("%d pages shared\n", shared);
   54.65 --	printk("%d pages swap cached\n", cached);
   54.66 --	printk("%ld pages in page table cache\n", pgtable_cache_size);
   54.67 -+	printk("Dummy show_mem\n");
   54.68 +@@ -63,6 +64,7 @@
   54.69 + 	printk("%d pages swap cached\n", cached);
   54.70 + 	printk("%ld pages in page table cache\n", pgtable_cache_size);
   54.71   }
   54.72 ++#endif
   54.73   
   54.74   /* physical address where the bootmem map is located */
   54.75 -@@ -81,6 +68,9 @@ find_max_pfn (unsigned long start, unsig
   54.76 + unsigned long bootmap_start;
   54.77 +@@ -140,6 +142,7 @@
   54.78 +  * Walk the EFI memory map and find usable memory for the system, taking
   54.79 +  * into account reserved areas.
   54.80 +  */
   54.81 ++#ifndef XEN
   54.82 + void
   54.83 + find_memory (void)
   54.84   {
   54.85 - 	unsigned long *max_pfnp = arg, pfn;
   54.86 - 
   54.87 -+#ifdef XEN
   54.88 -+//printf("find_max_pfn: start=%lx, end=%lx, *arg=%lx\n",start,end,*(unsigned long *)arg);
   54.89 -+#endif
   54.90 - 	pfn = (PAGE_ALIGN(end - 1) - PAGE_OFFSET) >> PAGE_SHIFT;
   54.91 - 	if (pfn > *max_pfnp)
   54.92 - 		*max_pfnp = pfn;
   54.93 -@@ -134,41 +124,6 @@ find_bootmap_location (unsigned long sta
   54.94 - 	return 0;
   54.95 - }
   54.96 +@@ -168,6 +171,7 @@
   54.97   
   54.98 --/**
   54.99 -- * find_memory - setup memory map
  54.100 -- *
  54.101 -- * Walk the EFI memory map and find usable memory for the system, taking
  54.102 -- * into account reserved areas.
  54.103 -- */
  54.104 --void
  54.105 --find_memory (void)
  54.106 --{
  54.107 --	unsigned long bootmap_size;
  54.108 --
  54.109 --	reserve_memory();
  54.110 --
  54.111 --	/* first find highest page frame number */
  54.112 --	max_pfn = 0;
  54.113 --	efi_memmap_walk(find_max_pfn, &max_pfn);
  54.114 --
  54.115 --	/* how many bytes to cover all the pages */
  54.116 --	bootmap_size = bootmem_bootmap_pages(max_pfn) << PAGE_SHIFT;
  54.117 --
  54.118 --	/* look for a location to hold the bootmap */
  54.119 --	bootmap_start = ~0UL;
  54.120 --	efi_memmap_walk(find_bootmap_location, &bootmap_size);
  54.121 --	if (bootmap_start == ~0UL)
  54.122 --		panic("Cannot find %ld bytes for bootmap\n", bootmap_size);
  54.123 --
  54.124 --	bootmap_size = init_bootmem(bootmap_start >> PAGE_SHIFT, max_pfn);
  54.125 --
  54.126 --	/* Free all available memory, then mark bootmem-map as being in use. */
  54.127 --	efi_memmap_walk(filter_rsvd_memory, free_bootmem);
  54.128 --	reserve_bootmem(bootmap_start, bootmap_size);
  54.129 --
  54.130 --	find_initrd();
  54.131 --}
  54.132 --
  54.133 + 	find_initrd();
  54.134 + }
  54.135 ++#endif
  54.136 + 
  54.137   #ifdef CONFIG_SMP
  54.138   /**
  54.139 -  * per_cpu_init - setup per-cpu variables
  54.140 -@@ -228,72 +183,41 @@ count_dma_pages (u64 start, u64 end, voi
  54.141 +@@ -225,6 +229,7 @@
  54.142 +  * Set up the page tables.
  54.143 +  */
  54.144 + 
  54.145 ++#ifndef XEN
  54.146   void
  54.147   paging_init (void)
  54.148   {
  54.149 --	unsigned long max_dma;
  54.150 --	unsigned long zones_size[MAX_NR_ZONES];
  54.151 --#ifdef CONFIG_VIRTUAL_MEM_MAP
  54.152 --	unsigned long zholes_size[MAX_NR_ZONES];
  54.153 --	unsigned long max_gap;
  54.154 --#endif
  54.155 --
  54.156 --	/* initialize mem_map[] */
  54.157 --
  54.158 --	memset(zones_size, 0, sizeof(zones_size));
  54.159 --
  54.160 --	num_physpages = 0;
  54.161 --	efi_memmap_walk(count_pages, &num_physpages);
  54.162 --
  54.163 --	max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
  54.164 --
  54.165 --#ifdef CONFIG_VIRTUAL_MEM_MAP
  54.166 --	memset(zholes_size, 0, sizeof(zholes_size));
  54.167 -+	struct pfn_info *pg;
  54.168 -+	/* Allocate and map the machine-to-phys table */
  54.169 -+	if ((pg = alloc_domheap_pages(NULL, 10)) == NULL)
  54.170 -+		panic("Not enough memory to bootstrap Xen.\n");
  54.171 -+	memset(page_to_virt(pg), 0x55, 16UL << 20);
  54.172 - 
  54.173 --	num_dma_physpages = 0;
  54.174 --	efi_memmap_walk(count_dma_pages, &num_dma_physpages);
  54.175 -+	/* Other mapping setup */
  54.176 - 
  54.177 --	if (max_low_pfn < max_dma) {
  54.178 --		zones_size[ZONE_DMA] = max_low_pfn;
  54.179 --		zholes_size[ZONE_DMA] = max_low_pfn - num_dma_physpages;
  54.180 --	} else {
  54.181 --		zones_size[ZONE_DMA] = max_dma;
  54.182 --		zholes_size[ZONE_DMA] = max_dma - num_dma_physpages;
  54.183 --		if (num_physpages > num_dma_physpages) {
  54.184 --			zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
  54.185 --			zholes_size[ZONE_NORMAL] =
  54.186 --				((max_low_pfn - max_dma) -
  54.187 --				 (num_physpages - num_dma_physpages));
  54.188 --		}
  54.189 --	}
  54.190 --
  54.191 --	max_gap = 0;
  54.192 --	efi_memmap_walk(find_largest_hole, (u64 *)&max_gap);
  54.193 --	if (max_gap < LARGE_GAP) {
  54.194 --		vmem_map = (struct page *) 0;
  54.195 --		free_area_init_node(0, &contig_page_data, zones_size, 0,
  54.196 --				    zholes_size);
  54.197 --	} else {
  54.198 --		unsigned long map_size;
  54.199 --
  54.200 --		/* allocate virtual_mem_map */
  54.201 --
  54.202 --		map_size = PAGE_ALIGN(max_low_pfn * sizeof(struct page));
  54.203 --		vmalloc_end -= map_size;
  54.204 --		vmem_map = (struct page *) vmalloc_end;
  54.205 --		efi_memmap_walk(create_mem_map_page_table, NULL);
  54.206 --
  54.207 --		mem_map = contig_page_data.node_mem_map = vmem_map;
  54.208 --		free_area_init_node(0, &contig_page_data, zones_size,
  54.209 --				    0, zholes_size);
  54.210 --
  54.211 --		printk("Virtual mem_map starts at 0x%p\n", mem_map);
  54.212 --	}
  54.213 --#else /* !CONFIG_VIRTUAL_MEM_MAP */
  54.214 --	if (max_low_pfn < max_dma)
  54.215 --		zones_size[ZONE_DMA] = max_low_pfn;
  54.216 --	else {
  54.217 --		zones_size[ZONE_DMA] = max_dma;
  54.218 --		zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
  54.219 --	}
  54.220 --	free_area_init(zones_size);
  54.221 --#endif /* !CONFIG_VIRTUAL_MEM_MAP */
  54.222 +@@ -297,3 +302,4 @@
  54.223 + #endif /* !CONFIG_VIRTUAL_MEM_MAP */
  54.224   	zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
  54.225   }
  54.226 -+
  54.227 -+struct pfn_info *frame_table;
  54.228 -+unsigned long frame_table_size;
  54.229 -+unsigned long max_page;
  54.230 -+
  54.231 -+/* FIXME: postpone support to machines with big holes between physical memorys.
  54.232 -+ * Current hack allows only efi memdesc upto 4G place. (See efi.c)
  54.233 -+ */
  54.234 -+#ifndef CONFIG_VIRTUAL_MEM_MAP
  54.235 -+#define FT_ALIGN_SIZE	(16UL << 20)
  54.236 -+void __init init_frametable(void)
  54.237 -+{
  54.238 -+	unsigned long i, p;
  54.239 -+	frame_table_size = max_page * sizeof(struct pfn_info);
  54.240 -+	frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
  54.241 -+
  54.242 -+	/* Request continuous trunk from boot allocator, since HV
  54.243 -+	 * address is identity mapped */
  54.244 -+	p = alloc_boot_pages(frame_table_size, FT_ALIGN_SIZE);
  54.245 -+	if (p == 0)
  54.246 -+		panic("Not enough memory for frame table.\n");
  54.247 -+
  54.248 -+	frame_table = __va(p);
  54.249 -+	memset(frame_table, 0, frame_table_size);
  54.250 -+	printk("size of frame_table: %lukB\n",
  54.251 -+		frame_table_size >> 10);
  54.252 -+}
  54.253 -+#endif
  54.254 ++#endif /* !CONFIG_XEN */
    55.1 --- a/xen/arch/ia64/patch/linux-2.6.11/mmzone.h	Fri Apr 29 16:49:15 2005 +0000
    55.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.3 @@ -1,19 +0,0 @@
    55.4 - mmzone.h |    4 ++++
    55.5 - 1 files changed, 4 insertions(+)
    55.6 -
    55.7 -Index: linux-2.6.11/include/linux/mmzone.h
    55.8 -===================================================================
    55.9 ---- linux-2.6.11.orig/include/linux/mmzone.h	2005-03-02 01:38:10.000000000 -0600
   55.10 -+++ linux-2.6.11/include/linux/mmzone.h	2005-03-19 13:49:30.427573139 -0600
   55.11 -@@ -209,7 +209,11 @@ struct zone {
   55.12 - 	 * rarely used fields:
   55.13 - 	 */
   55.14 - 	char			*name;
   55.15 -+#ifdef XEN
   55.16 -+};
   55.17 -+#else
   55.18 - } ____cacheline_maxaligned_in_smp;
   55.19 -+#endif
   55.20 - 
   55.21 - 
   55.22 - /*
    56.1 --- a/xen/arch/ia64/patch/linux-2.6.11/page.h	Fri Apr 29 16:49:15 2005 +0000
    56.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/page.h	Tue May 03 08:08:47 2005 +0000
    56.3 @@ -1,52 +1,34 @@
    56.4 - page.h |   42 +++++++++++++++++++++++++++++++++++++++---
    56.5 - 1 files changed, 39 insertions(+), 3 deletions(-)
    56.6 -
    56.7 -Index: linux-2.6.11-xendiffs/include/asm-ia64/page.h
    56.8 -===================================================================
    56.9 ---- linux-2.6.11-xendiffs.orig/include/asm-ia64/page.h	2005-04-06 22:58:07.597539393 -0500
   56.10 -+++ linux-2.6.11-xendiffs/include/asm-ia64/page.h	2005-04-06 23:06:15.908576975 -0500
   56.11 -@@ -12,6 +12,9 @@
   56.12 - #include <asm/intrinsics.h>
   56.13 - #include <asm/types.h>
   56.14 - 
   56.15 -+#ifndef __ASSEMBLY__
   56.16 -+#include <asm/flushtlb.h>
   56.17 -+#endif
   56.18 - /*
   56.19 -  * PAGE_SHIFT determines the actual kernel page size.
   56.20 -  */
   56.21 -@@ -95,9 +98,11 @@ extern int ia64_pfn_valid (unsigned long
   56.22 +--- ../../linux-2.6.11/include/asm-ia64/page.h	2005-03-02 00:37:48.000000000 -0700
   56.23 ++++ include/asm-ia64/page.h	2005-05-02 11:25:33.000000000 -0600
   56.24 +@@ -95,9 +95,15 @@
   56.25   #endif
   56.26   
   56.27   #ifndef CONFIG_DISCONTIGMEM
   56.28  +#ifdef XEN
   56.29 -+#define pfn_valid(pfn)		(0)
   56.30 ++# define pfn_valid(pfn)		(0)
   56.31 ++# define page_to_pfn(_page)	((unsigned long)((_page) - frame_table))
   56.32 ++# define pfn_to_page(_pfn)	(frame_table + (_pfn))
   56.33  +#else
   56.34   # define pfn_valid(pfn)		(((pfn) < max_mapnr) && ia64_pfn_valid(pfn))
   56.35 --# define page_to_pfn(page)	((unsigned long) (page - mem_map))
   56.36 --# define pfn_to_page(pfn)	(mem_map + (pfn))
   56.37 + # define page_to_pfn(page)	((unsigned long) (page - mem_map))
   56.38 + # define pfn_to_page(pfn)	(mem_map + (pfn))
   56.39  +#endif
   56.40   #else
   56.41   extern struct page *vmem_map;
   56.42   extern unsigned long max_low_pfn;
   56.43 -@@ -106,9 +111,15 @@ extern unsigned long max_low_pfn;
   56.44 - # define pfn_to_page(pfn)	(vmem_map + (pfn))
   56.45 - #endif
   56.46 - 
   56.47 --#define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
   56.48 -+#define page_to_pfn(_page)	((unsigned long)((_page) - frame_table))
   56.49 -+#define page_to_virt(_page)	phys_to_virt(page_to_phys(_page))
   56.50 -+
   56.51 -+#define page_to_phys(_page)	(page_to_pfn(_page) << PAGE_SHIFT)
   56.52 +@@ -109,6 +115,11 @@
   56.53 + #define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
   56.54   #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
   56.55   
   56.56 -+#define pfn_to_page(_pfn)	(frame_table + (_pfn))
   56.57 ++#ifdef XEN
   56.58 ++#define page_to_virt(_page)	phys_to_virt(page_to_phys(_page))
   56.59  +#define phys_to_page(kaddr)	pfn_to_page(((kaddr) >> PAGE_SHIFT))
   56.60 ++#endif
   56.61  +
   56.62   typedef union ia64_va {
   56.63   	struct {
   56.64   		unsigned long off : 61;		/* intra-region offset */
   56.65 -@@ -124,8 +135,25 @@ typedef union ia64_va {
   56.66 +@@ -124,8 +135,23 @@
   56.67    * expressed in this way to ensure they result in a single "dep"
   56.68    * instruction.
   56.69    */
   56.70 @@ -63,8 +45,6 @@ Index: linux-2.6.11-xendiffs/include/asm
   56.71  +// xen/drivers/console.c uses __va in a declaration (should be fixed!)
   56.72  +#define __pa(x)		({xen_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
   56.73  +#define __va(x)		({xen_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
   56.74 -+//# define __pa(x)	((unsigned long)(((unsigned long)x) - PAGE_OFFSET))
   56.75 -+//# define __va(x)	((void *)((char *)(x) + PAGE_OFFSET))
   56.76  +#else
   56.77   #define __pa(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;})
   56.78   #define __va(x)		({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;})
   56.79 @@ -72,7 +52,7 @@ Index: linux-2.6.11-xendiffs/include/asm
   56.80   
   56.81   #define REGION_NUMBER(x)	({ia64_va _v; _v.l = (long) (x); _v.f.reg;})
   56.82   #define REGION_OFFSET(x)	({ia64_va _v; _v.l = (long) (x); _v.f.off;})
   56.83 -@@ -197,11 +225,19 @@ get_order (unsigned long size)
   56.84 +@@ -197,7 +223,11 @@
   56.85   # define __pgprot(x)	(x)
   56.86   #endif /* !STRICT_MM_TYPECHECKS */
   56.87   
   56.88 @@ -84,11 +64,3 @@ Index: linux-2.6.11-xendiffs/include/asm
   56.89   
   56.90   #define VM_DATA_DEFAULT_FLAGS		(VM_READ | VM_WRITE |					\
   56.91   					 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC |		\
   56.92 - 					 (((current->personality & READ_IMPLIES_EXEC) != 0)	\
   56.93 - 					  ? VM_EXEC : 0))
   56.94 - 
   56.95 -+#ifdef XEN
   56.96 -+#define __flush_tlb() do {} while(0);
   56.97 -+#endif
   56.98 -+
   56.99 - #endif /* _ASM_IA64_PAGE_H */
    57.1 --- a/xen/arch/ia64/patch/linux-2.6.11/pgalloc.h	Fri Apr 29 16:49:15 2005 +0000
    57.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/pgalloc.h	Tue May 03 08:08:47 2005 +0000
    57.3 @@ -1,78 +1,72 @@
    57.4 - pgalloc.h |   17 +++++++++++------
    57.5 - 1 files changed, 11 insertions(+), 6 deletions(-)
    57.6 -
    57.7 -Index: linux-2.6.11-xendiffs/include/asm-ia64/pgalloc.h
    57.8 -===================================================================
    57.9 ---- linux-2.6.11-xendiffs.orig/include/asm-ia64/pgalloc.h	2005-04-08 11:57:30.909774800 -0500
   57.10 -+++ linux-2.6.11-xendiffs/include/asm-ia64/pgalloc.h	2005-04-08 11:58:08.102711219 -0500
   57.11 -@@ -18,6 +18,7 @@
   57.12 - #include <linux/compiler.h>
   57.13 - #include <linux/mm.h>
   57.14 - #include <linux/page-flags.h>
   57.15 -+#include <linux/preempt.h>
   57.16 - #include <linux/threads.h>
   57.17 - 
   57.18 - #include <asm/mmu_context.h>
   57.19 -@@ -34,6 +35,10 @@
   57.20 - #define pmd_quicklist		(local_cpu_data->pmd_quick)
   57.21 - #define pgtable_cache_size	(local_cpu_data->pgtable_cache_sz)
   57.22 - 
   57.23 -+/* FIXME: Later 3 level page table should be over, to create 
   57.24 -+ * new interface upon xen memory allocator. To simplify first
   57.25 -+ * effort moving to xen allocator, use xenheap pages temporarily. 
   57.26 -+ */
   57.27 - static inline pgd_t*
   57.28 - pgd_alloc_one_fast (struct mm_struct *mm)
   57.29 - {
   57.30 -@@ -61,7 +66,7 @@ pgd_alloc (struct mm_struct *mm)
   57.31 +--- ../../linux-2.6.11/include/asm-ia64/pgalloc.h	2005-03-02 00:37:31.000000000 -0700
   57.32 ++++ include/asm-ia64/pgalloc.h	2005-04-29 17:09:20.000000000 -0600
   57.33 +@@ -61,7 +61,11 @@
   57.34   	pgd_t *pgd = pgd_alloc_one_fast(mm);
   57.35   
   57.36   	if (unlikely(pgd == NULL)) {
   57.37 --		pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
   57.38 ++#ifdef XEN
   57.39  +		pgd = (pgd_t *)alloc_xenheap_page();
   57.40 ++#else
   57.41 + 		pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
   57.42 ++#endif
   57.43   	}
   57.44   	return pgd;
   57.45   }
   57.46 -@@ -104,7 +109,7 @@ pmd_alloc_one_fast (struct mm_struct *mm
   57.47 +@@ -104,7 +108,11 @@
   57.48   static inline pmd_t*
   57.49   pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
   57.50   {
   57.51 --	pmd_t *pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
   57.52 ++#ifdef XEN
   57.53  +	pmd_t *pmd = (pmd_t *)alloc_xenheap_page();
   57.54 ++#else
   57.55 + 	pmd_t *pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
   57.56 ++#endif
   57.57   
   57.58   	return pmd;
   57.59   }
   57.60 -@@ -136,7 +141,7 @@ pmd_populate_kernel (struct mm_struct *m
   57.61 +@@ -136,7 +144,11 @@
   57.62   static inline struct page *
   57.63   pte_alloc_one (struct mm_struct *mm, unsigned long addr)
   57.64   {
   57.65 --	struct page *pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
   57.66 ++#ifdef XEN
   57.67  +	struct page *pte = alloc_xenheap_page();
   57.68 ++#else
   57.69 + 	struct page *pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
   57.70 ++#endif
   57.71   
   57.72   	return pte;
   57.73   }
   57.74 -@@ -144,7 +149,7 @@ pte_alloc_one (struct mm_struct *mm, uns
   57.75 +@@ -144,7 +156,11 @@
   57.76   static inline pte_t *
   57.77   pte_alloc_one_kernel (struct mm_struct *mm, unsigned long addr)
   57.78   {
   57.79 --	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
   57.80 ++#ifdef XEN
   57.81  +	pte_t *pte = (pte_t *)alloc_xenheap_page();
   57.82 ++#else
   57.83 + 	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
   57.84 ++#endif
   57.85   
   57.86   	return pte;
   57.87   }
   57.88 -@@ -152,13 +157,13 @@ pte_alloc_one_kernel (struct mm_struct *
   57.89 +@@ -152,13 +168,21 @@
   57.90   static inline void
   57.91   pte_free (struct page *pte)
   57.92   {
   57.93 --	__free_page(pte);
   57.94 ++#ifdef XEN
   57.95  +	free_xenheap_page(pte);
   57.96 ++#else
   57.97 + 	__free_page(pte);
   57.98 ++#endif
   57.99   }
  57.100   
  57.101   static inline void
  57.102   pte_free_kernel (pte_t *pte)
  57.103   {
  57.104 --	free_page((unsigned long) pte);
  57.105 ++#ifdef XEN
  57.106  +	free_xenheap_page((unsigned long) pte);
  57.107 ++#else
  57.108 + 	free_page((unsigned long) pte);
  57.109 ++#endif
  57.110   }
  57.111   
  57.112   #define __pte_free_tlb(tlb, pte)	tlb_remove_page((tlb), (pte))
    58.1 --- a/xen/arch/ia64/patch/linux-2.6.11/sal.h	Fri Apr 29 16:49:15 2005 +0000
    58.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.3 @@ -1,39 +0,0 @@
    58.4 - sal.h |   17 +++++++++++++++++
    58.5 - 1 files changed, 17 insertions(+)
    58.6 -
    58.7 -Index: linux-2.6.11-xendiffs/include/asm-ia64/sal.h
    58.8 -===================================================================
    58.9 ---- linux-2.6.11-xendiffs.orig/include/asm-ia64/sal.h	2005-04-08 12:00:53.510988510 -0500
   58.10 -+++ linux-2.6.11-xendiffs/include/asm-ia64/sal.h	2005-04-08 12:02:17.778587216 -0500
   58.11 -@@ -36,6 +36,7 @@
   58.12 - #ifndef __ASSEMBLY__
   58.13 - 
   58.14 - #include <linux/bcd.h>
   58.15 -+#include <linux/preempt.h>
   58.16 - #include <linux/spinlock.h>
   58.17 - #include <linux/efi.h>
   58.18 - 
   58.19 -@@ -650,7 +651,23 @@ ia64_sal_freq_base (unsigned long which,
   58.20 - {
   58.21 - 	struct ia64_sal_retval isrv;
   58.22 - 
   58.23 -+//#ifdef XEN
   58.24 -+#if 0
   58.25 -+	unsigned long *x = (unsigned long *)ia64_sal;
   58.26 -+	unsigned long *inst = (unsigned long *)*x;
   58.27 -+	unsigned long __ia64_sc_flags;
   58.28 -+	struct ia64_fpreg __ia64_sc_fr[6];
   58.29 -+printf("ia64_sal_freq_base: about to save_scratch_fpregs\n");
   58.30 -+	ia64_save_scratch_fpregs(__ia64_sc_fr);
   58.31 -+	spin_lock_irqsave(&sal_lock, __ia64_sc_flags);
   58.32 -+printf("ia64_sal_freq_base: about to call, ia64_sal=%p, ia64_sal[0]=%p, ia64_sal[1]=%p\n",x,x[0],x[1]);
   58.33 -+printf("first inst=%p,%p\n",inst[0],inst[1]);
   58.34 -+	isrv = (*ia64_sal)(SAL_FREQ_BASE, which, 0, 0, 0, 0, 0, 0);
   58.35 -+	spin_unlock_irqrestore(&sal_lock, __ia64_sc_flags);
   58.36 -+	ia64_load_scratch_fpregs(__ia64_sc_fr);
   58.37 -+#else
   58.38 - 	SAL_CALL(isrv, SAL_FREQ_BASE, which, 0, 0, 0, 0, 0, 0);
   58.39 -+#endif
   58.40 - 	*ticks_per_second = isrv.v0;
   58.41 - 	*drift_info = isrv.v1;
   58.42 - 	return isrv.status;
    59.1 --- a/xen/arch/ia64/patch/linux-2.6.11/setup.c	Fri Apr 29 16:49:15 2005 +0000
    59.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/setup.c	Tue May 03 08:08:47 2005 +0000
    59.3 @@ -1,191 +1,96 @@
    59.4 - setup.c |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++-------------
    59.5 - 1 files changed, 58 insertions(+), 14 deletions(-)
    59.6 -
    59.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/setup.c
    59.8 -===================================================================
    59.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/setup.c	2005-04-07 17:44:13.294980153 -0500
   59.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/setup.c	2005-04-07 17:46:37.157717072 -0500
   59.11 -@@ -21,6 +21,9 @@
   59.12 - #include <linux/init.h>
   59.13 - 
   59.14 - #include <linux/acpi.h>
   59.15 -+#ifdef XEN
   59.16 -+#include <xen/sched.h>
   59.17 -+#endif
   59.18 - #include <linux/bootmem.h>
   59.19 - #include <linux/console.h>
   59.20 - #include <linux/delay.h>
   59.21 -@@ -30,13 +33,17 @@
   59.22 - #include <linux/seq_file.h>
   59.23 - #include <linux/string.h>
   59.24 - #include <linux/threads.h>
   59.25 -+#ifndef XEN
   59.26 - #include <linux/tty.h>
   59.27 - #include <linux/serial.h>
   59.28 - #include <linux/serial_core.h>
   59.29 -+#endif
   59.30 - #include <linux/efi.h>
   59.31 - #include <linux/initrd.h>
   59.32 +--- ../../linux-2.6.11/arch/ia64/kernel/setup.c	2005-03-02 00:37:49.000000000 -0700
   59.33 ++++ arch/ia64/setup.c	2005-05-02 10:04:03.000000000 -0600
   59.34 +@@ -127,7 +127,16 @@
   59.35 + 		range_end   = min(end, rsvd_region[i].start);
   59.36   
   59.37 -+#ifndef XEN
   59.38 - #include <asm/ia32.h>
   59.39 -+#endif
   59.40 - #include <asm/machvec.h>
   59.41 - #include <asm/mca.h>
   59.42 - #include <asm/meminit.h>
   59.43 -@@ -51,6 +58,12 @@
   59.44 - #include <asm/smp.h>
   59.45 - #include <asm/system.h>
   59.46 - #include <asm/unistd.h>
   59.47 + 		if (range_start < range_end)
   59.48  +#ifdef XEN
   59.49 -+#include <linux/mm.h>
   59.50 -+#include <asm/mmu_context.h>
   59.51 -+extern unsigned long loops_per_jiffy;		// from linux/init/main.c
   59.52 -+char saved_command_line[COMMAND_LINE_SIZE];	// from linux/init/main.c
   59.53 -+#endif
   59.54 - 
   59.55 - #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
   59.56 - # error "struct cpuinfo_ia64 too big!"
   59.57 -@@ -66,7 +79,9 @@ DEFINE_PER_CPU(unsigned long, local_per_
   59.58 - DEFINE_PER_CPU(unsigned long, ia64_phys_stacked_size_p8);
   59.59 - unsigned long ia64_cycles_per_usec;
   59.60 - struct ia64_boot_param *ia64_boot_param;
   59.61 -+#ifndef XEN
   59.62 - struct screen_info screen_info;
   59.63 -+#endif
   59.64 - 
   59.65 - unsigned long ia64_max_cacheline_size;
   59.66 - unsigned long ia64_iobase;	/* virtual address for I/O accesses */
   59.67 -@@ -95,7 +110,6 @@ EXPORT_SYMBOL(ia64_max_iommu_merge_mask)
   59.68 - struct rsvd_region rsvd_region[IA64_MAX_RSVD_REGIONS + 1];
   59.69 - int num_rsvd_regions;
   59.70 - 
   59.71 --
   59.72 - /*
   59.73 -  * Filter incoming memory segments based on the primitive map created from the boot
   59.74 -  * parameters. Segments contained in the map are removed from the memory ranges. A
   59.75 -@@ -125,9 +139,12 @@ filter_rsvd_memory (unsigned long start,
   59.76 - 	for (i = 0; i < num_rsvd_regions; ++i) {
   59.77 - 		range_start = max(start, prev_start);
   59.78 - 		range_end   = min(end, rsvd_region[i].start);
   59.79 --
   59.80 --		if (range_start < range_end)
   59.81 --			call_pernode_memory(__pa(range_start), range_end - range_start, func);
   59.82 ++		{
   59.83  +		/* init_boot_pages requires "ps, pe" */
   59.84 -+		if (range_start < range_end) {
   59.85  +			printk("Init boot pages: 0x%lx -> 0x%lx.\n",
   59.86  +				__pa(range_start), __pa(range_end));
   59.87  +			(*func)(__pa(range_start), __pa(range_end), 0);
   59.88  +		}
   59.89 ++#else
   59.90 + 			call_pernode_memory(__pa(range_start), range_end - range_start, func);
   59.91 ++#endif
   59.92   
   59.93   		/* nothing more available in this segment */
   59.94   		if (range_end == end) return 0;
   59.95 -@@ -184,17 +201,17 @@ reserve_memory (void)
   59.96 - 				+ strlen(__va(ia64_boot_param->command_line)) + 1);
   59.97 - 	n++;
   59.98 - 
   59.99 -+	/* Reserve xen image/bitmap/xen-heap */
  59.100 - 	rsvd_region[n].start = (unsigned long) ia64_imva((void *)KERNEL_START);
  59.101 --	rsvd_region[n].end   = (unsigned long) ia64_imva(_end);
  59.102 -+	rsvd_region[n].end   = rsvd_region[n].start + xenheap_size;
  59.103 +@@ -185,7 +194,12 @@
  59.104   	n++;
  59.105   
  59.106 --#ifdef CONFIG_BLK_DEV_INITRD
  59.107 -+	/* This is actually dom0 image */
  59.108 - 	if (ia64_boot_param->initrd_start) {
  59.109 - 		rsvd_region[n].start = (unsigned long)__va(ia64_boot_param->initrd_start);
  59.110 - 		rsvd_region[n].end   = rsvd_region[n].start + ia64_boot_param->initrd_size;
  59.111 - 		n++;
  59.112 - 	}
  59.113 --#endif
  59.114 + 	rsvd_region[n].start = (unsigned long) ia64_imva((void *)KERNEL_START);
  59.115 ++#ifdef XEN
  59.116 ++	/* Reserve xen image/bitmap/xen-heap */
  59.117 ++	rsvd_region[n].end   = rsvd_region[n].start + xenheap_size;
  59.118 ++#else
  59.119 + 	rsvd_region[n].end   = (unsigned long) ia64_imva(_end);
  59.120 ++#endif
  59.121 + 	n++;
  59.122   
  59.123 - 	/* end of memory marker */
  59.124 - 	rsvd_region[n].start = ~0UL;
  59.125 -@@ -204,6 +221,16 @@ reserve_memory (void)
  59.126 - 	num_rsvd_regions = n;
  59.127 - 
  59.128 - 	sort_regions(rsvd_region, num_rsvd_regions);
  59.129 -+
  59.130 -+	{
  59.131 -+		int i;
  59.132 -+		printk("Reserved regions: \n");
  59.133 -+		for (i = 0; i < num_rsvd_regions; i++)
  59.134 -+			printk("  [%d] -> [0x%lx, 0x%lx]\n",
  59.135 -+				i,
  59.136 -+				rsvd_region[i].start,
  59.137 -+				rsvd_region[i].end);
  59.138 -+	}
  59.139 + #ifdef CONFIG_BLK_DEV_INITRD
  59.140 +@@ -299,7 +313,11 @@
  59.141   }
  59.142   
  59.143 - /**
  59.144 -@@ -298,18 +325,17 @@ mark_bsp_online (void)
  59.145 - #endif
  59.146 - }
  59.147 - 
  59.148 + void __init
  59.149  +#ifdef XEN
  59.150 - void __init
  59.151 --setup_arch (char **cmdline_p)
  59.152  +early_setup_arch (char **cmdline_p)
  59.153 ++#else
  59.154 + setup_arch (char **cmdline_p)
  59.155 ++#endif
  59.156   {
  59.157   	unw_init();
  59.158   
  59.159 --	ia64_patch_vtop((u64) __start___vtop_patchlist, (u64) __end___vtop_patchlist);
  59.160 --
  59.161 +@@ -308,8 +326,14 @@
  59.162   	*cmdline_p = __va(ia64_boot_param->command_line);
  59.163   	strlcpy(saved_command_line, *cmdline_p, COMMAND_LINE_SIZE);
  59.164 + 
  59.165 ++#ifdef XEN
  59.166  +	cmdline_parse(*cmdline_p);
  59.167 - 
  59.168 ++#undef CONFIG_ACPI_BOOT
  59.169 ++#endif
  59.170   	efi_init();
  59.171 --	io_port_init();
  59.172 ++#ifndef XEN
  59.173 + 	io_port_init();
  59.174 ++#endif
  59.175   
  59.176   #ifdef CONFIG_IA64_GENERIC
  59.177   	{
  59.178 -@@ -339,6 +365,10 @@ setup_arch (char **cmdline_p)
  59.179 - 	if (early_console_setup(*cmdline_p) == 0)
  59.180 - 		mark_bsp_online();
  59.181 +@@ -351,8 +375,17 @@
  59.182 + # endif
  59.183 + #endif /* CONFIG_APCI_BOOT */
  59.184   
  59.185 -+#ifdef XEN
  59.186 ++#ifndef XEN
  59.187 + 	find_memory();
  59.188 ++#else
  59.189 ++	io_port_init();
  59.190 ++}
  59.191 + 
  59.192 ++void __init
  59.193 ++late_setup_arch (char **cmdline_p)
  59.194 ++{
  59.195  +#undef CONFIG_ACPI_BOOT
  59.196  +#endif
  59.197 -+
  59.198 - #ifdef CONFIG_ACPI_BOOT
  59.199 - 	/* Initialize the ACPI boot-time table parser */
  59.200 - 	acpi_table_init();
  59.201 -@@ -350,9 +380,13 @@ setup_arch (char **cmdline_p)
  59.202 - 	smp_build_cpu_map();	/* happens, e.g., with the Ski simulator */
  59.203 - # endif
  59.204 - #endif /* CONFIG_APCI_BOOT */
  59.205 -+	io_port_init();
  59.206 -+}
  59.207 -+#endif
  59.208 - 
  59.209 --	find_memory();
  59.210 --
  59.211 -+void __init
  59.212 -+setup_arch (void)
  59.213 -+{
  59.214   	/* process SAL system table: */
  59.215   	ia64_sal_init(efi.sal_systab);
  59.216   
  59.217 -@@ -388,7 +422,6 @@ setup_arch (char **cmdline_p)
  59.218 - 	if (!strstr(saved_command_line, "nomca"))
  59.219 - 		ia64_mca_init();
  59.220 - 
  59.221 --	platform_setup(cmdline_p);
  59.222 - 	paging_init();
  59.223 +@@ -492,12 +525,14 @@
  59.224 + {
  59.225   }
  59.226   
  59.227 -@@ -448,6 +481,9 @@ show_cpuinfo (struct seq_file *m, void *
  59.228 - 		sprintf(cp, " 0x%lx", mask);
  59.229 - 	}
  59.230 ++#ifndef XEN
  59.231 + struct seq_operations cpuinfo_op = {
  59.232 + 	.start =	c_start,
  59.233 + 	.next =		c_next,
  59.234 + 	.stop =		c_stop,
  59.235 + 	.show =		show_cpuinfo
  59.236 + };
  59.237 ++#endif
  59.238   
  59.239 -+#ifdef XEN
  59.240 -+#define seq_printf(a,b...) printf(b)
  59.241 -+#endif
  59.242 - 	seq_printf(m,
  59.243 - 		   "processor  : %d\n"
  59.244 - 		   "vendor     : %s\n"
  59.245 -@@ -659,11 +695,17 @@ cpu_init (void)
  59.246 + void
  59.247 + identify_cpu (struct cpuinfo_ia64 *c)
  59.248 +@@ -659,7 +694,11 @@
  59.249   					| IA64_DCR_DA | IA64_DCR_DD | IA64_DCR_LC));
  59.250   	atomic_inc(&init_mm.mm_count);
  59.251   	current->active_mm = &init_mm;
  59.252 @@ -197,18 +102,3 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  59.253   		BUG();
  59.254   
  59.255   	ia64_mmu_init(ia64_imva(cpu_data));
  59.256 -+#ifndef XEN
  59.257 - 	ia64_mca_cpu_init(ia64_imva(cpu_data));
  59.258 -+#endif
  59.259 - 
  59.260 - #ifdef CONFIG_IA32_SUPPORT
  59.261 - 	ia32_cpu_init();
  59.262 -@@ -711,6 +753,8 @@ cpu_init (void)
  59.263 - void
  59.264 - check_bugs (void)
  59.265 - {
  59.266 -+#ifndef XEN
  59.267 - 	ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
  59.268 - 			       (unsigned long) __end___mckinley_e9_bundles);
  59.269 -+#endif
  59.270 - }
    60.1 --- a/xen/arch/ia64/patch/linux-2.6.11/slab.h	Fri Apr 29 16:49:15 2005 +0000
    60.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.3 @@ -1,19 +0,0 @@
    60.4 - slab.h |    4 ++++
    60.5 - 1 files changed, 4 insertions(+)
    60.6 -
    60.7 -Index: linux-2.6.11/include/linux/slab.h
    60.8 -===================================================================
    60.9 ---- linux-2.6.11.orig/include/linux/slab.h	2005-03-02 01:38:33.000000000 -0600
   60.10 -+++ linux-2.6.11/include/linux/slab.h	2005-03-19 14:35:19.301871922 -0600
   60.11 -@@ -91,7 +91,11 @@ static inline void *kmalloc(size_t size,
   60.12 - 			goto found; \
   60.13 - 		else \
   60.14 - 			i++;
   60.15 -+#ifdef XEN
   60.16 -+#include <linux/kmalloc_sizes.h>
   60.17 -+#else
   60.18 - #include "kmalloc_sizes.h"
   60.19 -+#endif
   60.20 - #undef CACHE
   60.21 - 		{
   60.22 - 			extern void __you_cannot_kmalloc_that_much(void);
    61.1 --- a/xen/arch/ia64/patch/linux-2.6.11/swiotlb.c	Fri Apr 29 16:49:15 2005 +0000
    61.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/swiotlb.c	Tue May 03 08:08:47 2005 +0000
    61.3 @@ -1,70 +1,22 @@
    61.4 - swiotlb.c |   21 +++++++++++++--------
    61.5 - 1 files changed, 13 insertions(+), 8 deletions(-)
    61.6 -
    61.7 -Index: linux-2.6.11-xendiffs/arch/ia64/lib/swiotlb.c
    61.8 -===================================================================
    61.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/lib/swiotlb.c	2005-04-08 12:13:54.040202667 -0500
   61.10 -+++ linux-2.6.11-xendiffs/arch/ia64/lib/swiotlb.c	2005-04-08 12:19:09.170367318 -0500
   61.11 -@@ -124,8 +124,11 @@ swiotlb_init_with_default_size (size_t d
   61.12 - 	/*
   61.13 - 	 * Get IO TLB memory from the low pages
   61.14 - 	 */
   61.15 --	io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs *
   61.16 --					       (1 << IO_TLB_SHIFT));
   61.17 -+	/* FIXME: Do we really need swiotlb in HV? If all memory trunks
   61.18 -+	 * presented to guest as <4G, are actually <4G in machine range,
   61.19 -+	 * no DMA intevention from HV...
   61.20 -+	 */
   61.21 -+	io_tlb_start = alloc_xenheap_pages(get_order(io_tlb_nslabs * (1 << IO_TLB_SHIFT)));
   61.22 - 	if (!io_tlb_start)
   61.23 - 		panic("Cannot allocate SWIOTLB buffer");
   61.24 - 	io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
   61.25 -@@ -135,16 +138,16 @@ swiotlb_init_with_default_size (size_t d
   61.26 - 	 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
   61.27 - 	 * between io_tlb_start and io_tlb_end.
   61.28 - 	 */
   61.29 --	io_tlb_list = alloc_bootmem(io_tlb_nslabs * sizeof(int));
   61.30 -+	io_tlb_list = alloc_xenheap_pages(get_order(io_tlb_nslabs * sizeof(int)));
   61.31 - 	for (i = 0; i < io_tlb_nslabs; i++)
   61.32 -  		io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE);
   61.33 - 	io_tlb_index = 0;
   61.34 --	io_tlb_orig_addr = alloc_bootmem(io_tlb_nslabs * sizeof(char *));
   61.35 -+	io_tlb_orig_addr = alloc_xenheap_pages(get_order(io_tlb_nslabs * sizeof(char *)));
   61.36 +--- ../../linux-2.6.11/arch/ia64/lib/swiotlb.c	2005-03-02 00:38:17.000000000 -0700
   61.37 ++++ arch/ia64/lib/swiotlb.c	2005-05-02 13:04:15.000000000 -0600
   61.38 +@@ -49,6 +49,15 @@
   61.39 +  */
   61.40 + #define IO_TLB_SHIFT 11
   61.41   
   61.42 - 	/*
   61.43 - 	 * Get the overflow emergency buffer
   61.44 - 	 */
   61.45 --	io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
   61.46 -+	io_tlb_overflow_buffer = alloc_xenheap_pages(get_order(io_tlb_overflow));
   61.47 - 	printk(KERN_INFO "Placing software IO TLB between 0x%lx - 0x%lx\n",
   61.48 - 	       virt_to_phys(io_tlb_start), virt_to_phys(io_tlb_end));
   61.49 - }
   61.50 -@@ -328,13 +331,13 @@ swiotlb_alloc_coherent(struct device *hw
   61.51 - 	 */
   61.52 - 	flags |= GFP_DMA;
   61.53 ++#ifdef XEN
   61.54 ++#define __order_to_size(_order) (1 << (_order+PAGE_SHIFT))
   61.55 ++#define alloc_bootmem_low_pages(_x) alloc_xenheap_pages(get_order(_x))
   61.56 ++#define alloc_bootmem_low(_x) alloc_xenheap_pages(get_order(_x))
   61.57 ++#define alloc_bootmem(_x) alloc_xenheap_pages(get_order(_x))
   61.58 ++#define __get_free_pages(_x,_y) alloc_xenheap_pages(__order_to_size(_y))
   61.59 ++#define free_pages(_x,_y) free_xenheap_pages(_x,_y)
   61.60 ++#endif
   61.61 ++
   61.62 + int swiotlb_force;
   61.63   
   61.64 --	ret = (void *)__get_free_pages(flags, order);
   61.65 -+	ret = (void *)alloc_xenheap_pages(get_order(size));
   61.66 - 	if (ret && address_needs_mapping(hwdev, virt_to_phys(ret))) {
   61.67 - 		/*
   61.68 - 		 * The allocated memory isn't reachable by the device.
   61.69 - 		 * Fall back on swiotlb_map_single().
   61.70 - 		 */
   61.71 --		free_pages((unsigned long) ret, order);
   61.72 -+		free_xenheap_pages((unsigned long) ret, order);
   61.73 - 		ret = NULL;
   61.74 - 	}
   61.75 - 	if (!ret) {
   61.76 -@@ -372,7 +375,7 @@ swiotlb_free_coherent(struct device *hwd
   61.77 - {
   61.78 - 	if (!(vaddr >= (void *)io_tlb_start
   61.79 -                     && vaddr < (void *)io_tlb_end))
   61.80 --		free_pages((unsigned long) vaddr, get_order(size));
   61.81 -+		free_xenheap_pages((unsigned long) vaddr, get_order(size));
   61.82 - 	else
   61.83 - 		/* DMA_TO_DEVICE to avoid memcpy in unmap_single */
   61.84 - 		swiotlb_unmap_single (hwdev, dma_handle, size, DMA_TO_DEVICE);
   61.85 -@@ -388,8 +391,10 @@ swiotlb_full(struct device *dev, size_t 
   61.86 + /*
   61.87 +@@ -388,8 +397,10 @@
   61.88   	 * When the mapping is small enough return a static buffer to limit
   61.89   	 * the damage, or panic when the transfer is too big.
   61.90   	 */
    62.1 --- a/xen/arch/ia64/patch/linux-2.6.11/system.h	Fri Apr 29 16:49:15 2005 +0000
    62.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/system.h	Tue May 03 08:08:47 2005 +0000
    62.3 @@ -1,16 +1,10 @@
    62.4 - system.h |   15 +++++++++++++++
    62.5 - 1 files changed, 15 insertions(+)
    62.6 -
    62.7 -Index: linux-2.6.11-xendiffs/include/asm-ia64/system.h
    62.8 -===================================================================
    62.9 ---- linux-2.6.11-xendiffs.orig/include/asm-ia64/system.h	2005-04-07 10:39:11.066701457 -0500
   62.10 -+++ linux-2.6.11-xendiffs/include/asm-ia64/system.h	2005-04-07 10:40:19.540544127 -0500
   62.11 -@@ -24,8 +24,16 @@
   62.12 +--- ../../linux-2.6.11/include/asm-ia64/system.h	2005-03-02 00:38:07.000000000 -0700
   62.13 ++++ include/asm-ia64/system.h	2005-05-02 10:18:30.000000000 -0600
   62.14 +@@ -24,8 +24,15 @@
   62.15    * 0xa000000000000000+2*PERCPU_PAGE_SIZE
   62.16    * - 0xa000000000000000+3*PERCPU_PAGE_SIZE remain unmapped (guard page)
   62.17    */
   62.18  +#ifdef XEN
   62.19 -+//#define KERNEL_START		 0xf000000100000000
   62.20  +#define KERNEL_START		 0xf000000004000000
   62.21  +#define PERCPU_ADDR		 0xf100000000000000-PERCPU_PAGE_SIZE
   62.22  +#define SHAREDINFO_ADDR		 0xf100000000000000
   62.23 @@ -22,7 +16,7 @@ Index: linux-2.6.11-xendiffs/include/asm
   62.24   
   62.25   #ifndef __ASSEMBLY__
   62.26   
   62.27 -@@ -218,9 +226,13 @@ extern void ia64_load_extra (struct task
   62.28 +@@ -218,9 +225,13 @@
   62.29   # define PERFMON_IS_SYSWIDE() (0)
   62.30   #endif
   62.31   
   62.32 @@ -36,13 +30,3 @@ Index: linux-2.6.11-xendiffs/include/asm
   62.33   
   62.34   #define __switch_to(prev,next,last) do {							 \
   62.35   	if (IA64_HAS_EXTRA_STATE(prev))								 \
   62.36 -@@ -249,6 +261,9 @@ extern void ia64_load_extra (struct task
   62.37 - #else
   62.38 - # define switch_to(prev,next,last)	__switch_to(prev, next, last)
   62.39 - #endif
   62.40 -+//#ifdef XEN
   62.41 -+//#undef switch_to
   62.42 -+//#endif
   62.43 - 
   62.44 - /*
   62.45 -  * On IA-64, we don't want to hold the runqueue's lock during the low-level context-switch,
    63.1 --- a/xen/arch/ia64/patch/linux-2.6.11/time.c	Fri Apr 29 16:49:15 2005 +0000
    63.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/time.c	Tue May 03 08:08:47 2005 +0000
    63.3 @@ -1,263 +1,32 @@
    63.4 - time.c |  158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    63.5 - 1 files changed, 158 insertions(+)
    63.6 -
    63.7 -Index: linux-2.6.11-xendiffs/arch/ia64/kernel/time.c
    63.8 -===================================================================
    63.9 ---- linux-2.6.11-xendiffs.orig/arch/ia64/kernel/time.c	2005-04-07 17:02:39.634985144 -0500
   63.10 -+++ linux-2.6.11-xendiffs/arch/ia64/kernel/time.c	2005-04-07 17:23:52.777723222 -0500
   63.11 -@@ -10,16 +10,22 @@
   63.12 -  */
   63.13 - #include <linux/config.h>
   63.14 - 
   63.15 -+#ifndef XEN
   63.16 - #include <linux/cpu.h>
   63.17 -+#endif
   63.18 - #include <linux/init.h>
   63.19 - #include <linux/kernel.h>
   63.20 - #include <linux/module.h>
   63.21 -+#ifndef XEN
   63.22 - #include <linux/profile.h>
   63.23 -+#endif
   63.24 - #include <linux/sched.h>
   63.25 - #include <linux/time.h>
   63.26 - #include <linux/interrupt.h>
   63.27 - #include <linux/efi.h>
   63.28 -+#ifndef XEN
   63.29 - #include <linux/profile.h>
   63.30 -+#endif
   63.31 - #include <linux/timex.h>
   63.32 - 
   63.33 - #include <asm/machvec.h>
   63.34 -@@ -29,10 +35,19 @@
   63.35 +--- ../../linux-2.6.11/arch/ia64/kernel/time.c	2005-03-02 00:37:50.000000000 -0700
   63.36 ++++ arch/ia64/time.c	2005-05-02 11:19:29.000000000 -0600
   63.37 +@@ -29,6 +29,9 @@
   63.38   #include <asm/sal.h>
   63.39   #include <asm/sections.h>
   63.40   #include <asm/system.h>
   63.41  +#ifdef XEN
   63.42 -+#include <asm/ia64_int.h>
   63.43 ++#include <linux/jiffies.h>	// not included by xen/sched.h
   63.44  +#endif
   63.45   
   63.46   extern unsigned long wall_jiffies;
   63.47   
   63.48 -+#ifndef XEN
   63.49 - u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
   63.50 -+#else
   63.51 -+#define INITIAL_JIFFIES 0
   63.52 -+u64 jiffies_64 = INITIAL_JIFFIES;
   63.53 -+#define CPU_PROFILING 0
   63.54 -+#endif
   63.55 - 
   63.56 - EXPORT_SYMBOL(jiffies_64);
   63.57 - 
   63.58 -@@ -45,33 +60,154 @@ EXPORT_SYMBOL(last_cli_ip);
   63.59 +@@ -45,6 +48,7 @@
   63.60   
   63.61   #endif
   63.62   
   63.63 -+#ifdef XEN
   63.64 -+volatile unsigned long last_nsec_offset;
   63.65 -+extern rwlock_t xtime_lock;
   63.66 -+unsigned long cpu_khz;  /* Detected as we calibrate the TSC */
   63.67 -+static s_time_t        stime_irq;       /* System time at last 'time update' */
   63.68 -+
   63.69 -+static inline u64 get_time_delta(void)
   63.70 -+{
   63.71 -+	return ia64_get_itc();
   63.72 -+}
   63.73 -+
   63.74 -+s_time_t get_s_time(void)
   63.75 -+{
   63.76 -+    s_time_t now;
   63.77 -+    unsigned long flags;
   63.78 -+
   63.79 -+    read_lock_irqsave(&xtime_lock, flags);
   63.80 -+
   63.81 -+    now = stime_irq + get_time_delta();
   63.82 -+
   63.83 -+    /* Ensure that the returned system time is monotonically increasing. */
   63.84 -+    {
   63.85 -+        static s_time_t prev_now = 0;
   63.86 -+        if ( unlikely(now < prev_now) )
   63.87 -+            now = prev_now;
   63.88 -+        prev_now = now;
   63.89 -+    }
   63.90 -+
   63.91 -+    read_unlock_irqrestore(&xtime_lock, flags);
   63.92 -+
   63.93 -+    return now; 
   63.94 -+}
   63.95 -+
   63.96 -+void update_dom_time(struct exec_domain *ed)
   63.97 -+{
   63.98 -+// FIXME: implement this?
   63.99 -+//	printf("update_dom_time: called, not implemented, skipping\n");
  63.100 -+	return;
  63.101 -+}
  63.102 -+
  63.103 -+/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
  63.104 -+void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
  63.105 -+{
  63.106 -+// FIXME: Should this be do_settimeofday (from linux)???
  63.107 -+	printf("do_settime: called, not implemented, stopping\n");
  63.108 -+	dummy();
  63.109 -+}
  63.110 -+#endif
  63.111 -+
  63.112 -+#if 0	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  63.113 -+#endif	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  63.114 -+ 
  63.115  +#ifndef XEN
  63.116   static struct time_interpolator itc_interpolator = {
  63.117   	.shift = 16,
  63.118   	.mask = 0xffffffffffffffffLL,
  63.119 - 	.source = TIME_SOURCE_CPU
  63.120 - };
  63.121 -+#endif
  63.122 -+
  63.123 -+#ifdef XEN
  63.124 -+unsigned long domain0_ready = 0;	// FIXME (see below)
  63.125 -+#define typecheck(a,b)	1
  63.126 -+/* FROM linux/include/linux/jiffies.h */
  63.127 -+/*
  63.128 -+ *	These inlines deal with timer wrapping correctly. You are 
  63.129 -+ *	strongly encouraged to use them
  63.130 -+ *	1. Because people otherwise forget
  63.131 -+ *	2. Because if the timer wrap changes in future you won't have to
  63.132 -+ *	   alter your driver code.
  63.133 -+ *
  63.134 -+ * time_after(a,b) returns true if the time a is after time b.
  63.135 -+ *
  63.136 -+ * Do this with "<0" and ">=0" to only test the sign of the result. A
  63.137 -+ * good compiler would generate better code (and a really good compiler
  63.138 -+ * wouldn't care). Gcc is currently neither.
  63.139 -+ */
  63.140 -+#define time_after(a,b)		\
  63.141 -+	(typecheck(unsigned long, a) && \
  63.142 -+	 typecheck(unsigned long, b) && \
  63.143 -+	 ((long)(b) - (long)(a) < 0))
  63.144 -+#define time_before(a,b)	time_after(b,a)
  63.145 -+
  63.146 -+#define time_after_eq(a,b)	\
  63.147 -+	(typecheck(unsigned long, a) && \
  63.148 -+	 typecheck(unsigned long, b) && \
  63.149 -+	 ((long)(a) - (long)(b) >= 0))
  63.150 -+#define time_before_eq(a,b)	time_after_eq(b,a)
  63.151 -+#endif
  63.152 - 
  63.153 - static irqreturn_t
  63.154 - timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
  63.155 - {
  63.156 - 	unsigned long new_itm;
  63.157 - 
  63.158 -+#ifndef XEN
  63.159 - 	if (unlikely(cpu_is_offline(smp_processor_id()))) {
  63.160 - 		return IRQ_HANDLED;
  63.161 - 	}
  63.162 -+#endif
  63.163 -+#ifdef XEN
  63.164 -+	if (current->domain == dom0) {
  63.165 -+		// FIXME: there's gotta be a better way of doing this...
  63.166 -+		// We have to ensure that domain0 is launched before we
  63.167 -+		// call vcpu_timer_expired on it
  63.168 -+		//domain0_ready = 1; // moved to xensetup.c
  63.169 -+	}
  63.170 -+	if (domain0_ready && vcpu_timer_expired(dom0->exec_domain[0])) {
  63.171 -+		vcpu_pend_timer(dom0->exec_domain[0]);
  63.172 -+		//vcpu_set_next_timer(dom0->exec_domain[0]);
  63.173 -+		domain_wake(dom0->exec_domain[0]);
  63.174 -+	}
  63.175 -+	if (!is_idle_task(current->domain) && current->domain != dom0) {
  63.176 -+		if (vcpu_timer_expired(current)) {
  63.177 -+			vcpu_pend_timer(current);
  63.178 -+			// ensure another timer interrupt happens even if domain doesn't
  63.179 -+			vcpu_set_next_timer(current);
  63.180 -+			domain_wake(current);
  63.181 -+		}
  63.182 -+	}
  63.183 -+	raise_actimer_softirq();
  63.184 -+#endif
  63.185 - 
  63.186 -+#ifndef XEN
  63.187 - 	platform_timer_interrupt(irq, dev_id, regs);
  63.188 +@@ -110,6 +114,7 @@
  63.189 + 	} while (time_after_eq(ia64_get_itc(), new_itm));
  63.190 + 	return IRQ_HANDLED;
  63.191 + }
  63.192  +#endif
  63.193   
  63.194 - 	new_itm = local_cpu_data->itm_next;
  63.195 - 
  63.196 - 	if (!time_after(ia64_get_itc(), new_itm))
  63.197 -+#ifdef XEN
  63.198 -+		return;
  63.199 -+#else
  63.200 - 		printk(KERN_ERR "Oops: timer tick before it's due (itc=%lx,itm=%lx)\n",
  63.201 - 		       ia64_get_itc(), new_itm);
  63.202 -+#endif
  63.203 - 
  63.204 -+#ifdef XEN
  63.205 -+//	printf("GOT TO HERE!!!!!!!!!!!\n");
  63.206 -+	//while(1);
  63.207 -+#else
  63.208 - 	profile_tick(CPU_PROFILING, regs);
  63.209 -+#endif
  63.210 - 
  63.211 - 	while (1) {
  63.212 -+#ifndef XEN
  63.213 - 		update_process_times(user_mode(regs));
  63.214 -+#endif
  63.215 - 
  63.216 - 		new_itm += local_cpu_data->itm_delta;
  63.217 - 
  63.218 -@@ -82,10 +218,16 @@ timer_interrupt (int irq, void *dev_id, 
  63.219 - 			 * another CPU. We need to avoid to SMP race by acquiring the
  63.220 - 			 * xtime_lock.
  63.221 - 			 */
  63.222 -+#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
  63.223 - 			write_seqlock(&xtime_lock);
  63.224 -+#endif
  63.225 -+#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
  63.226 - 			do_timer(regs);
  63.227 -+#endif
  63.228 - 			local_cpu_data->itm_next = new_itm;
  63.229 -+#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
  63.230 - 			write_sequnlock(&xtime_lock);
  63.231 -+#endif
  63.232 - 		} else
  63.233 - 			local_cpu_data->itm_next = new_itm;
  63.234 - 
  63.235 -@@ -105,7 +247,12 @@ timer_interrupt (int irq, void *dev_id, 
  63.236 - 		 */
  63.237 - 		while (!time_after(new_itm, ia64_get_itc() + local_cpu_data->itm_delta/2))
  63.238 - 			new_itm += local_cpu_data->itm_delta;
  63.239 -+//#ifdef XEN
  63.240 -+//		vcpu_set_next_timer(current);
  63.241 -+//#else
  63.242 -+//printf("***** timer_interrupt: Setting itm to %lx\n",new_itm);
  63.243 - 		ia64_set_itm(new_itm);
  63.244 -+//#endif
  63.245 - 		/* double check, in case we got hit by a (slow) PMI: */
  63.246 - 	} while (time_after_eq(ia64_get_itc(), new_itm));
  63.247 - 	return IRQ_HANDLED;
  63.248 -@@ -120,6 +267,7 @@ ia64_cpu_local_tick (void)
  63.249 - 	int cpu = smp_processor_id();
  63.250 - 	unsigned long shift = 0, delta;
  63.251 - 
  63.252 -+printf("ia64_cpu_local_tick: about to call ia64_set_itv\n");
  63.253 - 	/* arrange for the cycle counter to generate a timer interrupt: */
  63.254 - 	ia64_set_itv(IA64_TIMER_VECTOR);
  63.255 - 
  63.256 -@@ -133,6 +281,7 @@ ia64_cpu_local_tick (void)
  63.257 - 		shift = (2*(cpu - hi) + 1) * delta/hi/2;
  63.258 - 	}
  63.259 - 	local_cpu_data->itm_next = ia64_get_itc() + delta + shift;
  63.260 -+printf("***** ia64_cpu_local_tick: Setting itm to %lx\n",local_cpu_data->itm_next);
  63.261 - 	ia64_set_itm(local_cpu_data->itm_next);
  63.262 - }
  63.263 - 
  63.264 -@@ -160,6 +309,7 @@ ia64_init_itm (void)
  63.265 - 	 * frequency and then a PAL call to determine the frequency ratio between the ITC
  63.266 - 	 * and the base frequency.
  63.267 - 	 */
  63.268 -+
  63.269 - 	status = ia64_sal_freq_base(SAL_FREQ_BASE_PLATFORM,
  63.270 - 				    &platform_base_freq, &platform_base_drift);
  63.271 - 	if (status != 0) {
  63.272 -@@ -212,6 +362,7 @@ ia64_init_itm (void)
  63.273 + /*
  63.274 +  * Encapsulate access to the itm structure for SMP.
  63.275 +@@ -212,6 +217,7 @@
  63.276   					+ itc_freq/2)/itc_freq;
  63.277   
  63.278   	if (!(sal_platform_features & IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT)) {
  63.279 @@ -265,7 +34,7 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  63.280   		itc_interpolator.frequency = local_cpu_data->itc_freq;
  63.281   		itc_interpolator.drift = itc_drift;
  63.282   #ifdef CONFIG_SMP
  63.283 -@@ -228,6 +379,7 @@ ia64_init_itm (void)
  63.284 +@@ -228,12 +234,14 @@
  63.285   		if (!nojitter) itc_interpolator.jitter = 1;
  63.286   #endif
  63.287   		register_time_interpolator(&itc_interpolator);
  63.288 @@ -273,30 +42,15 @@ Index: linux-2.6.11-xendiffs/arch/ia64/k
  63.289   	}
  63.290   
  63.291   	/* Setup the CPU local timer tick */
  63.292 -@@ -236,7 +388,9 @@ ia64_init_itm (void)
  63.293 + 	ia64_cpu_local_tick();
  63.294 + }
  63.295   
  63.296 ++#ifndef XEN
  63.297   static struct irqaction timer_irqaction = {
  63.298   	.handler =	timer_interrupt,
  63.299 -+#ifndef XEN
  63.300   	.flags =	SA_INTERRUPT,
  63.301 -+#endif
  63.302 - 	.name =		"timer"
  63.303 - };
  63.304 - 
  63.305 -@@ -244,12 +398,16 @@ void __init
  63.306 - time_init (void)
  63.307 - {
  63.308 - 	register_percpu_irq(IA64_TIMER_VECTOR, &timer_irqaction);
  63.309 -+#ifndef XEN
  63.310 - 	efi_gettimeofday(&xtime);
  63.311 -+#endif
  63.312 - 	ia64_init_itm();
  63.313 - 
  63.314 -+#ifndef XEN
  63.315 - 	/*
  63.316 - 	 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
  63.317 - 	 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
  63.318 +@@ -253,3 +261,4 @@
  63.319   	 */
  63.320   	set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
  63.321 + }
  63.322  +#endif
  63.323 - }
    64.1 --- a/xen/arch/ia64/patch/linux-2.6.11/tlb.c	Fri Apr 29 16:49:15 2005 +0000
    64.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/tlb.c	Tue May 03 08:08:47 2005 +0000
    64.3 @@ -1,21 +1,6 @@
    64.4 - tlb.c |   10 ++++++++++
    64.5 - 1 files changed, 10 insertions(+)
    64.6 -
    64.7 -Index: linux-2.6.11/arch/ia64/mm/tlb.c
    64.8 -===================================================================
    64.9 ---- linux-2.6.11.orig/arch/ia64/mm/tlb.c	2005-03-02 01:38:38.000000000 -0600
   64.10 -+++ linux-2.6.11/arch/ia64/mm/tlb.c	2005-03-19 14:58:43.978400822 -0600
   64.11 -@@ -21,7 +21,9 @@
   64.12 - #include <asm/mmu_context.h>
   64.13 - #include <asm/pgalloc.h>
   64.14 - #include <asm/pal.h>
   64.15 -+#ifndef XEN
   64.16 - #include <asm/tlbflush.h>
   64.17 -+#endif
   64.18 - 
   64.19 - static struct {
   64.20 - 	unsigned long mask;	/* mask of supported purge page-sizes */
   64.21 -@@ -43,6 +45,9 @@ DEFINE_PER_CPU(u8, ia64_need_tlb_flush);
   64.22 +--- ../../linux-2.6.11/arch/ia64/mm/tlb.c	2005-03-02 00:38:38.000000000 -0700
   64.23 ++++ arch/ia64/tlb.c	2005-05-02 10:23:09.000000000 -0600
   64.24 +@@ -43,6 +43,9 @@
   64.25   void
   64.26   wrap_mmu_context (struct mm_struct *mm)
   64.27   {
   64.28 @@ -25,7 +10,7 @@ Index: linux-2.6.11/arch/ia64/mm/tlb.c
   64.29   	unsigned long tsk_context, max_ctx = ia64_ctx.max_ctx;
   64.30   	struct task_struct *tsk;
   64.31   	int i;
   64.32 -@@ -83,6 +88,7 @@ wrap_mmu_context (struct mm_struct *mm)
   64.33 +@@ -83,6 +86,7 @@
   64.34   		put_cpu();
   64.35   	}
   64.36   	local_flush_tlb_all();
   64.37 @@ -33,7 +18,7 @@ Index: linux-2.6.11/arch/ia64/mm/tlb.c
   64.38   }
   64.39   
   64.40   void
   64.41 -@@ -132,6 +138,9 @@ EXPORT_SYMBOL(local_flush_tlb_all);
   64.42 +@@ -132,6 +136,9 @@
   64.43   void
   64.44   flush_tlb_range (struct vm_area_struct *vma, unsigned long start, unsigned long end)
   64.45   {
   64.46 @@ -43,7 +28,7 @@ Index: linux-2.6.11/arch/ia64/mm/tlb.c
   64.47   	struct mm_struct *mm = vma->vm_mm;
   64.48   	unsigned long size = end - start;
   64.49   	unsigned long nbits;
   64.50 -@@ -163,6 +172,7 @@ flush_tlb_range (struct vm_area_struct *
   64.51 +@@ -163,6 +170,7 @@
   64.52   # endif
   64.53   
   64.54   	ia64_srlz_i();			/* srlz.i implies srlz.d */
    65.1 --- a/xen/arch/ia64/patch/linux-2.6.11/unaligned.c	Fri Apr 29 16:49:15 2005 +0000
    65.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/unaligned.c	Tue May 03 08:08:47 2005 +0000
    65.3 @@ -1,39 +1,6 @@
    65.4 - unaligned.c |   27 +++++++++++++++++++++++++++
    65.5 - 1 files changed, 27 insertions(+)
    65.6 -
    65.7 -Index: linux-2.6.11/arch/ia64/kernel/unaligned.c
    65.8 -===================================================================
    65.9 ---- linux-2.6.11.orig/arch/ia64/kernel/unaligned.c	2005-03-02 01:38:25.000000000 -0600
   65.10 -+++ linux-2.6.11/arch/ia64/kernel/unaligned.c	2005-03-19 14:58:51.269335202 -0600
   65.11 -@@ -15,8 +15,10 @@
   65.12 -  */
   65.13 - #include <linux/kernel.h>
   65.14 - #include <linux/sched.h>
   65.15 -+#ifndef XEN
   65.16 - #include <linux/smp_lock.h>
   65.17 - #include <linux/tty.h>
   65.18 -+#endif
   65.19 - 
   65.20 - #include <asm/intrinsics.h>
   65.21 - #include <asm/processor.h>
   65.22 -@@ -24,7 +26,16 @@
   65.23 - #include <asm/uaccess.h>
   65.24 - #include <asm/unaligned.h>
   65.25 - 
   65.26 -+#ifdef XEN
   65.27 -+#define	ia64_peek(x...)	printk("ia64_peek: called, not implemented\n")
   65.28 -+#define	ia64_poke(x...)	printk("ia64_poke: called, not implemented\n")
   65.29 -+#define	ia64_sync_fph(x...) printk("ia64_sync_fph: called, not implemented\n")
   65.30 -+#define	ia64_flush_fph(x...) printk("ia64_flush_fph: called, not implemented\n")
   65.31 -+#define	die_if_kernel(x...) printk("die_if_kernel: called, not implemented\n")
   65.32 -+#define jiffies 0
   65.33 -+#else
   65.34 - extern void die_if_kernel(char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn));
   65.35 -+#endif
   65.36 - 
   65.37 - #undef DEBUG_UNALIGNED_TRAP
   65.38 - 
   65.39 -@@ -437,7 +448,11 @@ get_rse_reg (struct pt_regs *regs, unsig
   65.40 +--- ../../linux-2.6.11/arch/ia64/kernel/unaligned.c	2005-03-02 00:38:25.000000000 -0700
   65.41 ++++ arch/ia64/unaligned.c	2005-04-28 15:40:13.000000000 -0600
   65.42 +@@ -437,7 +437,11 @@
   65.43   }
   65.44   
   65.45   
   65.46 @@ -45,7 +12,7 @@ Index: linux-2.6.11/arch/ia64/kernel/una
   65.47   setreg (unsigned long regnum, unsigned long val, int nat, struct pt_regs *regs)
   65.48   {
   65.49   	struct switch_stack *sw = (struct switch_stack *) regs - 1;
   65.50 -@@ -611,7 +626,11 @@ getfpreg (unsigned long regnum, struct i
   65.51 +@@ -611,7 +615,11 @@
   65.52   }
   65.53   
   65.54   
   65.55 @@ -57,46 +24,19 @@ Index: linux-2.6.11/arch/ia64/kernel/una
   65.56   getreg (unsigned long regnum, unsigned long *val, int *nat, struct pt_regs *regs)
   65.57   {
   65.58   	struct switch_stack *sw = (struct switch_stack *) regs - 1;
   65.59 -@@ -1298,7 +1317,9 @@ ia64_handle_unaligned (unsigned long ifa
   65.60 - 	mm_segment_t old_fs = get_fs();
   65.61 - 	unsigned long bundle[2];
   65.62 - 	unsigned long opcode;
   65.63 -+#ifndef XEN
   65.64 - 	struct siginfo si;
   65.65 -+#endif
   65.66 - 	const struct exception_table_entry *eh = NULL;
   65.67 - 	union {
   65.68 - 		unsigned long l;
   65.69 -@@ -1317,6 +1338,9 @@ ia64_handle_unaligned (unsigned long ifa
   65.70 - 	 * user-level unaligned accesses.  Otherwise, a clever program could trick this
   65.71 - 	 * handler into reading an arbitrary kernel addresses...
   65.72 - 	 */
   65.73 +@@ -1294,6 +1302,9 @@
   65.74 + void
   65.75 + ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
   65.76 + {
   65.77  +#ifdef XEN
   65.78  +printk("ia64_handle_unaligned: called, not working yet\n");
   65.79  +#else
   65.80 - 	if (!user_mode(regs))
   65.81 - 		eh = search_exception_tables(regs->cr_iip + ia64_psr(regs)->ri);
   65.82 - 	if (user_mode(regs) || eh) {
   65.83 -@@ -1353,6 +1377,7 @@ ia64_handle_unaligned (unsigned long ifa
   65.84 - 
   65.85 - 	if (__copy_from_user(bundle, (void __user *) regs->cr_iip, 16))
   65.86 - 		goto failure;
   65.87 -+#endif
   65.88 - 
   65.89 - 	/*
   65.90 - 	 * extract the instruction from the bundle given the slot number
   65.91 -@@ -1493,6 +1518,7 @@ ia64_handle_unaligned (unsigned long ifa
   65.92 - 		/* NOT_REACHED */
   65.93 - 	}
   65.94 -   force_sigbus:
   65.95 -+#ifndef XEN
   65.96 - 	si.si_signo = SIGBUS;
   65.97 - 	si.si_errno = 0;
   65.98 - 	si.si_code = BUS_ADRALN;
   65.99 -@@ -1501,5 +1527,6 @@ ia64_handle_unaligned (unsigned long ifa
  65.100 - 	si.si_isr = 0;
  65.101 + 	struct ia64_psr *ipsr = ia64_psr(regs);
  65.102 + 	mm_segment_t old_fs = get_fs();
  65.103 + 	unsigned long bundle[2];
  65.104 +@@ -1502,4 +1513,5 @@
  65.105   	si.si_imm = 0;
  65.106   	force_sig_info(SIGBUS, &si, current);
  65.107 + 	goto done;
  65.108  +#endif
  65.109 - 	goto done;
  65.110   }
    66.1 --- a/xen/arch/ia64/patch/linux-2.6.11/wait.h	Fri Apr 29 16:49:15 2005 +0000
    66.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.3 @@ -1,35 +0,0 @@
    66.4 - wait.h |    6 ++++++
    66.5 - 1 files changed, 6 insertions(+)
    66.6 -
    66.7 -Index: linux-2.6.11/include/linux/wait.h
    66.8 -===================================================================
    66.9 ---- linux-2.6.11.orig/include/linux/wait.h	2005-03-02 01:38:10.000000000 -0600
   66.10 -+++ linux-2.6.11/include/linux/wait.h	2005-03-19 15:00:23.691156973 -0600
   66.11 -@@ -136,7 +136,11 @@ static inline void __remove_wait_queue(w
   66.12 - 	list_del(&old->task_list);
   66.13 - }
   66.14 - 
   66.15 -+#ifdef XEN
   66.16 -+void FASTCALL(__wake_up(struct task_struct *p));
   66.17 -+#else
   66.18 - void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key));
   66.19 -+#endif
   66.20 - extern void FASTCALL(__wake_up_locked(wait_queue_head_t *q, unsigned int mode));
   66.21 - extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr));
   66.22 - void FASTCALL(__wake_up_bit(wait_queue_head_t *, void *, int));
   66.23 -@@ -147,6 +151,7 @@ int FASTCALL(out_of_line_wait_on_bit(voi
   66.24 - int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned));
   66.25 - wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int));
   66.26 - 
   66.27 -+#ifndef XEN
   66.28 - #define wake_up(x)			__wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, NULL)
   66.29 - #define wake_up_nr(x, nr)		__wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr, NULL)
   66.30 - #define wake_up_all(x)			__wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, NULL)
   66.31 -@@ -155,6 +160,7 @@ wait_queue_head_t *FASTCALL(bit_waitqueu
   66.32 - #define wake_up_interruptible_all(x)	__wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)
   66.33 - #define	wake_up_locked(x)		__wake_up_locked((x), TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
   66.34 - #define wake_up_interruptible_sync(x)   __wake_up_sync((x),TASK_INTERRUPTIBLE, 1)
   66.35 -+#endif
   66.36 - 
   66.37 - #define __wait_event(wq, condition) 					\
   66.38 - do {									\
    67.1 --- a/xen/arch/ia64/process.c	Fri Apr 29 16:49:15 2005 +0000
    67.2 +++ b/xen/arch/ia64/process.c	Tue May 03 08:08:47 2005 +0000
    67.3 @@ -171,6 +171,10 @@ panic_domain(regs,"psr.ic off, deliverin
    67.4  		else if (vector == IA64_INST_TLB_VECTOR)
    67.5  			vector = IA64_ALT_INST_TLB_VECTOR;
    67.6  //	}
    67.7 +	if (vector == IA64_ALT_DATA_TLB_VECTOR ||
    67.8 +	    vector == IA64_ALT_INST_TLB_VECTOR) {
    67.9 +		vcpu_thash(ed,ifa,&PSCB(ed,iha));
   67.10 +	}
   67.11  	PSCB(ed,unat) = regs->ar_unat;  // not sure if this is really needed?
   67.12  	PSCB(ed,precover_ifs) = regs->cr_ifs;
   67.13  	vcpu_bsw0(ed);
    68.1 --- a/xen/arch/ia64/tools/mkbuildtree	Fri Apr 29 16:49:15 2005 +0000
    68.2 +++ b/xen/arch/ia64/tools/mkbuildtree	Tue May 03 08:08:47 2005 +0000
    68.3 @@ -85,24 +85,26 @@ cp_patch arch/ia64/kernel/entry.S arch/i
    68.4  cp_patch arch/ia64/kernel/head.S arch/ia64/head.S head.S
    68.5  #cp_patch arch/ia64/kernel/init_task.c arch/ia64/init_task.c init_task.c
    68.6  cp_patch arch/ia64/kernel/irq_ia64.c arch/ia64/irq_ia64.c irq_ia64.c
    68.7 -cp_patch arch/ia64/kernel/ivt.S arch/ia64/ivt.S ivt.S
    68.8 +#cp_patch arch/ia64/kernel/ivt.S arch/ia64/ivt.S ivt.S
    68.9  #cp_patch arch/ia64/kernel/minstate.h arch/ia64/minstate.h minstate.h
   68.10  cp_patch arch/ia64/kernel/setup.c arch/ia64/setup.c setup.c
   68.11  cp_patch arch/ia64/kernel/time.c arch/ia64/time.c time.c
   68.12  cp_patch arch/ia64/kernel/unaligned.c arch/ia64/unaligned.c unaligned.c
   68.13 -cp_patch arch/ia64/kernel/vmlinux.lds.S arch/ia64/xen.lds.S lds.S
   68.14 +#cp_patch arch/ia64/kernel/vmlinux.lds.S arch/ia64/xen.lds.S lds.S
   68.15 +softlink arch/ia64/kernel/vmlinux.lds.S arch/ia64/xen.lds.S
   68.16  
   68.17  #cp_patch mm/bootmem.c arch/ia64/mm_bootmem.c mm_bootmem.c
   68.18  #cp_patch mm/page_alloc.c arch/ia64/page_alloc.c page_alloc.c
   68.19  #cp_patch mm/slab.c arch/ia64/slab.c slab.c
   68.20  
   68.21  # following renamed to avoid conflict
   68.22 -cp_patch kernel/extable.c arch/ia64/linuxextable.c linuxextable.c
   68.23 +#cp_patch kernel/extable.c arch/ia64/linuxextable.c linuxextable.c
   68.24 +softlink kernel/extable.c arch/ia64/linuxextable.c
   68.25  
   68.26  cp_patch arch/ia64/mm/contig.c arch/ia64/mm_contig.c mm_contig.c
   68.27  cp_patch arch/ia64/mm/tlb.c arch/ia64/tlb.c tlb.c
   68.28  
   68.29 -cp_patch arch/ia64/hp/sim/hpsim_irq.c arch/ia64/hpsim_irq.c hpsim_irq.c
   68.30 +#cp_patch arch/ia64/hp/sim/hpsim_irq.c arch/ia64/hpsim_irq.c hpsim_irq.c
   68.31  
   68.32  softlink arch/ia64/kernel/efi_stub.S arch/ia64/efi_stub.S
   68.33  softlink arch/ia64/kernel/entry.h arch/ia64/entry.h
   68.34 @@ -149,38 +151,42 @@ softlink arch/ia64/hp/sim/hpsim.S arch/i
   68.35  
   68.36  # xen/include/asm-generic files
   68.37  
   68.38 -softlink include/asm-generic/bug.h include/asm-generic/bug.h bug.h
   68.39 -softlink include/asm-generic/div64.h include/asm-generic/div64.h div64.h
   68.40 +softlink include/asm-generic/bug.h include/asm-generic/bug.h
   68.41 +softlink include/asm-generic/div64.h include/asm-generic/div64.h
   68.42  softlink include/asm-generic/errno.h include/asm-generic/errno.h
   68.43  softlink include/asm-generic/errno-base.h include/asm-generic/errno-base.h
   68.44 -softlink include/asm-generic/ide_iops.h include/asm-generic/ide_iops.h ide_iops.h
   68.45 -softlink include/asm-generic/iomap.h include/asm-generic/iomap.h iomap.h
   68.46 -softlink include/asm-generic/pci-dma-compat.h include/asm-generic/pci-dma-compat.h pci-dma-compat.h
   68.47 -softlink include/asm-generic/pci.h include/asm-generic/pci.h pci.h
   68.48 -softlink include/asm-generic/pgtable.h include/asm-generic/pgtable.h pgtable.h
   68.49 -softlink include/asm-generic/pgtable-nopud.h include/asm-generic/pgtable-nopud.h pgtable-nopud.h
   68.50 -softlink include/asm-generic/sections.h include/asm-generic/sections.h sections.h
   68.51 -softlink include/asm-generic/topology.h include/asm-generic/topology.h topology.h
   68.52 -softlink include/asm-generic/vmlinux.lds.h include/asm-generic/vmlinux.lds.h vmlinux.lds.h
   68.53 +softlink include/asm-generic/ide_iops.h include/asm-generic/ide_iops.h
   68.54 +softlink include/asm-generic/iomap.h include/asm-generic/iomap.h
   68.55 +softlink include/asm-generic/pci-dma-compat.h include/asm-generic/pci-dma-compat.h
   68.56 +softlink include/asm-generic/pci.h include/asm-generic/pci.h
   68.57 +softlink include/asm-generic/pgtable.h include/asm-generic/pgtable.h
   68.58 +softlink include/asm-generic/pgtable-nopud.h include/asm-generic/pgtable-nopud.h
   68.59 +softlink include/asm-generic/sections.h include/asm-generic/sections.h
   68.60 +softlink include/asm-generic/topology.h include/asm-generic/topology.h
   68.61 +softlink include/asm-generic/vmlinux.lds.h include/asm-generic/vmlinux.lds.h
   68.62  
   68.63  
   68.64  # xen/include/asm-ia64 files
   68.65  
   68.66  cp_patch arch/ia64/hp/sim/hpsim_ssc.h include/asm-ia64/hpsim_ssc.h hpsim_ssc.h
   68.67  
   68.68 -cp_patch include/asm-ia64/current.h include/asm-ia64/current.h current.h
   68.69 +#cp_patch include/asm-ia64/current.h include/asm-ia64/current.h current.h
   68.70 +softlink include/asm-ia64/current.h include/asm-ia64/current.h
   68.71  #cp_patch include/asm-ia64/gcc_intrin.h include/asm-ia64/gcc_intrin.h gcc_intrin.h
   68.72  softlink include/asm-ia64/gcc_intrin.h include/asm-ia64/gcc_intrin.h
   68.73 -cp_patch include/asm-ia64/hardirq.h include/asm-ia64/hardirq.h hardirq.h
   68.74 +#cp_patch include/asm-ia64/hardirq.h include/asm-ia64/hardirq.h hardirq.h
   68.75 +softlink include/asm-ia64/hardirq.h include/asm-ia64/hardirq.h
   68.76  #cp_patch include/asm-ia64/hw_irq.h include/asm-ia64/hw_irq.h hw_irq.h
   68.77  softlink include/asm-ia64/hw_irq.h include/asm-ia64/hw_irq.h
   68.78  #cp_patch include/asm-ia64/ide.h include/asm-ia64/ide.h ide.h
   68.79  cp_patch include/asm-ia64/io.h include/asm-ia64/io.h io.h
   68.80 -cp_patch include/asm-ia64/irq.h include/asm-ia64/irq.h irq.h
   68.81 +#cp_patch include/asm-ia64/irq.h include/asm-ia64/irq.h irq.h
   68.82 +softlink include/asm-ia64/irq.h include/asm-ia64/irq.h
   68.83  cp_patch include/asm-ia64/kregs.h include/asm-ia64/kregs.h kregs.h
   68.84  cp_patch include/asm-ia64/page.h include/asm-ia64/page.h page.h
   68.85  cp_patch include/asm-ia64/processor.h include/asm-ia64/processor.h processor.h
   68.86 -cp_patch include/asm-ia64/sal.h include/asm-ia64/sal.h sal.h
   68.87 +#cp_patch include/asm-ia64/sal.h include/asm-ia64/sal.h sal.h
   68.88 +softlink include/asm-ia64/sal.h include/asm-ia64/sal.h
   68.89  cp_patch include/asm-ia64/system.h include/asm-ia64/system.h system.h
   68.90  cp_patch include/asm-ia64/types.h include/asm-ia64/types.h types.h
   68.91  
   68.92 @@ -190,6 +196,8 @@ null include/asm-ia64/desc.h
   68.93  null include/asm-ia64/io_apic.h
   68.94  null include/asm-ia64/pdb.h
   68.95  null include/asm-ia64/module.h
   68.96 +null include/asm-ia64/ia32.h
   68.97 +null include/asm-ia64/tlbflush.h
   68.98  
   68.99  softlink include/asm-ia64/acpi.h include/asm-ia64/acpi.h
  68.100  softlink include/asm-ia64/asmmacro.h include/asm-ia64/asmmacro.h
  68.101 @@ -208,7 +216,7 @@ softlink include/asm-ia64/dma-mapping.h 
  68.102  softlink include/asm-ia64/errno.h include/asm-ia64/errno.h
  68.103  softlink include/asm-ia64/fpu.h include/asm-ia64/fpu.h
  68.104  softlink include/asm-ia64/hdreg.h include/asm-ia64/hdreg.h
  68.105 -softlink include/asm-ia64/ia32.h include/asm-ia64/ia32.h
  68.106 +#softlink include/asm-ia64/ia32.h include/asm-ia64/ia32.h
  68.107  softlink include/asm-ia64/ia64regs.h include/asm-ia64/ia64regs.h
  68.108  softlink include/asm-ia64/intrinsics.h include/asm-ia64/intrinsics.h
  68.109  softlink include/asm-ia64/ioctl.h include/asm-ia64/ioctl.h
  68.110 @@ -257,23 +265,26 @@ softlink include/asm-ia64/ustack.h inclu
  68.111  
  68.112  # xen/include/asm-ia64/linux/*.h (== linux/include/linux/*.h)
  68.113  
  68.114 -cp_patch include/linux/bootmem.h include/asm-ia64/linux/bootmem.h bootmem.h
  68.115 +#cp_patch include/linux/bootmem.h include/asm-ia64/linux/bootmem.h bootmem.h
  68.116  cp_patch include/linux/cpumask.h include/asm-ia64/linux/cpumask.h cpumask.h
  68.117  #cp_patch include/linux/dma-mapping.h include/asm-ia64/linux/dma-mapping.h dma-mapping.h
  68.118  softlink include/linux/dma-mapping.h include/asm-ia64/linux/dma-mapping.h
  68.119  #cp_patch include/linux/efi.h include/asm-ia64/linux/efi.h efi.h
  68.120  softlink include/linux/efi.h include/asm-ia64/linux/efi.h
  68.121 -cp_patch include/linux/hardirq.h include/asm-ia64/linux/hardirq.h linuxhardirq.h
  68.122 +cp_patch include/linux/hardirq.h include/asm-ia64/linux/hardirq.h hardirq.h
  68.123  #cp_patch include/linux/init_task.h include/asm-ia64/linux/init_task.h init_task.h
  68.124  cp_patch include/linux/interrupt.h include/asm-ia64/linux/interrupt.h interrupt.h
  68.125 -cp_patch include/linux/mmzone.h include/asm-ia64/linux/mmzone.h mmzone.h
  68.126 +#cp_patch include/linux/mmzone.h include/asm-ia64/linux/mmzone.h mmzone.h
  68.127 +softlink include/linux/mmzone.h include/asm-ia64/linux/mmzone.h
  68.128  
  68.129 -cp_patch include/linux/wait.h include/asm-ia64/linux/wait.h wait.h
  68.130 +#cp_patch include/linux/wait.h include/asm-ia64/linux/wait.h wait.h
  68.131 +softlink include/linux/wait.h include/asm-ia64/linux/wait.h
  68.132  
  68.133 -cp_patch include/linux/slab.h include/asm-ia64/slab.h slab.h
  68.134 +#cp_patch include/linux/slab.h include/asm-ia64/slab.h slab.h
  68.135  
  68.136  # following renamed to avoid conflict
  68.137 -cp_patch include/linux/time.h include/xen/linuxtime.h linuxtime.h
  68.138 +#cp_patch include/linux/time.h include/xen/linuxtime.h linuxtime.h
  68.139 +softlink include/linux/time.h include/asm-ia64/linux/linuxtime.h
  68.140  
  68.141  softlink include/linux/bcd.h include/asm-ia64/linux/bcd.h
  68.142  softlink include/linux/bitmap.h include/asm-ia64/linux/bitmap.h
  68.143 @@ -289,14 +300,15 @@ softlink include/linux/percpu.h include/
  68.144  softlink include/linux/preempt.h include/asm-ia64/linux/preempt.h
  68.145  softlink include/linux/rbtree.h include/asm-ia64/linux/rbtree.h
  68.146  softlink include/linux/rwsem.h include/asm-ia64/linux/rwsem.h
  68.147 -softlink include/linux/seq_file.h include/asm-ia64/linux/seq_file.h
  68.148 -softlink include/linux/serial_core.h include/asm-ia64/linux/serial_core.h
  68.149 +#softlink include/linux/seq_file.h include/asm-ia64/linux/seq_file.h
  68.150 +#softlink include/linux/serial_core.h include/asm-ia64/linux/serial_core.h
  68.151  softlink include/linux/stddef.h include/asm-ia64/linux/stddef.h
  68.152  softlink include/linux/thread_info.h include/asm-ia64/linux/thread_info.h
  68.153  softlink include/linux/threads.h include/asm-ia64/linux/threads.h
  68.154  softlink include/linux/timex.h include/asm-ia64/linux/timex.h
  68.155  softlink include/linux/topology.h include/asm-ia64/linux/topology.h
  68.156 -softlink include/linux/tty.h include/asm-ia64/linux/tty.h
  68.157 +softlink include/linux/seqlock.h include/asm-ia64/linux/seqlock.h
  68.158 +softlink include/linux/jiffies.h include/asm-ia64/linux/jiffies.h
  68.159  
  68.160  null include/asm-ia64/linux/file.h
  68.161  null include/asm-ia64/linux/module.h
  68.162 @@ -305,6 +317,18 @@ null include/asm-ia64/linux/device.h
  68.163  null include/asm-ia64/linux/proc_fs.h
  68.164  null include/asm-ia64/linux/rtc.h
  68.165  null include/asm-ia64/linux/profile.h
  68.166 +null include/asm-ia64/linux/seqlock.h
  68.167 +null include/asm-ia64/linux/smp_lock.h
  68.168 +null include/asm-ia64/linux/tty.h
  68.169 +null include/asm-ia64/linux/kernel_stat.h
  68.170 +null include/asm-ia64/linux/ptrace.h
  68.171 +null include/asm-ia64/linux/random.h
  68.172 +null include/asm-ia64/linux/signal.h
  68.173 +null include/asm-ia64/linux/bootmem.h
  68.174 +null include/asm-ia64/linux/serial.h
  68.175 +null include/asm-ia64/linux/serial_core.h
  68.176 +null include/asm-ia64/linux/seq_file.h
  68.177 +null include/asm-ia64/linux/cpu.h
  68.178  
  68.179  softlink include/linux/byteorder/generic.h include/asm-ia64/linux/byteorder/generic.h
  68.180  softlink include/linux/byteorder/little_endian.h include/asm-ia64/linux/byteorder/little_endian.h
    69.1 --- a/xen/arch/ia64/vcpu.c	Fri Apr 29 16:49:15 2005 +0000
    69.2 +++ b/xen/arch/ia64/vcpu.c	Tue May 03 08:08:47 2005 +0000
    69.3 @@ -394,7 +394,10 @@ IA64FAULT vcpu_get_iim(VCPU *vcpu, UINT6
    69.4  
    69.5  IA64FAULT vcpu_get_iha(VCPU *vcpu, UINT64 *pval)
    69.6  {
    69.7 -	return vcpu_thash(vcpu,PSCB(vcpu,ifa),pval);
    69.8 +	//return vcpu_thash(vcpu,PSCB(vcpu,ifa),pval);
    69.9 +	UINT64 val = PSCB(vcpu,iha);
   69.10 +	*pval = val;
   69.11 +	return (IA64_NO_FAULT);
   69.12  }
   69.13  
   69.14  IA64FAULT vcpu_set_dcr(VCPU *vcpu, UINT64 val)
   69.15 @@ -747,7 +750,8 @@ IA64FAULT vcpu_set_tpr(VCPU *vcpu, UINT6
   69.16  {
   69.17  	if (val & 0xff00) return IA64_RSVDREG_FAULT;
   69.18  	PSCB(vcpu,tpr) = val;
   69.19 -	//PSCB(vcpu,pending_interruption) = 1;
   69.20 +	if (vcpu_check_pending_interrupts(vcpu) != SPURIOUS_VECTOR)
   69.21 +		PSCB(vcpu,pending_interruption) = 1;
   69.22  	return (IA64_NO_FAULT);
   69.23  }
   69.24  
   69.25 @@ -773,6 +777,8 @@ IA64FAULT vcpu_set_eoi(VCPU *vcpu, UINT6
   69.26  		// with interrupts disabled
   69.27  		printf("Trying to EOI interrupt with interrupts enabled\r\n");
   69.28  	}
   69.29 +	if (vcpu_check_pending_interrupts(vcpu) != SPURIOUS_VECTOR)
   69.30 +		PSCB(vcpu,pending_interruption) = 1;
   69.31  //printf("YYYYY vcpu_set_eoi: Successful\n");
   69.32  	return (IA64_NO_FAULT);
   69.33  }
   69.34 @@ -1138,11 +1144,13 @@ IA64FAULT vcpu_thash(VCPU *vcpu, UINT64 
   69.35  	UINT64 VHPT_addr = VHPT_addr1 | ((VHPT_addr2a | VHPT_addr2b) << 15) |
   69.36  			VHPT_addr3;
   69.37  
   69.38 +#if 0
   69.39  	if (VHPT_addr1 == 0xe000000000000000L) {
   69.40  	    printf("vcpu_thash: thash unsupported with rr7 @%lx\n",
   69.41  		PSCB(vcpu,iip));
   69.42  	    return (IA64_ILLOP_FAULT);
   69.43  	}
   69.44 +#endif
   69.45  //verbose("vcpu_thash: vadr=%p, VHPT_addr=%p\n",vadr,VHPT_addr);
   69.46  	*pval = VHPT_addr;
   69.47  	return (IA64_NO_FAULT);
    70.1 --- a/xen/arch/ia64/vhpt.c	Fri Apr 29 16:49:15 2005 +0000
    70.2 +++ b/xen/arch/ia64/vhpt.c	Tue May 03 08:08:47 2005 +0000
    70.3 @@ -21,7 +21,20 @@ void vhpt_flush(void)
    70.4  {
    70.5  	struct vhpt_lf_entry *v = (void *)VHPT_ADDR;
    70.6  	int i, cnt = 0;
    70.7 +#if 0
    70.8 +static int firsttime = 2;
    70.9  
   70.10 +if (firsttime) firsttime--;
   70.11 +else {
   70.12 +printf("vhpt_flush: *********************************************\n");
   70.13 +printf("vhpt_flush: *********************************************\n");
   70.14 +printf("vhpt_flush: *********************************************\n");
   70.15 +printf("vhpt_flush: flushing vhpt (seems to crash at rid wrap?)...\n");
   70.16 +printf("vhpt_flush: *********************************************\n");
   70.17 +printf("vhpt_flush: *********************************************\n");
   70.18 +printf("vhpt_flush: *********************************************\n");
   70.19 +}
   70.20 +#endif
   70.21  	for (i = 0; i < VHPT_NUM_ENTRIES; i++, v++) {
   70.22  		v->itir = 0;
   70.23  		v->CChain = 0;
    71.1 --- a/xen/arch/ia64/xenasm.S	Fri Apr 29 16:49:15 2005 +0000
    71.2 +++ b/xen/arch/ia64/xenasm.S	Tue May 03 08:08:47 2005 +0000
    71.3 @@ -190,7 +190,6 @@ 1:
    71.4  
    71.5  	movl r22=SHAREDINFO_ADDR
    71.6  	;;
    71.7 -	movl r25=PAGE_SHARED
    71.8  	movl r25=__pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RW)
    71.9  	;;
   71.10  	mov r21=loc5			// saved sharedinfo physical address
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/xen/arch/ia64/xenirq.c	Tue May 03 08:08:47 2005 +0000
    72.3 @@ -0,0 +1,77 @@
    72.4 +/*
    72.5 + * Xen irq routines
    72.6 + *
    72.7 + * Copyright (C) 2005 Hewlett-Packard Co.
    72.8 + *	Dan Magenheimer (dan.magenheimer@hp.com)
    72.9 + *
   72.10 + */
   72.11 +
   72.12 +#include <asm/ptrace.h>
   72.13 +#include <asm/hw_irq.h>
   72.14 +
   72.15 +
   72.16 +void
   72.17 +xen_debug_irq(ia64_vector vector, struct pt_regs *regs)
   72.18 +{
   72.19 +//FIXME: For debug only, can be removed
   72.20 +	static char firstirq = 1;
   72.21 +	static char firsttime[256];
   72.22 +	static char firstpend[256];
   72.23 +	if (firstirq) {
   72.24 +		int i;
   72.25 +		for (i=0;i<256;i++) firsttime[i] = 1;
   72.26 +		for (i=0;i<256;i++) firstpend[i] = 1;
   72.27 +		firstirq = 0;
   72.28 +	}
   72.29 +	if (firsttime[vector]) {
   72.30 +		printf("**** (entry) First received int on vector=%d,itc=%lx\n",
   72.31 +			(unsigned long) vector, ia64_get_itc());
   72.32 +		firsttime[vector] = 0;
   72.33 +	}
   72.34 +}
   72.35 +
   72.36 +
   72.37 +int
   72.38 +xen_do_IRQ(ia64_vector vector)
   72.39 +{
   72.40 +	if (vector != 0xef) {
   72.41 +		extern void vcpu_pend_interrupt(void *, int);
   72.42 +#if 0
   72.43 +		if (firsttime[vector]) {
   72.44 +			printf("**** (iterate) First received int on vector=%d,itc=%lx\n",
   72.45 +			(unsigned long) vector, ia64_get_itc());
   72.46 +			firsttime[vector] = 0;
   72.47 +		}
   72.48 +		if (firstpend[vector]) {
   72.49 +			printf("**** First pended int on vector=%d,itc=%lx\n",
   72.50 +				(unsigned long) vector,ia64_get_itc());
   72.51 +			firstpend[vector] = 0;
   72.52 +		}
   72.53 +#endif
   72.54 +		//FIXME: TEMPORARY HACK!!!!
   72.55 +		vcpu_pend_interrupt(dom0->exec_domain[0],vector);
   72.56 +		domain_wake(dom0->exec_domain[0]);
   72.57 +		return(1);
   72.58 +	}
   72.59 +	return(0);
   72.60 +}
   72.61 +
   72.62 +/* From linux/kernel/softirq.c */
   72.63 +#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED
   72.64 +# define invoke_softirq()	__do_softirq()
   72.65 +#else
   72.66 +# define invoke_softirq()	do_softirq()
   72.67 +#endif
   72.68 +
   72.69 +/*
   72.70 + * Exit an interrupt context. Process softirqs if needed and possible:
   72.71 + */
   72.72 +void irq_exit(void)
   72.73 +{
   72.74 +	//account_system_vtime(current);
   72.75 +	//sub_preempt_count(IRQ_EXIT_OFFSET);
   72.76 +	if (!in_interrupt() && local_softirq_pending())
   72.77 +		invoke_softirq();
   72.78 +	//preempt_enable_no_resched();
   72.79 +}
   72.80 +/* end from linux/kernel/softirq.c */
    73.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.2 +++ b/xen/arch/ia64/xenmem.c	Tue May 03 08:08:47 2005 +0000
    73.3 @@ -0,0 +1,67 @@
    73.4 +/*
    73.5 + * Xen memory allocator routines
    73.6 + *
    73.7 + * Copyright (C) 2005 Hewlett-Packard Co
    73.8 + *	Dan Magenheimer <dan.magenheimer@hp.com>
    73.9 + * Copyright (C) 2005 Intel Corp.
   73.10 + *
   73.11 + * Routines used by ia64 machines with contiguous (or virtually contiguous)
   73.12 + * memory.
   73.13 + */
   73.14 +
   73.15 +#include <linux/config.h>
   73.16 +#include <asm/pgtable.h>
   73.17 +
   73.18 +extern struct page *zero_page_memmap_ptr;
   73.19 +struct pfn_info *frame_table;
   73.20 +unsigned long frame_table_size;
   73.21 +unsigned long max_page;
   73.22 +
   73.23 +struct page *mem_map;
   73.24 +#define MAX_DMA_ADDRESS ~0UL	// FIXME???
   73.25 +
   73.26 +#ifdef CONFIG_VIRTUAL_MEM_MAP
   73.27 +static unsigned long num_dma_physpages;
   73.28 +#endif
   73.29 +
   73.30 +/*
   73.31 + * Set up the page tables.
   73.32 + */
   73.33 +
   73.34 +void
   73.35 +paging_init (void)
   73.36 +{
   73.37 +	struct pfn_info *pg;
   73.38 +	/* Allocate and map the machine-to-phys table */
   73.39 +	if ((pg = alloc_domheap_pages(NULL, 10)) == NULL)
   73.40 +		panic("Not enough memory to bootstrap Xen.\n");
   73.41 +	memset(page_to_virt(pg), 0x55, 16UL << 20);
   73.42 +
   73.43 +	/* Other mapping setup */
   73.44 +
   73.45 +	zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
   73.46 +}
   73.47 +
   73.48 +/* FIXME: postpone support to machines with big holes between physical memorys.
   73.49 + * Current hack allows only efi memdesc upto 4G place. (See efi.c)
   73.50 + */
   73.51 +#ifndef CONFIG_VIRTUAL_MEM_MAP
   73.52 +#define FT_ALIGN_SIZE	(16UL << 20)
   73.53 +void __init init_frametable(void)
   73.54 +{
   73.55 +	unsigned long i, p;
   73.56 +	frame_table_size = max_page * sizeof(struct pfn_info);
   73.57 +	frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
   73.58 +
   73.59 +	/* Request continuous trunk from boot allocator, since HV
   73.60 +	 * address is identity mapped */
   73.61 +	p = alloc_boot_pages(frame_table_size, FT_ALIGN_SIZE);
   73.62 +	if (p == 0)
   73.63 +		panic("Not enough memory for frame table.\n");
   73.64 +
   73.65 +	frame_table = __va(p);
   73.66 +	memset(frame_table, 0, frame_table_size);
   73.67 +	printk("size of frame_table: %lukB\n",
   73.68 +		frame_table_size >> 10);
   73.69 +}
   73.70 +#endif
    74.1 --- a/xen/arch/ia64/xenmisc.c	Fri Apr 29 16:49:15 2005 +0000
    74.2 +++ b/xen/arch/ia64/xenmisc.c	Tue May 03 08:08:47 2005 +0000
    74.3 @@ -27,7 +27,13 @@ unsigned int watchdog_on = 0;	// from ar
    74.4  
    74.5  void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n"); }
    74.6  void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); }
    74.7 -void hpsim_setup(char **x) { printf("hpsim_setup() skipped (MAY NEED FOR CONSOLE INPUT!!!)\n"); }	
    74.8 +void ia64_mca_cpu_init(void *x) { }
    74.9 +void ia64_patch_mckinley_e9(unsigned long a, unsigned long b) { }
   74.10 +void ia64_patch_vtop(unsigned long a, unsigned long b) { }
   74.11 +void hpsim_setup(char **x) { }
   74.12 +
   74.13 +// called from mem_init... don't think s/w I/O tlb is needed in Xen
   74.14 +//void swiotlb_init(void) { }  ...looks like it IS needed
   74.15  
   74.16  long
   74.17  is_platform_hp_ski(void)
   74.18 @@ -237,17 +243,74 @@ void physdev_destroy_state(struct domain
   74.19  	dummy();
   74.20  }
   74.21  
   74.22 +///////////////////////////////
   74.23 +// called from arch/ia64/head.S
   74.24 +///////////////////////////////
   74.25 +
   74.26 +void console_print(char *msg)
   74.27 +{
   74.28 +	printk("console_print called, how did start_kernel return???\n");
   74.29 +}
   74.30 +
   74.31 +void kernel_thread_helper(void)
   74.32 +{
   74.33 +	printk("kernel_thread_helper not implemented\n");
   74.34 +	dummy();
   74.35 +}
   74.36 +
   74.37 +void sys_exit(void)
   74.38 +{
   74.39 +	printk("sys_exit not implemented\n");
   74.40 +	dummy();
   74.41 +}
   74.42 +
   74.43 +////////////////////////////////////
   74.44 +// called from unaligned.c
   74.45 +////////////////////////////////////
   74.46 +
   74.47 +void die_if_kernel(char *str, struct pt_regs *regs, long err) /* __attribute__ ((noreturn)) */
   74.48 +{
   74.49 +	printk("die_if_kernel: called, not implemented\n");
   74.50 +}
   74.51 +
   74.52 +long
   74.53 +ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
   74.54 +	   unsigned long user_rbs_end, unsigned long addr, long *val)
   74.55 +{
   74.56 +	printk("ia64_peek: called, not implemented\n");
   74.57 +}
   74.58 +
   74.59 +long
   74.60 +ia64_poke (struct task_struct *child, struct switch_stack *child_stack,
   74.61 +	   unsigned long user_rbs_end, unsigned long addr, long val)
   74.62 +{
   74.63 +	printk("ia64_poke: called, not implemented\n");
   74.64 +}
   74.65 +
   74.66 +void
   74.67 +ia64_sync_fph (struct task_struct *task)
   74.68 +{
   74.69 +	printk("ia64_sync_fph: called, not implemented\n");
   74.70 +}
   74.71 +
   74.72 +void
   74.73 +ia64_flush_fph (struct task_struct *task)
   74.74 +{
   74.75 +	printk("ia64_flush_fph: called, not implemented\n");
   74.76 +}
   74.77 +
   74.78 +////////////////////////////////////
   74.79 +// called from irq_ia64.c:init_IRQ()
   74.80 +//   (because CONFIG_IA64_HP_SIM is specified)
   74.81 +////////////////////////////////////
   74.82 +void hpsim_irq_init(void) { }
   74.83 +
   74.84 +
   74.85  // accomodate linux extable.c
   74.86  //const struct exception_table_entry *
   74.87 -void *search_module_extables(unsigned long addr)
   74.88 -{
   74.89 -	return NULL;
   74.90 -}
   74.91 -
   74.92 -void *module_text_address(unsigned long addr)
   74.93 -{
   74.94 -	return NULL;
   74.95 -}
   74.96 +void *search_module_extables(unsigned long addr) { return NULL; }
   74.97 +void *__module_text_address(unsigned long addr) { return NULL; }
   74.98 +void *module_text_address(unsigned long addr) { return NULL; }
   74.99  
  74.100  void cs10foo(void) {}
  74.101  void cs01foo(void) {}
    75.1 --- a/xen/arch/ia64/xensetup.c	Fri Apr 29 16:49:15 2005 +0000
    75.2 +++ b/xen/arch/ia64/xensetup.c	Tue May 03 08:08:47 2005 +0000
    75.3 @@ -1,13 +1,9 @@
    75.4  /******************************************************************************
    75.5 - * kernel.c
    75.6 - * 
    75.7 - * This file should contain architecture-independent bootstrap and low-level
    75.8 - * help routines. It's a bit x86/PC specific right now!
    75.9 - * 
   75.10 - * Copyright (c) 2002-2003 K A Fraser
   75.11 + * xensetup.c
   75.12 + * Copyright (c) 2004-2005  Hewlett-Packard Co
   75.13 + *         Dan Magenheimer <dan.magenheimer@hp.com>
   75.14   */
   75.15  
   75.16 -//#include <stdarg.h>
   75.17  #include <xen/config.h>
   75.18  #include <xen/lib.h>
   75.19  #include <xen/errno.h>
   75.20 @@ -20,16 +16,14 @@
   75.21  //#include <xen/console.h>
   75.22  //#include <xen/serial.h>
   75.23  #include <xen/trace.h>
   75.24 -//#include <asm/shadow.h>
   75.25 -//#include <asm/io.h>
   75.26 -//#include <asm/uaccess.h>
   75.27 -//#include <asm/domain_page.h>
   75.28 -//#include <public/dom0_ops.h>
   75.29  #include <asm/meminit.h>
   75.30  #include <asm/page.h>
   75.31 +#include <asm/setup.h>
   75.32  
   75.33  unsigned long xenheap_phys_end;
   75.34  
   75.35 +char saved_command_line[COMMAND_LINE_SIZE];
   75.36 +
   75.37  struct exec_domain *idle_task[NR_CPUS] = { &idle0_exec_domain };
   75.38  
   75.39  #ifdef CLONE_DOMAIN0
   75.40 @@ -84,7 +78,7 @@ char opt_physdev_dom0_hide[200] = "";
   75.41  char opt_leveltrigger[30] = "", opt_edgetrigger[30] = "";
   75.42  /*
   75.43   * opt_xenheap_megabytes: Size of Xen heap in megabytes, including:
   75.44 - * 	xen image
   75.45 + *	xen image
   75.46   *	bootmap bits
   75.47   *	xen heap
   75.48   * Note: To allow xenheap size configurable, the prerequisite is
   75.49 @@ -147,10 +141,9 @@ static void __init do_initcalls(void)
   75.50          (*call)();
   75.51  }
   75.52  
   75.53 -void cmain(multiboot_info_t *mbi)
   75.54 +void start_kernel(void)
   75.55  {
   75.56      unsigned char *cmdline;
   75.57 -    module_t *mod = (module_t *)__va(mbi->mods_addr);
   75.58      void *heap_start;
   75.59      int i;
   75.60      unsigned long max_mem, nr_pages, firsthole_start;
   75.61 @@ -162,7 +155,8 @@ void cmain(multiboot_info_t *mbi)
   75.62      xen_pstart = ia64_tpa(KERNEL_START);
   75.63  
   75.64      /* Must do this early -- e.g., spinlocks rely on get_current(). */
   75.65 -    set_current(&idle0_exec_domain);
   75.66 +    //set_current(&idle0_exec_domain);
   75.67 +    ia64_r13 = (void *)&idle0_exec_domain;
   75.68      idle0_exec_domain.domain = &idle0_domain;
   75.69  
   75.70      early_setup_arch(&cmdline);
   75.71 @@ -170,7 +164,7 @@ void cmain(multiboot_info_t *mbi)
   75.72      /* We initialise the serial devices very early so we can get debugging. */
   75.73      serial_init_stage1();
   75.74  
   75.75 -    init_console(); 
   75.76 +    init_console();
   75.77      set_printk_prefix("(XEN) ");
   75.78  
   75.79      /* xenheap should be in same TR-covered range with xen image */
   75.80 @@ -201,7 +195,7 @@ void cmain(multiboot_info_t *mbi)
   75.81  	   ia64_boot_param->initrd_size);
   75.82      ia64_boot_param->initrd_start = initial_images_start;
   75.83      printk("Done\n");
   75.84 -    
   75.85 +
   75.86      /* first find highest page frame number */
   75.87      max_page = 0;
   75.88      efi_memmap_walk(find_max_pfn, &max_page);
   75.89 @@ -217,7 +211,7 @@ void cmain(multiboot_info_t *mbi)
   75.90      efi_memmap_walk(filter_rsvd_memory, init_boot_pages);
   75.91      efi_memmap_walk(xen_count_pages, &nr_pages);
   75.92  
   75.93 -    printk("System RAM: %luMB (%lukB)\n", 
   75.94 +    printk("System RAM: %luMB (%lukB)\n",
   75.95  	nr_pages >> (20 - PAGE_SHIFT),
   75.96  	nr_pages << (PAGE_SHIFT - 10));
   75.97  
   75.98 @@ -235,15 +229,15 @@ void cmain(multiboot_info_t *mbi)
   75.99  	(xenheap_phys_end-__pa(heap_start)) >> 20,
  75.100  	(xenheap_phys_end-__pa(heap_start)) >> 10);
  75.101  
  75.102 -    setup_arch();
  75.103 +    late_setup_arch(&cmdline);
  75.104      setup_per_cpu_areas();
  75.105      mem_init();
  75.106  
  75.107  printk("About to call scheduler_init()\n");
  75.108      scheduler_init();
  75.109      local_irq_disable();
  75.110 -printk("About to call time_init()\n");
  75.111 -    time_init();
  75.112 +printk("About to call xen_time_init()\n");
  75.113 +    xen_time_init();
  75.114  printk("About to call ac_timer_init()\n");
  75.115      ac_timer_init();
  75.116  // init_xen_time(); ???
  75.117 @@ -267,7 +261,7 @@ printk("About to call init_idle_task()\n
  75.118      {
  75.119      int i;
  75.120      for (i = 0; i < CLONE_DOMAIN0; i++) {
  75.121 -    	clones[i] = do_createdomain(i+1, 0);
  75.122 +	clones[i] = do_createdomain(i+1, 0);
  75.123          if ( clones[i] == NULL )
  75.124              panic("Error creating domain0 clone %d\n",i);
  75.125      }
  75.126 @@ -278,9 +272,6 @@ printk("About to call init_idle_task()\n
  75.127  
  75.128      set_bit(DF_PRIVILEGED, &dom0->d_flags);
  75.129  
  75.130 -//printk("About to call shadow_mode_init()\n");
  75.131 -//    shadow_mode_init();
  75.132 -
  75.133      /*
  75.134       * We're going to setup domain0 using the module(s) that we stashed safely
  75.135       * above our heap. The second module, if present, is an initrd ramdisk.
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/xen/arch/ia64/xentime.c	Tue May 03 08:08:47 2005 +0000
    76.3 @@ -0,0 +1,204 @@
    76.4 +/*
    76.5 + * xen/arch/ia64/time.c
    76.6 + *
    76.7 + * Copyright (C) 2005 Hewlett-Packard Co
    76.8 + *	Dan Magenheimer <dan.magenheimer@hp.com>
    76.9 + */
   76.10 +
   76.11 +#include <linux/config.h>
   76.12 +
   76.13 +#include <linux/cpu.h>
   76.14 +#include <linux/init.h>
   76.15 +#include <linux/kernel.h>
   76.16 +#include <linux/module.h>
   76.17 +#include <linux/profile.h>
   76.18 +#include <linux/sched.h>
   76.19 +#include <linux/time.h>
   76.20 +#include <linux/interrupt.h>
   76.21 +#include <linux/efi.h>
   76.22 +#include <linux/profile.h>
   76.23 +#include <linux/timex.h>
   76.24 +
   76.25 +#include <asm/machvec.h>
   76.26 +#include <asm/delay.h>
   76.27 +#include <asm/hw_irq.h>
   76.28 +#include <asm/ptrace.h>
   76.29 +#include <asm/sal.h>
   76.30 +#include <asm/sections.h>
   76.31 +#include <asm/system.h>
   76.32 +#ifdef XEN
   76.33 +#include <linux/jiffies.h>	// not included by xen/sched.h
   76.34 +#endif
   76.35 +
   76.36 +#define TIME_KEEPER_ID  0
   76.37 +extern unsigned long wall_jiffies;
   76.38 +
   76.39 +static s_time_t        stime_irq;       /* System time at last 'time update' */
   76.40 +
   76.41 +unsigned long domain0_ready = 0;
   76.42 +
   76.43 +static inline u64 get_time_delta(void)
   76.44 +{
   76.45 +	return ia64_get_itc();
   76.46 +}
   76.47 +
   76.48 +s_time_t get_s_time(void)
   76.49 +{
   76.50 +    s_time_t now;
   76.51 +    unsigned long flags;
   76.52 +
   76.53 +    read_lock_irqsave(&xtime_lock, flags);
   76.54 +
   76.55 +    now = stime_irq + get_time_delta();
   76.56 +
   76.57 +    /* Ensure that the returned system time is monotonically increasing. */
   76.58 +    {
   76.59 +        static s_time_t prev_now = 0;
   76.60 +        if ( unlikely(now < prev_now) )
   76.61 +            now = prev_now;
   76.62 +        prev_now = now;
   76.63 +    }
   76.64 +
   76.65 +    read_unlock_irqrestore(&xtime_lock, flags);
   76.66 +
   76.67 +    return now; 
   76.68 +}
   76.69 +
   76.70 +void update_dom_time(struct exec_domain *ed)
   76.71 +{
   76.72 +// FIXME: implement this?
   76.73 +//	printf("update_dom_time: called, not implemented, skipping\n");
   76.74 +	return;
   76.75 +}
   76.76 +
   76.77 +/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
   76.78 +void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
   76.79 +{
   76.80 +// FIXME: Should this be do_settimeofday (from linux)???
   76.81 +	printf("do_settime: called, not implemented, stopping\n");
   76.82 +	dummy();
   76.83 +}
   76.84 +
   76.85 +irqreturn_t
   76.86 +xen_timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
   76.87 +{
   76.88 +	unsigned long new_itm;
   76.89 +
   76.90 +#ifndef XEN
   76.91 +	if (unlikely(cpu_is_offline(smp_processor_id()))) {
   76.92 +		return IRQ_HANDLED;
   76.93 +	}
   76.94 +#endif
   76.95 +#ifdef XEN
   76.96 +	if (current->domain == dom0) {
   76.97 +		// FIXME: there's gotta be a better way of doing this...
   76.98 +		// We have to ensure that domain0 is launched before we
   76.99 +		// call vcpu_timer_expired on it
  76.100 +		//domain0_ready = 1; // moved to xensetup.c
  76.101 +		current->vcpu_info->arch.pending_interruption = 1;
  76.102 +	}
  76.103 +	if (domain0_ready && vcpu_timer_expired(dom0->exec_domain[0])) {
  76.104 +		vcpu_pend_timer(dom0->exec_domain[0]);
  76.105 +		//vcpu_set_next_timer(dom0->exec_domain[0]);
  76.106 +		domain_wake(dom0->exec_domain[0]);
  76.107 +	}
  76.108 +	if (!is_idle_task(current->domain) && current->domain != dom0) {
  76.109 +		if (vcpu_timer_expired(current)) {
  76.110 +			vcpu_pend_timer(current);
  76.111 +			// ensure another timer interrupt happens even if domain doesn't
  76.112 +			vcpu_set_next_timer(current);
  76.113 +			domain_wake(current);
  76.114 +		}
  76.115 +	}
  76.116 +	raise_actimer_softirq();
  76.117 +#endif
  76.118 +
  76.119 +#ifndef XEN
  76.120 +	platform_timer_interrupt(irq, dev_id, regs);
  76.121 +#endif
  76.122 +
  76.123 +	new_itm = local_cpu_data->itm_next;
  76.124 +
  76.125 +	if (!time_after(ia64_get_itc(), new_itm))
  76.126 +#ifdef XEN
  76.127 +		return;
  76.128 +#else
  76.129 +		printk(KERN_ERR "Oops: timer tick before it's due (itc=%lx,itm=%lx)\n",
  76.130 +		       ia64_get_itc(), new_itm);
  76.131 +#endif
  76.132 +
  76.133 +#ifdef XEN
  76.134 +//	printf("GOT TO HERE!!!!!!!!!!!\n");
  76.135 +	//while(1);
  76.136 +#else
  76.137 +	profile_tick(CPU_PROFILING, regs);
  76.138 +#endif
  76.139 +
  76.140 +	while (1) {
  76.141 +#ifndef XEN
  76.142 +		update_process_times(user_mode(regs));
  76.143 +#endif
  76.144 +
  76.145 +		new_itm += local_cpu_data->itm_delta;
  76.146 +
  76.147 +		if (smp_processor_id() == TIME_KEEPER_ID) {
  76.148 +			/*
  76.149 +			 * Here we are in the timer irq handler. We have irqs locally
  76.150 +			 * disabled, but we don't know if the timer_bh is running on
  76.151 +			 * another CPU. We need to avoid to SMP race by acquiring the
  76.152 +			 * xtime_lock.
  76.153 +			 */
  76.154 +#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
  76.155 +			write_seqlock(&xtime_lock);
  76.156 +#endif
  76.157 +#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
  76.158 +			do_timer(regs);
  76.159 +#endif
  76.160 +			local_cpu_data->itm_next = new_itm;
  76.161 +#ifdef TURN_ME_OFF_FOR_NOW_IA64_XEN
  76.162 +			write_sequnlock(&xtime_lock);
  76.163 +#endif
  76.164 +		} else
  76.165 +			local_cpu_data->itm_next = new_itm;
  76.166 +
  76.167 +		if (time_after(new_itm, ia64_get_itc()))
  76.168 +			break;
  76.169 +	}
  76.170 +
  76.171 +	do {
  76.172 +		/*
  76.173 +		 * If we're too close to the next clock tick for
  76.174 +		 * comfort, we increase the safety margin by
  76.175 +		 * intentionally dropping the next tick(s).  We do NOT
  76.176 +		 * update itm.next because that would force us to call
  76.177 +		 * do_timer() which in turn would let our clock run
  76.178 +		 * too fast (with the potentially devastating effect
  76.179 +		 * of losing monotony of time).
  76.180 +		 */
  76.181 +		while (!time_after(new_itm, ia64_get_itc() + local_cpu_data->itm_delta/2))
  76.182 +			new_itm += local_cpu_data->itm_delta;
  76.183 +//#ifdef XEN
  76.184 +//		vcpu_set_next_timer(current);
  76.185 +//#else
  76.186 +//printf("***** timer_interrupt: Setting itm to %lx\n",new_itm);
  76.187 +		ia64_set_itm(new_itm);
  76.188 +//#endif
  76.189 +		/* double check, in case we got hit by a (slow) PMI: */
  76.190 +	} while (time_after_eq(ia64_get_itc(), new_itm));
  76.191 +	return IRQ_HANDLED;
  76.192 +}
  76.193 +
  76.194 +static struct irqaction xen_timer_irqaction = {
  76.195 +	.handler =	xen_timer_interrupt,
  76.196 +#ifndef XEN
  76.197 +	.flags =	SA_INTERRUPT,
  76.198 +#endif
  76.199 +	.name =		"timer"
  76.200 +};
  76.201 +
  76.202 +void __init
  76.203 +xen_time_init (void)
  76.204 +{
  76.205 +	register_percpu_irq(IA64_TIMER_VECTOR, &xen_timer_irqaction);
  76.206 +	ia64_init_itm();
  76.207 +}
    77.1 --- a/xen/include/asm-ia64/config.h	Fri Apr 29 16:49:15 2005 +0000
    77.2 +++ b/xen/include/asm-ia64/config.h	Tue May 03 08:08:47 2005 +0000
    77.3 @@ -14,8 +14,6 @@
    77.4  // needed by include/asm-ia64/page.h
    77.5  #define	CONFIG_IA64_PAGE_SIZE_16KB	// 4KB doesn't work?!?
    77.6  #define	CONFIG_IA64_GRANULE_16MB
    77.7 -// needed in arch/ia64/setup.c to reserve memory for domain0
    77.8 -#define CONFIG_BLK_DEV_INITRD
    77.9  
   77.10  #ifndef __ASSEMBLY__
   77.11  
   77.12 @@ -116,6 +114,9 @@ struct page;
   77.13  // avoid redefining task_t in asm/thread_info.h
   77.14  #define task_t	struct domain
   77.15  
   77.16 +// avoid redefining task_struct in asm/current.h
   77.17 +#define task_struct exec_domain
   77.18 +
   77.19  // linux/include/asm-ia64/machvec.h (linux/arch/ia64/lib/io.c)
   77.20  #define platform_inb	__ia64_inb
   77.21  #define platform_inw	__ia64_inw
   77.22 @@ -131,8 +132,10 @@ struct page;
   77.23  #undef ____cacheline_aligned
   77.24  #undef ____cacheline_aligned_in_smp
   77.25  #define __cacheline_aligned
   77.26 +#define __cacheline_aligned_in_smp
   77.27  #define ____cacheline_aligned
   77.28  #define ____cacheline_aligned_in_smp
   77.29 +#define ____cacheline_maxaligned_in_smp
   77.30  
   77.31  #include "asm/types.h"	// for u64
   77.32  struct device {
   77.33 @@ -177,8 +180,6 @@ struct pci_bus_region {
   77.34  	unsigned long end;
   77.35  };
   77.36  
   77.37 -// from linux/include/linux/module.h
   77.38 -
   77.39  // warning: unless search_extable is declared, the return value gets
   77.40  // truncated to 32-bits, causing a very strange error in privop handling
   77.41  struct exception_table_entry;
   77.42 @@ -221,18 +222,47 @@ void sort_main_extable(void);
   77.43  // FIXME following needs work
   77.44  #define atomic_compareandswap(old, new, v) old
   77.45  
   77.46 -// x86 typedef still used in sched.h, may go away later
   77.47 -//typedef unsigned long l1_pgentry_t;
   77.48 -
   77.49  // see include/asm-ia64/mm.h, handle remaining pfn_info uses until gone
   77.50  #define pfn_info page
   77.51  
   77.52  // see common/keyhandler.c
   77.53  #define	nop()	asm volatile ("nop 0")
   77.54  
   77.55 -#define ARCH_HAS_EXEC_DOMAIN_MM_PTR
   77.56 +// from include/linux/preempt.h (needs including from interrupt.h or smp.h)
   77.57 +#define preempt_enable()	do { } while (0)
   77.58 +#define preempt_disable()	do { } while (0)
   77.59 +
   77.60 +// needed for include/xen/linuxtime.h
   77.61 +typedef s64 time_t;
   77.62 +typedef s64 suseconds_t;
   77.63 +
   77.64 +// needed for include/linux/jiffies.h
   77.65 +typedef long clock_t;
   77.66  
   77.67 -// see arch/x86/nmi.c !?!?
   77.68 +// from include/linux/kernel.h, needed by jiffies.h
   77.69 +#define typecheck(type,x) \
   77.70 +({	type __dummy; \
   77.71 +	typeof(x) __dummy2; \
   77.72 +	(void)(&__dummy == &__dummy2); \
   77.73 +	1; \
   77.74 +})
   77.75 +
   77.76 +// from include/linux/timex.h, needed by arch/ia64/time.c
   77.77 +#define	TIME_SOURCE_CPU 0
   77.78 +
   77.79 +// used in common code
   77.80 +#define softirq_pending(cpu)	(cpu_data(cpu)->softirq_pending)
   77.81 +
   77.82 +// dup'ed from signal.h to avoid changes to includes
   77.83 +#define	SA_SHIRQ	0x04000000
   77.84 +#define	SA_INTERRUPT	0x20000000
   77.85 +
   77.86 +// needed for setup.c
   77.87 +extern unsigned long loops_per_jiffy;
   77.88 +extern char saved_command_line[];
   77.89 +struct screen_info { };
   77.90 +#define seq_printf(a,b...) printf(b)
   77.91 +#define CONFIG_BLK_DEV_INITRD // needed to reserve memory for domain0
   77.92  
   77.93  // these declarations got moved at some point, find a better place for them
   77.94  extern int opt_noht;
   77.95 @@ -251,6 +281,8 @@ extern unsigned int watchdog_on;
   77.96  
   77.97  #undef CONFIG_X86
   77.98  
   77.99 +#define CONFIG_MCKINLEY
  77.100 +
  77.101  //#define CONFIG_SMP 1
  77.102  //#define CONFIG_NR_CPUS 2
  77.103  //leave SMP for a later time
    78.1 --- a/xen/include/asm-x86/debugger.h	Fri Apr 29 16:49:15 2005 +0000
    78.2 +++ b/xen/include/asm-x86/debugger.h	Tue May 03 08:08:47 2005 +0000
    78.3 @@ -42,7 +42,14 @@
    78.4  
    78.5  extern int __trap_to_cdb(struct cpu_user_regs *r);
    78.6  #define debugger_trap_entry(_v, _r) (0)
    78.7 -#define debugger_trap_fatal(_v, _r) __trap_to_cdb(_r)
    78.8 +
    78.9 +static inline int debugger_trap_fatal(
   78.10 +    unsigned int vector, struct cpu_user_regs *regs)
   78.11 +{
   78.12 +    (void)__trap_to_cdb(regs);
   78.13 +    return (vector == TRAP_int3); /* int3 is harmless */
   78.14 +}
   78.15 +
   78.16  /* Int3 is a trivial way to gather cpu_user_regs context. */
   78.17  #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
   78.18  
    79.1 --- a/xen/include/public/arch-ia64.h	Fri Apr 29 16:49:15 2005 +0000
    79.2 +++ b/xen/include/public/arch-ia64.h	Tue May 03 08:08:47 2005 +0000
    79.3 @@ -22,7 +22,7 @@ typedef unsigned long cpureg_t;   /* Ful
    79.4  
    79.5  typedef struct
    79.6  {
    79.7 -} PACKED struct cpu_user_regs;
    79.8 +} PACKED cpu_user_regs;
    79.9  
   79.10  /*
   79.11   * NB. This may become a 64-bit count with no shift. If this happens then the