direct-io.hg

changeset 3328:708bd9c8362b

bitkeeper revision 1.1159.170.64 (41ce8bd3sGsiOUiBHp1KyOcLPmYBgQ)

sync w/ head.
author cl349@arcadians.cl.cam.ac.uk
date Sun Dec 26 10:00:51 2004 +0000 (2004-12-26)
parents 40ee875afa3b f36de623daa0
children 73da7a950ed4
files .rootkeys linux-2.4.28-xen-sparse/arch/xen/kernel/time.c linux-2.4.28-xen-sparse/arch/xen/mm/init.c linux-2.6.10-rc3-xen-sparse/arch/xen/configs/xen0_defconfig linux-2.6.10-rc3-xen-sparse/arch/xen/configs/xenU_defconfig linux-2.6.10-rc3-xen-sparse/arch/xen/i386/Kconfig linux-2.6.10-rc3-xen-sparse/arch/xen/i386/kernel/traps.c linux-2.6.10-rc3-xen-sparse/arch/xen/kernel/reboot.c linux-2.6.10-rc3-xen-sparse/drivers/xen/netback/interface.c tools/libxc/Makefile tools/libxc/plan9a.out.h tools/libxc/xc.h tools/libxc/xc_linux_save.c tools/libxc/xc_plan9_build.c tools/misc/xencons tools/python/xen/lowlevel/xc/xc.c tools/python/xen/util/console_client.py tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/encode.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/domain.py tools/python/xen/xend/server/messages.py tools/python/xen/xend/sxp.py tools/python/xen/xm/main.py tools/python/xen/xm/sysrq.py xen/arch/x86/Rules.mk xen/arch/x86/boot/x86_32.S xen/arch/x86/boot/x86_64.S xen/arch/x86/domain.c xen/arch/x86/setup.c xen/arch/x86/shadow.c xen/arch/x86/smpboot.c xen/arch/x86/traps.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_64/asm-offsets.c xen/arch/x86/x86_64/mm.c xen/arch/x86/x86_64/xen.lds xen/common/domain.c xen/common/physdev.c xen/include/asm-x86/asm_defns.h xen/include/asm-x86/domain.h xen/include/asm-x86/irq.h xen/include/asm-x86/multicall.h xen/include/asm-x86/processor.h xen/include/asm-x86/system.h xen/include/asm-x86/uaccess.h xen/include/asm-x86/x86_32/asm_defns.h xen/include/asm-x86/x86_32/current.h xen/include/asm-x86/x86_32/uaccess.h xen/include/asm-x86/x86_64/asm_defns.h xen/include/asm-x86/x86_64/current.h xen/include/asm-x86/x86_64/uaccess.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h xen/include/public/io/domain_controller.h xen/include/public/trace.h xen/include/xen/domain.h xen/include/xen/sched.h
line diff
     1.1 --- a/.rootkeys	Wed Dec 08 01:30:49 2004 +0000
     1.2 +++ b/.rootkeys	Sun Dec 26 10:00:51 2004 +0000
     1.3 @@ -318,6 +318,7 @@ 40ee75a93cqxHp6MiYXxxwR5j2_8QQ tools/exa
     1.4  41090ec8Pj_bkgCBpg2W7WfmNkumEA tools/examples/xmexample1
     1.5  40cf2937oKlROYOJTN8GWwWM5AmjBg tools/examples/xmexample2
     1.6  3fbba6dbDfYvJSsw9500b4SZyUhxjQ tools/libxc/Makefile
     1.7 +41cc934abX-QLXJXW_clV_wRjM0zYg tools/libxc/plan9a.out.h
     1.8  3fbba6dc1uU7U3IFeF6A-XEOYF2MkQ tools/libxc/rpm.spec
     1.9  3fbba6dcrNxtygEcgJYAJJ1gCQqfsA tools/libxc/xc.h
    1.10  40589968oCfoUlXd460CjVAkBE8IBA tools/libxc/xc_atropos.c
    1.11 @@ -332,6 +333,7 @@ 3fbba6dbl267zZOAVHYLOdLCdhcZMw tools/lib
    1.12  3fbba6db7li3FJiABYtCmuGxOJxEGw tools/libxc/xc_linux_save.c
    1.13  3fbba6db7WnnJr0KFrIFrqNlSKvFYg tools/libxc/xc_misc.c
    1.14  4051bce6CHAsYh8P5t2OHDtRWOP9og tools/libxc/xc_physdev.c
    1.15 +41cc934aO1m6NxEh_8eDr9bJIMoLFA tools/libxc/xc_plan9_build.c
    1.16  3fbba6dctWRWlFJkYb6hdix2X4WMuw tools/libxc/xc_private.c
    1.17  3fbba6dcbVrG2hPzEzwdeV_UC8kydQ tools/libxc/xc_private.h
    1.18  40589968UQFnJeOMn8UIFLbXBuwXjw tools/libxc/xc_rrobin.c
    1.19 @@ -519,6 +521,7 @@ 40cf2937isyS250zyd0Q2GuEDoNXfQ tools/pyt
    1.20  411b2c1ehdEGO_CwG0tvn85Q-Tfh5g tools/python/xen/xm/migrate.py
    1.21  40cf2937PSslwBliN1g7ofDy2H_RhA tools/python/xen/xm/opts.py
    1.22  40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py
    1.23 +41b88ba6_C4---jeA895Efg9YFZgKA tools/python/xen/xm/sysrq.py
    1.24  40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy
    1.25  40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile
    1.26  4120b0e5L_nW-u0MWRfIdXg4ng4OjA tools/sv/images/destroy.png
    1.27 @@ -690,7 +693,9 @@ 3ddb79bcHwuCQDjBICDTSis52hWguw xen/arch/
    1.28  40f92331jfOlE7MfKwpdkEb1CEf23g xen/arch/x86/x86_32/seg_fixup.c
    1.29  3ddb79bc4nTpGQOe6_-MbyZzkhlhFQ xen/arch/x86/x86_32/usercopy.c
    1.30  3ddb79bcOMCu9-5mKpjIh5d0qqBDPg xen/arch/x86/x86_32/xen.lds
    1.31 +41bf1717Ty3hwN3E9swdu8QfnvGqww xen/arch/x86/x86_64/asm-offsets.c
    1.32  40e96d3aLDI-nViMuYneD7VKYlZrVg xen/arch/x86/x86_64/entry.S
    1.33 +41bf1717XhPz_dNT5OKSjgmbFuWBuA xen/arch/x86/x86_64/mm.c
    1.34  40e96d3ahBTZqbTViInnq0lM03vs7A xen/arch/x86/x86_64/usercopy.c
    1.35  40e96d3akN3Hu_J5Bk-WXD8OGscrYQ xen/arch/x86/x86_64/xen.lds
    1.36  3ddb79bdff-gj-jFGKjOejeHLqL8Lg xen/common/Makefile
    1.37 @@ -778,6 +783,7 @@ 40715b2d1yZkqyAt0kgx2xEwsatuuA xen/inclu
    1.38  40715b2dWe0tDhx9LkLXzTQkvD49RA xen/include/asm-x86/acpi.h
    1.39  3ddb79c3l4IiQtf6MS2jIzcd-hJS8g xen/include/asm-x86/apic.h
    1.40  3ddb79c3QJYWr8LLGdonLbWmNb9pQQ xen/include/asm-x86/apicdef.h
    1.41 +41bf17171g_hhz2k4B-fN9LQlODDjQ xen/include/asm-x86/asm_defns.h
    1.42  3ddb79c3OiG9eTsi9Dy3F_OkuRAzKA xen/include/asm-x86/atomic.h
    1.43  3ddb79c3rM-Ote0Xn6Ytg8Y6YqAG-A xen/include/asm-x86/bitops.h
    1.44  3ddb79c3KhTI0F_Iw_hRL9QEyOVK-g xen/include/asm-x86/cache.h
    1.45 @@ -789,7 +795,6 @@ 3ddb79c2jFkPAZTDmU35L6IUssYMgQ xen/inclu
    1.46  3ddb79c3r9-31dIsewPV3P3i8HALsQ xen/include/asm-x86/delay.h
    1.47  3ddb79c34BFiXjBJ_cCKB0aCsV1IDw xen/include/asm-x86/desc.h
    1.48  40715b2dTokMLYGSuD58BnxOqyWVew xen/include/asm-x86/div64.h
    1.49 -40f2b4a2hC3HtChu-ArD8LyojxWMjg xen/include/asm-x86/domain.h
    1.50  3e20b82fl1jmQiKdLy7fxMcutfpjWA xen/include/asm-x86/domain_page.h
    1.51  3ddb79c3NU8Zy40OTrq3D-i30Y3t4A xen/include/asm-x86/fixmap.h
    1.52  3e2d29944GI24gf7vOP_7x8EyuqxeA xen/include/asm-x86/flushtlb.h
    1.53 @@ -825,6 +830,7 @@ 3ddb79c2ADvRmdexd9y3AYK9_NTx-Q xen/inclu
    1.54  3ddb79c3mbqEM7QQr3zVq7NiBNhouA xen/include/asm-x86/x86_32/regs.h
    1.55  3e7f358aG11EvMI9VJ4_9hD4LUO7rQ xen/include/asm-x86/x86_32/string.h
    1.56  3ddb79c3M2n1ROZH6xk3HbyN4CPDqg xen/include/asm-x86/x86_32/uaccess.h
    1.57 +41bf1717bML6GxpclTWJabiaO5W5vg xen/include/asm-x86/x86_64/asm_defns.h
    1.58  404f1b9ceJeGVaPNIENm2FkK0AgEOQ xen/include/asm-x86/x86_64/current.h
    1.59  404f1b9fl6AQ_a-T1TDK3fuwTPXmHw xen/include/asm-x86/x86_64/desc.h
    1.60  404f1badfXZJZ2sU8sh9PS2EZvd19Q xen/include/asm-x86/x86_64/ldt.h
    1.61 @@ -852,6 +858,7 @@ 3ddb79c259jh8hE7vre_8NuE7nwNSA xen/inclu
    1.62  3eb165e0eawr3R-p2ZQtSdLWtLRN_A xen/include/xen/console.h
    1.63  3ddb79c1V44RD26YqCUm-kqIupM37A xen/include/xen/ctype.h
    1.64  3ddb79c05DdHQ0UxX_jKsXdR4QlMCA xen/include/xen/delay.h
    1.65 +40f2b4a2hC3HtChu-ArD8LyojxWMjg xen/include/xen/domain.h
    1.66  3ddb79c2O729EttZTYu1c8LcsUO_GQ xen/include/xen/elf.h
    1.67  3ddb79c0HIghfBF8zFUdmXhOU8i6hA xen/include/xen/errno.h
    1.68  3ddb79c1W0lQca8gRV7sN6j3iY4Luw xen/include/xen/event.h
     2.1 --- a/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c	Wed Dec 08 01:30:49 2004 +0000
     2.2 +++ b/linux-2.4.28-xen-sparse/arch/xen/kernel/time.c	Sun Dec 26 10:00:51 2004 +0000
     2.3 @@ -99,6 +99,10 @@ static u64 processed_system_time;   /* S
     2.4  
     2.5  #define NS_PER_TICK (1000000000ULL/HZ)
     2.6  
     2.7 +#ifndef NSEC_PER_SEC
     2.8 +#define NSEC_PER_SEC (1000000000L)
     2.9 +#endif
    2.10 +
    2.11  #define HANDLE_USEC_UNDERFLOW(_tv)         \
    2.12      do {                                   \
    2.13          while ( (_tv).tv_usec < 0 )        \
    2.14 @@ -115,6 +119,17 @@ static u64 processed_system_time;   /* S
    2.15              (_tv).tv_sec++;                \
    2.16          }                                  \
    2.17      } while ( 0 )
    2.18 +static inline void __normalize_time(time_t *sec, s64 *nsec)
    2.19 +{
    2.20 +	while (*nsec >= NSEC_PER_SEC) {
    2.21 +		(*nsec) -= NSEC_PER_SEC;
    2.22 +		(*sec)++;
    2.23 +	}
    2.24 +	while (*nsec < 0) {
    2.25 +		(*nsec) += NSEC_PER_SEC;
    2.26 +		(*sec)--;
    2.27 +	}
    2.28 +}
    2.29  
    2.30  /* Dynamically-mapped IRQs. */
    2.31  static int time_irq, debug_irq;
    2.32 @@ -256,6 +271,7 @@ void do_gettimeofday(struct timeval *tv)
    2.33  {
    2.34      unsigned long flags, lost;
    2.35      struct timeval _tv;
    2.36 +    s64 nsec;
    2.37  
    2.38   again:
    2.39      read_lock_irqsave(&xtime_lock, flags);
    2.40 @@ -266,6 +282,10 @@ void do_gettimeofday(struct timeval *tv)
    2.41      _tv.tv_sec   = xtime.tv_sec;
    2.42      _tv.tv_usec += xtime.tv_usec;
    2.43  
    2.44 +    nsec = shadow_system_time - processed_system_time;
    2.45 +    __normalize_time(&_tv.tv_sec, &nsec);
    2.46 +    _tv.tv_usec += (long)nsec / 1000L;
    2.47 +
    2.48      if ( unlikely(!TIME_VALUES_UP_TO_DATE) )
    2.49      {
    2.50          /*
    2.51 @@ -301,7 +321,8 @@ void do_gettimeofday(struct timeval *tv)
    2.52  void do_settimeofday(struct timeval *tv)
    2.53  {
    2.54      struct timeval newtv;
    2.55 -    suseconds_t usec;
    2.56 +    s64            nsec;
    2.57 +    suseconds_t    usec;
    2.58      
    2.59      if ( !INDEPENDENT_WALLCLOCK() )
    2.60          return;
    2.61 @@ -315,6 +336,11 @@ void do_settimeofday(struct timeval *tv)
    2.62       */
    2.63   again:
    2.64      usec = tv->tv_usec - __get_time_delta_usecs();
    2.65 +
    2.66 +    nsec = shadow_system_time - processed_system_time;
    2.67 +    __normalize_time(&tv->tv_sec, &nsec);
    2.68 +    usec -= (long)nsec / 1000L;
    2.69 +
    2.70      if ( unlikely(!TIME_VALUES_UP_TO_DATE) )
    2.71      {
    2.72          __get_time_values_from_xen();
     3.1 --- a/linux-2.4.28-xen-sparse/arch/xen/mm/init.c	Wed Dec 08 01:30:49 2004 +0000
     3.2 +++ b/linux-2.4.28-xen-sparse/arch/xen/mm/init.c	Sun Dec 26 10:00:51 2004 +0000
     3.3 @@ -36,6 +36,10 @@
     3.4  #include <asm/apic.h>
     3.5  #include <asm/tlb.h>
     3.6  
     3.7 +/* XEN: We *cannot* use mmx_clear_page() this early. Force dumb memset(). */
     3.8 +#undef clear_page
     3.9 +#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
    3.10 +
    3.11  mmu_gather_t mmu_gathers[NR_CPUS];
    3.12  unsigned long highstart_pfn, highend_pfn;
    3.13  static unsigned long totalram_pages;
     4.1 --- a/linux-2.6.10-rc3-xen-sparse/arch/xen/configs/xen0_defconfig	Wed Dec 08 01:30:49 2004 +0000
     4.2 +++ b/linux-2.6.10-rc3-xen-sparse/arch/xen/configs/xen0_defconfig	Sun Dec 26 10:00:51 2004 +0000
     4.3 @@ -1,7 +1,7 @@
     4.4  #
     4.5  # Automatically generated make config: don't edit
     4.6  # Linux kernel version: 2.6.10-rc2-xen0
     4.7 -# Wed Dec  1 09:22:49 2004
     4.8 +# Thu Dec 23 14:01:43 2004
     4.9  #
    4.10  CONFIG_XEN=y
    4.11  CONFIG_ARCH_XEN=y
    4.12 @@ -79,6 +79,11 @@ CONFIG_MMU=y
    4.13  CONFIG_UID16=y
    4.14  CONFIG_GENERIC_ISA_DMA=y
    4.15  CONFIG_GENERIC_IOMAP=y
    4.16 +# CONFIG_M386 is not set
    4.17 +# CONFIG_M486 is not set
    4.18 +# CONFIG_M586 is not set
    4.19 +# CONFIG_M586TSC is not set
    4.20 +# CONFIG_M586MMX is not set
    4.21  # CONFIG_M686 is not set
    4.22  # CONFIG_MPENTIUMII is not set
    4.23  # CONFIG_MPENTIUMIII is not set
    4.24 @@ -88,6 +93,9 @@ CONFIG_MPENTIUM4=y
    4.25  # CONFIG_MK7 is not set
    4.26  # CONFIG_MK8 is not set
    4.27  # CONFIG_MCRUSOE is not set
    4.28 +# CONFIG_MWINCHIPC6 is not set
    4.29 +# CONFIG_MWINCHIP2 is not set
    4.30 +# CONFIG_MWINCHIP3D is not set
    4.31  # CONFIG_MCYRIXIII is not set
    4.32  # CONFIG_MVIAC3_2 is not set
    4.33  # CONFIG_X86_GENERIC is not set
     5.1 --- a/linux-2.6.10-rc3-xen-sparse/arch/xen/configs/xenU_defconfig	Wed Dec 08 01:30:49 2004 +0000
     5.2 +++ b/linux-2.6.10-rc3-xen-sparse/arch/xen/configs/xenU_defconfig	Sun Dec 26 10:00:51 2004 +0000
     5.3 @@ -1,7 +1,7 @@
     5.4  #
     5.5  # Automatically generated make config: don't edit
     5.6  # Linux kernel version: 2.6.10-rc2-xenU
     5.7 -# Wed Dec  1 09:22:09 2004
     5.8 +# Thu Dec 23 14:02:24 2004
     5.9  #
    5.10  CONFIG_XEN=y
    5.11  CONFIG_ARCH_XEN=y
    5.12 @@ -78,6 +78,11 @@ CONFIG_MMU=y
    5.13  CONFIG_UID16=y
    5.14  CONFIG_GENERIC_ISA_DMA=y
    5.15  CONFIG_GENERIC_IOMAP=y
    5.16 +# CONFIG_M386 is not set
    5.17 +# CONFIG_M486 is not set
    5.18 +# CONFIG_M586 is not set
    5.19 +# CONFIG_M586TSC is not set
    5.20 +# CONFIG_M586MMX is not set
    5.21  # CONFIG_M686 is not set
    5.22  # CONFIG_MPENTIUMII is not set
    5.23  # CONFIG_MPENTIUMIII is not set
    5.24 @@ -87,6 +92,9 @@ CONFIG_MPENTIUM4=y
    5.25  # CONFIG_MK7 is not set
    5.26  # CONFIG_MK8 is not set
    5.27  # CONFIG_MCRUSOE is not set
    5.28 +# CONFIG_MWINCHIPC6 is not set
    5.29 +# CONFIG_MWINCHIP2 is not set
    5.30 +# CONFIG_MWINCHIP3D is not set
    5.31  # CONFIG_MCYRIXIII is not set
    5.32  # CONFIG_MVIAC3_2 is not set
    5.33  # CONFIG_X86_GENERIC is not set
     6.1 --- a/linux-2.6.10-rc3-xen-sparse/arch/xen/i386/Kconfig	Wed Dec 08 01:30:49 2004 +0000
     6.2 +++ b/linux-2.6.10-rc3-xen-sparse/arch/xen/i386/Kconfig	Sun Dec 26 10:00:51 2004 +0000
     6.3 @@ -32,70 +32,70 @@ choice
     6.4  	prompt "Processor family"
     6.5  	default M686
     6.6  
     6.7 -#config M386
     6.8 -#	bool "386"
     6.9 -#	---help---
    6.10 -#	  This is the processor type of your CPU. This information is used for
    6.11 -#	  optimizing purposes. In order to compile a kernel that can run on
    6.12 -#	  all x86 CPU types (albeit not optimally fast), you can specify
    6.13 -#	  "386" here.
    6.14 -#
    6.15 -#	  The kernel will not necessarily run on earlier architectures than
    6.16 -#	  the one you have chosen, e.g. a Pentium optimized kernel will run on
    6.17 -#	  a PPro, but not necessarily on a i486.
    6.18 -#
    6.19 -#	  Here are the settings recommended for greatest speed:
    6.20 -#	  - "386" for the AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI
    6.21 -#	  486DLC/DLC2, UMC 486SX-S and NexGen Nx586.  Only "386" kernels
    6.22 -#	  will run on a 386 class machine.
    6.23 -#	  - "486" for the AMD/Cyrix/IBM/Intel 486DX/DX2/DX4 or
    6.24 -#	  SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S.
    6.25 -#	  - "586" for generic Pentium CPUs lacking the TSC
    6.26 -#	  (time stamp counter) register.
    6.27 -#	  - "Pentium-Classic" for the Intel Pentium.
    6.28 -#	  - "Pentium-MMX" for the Intel Pentium MMX.
    6.29 -#	  - "Pentium-Pro" for the Intel Pentium Pro.
    6.30 -#	  - "Pentium-II" for the Intel Pentium II or pre-Coppermine Celeron.
    6.31 -#	  - "Pentium-III" for the Intel Pentium III or Coppermine Celeron.
    6.32 -#	  - "Pentium-4" for the Intel Pentium 4 or P4-based Celeron.
    6.33 -#	  - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D).
    6.34 -#	  - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
    6.35 -#	  - "Crusoe" for the Transmeta Crusoe series.
    6.36 +config M386
    6.37 +	bool "386"
    6.38 +	---help---
    6.39 +	  This is the processor type of your CPU. This information is used for
    6.40 +	  optimizing purposes. In order to compile a kernel that can run on
    6.41 +	  all x86 CPU types (albeit not optimally fast), you can specify
    6.42 +	  "386" here.
    6.43 +
    6.44 +	  The kernel will not necessarily run on earlier architectures than
    6.45 +	  the one you have chosen, e.g. a Pentium optimized kernel will run on
    6.46 +	  a PPro, but not necessarily on a i486.
    6.47 +
    6.48 +	  Here are the settings recommended for greatest speed:
    6.49 +	  - "386" for the AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI
    6.50 +	  486DLC/DLC2, UMC 486SX-S and NexGen Nx586.  Only "386" kernels
    6.51 +	  will run on a 386 class machine.
    6.52 +	  - "486" for the AMD/Cyrix/IBM/Intel 486DX/DX2/DX4 or
    6.53 +	  SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S.
    6.54 +	  - "586" for generic Pentium CPUs lacking the TSC
    6.55 +	  (time stamp counter) register.
    6.56 +	  - "Pentium-Classic" for the Intel Pentium.
    6.57 +	  - "Pentium-MMX" for the Intel Pentium MMX.
    6.58 +	  - "Pentium-Pro" for the Intel Pentium Pro.
    6.59 +	  - "Pentium-II" for the Intel Pentium II or pre-Coppermine Celeron.
    6.60 +	  - "Pentium-III" for the Intel Pentium III or Coppermine Celeron.
    6.61 +	  - "Pentium-4" for the Intel Pentium 4 or P4-based Celeron.
    6.62 +	  - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D).
    6.63 +	  - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
    6.64 +	  - "Crusoe" for the Transmeta Crusoe series.
    6.65  #	  - "Efficeon" for the Transmeta Efficeon series.
    6.66 -#	  - "Winchip-C6" for original IDT Winchip.
    6.67 -#	  - "Winchip-2" for IDT Winchip 2.
    6.68 -#	  - "Winchip-2A" for IDT Winchips with 3dNow! capabilities.
    6.69 -#	  - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
    6.70 -#	  - "VIA C3-2 for VIA C3-2 "Nehemiah" (model 9 and above).
    6.71 -#
    6.72 -#	  If you don't know what to do, choose "386".
    6.73 +	  - "Winchip-C6" for original IDT Winchip.
    6.74 +	  - "Winchip-2" for IDT Winchip 2.
    6.75 +	  - "Winchip-2A" for IDT Winchips with 3dNow! capabilities.
    6.76 +	  - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
    6.77 +	  - "VIA C3-2 for VIA C3-2 "Nehemiah" (model 9 and above).
    6.78 +
    6.79 +	  If you don't know what to do, choose "386".
    6.80  
    6.81 -#config M486
    6.82 -#	bool "486"
    6.83 -#	help
    6.84 -#	  Select this for a 486 series processor, either Intel or one of the
    6.85 -#	  compatible processors from AMD, Cyrix, IBM, or Intel.  Includes DX,
    6.86 -#	  DX2, and DX4 variants; also SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or
    6.87 -#	  U5S.
    6.88 +config M486
    6.89 +	bool "486"
    6.90 +	help
    6.91 +	  Select this for a 486 series processor, either Intel or one of the
    6.92 +	  compatible processors from AMD, Cyrix, IBM, or Intel.  Includes DX,
    6.93 +	  DX2, and DX4 variants; also SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or
    6.94 +	  U5S.
    6.95  
    6.96 -#config M586
    6.97 -#	bool "586/K5/5x86/6x86/6x86MX"
    6.98 -#	help
    6.99 -#	  Select this for an 586 or 686 series processor such as the AMD K5,
   6.100 -#	  the Intel 5x86 or 6x86, or the Intel 6x86MX.  This choice does not
   6.101 -#	  assume the RDTSC (Read Time Stamp Counter) instruction.
   6.102 +config M586
   6.103 +	bool "586/K5/5x86/6x86/6x86MX"
   6.104 +	help
   6.105 +	  Select this for an 586 or 686 series processor such as the AMD K5,
   6.106 +	  the Intel 5x86 or 6x86, or the Intel 6x86MX.  This choice does not
   6.107 +	  assume the RDTSC (Read Time Stamp Counter) instruction.
   6.108  
   6.109 -#config M586TSC
   6.110 -#	bool "Pentium-Classic"
   6.111 -#	help
   6.112 -#	  Select this for a Pentium Classic processor with the RDTSC (Read
   6.113 -#	  Time Stamp Counter) instruction for benchmarking.
   6.114 +config M586TSC
   6.115 +	bool "Pentium-Classic"
   6.116 +	help
   6.117 +	  Select this for a Pentium Classic processor with the RDTSC (Read
   6.118 +	  Time Stamp Counter) instruction for benchmarking.
   6.119  
   6.120 -#config M586MMX
   6.121 -#	bool "Pentium-MMX"
   6.122 -#	help
   6.123 -#	  Select this for a Pentium with the MMX graphics/multimedia
   6.124 -#	  extended instructions.
   6.125 +config M586MMX
   6.126 +	bool "Pentium-MMX"
   6.127 +	help
   6.128 +	  Select this for a Pentium with the MMX graphics/multimedia
   6.129 +	  extended instructions.
   6.130  
   6.131  config M686
   6.132  	bool "Pentium-Pro"
   6.133 @@ -164,33 +164,33 @@ config MCRUSOE
   6.134  	  like a 586 with TSC, and sets some GCC optimization flags (like a
   6.135  	  Pentium Pro with no alignment requirements).
   6.136  
   6.137 -#config MEFFICEON
   6.138 -#	bool "Efficeon"
   6.139 -#	help
   6.140 -#	  Select this for a Transmeta Efficeon processor.
   6.141 +config MEFFICEON
   6.142 +	bool "Efficeon"
   6.143 +	help
   6.144 +	  Select this for a Transmeta Efficeon processor.
   6.145  
   6.146 -#config MWINCHIPC6
   6.147 -#	bool "Winchip-C6"
   6.148 -#	help
   6.149 -#	  Select this for an IDT Winchip C6 chip.  Linux and GCC
   6.150 -#	  treat this chip as a 586TSC with some extended instructions
   6.151 -#	  and alignment requirements.
   6.152 +config MWINCHIPC6
   6.153 +	bool "Winchip-C6"
   6.154 +	help
   6.155 +	  Select this for an IDT Winchip C6 chip.  Linux and GCC
   6.156 +	  treat this chip as a 586TSC with some extended instructions
   6.157 +	  and alignment requirements.
   6.158  
   6.159 -#config MWINCHIP2
   6.160 -#	bool "Winchip-2"
   6.161 -#	help
   6.162 -#	  Select this for an IDT Winchip-2.  Linux and GCC
   6.163 -#	  treat this chip as a 586TSC with some extended instructions
   6.164 -#	  and alignment requirements.
   6.165 +config MWINCHIP2
   6.166 +	bool "Winchip-2"
   6.167 +	help
   6.168 +	  Select this for an IDT Winchip-2.  Linux and GCC
   6.169 +	  treat this chip as a 586TSC with some extended instructions
   6.170 +	  and alignment requirements.
   6.171  
   6.172 -#config MWINCHIP3D
   6.173 -#	bool "Winchip-2A/Winchip-3"
   6.174 -#	help
   6.175 -#	  Select this for an IDT Winchip-2A or 3.  Linux and GCC
   6.176 -#	  treat this chip as a 586TSC with some extended instructions
   6.177 -#	  and alignment reqirements.  Also enable out of order memory
   6.178 -#	  stores for this CPU, which can increase performance of some
   6.179 -#	  operations.
   6.180 +config MWINCHIP3D
   6.181 +	bool "Winchip-2A/Winchip-3"
   6.182 +	help
   6.183 +	  Select this for an IDT Winchip-2A or 3.  Linux and GCC
   6.184 +	  treat this chip as a 586TSC with some extended instructions
   6.185 +	  and alignment reqirements.  Also enable out of order memory
   6.186 +	  stores for this CPU, which can increase performance of some
   6.187 +	  operations.
   6.188  
   6.189  config MCYRIXIII
   6.190  	bool "CyrixIII/VIA-C3"
     7.1 --- a/linux-2.6.10-rc3-xen-sparse/arch/xen/i386/kernel/traps.c	Wed Dec 08 01:30:49 2004 +0000
     7.2 +++ b/linux-2.6.10-rc3-xen-sparse/arch/xen/i386/kernel/traps.c	Sun Dec 26 10:00:51 2004 +0000
     7.3 @@ -979,7 +979,6 @@ void __init trap_init(void)
     7.4  	 * default LDT is a single-entry callgate to lcall7 for iBCS
     7.5  	 * and a callgate to lcall27 for Solaris/x86 binaries
     7.6  	 */
     7.7 -	clear_page(&default_ldt[0]);
     7.8  	make_lowmem_page_readonly(&default_ldt[0]);
     7.9  	xen_flush_page_update_queue();
    7.10  
     8.1 --- a/linux-2.6.10-rc3-xen-sparse/arch/xen/kernel/reboot.c	Wed Dec 08 01:30:49 2004 +0000
     8.2 +++ b/linux-2.6.10-rc3-xen-sparse/arch/xen/kernel/reboot.c	Sun Dec 26 10:00:51 2004 +0000
     8.3 @@ -8,6 +8,7 @@ static int errno;
     8.4  #include <linux/unistd.h>
     8.5  #include <linux/module.h>
     8.6  #include <linux/reboot.h>
     8.7 +#include <linux/sysrq.h>
     8.8  #include <asm/irq.h>
     8.9  #include <asm/mmu_context.h>
    8.10  #include <asm-xen/ctrl_if.h>
    8.11 @@ -49,10 +50,9 @@ EXPORT_SYMBOL(machine_power_off);
    8.12   * Stop/pickle callback handling.
    8.13   */
    8.14  
    8.15 -//#include <asm/suspend.h>
    8.16 -
    8.17  /* Ignore multiple shutdown requests. */
    8.18  static int shutting_down = -1;
    8.19 +static int pending_sysrq = -1;
    8.20  
    8.21  static void __do_suspend(void)
    8.22  {
    8.23 @@ -214,9 +214,18 @@ static void __shutdown_handler(void *unu
    8.24      }
    8.25  }
    8.26  
    8.27 +static void __sysrq_handler(void *unused)
    8.28 +{
    8.29 +#ifdef CONFIG_MAGIC_SYSRQ
    8.30 +    handle_sysrq(pending_sysrq, NULL, NULL);
    8.31 +#endif
    8.32 +    pending_sysrq = -1;
    8.33 +}
    8.34 +
    8.35  static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
    8.36  {
    8.37      static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
    8.38 +    static DECLARE_WORK(sysrq_work, __sysrq_handler, NULL);
    8.39  
    8.40      if ( (shutting_down == -1) &&
    8.41           ((msg->subtype == CMSG_SHUTDOWN_POWEROFF) ||
    8.42 @@ -226,6 +235,12 @@ static void shutdown_handler(ctrl_msg_t 
    8.43          shutting_down = msg->subtype;
    8.44          schedule_work(&shutdown_work);
    8.45      }
    8.46 +    else if ( (pending_sysrq == -1) && 
    8.47 +              (msg->subtype == CMSG_SHUTDOWN_SYSRQ) )
    8.48 +    {
    8.49 +        pending_sysrq = msg->msg[0];
    8.50 +        schedule_work(&sysrq_work);
    8.51 +    }
    8.52      else
    8.53      {
    8.54          printk("Ignore spurious shutdown request\n");
     9.1 --- a/linux-2.6.10-rc3-xen-sparse/drivers/xen/netback/interface.c	Wed Dec 08 01:30:49 2004 +0000
     9.2 +++ b/linux-2.6.10-rc3-xen-sparse/drivers/xen/netback/interface.c	Sun Dec 26 10:00:51 2004 +0000
     9.3 @@ -124,13 +124,17 @@ void netif_create(netif_be_create_t *cre
     9.4  
     9.5      dev->hard_start_xmit = netif_be_start_xmit;
     9.6      dev->get_stats       = netif_be_get_stats;
     9.7 -    memcpy(dev->dev_addr, create->mac, ETH_ALEN);
     9.8  
     9.9      /* Disable queuing. */
    9.10      dev->tx_queue_len = 0;
    9.11  
    9.12 -    /* Force a different MAC from remote end. */
    9.13 -    dev->dev_addr[2] ^= 1;
    9.14 +    /*
    9.15 +     * Initialise a dummy MAC address. We choose the numerically largest
    9.16 +     * non-broadcast address to prevent the address getting stolen by an 
    9.17 +     * Ethernet bridge for STP purposes. (FE:FF:FF:FF:FF:FF)
    9.18 +     */
    9.19 +    memset(dev->dev_addr, 0xFF, ETH_ALEN);
    9.20 +    dev->dev_addr[0] &= ~0x01;
    9.21  
    9.22      if ( (err = register_netdev(dev)) != 0 )
    9.23      {
    10.1 --- a/tools/libxc/Makefile	Wed Dec 08 01:30:49 2004 +0000
    10.2 +++ b/tools/libxc/Makefile	Sun Dec 26 10:00:51 2004 +0000
    10.3 @@ -18,6 +18,7 @@ SRCS     += xc_domain.c
    10.4  SRCS     += xc_evtchn.c
    10.5  SRCS     += xc_io.c
    10.6  SRCS     += xc_linux_build.c
    10.7 +SRCS     += xc_plan9_build.c
    10.8  SRCS     += xc_linux_restore.c
    10.9  SRCS     += xc_linux_save.c
   10.10  SRCS     += xc_misc.c
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/tools/libxc/plan9a.out.h	Sun Dec 26 10:00:51 2004 +0000
    11.3 @@ -0,0 +1,28 @@
    11.4 +
    11.5 +typedef struct	Exec
    11.6 +{
    11.7 +	long	magic;		/* magic number */
    11.8 +	long	text;	 	/* size of text segment */
    11.9 +	long	data;	 	/* size of initialized data */
   11.10 +	long	bss;	  	/* size of uninitialized data */
   11.11 +	long	syms;	 	/* size of symbol table */
   11.12 +	long	entry;	 	/* entry point */
   11.13 +	long	spsz;		/* size of pc/sp offset table */
   11.14 +	long	pcsz;		/* size of pc/line number table */
   11.15 +} Exec;
   11.16 +
   11.17 +#define	_MAGIC(b)	((((4*b)+0)*b)+7)
   11.18 +#define	A_MAGIC		_MAGIC(8)	/* 68020 */
   11.19 +#define	I_MAGIC		_MAGIC(11)	/* intel 386 */
   11.20 +#define	J_MAGIC		_MAGIC(12)	/* intel 960 */
   11.21 +#define	K_MAGIC		_MAGIC(13)	/* sparc */
   11.22 +#define	V_MAGIC		_MAGIC(16)	/* mips 3000 */
   11.23 +#define	X_MAGIC		_MAGIC(17)	/* att dsp 3210 */
   11.24 +#define	M_MAGIC		_MAGIC(18)	/* mips 4000 */
   11.25 +#define	D_MAGIC		_MAGIC(19)	/* amd 29000 */
   11.26 +#define	E_MAGIC		_MAGIC(20)	/* arm 7-something */
   11.27 +#define	Q_MAGIC		_MAGIC(21)	/* powerpc */
   11.28 +#define	N_MAGIC		_MAGIC(22)	/* mips 4000 LE */
   11.29 +#define	L_MAGIC		_MAGIC(23)	/* dec alpha */
   11.30 +#define	P_MAGIC		_MAGIC(24)	/* mips 3000 LE */
   11.31 +
    12.1 --- a/tools/libxc/xc.h	Wed Dec 08 01:30:49 2004 +0000
    12.2 +++ b/tools/libxc/xc.h	Sun Dec 26 10:00:51 2004 +0000
    12.3 @@ -9,14 +9,15 @@
    12.4  #ifndef __XC_H__
    12.5  #define __XC_H__
    12.6  
    12.7 -typedef unsigned char      u8;
    12.8 -typedef unsigned short     u16;
    12.9 -typedef unsigned long      u32;
   12.10 -typedef unsigned long long u64;
   12.11 -typedef signed char        s8;
   12.12 -typedef signed short       s16;
   12.13 -typedef signed long        s32;
   12.14 -typedef signed long long   s64;
   12.15 +#include <stdint.h>
   12.16 +typedef uint8_t            u8;
   12.17 +typedef uint16_t           u16;
   12.18 +typedef uint32_t           u32;
   12.19 +typedef uint64_t           u64;
   12.20 +typedef int8_t             s8;
   12.21 +typedef int16_t            s16;
   12.22 +typedef int32_t            s32;
   12.23 +typedef int64_t            s64;
   12.24  
   12.25  #include <xen/xen.h>
   12.26  #include <xen/dom0_ops.h>
   12.27 @@ -96,6 +97,14 @@ int xc_linux_build(int xc_handle,
   12.28                     unsigned int control_evtchn,
   12.29                     unsigned long flags);
   12.30  
   12.31 +int
   12.32 +xc_plan9_build (int xc_handle,
   12.33 +                u32 domid, 
   12.34 +                const char *image_name,
   12.35 +                const char *cmdline, 
   12.36 +		unsigned int control_evtchn, 
   12.37 +		unsigned long flags);
   12.38 +
   12.39  int xc_bvtsched_global_set(int xc_handle,
   12.40                             unsigned long ctx_allow);
   12.41  
    13.1 --- a/tools/libxc/xc_linux_save.c	Wed Dec 08 01:30:49 2004 +0000
    13.2 +++ b/tools/libxc/xc_linux_save.c	Sun Dec 26 10:00:51 2004 +0000
    13.3 @@ -6,6 +6,7 @@
    13.4   * Copyright (c) 2003, K A Fraser.
    13.5   */
    13.6  
    13.7 +#include <inttypes.h>
    13.8  #include <sys/time.h>
    13.9  #include "xc_private.h"
   13.10  #include <xen/linux/suspend.h>
   13.11 @@ -245,7 +246,7 @@ static int print_stats( int xc_handle, u
   13.12  
   13.13      if ( print )
   13.14          printf("delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, "
   13.15 -               "dirtied %dMb/s %ld pages\n",
   13.16 +               "dirtied %dMb/s %" PRId32 " pages\n",
   13.17                 wall_delta, 
   13.18                 (int)((d0_cpu_delta*100)/wall_delta),
   13.19                 (int)((d1_cpu_delta*100)/wall_delta),
   13.20 @@ -307,8 +308,8 @@ static int analysis_phase( int xc_handle
   13.21                                 DOM0_SHADOW_CONTROL_OP_PEEK,
   13.22                                 NULL, 0, &stats);
   13.23  
   13.24 -            printf("now= %lld faults= %ld dirty= %ld dirty_net= %ld "
   13.25 -                   "dirty_block= %ld\n", 
   13.26 +            printf("now= %lld faults= %" PRId32 " dirty= %" PRId32
   13.27 +                   " dirty_net= %" PRId32 " dirty_block= %" PRId32"\n", 
   13.28                     ((now-start)+500)/1000, 
   13.29                     stats.fault_count, stats.dirty_count,
   13.30                     stats.dirty_net_count, stats.dirty_block_count);
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/tools/libxc/xc_plan9_build.c	Sun Dec 26 10:00:51 2004 +0000
    14.3 @@ -0,0 +1,744 @@
    14.4 +/******************************************************************************
    14.5 + * xc_plan9_build.c
    14.6 + * derived from xc_linux_build.c
    14.7 + */
    14.8 +
    14.9 +#include "xc_private.h"
   14.10 +
   14.11 +#include <zlib.h>
   14.12 +
   14.13 +#define DEBUG 1
   14.14 +#ifdef DEBUG
   14.15 +#define DPRINTF(x) printf x; fflush(stdout);
   14.16 +#else
   14.17 +#define DPRINTF(x)
   14.18 +#endif
   14.19 +
   14.20 +#include "plan9a.out.h"
   14.21 +
   14.22 +/* really TOS which means stack starts at 0x2000, and uses page 1*/
   14.23 +#define STACKPAGE 2
   14.24 +struct Exec header, origheader;
   14.25 +
   14.26 +typedef struct page {
   14.27 +	char data[PAGE_SIZE];
   14.28 +} PAGE;
   14.29 +
   14.30 +
   14.31 +int
   14.32 +memcpy_toguest(int xc_handle, u32 dom, void *v, int size,
   14.33 +	       unsigned long *page_array, unsigned int to_page)
   14.34 +{
   14.35 +	int ret;
   14.36 +	unsigned char *cp = v;
   14.37 +	unsigned int whichpage;
   14.38 +	unsigned char *vaddr;
   14.39 +
   14.40 +//  DPRINTF(("memcpy_to_guest: to_page 0x%x, count %d\n", to_page, size));
   14.41 +	for (ret = 0, whichpage = to_page; size > 0;
   14.42 +	     whichpage++, size -= PAGE_SIZE, cp += PAGE_SIZE) {
   14.43 +
   14.44 +		//     DPRINTF (("map_pfn_writeable(%p, 0x%lx)\n", pm_handle,
   14.45 +//                page_array[whichpage]));
   14.46 +		vaddr = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   14.47 +					     PROT_READ | PROT_WRITE,
   14.48 +					     page_array[whichpage]);
   14.49 +		//    DPRINTF (("vaddr is %p\n", vaddr));
   14.50 +		if (vaddr == NULL) {
   14.51 +			ret = -1;
   14.52 +			ERROR("Couldn't map guest memory");
   14.53 +			goto out;
   14.54 +		}
   14.55 +		//   DPRINTF (("copy %p to %p, count 0x%x\n", cp, vaddr, 4096));
   14.56 +		memcpy(vaddr, cp, 4096);
   14.57 +		munmap(vaddr, PAGE_SIZE);
   14.58 +		//  DPRINTF (("Did %ud'th pages\n", whichpage));
   14.59 +	}
   14.60 +      out:
   14.61 +	return ret;
   14.62 +}
   14.63 +
   14.64 +/* this is a function which can go away. It dumps a hunk of 
   14.65 + * guest pages to a file (/tmp/dumpit); handy for debugging
   14.66 + * your image builder. 
   14.67 + * Xen guys, nuke this if you wish.
   14.68 + */
   14.69 +void
   14.70 +dumpit(int xc_handle, u32 dom,
   14.71 +       int start_page, int tot, unsigned long *page_array)
   14.72 +{
   14.73 +	int i, ofd;
   14.74 +	unsigned char *vaddr;
   14.75 +
   14.76 +	ofd = open("/tmp/dumpit", O_RDWR);
   14.77 +	for (i = start_page; i < tot; i++) {
   14.78 +		vaddr = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   14.79 +					     PROT_READ | PROT_WRITE,
   14.80 +					     page_array[i]);
   14.81 +		if (!vaddr) {
   14.82 +			fprintf(stderr, "Page %d\n", i);
   14.83 +			perror("shit");
   14.84 +			read(0, &i, 1);
   14.85 +			return;
   14.86 +		}
   14.87 +		write(ofd, vaddr, 4096);
   14.88 +		munmap(vaddr, PAGE_SIZE);
   14.89 +	}
   14.90 +}
   14.91 +int
   14.92 +blah(char *b)
   14.93 +{
   14.94 +	fprintf(stderr, "Error in xc_plan9_build!\n");
   14.95 +	perror(b);
   14.96 +	return errno;
   14.97 +}
   14.98 +
   14.99 +/* swap bytes. For plan 9 headers */
  14.100 +void
  14.101 +swabby(unsigned long *s, char *name)
  14.102 +{
  14.103 +	unsigned long it;
  14.104 +	it = ((*s & 0xff000000) >> 24) | ((*s & 0xff0000) >> 8) |
  14.105 +	    ((*s & 0xff00) << 8) | ((*s & 0xff) << 24);
  14.106 +	DPRINTF(("Item %s is 0x%lx\n", name, it));
  14.107 +	*s = it;
  14.108 +}
  14.109 +
  14.110 +void
  14.111 +plan9header(Exec * header)
  14.112 +{
  14.113 +	/* header is big-endian */
  14.114 +	swabby(&header->magic, "magic");
  14.115 +	swabby(&header->text, "text");
  14.116 +	swabby(&header->data, "data");
  14.117 +	swabby(&header->bss, "bss");
  14.118 +	swabby(&header->syms, "syms");
  14.119 +	swabby(&header->entry, "entry");
  14.120 +	swabby(&header->spsz, "spsz");
  14.121 +	swabby(&header->pcsz, "pcsz");
  14.122 +
  14.123 +}
  14.124 +
  14.125 +static int
  14.126 + loadp9image(gzFile kernel_gfd, int xc_handle, u32 dom,
  14.127 +	     unsigned long *page_array,
  14.128 +	     unsigned long tot_pages, unsigned long *virt_load_addr,
  14.129 +	     unsigned long *ksize, unsigned long *symtab_addr,
  14.130 +	     unsigned long *symtab_len,
  14.131 +	     unsigned long *first_data_page, unsigned long *pdb_page);
  14.132 +
  14.133 +#define P9ROUND (P9SIZE / 8)
  14.134 +
  14.135 +#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
  14.136 +#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
  14.137 +
  14.138 +static long
  14.139 +get_tot_pages(int xc_handle, u32 domid)
  14.140 +{
  14.141 +	dom0_op_t op;
  14.142 +	op.cmd = DOM0_GETDOMAININFO;
  14.143 +	op.u.getdomaininfo.domain = (domid_t) domid;
  14.144 +	op.u.getdomaininfo.ctxt = NULL;
  14.145 +	return (do_dom0_op(xc_handle, &op) < 0) ?
  14.146 +	    -1 : op.u.getdomaininfo.tot_pages;
  14.147 +}
  14.148 +
  14.149 +static int
  14.150 +get_pfn_list(int xc_handle,
  14.151 +	     u32 domid, unsigned long *pfn_buf, unsigned long max_pfns)
  14.152 +{
  14.153 +	dom0_op_t op;
  14.154 +	int ret;
  14.155 +	op.cmd = DOM0_GETMEMLIST;
  14.156 +	op.u.getmemlist.domain = (domid_t) domid;
  14.157 +	op.u.getmemlist.max_pfns = max_pfns;
  14.158 +	op.u.getmemlist.buffer = pfn_buf;
  14.159 +
  14.160 +	if (mlock(pfn_buf, max_pfns * sizeof (unsigned long)) != 0)
  14.161 +		return -1;
  14.162 +
  14.163 +	ret = do_dom0_op(xc_handle, &op);
  14.164 +
  14.165 +	(void) munlock(pfn_buf, max_pfns * sizeof (unsigned long));
  14.166 +
  14.167 +#if 0
  14.168 +#ifdef DEBUG
  14.169 +	DPRINTF(("Ret for get_pfn_list is %d\n", ret));
  14.170 +	if (ret >= 0) {
  14.171 +		int i, j;
  14.172 +		for (i = 0; i < op.u.getmemlist.num_pfns; i += 16) {
  14.173 +			fprintf(stderr, "0x%x: ", i);
  14.174 +			for (j = 0; j < 16; j++)
  14.175 +				fprintf(stderr, "0x%lx ", pfn_buf[i + j]);
  14.176 +			fprintf(stderr, "\n");
  14.177 +		}
  14.178 +	}
  14.179 +#endif
  14.180 +#endif
  14.181 +	return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
  14.182 +}
  14.183 +
  14.184 +static int
  14.185 +setup_guestos(int xc_handle,
  14.186 +	      u32 dom,
  14.187 +	      gzFile kernel_gfd,
  14.188 +	      unsigned long tot_pages,
  14.189 +	      unsigned long *virt_startinfo_addr,
  14.190 +	      unsigned long *virt_load_addr,
  14.191 +	      full_execution_context_t * ctxt,
  14.192 +	      const char *cmdline,
  14.193 +	      unsigned long shared_info_frame, 
  14.194 +	      unsigned int control_evtchn,
  14.195 +	      int flags)
  14.196 +{
  14.197 +	l1_pgentry_t *vl1e = NULL;
  14.198 +	l2_pgentry_t *vl2tab = NULL, *vl2e = NULL;
  14.199 +	unsigned long *cpage_array = NULL;
  14.200 +	unsigned long *pte_array = NULL;
  14.201 +	unsigned long l2tab;
  14.202 +	unsigned long l1tab;
  14.203 +	unsigned long count;
  14.204 +	unsigned long symtab_addr = 0, symtab_len = 0;
  14.205 +	start_info_t *start_info;
  14.206 +	shared_info_t *shared_info;
  14.207 +	unsigned long ksize;
  14.208 +	mmu_t *mmu = NULL;
  14.209 +	int i;
  14.210 +	unsigned long first_page_after_kernel, 
  14.211 +	  first_data_page, 
  14.212 +	  page_array_page;
  14.213 +	unsigned long cpu0pdb, cpu0pte, cpu0ptelast;
  14.214 +	unsigned long /*last_pfn, */ tot_pte_pages;
  14.215 +
  14.216 +	DPRINTF(("tot pages is %ld\n", tot_pages));
  14.217 +	if ((cpage_array = malloc(tot_pages * sizeof (unsigned long))) == NULL) {
  14.218 +		PERROR("Could not allocate cpage array");
  14.219 +		goto error_out;
  14.220 +	}
  14.221 +
  14.222 +	if (get_pfn_list(xc_handle, dom, cpage_array, tot_pages) != tot_pages) {
  14.223 +		PERROR("Could not get the page frame list");
  14.224 +		goto error_out;
  14.225 +	}
  14.226 +
  14.227 +	for (i = 0; i < 64; i++)
  14.228 +		DPRINTF(("First %d page is 0x%lx\n", i, cpage_array[i]));
  14.229 +
  14.230 +	tot_pte_pages = tot_pages >> 10;
  14.231 +	DPRINTF(("Page range is 0 to 0x%lx, which requires 0x%lx pte pages\n",
  14.232 +		 tot_pte_pages, tot_pte_pages));
  14.233 +
  14.234 +	if (loadp9image(kernel_gfd, xc_handle, dom, cpage_array, tot_pages,
  14.235 +			virt_load_addr, &ksize, &symtab_addr, &symtab_len,
  14.236 +			&first_data_page, &first_page_after_kernel))
  14.237 +		goto error_out;
  14.238 +	DPRINTF(("First data page is 0x%lx\n", first_data_page));
  14.239 +	DPRINTF(("First page after kernel is 0x%lx\n",
  14.240 +		 first_page_after_kernel));
  14.241 +
  14.242 +	/*
  14.243 +	   NEED TO INCREMENT first page after kernel by:
  14.244 +	   + 1 (pdb)
  14.245 +	   + tot_pte_pages (pte)
  14.246 +	   + tot_pte_pages (page_array)
  14.247 +	 */
  14.248 +	/* SO, have to copy the first kernel pages pfns right into the 
  14.249 +	 * page_array, then do identity maps for the rest. 
  14.250 +	 */
  14.251 +	DPRINTF(("mapped kernel pages\n"));
  14.252 +
  14.253 +	/* now loop over all ptes and store into the page_array, so as
  14.254 +	 * to get the identity map. 
  14.255 +	 */
  14.256 +	if ((pte_array =
  14.257 +	     malloc(tot_pte_pages * 1024 * sizeof (unsigned long))) == NULL) {
  14.258 +		PERROR("Could not allocate pte array");
  14.259 +		goto error_out;
  14.260 +	}
  14.261 +
  14.262 +	/* plan 9 on startup expects a "l2" (xen parlance) at 0x2000, 
  14.263 +	 * this "l2" should have one PTE pointer for a va of 0x80000000. 
  14.264 +	 * and an l1 (PTEs to you) at 0x3000. (physical). 
  14.265 +	 * the PTEs should map the first 4M of memory. 
  14.266 +	 */
  14.267 +	/* get a physical address for the L2. This means take the PFN and 
  14.268 +	 * shift left.
  14.269 +	 */
  14.270 +	/* this terminology is plan 9 terminology. 
  14.271 +	 * pdb is essentially the Xen L2. 'Page Directory Block'? 
  14.272 +	 * I need to ask JMK.
  14.273 +	 * cpupte is the pte array. 
  14.274 +	 * Plan 9 counts on these being set up for cpu0. 
  14.275 +	 * SO: cpu0pdb (Xen L2)
  14.276 +	 * and cpupte  (Xen L1)
  14.277 +	 */
  14.278 +	/* cpu0pdb is right after kernel */
  14.279 +	cpu0pdb = first_page_after_kernel;
  14.280 +	/* cpu0pte comes right after cpu0pdb */
  14.281 +	cpu0pte = cpu0pdb + 1;
  14.282 +	/* number of the past cpu0pte page */
  14.283 +	cpu0ptelast = cpu0pte + tot_pte_pages - 1;
  14.284 +	/* first page of the page array (mfn) */
  14.285 +	page_array_page = cpu0ptelast + 1;
  14.286 +
  14.287 +	DPRINTF(("cpu0pdb 0x%lx, cpu0pte 0x%lx cpu0ptelast 0x%lx\n", cpu0pdb,
  14.288 +		 cpu0pte, cpu0ptelast));
  14.289 +	l2tab = cpage_array[cpu0pdb] << PAGE_SHIFT;
  14.290 +	DPRINTF(("l2tab 0x%lx\n", l2tab));
  14.291 +	ctxt->pt_base = l2tab;
  14.292 +
  14.293 +	/* get a physical address for the L1. This means take the PFN and 
  14.294 +	 * shift left.
  14.295 +	 */
  14.296 +	l1tab = cpage_array[cpu0pte] << PAGE_SHIFT;
  14.297 +	DPRINTF(("l1tab 0x%lx\n", l1tab));
  14.298 +	if ((mmu = init_mmu_updates(xc_handle, dom)) == NULL)
  14.299 +		goto error_out;
  14.300 +	DPRINTF(("now map in l2tab\n"));
  14.301 +
  14.302 +	/* Initialise the page tables. */
  14.303 +	/* mmap in the l2tab */
  14.304 +	if ((vl2tab = xc_map_foreign_range(xc_handle, dom,
  14.305 +					   PAGE_SIZE, PROT_READ | PROT_WRITE,
  14.306 +					   l2tab >> PAGE_SHIFT)) == NULL)
  14.307 +		goto error_out;
  14.308 +	DPRINTF(("vl2tab 0x%p\n", vl2tab));
  14.309 +	/* now we have the cpu0pdb for the kernel, starting at 0x2000, 
  14.310 +	 * so we can plug in the physical pointer to the 0x3000 pte
  14.311 +	 */
  14.312 +	/* zero it */
  14.313 +	memset(vl2tab, 0, PAGE_SIZE);
  14.314 +	/* get a pointer in the l2tab for the virt_load_addr */
  14.315 +	DPRINTF(("&vl2tab[l2_table_offset(*virt_load_addr)] is 0x%p[0x%lx]\n",
  14.316 +		 &vl2tab[l2_table_offset(*virt_load_addr)],
  14.317 +		 l2_table_offset(*virt_load_addr)));
  14.318 +
  14.319 +	vl2e = &vl2tab[l2_table_offset(*virt_load_addr)];
  14.320 +
  14.321 +	/* OK, for all the available PTE, set the PTE pointer up */
  14.322 +	DPRINTF(("For i  = %ld to %ld ...\n", cpu0pte, cpu0ptelast));
  14.323 +	for (i = cpu0pte; i <= cpu0ptelast; i++) {
  14.324 +		DPRINTF(("Index %d Set %p to 0x%lx\n", i, vl2e,
  14.325 +			 (cpage_array[i] << PAGE_SHIFT) | L2_PROT));
  14.326 +		*vl2e++ = (cpage_array[i] << PAGE_SHIFT) | L2_PROT;
  14.327 +	}
  14.328 +
  14.329 +	/* unmap it ... */
  14.330 +	munmap(vl2tab, PAGE_SIZE);
  14.331 +
  14.332 +	/* for the pages from virt_load_pointer to the end of this 
  14.333 +	 * set of PTEs, map in the PFN for that VA
  14.334 +	 */
  14.335 +	for (vl1e = (l1_pgentry_t *) pte_array, count = 0;
  14.336 +	     count < tot_pte_pages * 1024; count++, vl1e++) {
  14.337 +
  14.338 +		*vl1e = cpage_array[count];
  14.339 +		if (!cpage_array[count])
  14.340 +			continue;
  14.341 +		/* set in the PFN for this entry */
  14.342 +		*vl1e = (cpage_array[count] << PAGE_SHIFT) | L1_PROT;
  14.343 +/*
  14.344 +      DPRINTF (("vl1e # %d 0x%lx gets 0x%lx\n",
  14.345 +		count, vl1e, *vl1e));
  14.346 +*/
  14.347 +		if ((count >= cpu0pdb) && (count <= cpu0ptelast)) {
  14.348 +			//DPRINTF(("   Fix up page %d as it is in pte ville: ", count));
  14.349 +			*vl1e &= ~_PAGE_RW;
  14.350 +			DPRINTF(("0x%lx\n", *vl1e));
  14.351 +		}
  14.352 +		if ((count >= (0x100000 >> 12))
  14.353 +		    && (count < (first_data_page >> 12))) {
  14.354 +			//DPRINTF(("   Fix up page %d as it is in text ", count));
  14.355 +			*vl1e &= ~_PAGE_RW;
  14.356 +			//DPRINTF (("0x%lx\n", *vl1e));
  14.357 +		}
  14.358 +	}
  14.359 +	/* special thing. Pre-map the shared info page */
  14.360 +	vl1e = &pte_array[2];
  14.361 +	*vl1e = (shared_info_frame << PAGE_SHIFT) | L1_PROT;
  14.362 +	DPRINTF(("v1l1 %p, has value 0x%lx\n", vl1e, *(unsigned long *) vl1e));
  14.363 +	/* another special thing. VA 80005000 has to point to 80006000 */
  14.364 +	/* this is a Plan 9 thing -- the 'mach' pointer */
  14.365 +	/* 80005000 is the mach pointer per-cpu, and the actual
  14.366 +	 * mach pointers are 80006000, 80007000 etc. 
  14.367 +	 */
  14.368 +	vl1e = &pte_array[5];
  14.369 +	*vl1e = (cpage_array[6] << PAGE_SHIFT) | L1_PROT;
  14.370 +
  14.371 +	/* OK, it's all set up, copy it in */
  14.372 +	memcpy_toguest(xc_handle, dom, pte_array,
  14.373 +		       (tot_pte_pages * 1024 * sizeof (unsigned long) /**/),
  14.374 +		       cpage_array, cpu0pte);
  14.375 +
  14.376 +	/* We really need to have the vl1tab unmapped or the add_mmu_update
  14.377 +	 * below will fail bigtime. 
  14.378 +	 */
  14.379 +	/* Xen guys: remember my errors on domain exit? Something I'm doing
  14.380 +	 * wrong in here? We never did find out ...
  14.381 +	 */
  14.382 +	/* get rid of the entries we can not use ... */
  14.383 +	memcpy_toguest(xc_handle, dom, cpage_array,
  14.384 +		       (tot_pte_pages * 1024 * sizeof (unsigned long) /**/),
  14.385 +		       cpage_array, page_array_page);
  14.386 +	/* last chance to dump all of memory */
  14.387 +	// dumpit(xc_handle, dom, 0 /*0x100000>>12*/, tot_pages, cpage_array) ;
  14.388 +	/*
  14.389 +	 * Pin down l2tab addr as page dir page - causes hypervisor to provide
  14.390 +	 * correct protection for the page
  14.391 +	 */
  14.392 +	if (add_mmu_update(xc_handle, mmu,
  14.393 +			   l2tab | MMU_EXTENDED_COMMAND, MMUEXT_PIN_L2_TABLE))
  14.394 +		goto error_out;
  14.395 +
  14.396 +	for (count = 0; count < tot_pages; count++) {
  14.397 +/*
  14.398 +      DPRINTF (("add_mmu_update(0x%x, 0x%x, 0x%x, %d)\n", xc_handle, mmu,
  14.399 +							   (cpage_array[count]
  14.400 +							    << PAGE_SHIFT) |
  14.401 +							   MMU_MACHPHYS_UPDATE,
  14.402 +							   count));
  14.403 +*/
  14.404 +		if (add_mmu_update(xc_handle, mmu,
  14.405 +				   (cpage_array[count] << PAGE_SHIFT) |
  14.406 +				   MMU_MACHPHYS_UPDATE, count))
  14.407 +			goto error_out;
  14.408 +		//DPRINTF(("Do the next one\n"));
  14.409 +	}
  14.410 +/*
  14.411 + */
  14.412 +
  14.413 +	//dumpit(pm_handle, 3, 4, page_array);
  14.414 +	/* put the virt_startinfo_addr at KZERO */
  14.415 +	/* just hard-code for now */
  14.416 +	*virt_startinfo_addr = 0x80000000;
  14.417 +
  14.418 +	DPRINTF(("virt_startinfo_addr = 0x%lx\n", *virt_startinfo_addr));
  14.419 +	start_info = xc_map_foreign_range(xc_handle, dom,
  14.420 +					  PAGE_SIZE, PROT_READ | PROT_WRITE,
  14.421 +					  cpage_array[0]);
  14.422 +	DPRINTF(("startinfo = 0x%p\n", start_info));
  14.423 +	DPRINTF(("shared_info_frame is %lx\n", shared_info_frame));
  14.424 +	memset(start_info, 0, sizeof (*start_info));
  14.425 +	start_info->pt_base = 0x80000000 | cpu0pdb << PAGE_SHIFT;
  14.426 +	start_info->mfn_list = 0x80000000 | (page_array_page) << PAGE_SHIFT;
  14.427 +	DPRINTF(("mfn_list 0x%lx\n", start_info->mfn_list));
  14.428 +	start_info->mod_start = 0;
  14.429 +	start_info->mod_len = 0;
  14.430 +	start_info->nr_pages = tot_pte_pages * 1024;
  14.431 +	start_info->nr_pt_frames = tot_pte_pages + 1;
  14.432 +	start_info->shared_info = shared_info_frame;
  14.433 +	start_info->flags = 0;
  14.434 +	DPRINTF((" control event channel is %d\n", control_evtchn));
  14.435 +	start_info->domain_controller_evtchn = control_evtchn;
  14.436 +	strncpy(start_info->cmd_line, cmdline, MAX_CMDLINE);
  14.437 +	start_info->cmd_line[MAX_CMDLINE - 1] = '\0';
  14.438 +	munmap(start_info, PAGE_SIZE);
  14.439 +
  14.440 +	DPRINTF(("done setting up start_info\n"));
  14.441 +	DPRINTF(("shared_info_frame = 0x%lx\n", shared_info_frame));
  14.442 +	/* shared_info page starts its life empty. */
  14.443 +
  14.444 +	shared_info = xc_map_foreign_range(xc_handle, dom,
  14.445 +					   PAGE_SIZE, PROT_READ | PROT_WRITE,
  14.446 +					   shared_info_frame);
  14.447 +	memset(shared_info, 0, PAGE_SIZE);
  14.448 +	/* Mask all upcalls... */
  14.449 +	DPRINTF(("mask all upcalls\n"));
  14.450 +	for (i = 0; i < MAX_VIRT_CPUS; i++)
  14.451 +		shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
  14.452 +	munmap(shared_info, PAGE_SIZE);
  14.453 +
  14.454 +	/* Send the page update requests down to the hypervisor. */
  14.455 +	DPRINTF(("send page update reqs down.\n"));
  14.456 +	if (finish_mmu_updates(xc_handle, mmu))
  14.457 +		goto error_out;
  14.458 +
  14.459 +	//DPRINTF (("call dumpit.\n"));
  14.460 +	//dumpit(pm_handle, 0x100000>>12, tot_pages, page_array) ;
  14.461 +	//dumpit (pm_handle, 2, 0x100, page_array);
  14.462 +	free(mmu);
  14.463 +
  14.464 +	/* we don't bother freeing anything at this point -- 
  14.465 +	 * we're exiting and it is pointless
  14.466 +	 */
  14.467 +	return 0;
  14.468 +
  14.469 +      error_out:
  14.470 +	/* oh well we still free some things -- I oughtta nuke this */
  14.471 +	if (mmu != NULL)
  14.472 +		free(mmu);
  14.473 +	;
  14.474 +	return -1;
  14.475 +}
  14.476 +
  14.477 +int
  14.478 +xc_plan9_build(int xc_handle,
  14.479 +	       u32 domid,
  14.480 +	       const char *image_name,
  14.481 +	       const char *cmdline,
  14.482 +	       unsigned int control_evtchn, unsigned long flags)
  14.483 +{
  14.484 +	dom0_op_t launch_op, op;
  14.485 +	unsigned long load_addr;
  14.486 +	long tot_pages;
  14.487 +	int kernel_fd = -1;
  14.488 +	gzFile kernel_gfd = NULL;
  14.489 +	int rc, i;
  14.490 +	full_execution_context_t st_ctxt, *ctxt = &st_ctxt;
  14.491 +	unsigned long virt_startinfo_addr;
  14.492 +
  14.493 +	if ((tot_pages = get_tot_pages(xc_handle, domid)) < 0) {
  14.494 +		PERROR("Could not find total pages for domain");
  14.495 +		return 1;
  14.496 +	}
  14.497 +	DPRINTF(("get_tot_pages returns %ld pages\n", tot_pages));
  14.498 +
  14.499 +	kernel_fd = open(image_name, O_RDONLY);
  14.500 +	if (kernel_fd < 0) {
  14.501 +		PERROR("Could not open kernel image");
  14.502 +		return 1;
  14.503 +	}
  14.504 +
  14.505 +	if ((kernel_gfd = gzdopen(kernel_fd, "rb")) == NULL) {
  14.506 +		PERROR("Could not allocate decompression state for state file");
  14.507 +		close(kernel_fd);
  14.508 +		return 1;
  14.509 +	}
  14.510 +
  14.511 +	DPRINTF(("get_tot_pages returns %ld pages\n", tot_pages));
  14.512 +	if (mlock(&st_ctxt, sizeof (st_ctxt))) {
  14.513 +		PERROR("Unable to mlock ctxt");
  14.514 +		return 1;
  14.515 +	}
  14.516 +
  14.517 +	op.cmd = DOM0_GETDOMAININFO;
  14.518 +	op.u.getdomaininfo.domain = (domid_t) domid;
  14.519 +	op.u.getdomaininfo.ctxt = ctxt;
  14.520 +	if ((do_dom0_op(xc_handle, &op) < 0) ||
  14.521 +	    ((u32) op.u.getdomaininfo.domain != domid)) {
  14.522 +		PERROR("Could not get info on domain");
  14.523 +		goto error_out;
  14.524 +	}
  14.525 +	DPRINTF(("get_tot_pages returns %ld pages\n", tot_pages));
  14.526 +
  14.527 +	if (!(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED)
  14.528 +	    || (op.u.getdomaininfo.ctxt->pt_base != 0)) {
  14.529 +		ERROR("Domain is already constructed");
  14.530 +		goto error_out;
  14.531 +	}
  14.532 +
  14.533 +	DPRINTF(("get_tot_pages returns %ld pages\n", tot_pages));
  14.534 +	if (setup_guestos(xc_handle, domid, kernel_gfd, tot_pages,
  14.535 +			  &virt_startinfo_addr,
  14.536 +			  &load_addr, &st_ctxt, cmdline,
  14.537 +			  op.u.getdomaininfo.shared_info_frame,
  14.538 +			  control_evtchn, flags) < 0) {
  14.539 +		ERROR("Error constructing guest OS");
  14.540 +		goto error_out;
  14.541 +	}
  14.542 +
  14.543 +	/* leave the leak in here for now
  14.544 +	   if ( kernel_fd >= 0 )
  14.545 +	   close(kernel_fd);
  14.546 +	   if( kernel_gfd )
  14.547 +	   gzclose(kernel_gfd);
  14.548 +	 */
  14.549 +	ctxt->flags = 0;
  14.550 +
  14.551 +	/*
  14.552 +	 * Initial register values:
  14.553 +	 *  DS,ES,FS,GS = FLAT_GUESTOS_DS
  14.554 +	 *       CS:EIP = FLAT_GUESTOS_CS:start_pc
  14.555 +	 *       SS:ESP = FLAT_GUESTOS_DS:start_stack
  14.556 +	 *          ESI = start_info
  14.557 +	 *  [EAX,EBX,ECX,EDX,EDI,EBP are zero]
  14.558 +	 *       EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)
  14.559 +	 */
  14.560 +	ctxt->cpu_ctxt.ds = FLAT_GUESTOS_DS;
  14.561 +	ctxt->cpu_ctxt.es = FLAT_GUESTOS_DS;
  14.562 +	ctxt->cpu_ctxt.fs = FLAT_GUESTOS_DS;
  14.563 +	ctxt->cpu_ctxt.gs = FLAT_GUESTOS_DS;
  14.564 +	ctxt->cpu_ctxt.ss = FLAT_GUESTOS_DS;
  14.565 +	ctxt->cpu_ctxt.cs = FLAT_GUESTOS_CS;
  14.566 +	ctxt->cpu_ctxt.eip = load_addr;
  14.567 +	ctxt->cpu_ctxt.eip = 0x80100020;
  14.568 +	/* put stack at top of second page */
  14.569 +	ctxt->cpu_ctxt.esp = 0x80000000 + (STACKPAGE << PAGE_SHIFT);
  14.570 +
  14.571 +	/* why is this set? */
  14.572 +	ctxt->cpu_ctxt.esi = ctxt->cpu_ctxt.esp;
  14.573 +	ctxt->cpu_ctxt.eflags = (1 << 9) | (1 << 2);
  14.574 +
  14.575 +	/* FPU is set up to default initial state. */
  14.576 +	memset(ctxt->fpu_ctxt, 0, sizeof (ctxt->fpu_ctxt));
  14.577 +
  14.578 +	/* Virtual IDT is empty at start-of-day. */
  14.579 +	for (i = 0; i < 256; i++) {
  14.580 +		ctxt->trap_ctxt[i].vector = i;
  14.581 +		ctxt->trap_ctxt[i].cs = FLAT_GUESTOS_CS;
  14.582 +	}
  14.583 +	ctxt->fast_trap_idx = 0;
  14.584 +
  14.585 +	/* No LDT. */
  14.586 +	ctxt->ldt_ents = 0;
  14.587 +
  14.588 +	/* Use the default Xen-provided GDT. */
  14.589 +	ctxt->gdt_ents = 0;
  14.590 +
  14.591 +	/* Ring 1 stack is the initial stack. */
  14.592 +	/* put stack at top of second page */
  14.593 +	ctxt->guestos_ss = FLAT_GUESTOS_DS;
  14.594 +	ctxt->guestos_esp = ctxt->cpu_ctxt.esp;
  14.595 +
  14.596 +	/* No debugging. */
  14.597 +	memset(ctxt->debugreg, 0, sizeof (ctxt->debugreg));
  14.598 +
  14.599 +	/* No callback handlers. */
  14.600 +	ctxt->event_callback_cs = FLAT_GUESTOS_CS;
  14.601 +	ctxt->event_callback_eip = 0;
  14.602 +	ctxt->failsafe_callback_cs = FLAT_GUESTOS_CS;
  14.603 +	ctxt->failsafe_callback_eip = 0;
  14.604 +
  14.605 +	memset(&launch_op, 0, sizeof (launch_op));
  14.606 +
  14.607 +	launch_op.u.builddomain.domain = (domid_t) domid;
  14.608 +	//  launch_op.u.builddomain.num_vifs = 1;
  14.609 +	launch_op.u.builddomain.ctxt = ctxt;
  14.610 +	launch_op.cmd = DOM0_BUILDDOMAIN;
  14.611 +	rc = do_dom0_op(xc_handle, &launch_op);
  14.612 +
  14.613 +	fprintf(stderr, "RC is %d\n", rc);
  14.614 +	return rc;
  14.615 +
  14.616 +      error_out:
  14.617 +	if (kernel_fd >= 0)
  14.618 +		close(kernel_fd);
  14.619 +	if (kernel_gfd)
  14.620 +		gzclose(kernel_gfd);
  14.621 +
  14.622 +	return -1;
  14.623 +}
  14.624 +
  14.625 +/* 
  14.626 + * Plan 9 memory layout (initial)
  14.627 + * ----------------
  14.628 + * | info from xen| @0
  14.629 + * ----------------
  14.630 + * | stack        |
  14.631 + * ----------------<--- page 2
  14.632 + * | empty        |
  14.633 + * ---------------<---- page 5 MACHADDR (always points to machp[cpuno]
  14.634 + * | aliased      |
  14.635 + * ---------------<----- page 6 CPU0MACH
  14.636 + * | CPU0MACH     |
  14.637 + * ----------------
  14.638 + * | empty        |
  14.639 + * ---------------- *virt_load_addr = ehdr.e_entry (0x80100000)
  14.640 + * | kernel       |
  14.641 + * |              |
  14.642 + * ---------------- <----- page aligned boundary.
  14.643 + * | data         |
  14.644 + * |              | 
  14.645 + * ----------------
  14.646 + * | bss          |
  14.647 + * ----------------<---  end of kernel (page aligned)
  14.648 + * | PMD cpu0pdb  |
  14.649 + * ----------------<--- page +1
  14.650 + * | PTE cpu0pte  |
  14.651 + * ----------------<--- page (tot_pte_pages)/1024
  14.652 + * | page_array   |
  14.653 + * ---------------- <--- page (tot_pte_pages)/1024
  14.654 + * | empty to TOM |
  14.655 + * ----------------
  14.656 + */
  14.657 +
  14.658 +static int
  14.659 +loadp9image(gzFile kernel_gfd, int xc_handle, u32 dom,
  14.660 +	    unsigned long *page_array,
  14.661 +	    unsigned long tot_pages, unsigned long *virt_load_addr,
  14.662 +	    unsigned long *ksize, unsigned long *symtab_addr,
  14.663 +	    unsigned long *symtab_len,
  14.664 +	    unsigned long *first_data_page, unsigned long *pdb_page)
  14.665 +{
  14.666 +	unsigned long datapage;
  14.667 +	Exec ehdr;
  14.668 +
  14.669 +	char *p;
  14.670 +	unsigned long maxva;
  14.671 +	int curpos, ret;
  14.672 +	PAGE *image = 0;
  14.673 +	unsigned long image_tot_pages = 0;
  14.674 +	unsigned long textround;
  14.675 +
  14.676 +	ret = -1;
  14.677 +
  14.678 +	p = NULL;
  14.679 +	maxva = 0;
  14.680 +
  14.681 +	if (gzread(kernel_gfd, &ehdr, sizeof (Exec)) != sizeof (Exec)) {
  14.682 +		PERROR("Error reading kernel image P9 header.");
  14.683 +		goto out;
  14.684 +	}
  14.685 +
  14.686 +	plan9header(&ehdr);
  14.687 +	curpos = sizeof (Exec);
  14.688 +
  14.689 +	if (ehdr.magic != I_MAGIC) {
  14.690 +		PERROR("Image does not have an P9 header.");
  14.691 +		goto out;
  14.692 +	}
  14.693 +
  14.694 +	textround = ((ehdr.text + 0x20 + 4095) >> 12) << 12;
  14.695 +	*first_data_page = 0x100000 + textround;
  14.696 +	DPRINTF(("ehrd.text is 0x%lx, textround is 0x%lx\n",
  14.697 +		 ehdr.text, textround));
  14.698 +
  14.699 +	image_tot_pages =
  14.700 +	    (textround + ehdr.data + ehdr.bss + PAGE_SIZE - 1) >> PAGE_SHIFT;
  14.701 +	DPRINTF(("tot pages is %ld\n", image_tot_pages));
  14.702 +
  14.703 +	*virt_load_addr = 0x80100000;
  14.704 +
  14.705 +	if ((*virt_load_addr & (PAGE_SIZE - 1)) != 0) {
  14.706 +		ERROR("We can only deal with page-aligned load addresses");
  14.707 +		goto out;
  14.708 +	}
  14.709 +
  14.710 +	if ((*virt_load_addr + (image_tot_pages << PAGE_SHIFT)) >
  14.711 +	    HYPERVISOR_VIRT_START) {
  14.712 +		ERROR("Cannot map all domain memory without hitting Xen space");
  14.713 +		goto out;
  14.714 +	}
  14.715 +
  14.716 +	/* just malloc an image that is image_tot_pages  in size. Then read in 
  14.717 +	 * the image -- text, data, -- to page-rounded alignments. 
  14.718 +	 * then copy into xen .
  14.719 +	 * this gets BSS zeroed for free
  14.720 +	 */
  14.721 +	DPRINTF(("Allocate %ld bytes\n", image_tot_pages * sizeof (*image)));
  14.722 +	image = calloc(image_tot_pages, sizeof (*image));
  14.723 +	if (!image)
  14.724 +		return blah("alloc data");
  14.725 +	/* text starts at 0x20, after the header, just like Unix long ago */
  14.726 +	if (gzread(kernel_gfd, &image[0].data[sizeof (Exec)], ehdr.text) <
  14.727 +	    ehdr.text)
  14.728 +		return blah("read text");
  14.729 +	DPRINTF(("READ TEXT %ld bytes\n", ehdr.text));
  14.730 +	datapage = ((ehdr.text + sizeof (Exec)) / PAGE_SIZE) + 1;
  14.731 +	if (gzread(kernel_gfd, image[datapage].data, ehdr.data) < ehdr.data)
  14.732 +		return blah("read data");
  14.733 +	DPRINTF(("READ DATA %ld bytes\n", ehdr.data));
  14.734 +
  14.735 +	/* nice contig stuff */
  14.736 +	/* oops need to start at 0x100000 */
  14.737 +
  14.738 +	ret = memcpy_toguest(xc_handle, dom,
  14.739 +			     image, image_tot_pages * 4096, page_array, 0x100);
  14.740 +	DPRINTF(("done copying kernel to guest memory\n"));
  14.741 +
  14.742 +      out:
  14.743 +	if (image)
  14.744 +		free(image);
  14.745 +	*pdb_page = image_tot_pages + (0x100000 >> PAGE_SHIFT);
  14.746 +	return ret;
  14.747 +}
    15.1 --- a/tools/misc/xencons	Wed Dec 08 01:30:49 2004 +0000
    15.2 +++ b/tools/misc/xencons	Sun Dec 26 10:00:51 2004 +0000
    15.3 @@ -27,24 +27,34 @@ def __recv_from_sock(sock):
    15.4      while not stop:
    15.5          try:
    15.6              data = sock.recv(1024)
    15.7 -            os.write(1, data)
    15.8          except socket.error, error:
    15.9              if error[0] != errno.EINTR:
   15.10                  raise
   15.11 +        else:
   15.12 +            try:
   15.13 +                os.write(1, data)
   15.14 +            except os.error, error:
   15.15 +                if error[0] != errno.EINTR:
   15.16 +                    raise
   15.17      os.wait()
   15.18  
   15.19  def __send_to_sock(sock):
   15.20      while 1:
   15.21 -        data = os.read(0,1024)
   15.22 -        if ord(data[0]) == ord(']')-64:
   15.23 -            break
   15.24          try:
   15.25 -            sock.send(data)
   15.26 -        except socket.error, error:
   15.27 -            if error[0] == errno.EPIPE:
   15.28 -                sys.exit(0)
   15.29 +            data = os.read(0,1024)
   15.30 +        except os.error, error:
   15.31              if error[0] != errno.EINTR:
   15.32                  raise
   15.33 +        else:
   15.34 +            if ord(data[0]) == ord(']')-64:
   15.35 +                break
   15.36 +            try:
   15.37 +                sock.send(data)
   15.38 +            except socket.error, error:
   15.39 +                if error[0] == errno.EPIPE:
   15.40 +                    sys.exit(0)
   15.41 +                if error[0] != errno.EINTR:
   15.42 +                    raise
   15.43      sys.exit(0)
   15.44  
   15.45  def connect(host,port):
    16.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed Dec 08 01:30:49 2004 +0000
    16.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Sun Dec 26 10:00:51 2004 +0000
    16.3 @@ -366,6 +366,33 @@ static PyObject *pyxc_linux_build(PyObje
    16.4      return zero;
    16.5  }
    16.6  
    16.7 +static PyObject *pyxc_plan9_build(PyObject *self,
    16.8 +                                  PyObject *args,
    16.9 +                                  PyObject *kwds)
   16.10 +{
   16.11 +    XcObject *xc = (XcObject *)self;
   16.12 +
   16.13 +    u32   dom;
   16.14 +    char *image, *ramdisk = NULL, *cmdline = "";
   16.15 +    int   control_evtchn, flags = 0;
   16.16 +
   16.17 +    static char *kwd_list[] = { "dom", "control_evtchn",
   16.18 +                                "image", "ramdisk", "cmdline", "flags",
   16.19 +                                NULL };
   16.20 +
   16.21 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssi", kwd_list,
   16.22 +                                      &dom, &control_evtchn,
   16.23 +                                      &image, &ramdisk, &cmdline, &flags) )
   16.24 +        return NULL;
   16.25 +
   16.26 +    if ( xc_plan9_build(xc->xc_handle, dom, image,
   16.27 +                        cmdline, control_evtchn, flags) != 0 )
   16.28 +        return PyErr_SetFromErrno(xc_error);
   16.29 +
   16.30 +    Py_INCREF(zero);
   16.31 +    return zero;
   16.32 +}
   16.33 +
   16.34  static PyObject *pyxc_bvtsched_global_set(PyObject *self,
   16.35                                            PyObject *args,
   16.36                                            PyObject *kwds)
   16.37 @@ -889,6 +916,14 @@ static PyMethodDef pyxc_methods[] = {
   16.38        " state_file [str]:    Name of state file. Must not currently exist.\n"
   16.39        " progress   [int, 1]: Bool - display a running progress indication?\n\n"
   16.40        "Returns: [int] 0 on success; -1 on error.\n" },
   16.41 +    { "plan9_build",
   16.42 +      (PyCFunction)pyxc_plan9_build,
   16.43 +      METH_VARARGS | METH_KEYWORDS, "\n"
   16.44 +      "Build a new Plan 9 guest OS.\n"
   16.45 +      " dom     [long]:     Identifier of domain to build into.\n"
   16.46 +      " image   [str]:      Name of kernel image file. May be gzipped.\n"
   16.47 +      " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
   16.48 +      "Returns: [int] 0 on success; -1 on error.\n" },
   16.49  
   16.50      { "linux_restore", 
   16.51        (PyCFunction)pyxc_linux_restore, 
    17.1 --- a/tools/python/xen/util/console_client.py	Wed Dec 08 01:30:49 2004 +0000
    17.2 +++ b/tools/python/xen/util/console_client.py	Sun Dec 26 10:00:51 2004 +0000
    17.3 @@ -27,24 +27,34 @@ def __recv_from_sock(sock):
    17.4      while not stop:
    17.5          try:
    17.6              data = sock.recv(1024)
    17.7 -            os.write(1, data)
    17.8          except socket.error, error:
    17.9              if error[0] != errno.EINTR:
   17.10                  raise
   17.11 +        else:
   17.12 +            try:
   17.13 +                os.write(1, data)
   17.14 +            except os.error, error:
   17.15 +                if error[0] != errno.EINTR:
   17.16 +                    raise
   17.17      os.wait()
   17.18  
   17.19  def __send_to_sock(sock):
   17.20      while 1:
   17.21 -        data = os.read(0,1024)
   17.22 -        if ord(data[0]) == ord(']')-64:
   17.23 -            break
   17.24          try:
   17.25 -            sock.send(data)
   17.26 -        except socket.error, error:
   17.27 -            if error[0] == errno.EPIPE:
   17.28 -                sys.exit(0)
   17.29 +            data = os.read(0,1024)
   17.30 +        except os.error, error:
   17.31              if error[0] != errno.EINTR:
   17.32                  raise
   17.33 +        else:
   17.34 +            if ord(data[0]) == ord(']')-64:
   17.35 +                break
   17.36 +            try:
   17.37 +                sock.send(data)
   17.38 +            except socket.error, error:
   17.39 +                if error[0] == errno.EPIPE:
   17.40 +                    sys.exit(0)
   17.41 +                if error[0] != errno.EINTR:
   17.42 +                    raise
   17.43      sys.exit(0)
   17.44  
   17.45  def connect(host,port):
    18.1 --- a/tools/python/xen/xend/XendClient.py	Wed Dec 08 01:30:49 2004 +0000
    18.2 +++ b/tools/python/xen/xend/XendClient.py	Sun Dec 26 10:00:51 2004 +0000
    18.3 @@ -228,10 +228,11 @@ class Xend:
    18.4          return self.xendPost(self.domainurl(id),
    18.5                               {'op'      : 'pause' })
    18.6  
    18.7 -    def xend_domain_shutdown(self, id, reason):
    18.8 +    def xend_domain_shutdown(self, id, reason, key=0):
    18.9          return self.xendPost(self.domainurl(id),
   18.10                               {'op'      : 'shutdown',
   18.11 -                              'reason'  : reason })
   18.12 +                              'reason'  : reason,
   18.13 +                              'key'     : key })
   18.14  
   18.15      def xend_domain_destroy(self, id, reason):
   18.16          return self.xendPost(self.domainurl(id),
    19.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Dec 08 01:30:49 2004 +0000
    19.2 +++ b/tools/python/xen/xend/XendDomain.py	Sun Dec 26 10:00:51 2004 +0000
    19.3 @@ -455,7 +455,7 @@ class XendDomain:
    19.4          except Exception, ex:
    19.5              raise XendError(str(ex))
    19.6      
    19.7 -    def domain_shutdown(self, id, reason='poweroff'):
    19.8 +    def domain_shutdown(self, id, reason='poweroff', key=0):
    19.9          """Shutdown domain (nicely).
   19.10           - poweroff: restart according to exit code and restart mode
   19.11           - reboot:   restart on exit
   19.12 @@ -474,7 +474,7 @@ class XendDomain:
   19.13          eserver.inject('xend.domain.shutdown', [dominfo.name, dominfo.id, reason])
   19.14          if reason == 'halt':
   19.15              reason = 'poweroff'
   19.16 -        val = xend.domain_shutdown(dominfo.id, reason)
   19.17 +        val = xend.domain_shutdown(dominfo.id, reason, key)
   19.18          self.refresh_schedule()
   19.19          return val
   19.20  
    20.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Dec 08 01:30:49 2004 +0000
    20.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Sun Dec 26 10:00:51 2004 +0000
    20.3 @@ -1065,6 +1065,34 @@ def vm_image_linux(vm, image):
    20.4      vm.create_domain("linux", kernel, ramdisk, cmdline)
    20.5      return vm
    20.6  
    20.7 +def vm_image_plan9(vm, image):
    20.8 +    """Create a VM for a Plan 9 image.
    20.9 +
   20.10 +    name      vm name
   20.11 +    memory    vm memory
   20.12 +    image     image config
   20.13 +
   20.14 +    returns vm 
   20.15 +    """
   20.16 +    #todo: Same as for linux. Is that right? If so can unify them.
   20.17 +    kernel = sxp.child_value(image, "kernel")
   20.18 +    cmdline = ""
   20.19 +    ip = sxp.child_value(image, "ip", "dhcp")
   20.20 +    if ip:
   20.21 +        cmdline += "ip=" + ip
   20.22 +    root = sxp.child_value(image, "root")
   20.23 +    if root:
   20.24 +        cmdline += "root=" + root
   20.25 +    args = sxp.child_value(image, "args")
   20.26 +    if args:
   20.27 +        cmdline += " " + args
   20.28 +    ramdisk = sxp.child_value(image, "ramdisk", '')
   20.29 +    vifs = vm.config_devices("vif")
   20.30 +    vm.create_domain("plan9", kernel, ramdisk, cmdline)
   20.31 +    return vm
   20.32 +    
   20.33 +    
   20.34 +
   20.35  def vm_dev_vif(vm, val, index, change=0):
   20.36      """Create a virtual network interface (vif).
   20.37  
   20.38 @@ -1186,6 +1214,7 @@ def vm_field_maxmem(vm, config, val, ind
   20.39  
   20.40  # Register image handlers.
   20.41  add_image_handler('linux',  vm_image_linux)
   20.42 +add_image_handler('plan9',  vm_image_plan9)
   20.43  
   20.44  # Register device handlers.
   20.45  add_device_handler('vif',  vm_dev_vif)
    21.1 --- a/tools/python/xen/xend/encode.py	Wed Dec 08 01:30:49 2004 +0000
    21.2 +++ b/tools/python/xen/xend/encode.py	Sun Dec 26 10:00:51 2004 +0000
    21.3 @@ -14,6 +14,8 @@ import httplib
    21.4  import random
    21.5  import md5
    21.6  
    21.7 +from xen.util.ip import _readline, _readlines
    21.8 +
    21.9  # Extract from HTML4 spec.
   21.10  ## The following example illustrates "multipart/form-data"
   21.11  ## encoding. Suppose we have the following form:
   21.12 @@ -122,7 +124,7 @@ def encode_multipart(d):
   21.13              out.write('"\r\n')
   21.14              out.write('Content-Type: application/octet-stream\r\n')
   21.15              out.write('\r\n')
   21.16 -            for l in v.readlines():
   21.17 +            for l in _readlines(v):
   21.18                 out.write(l)  
   21.19          else:
   21.20              out.write('Content-Disposition: form-data; name="')
    22.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Wed Dec 08 01:30:49 2004 +0000
    22.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Sun Dec 26 10:00:51 2004 +0000
    22.3 @@ -711,14 +711,14 @@ class Daemon:
    22.4              raise XendError('Invalid console id')
    22.5          console.disconnect()
    22.6  
    22.7 -    def domain_shutdown(self, dom, reason):
    22.8 +    def domain_shutdown(self, dom, reason, key=0):
    22.9          """Shutdown a domain.
   22.10          """
   22.11          dom = int(dom)
   22.12          ctrl = self.domainCF.getController(dom)
   22.13          if not ctrl:
   22.14              raise XendError('No domain controller: %s' % dom)
   22.15 -        ctrl.shutdown(reason)
   22.16 +        ctrl.shutdown(reason, key)
   22.17          return 0
   22.18  
   22.19      def domain_mem_target_set(self, dom, target):
    23.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Wed Dec 08 01:30:49 2004 +0000
    23.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Sun Dec 26 10:00:51 2004 +0000
    23.3 @@ -47,7 +47,8 @@ class SrvDomain(SrvDir):
    23.4      def op_shutdown(self, op, req):
    23.5          fn = FormFn(self.xd.domain_shutdown,
    23.6                      [['dom', 'str'],
    23.7 -                     ['reason', 'str']])
    23.8 +                     ['reason', 'str'],
    23.9 +                     ['key', 'int']])
   23.10          val = fn(req.args, {'dom': self.dom.id})
   23.11          req.setResponseCode(http.ACCEPTED)
   23.12          req.setHeader("Location", "%s/.." % req.prePathURL())
    24.1 --- a/tools/python/xen/xend/server/domain.py	Wed Dec 08 01:30:49 2004 +0000
    24.2 +++ b/tools/python/xen/xend/server/domain.py	Sun Dec 26 10:00:51 2004 +0000
    24.3 @@ -28,7 +28,8 @@ class DomainController(controller.Contro
    24.4      """
    24.5      reasons = {'poweroff' : 'shutdown_poweroff_t',
    24.6                 'reboot'   : 'shutdown_reboot_t',
    24.7 -               'suspend'  : 'shutdown_suspend_t' }
    24.8 +               'suspend'  : 'shutdown_suspend_t',
    24.9 +               'sysrq'    : 'shutdown_sysrq_t' }
   24.10  
   24.11      def __init__(self, factory, dom):
   24.12          controller.Controller.__init__(self, factory, dom)
   24.13 @@ -36,16 +37,19 @@ class DomainController(controller.Contro
   24.14          self.addMethod(CMSG_MEM_REQUEST, 0, None)
   24.15          self.registerChannel()
   24.16  
   24.17 -    def shutdown(self, reason):
   24.18 +    def shutdown(self, reason, key=0):
   24.19          """Shutdown a domain.
   24.20  
   24.21          reason shutdown reason
   24.22 +        key    sysrq key (only if reason is 'sysrq')
   24.23          """
   24.24          msgtype = self.reasons.get(reason)
   24.25          if not msgtype:
   24.26              raise XendError('invalid reason:' + reason)
   24.27 -        msg = packMsg(msgtype, {})
   24.28 -        self.writeRequest(msg)
   24.29 +        extra = {}
   24.30 +        if reason == 'sysrq': extra['key'] = key
   24.31 +        print extra
   24.32 +        self.writeRequest(packMsg(msgtype, extra))
   24.33  
   24.34      def mem_target_set(self, target):
   24.35          """Set domain memory target in pages.
    25.1 --- a/tools/python/xen/xend/server/messages.py	Wed Dec 08 01:30:49 2004 +0000
    25.2 +++ b/tools/python/xen/xend/server/messages.py	Sun Dec 26 10:00:51 2004 +0000
    25.3 @@ -197,10 +197,12 @@ CMSG_SHUTDOWN = 6
    25.4  CMSG_SHUTDOWN_POWEROFF  = 0
    25.5  CMSG_SHUTDOWN_REBOOT    = 1
    25.6  CMSG_SHUTDOWN_SUSPEND   = 2
    25.7 +CMSG_SHUTDOWN_SYSRQ     = 3
    25.8  
    25.9  STOPCODE_shutdown       = 0
   25.10  STOPCODE_reboot         = 1
   25.11  STOPCODE_suspend        = 2
   25.12 +STOPCODE_sysrq          = 3
   25.13  
   25.14  shutdown_formats = {
   25.15      'shutdown_poweroff_t':
   25.16 @@ -211,6 +213,9 @@ shutdown_formats = {
   25.17  
   25.18      'shutdown_suspend_t':
   25.19      (CMSG_SHUTDOWN, CMSG_SHUTDOWN_SUSPEND),
   25.20 +    
   25.21 +    'shutdown_sysrq_t':
   25.22 +    (CMSG_SHUTDOWN, CMSG_SHUTDOWN_SYSRQ)
   25.23      }
   25.24  
   25.25  msg_formats.update(shutdown_formats)
    26.1 --- a/tools/python/xen/xend/sxp.py	Wed Dec 08 01:30:49 2004 +0000
    26.2 +++ b/tools/python/xen/xend/sxp.py	Sun Dec 26 10:00:51 2004 +0000
    26.3 @@ -17,6 +17,7 @@ import types
    26.4  import errno
    26.5  import string
    26.6  from StringIO import StringIO
    26.7 +from xen.util.ip import _readline, _readlines
    26.8  
    26.9  __all__ = [
   26.10      "mime_type", 
   26.11 @@ -713,7 +714,7 @@ def parse(io):
   26.12      """
   26.13      pin = Parser()
   26.14      while 1:
   26.15 -        buf = io.readline()
   26.16 +        buf = _readline(io)
   26.17          pin.input(buf)
   26.18          if len(buf) == 0:
   26.19              break
    27.1 --- a/tools/python/xen/xm/main.py	Wed Dec 08 01:30:49 2004 +0000
    27.2 +++ b/tools/python/xen/xm/main.py	Sun Dec 26 10:00:51 2004 +0000
    27.3 @@ -11,7 +11,7 @@ from xen.xend import PrettyPrint
    27.4  from xen.xend import sxp
    27.5  from xen.xend.XendClient import XendError, server
    27.6  from xen.xend.XendClient import main as xend_client_main
    27.7 -from xen.xm import create, destroy, migrate, shutdown
    27.8 +from xen.xm import create, destroy, migrate, shutdown, sysrq
    27.9  from xen.xm.opts import *
   27.10  
   27.11  class Group:
   27.12 @@ -401,6 +401,19 @@ class ProgShutdown(Prog):
   27.13  
   27.14  xm.prog(ProgShutdown)
   27.15  
   27.16 +class ProgSysrq(Prog):
   27.17 +    group = 'domain'
   27.18 +    name = "sysrq"
   27.19 +    info = """Send a sysrq to a domain."""
   27.20 +
   27.21 +    def help(self, args):
   27.22 +        sysrq.main([args[0], '-h'])
   27.23 +    
   27.24 +    def main(self, args):
   27.25 +        sysrq.main(args)
   27.26 +
   27.27 +xm.prog(ProgSysrq)
   27.28 +
   27.29  class ProgPause(Prog):
   27.30      group = 'domain'
   27.31      name = "pause"
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/tools/python/xen/xm/sysrq.py	Sun Dec 26 10:00:51 2004 +0000
    28.3 @@ -0,0 +1,39 @@
    28.4 +# (C) Matthew Bloch <matthew@bytemark.co.uk> 2004
    28.5 +
    28.6 +"""Domain shutdown.
    28.7 +"""
    28.8 +import string
    28.9 +import sys
   28.10 +import time
   28.11 +
   28.12 +from xen.xend.XendClient import server
   28.13 +from xen.xm.opts import *
   28.14 +
   28.15 +DOM0_NAME = 'Domain-0'
   28.16 +DOM0_ID = '0'
   28.17 +
   28.18 +gopts = Opts(use="""[DOM] [letter]
   28.19 +
   28.20 +Sends a Linux sysrq to a domain.
   28.21 +""")
   28.22 +
   28.23 +gopts.opt('help', short='h',
   28.24 +         fn=set_true, default=0,
   28.25 +         use="Print this help.")
   28.26 +
   28.27 +def sysrq(dom, req):
   28.28 +    server.xend_domain_shutdown(dom, 'sysrq', req)
   28.29 +
   28.30 +def main(argv):
   28.31 +    opts = gopts
   28.32 +    args = opts.parse(argv)
   28.33 +    if opts.vals.help:
   28.34 +        opts.usage()
   28.35 +        return
   28.36 +        
   28.37 +    # no options for the moment
   28.38 +    if len(args) < 1: opts.err('Missing domain')
   28.39 +    if len(args) < 2: opts.err('Missing sysrq character')
   28.40 +    dom = args[0]
   28.41 +    req = ord(args[1][0])
   28.42 +    sysrq(dom, req)
    29.1 --- a/xen/arch/x86/Rules.mk	Wed Dec 08 01:30:49 2004 +0000
    29.2 +++ b/xen/arch/x86/Rules.mk	Sun Dec 26 10:00:51 2004 +0000
    29.3 @@ -32,3 +32,20 @@ CFLAGS  += -m64 -mno-red-zone -fpic -fno
    29.4  CFLAGS  += -fno-asynchronous-unwind-tables
    29.5  LDFLAGS := --oformat elf64-x86-64
    29.6  endif
    29.7 +
    29.8 +# Test for at least GCC v3.2.x.
    29.9 +gcc-ver = $(shell $(CC) -dumpversion | sed -e 's/^\(.\)\.\(.\)\.\(.\)/\$(1)/')
   29.10 +ifeq ($(call gcc-ver,1),1)
   29.11 +$(error gcc-1.x.x unsupported - upgrade to at least gcc-3.2.x)
   29.12 +endif
   29.13 +ifeq ($(call gcc-ver,1),2)
   29.14 +$(error gcc-2.x.x unsupported - upgrade to at least gcc-3.2.x)
   29.15 +endif
   29.16 +ifeq ($(call gcc-ver,1),3)
   29.17 +ifeq ($(call gcc-ver,2),0)
   29.18 +$(error gcc-3.0.x unsupported - upgrade to at least gcc-3.2.x)
   29.19 +endif
   29.20 +ifeq ($(call gcc-ver,2),1)
   29.21 +$(error gcc-3.1.x unsupported - upgrade to at least gcc-3.2.x)
   29.22 +endif
   29.23 +endif
    30.1 --- a/xen/arch/x86/boot/x86_32.S	Wed Dec 08 01:30:49 2004 +0000
    30.2 +++ b/xen/arch/x86/boot/x86_32.S	Sun Dec 26 10:00:51 2004 +0000
    30.3 @@ -102,15 +102,15 @@ 1:      lss     stack_start-__PAGE_OFFSE
    30.4  
    30.5          /* Initialize low and high mappings of all memory with 4MB pages */
    30.6          mov     $idle_pg_table-__PAGE_OFFSET,%edi
    30.7 -        mov     $0x1e3,%eax                  /* PRESENT+RW+A+D+4MB+GLOBAL */
    30.8 +        mov     $0xe3,%eax                  /* PRESENT+RW+A+D+4MB */
    30.9  1:      mov     %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */
   30.10          stosl                                /* low mapping */
   30.11          add     $(1<<L2_PAGETABLE_SHIFT),%eax
   30.12 -        cmp     $DIRECTMAP_PHYS_END+0x1e3,%eax
   30.13 +        cmp     $DIRECTMAP_PHYS_END+0xe3,%eax
   30.14          jne     1b
   30.15  1:      stosl   /* low mappings cover as much physmem as possible */
   30.16          add     $(1<<L2_PAGETABLE_SHIFT),%eax
   30.17 -        cmp     $__HYPERVISOR_VIRT_START+0x1e3,%eax
   30.18 +        cmp     $__HYPERVISOR_VIRT_START+0xe3,%eax
   30.19          jne     1b
   30.20          
   30.21          /* Initialise IDT with simple error defaults. */
    31.1 --- a/xen/arch/x86/boot/x86_64.S	Wed Dec 08 01:30:49 2004 +0000
    31.2 +++ b/xen/arch/x86/boot/x86_64.S	Sun Dec 26 10:00:51 2004 +0000
    31.3 @@ -257,30 +257,22 @@ copy_to_user:
    31.4  set_intr_gate:
    31.5  die:
    31.6  machine_to_phys_mapping:
    31.7 -.globl copy_from_user, show_registers, __set_fixmap, do_iopl, check_descriptor
    31.8 +.globl copy_from_user, show_registers, do_iopl
    31.9  copy_from_user: 
   31.10  show_registers: 
   31.11 -__set_fixmap: 
   31.12  do_iopl: 
   31.13 -check_descriptor:
   31.14 -.globl set_gdt, idt_table, copy_user_generic, memcmp, idt_tables, new_thread
   31.15 -set_gdt:
   31.16 +.globl idt_table, copy_user_generic, memcmp, idt_tables, new_thread
   31.17  idt_table:
   31.18  copy_user_generic:
   31.19  memcmp:
   31.20  idt_tables:
   31.21  new_thread:
   31.22 -.globl switch_to, continue_nonidle_task, __get_user_1, paging_init, trap_init
   31.23 +.globl switch_to, __get_user_1, __get_user_4, __get_user_8, trap_init
   31.24  switch_to:
   31.25 -continue_nonidle_task:
   31.26  __get_user_1:
   31.27 -paging_init:
   31.28 +__get_user_4:
   31.29 +__get_user_8:
   31.30  trap_init: 
   31.31 -.globl __get_user_8, zap_low_mappings, set_debugreg,synchronise_pagetables
   31.32 -__get_user_8:
   31.33 -zap_low_mappings:
   31.34 +.globl set_debugreg
   31.35  set_debugreg:
   31.36 -synchronise_pagetables:
   31.37 -.globl destroy_gdt
   31.38 -destroy_gdt:    
   31.39          
    32.1 --- a/xen/arch/x86/domain.c	Wed Dec 08 01:30:49 2004 +0000
    32.2 +++ b/xen/arch/x86/domain.c	Sun Dec 26 10:00:51 2004 +0000
    32.3 @@ -48,35 +48,16 @@
    32.4  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    32.5  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    32.6  
    32.7 -int hlt_counter;
    32.8 -
    32.9 -void disable_hlt(void)
   32.10 +static void default_idle(void)
   32.11  {
   32.12 -    hlt_counter++;
   32.13 -}
   32.14 -
   32.15 -void enable_hlt(void)
   32.16 -{
   32.17 -    hlt_counter--;
   32.18 +    __cli();
   32.19 +    if ( !softirq_pending(smp_processor_id()) )
   32.20 +        safe_halt();
   32.21 +    else
   32.22 +        __sti();
   32.23  }
   32.24  
   32.25 -/*
   32.26 - * We use this if we don't have any better
   32.27 - * idle routine..
   32.28 - */
   32.29 -static void default_idle(void)
   32.30 -{
   32.31 -    if ( hlt_counter == 0 )
   32.32 -    {
   32.33 -        __cli();
   32.34 -        if ( !softirq_pending(smp_processor_id()) )
   32.35 -            safe_halt();
   32.36 -        else
   32.37 -            __sti();
   32.38 -    }
   32.39 -}
   32.40 -
   32.41 -void continue_cpu_idle_loop(void)
   32.42 +static __attribute_used__ void idle_loop(void)
   32.43  {
   32.44      int cpu = smp_processor_id();
   32.45      for ( ; ; )
   32.46 @@ -102,7 +83,7 @@ void startup_cpu_idle_loop(void)
   32.47      smp_mb();
   32.48      init_idle();
   32.49  
   32.50 -    continue_cpu_idle_loop();
   32.51 +    idle_loop();
   32.52  }
   32.53  
   32.54  static long no_idt[2];
   32.55 @@ -216,20 +197,43 @@ void free_perdomain_pt(struct domain *d)
   32.56      free_xenheap_page((unsigned long)d->mm.perdomain_pt);
   32.57  }
   32.58  
   32.59 +static void continue_idle_task(struct domain *d)
   32.60 +{
   32.61 +    reset_stack_and_jump(idle_loop);
   32.62 +}
   32.63 +
   32.64 +static void continue_nonidle_task(struct domain *d)
   32.65 +{
   32.66 +    reset_stack_and_jump(ret_from_intr);
   32.67 +}
   32.68 +
   32.69  void arch_do_createdomain(struct domain *d)
   32.70  {
   32.71 -    d->shared_info = (void *)alloc_xenheap_page();
   32.72 -    memset(d->shared_info, 0, PAGE_SIZE);
   32.73 -    d->shared_info->arch.mfn_to_pfn_start = 
   32.74 -	virt_to_phys(&machine_to_phys_mapping[0])>>PAGE_SHIFT;
   32.75 -    SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
   32.76 -    machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
   32.77 -                           PAGE_SHIFT] = INVALID_P2M_ENTRY;
   32.78 +#ifdef ARCH_HAS_FAST_TRAP
   32.79 +    SET_DEFAULT_FAST_TRAP(&d->thread);
   32.80 +#endif
   32.81 +
   32.82 +    if ( d->id == IDLE_DOMAIN_ID )
   32.83 +    {
   32.84 +        d->thread.schedule_tail = continue_idle_task;
   32.85 +    }
   32.86 +    else
   32.87 +    {
   32.88 +        d->thread.schedule_tail = continue_nonidle_task;
   32.89  
   32.90 -    d->mm.perdomain_pt = (l1_pgentry_t *)alloc_xenheap_page();
   32.91 -    memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
   32.92 -    machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
   32.93 -                           PAGE_SHIFT] = INVALID_P2M_ENTRY;
   32.94 +        d->shared_info = (void *)alloc_xenheap_page();
   32.95 +        memset(d->shared_info, 0, PAGE_SIZE);
   32.96 +        d->shared_info->arch.mfn_to_pfn_start = 
   32.97 +            virt_to_phys(&machine_to_phys_mapping[0])>>PAGE_SHIFT;
   32.98 +        SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
   32.99 +        machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
  32.100 +                               PAGE_SHIFT] = INVALID_P2M_ENTRY;
  32.101 +
  32.102 +        d->mm.perdomain_pt = (l1_pgentry_t *)alloc_xenheap_page();
  32.103 +        memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
  32.104 +        machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
  32.105 +                               PAGE_SHIFT] = INVALID_P2M_ENTRY;
  32.106 +    }
  32.107  }
  32.108  
  32.109  int arch_final_setup_guestos(struct domain *d, full_execution_context_t *c)
  32.110 @@ -263,7 +267,6 @@ int arch_final_setup_guestos(struct doma
  32.111             sizeof(d->thread.traps));
  32.112  
  32.113  #ifdef ARCH_HAS_FAST_TRAP
  32.114 -    SET_DEFAULT_FAST_TRAP(&d->thread);
  32.115      if ( (rc = (int)set_fast_trap(d, c->fast_trap_idx)) != 0 )
  32.116          return rc;
  32.117  #endif
  32.118 @@ -328,9 +331,6 @@ void new_thread(struct domain *d,
  32.119  
  32.120      __save_flags(ec->eflags);
  32.121      ec->eflags |= X86_EFLAGS_IF;
  32.122 -
  32.123 -    /* No fast trap at start of day. */
  32.124 -    SET_DEFAULT_FAST_TRAP(&d->thread);
  32.125  }
  32.126  
  32.127  
  32.128 @@ -427,6 +427,8 @@ long do_iopl(domid_t domain, unsigned in
  32.129      return 0;
  32.130  }
  32.131  
  32.132 +#endif
  32.133 +
  32.134  unsigned long hypercall_create_continuation(
  32.135      unsigned int op, unsigned int nr_args, ...)
  32.136  {
  32.137 @@ -448,11 +450,15 @@ unsigned long hypercall_create_continuat
  32.138      else
  32.139      {
  32.140          ec       = get_execution_context();
  32.141 +#if defined(__i386__)
  32.142          ec->eax  = op;
  32.143          ec->eip -= 2;  /* re-execute 'int 0x82' */
  32.144          
  32.145          for ( i = 0, preg = &ec->ebx; i < nr_args; i++, preg++ )
  32.146              *preg = va_arg(args, unsigned long);
  32.147 +#else
  32.148 +        preg = NULL; /* XXX x86/64 */
  32.149 +#endif
  32.150      }
  32.151  
  32.152      va_end(args);
  32.153 @@ -460,9 +466,6 @@ unsigned long hypercall_create_continuat
  32.154      return op;
  32.155  }
  32.156  
  32.157 -#endif
  32.158 -
  32.159 -
  32.160  static void relinquish_list(struct domain *d, struct list_head *list)
  32.161  {
  32.162      struct list_head *ent;
    33.1 --- a/xen/arch/x86/setup.c	Wed Dec 08 01:30:49 2004 +0000
    33.2 +++ b/xen/arch/x86/setup.c	Sun Dec 26 10:00:51 2004 +0000
    33.3 @@ -328,6 +328,8 @@ void __init start_of_day(void)
    33.4  
    33.5      sort_exception_tables();
    33.6  
    33.7 +    arch_do_createdomain(current);
    33.8 +
    33.9      /* Tell the PCI layer not to allocate too close to the RAM area.. */
   33.10      low_mem_size = ((max_page << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
   33.11      if ( low_mem_size > pci_mem_start ) pci_mem_start = low_mem_size;
    34.1 --- a/xen/arch/x86/shadow.c	Wed Dec 08 01:30:49 2004 +0000
    34.2 +++ b/xen/arch/x86/shadow.c	Sun Dec 26 10:00:51 2004 +0000
    34.3 @@ -517,10 +517,10 @@ static void shadow_map_l1_into_current_l
    34.4              mk_l2_pgentry(spde);
    34.5  
    34.6          gpl1e = (unsigned long *) &(linear_pg_table[
    34.7 -            (va>>PAGE_SHIFT) & ~(ENTRIES_PER_L1_PAGETABLE-1)]);
    34.8 +            (va>>L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE-1)]);
    34.9  
   34.10 -        spl1e = (unsigned long *) &shadow_linear_pg_table[
   34.11 -            (va>>PAGE_SHIFT) & ~(ENTRIES_PER_L1_PAGETABLE-1)];
   34.12 +        spl1e = (unsigned long *) &(shadow_linear_pg_table[
   34.13 +            (va>>L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE-1)]);
   34.14  
   34.15          for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   34.16              l1pte_propagate_from_guest(m, &gpl1e[i], &spl1e[i]);
    35.1 --- a/xen/arch/x86/smpboot.c	Wed Dec 08 01:30:49 2004 +0000
    35.2 +++ b/xen/arch/x86/smpboot.c	Sun Dec 26 10:00:51 2004 +0000
    35.3 @@ -662,10 +662,6 @@ static void __init do_boot_cpu (int apic
    35.4  
    35.5      map_cpu_to_boot_apicid(cpu, apicid);
    35.6  
    35.7 -#if defined(__i386__)
    35.8 -    SET_DEFAULT_FAST_TRAP(&idle->thread);
    35.9 -#endif
   35.10 -
   35.11      idle_task[cpu] = idle;
   35.12  
   35.13      /* start_eip had better be page-aligned! */
    36.1 --- a/xen/arch/x86/traps.c	Wed Dec 08 01:30:49 2004 +0000
    36.2 +++ b/xen/arch/x86/traps.c	Sun Dec 26 10:00:51 2004 +0000
    36.3 @@ -981,4 +981,10 @@ unsigned long do_get_debugreg(int reg)
    36.4      return current->thread.debugreg[reg];
    36.5  }
    36.6  
    36.7 +#else
    36.8 +
    36.9 +asmlinkage void fatal_trap(int trapnr, struct xen_regs *regs)
   36.10 +{
   36.11 +}
   36.12 +
   36.13  #endif /* __i386__ */
    37.1 --- a/xen/arch/x86/x86_32/entry.S	Wed Dec 08 01:30:49 2004 +0000
    37.2 +++ b/xen/arch/x86/x86_32/entry.S	Sun Dec 26 10:00:51 2004 +0000
    37.3 @@ -56,7 +56,7 @@
    37.4  #include <xen/config.h>
    37.5  #include <xen/errno.h>
    37.6  #include <xen/softirq.h>
    37.7 -#include <asm/x86_32/asm_defns.h>
    37.8 +#include <asm/asm_defns.h>
    37.9  #include <public/xen.h>
   37.10  
   37.11  #define GET_CURRENT(reg)   \
   37.12 @@ -65,10 +65,6 @@
   37.13          andl $~3,reg;      \
   37.14          movl (reg),reg;
   37.15  
   37.16 -ENTRY(continue_nonidle_task)
   37.17 -        GET_CURRENT(%ebx)
   37.18 -        jmp test_all_events
   37.19 -
   37.20          ALIGN
   37.21  restore_all_guest:
   37.22          testb $TF_failsafe_return,DOMAIN_thread_flags(%ebx)
    38.1 --- a/xen/arch/x86/x86_32/mm.c	Wed Dec 08 01:30:49 2004 +0000
    38.2 +++ b/xen/arch/x86/x86_32/mm.c	Sun Dec 26 10:00:51 2004 +0000
    38.3 @@ -59,11 +59,13 @@ void __init paging_init(void)
    38.4      void *ioremap_pt;
    38.5      int i;
    38.6  
    38.7 -    /* Idle page table 1:1 maps the first part of physical memory. */
    38.8 -    for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
    38.9 -        idle_pg_table[i] = 
   38.10 -            mk_l2_pgentry((i << L2_PAGETABLE_SHIFT) | 
   38.11 -                          __PAGE_HYPERVISOR | _PAGE_PSE);
   38.12 +    /* Xen heap mappings can be GLOBAL. */
   38.13 +    if ( cpu_has_pge )
   38.14 +    {
   38.15 +        for ( i = 0; i < DIRECTMAP_PHYS_END; i += (1 << L2_PAGETABLE_SHIFT) )
   38.16 +            ((unsigned long *)idle_pg_table)
   38.17 +                [(i + PAGE_OFFSET) >> L2_PAGETABLE_SHIFT] |= _PAGE_GLOBAL;
   38.18 +    }
   38.19  
   38.20      /* Create page table for ioremap(). */
   38.21      ioremap_pt = (void *)alloc_xenheap_page();
   38.22 @@ -86,7 +88,6 @@ void __init paging_init(void)
   38.23      /* Set up linear page table mapping. */
   38.24      idle_pg_table[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
   38.25          mk_l2_pgentry(__pa(idle_pg_table) | __PAGE_HYPERVISOR);
   38.26 -
   38.27  }
   38.28  
   38.29  void __init zap_low_mappings(void)
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/xen/arch/x86/x86_64/asm-offsets.c	Sun Dec 26 10:00:51 2004 +0000
    39.3 @@ -0,0 +1,71 @@
    39.4 +/*
    39.5 + * Generate definitions needed by assembly language modules.
    39.6 + * This code generates raw asm output which is post-processed
    39.7 + * to extract and format the required data.
    39.8 + */
    39.9 +
   39.10 +#include <xen/sched.h>
   39.11 +
   39.12 +#define DEFINE(_sym, _val) \
   39.13 +    __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) )
   39.14 +#define BLANK() \
   39.15 +    __asm__ __volatile__ ( "\n->" : : )
   39.16 +#define OFFSET(_sym, _str, _mem) \
   39.17 +    DEFINE(_sym, offsetof(_str, _mem));
   39.18 +
   39.19 +void __dummy__(void)
   39.20 +{
   39.21 +    OFFSET(XREGS_r15, struct xen_regs, r15);
   39.22 +    OFFSET(XREGS_r14, struct xen_regs, r14);
   39.23 +    OFFSET(XREGS_r13, struct xen_regs, r13);
   39.24 +    OFFSET(XREGS_r12, struct xen_regs, r12);
   39.25 +    OFFSET(XREGS_rbp, struct xen_regs, rbp);
   39.26 +    OFFSET(XREGS_rbx, struct xen_regs, rbx);
   39.27 +    OFFSET(XREGS_r11, struct xen_regs, r11);
   39.28 +    OFFSET(XREGS_r10, struct xen_regs, r10);
   39.29 +    OFFSET(XREGS_r9, struct xen_regs, r9);
   39.30 +    OFFSET(XREGS_r8, struct xen_regs, r8);
   39.31 +    OFFSET(XREGS_rax, struct xen_regs, rax);
   39.32 +    OFFSET(XREGS_rcx, struct xen_regs, rcx);
   39.33 +    OFFSET(XREGS_rdx, struct xen_regs, rdx);
   39.34 +    OFFSET(XREGS_rsi, struct xen_regs, rsi);
   39.35 +    OFFSET(XREGS_rdi, struct xen_regs, rdi);
   39.36 +    OFFSET(XREGS_orig_rax, struct xen_regs, orig_rax);
   39.37 +    OFFSET(XREGS_rip, struct xen_regs, rip);
   39.38 +    OFFSET(XREGS_cs, struct xen_regs, cs);
   39.39 +    OFFSET(XREGS_eflags, struct xen_regs, eflags);
   39.40 +    OFFSET(XREGS_rsp, struct xen_regs, rsp);
   39.41 +    OFFSET(XREGS_ss, struct xen_regs, ss);
   39.42 +    BLANK();
   39.43 +
   39.44 +    OFFSET(DOMAIN_processor, struct domain, processor);
   39.45 +    OFFSET(DOMAIN_shared_info, struct domain, shared_info);
   39.46 +    OFFSET(DOMAIN_event_sel, struct domain, thread.event_selector);
   39.47 +    OFFSET(DOMAIN_event_addr, struct domain, thread.event_address);
   39.48 +    OFFSET(DOMAIN_failsafe_sel, struct domain, thread.failsafe_selector);
   39.49 +    OFFSET(DOMAIN_failsafe_addr, struct domain, thread.failsafe_address);
   39.50 +    OFFSET(DOMAIN_trap_bounce, struct domain, thread.trap_bounce);
   39.51 +    OFFSET(DOMAIN_thread_flags, struct domain, thread.flags);
   39.52 +    BLANK();
   39.53 +
   39.54 +    OFFSET(SHINFO_upcall_pending, shared_info_t, 
   39.55 +           vcpu_data[0].evtchn_upcall_pending);
   39.56 +    OFFSET(SHINFO_upcall_mask, shared_info_t, 
   39.57 +           vcpu_data[0].evtchn_upcall_mask);
   39.58 +    BLANK();
   39.59 +
   39.60 +    OFFSET(TRAPBOUNCE_error_code, struct trap_bounce, error_code);
   39.61 +    OFFSET(TRAPBOUNCE_cr2, struct trap_bounce, cr2);
   39.62 +    OFFSET(TRAPBOUNCE_flags, struct trap_bounce, flags);
   39.63 +    OFFSET(TRAPBOUNCE_cs, struct trap_bounce, cs);
   39.64 +    OFFSET(TRAPBOUNCE_eip, struct trap_bounce, eip);
   39.65 +    BLANK();
   39.66 +
   39.67 +    OFFSET(MULTICALL_op, multicall_entry_t, op);
   39.68 +    OFFSET(MULTICALL_arg0, multicall_entry_t, args[0]);
   39.69 +    OFFSET(MULTICALL_arg1, multicall_entry_t, args[1]);
   39.70 +    OFFSET(MULTICALL_arg2, multicall_entry_t, args[2]);
   39.71 +    OFFSET(MULTICALL_arg3, multicall_entry_t, args[3]);
   39.72 +    OFFSET(MULTICALL_arg4, multicall_entry_t, args[4]);
   39.73 +    OFFSET(MULTICALL_result, multicall_entry_t, args[5]);
   39.74 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/xen/arch/x86/x86_64/mm.c	Sun Dec 26 10:00:51 2004 +0000
    40.3 @@ -0,0 +1,455 @@
    40.4 +/******************************************************************************
    40.5 + * arch/x86/x86_64/mm.c
    40.6 + * 
    40.7 + * Modifications to Linux original are copyright (c) 2004, K A Fraser
    40.8 + * 
    40.9 + * This program is free software; you can redistribute it and/or modify
   40.10 + * it under the terms of the GNU General Public License as published by
   40.11 + * the Free Software Foundation; either version 2 of the License, or
   40.12 + * (at your option) any later version.
   40.13 + * 
   40.14 + * This program is distributed in the hope that it will be useful,
   40.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   40.17 + * GNU General Public License for more details.
   40.18 + * 
   40.19 + * You should have received a copy of the GNU General Public License
   40.20 + * along with this program; if not, write to the Free Software
   40.21 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   40.22 + */
   40.23 +
   40.24 +#include <xen/config.h>
   40.25 +#include <xen/lib.h>
   40.26 +#include <xen/init.h>
   40.27 +#include <xen/mm.h>
   40.28 +#include <asm/page.h>
   40.29 +#include <asm/flushtlb.h>
   40.30 +#include <asm/fixmap.h>
   40.31 +#include <asm/domain_page.h>
   40.32 +
   40.33 +static inline void set_pte_phys(unsigned long vaddr,
   40.34 +                                l1_pgentry_t entry)
   40.35 +{
   40.36 +    l4_pgentry_t *l4ent;
   40.37 +    l3_pgentry_t *l3ent;
   40.38 +    l2_pgentry_t *l2ent;
   40.39 +    l1_pgentry_t *l1ent;
   40.40 +
   40.41 +    l4ent = &idle_pg_table[l4_table_offset(vaddr)];
   40.42 +    l3ent = l4_pgentry_to_l3(*l4ent) + l3_table_offset(vaddr);
   40.43 +    l2ent = l3_pgentry_to_l2(*l3ent) + l2_table_offset(vaddr);
   40.44 +    l1ent = l2_pgentry_to_l1(*l2ent) + l1_table_offset(vaddr);
   40.45 +    *l1ent = entry;
   40.46 +
   40.47 +    /* It's enough to flush this one mapping. */
   40.48 +    __flush_tlb_one(vaddr);
   40.49 +}
   40.50 +
   40.51 +
   40.52 +void __set_fixmap(enum fixed_addresses idx, 
   40.53 +                  l1_pgentry_t entry)
   40.54 +{
   40.55 +    unsigned long address = fix_to_virt(idx);
   40.56 +
   40.57 +    if ( likely(idx < __end_of_fixed_addresses) )
   40.58 +        set_pte_phys(address, entry);
   40.59 +    else
   40.60 +        printk("Invalid __set_fixmap\n");
   40.61 +}
   40.62 +
   40.63 +
   40.64 +void __init paging_init(void)
   40.65 +{
   40.66 +    void *ioremap_pt;
   40.67 +    int i;
   40.68 +
   40.69 +    /* Create page table for ioremap(). */
   40.70 +    ioremap_pt = (void *)alloc_xenheap_page();
   40.71 +    clear_page(ioremap_pt);
   40.72 +    idle_pg_table[IOREMAP_VIRT_START >> L2_PAGETABLE_SHIFT] = 
   40.73 +        mk_l2_pgentry(__pa(ioremap_pt) | __PAGE_HYPERVISOR);
   40.74 +
   40.75 +    /* Create read-only mapping of MPT for guest-OS use. */
   40.76 +    idle_pg_table[RO_MPT_VIRT_START >> L2_PAGETABLE_SHIFT] =
   40.77 +        mk_l2_pgentry(l2_pgentry_val(
   40.78 +            idle_pg_table[RDWR_MPT_VIRT_START >> L2_PAGETABLE_SHIFT]) & 
   40.79 +                      ~_PAGE_RW);
   40.80 +
   40.81 +    /* Set up mapping cache for domain pages. */
   40.82 +    mapcache = (unsigned long *)alloc_xenheap_page();
   40.83 +    clear_page(mapcache);
   40.84 +    idle_pg_table[MAPCACHE_VIRT_START >> L2_PAGETABLE_SHIFT] =
   40.85 +        mk_l2_pgentry(__pa(mapcache) | __PAGE_HYPERVISOR);
   40.86 +
   40.87 +    /* Set up linear page table mapping. */
   40.88 +    idle_pg_table[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =
   40.89 +        mk_l2_pgentry(__pa(idle_pg_table) | __PAGE_HYPERVISOR);
   40.90 +
   40.91 +}
   40.92 +
   40.93 +void __init zap_low_mappings(void)
   40.94 +{
   40.95 +    idle_pg_table[0] = 0;
   40.96 +}
   40.97 +
   40.98 +
   40.99 +/*
  40.100 + * Allows shooting down of borrowed page-table use on specific CPUs.
  40.101 + * Specifically, we borrow page tables when running the idle domain.
  40.102 + */
  40.103 +static void __synchronise_pagetables(void *mask)
  40.104 +{
  40.105 +    struct domain *d = current;
  40.106 +    if ( ((unsigned long)mask & (1<<d->processor)) && is_idle_task(d) )
  40.107 +        write_ptbase(&d->mm);
  40.108 +}
  40.109 +void synchronise_pagetables(unsigned long cpu_mask)
  40.110 +{
  40.111 +    __synchronise_pagetables((void *)cpu_mask);
  40.112 +    smp_call_function(__synchronise_pagetables, (void *)cpu_mask, 1, 1);
  40.113 +}
  40.114 +
  40.115 +long do_stack_switch(unsigned long ss, unsigned long esp)
  40.116 +{
  40.117 +    int nr = smp_processor_id();
  40.118 +    struct tss_struct *t = &init_tss[nr];
  40.119 +
  40.120 +    /* We need to do this check as we load and use SS on guest's behalf. */
  40.121 +    if ( (ss & 3) == 0 )
  40.122 +        return -EPERM;
  40.123 +
  40.124 +    current->thread.guestos_ss = ss;
  40.125 +    current->thread.guestos_sp = esp;
  40.126 +    t->ss1  = ss;
  40.127 +    t->esp1 = esp;
  40.128 +
  40.129 +    return 0;
  40.130 +}
  40.131 +
  40.132 +
  40.133 +/* Returns TRUE if given descriptor is valid for GDT or LDT. */
  40.134 +int check_descriptor(unsigned long *d)
  40.135 +{
  40.136 +    unsigned long base, limit, a = d[0], b = d[1];
  40.137 +
  40.138 +    /* A not-present descriptor will always fault, so is safe. */
  40.139 +    if ( !(b & _SEGMENT_P) ) 
  40.140 +        goto good;
  40.141 +
  40.142 +    /*
  40.143 +     * We don't allow a DPL of zero. There is no legitimate reason for 
  40.144 +     * specifying DPL==0, and it gets rather dangerous if we also accept call 
  40.145 +     * gates (consider a call gate pointing at another guestos descriptor with 
  40.146 +     * DPL 0 -- this would get the OS ring-0 privileges).
  40.147 +     */
  40.148 +    if ( (b & _SEGMENT_DPL) == 0 )
  40.149 +        goto bad;
  40.150 +
  40.151 +    if ( !(b & _SEGMENT_S) )
  40.152 +    {
  40.153 +        /*
  40.154 +         * System segment:
  40.155 +         *  1. Don't allow interrupt or trap gates as they belong in the IDT.
  40.156 +         *  2. Don't allow TSS descriptors or task gates as we don't
  40.157 +         *     virtualise x86 tasks.
  40.158 +         *  3. Don't allow LDT descriptors because they're unnecessary and
  40.159 +         *     I'm uneasy about allowing an LDT page to contain LDT
  40.160 +         *     descriptors. In any case, Xen automatically creates the
  40.161 +         *     required descriptor when reloading the LDT register.
  40.162 +         *  4. We allow call gates but they must not jump to a private segment.
  40.163 +         */
  40.164 +
  40.165 +        /* Disallow everything but call gates. */
  40.166 +        if ( (b & _SEGMENT_TYPE) != 0xc00 )
  40.167 +            goto bad;
  40.168 +
  40.169 +        /* Can't allow far jump to a Xen-private segment. */
  40.170 +        if ( !VALID_CODESEL(a>>16) )
  40.171 +            goto bad;
  40.172 +
  40.173 +        /* Reserved bits must be zero. */
  40.174 +        if ( (b & 0xe0) != 0 )
  40.175 +            goto bad;
  40.176 +        
  40.177 +        /* No base/limit check is needed for a call gate. */
  40.178 +        goto good;
  40.179 +    }
  40.180 +    
  40.181 +    /* Check that base is at least a page away from Xen-private area. */
  40.182 +    base  = (b&(0xff<<24)) | ((b&0xff)<<16) | (a>>16);
  40.183 +    if ( base >= (PAGE_OFFSET - PAGE_SIZE) )
  40.184 +        goto bad;
  40.185 +
  40.186 +    /* Check and truncate the limit if necessary. */
  40.187 +    limit = (b&0xf0000) | (a&0xffff);
  40.188 +    limit++; /* We add one because limit is inclusive. */
  40.189 +    if ( (b & _SEGMENT_G) )
  40.190 +        limit <<= 12;
  40.191 +
  40.192 +    if ( (b & (_SEGMENT_CODE | _SEGMENT_EC)) == _SEGMENT_EC )
  40.193 +    {
  40.194 +        /*
  40.195 +         * Grows-down limit check. 
  40.196 +         * NB. limit == 0xFFFFF provides no access      (if G=1).
  40.197 +         *     limit == 0x00000 provides 4GB-4kB access (if G=1).
  40.198 +         */
  40.199 +        if ( (base + limit) > base )
  40.200 +        {
  40.201 +            limit = -(base & PAGE_MASK);
  40.202 +            goto truncate;
  40.203 +        }
  40.204 +    }
  40.205 +    else
  40.206 +    {
  40.207 +        /*
  40.208 +         * Grows-up limit check.
  40.209 +         * NB. limit == 0xFFFFF provides 4GB access (if G=1).
  40.210 +         *     limit == 0x00000 provides 4kB access (if G=1).
  40.211 +         */
  40.212 +        if ( ((base + limit) <= base) || 
  40.213 +             ((base + limit) > PAGE_OFFSET) )
  40.214 +        {
  40.215 +            limit = PAGE_OFFSET - base;
  40.216 +        truncate:
  40.217 +            if ( !(b & _SEGMENT_G) )
  40.218 +                goto bad; /* too dangerous; too hard to work out... */
  40.219 +            limit = (limit >> 12) - 1;
  40.220 +            d[0] &= ~0x0ffff; d[0] |= limit & 0x0ffff;
  40.221 +            d[1] &= ~0xf0000; d[1] |= limit & 0xf0000;
  40.222 +        }
  40.223 +    }
  40.224 +
  40.225 + good:
  40.226 +    return 1;
  40.227 + bad:
  40.228 +    return 0;
  40.229 +}
  40.230 +
  40.231 +
  40.232 +void destroy_gdt(struct domain *d)
  40.233 +{
  40.234 +    int i;
  40.235 +    unsigned long pfn;
  40.236 +
  40.237 +    for ( i = 0; i < 16; i++ )
  40.238 +    {
  40.239 +        if ( (pfn = l1_pgentry_to_pagenr(d->mm.perdomain_pt[i])) != 0 )
  40.240 +            put_page_and_type(&frame_table[pfn]);
  40.241 +        d->mm.perdomain_pt[i] = mk_l1_pgentry(0);
  40.242 +    }
  40.243 +}
  40.244 +
  40.245 +
  40.246 +long set_gdt(struct domain *d, 
  40.247 +             unsigned long *frames,
  40.248 +             unsigned int entries)
  40.249 +{
  40.250 +    /* NB. There are 512 8-byte entries per GDT page. */
  40.251 +    int i = 0, nr_pages = (entries + 511) / 512;
  40.252 +    struct desc_struct *vgdt;
  40.253 +    unsigned long pfn;
  40.254 +
  40.255 +    /* Check the first page in the new GDT. */
  40.256 +    if ( (pfn = frames[0]) >= max_page )
  40.257 +        goto fail;
  40.258 +
  40.259 +    /* The first page is special because Xen owns a range of entries in it. */
  40.260 +    if ( !get_page_and_type(&frame_table[pfn], d, PGT_gdt_page) )
  40.261 +    {
  40.262 +        /* GDT checks failed: try zapping the Xen reserved entries. */
  40.263 +        if ( !get_page_and_type(&frame_table[pfn], d, PGT_writable_page) )
  40.264 +            goto fail;
  40.265 +        vgdt = map_domain_mem(pfn << PAGE_SHIFT);
  40.266 +        memset(vgdt + FIRST_RESERVED_GDT_ENTRY, 0,
  40.267 +               NR_RESERVED_GDT_ENTRIES*8);
  40.268 +        unmap_domain_mem(vgdt);
  40.269 +        put_page_and_type(&frame_table[pfn]);
  40.270 +
  40.271 +        /* Okay, we zapped the entries. Now try the GDT checks again. */
  40.272 +        if ( !get_page_and_type(&frame_table[pfn], d, PGT_gdt_page) )
  40.273 +            goto fail;
  40.274 +    }
  40.275 +
  40.276 +    /* Check the remaining pages in the new GDT. */
  40.277 +    for ( i = 1; i < nr_pages; i++ )
  40.278 +        if ( ((pfn = frames[i]) >= max_page) ||
  40.279 +             !get_page_and_type(&frame_table[pfn], d, PGT_gdt_page) )
  40.280 +            goto fail;
  40.281 +
  40.282 +    /* Copy reserved GDT entries to the new GDT. */
  40.283 +    vgdt = map_domain_mem(frames[0] << PAGE_SHIFT);
  40.284 +    memcpy(vgdt + FIRST_RESERVED_GDT_ENTRY, 
  40.285 +           gdt_table + FIRST_RESERVED_GDT_ENTRY, 
  40.286 +           NR_RESERVED_GDT_ENTRIES*8);
  40.287 +    unmap_domain_mem(vgdt);
  40.288 +
  40.289 +    /* Tear down the old GDT. */
  40.290 +    destroy_gdt(d);
  40.291 +
  40.292 +    /* Install the new GDT. */
  40.293 +    for ( i = 0; i < nr_pages; i++ )
  40.294 +        d->mm.perdomain_pt[i] =
  40.295 +            mk_l1_pgentry((frames[i] << PAGE_SHIFT) | __PAGE_HYPERVISOR);
  40.296 +
  40.297 +    SET_GDT_ADDRESS(d, GDT_VIRT_START);
  40.298 +    SET_GDT_ENTRIES(d, entries);
  40.299 +
  40.300 +    return 0;
  40.301 +
  40.302 + fail:
  40.303 +    while ( i-- > 0 )
  40.304 +        put_page_and_type(&frame_table[frames[i]]);
  40.305 +    return -EINVAL;
  40.306 +}
  40.307 +
  40.308 +
  40.309 +long do_set_gdt(unsigned long *frame_list, unsigned int entries)
  40.310 +{
  40.311 +    int nr_pages = (entries + 511) / 512;
  40.312 +    unsigned long frames[16];
  40.313 +    long ret;
  40.314 +
  40.315 +    if ( (entries <= LAST_RESERVED_GDT_ENTRY) || (entries > 8192) ) 
  40.316 +        return -EINVAL;
  40.317 +    
  40.318 +    if ( copy_from_user(frames, frame_list, nr_pages * sizeof(unsigned long)) )
  40.319 +        return -EFAULT;
  40.320 +
  40.321 +    if ( (ret = set_gdt(current, frames, entries)) == 0 )
  40.322 +    {
  40.323 +        local_flush_tlb();
  40.324 +        __asm__ __volatile__ ("lgdt %0" : "=m" (*current->mm.gdt));
  40.325 +    }
  40.326 +
  40.327 +    return ret;
  40.328 +}
  40.329 +
  40.330 +
  40.331 +long do_update_descriptor(
  40.332 +    unsigned long pa, unsigned long word1, unsigned long word2)
  40.333 +{
  40.334 +    unsigned long *gdt_pent, pfn = pa >> PAGE_SHIFT, d[2];
  40.335 +    struct pfn_info *page;
  40.336 +    long ret = -EINVAL;
  40.337 +
  40.338 +    d[0] = word1;
  40.339 +    d[1] = word2;
  40.340 +
  40.341 +    if ( (pa & 7) || (pfn >= max_page) || !check_descriptor(d) )
  40.342 +        return -EINVAL;
  40.343 +
  40.344 +    page = &frame_table[pfn];
  40.345 +    if ( unlikely(!get_page(page, current)) )
  40.346 +        return -EINVAL;
  40.347 +
  40.348 +    /* Check if the given frame is in use in an unsafe context. */
  40.349 +    switch ( page->u.inuse.type_info & PGT_type_mask )
  40.350 +    {
  40.351 +    case PGT_gdt_page:
  40.352 +        /* Disallow updates of Xen-reserved descriptors in the current GDT. */
  40.353 +        if ( (l1_pgentry_to_pagenr(current->mm.perdomain_pt[0]) == pfn) &&
  40.354 +             (((pa&(PAGE_SIZE-1))>>3) >= FIRST_RESERVED_GDT_ENTRY) &&
  40.355 +             (((pa&(PAGE_SIZE-1))>>3) <= LAST_RESERVED_GDT_ENTRY) )
  40.356 +            goto out;
  40.357 +        if ( unlikely(!get_page_type(page, PGT_gdt_page)) )
  40.358 +            goto out;
  40.359 +        break;
  40.360 +    case PGT_ldt_page:
  40.361 +        if ( unlikely(!get_page_type(page, PGT_ldt_page)) )
  40.362 +            goto out;
  40.363 +        break;
  40.364 +    default:
  40.365 +        if ( unlikely(!get_page_type(page, PGT_writable_page)) )
  40.366 +            goto out;
  40.367 +        break;
  40.368 +    }
  40.369 +
  40.370 +    /* All is good so make the update. */
  40.371 +    gdt_pent = map_domain_mem(pa);
  40.372 +    memcpy(gdt_pent, d, 8);
  40.373 +    unmap_domain_mem(gdt_pent);
  40.374 +
  40.375 +    put_page_type(page);
  40.376 +
  40.377 +    ret = 0; /* success */
  40.378 +
  40.379 + out:
  40.380 +    put_page(page);
  40.381 +    return ret;
  40.382 +}
  40.383 +
  40.384 +#ifdef MEMORY_GUARD
  40.385 +
  40.386 +void *memguard_init(void *heap_start)
  40.387 +{
  40.388 +    l1_pgentry_t *l1;
  40.389 +    int i, j;
  40.390 +
  40.391 +    /* Round the allocation pointer up to a page boundary. */
  40.392 +    heap_start = (void *)(((unsigned long)heap_start + (PAGE_SIZE-1)) & 
  40.393 +                          PAGE_MASK);
  40.394 +
  40.395 +    /* Memory guarding is incompatible with super pages. */
  40.396 +    for ( i = 0; i < (xenheap_phys_end >> L2_PAGETABLE_SHIFT); i++ )
  40.397 +    {
  40.398 +        l1 = (l1_pgentry_t *)heap_start;
  40.399 +        heap_start = (void *)((unsigned long)heap_start + PAGE_SIZE);
  40.400 +        for ( j = 0; j < ENTRIES_PER_L1_PAGETABLE; j++ )
  40.401 +            l1[j] = mk_l1_pgentry((i << L2_PAGETABLE_SHIFT) |
  40.402 +                                   (j << L1_PAGETABLE_SHIFT) | 
  40.403 +                                  __PAGE_HYPERVISOR);
  40.404 +        idle_pg_table[i] = idle_pg_table[i + l2_table_offset(PAGE_OFFSET)] =
  40.405 +            mk_l2_pgentry(virt_to_phys(l1) | __PAGE_HYPERVISOR);
  40.406 +    }
  40.407 +
  40.408 +    return heap_start;
  40.409 +}
  40.410 +
  40.411 +static void __memguard_change_range(void *p, unsigned long l, int guard)
  40.412 +{
  40.413 +    l1_pgentry_t *l1;
  40.414 +    l2_pgentry_t *l2;
  40.415 +    unsigned long _p = (unsigned long)p;
  40.416 +    unsigned long _l = (unsigned long)l;
  40.417 +
  40.418 +    /* Ensure we are dealing with a page-aligned whole number of pages. */
  40.419 +    ASSERT((_p&PAGE_MASK) != 0);
  40.420 +    ASSERT((_l&PAGE_MASK) != 0);
  40.421 +    ASSERT((_p&~PAGE_MASK) == 0);
  40.422 +    ASSERT((_l&~PAGE_MASK) == 0);
  40.423 +
  40.424 +    while ( _l != 0 )
  40.425 +    {
  40.426 +        l2  = &idle_pg_table[l2_table_offset(_p)];
  40.427 +        l1  = l2_pgentry_to_l1(*l2) + l1_table_offset(_p);
  40.428 +        if ( guard )
  40.429 +            *l1 = mk_l1_pgentry(l1_pgentry_val(*l1) & ~_PAGE_PRESENT);
  40.430 +        else
  40.431 +            *l1 = mk_l1_pgentry(l1_pgentry_val(*l1) | _PAGE_PRESENT);
  40.432 +        _p += PAGE_SIZE;
  40.433 +        _l -= PAGE_SIZE;
  40.434 +    }
  40.435 +}
  40.436 +
  40.437 +void memguard_guard_range(void *p, unsigned long l)
  40.438 +{
  40.439 +    __memguard_change_range(p, l, 1);
  40.440 +    local_flush_tlb();
  40.441 +}
  40.442 +
  40.443 +void memguard_unguard_range(void *p, unsigned long l)
  40.444 +{
  40.445 +    __memguard_change_range(p, l, 0);
  40.446 +}
  40.447 +
  40.448 +int memguard_is_guarded(void *p)
  40.449 +{
  40.450 +    l1_pgentry_t *l1;
  40.451 +    l2_pgentry_t *l2;
  40.452 +    unsigned long _p = (unsigned long)p;
  40.453 +    l2  = &idle_pg_table[l2_table_offset(_p)];
  40.454 +    l1  = l2_pgentry_to_l1(*l2) + l1_table_offset(_p);
  40.455 +    return !(l1_pgentry_val(*l1) & _PAGE_PRESENT);
  40.456 +}
  40.457 +
  40.458 +#endif
    41.1 --- a/xen/arch/x86/x86_64/xen.lds	Wed Dec 08 01:30:49 2004 +0000
    41.2 +++ b/xen/arch/x86/x86_64/xen.lds	Sun Dec 26 10:00:51 2004 +0000
    41.3 @@ -28,6 +28,11 @@ SECTIONS
    41.4    __ex_table : { *(__ex_table) } :text
    41.5    __stop___ex_table = .;
    41.6  
    41.7 +  . = ALIGN(16);                /* Pre-exception table */
    41.8 +  __start___pre_ex_table = .;
    41.9 +  __pre_ex_table : { *(__pre_ex_table) } :text
   41.10 +  __stop___pre_ex_table = .;
   41.11 +
   41.12    __start___ksymtab = .;	/* Kernel symbol table */
   41.13    __ksymtab : { *(__ksymtab) } :text
   41.14    __stop___ksymtab = .;
    42.1 --- a/xen/common/domain.c	Wed Dec 08 01:30:49 2004 +0000
    42.2 +++ b/xen/common/domain.c	Sun Dec 26 10:00:51 2004 +0000
    42.3 @@ -47,20 +47,21 @@ struct domain *do_createdomain(domid_t d
    42.4      /* Per-domain PCI-device list. */
    42.5      spin_lock_init(&d->pcidev_lock);
    42.6      INIT_LIST_HEAD(&d->pcidev_list);
    42.7 +    
    42.8 +    if ( (d->id != IDLE_DOMAIN_ID) &&
    42.9 +         ((init_event_channels(d) != 0) || (grant_table_create(d) != 0)) )
   42.10 +    {
   42.11 +        destroy_event_channels(d);
   42.12 +        free_domain_struct(d);
   42.13 +        return NULL;
   42.14 +    }
   42.15 +    
   42.16 +    arch_do_createdomain(d);
   42.17 +    
   42.18 +    sched_add_domain(d);
   42.19  
   42.20      if ( d->id != IDLE_DOMAIN_ID )
   42.21      {
   42.22 -        if ( (init_event_channels(d) != 0) || (grant_table_create(d) != 0) )
   42.23 -        {
   42.24 -            destroy_event_channels(d);
   42.25 -            free_domain_struct(d);
   42.26 -            return NULL;
   42.27 -        }
   42.28 -
   42.29 -        arch_do_createdomain(d);
   42.30 -
   42.31 -        sched_add_domain(d);
   42.32 -
   42.33          write_lock(&domlist_lock);
   42.34          pd = &domain_list; /* NB. domain_list maintained in order of dom_id. */
   42.35          for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_list )
   42.36 @@ -72,10 +73,6 @@ struct domain *do_createdomain(domid_t d
   42.37          domain_hash[DOMAIN_HASH(dom_id)] = d;
   42.38          write_unlock(&domlist_lock);
   42.39      }
   42.40 -    else
   42.41 -    {
   42.42 -        sched_add_domain(d);
   42.43 -    }
   42.44  
   42.45      return d;
   42.46  }
    43.1 --- a/xen/common/physdev.c	Wed Dec 08 01:30:49 2004 +0000
    43.2 +++ b/xen/common/physdev.c	Sun Dec 26 10:00:51 2004 +0000
    43.3 @@ -742,7 +742,8 @@ void physdev_init_dom0(struct domain *p)
    43.4           *
    43.5           * In Linux2.6 we set pcibios_scan_all_fns().
    43.6           */
    43.7 -        if ( dev->hdr_type != PCI_HEADER_TYPE_NORMAL )
    43.8 +        if ( (dev->hdr_type != PCI_HEADER_TYPE_NORMAL) &&
    43.9 +             (dev->hdr_type != PCI_HEADER_TYPE_CARDBUS) )
   43.10              continue;
   43.11          pdev = xmalloc(sizeof(phys_dev_t));
   43.12          pdev->dev = dev;
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/xen/include/asm-x86/asm_defns.h	Sun Dec 26 10:00:51 2004 +0000
    44.3 @@ -0,0 +1,18 @@
    44.4 +
    44.5 +#ifndef __X86_ASM_DEFNS_H__
    44.6 +#define __X86_ASM_DEFNS_H__
    44.7 +
    44.8 +/* NB. Auto-generated from arch/.../asm-offsets.c */
    44.9 +#include <asm/asm-offsets.h>
   44.10 +#include <asm/processor.h>
   44.11 +
   44.12 +#define __STR(x) #x
   44.13 +#define STR(x) __STR(x)
   44.14 +
   44.15 +#ifdef __x86_64__
   44.16 +#include <asm/x86_64/asm_defns.h>
   44.17 +#else
   44.18 +#include <asm/x86_32/asm_defns.h>
   44.19 +#endif
   44.20 +
   44.21 +#endif /* __X86_ASM_DEFNS_H__ */
    45.1 --- a/xen/include/asm-x86/domain.h	Wed Dec 08 01:30:49 2004 +0000
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,14 +0,0 @@
    45.4 -
    45.5 -#ifndef __ASM_X86_DOMAIN_H__
    45.6 -#define __ASM_X86_DOMAIN_H__
    45.7 -
    45.8 -extern void arch_do_createdomain(struct domain *d);
    45.9 -
   45.10 -extern int  arch_final_setup_guestos(
   45.11 -    struct domain *d, full_execution_context_t *c);
   45.12 -
   45.13 -extern void free_perdomain_pt(struct domain *d);
   45.14 -
   45.15 -extern void domain_relinquish_memory(struct domain *d);
   45.16 -
   45.17 -#endif /* __ASM_X86_DOMAIN_H__ */
    46.1 --- a/xen/include/asm-x86/irq.h	Wed Dec 08 01:30:49 2004 +0000
    46.2 +++ b/xen/include/asm-x86/irq.h	Sun Dec 26 10:00:51 2004 +0000
    46.3 @@ -5,7 +5,7 @@
    46.4  
    46.5  #include <xen/config.h>
    46.6  #include <asm/atomic.h>
    46.7 -#include <asm/x86_32/asm_defns.h>
    46.8 +#include <asm/asm_defns.h>
    46.9  
   46.10  extern void disable_irq(unsigned int);
   46.11  extern void disable_irq_nosync(unsigned int);
    47.1 --- a/xen/include/asm-x86/multicall.h	Wed Dec 08 01:30:49 2004 +0000
    47.2 +++ b/xen/include/asm-x86/multicall.h	Sun Dec 26 10:00:51 2004 +0000
    47.3 @@ -5,7 +5,13 @@
    47.4  #ifndef __ASM_X86_MULTICALL_H__
    47.5  #define __ASM_X86_MULTICALL_H__
    47.6  
    47.7 -#include <asm-x86/x86_32/asm_defns.h>
    47.8 +#include <asm/asm_defns.h>
    47.9 +
   47.10 +#ifdef __x86_64__
   47.11 +
   47.12 +#define do_multicall_call(_call) BUG()
   47.13 +
   47.14 +#else
   47.15  
   47.16  #define do_multicall_call(_call)                       \
   47.17      do {                                               \
   47.18 @@ -23,4 +29,6 @@
   47.19              : : "b" (_call) : "eax", "ecx", "edx" );   \
   47.20      } while ( 0 )
   47.21  
   47.22 +#endif
   47.23 +
   47.24  #endif /* __ASM_X86_MULTICALL_H__ */
    48.1 --- a/xen/include/asm-x86/processor.h	Wed Dec 08 01:30:49 2004 +0000
    48.2 +++ b/xen/include/asm-x86/processor.h	Sun Dec 26 10:00:51 2004 +0000
    48.3 @@ -254,18 +254,18 @@ static inline unsigned int cpuid_edx(uns
    48.4  })
    48.5  
    48.6  #define write_cr0(x) \
    48.7 -	__asm__("mov"__OS" %0,%%cr0": :"r" (x));
    48.8 +	__asm__("mov"__OS" %0,%%cr0": :"r" ((unsigned long)x));
    48.9  
   48.10  #define read_cr4() ({ \
   48.11 -	unsigned int __dummy; \
   48.12 +	unsigned long __dummy; \
   48.13  	__asm__( \
   48.14 -		"movl %%cr4,%0\n\t" \
   48.15 +		"mov"__OS" %%cr4,%0\n\t" \
   48.16  		:"=r" (__dummy)); \
   48.17  	__dummy; \
   48.18  })
   48.19  
   48.20  #define write_cr4(x) \
   48.21 -	__asm__("movl %0,%%cr4": :"r" (x));
   48.22 +	__asm__("mov"__OS" %0,%%cr4": :"r" ((unsigned long)x));
   48.23  
   48.24  /*
   48.25   * Save the cr4 feature set we're using (ie
   48.26 @@ -290,7 +290,7 @@ static inline void clear_in_cr4 (unsigne
   48.27      mmu_cr4_features &= ~mask;
   48.28      __asm__("mov"__OS" %%cr4,%%"__OP"ax\n\t"
   48.29              "and"__OS" %0,%%"__OP"ax\n\t"
   48.30 -            "movl"__OS" %%"__OP"ax,%%cr4\n"
   48.31 +            "mov"__OS" %%"__OP"ax,%%cr4\n"
   48.32              : : "irg" (~mask)
   48.33              :"ax");
   48.34  }
   48.35 @@ -399,6 +399,8 @@ struct thread_struct {
   48.36      /* general user-visible register state */
   48.37      execution_context_t user_ctxt;
   48.38  
   48.39 +    void (*schedule_tail) (struct domain *);
   48.40 +
   48.41      /*
   48.42       * Return vectors pushed to us by guest OS.
   48.43       * The stack frame for events is exactly that of an x86 hardware interrupt.
   48.44 @@ -456,14 +458,10 @@ extern struct desc_struct *idt_tables[];
   48.45  
   48.46  long set_fast_trap(struct domain *p, int idx);
   48.47  
   48.48 -#define INIT_THREAD  { fast_trap_idx: 0x20 }
   48.49 -
   48.50 -#elif defined(__x86_64__)
   48.51 +#endif
   48.52  
   48.53  #define INIT_THREAD { 0 }
   48.54  
   48.55 -#endif /* __x86_64__ */
   48.56 -
   48.57  extern int gpf_emulate_4gb(struct xen_regs *regs);
   48.58  
   48.59  struct mm_struct {
    49.1 --- a/xen/include/asm-x86/system.h	Wed Dec 08 01:30:49 2004 +0000
    49.2 +++ b/xen/include/asm-x86/system.h	Sun Dec 26 10:00:51 2004 +0000
    49.3 @@ -271,13 +271,6 @@ static inline int local_irq_is_enabled(v
    49.4      return !!(flags & (1<<9)); /* EFLAGS_IF */
    49.5  }
    49.6  
    49.7 -/*
    49.8 - * disable hlt during certain critical i/o operations
    49.9 - */
   49.10 -#define HAVE_DISABLE_HLT
   49.11 -void disable_hlt(void);
   49.12 -void enable_hlt(void);
   49.13 -
   49.14  #define BROKEN_ACPI_Sx		0x0001
   49.15  #define BROKEN_INIT_AFTER_S1	0x0002
   49.16  
    50.1 --- a/xen/include/asm-x86/uaccess.h	Wed Dec 08 01:30:49 2004 +0000
    50.2 +++ b/xen/include/asm-x86/uaccess.h	Sun Dec 26 10:00:51 2004 +0000
    50.3 @@ -1,6 +1,32 @@
    50.4 +
    50.5 +#ifndef __X86_UACCESS_H__
    50.6 +#define __X86_UACCESS_H__
    50.7  
    50.8  #ifdef __x86_64__
    50.9  #include <asm/x86_64/uaccess.h>
   50.10  #else
   50.11  #include <asm/x86_32/uaccess.h>
   50.12  #endif
   50.13 +
   50.14 +/*
   50.15 + * The exception table consists of pairs of addresses: the first is the
   50.16 + * address of an instruction that is allowed to fault, and the second is
   50.17 + * the address at which the program should continue.  No registers are
   50.18 + * modified, so it is entirely up to the continuation code to figure out
   50.19 + * what to do.
   50.20 + *
   50.21 + * All the routines below use bits of fixup code that are out of line
   50.22 + * with the main instruction path.  This means when everything is well,
   50.23 + * we don't even have to jump over them.  Further, they do not intrude
   50.24 + * on our cache or tlb entries.
   50.25 + */
   50.26 +
   50.27 +struct exception_table_entry
   50.28 +{
   50.29 +	unsigned long insn, fixup;
   50.30 +};
   50.31 +
   50.32 +extern unsigned long search_exception_table(unsigned long);
   50.33 +extern void sort_exception_tables(void);
   50.34 +
   50.35 +#endif /* __X86_UACCESS_H__ */
    51.1 --- a/xen/include/asm-x86/x86_32/asm_defns.h	Wed Dec 08 01:30:49 2004 +0000
    51.2 +++ b/xen/include/asm-x86/x86_32/asm_defns.h	Sun Dec 26 10:00:51 2004 +0000
    51.3 @@ -1,12 +1,5 @@
    51.4 -#ifndef __ASM_DEFNS_H__
    51.5 -#define __ASM_DEFNS_H__
    51.6 -
    51.7 -/* NB. Auto-generated from arch/.../asm-offsets.c */
    51.8 -#include <asm/asm-offsets.h>
    51.9 -#include <asm/processor.h>
   51.10 -
   51.11 -#define __STR(x) #x
   51.12 -#define STR(x) __STR(x)
   51.13 +#ifndef __X86_32_ASM_DEFNS_H__
   51.14 +#define __X86_32_ASM_DEFNS_H__
   51.15  
   51.16  /* Maybe auto-generate the following two cases (quoted vs. unquoted). */
   51.17  #ifndef __ASSEMBLY__
   51.18 @@ -85,4 +78,4 @@
   51.19  
   51.20  #endif
   51.21  
   51.22 -#endif /* __ASM_DEFNS_H__ */
   51.23 +#endif /* __X86_32_ASM_DEFNS_H__ */
    52.1 --- a/xen/include/asm-x86/x86_32/current.h	Wed Dec 08 01:30:49 2004 +0000
    52.2 +++ b/xen/include/asm-x86/x86_32/current.h	Sun Dec 26 10:00:51 2004 +0000
    52.3 @@ -45,14 +45,11 @@ static inline unsigned long get_stack_to
    52.4      return p;
    52.5  }
    52.6  
    52.7 -#define schedule_tail(_p)                                         \
    52.8 +#define reset_stack_and_jump(__fn)                                \
    52.9      __asm__ __volatile__ (                                        \
   52.10 -        "andl %%esp,%0; addl %2,%0; movl %0,%%esp; jmp *%1"       \
   52.11 -        : : "r" (~(STACK_SIZE-1)),                                \
   52.12 -            "r" (unlikely(is_idle_task((_p))) ?                   \
   52.13 -                                continue_cpu_idle_loop :          \
   52.14 -                                continue_nonidle_task),           \
   52.15 -            "i" (STACK_SIZE-STACK_RESERVED) )
   52.16 +        "movl %0,%%esp; jmp "STR(__fn)                            \
   52.17 +        : : "r" (get_execution_context()) )
   52.18  
   52.19 +#define schedule_tail(_d) ((_d)->thread.schedule_tail)(_d)
   52.20  
   52.21  #endif /* _X86_CURRENT_H */
    53.1 --- a/xen/include/asm-x86/x86_32/uaccess.h	Wed Dec 08 01:30:49 2004 +0000
    53.2 +++ b/xen/include/asm-x86/x86_32/uaccess.h	Sun Dec 26 10:00:51 2004 +0000
    53.3 @@ -69,27 +69,6 @@ extern struct movsl_mask {
    53.4  #define array_access_ok(type,addr,count,size) \
    53.5      (likely(count < (~0UL/size)) && access_ok(type,addr,count*size))
    53.6  
    53.7 -/*
    53.8 - * The exception table consists of pairs of addresses: the first is the
    53.9 - * address of an instruction that is allowed to fault, and the second is
   53.10 - * the address at which the program should continue.  No registers are
   53.11 - * modified, so it is entirely up to the continuation code to figure out
   53.12 - * what to do.
   53.13 - *
   53.14 - * All the routines below use bits of fixup code that are out of line
   53.15 - * with the main instruction path.  This means when everything is well,
   53.16 - * we don't even have to jump over them.  Further, they do not intrude
   53.17 - * on our cache or tlb entries.
   53.18 - */
   53.19 -
   53.20 -struct exception_table_entry
   53.21 -{
   53.22 -	unsigned long insn, fixup;
   53.23 -};
   53.24 -
   53.25 -extern unsigned long search_exception_table(unsigned long);
   53.26 -extern void sort_exception_tables(void);
   53.27 -
   53.28  /**
   53.29   * get_user: - Get a simple variable from user space.
   53.30   * @x:   Variable to store result.
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/xen/include/asm-x86/x86_64/asm_defns.h	Sun Dec 26 10:00:51 2004 +0000
    54.3 @@ -0,0 +1,6 @@
    54.4 +#ifndef __X86_64_ASM_DEFNS_H__
    54.5 +#define __X86_64_ASM_DEFNS_H__
    54.6 +
    54.7 +#define SAVE_ALL(_r) ""
    54.8 +
    54.9 +#endif /* __X86_64_ASM_DEFNS_H__ */
    55.1 --- a/xen/include/asm-x86/x86_64/current.h	Wed Dec 08 01:30:49 2004 +0000
    55.2 +++ b/xen/include/asm-x86/x86_64/current.h	Sun Dec 26 10:00:51 2004 +0000
    55.3 @@ -40,15 +40,12 @@ static inline unsigned long get_stack_to
    55.4      return p;
    55.5  }
    55.6  
    55.7 -#define schedule_tail(_p)                                         \
    55.8 +#define reset_stack_and_jump(__fn)                                \
    55.9      __asm__ __volatile__ (                                        \
   55.10 -        "andq %%rsp,%0; addq %2,%0; movq %0,%%rsp; jmp *%1"       \
   55.11 -        : : "r" (~(STACK_SIZE-1)),                                \
   55.12 -            "r" (unlikely(is_idle_task((_p))) ?                   \
   55.13 -                                continue_cpu_idle_loop :          \
   55.14 -                                continue_nonidle_task),           \
   55.15 -            "i" (STACK_SIZE-STACK_RESERVED) )
   55.16 +        "movq %0,%%rsp; jmp "STR(__fn)                            \
   55.17 +        : : "r" (get_execution_context()) )
   55.18  
   55.19 +#define schedule_tail(_d) ((_d)->thread.schedule_tail)(_d)
   55.20  
   55.21  #else
   55.22  
    56.1 --- a/xen/include/asm-x86/x86_64/uaccess.h	Wed Dec 08 01:30:49 2004 +0000
    56.2 +++ b/xen/include/asm-x86/x86_64/uaccess.h	Sun Dec 26 10:00:51 2004 +0000
    56.3 @@ -35,31 +35,15 @@
    56.4  
    56.5  #define access_ok(type, addr, size) (__range_not_ok(addr,size) == 0)
    56.6  
    56.7 +#define array_access_ok(type,addr,count,size)                    \
    56.8 +    (likely(sizeof(count) <= 4) /* disallow 64-bit counts */ &&  \
    56.9 +     access_ok(type,addr,count*size))
   56.10 +
   56.11  extern inline int verify_area(int type, const void __user * addr, unsigned long size)
   56.12  {
   56.13  	return access_ok(type,addr,size) ? 0 : -EFAULT;
   56.14  }
   56.15  
   56.16 -
   56.17 -/*
   56.18 - * The exception table consists of pairs of addresses: the first is the
   56.19 - * address of an instruction that is allowed to fault, and the second is
   56.20 - * the address at which the program should continue.  No registers are
   56.21 - * modified, so it is entirely up to the continuation code to figure out
   56.22 - * what to do.
   56.23 - *
   56.24 - * All the routines below use bits of fixup code that are out of line
   56.25 - * with the main instruction path.  This means when everything is well,
   56.26 - * we don't even have to jump over them.  Further, they do not intrude
   56.27 - * on our cache or tlb entries.
   56.28 - */
   56.29 -
   56.30 -struct exception_table_entry
   56.31 -{
   56.32 -	unsigned long insn, fixup;
   56.33 -};
   56.34 -
   56.35 -
   56.36  /*
   56.37   * These are the main single-value transfer routines.  They automatically
   56.38   * use the right size if we just have the right pointer type.
    57.1 --- a/xen/include/public/arch-x86_32.h	Wed Dec 08 01:30:49 2004 +0000
    57.2 +++ b/xen/include/public/arch-x86_32.h	Sun Dec 26 10:00:51 2004 +0000
    57.3 @@ -2,6 +2,8 @@
    57.4   * arch-x86_32.h
    57.5   * 
    57.6   * Guest OS interface to x86 32-bit Xen.
    57.7 + * 
    57.8 + * Copyright (c) 2004, K A Fraser
    57.9   */
   57.10  
   57.11  #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
    58.1 --- a/xen/include/public/arch-x86_64.h	Wed Dec 08 01:30:49 2004 +0000
    58.2 +++ b/xen/include/public/arch-x86_64.h	Sun Dec 26 10:00:51 2004 +0000
    58.3 @@ -2,6 +2,8 @@
    58.4   * arch-x86_64.h
    58.5   * 
    58.6   * Guest OS interface to x86 64-bit Xen.
    58.7 + * 
    58.8 + * Copyright (c) 2004, K A Fraser
    58.9   */
   58.10  
   58.11  #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
    59.1 --- a/xen/include/public/io/domain_controller.h	Wed Dec 08 01:30:49 2004 +0000
    59.2 +++ b/xen/include/public/io/domain_controller.h	Sun Dec 26 10:00:51 2004 +0000
    59.3 @@ -555,6 +555,7 @@ typedef struct {
    59.4  #define CMSG_SHUTDOWN_REBOOT    1   /* Clean shutdown (SHUTDOWN_reboot).     */
    59.5  #define CMSG_SHUTDOWN_SUSPEND   2   /* Create suspend info, then             */
    59.6                                      /* SHUTDOWN_suspend.                     */
    59.7 +#define CMSG_SHUTDOWN_SYSRQ     3
    59.8  
    59.9  
   59.10  /******************************************************************************
    60.1 --- a/xen/include/public/trace.h	Wed Dec 08 01:30:49 2004 +0000
    60.2 +++ b/xen/include/public/trace.h	Sun Dec 26 10:00:51 2004 +0000
    60.3 @@ -1,5 +1,7 @@
    60.4  /******************************************************************************
    60.5   * trace.h
    60.6 + * 
    60.7 + * Mark Williamson, (C) 2004 Intel Research Cambridge
    60.8   */
    60.9  
   60.10  #ifndef __XEN_PUBLIC_TRACE_H__
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/xen/include/xen/domain.h	Sun Dec 26 10:00:51 2004 +0000
    61.3 @@ -0,0 +1,20 @@
    61.4 +
    61.5 +#ifndef __XEN_DOMAIN_H__
    61.6 +#define __XEN_DOMAIN_H__
    61.7 +
    61.8 +
    61.9 +
   61.10 +/*
   61.11 + * Arch-specifics.
   61.12 + */
   61.13 +
   61.14 +extern void arch_do_createdomain(struct domain *d);
   61.15 +
   61.16 +extern int  arch_final_setup_guestos(
   61.17 +    struct domain *d, full_execution_context_t *c);
   61.18 +
   61.19 +extern void free_perdomain_pt(struct domain *d);
   61.20 +
   61.21 +extern void domain_relinquish_memory(struct domain *d);
   61.22 +
   61.23 +#endif /* __XEN_DOMAIN_H__ */
    62.1 --- a/xen/include/xen/sched.h	Wed Dec 08 01:30:49 2004 +0000
    62.2 +++ b/xen/include/xen/sched.h	Sun Dec 26 10:00:51 2004 +0000
    62.3 @@ -214,9 +214,6 @@ void domain_init(void);
    62.4  int idle_cpu(int cpu); /* Is CPU 'cpu' idle right now? */
    62.5  
    62.6  void startup_cpu_idle_loop(void);
    62.7 -void continue_cpu_idle_loop(void);
    62.8 -
    62.9 -void continue_nonidle_task(void);
   62.10  
   62.11  unsigned long hypercall_create_continuation(
   62.12      unsigned int op, unsigned int nr_args, ...);
   62.13 @@ -295,6 +292,6 @@ static inline void domain_unpause_by_sys
   62.14  #define VM_ASSIST(_d,_t) (test_bit((_t), &(_d)->vm_assist))
   62.15  
   62.16  #include <xen/slab.h>
   62.17 -#include <asm/domain.h>
   62.18 +#include <xen/domain.h>
   62.19  
   62.20  #endif /* __SCHED_H__ */