ia64/xen-unstable

changeset 9675:5cc367720223

merge with xen-unstable.hg
author awilliam@xenbuild.aw
date Tue Apr 11 18:54:18 2006 -0600 (2006-04-11)
parents 5719550652a1 edefe24d78bd
children 15a04f998083
files buildconfigs/linux-defconfig_xen_ia64 linux-2.6-xen-sparse/arch/ia64/Makefile linux-2.6-xen-sparse/include/asm-ia64/hypercall.h linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h linux-2.6-xen-sparse/include/linux/irq.h linux-2.6-xen-sparse/kernel/irq/manage.c linux-2.6-xen-sparse/lib/Kconfig.debug tools/ioemu/vl.c xen/Post.mk xen/arch/ia64/Makefile xen/arch/ia64/vmx/Makefile xen/arch/ia64/vmx/vmx_ivt.S xen/arch/ia64/xen/Makefile xen/arch/ia64/xen/hypercall.c xen/arch/ia64/xen/irq.c xen/arch/ia64/xen/xentime.c xen/include/asm-x86/mach-bigsmp/mach_apic.h xen/include/asm-x86/mach-bigsmp/mach_apicdef.h xen/include/asm-x86/mach-bigsmp/mach_ipi.h xen/include/asm-x86/mach-default/mach_apic.h xen/include/asm-x86/mach-default/mach_apicdef.h xen/include/asm-x86/mach-default/mach_ipi.h xen/include/asm-x86/mach-es7000/mach_apic.h xen/include/asm-x86/mach-es7000/mach_apicdef.h xen/include/asm-x86/mach-es7000/mach_ipi.h xen/include/asm-x86/mach-es7000/mach_wakecpu.h xen/include/asm-x86/mach-generic/mach_apicdef.h xen/include/asm-x86/mach-generic/mach_ipi.h xen/include/asm-x86/mach-generic/mach_mpspec.h xen/include/asm-x86/mach-summit/mach_apic.h xen/include/asm-x86/mach-summit/mach_apicdef.h xen/include/asm-x86/mach-summit/mach_ipi.h
line diff
     1.1 --- a/.hgtags	Tue Apr 11 13:55:47 2006 -0600
     1.2 +++ b/.hgtags	Tue Apr 11 18:54:18 2006 -0600
     1.3 @@ -14,3 +14,4 @@ 30c521db4c71960b0cf1d9c9e1b658e77b535a3e
     1.4  3d330e41f41ce1bc118c02346e18949ad5d67f6b split-1.1
     1.5  c8fdb0caa77b429cf47f9707926e83947778cb48 RELEASE-3.0.0
     1.6  af0573e9e5258db0a9d28aa954dd302ddd2c2d23 3.0.2-rc
     1.7 +d0d3fef37685be264a7f52201f8ef44c030daad3 3.0.2-branched
     2.1 --- a/Config.mk	Tue Apr 11 13:55:47 2006 -0600
     2.2 +++ b/Config.mk	Tue Apr 11 18:54:18 2006 -0600
     2.3 @@ -24,6 +24,7 @@ OBJCOPY    = $(CROSS_COMPILE)objcopy
     2.4  OBJDUMP    = $(CROSS_COMPILE)objdump
     2.5  
     2.6  DISTDIR     ?= $(XEN_ROOT)/dist
     2.7 +DESTDIR     ?= /
     2.8  
     2.9  INSTALL      = install
    2.10  INSTALL_DIR  = $(INSTALL) -d -m0755
     3.1 --- a/Makefile	Tue Apr 11 13:55:47 2006 -0600
     3.2 +++ b/Makefile	Tue Apr 11 18:54:18 2006 -0600
     3.3 @@ -14,6 +14,7 @@ export XEN_TARGET_ARCH SUBARCH XEN_SYSTY
     3.4  endif
     3.5  
     3.6  # Default target must appear before any include lines
     3.7 +.PHONY: all
     3.8  all: dist
     3.9  
    3.10  XEN_ROOT=$(CURDIR)
    3.11 @@ -24,12 +25,11 @@ ifeq ($(XEN_TARGET_X86_PAE),y)
    3.12  export pae=y
    3.13  endif
    3.14  
    3.15 -.PHONY:	all dist install xen kernels tools dev-docs docs world clean
    3.16 -.PHONY:	mkpatches mrproper kbuild kdelete kclean
    3.17 -
    3.18  # build and install everything into the standard system directories
    3.19 +.PHONY: install
    3.20  install: install-xen install-kernels install-tools install-docs
    3.21  
    3.22 +.PHONY: build
    3.23  build: kernels
    3.24  	$(MAKE) -C xen build
    3.25  	$(MAKE) -C tools build
    3.26 @@ -38,10 +38,12 @@ build: kernels
    3.27  # The test target is for unit tests that can run without an installation.  Of
    3.28  # course, many tests require a machine running Xen itself, and these are
    3.29  # handled elsewhere.
    3.30 +.PHONY: test
    3.31  test:
    3.32  	$(MAKE) -C tools/python test
    3.33  
    3.34  # build and install everything into local dist directory
    3.35 +.PHONY: dist
    3.36  dist: DESTDIR=$(DISTDIR)/install
    3.37  dist: dist-xen dist-kernels dist-tools dist-docs
    3.38  	$(INSTALL_DIR) $(DISTDIR)/check
    3.39 @@ -54,79 +56,83 @@ dist-%: install-%
    3.40  	@: # do nothing
    3.41  
    3.42  # Legacy dist targets
    3.43 +.PHONY: xen tools kernels docs
    3.44  xen: dist-xen
    3.45  tools: dist-tools
    3.46  kernels: dist-kernels
    3.47  docs: dist-docs
    3.48  
    3.49 +.PHONY: prep-kernels
    3.50  prep-kernels:
    3.51  	for i in $(XKERNELS) ; do $(MAKE) $$i-prep || exit 1; done
    3.52  
    3.53 +.PHONY: install-xen
    3.54  install-xen:
    3.55  	$(MAKE) -C xen install
    3.56  
    3.57 +.PHONY: install-tools
    3.58  install-tools:
    3.59  	$(MAKE) -C tools install
    3.60  
    3.61 +.PHONY: install-kernels
    3.62  install-kernels:
    3.63  	for i in $(XKERNELS) ; do $(MAKE) $$i-install || exit 1; done
    3.64  
    3.65 +.PHONY: install-docs
    3.66  install-docs:
    3.67  	sh ./docs/check_pkgs && $(MAKE) -C docs install || true
    3.68  
    3.69 +.PHONY: dev-docs
    3.70  dev-docs:
    3.71  	$(MAKE) -C docs dev-docs
    3.72  
    3.73  # Build all the various kernels and modules
    3.74 +.PHONY: kbuild
    3.75  kbuild: kernels
    3.76  
    3.77  # Delete the kernel build trees entirely
    3.78 +.PHONY: kdelete
    3.79  kdelete:
    3.80  	for i in $(XKERNELS) ; do $(MAKE) $$i-delete ; done
    3.81  
    3.82  # Clean the kernel build trees
    3.83 +.PHONY: kclean
    3.84  kclean:
    3.85  	for i in $(XKERNELS) ; do $(MAKE) $$i-clean ; done
    3.86  
    3.87  # Make patches from kernel sparse trees
    3.88 +.PHONY: mkpatches
    3.89  mkpatches:
    3.90  	for i in $(ALLSPARSETREES) ; do $(MAKE) $$i-xen.patch; done
    3.91  
    3.92  # build xen, the tools, and a domain 0 plus unprivileged linux-xen images,
    3.93  # and place them in the install directory. 'make install' should then
    3.94  # copy them to the normal system directories
    3.95 +.PHONY: world
    3.96  world: 
    3.97  	$(MAKE) clean
    3.98  	$(MAKE) kdelete
    3.99  	$(MAKE) dist
   3.100  
   3.101  # clean doesn't do a kclean
   3.102 +.PHONY: clean
   3.103  clean:: 
   3.104  	$(MAKE) -C xen clean
   3.105  	$(MAKE) -C tools clean
   3.106  	$(MAKE) -C docs clean
   3.107  
   3.108  # clean, but blow away kernel build tree plus tarballs
   3.109 +.PHONY: distclean
   3.110  distclean: clean
   3.111  	rm -rf dist patches/tmp
   3.112  	for i in $(ALLKERNELS) ; do $(MAKE) $$i-delete ; done
   3.113  	for i in $(ALLSPARSETREES) ; do $(MAKE) $$i-mrproper ; done
   3.114  
   3.115  # Linux name for GNU distclean
   3.116 +.PHONY: mrproper
   3.117  mrproper: distclean
   3.118  
   3.119 -install-logging: LOGGING=logging-0.4.9.2
   3.120 -install-logging:
   3.121 -	[ -f $(LOGGING).tar.gz ] || wget http://www.red-dove.com/$(LOGGING).tar.gz
   3.122 -	tar -zxf $(LOGGING).tar.gz
   3.123 -	cd $(LOGGING) && python setup.py install
   3.124 -
   3.125 -# handy target to upgrade iptables (use rpm or apt-get in preference)
   3.126 -install-iptables:
   3.127 -	wget http://www.netfilter.org/files/iptables-1.2.11.tar.bz2
   3.128 -	tar -jxf iptables-1.2.11.tar.bz2
   3.129 -	$(MAKE) -C iptables-1.2.11 PREFIX= KERNEL_DIR=../linux-$(LINUX_VER)-xen0 install
   3.130 -
   3.131 +.PHONY: help
   3.132  help:
   3.133  	@echo 'Installation targets:'
   3.134  	@echo '  install          - build and install everything'
   3.135 @@ -147,25 +153,28 @@ help:
   3.136  	@echo '  dev-docs         - build developer-only documentation'
   3.137  	@echo ''
   3.138  	@echo 'Cleaning targets:'
   3.139 -	@echo '  clean            - clean the Xen, tools and docs (but not'
   3.140 -	@echo '                     guest kernel) trees'
   3.141 -	@echo '  distclean        - clean plus delete kernel tarballs and kernel'
   3.142 -	@echo '                     build trees'
   3.143 +	@echo '  clean            - clean the Xen, tools and docs (but not guest kernel trees)'
   3.144 +	@echo '  distclean        - clean plus delete kernel build trees and'
   3.145 +	@echo '                     local downloaded files'
   3.146  	@echo '  kdelete          - delete guest kernel build trees'
   3.147  	@echo '  kclean           - clean guest kernel build trees'
   3.148  	@echo ''
   3.149 -	@echo 'Dependency installation targets:'
   3.150 -	@echo '  install-logging  - install the Python Logging package'
   3.151 -	@echo '  install-iptables - install iptables tools'
   3.152 -	@echo ''
   3.153  	@echo 'Miscellaneous targets:'
   3.154  	@echo '  prep-kernels     - prepares kernel directories, does not build'
   3.155  	@echo '  mkpatches        - make patches against vanilla kernels from'
   3.156  	@echo '                     sparse trees'
   3.157 -	@echo '  uninstall        - attempt to remove installed Xen tools (use'
   3.158 -	@echo '                     with extreme care!)'
   3.159 +	@echo '  uninstall        - attempt to remove installed Xen tools'
   3.160 +	@echo '                     (use with extreme care!)'
   3.161 +	@echo
   3.162 +	@echo 'Environment:'
   3.163 +	@echo '  XEN_PYTHON_NATIVE_INSTALL=y'
   3.164 +	@echo '                   - native python install or dist'
   3.165 +	@echo '                     install into prefix/lib/python<VERSION>'
   3.166 +	@echo '                     instead of <PREFIX>/lib/python'
   3.167 +	@echo '                     true if set to non-empty value, false otherwise'
   3.168  
   3.169  # Use this target with extreme care!
   3.170 +.PHONY: uninstall
   3.171  uninstall: D=$(DESTDIR)
   3.172  uninstall:
   3.173  	[ -d $(D)/etc/xen ] && mv -f $(D)/etc/xen $(D)/etc/xen.old-`date +%s` || true
   3.174 @@ -199,5 +208,6 @@ uninstall:
   3.175  	rm -rf $(D)/usr/share/man/man8/xen*
   3.176  
   3.177  # Legacy targets for compatibility
   3.178 +.PHONY: linux26
   3.179  linux26:
   3.180  	$(MAKE) 'KERNELS=linux-2.6*' kernels
     4.1 --- a/README	Tue Apr 11 13:55:47 2006 -0600
     4.2 +++ b/README	Tue Apr 11 18:54:18 2006 -0600
     4.3 @@ -1,158 +1,176 @@
     4.4 -################################
     4.5 - __  __            _____  ___  
     4.6 - \ \/ /___ _ __   |___ / / _ \ 
     4.7 -  \  // _ \ '_ \    |_ \| | | |
     4.8 -  /  \  __/ | | |  ___) | |_| |
     4.9 - /_/\_\___|_| |_| |____(_)___/ 
    4.10 -
    4.11 -################################
    4.12 -
    4.13 -http://www.xensource.com/xen/about.html
    4.14 -
    4.15 -What is Xen?
    4.16 -============
    4.17 -
    4.18 -Xen is a Virtual Machine Monitor (VMM) originally developed by the
    4.19 -Systems Research Group of the University of Cambridge Computer
    4.20 -Laboratory, as part of the UK-EPSRC funded XenoServers project.  Xen
    4.21 -is freely-distributable Open Source software, released under the GNU
    4.22 -GPL. Since its initial public release, Xen has grown a large
    4.23 -development community, spearheaded by XenSource Inc, a company created
    4.24 -by the original Xen development team to build enterprise products
    4.25 -around Xen.
    4.26 -
    4.27 -The 3.0 release offers excellent performance, hardware support and
    4.28 -enterprise-grade features such as x86_32-PAE, x86_64, SMP guests and
    4.29 -live relocation of VMs. This install tree contains source for a Linux
    4.30 -2.6 guest; ports to Linux 2.4, NetBSD, FreeBSD and Solaris will follow
    4.31 -later (and are already available for previous Xen releases).
    4.32 -
    4.33 -This file contains some quick-start instructions to install Xen on
    4.34 -your system. For full documentation, see the Xen User Manual. If this
    4.35 -is a pre-built release then you can find the manual at:
    4.36 - dist/install/usr/share/doc/xen/pdf/user.pdf
    4.37 -If you have a source release, then 'make -C docs' will build the
    4.38 -manual at docs/pdf/user.pdf.
    4.39 -
    4.40 -Quick-Start Guide - Pre-Built Binary Release
    4.41 -============================================
    4.42 -
    4.43 -[NB. Unless noted otherwise, all the following steps should be
    4.44 -performed with root privileges.]
    4.45 -
    4.46 -1. Install the binary distribution onto your filesystem:
    4.47 -
    4.48 -    # sh ./install.sh
    4.49 -
    4.50 -   Among other things, this will install Xen and Xen-ready Linux
    4.51 -   kernel files in /boot, kernel modules and Python packages in /lib,
    4.52 -   and various control tools in standard 'bin' directories.
    4.53 -
    4.54 -2. Configure your bootloader to boot Xen and an initial Linux virtual
    4.55 -   machine. Note that Xen currently only works with GRUB and pxelinux
    4.56 -   derived boot loaders: less common alternatives such as LILO are
    4.57 -   *not* supported. You can most likely find your GRUB menu file at
    4.58 -   /boot/grub/menu.lst: edit this file to include an entry like the
    4.59 -   following:
    4.60 -
    4.61 -    title Xen 3.0 / XenLinux 2.6
    4.62 -       kernel /boot/xen-3.0.gz console=vga
    4.63 -       module /boot/vmlinuz-2.6-xen root=<root-dev> ro console=tty0
    4.64 -       module /boot/initrd-2.6-xen.img
    4.65 -
    4.66 -   NB: Not all kernel configs need an initial ram disk (initrd), but
    4.67 -   if you do specify one you'll need to use the 'module' grub directive
    4.68 -   rather than 'initrd'.
    4.69 -
    4.70 -   The linux command line takes all the usual options, such as
    4.71 -   root=<root-dev> to specify your usual root partition (e.g.,
    4.72 -   /dev/hda1).  
    4.73 -
    4.74 -   The Xen command line takes a number of optional arguments described
    4.75 -   in the manual. The most common is 'dom0_mem=xxxM' which sets the
    4.76 -   amount of memory to allocate for use by your initial virtual
    4.77 -   machine (known as domain 0). Note that Xen itself reserves about
    4.78 -   32MB memory for internal use, which is not available for allocation
    4.79 -   to virtual machines.  
    4.80 -
    4.81 -3. Reboot your system and select the "Xen 3.0 / XenLinux 2.6" menu
    4.82 -   option. After booting Xen, Linux will start and your initialisation
    4.83 -   scripts should execute in the usual way.
    4.84 -
    4.85 -Quick-Start Guide - Source Release
    4.86 -==================================
    4.87 -
    4.88 -First, there are a number of prerequisites for building a Xen source
    4.89 -release. Make sure you have all the following installed, either by
    4.90 -visiting the project webpage or installing a pre-built package
    4.91 -provided by your Linux distributor:
    4.92 -    * GCC (preferably v3.2.x or v3.3.x; older versions are unsupported) 
    4.93 -    * GNU Make
    4.94 -    * GNU Binutils
    4.95 -    * Development install of zlib (e.g., zlib-dev)
    4.96 -    * Development install of Python v2.3 or later (e.g., python-dev)
    4.97 -    * bridge-utils package (/sbin/brctl)
    4.98 -    * iproute package (/sbin/ip)
    4.99 -    * hotplug or udev
   4.100 -
   4.101 -[NB. Unless noted otherwise, all the following steps should be
   4.102 -performed with root privileges.]
   4.103 -
   4.104 -1. Download and untar the source tarball file. This will be a
   4.105 -   file named xen-unstable-src.tgz, or xen-$version-src.tgz.
   4.106 -   You can also pull the current version from the SCMS
   4.107 -   that is being used (Bitkeeper, scheduled to change shortly).
   4.108 -
   4.109 -    # tar xzf xen-unstable-src.tgz
   4.110 -
   4.111 -   Assuming you are using the unstable tree, this will
   4.112 -   untar into xen-unstable. The rest of the instructions
   4.113 -   use the unstable tree as an example, substitute the
   4.114 -   version for unstable.
   4.115 -
   4.116 -2. cd to xen-unstable (or whatever you sensibly rename it to).
   4.117 -   The Linux, netbsd and freebsd kernel source trees are in
   4.118 -   the $os-$version-xen-sparse directories.
   4.119 -
   4.120 -On Linux:
   4.121 -
   4.122 -3. For the very first build, or if you want to destroy existing
   4.123 -   .configs and build trees, perform the following steps:
   4.124 -
   4.125 -    # make KERNELS=linux-2.6-xen world
   4.126 -    # make install
   4.127 -
   4.128 -   It will create and install into the dist/ directory which is the
   4.129 -   default install location. It will build the xen binary (xen.gz),
   4.130 -   and a linux kernel and modules that can be used in both dom0 and an
   4.131 -   unprivileged guest kernel (vmlinuz-2.6.x-xen), the tools and the
   4.132 -   documentation.
   4.133 -
   4.134 -   If you don't specify KERNELS= on the make command line it will
   4.135 -   default to building two kernels, vmlinuz-2.6.x-xen0 and
   4.136 -   vmlinuz-2.6.x-xenU. These are smaller builds with just selected
   4.137 -   modules, intended primarilly for developers that don't like to wait
   4.138 -   for a -xen kernel to build. The -xenU kernel is particularly small
   4.139 -   as it does not contain any physical device drivers, and hence is
   4.140 -   only useful for guest domains.
   4.141 -
   4.142 -   If you want to build an x86_32 PAE capable xen and kernel to work
   4.143 -   on machines with >= 4GB of memory, use XEN_TARGET_X86_PAE=y on the
   4.144 -   make command line.
   4.145 -
   4.146 -4. To rebuild an existing tree without modifying the config:
   4.147 -    # make dist
   4.148 -
   4.149 -   This will build and install xen, kernels, tools, and
   4.150 -   docs into the local dist/ directory.
   4.151 -
   4.152 -5. To rebuild a kernel with a modified config:
   4.153 -
   4.154 -    # make linux-2.6-xen-config CONFIGMODE=menuconfig     (or xconfig)
   4.155 -    # make linux-2.6-xen-build
   4.156 -    # make linux-2.6-xen-install
   4.157 -
   4.158 -   Depending on your config, you may need to use 'mkinitrd' to create
   4.159 -   an initial ram disk, just like a native system e.g. 
   4.160 -    # depmod 2.6.12.6-xen
   4.161 -    # mkinitrd -v -f --with=aacraid --with=sd_mod --with=scsi_mod initrd-2.6.12.6-xen.img 2.6.12.6-xen
   4.162 +################################
   4.163 + __  __            _____  ___  
   4.164 + \ \/ /___ _ __   |___ / / _ \ 
   4.165 +  \  // _ \ '_ \    |_ \| | | |
   4.166 +  /  \  __/ | | |  ___) | |_| |
   4.167 + /_/\_\___|_| |_| |____(_)___/ 
   4.168 +
   4.169 +################################
   4.170 +
   4.171 +http://www.xensource.com/xen/about.html
   4.172 +
   4.173 +What is Xen?
   4.174 +============
   4.175 +
   4.176 +Xen is a Virtual Machine Monitor (VMM) originally developed by the
   4.177 +Systems Research Group of the University of Cambridge Computer
   4.178 +Laboratory, as part of the UK-EPSRC funded XenoServers project.  Xen
   4.179 +is freely-distributable Open Source software, released under the GNU
   4.180 +GPL. Since its initial public release, Xen has grown a large
   4.181 +development community, spearheaded by XenSource Inc, a company created
   4.182 +by the original Xen development team to build enterprise products
   4.183 +around Xen.
   4.184 +
   4.185 +The 3.0 release offers excellent performance, hardware support and
   4.186 +enterprise-grade features such as x86_32-PAE, x86_64, SMP guests and
   4.187 +live relocation of VMs. This install tree contains source for a Linux
   4.188 +2.6 guest; ports to Linux 2.4, NetBSD, FreeBSD and Solaris will follow
   4.189 +later (and are already available for previous Xen releases).
   4.190 +
   4.191 +This file contains some quick-start instructions to install Xen on
   4.192 +your system. For full documentation, see the Xen User Manual. If this
   4.193 +is a pre-built release then you can find the manual at:
   4.194 + dist/install/usr/share/doc/xen/pdf/user.pdf
   4.195 +If you have a source release, then 'make -C docs' will build the
   4.196 +manual at docs/pdf/user.pdf.
   4.197 +
   4.198 +Quick-Start Guide - Pre-Built Binary Release
   4.199 +============================================
   4.200 +
   4.201 +[NB. Unless noted otherwise, all the following steps should be
   4.202 +performed with root privileges.]
   4.203 +
   4.204 +1. Install the binary distribution onto your filesystem:
   4.205 +
   4.206 +    # sh ./install.sh
   4.207 +
   4.208 +   Among other things, this will install Xen and Xen-ready Linux
   4.209 +   kernel files in /boot, kernel modules and Python packages in /lib,
   4.210 +   and various control tools in standard 'bin' directories.
   4.211 +
   4.212 +2. Configure your bootloader to boot Xen and an initial Linux virtual
   4.213 +   machine. Note that Xen currently only works with GRUB and pxelinux
   4.214 +   derived boot loaders: less common alternatives such as LILO are
   4.215 +   *not* supported. You can most likely find your GRUB menu file at
   4.216 +   /boot/grub/menu.lst: edit this file to include an entry like the
   4.217 +   following:
   4.218 +
   4.219 +    title Xen 3.0 / XenLinux 2.6
   4.220 +       kernel /boot/xen-3.0.gz console=vga
   4.221 +       module /boot/vmlinuz-2.6-xen root=<root-dev> ro console=tty0
   4.222 +       module /boot/initrd-2.6-xen.img
   4.223 +
   4.224 +   NB: Not all kernel configs need an initial ram disk (initrd), but
   4.225 +   if you do specify one you'll need to use the 'module' grub directive
   4.226 +   rather than 'initrd'.
   4.227 +
   4.228 +   The linux command line takes all the usual options, such as
   4.229 +   root=<root-dev> to specify your usual root partition (e.g.,
   4.230 +   /dev/hda1).  
   4.231 +
   4.232 +   The Xen command line takes a number of optional arguments described
   4.233 +   in the manual. The most common is 'dom0_mem=xxxM' which sets the
   4.234 +   amount of memory to allocate for use by your initial virtual
   4.235 +   machine (known as domain 0). Note that Xen itself reserves about
   4.236 +   32MB memory for internal use, which is not available for allocation
   4.237 +   to virtual machines.  
   4.238 +
   4.239 +3. Reboot your system and select the "Xen 3.0 / XenLinux 2.6" menu
   4.240 +   option. After booting Xen, Linux will start and your initialisation
   4.241 +   scripts should execute in the usual way.
   4.242 +
   4.243 +Quick-Start Guide - Source Release
   4.244 +==================================
   4.245 +
   4.246 +First, there are a number of prerequisites for building a Xen source
   4.247 +release. Make sure you have all the following installed, either by
   4.248 +visiting the project webpage or installing a pre-built package
   4.249 +provided by your Linux distributor:
   4.250 +    * GCC (preferably v3.2.x or v3.3.x; older versions are unsupported) 
   4.251 +    * GNU Make
   4.252 +    * GNU Binutils
   4.253 +    * Development install of zlib (e.g., zlib-dev)
   4.254 +    * Development install of Python v2.3 or later (e.g., python-dev)
   4.255 +    * bridge-utils package (/sbin/brctl)
   4.256 +    * iproute package (/sbin/ip)
   4.257 +    * hotplug or udev
   4.258 +
   4.259 +[NB. Unless noted otherwise, all the following steps should be
   4.260 +performed with root privileges.]
   4.261 +
   4.262 +1. Download and untar the source tarball file. This will be a
   4.263 +   file named xen-unstable-src.tgz, or xen-$version-src.tgz.
   4.264 +   You can also pull the current version from the SCMS
   4.265 +   that is being used (Bitkeeper, scheduled to change shortly).
   4.266 +
   4.267 +    # tar xzf xen-unstable-src.tgz
   4.268 +
   4.269 +   Assuming you are using the unstable tree, this will
   4.270 +   untar into xen-unstable. The rest of the instructions
   4.271 +   use the unstable tree as an example, substitute the
   4.272 +   version for unstable.
   4.273 +
   4.274 +2. cd to xen-unstable (or whatever you sensibly rename it to).
   4.275 +   The Linux, netbsd and freebsd kernel source trees are in
   4.276 +   the $os-$version-xen-sparse directories.
   4.277 +
   4.278 +On Linux:
   4.279 +
   4.280 +3. For the very first build, or if you want to destroy existing
   4.281 +   .configs and build trees, perform the following steps:
   4.282 +
   4.283 +    # make world
   4.284 +    # make install
   4.285 +
   4.286 +   This will create and install onto the local machine. It will build 
   4.287 +   the xen binary (xen.gz), and a linux kernel and modules that can be
   4.288 +   used in both dom0 and an unprivileged guest kernel (vmlinuz-2.6.x-xen),
   4.289 +   the tools and the documentation.
   4.290 +
   4.291 +   You can override the destination for make install by setting DESTDIR 
   4.292 +   to some value.
   4.293 +
   4.294 +   The make command line defaults to building the kernel vmlinuz-2.6.x-xen. 
   4.295 +   You can override this default by specifying KERNELS=kernelname. For 
   4.296 +   example, you can make two kernels - linux-2.6-xen0 
   4.297 +   and linux-2.6-xenU - which are smaller builds containing only selected 
   4.298 +   modules, intended primarily for developers that don't like to wait 
   4.299 +   for a full -xen kernel to build. The -xenU kernel is particularly small,
   4.300 +   as it does not contain any physical device drivers, and hence is
   4.301 +   only useful for guest domains.
   4.302 +
   4.303 +   To make these two kernels, simply specify
   4.304 +
   4.305 +   KERNELS="linux-2.6-xen0 linux-2.6-xenU"
   4.306 +
   4.307 +   in the make command line.
   4.308 +
   4.309 +   If you want to build an x86_32 PAE capable xen and kernel to work
   4.310 +   on machines with >= 4GB of memory, use XEN_TARGET_X86_PAE=y on the
   4.311 +   make command line.
   4.312 +
   4.313 +4. To rebuild an existing tree without modifying the config:
   4.314 +    # make dist
   4.315 +
   4.316 +   This will build and install xen, kernels, tools, and
   4.317 +   docs into the local dist/ directory. 
   4.318 +
   4.319 +   You can override the destination for make install by setting DISTDIR 
   4.320 +   to some value.
   4.321 +
   4.322 +   make install and make dist differ in that make install does the 
   4.323 +   right things for your local machine (installing the appropriate 
   4.324 +   version of hotplug or udev scripts, for example), but make dist 
   4.325 +   includes all versions of those scripts, so that you can copy the dist 
   4.326 +   directory to another machine and install from that distribution.
   4.327 +
   4.328 +5. To rebuild a kernel with a modified config:
   4.329 +
   4.330 +    # make linux-2.6-xen-config CONFIGMODE=menuconfig     (or xconfig)
   4.331 +    # make linux-2.6-xen-build
   4.332 +    # make linux-2.6-xen-install
   4.333 +
   4.334 +   Depending on your config, you may need to use 'mkinitrd' to create
   4.335 +   an initial ram disk, just like a native system e.g. 
   4.336 +    # depmod 2.6.16-xen
   4.337 +    # mkinitrd -v -f --with=aacraid --with=sd_mod --with=scsi_mod initrd-2.6.16-xen.img 2.6.16-xen
     5.1 --- a/buildconfigs/Rules.mk	Tue Apr 11 13:55:47 2006 -0600
     5.2 +++ b/buildconfigs/Rules.mk	Tue Apr 11 18:54:18 2006 -0600
     5.3 @@ -6,8 +6,6 @@ export DESTDIR
     5.4  ALLKERNELS = $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.*))
     5.5  ALLSPARSETREES = $(patsubst %-xen-sparse,%,$(wildcard *-xen-sparse))
     5.6  
     5.7 -.PHONY:	mkpatches mrproper
     5.8 -
     5.9  # Setup pristine search path
    5.10  PRISTINE_SRC_PATH	?= .:..
    5.11  vpath pristine-% $(PRISTINE_SRC_PATH)
    5.12 @@ -40,29 +38,6 @@ patch-%.bz2:
    5.13  	@echo "Cannot find $(@F) in path $(LINUX_SRC_PATH)"
    5.14  	wget $(KERNEL_REPO)/pub/linux/kernel/v$(_LINUX_VDIR)/$(_LINUX_XDIR)/$(@F) -O./$@
    5.15  
    5.16 -# Expand NetBSD release to NetBSD version
    5.17 -NETBSD_RELEASE  ?= 2.0
    5.18 -NETBSD_VER      ?= $(patsubst netbsd-%-xen-sparse,%,$(wildcard netbsd-$(NETBSD_RELEASE)*-xen-sparse))
    5.19 -NETBSD_CVSSNAP  ?= 20050309
    5.20 -
    5.21 -# Setup NetBSD search path
    5.22 -NETBSD_SRC_PATH	?= .:..
    5.23 -vpath netbsd-%.tar.bz2 $(NETBSD_SRC_PATH)
    5.24 -
    5.25 -# download a pristine NetBSD tarball if there isn't one in NETBSD_SRC_PATH
    5.26 -netbsd-%-xen-kernel-$(NETBSD_CVSSNAP).tar.bz2:
    5.27 -	@echo "Cannot find $@ in path $(NETBSD_SRC_PATH)"
    5.28 -	wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/$@ -O./$@
    5.29 -
    5.30 -netbsd-%.tar.bz2: netbsd-%-xen-kernel-$(NETBSD_CVSSNAP).tar.bz2
    5.31 -	ln -fs $< $@
    5.32 -
    5.33 -ifeq ($(OS),linux)
    5.34 -OS_VER = $(LINUX_VER)
    5.35 -else
    5.36 -OS_VER = $(NETBSD_VER)
    5.37 -endif
    5.38 -
    5.39  pristine-%: pristine-%/.valid-pristine
    5.40  	@true
    5.41  
    5.42 @@ -84,6 +59,7 @@ ifneq ($(PATCHDIRS),)
    5.43  $(patsubst patches/%,patches/%/.makedep,$(PATCHDIRS)): patches/%/.makedep: 
    5.44  	@echo 'ref-$*/.valid-ref: $$(wildcard patches/$*/*.patch)' >$@
    5.45  
    5.46 +.PHONY: clean
    5.47  clean::
    5.48  	rm -f patches/*/.makedep
    5.49  
    5.50 @@ -124,27 +100,21 @@ linux-2.6-xen.patch: ref-linux-$(LINUX_V
    5.51  	rm -rf tmp-$@
    5.52  	cp -al $(<D) tmp-$@
    5.53  	( cd linux-2.6-xen-sparse && ./mkbuildtree ../tmp-$@ )	
    5.54 -	diff -Nurp $(<D) tmp-$@ > $@ || true
    5.55 +	diff -Nurp $(patsubst ref%,pristine%,$(<D)) tmp-$@ > $@ || true
    5.56  	rm -rf tmp-$@
    5.57  
    5.58  %-xen.patch: ref-%/.valid-ref
    5.59  	rm -rf tmp-$@
    5.60  	cp -al $(<D) tmp-$@
    5.61  	( cd $*-xen-sparse && ./mkbuildtree ../tmp-$@ )	
    5.62 -	diff -Nurp $(<D) tmp-$@ > $@ || true
    5.63 +	diff -Nurp $(patsubst ref%,pristine%,$(<D)) tmp-$@ > $@ || true
    5.64  	rm -rf tmp-$@
    5.65  
    5.66 -%-mrproper: %-mrproper-extra
    5.67 +%-mrproper:
    5.68  	rm -rf pristine-$(*)* ref-$(*)* $*.tar.bz2
    5.69  	rm -rf $*-xen.patch
    5.70  
    5.71 -netbsd-%-mrproper-extra:
    5.72 -	rm -rf netbsd-$*-tools netbsd-$*-tools.tar.bz2
    5.73 -	rm -f netbsd-$*-xen-kernel-$(NETBSD_CVSSNAP).tar.bz2
    5.74 -
    5.75 -%-mrproper-extra:
    5.76 -	@: # do nothing
    5.77 -
    5.78 +.PHONY: config-update-pae
    5.79  config-update-pae:
    5.80  ifeq ($(XEN_TARGET_X86_PAE),y)
    5.81  	sed -e 's!^CONFIG_HIGHMEM4G=y$$!\# CONFIG_HIGHMEM4G is not set!;s!^\# CONFIG_HIGHMEM64G is not set$$!CONFIG_HIGHMEM64G=y!' $(CONFIG_FILE) > $(CONFIG_FILE)- && mv $(CONFIG_FILE)- $(CONFIG_FILE)
     6.1 --- a/buildconfigs/linux-defconfig_xen0_ia64	Tue Apr 11 13:55:47 2006 -0600
     6.2 +++ b/buildconfigs/linux-defconfig_xen0_ia64	Tue Apr 11 18:54:18 2006 -0600
     6.3 @@ -95,6 +95,7 @@ CONFIG_ARCH_XEN=y
     6.4  CONFIG_XEN_PRIVILEGED_GUEST=y
     6.5  CONFIG_XEN_BLKDEV_GRANT=y
     6.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     6.7 +CONFIG_XEN_BACKEND=y
     6.8  CONFIG_XEN_BLKDEV_BACKEND=y
     6.9  CONFIG_XEN_SYSFS=y
    6.10  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
     7.1 --- a/buildconfigs/linux-defconfig_xen0_x86_32	Tue Apr 11 13:55:47 2006 -0600
     7.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_32	Tue Apr 11 18:54:18 2006 -0600
     7.3 @@ -1,7 +1,7 @@
     7.4  #
     7.5  # Automatically generated make config: don't edit
     7.6 -# Linux kernel version: 2.6.16-rc3-xen0
     7.7 -# Thu Feb 16 22:52:42 2006
     7.8 +# Linux kernel version: 2.6.16-xen0
     7.9 +# Sat Apr  8 11:34:07 2006
    7.10  #
    7.11  CONFIG_X86_32=y
    7.12  CONFIG_SEMAPHORE_SLEEPERS=y
    7.13 @@ -208,7 +208,6 @@ CONFIG_ACPI_BLACKLIST_YEAR=0
    7.14  CONFIG_ACPI_EC=y
    7.15  CONFIG_ACPI_POWER=y
    7.16  CONFIG_ACPI_SYSTEM=y
    7.17 -# CONFIG_X86_PM_TIMER is not set
    7.18  # CONFIG_ACPI_CONTAINER is not set
    7.19  
    7.20  #
    7.21 @@ -392,7 +391,13 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
    7.22  #
    7.23  # Plug and Play support
    7.24  #
    7.25 -# CONFIG_PNP is not set
    7.26 +CONFIG_PNP=y
    7.27 +CONFIG_PNP_DEBUG=y
    7.28 +
    7.29 +#
    7.30 +# Protocols
    7.31 +#
    7.32 +CONFIG_PNPACPI=y
    7.33  
    7.34  #
    7.35  # Block devices
    7.36 @@ -440,6 +445,7 @@ CONFIG_BLK_DEV_IDECD=y
    7.37  #
    7.38  CONFIG_IDE_GENERIC=y
    7.39  # CONFIG_BLK_DEV_CMD640 is not set
    7.40 +# CONFIG_BLK_DEV_IDEPNP is not set
    7.41  CONFIG_BLK_DEV_IDEPCI=y
    7.42  # CONFIG_IDEPCI_SHARE_IRQ is not set
    7.43  # CONFIG_BLK_DEV_OFFBOARD is not set
    7.44 @@ -623,6 +629,7 @@ CONFIG_NETDEVICES=y
    7.45  # CONFIG_BONDING is not set
    7.46  # CONFIG_EQUALIZER is not set
    7.47  CONFIG_TUN=y
    7.48 +# CONFIG_NET_SB1000 is not set
    7.49  
    7.50  #
    7.51  # ARCnet devices
    7.52 @@ -1064,11 +1071,7 @@ CONFIG_USB_MON=y
    7.53  # CONFIG_INFINIBAND is not set
    7.54  
    7.55  #
    7.56 -# SN Devices
    7.57 -#
    7.58 -
    7.59 -#
    7.60 -# EDAC - error detection and reporting (RAS)
    7.61 +# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
    7.62  #
    7.63  # CONFIG_EDAC is not set
    7.64  
    7.65 @@ -1231,6 +1234,7 @@ CONFIG_NLS_ISO8859_1=y
    7.66  #
    7.67  # Instrumentation Support
    7.68  #
    7.69 +# CONFIG_PROFILING is not set
    7.70  # CONFIG_KPROBES is not set
    7.71  
    7.72  #
    7.73 @@ -1305,13 +1309,14 @@ CONFIG_CRYPTO_CRC32C=m
    7.74  #
    7.75  # CONFIG_CRYPTO_DEV_PADLOCK is not set
    7.76  CONFIG_XEN=y
    7.77 -CONFIG_NO_IDLE_HZ=y
    7.78 +CONFIG_XEN_INTERFACE_VERSION=0x00030101
    7.79  
    7.80  #
    7.81  # XEN
    7.82  #
    7.83  CONFIG_XEN_PRIVILEGED_GUEST=y
    7.84  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
    7.85 +CONFIG_XEN_BACKEND=y
    7.86  CONFIG_XEN_PCIDEV_BACKEND=y
    7.87  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
    7.88  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
    7.89 @@ -1331,6 +1336,7 @@ CONFIG_XEN_DISABLE_SERIAL=y
    7.90  CONFIG_XEN_SYSFS=y
    7.91  CONFIG_HAVE_ARCH_ALLOC_SKB=y
    7.92  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
    7.93 +CONFIG_NO_IDLE_HZ=y
    7.94  
    7.95  #
    7.96  # Library routines
    7.97 @@ -1343,4 +1349,6 @@ CONFIG_ZLIB_INFLATE=y
    7.98  CONFIG_GENERIC_HARDIRQS=y
    7.99  CONFIG_GENERIC_IRQ_PROBE=y
   7.100  CONFIG_X86_BIOS_REBOOT=y
   7.101 +CONFIG_X86_NO_TSS=y
   7.102 +CONFIG_X86_NO_IDT=y
   7.103  CONFIG_KTIME_SCALAR=y
     8.1 --- a/buildconfigs/linux-defconfig_xen0_x86_64	Tue Apr 11 13:55:47 2006 -0600
     8.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_64	Tue Apr 11 18:54:18 2006 -0600
     8.3 @@ -327,7 +327,13 @@ CONFIG_STANDALONE=y
     8.4  #
     8.5  # Plug and Play support
     8.6  #
     8.7 -# CONFIG_PNP is not set
     8.8 +CONFIG_PNP=y
     8.9 +CONFIG_PNP_DEBUG=y
    8.10 +
    8.11 +#
    8.12 +# Protocols
    8.13 +#
    8.14 +CONFIG_PNPACPI=y
    8.15  
    8.16  #
    8.17  # Block devices
    8.18 @@ -375,6 +381,7 @@ CONFIG_BLK_DEV_IDECD=y
    8.19  #
    8.20  CONFIG_IDE_GENERIC=y
    8.21  # CONFIG_BLK_DEV_CMD640 is not set
    8.22 +# CONFIG_BLK_DEV_IDEPNP is not set
    8.23  CONFIG_BLK_DEV_IDEPCI=y
    8.24  # CONFIG_IDEPCI_SHARE_IRQ is not set
    8.25  # CONFIG_BLK_DEV_OFFBOARD is not set
    8.26 @@ -559,6 +566,7 @@ CONFIG_NETDEVICES=y
    8.27  # CONFIG_BONDING is not set
    8.28  # CONFIG_EQUALIZER is not set
    8.29  CONFIG_TUN=y
    8.30 +# CONFIG_NET_SB1000 is not set
    8.31  
    8.32  #
    8.33  # ARCnet devices
    8.34 @@ -1183,6 +1191,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
    8.35  # CONFIG_DEBUG_SPINLOCK is not set
    8.36  # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
    8.37  # CONFIG_DEBUG_KOBJECT is not set
    8.38 +# CONFIG_DEBUG_INFO is not set
    8.39  # CONFIG_DEBUG_FS is not set
    8.40  # CONFIG_DEBUG_VM is not set
    8.41  CONFIG_FRAME_POINTER=y
    8.42 @@ -1237,6 +1246,7 @@ CONFIG_NO_IDLE_HZ=y
    8.43  #
    8.44  CONFIG_XEN_PRIVILEGED_GUEST=y
    8.45  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
    8.46 +CONFIG_XEN_BACKEND=y
    8.47  CONFIG_XEN_PCIDEV_BACKEND=y
    8.48  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
    8.49  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     9.1 --- a/buildconfigs/linux-defconfig_xenU_ia64	Tue Apr 11 13:55:47 2006 -0600
     9.2 +++ b/buildconfigs/linux-defconfig_xenU_ia64	Tue Apr 11 18:54:18 2006 -0600
     9.3 @@ -92,6 +92,7 @@ CONFIG_ARCH_XEN=y
     9.4  CONFIG_XEN_PRIVILEGED_GUEST=y
     9.5  CONFIG_XEN_BLKDEV_GRANT=y
     9.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     9.7 +CONFIG_XEN_BACKEND=y
     9.8  CONFIG_XEN_BLKDEV_BACKEND=y
     9.9  CONFIG_XEN_SYSFS=y
    9.10  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
    10.1 --- a/buildconfigs/linux-defconfig_xenU_x86_32	Tue Apr 11 13:55:47 2006 -0600
    10.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_32	Tue Apr 11 18:54:18 2006 -0600
    10.3 @@ -779,6 +779,7 @@ CONFIG_NLS_ISO8859_1=y
    10.4  #
    10.5  # Instrumentation Support
    10.6  #
    10.7 +# CONFIG_PROFILING is not set
    10.8  # CONFIG_KPROBES is not set
    10.9  
   10.10  #
   10.11 @@ -858,13 +859,9 @@ CONFIG_NO_IDLE_HZ=y
   10.12  #
   10.13  # CONFIG_XEN_PRIVILEGED_GUEST is not set
   10.14  CONFIG_XEN_UNPRIVILEGED_GUEST=y
   10.15 -# CONFIG_XEN_PCIDEV_BACKEND is not set
   10.16 -# CONFIG_XEN_BLKDEV_BACKEND is not set
   10.17 -# CONFIG_XEN_NETDEV_BACKEND is not set
   10.18 -# CONFIG_XEN_TPMDEV_BACKEND is not set
   10.19 +# CONFIG_XEN_BACKEND is not set
   10.20  CONFIG_XEN_BLKDEV_FRONTEND=y
   10.21  CONFIG_XEN_NETDEV_FRONTEND=y
   10.22 -# CONFIG_XEN_BLKDEV_TAP is not set
   10.23  # CONFIG_XEN_TPMDEV_FRONTEND is not set
   10.24  CONFIG_XEN_SCRUB_PAGES=y
   10.25  CONFIG_XEN_DISABLE_SERIAL=y
    11.1 --- a/buildconfigs/linux-defconfig_xenU_x86_64	Tue Apr 11 13:55:47 2006 -0600
    11.2 +++ b/buildconfigs/linux-defconfig_xenU_x86_64	Tue Apr 11 18:54:18 2006 -0600
    11.3 @@ -1080,6 +1080,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
    11.4  # CONFIG_DEBUG_SPINLOCK is not set
    11.5  # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
    11.6  # CONFIG_DEBUG_KOBJECT is not set
    11.7 +# CONFIG_DEBUG_INFO is not set
    11.8  # CONFIG_DEBUG_FS is not set
    11.9  # CONFIG_DEBUG_VM is not set
   11.10  CONFIG_FRAME_POINTER=y
   11.11 @@ -1134,13 +1135,9 @@ CONFIG_NO_IDLE_HZ=y
   11.12  #
   11.13  # CONFIG_XEN_PRIVILEGED_GUEST is not set
   11.14  CONFIG_XEN_UNPRIVILEGED_GUEST=y
   11.15 -# CONFIG_XEN_PCIDEV_BACKEND is not set
   11.16 -# CONFIG_XEN_BLKDEV_BACKEND is not set
   11.17 -# CONFIG_XEN_NETDEV_BACKEND is not set
   11.18 -# CONFIG_XEN_TPMDEV_BACKEND is not set
   11.19 +# CONFIG_XEN_BACKEND is not set
   11.20  CONFIG_XEN_BLKDEV_FRONTEND=y
   11.21  CONFIG_XEN_NETDEV_FRONTEND=y
   11.22 -# CONFIG_XEN_BLKDEV_TAP is not set
   11.23  # CONFIG_XEN_TPMDEV_FRONTEND is not set
   11.24  CONFIG_XEN_SCRUB_PAGES=y
   11.25  CONFIG_XEN_DISABLE_SERIAL=y
    12.1 --- a/buildconfigs/linux-defconfig_xen_ia64	Tue Apr 11 13:55:47 2006 -0600
    12.2 +++ b/buildconfigs/linux-defconfig_xen_ia64	Tue Apr 11 18:54:18 2006 -0600
    12.3 @@ -95,6 +95,7 @@ CONFIG_ARCH_XEN=y
    12.4  CONFIG_XEN_PRIVILEGED_GUEST=y
    12.5  CONFIG_XEN_BLKDEV_GRANT=y
    12.6  CONFIG_XEN_BLKDEV_FRONTEND=y
    12.7 +CONFIG_XEN_BACKEND=y
    12.8  CONFIG_XEN_BLKDEV_BACKEND=y
    12.9  CONFIG_XEN_SYSFS=y
   12.10  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
    13.1 --- a/buildconfigs/linux-defconfig_xen_x86_32	Tue Apr 11 13:55:47 2006 -0600
    13.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32	Tue Apr 11 18:54:18 2006 -0600
    13.3 @@ -292,11 +292,11 @@ CONFIG_NET=y
    13.4  # Networking options
    13.5  #
    13.6  # CONFIG_NETDEBUG is not set
    13.7 -CONFIG_PACKET=m
    13.8 +CONFIG_PACKET=y
    13.9  CONFIG_PACKET_MMAP=y
   13.10 -CONFIG_UNIX=m
   13.11 +CONFIG_UNIX=y
   13.12  CONFIG_XFRM=y
   13.13 -CONFIG_XFRM_USER=m
   13.14 +CONFIG_XFRM_USER=y
   13.15  CONFIG_NET_KEY=m
   13.16  CONFIG_INET=y
   13.17  CONFIG_IP_MULTICAST=y
   13.18 @@ -912,12 +912,12 @@ CONFIG_PARPORT_1284=y
   13.19  # Plug and Play support
   13.20  #
   13.21  CONFIG_PNP=y
   13.22 -# CONFIG_PNP_DEBUG is not set
   13.23 +CONFIG_PNP_DEBUG=y
   13.24  
   13.25  #
   13.26  # Protocols
   13.27  #
   13.28 -# CONFIG_PNPACPI is not set
   13.29 +CONFIG_PNPACPI=y
   13.30  
   13.31  #
   13.32  # Block devices
   13.33 @@ -2892,6 +2892,7 @@ CONFIG_NLS_UTF8=m
   13.34  #
   13.35  # Instrumentation Support
   13.36  #
   13.37 +# CONFIG_PROFILING is not set
   13.38  # CONFIG_KPROBES is not set
   13.39  
   13.40  #
   13.41 @@ -2978,6 +2979,7 @@ CONFIG_NO_IDLE_HZ=y
   13.42  #
   13.43  CONFIG_XEN_PRIVILEGED_GUEST=y
   13.44  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
   13.45 +CONFIG_XEN_BACKEND=y
   13.46  CONFIG_XEN_PCIDEV_BACKEND=y
   13.47  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
   13.48  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
    14.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Tue Apr 11 13:55:47 2006 -0600
    14.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Tue Apr 11 18:54:18 2006 -0600
    14.3 @@ -776,7 +776,13 @@ CONFIG_PARPORT_1284=y
    14.4  #
    14.5  # Plug and Play support
    14.6  #
    14.7 -# CONFIG_PNP is not set
    14.8 +CONFIG_PNP=y
    14.9 +CONFIG_PNP_DEBUG=y
   14.10 +
   14.11 +#
   14.12 +# Protocols
   14.13 +#
   14.14 +CONFIG_PNPACPI=y
   14.15  
   14.16  #
   14.17  # Block devices
   14.18 @@ -857,6 +863,7 @@ CONFIG_BLK_DEV_IDESCSI=m
   14.19  CONFIG_IDE_GENERIC=y
   14.20  CONFIG_BLK_DEV_CMD640=y
   14.21  CONFIG_BLK_DEV_CMD640_ENHANCED=y
   14.22 +CONFIG_BLK_DEV_IDEPNP=y
   14.23  CONFIG_BLK_DEV_IDEPCI=y
   14.24  CONFIG_IDEPCI_SHARE_IRQ=y
   14.25  # CONFIG_BLK_DEV_OFFBOARD is not set
   14.26 @@ -1088,6 +1095,7 @@ CONFIG_DUMMY=m
   14.27  CONFIG_BONDING=m
   14.28  CONFIG_EQUALIZER=m
   14.29  CONFIG_TUN=m
   14.30 +CONFIG_NET_SB1000=m
   14.31  
   14.32  #
   14.33  # ARCnet devices
   14.34 @@ -2587,6 +2595,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
   14.35  # CONFIG_DEBUG_SPINLOCK is not set
   14.36  # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
   14.37  # CONFIG_DEBUG_KOBJECT is not set
   14.38 +# CONFIG_DEBUG_INFO is not set
   14.39  # CONFIG_DEBUG_FS is not set
   14.40  # CONFIG_DEBUG_VM is not set
   14.41  # CONFIG_FRAME_POINTER is not set
   14.42 @@ -2647,6 +2656,7 @@ CONFIG_NO_IDLE_HZ=y
   14.43  #
   14.44  CONFIG_XEN_PRIVILEGED_GUEST=y
   14.45  # CONFIG_XEN_UNPRIVILEGED_GUEST is not set
   14.46 +CONFIG_XEN_BACKEND=y
   14.47  CONFIG_XEN_PCIDEV_BACKEND=y
   14.48  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
   14.49  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
    15.1 --- a/buildconfigs/mk.linux-2.6-xen	Tue Apr 11 13:55:47 2006 -0600
    15.2 +++ b/buildconfigs/mk.linux-2.6-xen	Tue Apr 11 18:54:18 2006 -0600
    15.3 @@ -1,19 +1,15 @@
    15.4 -
    15.5 -OS           = linux
    15.6 -
    15.7  LINUX_SERIES = 2.6
    15.8  LINUX_VER    = 2.6.16
    15.9  LINUX_SRCS = linux-2.6.16.tar.bz2
   15.10  
   15.11  EXTRAVERSION ?= xen
   15.12  
   15.13 -LINUX_DIR    = $(OS)-$(LINUX_VER)-$(EXTRAVERSION)
   15.14 +LINUX_DIR    = linux-$(LINUX_VER)-$(EXTRAVERSION)
   15.15  
   15.16  include buildconfigs/Rules.mk
   15.17  
   15.18 -.PHONY: build clean delete
   15.19 -
   15.20  # The real action starts here!
   15.21 +.PHONY: build
   15.22  build: $(LINUX_DIR)/include/linux/autoconf.h
   15.23  	if grep "^CONFIG_MODULES=" $(LINUX_DIR)/.config ; then \
   15.24  	    $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) modules ; \
   15.25 @@ -22,7 +18,7 @@ build: $(LINUX_DIR)/include/linux/autoco
   15.26  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) vmlinuz
   15.27  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(DESTDIR) install
   15.28  
   15.29 -$(LINUX_DIR)/include/linux/autoconf.h: ref-$(OS)-$(LINUX_VER)/.valid-ref
   15.30 +$(LINUX_DIR)/include/linux/autoconf.h: ref-linux-$(LINUX_VER)/.valid-ref
   15.31  	rm -rf $(LINUX_DIR)
   15.32  	cp -al $(<D) $(LINUX_DIR)
   15.33  	# Apply arch-xen patches
   15.34 @@ -42,14 +38,18 @@ build: $(LINUX_DIR)/include/linux/autoco
   15.35  	  rm -f Makefile ; mv Mk.tmp Makefile )
   15.36  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) oldconfig
   15.37  
   15.38 +.PHONY: prep
   15.39  prep: $(LINUX_DIR)/include/linux/autoconf.h
   15.40  
   15.41 +.PHONY: config
   15.42  config: CONFIGMODE = menuconfig
   15.43  config: $(LINUX_DIR)/include/linux/autoconf.h
   15.44  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) $(CONFIGMODE)
   15.45  
   15.46 +.PHONY: clean
   15.47  clean::
   15.48  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) clean
   15.49  
   15.50 +.PHONY: delete
   15.51  delete: 
   15.52 -	rm -rf tmp-$(OS)-$(LINUX_VER) $(LINUX_DIR) 
   15.53 +	rm -rf tmp-linux-$(LINUX_VER) $(LINUX_DIR) 
    16.1 --- a/docs/Makefile	Tue Apr 11 13:55:47 2006 -0600
    16.2 +++ b/docs/Makefile	Tue Apr 11 18:54:18 2006 -0600
    16.3 @@ -26,22 +26,28 @@ DOC_HTML	:= $(patsubst src/%.tex,html/%/
    16.4  
    16.5  GFX = $(patsubst %.fig, %.eps, $(wildcard figs/*.fig))
    16.6  
    16.7 -.PHONY:	all build dev-docs python-dev-docs ps pdf html clean install
    16.8 +.PHONY: all
    16.9 +all: build
   16.10  
   16.11 -all: build
   16.12 +.PHONY: build
   16.13  build: ps pdf html man-pages
   16.14  	rm -f *.aux *.dvi *.bbl *.blg *.glo *.idx *.ilg *.log *.ind *.toc
   16.15  
   16.16 +.PHONY: dev-docs
   16.17  dev-docs: python-dev-docs
   16.18  
   16.19 +.PHONY: ps
   16.20  ps: $(DOC_PS)
   16.21  
   16.22 +.PHONY: pdf
   16.23  pdf: $(DOC_PDF)
   16.24  
   16.25 +.PHONY: html
   16.26  html:
   16.27  	@if which $(LATEX2HTML) 1>/dev/null 2>/dev/null; then \
   16.28  	$(MAKE) $(DOC_HTML); fi
   16.29  
   16.30 +.PHONY: python-dev-docs
   16.31  python-dev-docs:
   16.32  	@mkdir -v -p api/tools/python
   16.33  	@if which $(DOXYGEN) 1>/dev/null 2>/dev/null; then         \
   16.34 @@ -50,6 +56,7 @@ python-dev-docs:
   16.35  	$(MAKE) -C api/tools/python/latex ; else                   \
   16.36          echo "Doxygen not installed; skipping python-dev-docs."; fi
   16.37  
   16.38 +.PHONY: man-pages
   16.39  man-pages:
   16.40  	@if which $(POD2MAN) 1>/dev/null 2>/dev/null; then \
   16.41  	$(MAKE) $(DOC_MAN1) $(DOC_MAN5); fi
   16.42 @@ -64,6 +71,7 @@ man5/%.5: man/%.pod.5 Makefile
   16.43  	$(POD2MAN) --release=$(VERSION) --name=`echo $@ | sed 's/^man5.//'| \
   16.44  		sed 's/.5//'` -s 5 -c "Xen" $< $@
   16.45  
   16.46 +.PHONY: clean
   16.47  clean:
   16.48  	rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~ 
   16.49  	rm -rf *.ilg *.log *.ind *.toc *.bak core
   16.50 @@ -72,6 +80,7 @@ clean:
   16.51  	rm -rf man5
   16.52  	rm -rf man1
   16.53  
   16.54 +.PHONY: install
   16.55  install: all
   16.56  	rm -rf $(DESTDIR)$(pkgdocdir)
   16.57  	$(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)
    17.1 --- a/docs/man/xm.pod.1	Tue Apr 11 13:55:47 2006 -0600
    17.2 +++ b/docs/man/xm.pod.1	Tue Apr 11 18:54:18 2006 -0600
    17.3 @@ -360,7 +360,7 @@ your Linux Kernel sources.
    17.4  Moves a domain out of the paused state.  This will allow a previously
    17.5  paused domain to now be eligible for scheduling by the Xen hypervisor.
    17.6  
    17.7 -=item B<set-vcpus> I<domain-id> I<vcpu-count>
    17.8 +=item B<vcpu-set> I<domain-id> I<vcpu-count>
    17.9  
   17.10  Enables the I<vcpu-count> virtual CPUs for the domain in question.
   17.11  Like mem-set, this command can only allocate up to the maximum virtual
   17.12 @@ -370,8 +370,8 @@ If the I<vcpu-count> is smaller than the
   17.13  VCPUs, the highest number VCPUs will be hotplug removed.  This may be
   17.14  important for pinning purposes.
   17.15  
   17.16 -Attempting to set-vcpus to a number larger than the initially
   17.17 -configured VCPU count is an error.  Trying to set-vcpus to < 1 will be
   17.18 +Attempting to set the VCPUs to a number larger than the initially
   17.19 +configured VCPU count is an error.  Trying to set VCPUs to < 1 will be
   17.20  quietly ignored.
   17.21  
   17.22  =item B<vcpu-list> I<[domain-id]>
    18.1 --- a/docs/src/user.tex	Tue Apr 11 13:55:47 2006 -0600
    18.2 +++ b/docs/src/user.tex	Tue Apr 11 18:54:18 2006 -0600
    18.3 @@ -2052,7 +2052,7 @@ dev86 & The dev86 package provides an as
    18.4  
    18.5  If the dev86 package is not available on the x86\_64 distribution, you can install the i386 version of it. The dev86 rpm package for various distributions can be found at {\scriptsize {\tt http://www.rpmfind.net/linux/rpm2html/search.php?query=dev86\&submit=Search}} \\
    18.6  
    18.7 -LibVNCServer & The unmodified guest's VGA display, keyboard, and mouse are virtualized using the vncserver library provided by this package. You can get the sources of libvncserver from {\small {\tt http://sourceforge.net/projects/libvncserver}}. Build and install the sources on the build system to get the libvncserver library. The 0.8pre version of libvncserver is currently working well with Xen.\\
    18.8 +LibVNCServer & The unmodified guest's VGA display, keyboard, and mouse can be virtualized by the vncserver library. You can get the sources of libvncserver from {\small {\tt http://sourceforge.net/projects/libvncserver}}. Build and install the sources on the build system to get the libvncserver library. There is a significant performance degradation in 0.8 version. The current sources in the CVS tree have fixed this degradation. So it is highly recommended to download the latest CVS sources and install them.\\
    18.9  
   18.10  SDL-devel, SDL & Simple DirectMedia Layer (SDL) is another way of virtualizing the unmodified guest console. It provides an X window for the guest console. 
   18.11  
   18.12 @@ -2077,6 +2077,8 @@ acpi & Enable VMX guest ACPI, default=0 
   18.13  
   18.14  apic & Enable VMX guest APIC, default=0 (disabled)\\
   18.15  
   18.16 +pae & Enable VMX guest PAE, default=0 (disabled)\\
   18.17 +
   18.18  vif     & Optionally defines MAC address and/or bridge for the network interfaces. Random MACs are assigned if not given. {\small {\tt type=ioemu}} means ioemu is used to virtualize the VMX NIC. If no type is specified, vbd is used, as with paravirtualized guests.\\
   18.19  
   18.20  disk & Defines the disk devices you want the domain to have access to, and what you want them accessible as. If using a physical device as the VMX guest's disk, each disk entry is of the form 
   18.21 @@ -2229,6 +2231,30 @@ Simply follow the usual method of creati
   18.22  
   18.23  In the default configuration, VNC is on and SDL is off. Therefore VNC windows will open when VMX guests are created. If you want to use SDL to create VMX guests, set {\small {\tt sdl=1}} in your VMX configuration file. You can also turn off VNC by setting {\small {\tt vnc=0}}.
   18.24   
   18.25 +\subsection{Use mouse in VNC window}
   18.26 +The default PS/2 mouse will not work properly in VMX by a VNC window. Summagraphics mouse emulation does work in this environment. A Summagraphics mouse can be enabled by reconfiguring 2 services:
   18.27 +
   18.28 +{\small {\tt 1. General Purpose Mouse (GPM). The GPM daemon is configured in different ways in different Linux distributions. On a Redhat distribution, this is accomplished by changing the file `/etc/sysconfig/mouse' to have the following:\\
   18.29 +MOUSETYPE="summa"\\
   18.30 +XMOUSETYPE="SUMMA"\\
   18.31 +DEVICE=/dev/ttyS0\\
   18.32 +\\
   18.33 +2. X11. For all Linux distributions, change the Mouse0 stanza in `/etc/X11/xorg.conf' to:\\
   18.34 +Section "InputDevice"\\
   18.35 +Identifier "Mouse0"\\
   18.36 +Driver "summa"\\
   18.37 +Option "Device" "/dev/ttyS0"\\
   18.38 +Option "InputFashion" "Tablet"\\
   18.39 +Option "Mode" "Absolute"\\
   18.40 +Option "Name" "EasyPen"\\
   18.41 +Option "Compatible" "True"\\
   18.42 +Option "Protocol" "Auto"\\
   18.43 +Option "SendCoreEvents" "on"\\
   18.44 +Option "Vendor" "GENIUS"\\
   18.45 +EndSection}}
   18.46 +
   18.47 +If the Summagraphics mouse isn't the default mouse, you can manually kill 'gpm' and restart it with the command "gpm -m /dev/ttyS0 -t summa". Note that Summagraphics mouse makes no sense in an SDL window and is therefore not available in this environment.
   18.48 +
   18.49  \subsection{Destroy VMX guests}
   18.50  VMX guests can be destroyed in the same way as can paravirtualized guests. We recommend that you type the command 
   18.51  
    19.1 --- a/extras/mini-os/Makefile	Tue Apr 11 13:55:47 2006 -0600
    19.2 +++ b/extras/mini-os/Makefile	Tue Apr 11 18:54:18 2006 -0600
    19.3 @@ -37,8 +37,10 @@ OBJS += $(patsubst %.c,%.o,$(wildcard co
    19.4  HDRS := $(wildcard include/*.h)
    19.5  HDRS += $(wildcard include/xen/*.h)
    19.6  
    19.7 +.PHONY: default
    19.8  default: $(TARGET)
    19.9  
   19.10 +.PHONY: links
   19.11  links:
   19.12  	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
   19.13  
   19.14 @@ -46,6 +48,7 @@ links:
   19.15  	$(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o $@.elf
   19.16  	gzip -f -9 -c $@.elf >$@.gz
   19.17  
   19.18 +.PHONY: clean
   19.19  clean:
   19.20  	find . -type f -name '*.o' | xargs rm -f
   19.21  	rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
    20.1 --- a/extras/mini-os/traps.c	Tue Apr 11 13:55:47 2006 -0600
    20.2 +++ b/extras/mini-os/traps.c	Tue Apr 11 18:54:18 2006 -0600
    20.3 @@ -4,6 +4,7 @@
    20.4  #include <hypervisor.h>
    20.5  #include <mm.h>
    20.6  #include <lib.h>
    20.7 +#include <sched.h>
    20.8  
    20.9  /*
   20.10   * These are assembler stubs in entry.S.
   20.11 @@ -31,6 +32,8 @@ void machine_check(void);
   20.12  
   20.13  void dump_regs(struct pt_regs *regs)
   20.14  {
   20.15 +    printk("Thread: %s\n", current->name);
   20.16 +#ifdef __i386__    
   20.17      printk("EIP: %x, EFLAGS %x.\n", regs->eip, regs->eflags);
   20.18      printk("EBX: %08x ECX: %08x EDX: %08x\n",
   20.19  	   regs->ebx, regs->ecx, regs->edx);
   20.20 @@ -40,9 +43,22 @@ void dump_regs(struct pt_regs *regs)
   20.21  	   regs->xds, regs->xes, regs->orig_eax, regs->eip);
   20.22      printk("CS: %04x EFLAGS: %08x esp: %08x ss: %04x\n",
   20.23  	   regs->xcs, regs->eflags, regs->esp, regs->xss);
   20.24 -
   20.25 -}	
   20.26 -
   20.27 +#else
   20.28 +    printk("RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->rip);
   20.29 +    printk("\nRSP: %04lx:%016lx  EFLAGS: %08lx\n", 
   20.30 +           regs->ss, regs->rsp, regs->eflags);
   20.31 +    printk("RAX: %016lx RBX: %016lx RCX: %016lx\n",
   20.32 +           regs->rax, regs->rbx, regs->rcx);
   20.33 +    printk("RDX: %016lx RSI: %016lx RDI: %016lx\n",
   20.34 +           regs->rdx, regs->rsi, regs->rdi); 
   20.35 +    printk("RBP: %016lx R08: %016lx R09: %016lx\n",
   20.36 +           regs->rbp, regs->r8, regs->r9); 
   20.37 +    printk("R10: %016lx R11: %016lx R12: %016lx\n",
   20.38 +           regs->r10, regs->r11, regs->r12); 
   20.39 +    printk("R13: %016lx R14: %016lx R15: %016lx\n",
   20.40 +           regs->r13, regs->r14, regs->r15); 
   20.41 +#endif
   20.42 +}
   20.43  
   20.44  static void do_trap(int trapnr, char *str, struct pt_regs * regs, unsigned long error_code)
   20.45  {
   20.46 @@ -110,36 +126,17 @@ void do_page_fault(struct pt_regs *regs,
   20.47      printk("Page fault at linear address %p, regs %p, code %lx\n", addr, regs,
   20.48  	   error_code);
   20.49      dump_regs(regs);
   20.50 -#ifdef __x86_64__
   20.51 -    /* FIXME: _PAGE_PSE */
   20.52 -    {
   20.53 -        unsigned long *tab = (unsigned long *)start_info.pt_base;
   20.54 -        unsigned long page;
   20.55 -    
   20.56 -        printk("Pagetable walk from %p:\n", tab);
   20.57 -        
   20.58 -        page = tab[l4_table_offset(addr)];
   20.59 -        tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   20.60 -        printk(" L4 = %p (%p)\n", page, tab);
   20.61 -
   20.62 -        page = tab[l3_table_offset(addr)];
   20.63 -        tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   20.64 -        printk("  L3 = %p (%p)\n", page, tab);
   20.65 -        
   20.66 -        page = tab[l2_table_offset(addr)];
   20.67 -        tab =  to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   20.68 -        printk("   L2 = %p (%p)\n", page, tab);
   20.69 -        
   20.70 -        page = tab[l1_table_offset(addr)];
   20.71 -        printk("    L1 = %p\n", page);
   20.72 -    }
   20.73 -#endif
   20.74 +    page_walk(addr);
   20.75      do_exit();
   20.76  }
   20.77  
   20.78  void do_general_protection(struct pt_regs *regs, long error_code)
   20.79  {
   20.80 -    printk("GPF %p, error_code=%lx\n", regs, error_code);
   20.81 +#ifdef __i386__
   20.82 +    printk("GPF eip: %p, error_code=%lx\n", regs->eip, error_code);
   20.83 +#else    
   20.84 +    printk("GPF rip: %p, error_code=%lx\n", regs->rip, error_code);
   20.85 +#endif
   20.86      dump_regs(regs);
   20.87      do_exit();
   20.88  }
    21.1 --- a/linux-2.6-xen-sparse/arch/i386/Kconfig	Tue Apr 11 13:55:47 2006 -0600
    21.2 +++ b/linux-2.6-xen-sparse/arch/i386/Kconfig	Tue Apr 11 18:54:18 2006 -0600
    21.3 @@ -1116,9 +1116,7 @@ source "fs/Kconfig"
    21.4  menu "Instrumentation Support"
    21.5  	depends on EXPERIMENTAL
    21.6  
    21.7 -if !X86_XEN
    21.8  source "arch/i386/oprofile/Kconfig"
    21.9 -endif
   21.10  
   21.11  config KPROBES
   21.12  	bool "Kprobes (EXPERIMENTAL)"
    22.1 --- a/linux-2.6-xen-sparse/arch/i386/Makefile	Tue Apr 11 13:55:47 2006 -0600
    22.2 +++ b/linux-2.6-xen-sparse/arch/i386/Makefile	Tue Apr 11 18:54:18 2006 -0600
    22.3 @@ -45,6 +45,11 @@ CFLAGS				+= $(shell if [ $(call cc-vers
    22.4  
    22.5  CFLAGS += $(cflags-y)
    22.6  
    22.7 +cppflags-$(CONFIG_XEN) += \
    22.8 +	-D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
    22.9 +
   22.10 +CPPFLAGS += $(cppflags-y)
   22.11 +
   22.12  # Default subarch .c files
   22.13  mcore-y  := mach-default
   22.14  
   22.15 @@ -107,7 +112,7 @@ boot := arch/i386/boot
   22.16  	zdisk bzdisk fdimage fdimage144 fdimage288 install
   22.17  
   22.18  ifdef CONFIG_XEN
   22.19 -CPPFLAGS        := -D__KERNEL__ -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(LINUXINCLUDE)
   22.20 +CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
   22.21  head-y := arch/i386/kernel/head-xen.o arch/i386/kernel/init_task-xen.o
   22.22  boot := arch/i386/boot-xen
   22.23  .PHONY: vmlinuz
   22.24 @@ -157,3 +162,4 @@ define archhelp
   22.25  endef
   22.26  
   22.27  CLEAN_FILES += arch/$(ARCH)/boot/fdimage arch/$(ARCH)/boot/mtools.conf
   22.28 +CLEAN_FILES += vmlinuz vmlinux-stripped
    23.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S	Tue Apr 11 13:55:47 2006 -0600
    23.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S	Tue Apr 11 18:54:18 2006 -0600
    23.3 @@ -65,7 +65,6 @@ ES		= 0x20
    23.4  ORIG_EAX	= 0x24
    23.5  EIP		= 0x28
    23.6  CS		= 0x2C
    23.7 -EVENT_MASK	= 0x2E
    23.8  EFLAGS		= 0x30
    23.9  OLDESP		= 0x34
   23.10  OLDSS		= 0x38
   23.11 @@ -290,14 +289,14 @@ restore_all:
   23.12  restore_nocheck:
   23.13  #else
   23.14  restore_nocheck:
   23.15 -	testl $(VM_MASK|NMI_MASK), EFLAGS(%esp)
   23.16 +	movl EFLAGS(%esp), %eax
   23.17 +	testl $(VM_MASK|NMI_MASK), %eax
   23.18  	jnz hypervisor_iret
   23.19 -	movb EVENT_MASK(%esp), %al
   23.20 -	notb %al			# %al == ~saved_mask
   23.21 +	shr $9, %eax			# EAX[0] == IRET_EFLAGS.IF
   23.22  	GET_VCPU_INFO
   23.23  	andb evtchn_upcall_mask(%esi),%al
   23.24 -	andb $1,%al			# %al == mask & ~saved_mask
   23.25 -	jnz restore_all_enable_events	#     != 0 => reenable event delivery
   23.26 +	andb $1,%al			# EAX[0] == IRET_EFLAGS.IF & event_mask
   23.27 +	jnz restore_all_enable_events	#        != 0 => enable event delivery
   23.28  #endif
   23.29  	RESTORE_REGS
   23.30  	addl $4, %esp
   23.31 @@ -462,7 +461,7 @@ vector=0
   23.32  ENTRY(irq_entries_start)
   23.33  .rept NR_IRQS
   23.34  	ALIGN
   23.35 -1:	pushl 0x80000000+$vector
   23.36 +1:	pushl $~(vector)
   23.37  	jmp common_interrupt
   23.38  .data
   23.39  	.long 1b
   23.40 @@ -479,7 +478,7 @@ common_interrupt:
   23.41  
   23.42  #define BUILD_INTERRUPT(name, nr)	\
   23.43  ENTRY(name)				\
   23.44 -	pushl 0x80000000+$nr;		\
   23.45 +	pushl $~(nr);			\
   23.46  	SAVE_ALL			\
   23.47  	movl %esp,%eax;			\
   23.48  	call smp_/**/name;		\
   23.49 @@ -555,14 +554,9 @@ scrit:	/**** START OF CRITICAL REGION **
   23.50  	RESTORE_REGS
   23.51  	addl $4, %esp
   23.52  1:	iret
   23.53 -.section .fixup,"ax"
   23.54 -2:	pushl $0
   23.55 -	pushl $do_iret_error
   23.56 -	jmp error_code
   23.57 -.previous
   23.58  .section __ex_table,"a"
   23.59  	.align 4
   23.60 -	.long 1b,2b
   23.61 +	.long 1b,iret_exc
   23.62  .previous
   23.63  14:	__DISABLE_INTERRUPTS
   23.64  	jmp  11b
   23.65 @@ -614,30 +608,51 @@ critical_fixup_table:
   23.66  	.byte 0x00,0x00			# jmp  11b
   23.67  
   23.68  # Hypervisor uses this for application faults while it executes.
   23.69 +# We get here for two reasons:
   23.70 +#  1. Fault while reloading DS, ES, FS or GS
   23.71 +#  2. Fault while executing IRET
   23.72 +# Category 1 we fix up by reattempting the load, and zeroing the segment
   23.73 +# register if the load fails.
   23.74 +# Category 2 we fix up by jumping to do_iret_error. We cannot use the
   23.75 +# normal Linux return path in this case because if we use the IRET hypercall
   23.76 +# to pop the stack frame we end up in an infinite loop of failsafe callbacks.
   23.77 +# We distinguish between categories by maintaining a status value in EAX.
   23.78  ENTRY(failsafe_callback)
   23.79 -1:	popl %ds
   23.80 -2:	popl %es
   23.81 -3:	popl %fs
   23.82 -4:	popl %gs
   23.83 -	subl $4,%esp
   23.84 +	pushl %eax
   23.85 +	movl $1,%eax
   23.86 +1:	mov 4(%esp),%ds
   23.87 +2:	mov 8(%esp),%es
   23.88 +3:	mov 12(%esp),%fs
   23.89 +4:	mov 16(%esp),%gs
   23.90 +	testl %eax,%eax
   23.91 +	popl %eax
   23.92 +	jz 5f
   23.93 +	addl $16,%esp		# EAX != 0 => Category 2 (Bad IRET)
   23.94 +	jmp iret_exc
   23.95 +5:	addl $16,%esp		# EAX == 0 => Category 1 (Bad segment)
   23.96 +	pushl $0
   23.97  	SAVE_ALL
   23.98 -	jmp  ret_from_exception
   23.99 -.section .fixup,"ax";	\
  23.100 -6:	movl $0,(%esp);	\
  23.101 -	jmp 1b;		\
  23.102 -7:	movl $0,(%esp);	\
  23.103 -	jmp 2b;		\
  23.104 -8:	movl $0,(%esp);	\
  23.105 -	jmp 3b;		\
  23.106 -9:	movl $0,(%esp);	\
  23.107 -	jmp 4b;		\
  23.108 -.previous;		\
  23.109 -.section __ex_table,"a";\
  23.110 -	.align 4;	\
  23.111 -	.long 1b,6b;	\
  23.112 -	.long 2b,7b;	\
  23.113 -	.long 3b,8b;	\
  23.114 -	.long 4b,9b;	\
  23.115 +	jmp ret_from_exception
  23.116 +.section .fixup,"ax";		\
  23.117 +6:	xorl %eax,%eax;		\
  23.118 +	movl %eax,4(%esp);	\
  23.119 +	jmp 1b;			\
  23.120 +7:	xorl %eax,%eax;		\
  23.121 +	movl %eax,8(%esp);	\
  23.122 +	jmp 2b;			\
  23.123 +8:	xorl %eax,%eax;		\
  23.124 +	movl %eax,12(%esp);	\
  23.125 +	jmp 3b;			\
  23.126 +9:	xorl %eax,%eax;		\
  23.127 +	movl %eax,16(%esp);	\
  23.128 +	jmp 4b;			\
  23.129 +.previous;			\
  23.130 +.section __ex_table,"a";	\
  23.131 +	.align 4;		\
  23.132 +	.long 1b,6b;		\
  23.133 +	.long 2b,7b;		\
  23.134 +	.long 3b,8b;		\
  23.135 +	.long 4b,9b;		\
  23.136  .previous
  23.137  #endif
  23.138  
    24.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/irq-xen.c	Tue Apr 11 13:55:47 2006 -0600
    24.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/irq-xen.c	Tue Apr 11 18:54:18 2006 -0600
    24.3 @@ -54,7 +54,7 @@ static union irq_ctx *softirq_ctx[NR_CPU
    24.4  fastcall unsigned int do_IRQ(struct pt_regs *regs)
    24.5  {	
    24.6  	/* high bit used in ret_from_ code */
    24.7 -	int irq = regs->orig_eax & __IRQ_MASK(BITS_PER_LONG - 1);
    24.8 +	int irq = ~regs->orig_eax;
    24.9  #ifdef CONFIG_4KSTACKS
   24.10  	union irq_ctx *curctx, *irqctx;
   24.11  	u32 *isp;
    25.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c	Tue Apr 11 13:55:47 2006 -0600
    25.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c	Tue Apr 11 18:54:18 2006 -0600
    25.3 @@ -69,7 +69,7 @@ dma_map_sg(struct device *hwdev, struct 
    25.4  	} else {
    25.5  		for (i = 0; i < nents; i++ ) {
    25.6  			sg[i].dma_address =
    25.7 -				page_to_phys(sg[i].page) + sg[i].offset;
    25.8 +				page_to_bus(sg[i].page) + sg[i].offset;
    25.9  			sg[i].dma_length  = sg[i].length;
   25.10  			BUG_ON(!sg[i].page);
   25.11  			IOMMU_BUG_ON(address_needs_mapping(
   25.12 @@ -105,7 +105,7 @@ dma_map_page(struct device *dev, struct 
   25.13  		dma_addr = swiotlb_map_page(
   25.14  			dev, page, offset, size, direction);
   25.15  	} else {
   25.16 -		dma_addr = page_to_phys(page) + offset;
   25.17 +		dma_addr = page_to_bus(page) + offset;
   25.18  		IOMMU_BUG_ON(address_needs_mapping(dev, dma_addr));
   25.19  	}
   25.20  
    26.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Tue Apr 11 13:55:47 2006 -0600
    26.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Tue Apr 11 18:54:18 2006 -0600
    26.3 @@ -114,7 +114,7 @@ void xen_idle(void)
    26.4  		smp_mb__after_clear_bit();
    26.5  		stop_hz_timer();
    26.6  		/* Blocking includes an implicit local_irq_enable(). */
    26.7 -		HYPERVISOR_sched_op(SCHEDOP_block, 0);
    26.8 +		HYPERVISOR_block();
    26.9  		start_hz_timer();
   26.10  		set_thread_flag(TIF_POLLING_NRFLAG);
   26.11  	}
    27.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/quirks-xen.c	Tue Apr 11 13:55:47 2006 -0600
    27.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/quirks-xen.c	Tue Apr 11 18:54:18 2006 -0600
    27.3 @@ -5,7 +5,7 @@
    27.4  #include <linux/pci.h>
    27.5  #include <linux/irq.h>
    27.6  
    27.7 -#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
    27.8 +#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_SMP) || defined(CONFIG_XEN)) && defined(CONFIG_PCI)
    27.9  
   27.10  static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
   27.11  {
    28.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Tue Apr 11 13:55:47 2006 -0600
    28.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Tue Apr 11 18:54:18 2006 -0600
    28.3 @@ -1317,6 +1317,11 @@ void __init setup_bootmem_allocator(void
    28.4  		}
    28.5  	}
    28.6  #endif
    28.7 +#ifdef CONFIG_KEXEC
    28.8 +	if (crashk_res.start != crashk_res.end)
    28.9 +		reserve_bootmem(crashk_res.start,
   28.10 +			crashk_res.end - crashk_res.start + 1);
   28.11 +#endif
   28.12  
   28.13  	if (!xen_feature(XENFEAT_auto_translated_physmap))
   28.14  		phys_to_machine_mapping =
   28.15 @@ -1436,11 +1441,6 @@ legacy_init_iomem_resources(struct resou
   28.16  		}
   28.17  	}
   28.18  #endif
   28.19 -#ifdef CONFIG_KEXEC
   28.20 -	if (crashk_res.start != crashk_res.end)
   28.21 -		reserve_bootmem(crashk_res.start,
   28.22 -			crashk_res.end - crashk_res.start + 1);
   28.23 -#endif
   28.24  }
   28.25  
   28.26  /*
   28.27 @@ -1633,9 +1633,9 @@ void __init setup_arch(char **cmdline_p)
   28.28  	physdev_op_t op;
   28.29  	unsigned long max_low_pfn;
   28.30  
   28.31 -	/* Force a quick death if the kernel panics. */
   28.32 +	/* Force a quick death if the kernel panics (not domain 0). */
   28.33  	extern int panic_timeout;
   28.34 -	if (panic_timeout == 0)
   28.35 +	if (!panic_timeout && !(xen_start_info->flags & SIF_INITDOMAIN))
   28.36  		panic_timeout = 1;
   28.37  
   28.38  	/* Register a call for panic conditions. */
   28.39 @@ -1848,10 +1848,6 @@ void __init setup_arch(char **cmdline_p)
   28.40  		get_smp_config();
   28.41  #endif
   28.42  
   28.43 -	/* XXX Disable irqdebug until we have a way to avoid interrupt
   28.44 -	 * conflicts. */
   28.45 -	noirqdebug_setup("");
   28.46 -
   28.47  	register_memory();
   28.48  
   28.49  	if (xen_start_info->flags & SIF_INITDOMAIN) {
   28.50 @@ -1877,7 +1873,7 @@ void __init setup_arch(char **cmdline_p)
   28.51  static int
   28.52  xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
   28.53  {
   28.54 -	HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
   28.55 +	HYPERVISOR_shutdown(SHUTDOWN_crash);
   28.56  	/* we're never actually going to get here... */
   28.57  	return NOTIFY_DONE;
   28.58  }
    29.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Tue Apr 11 13:55:47 2006 -0600
    29.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Tue Apr 11 18:54:18 2006 -0600
    29.3 @@ -32,7 +32,7 @@ EXPORT_SYMBOL(swiotlb);
    29.4  
    29.5  #define OFFSET(val,align) ((unsigned long)((val) & ( (align) - 1)))
    29.6  
    29.7 -#define SG_ENT_PHYS_ADDRESS(sg)	(page_to_phys((sg)->page) + (sg)->offset)
    29.8 +#define SG_ENT_PHYS_ADDRESS(sg)	(page_to_bus((sg)->page) + (sg)->offset)
    29.9  
   29.10  /*
   29.11   * Maximum allowable number of contiguous slabs to map,
   29.12 @@ -607,7 +607,7 @@ swiotlb_map_page(struct device *hwdev, s
   29.13  	dma_addr_t dev_addr;
   29.14  	char *map;
   29.15  
   29.16 -	dev_addr = page_to_phys(page) + offset;
   29.17 +	dev_addr = page_to_bus(page) + offset;
   29.18  	if (address_needs_mapping(hwdev, dev_addr)) {
   29.19  		buffer.page   = page;
   29.20  		buffer.offset = offset;
    30.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Tue Apr 11 13:55:47 2006 -0600
    30.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Tue Apr 11 18:54:18 2006 -0600
    30.3 @@ -177,6 +177,32 @@ int touch_pte_range(struct mm_struct *mm
    30.4  
    30.5  EXPORT_SYMBOL(touch_pte_range);
    30.6  
    30.7 +void *vm_map_xen_pages (unsigned long maddr, int vm_size, pgprot_t prot)
    30.8 +{
    30.9 +	int error;
   30.10 +       
   30.11 +	struct vm_struct *vma;
   30.12 +	vma = get_vm_area (vm_size, VM_IOREMAP);
   30.13 +      
   30.14 +	if (vma == NULL) {
   30.15 +		printk ("ioremap.c,vm_map_xen_pages(): "
   30.16 +			"Failed to get VMA area\n");
   30.17 +		return NULL;
   30.18 +	}
   30.19 +
   30.20 +	error = direct_kernel_remap_pfn_range((unsigned long) vma->addr,
   30.21 +					      maddr >> PAGE_SHIFT, vm_size,
   30.22 +					      prot, DOMID_SELF );
   30.23 +	if (error == 0) {
   30.24 +		return vma->addr;
   30.25 +	} else {
   30.26 +		printk ("ioremap.c,vm_map_xen_pages(): "
   30.27 +			"Failed to map xen shared pages into kernel space\n");
   30.28 +		return NULL;
   30.29 +	}
   30.30 +}
   30.31 +EXPORT_SYMBOL(vm_map_xen_pages);
   30.32 +
   30.33  /*
   30.34   * Does @address reside within a non-highmem page that is local to this virtual
   30.35   * machine (i.e., not an I/O page, nor a memory page belonging to another VM).
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/linux-2.6-xen-sparse/arch/i386/oprofile/Makefile	Tue Apr 11 18:54:18 2006 -0600
    31.3 @@ -0,0 +1,16 @@
    31.4 +obj-$(CONFIG_OPROFILE) += oprofile.o
    31.5 +
    31.6 +DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
    31.7 +		oprof.o cpu_buffer.o buffer_sync.o \
    31.8 +		event_buffer.o oprofile_files.o \
    31.9 +		oprofilefs.o oprofile_stats.o  \
   31.10 +		timer_int.o )
   31.11 +
   31.12 +ifdef CONFIG_XEN
   31.13 +oprofile-y				:= $(DRIVER_OBJS) xenoprof.o
   31.14 +else 
   31.15 +oprofile-y				:= $(DRIVER_OBJS) init.o backtrace.o
   31.16 +oprofile-$(CONFIG_X86_LOCAL_APIC) 	+= nmi_int.o op_model_athlon.o \
   31.17 +					   op_model_ppro.o op_model_p4.o
   31.18 +oprofile-$(CONFIG_X86_IO_APIC)		+= nmi_timer_int.o
   31.19 +endif
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Tue Apr 11 18:54:18 2006 -0600
    32.3 @@ -0,0 +1,395 @@
    32.4 +/**
    32.5 + * @file xenoprof.c
    32.6 + *
    32.7 + * @remark Copyright 2002 OProfile authors
    32.8 + * @remark Read the file COPYING
    32.9 + *
   32.10 + * @author John Levon <levon@movementarian.org>
   32.11 + *
   32.12 + * Modified by Aravind Menon and Jose Renato Santos for Xen
   32.13 + * These modifications are:
   32.14 + * Copyright (C) 2005 Hewlett-Packard Co.
   32.15 + */
   32.16 +
   32.17 +#include <linux/init.h>
   32.18 +#include <linux/notifier.h>
   32.19 +#include <linux/smp.h>
   32.20 +#include <linux/oprofile.h>
   32.21 +#include <linux/sysdev.h>
   32.22 +#include <linux/slab.h>
   32.23 +#include <linux/interrupt.h>
   32.24 +#include <linux/vmalloc.h>
   32.25 +#include <asm/nmi.h>
   32.26 +#include <asm/msr.h>
   32.27 +#include <asm/apic.h>
   32.28 +#include <asm/pgtable.h>
   32.29 +#include <xen/evtchn.h>
   32.30 +#include "op_counter.h"
   32.31 +
   32.32 +#include <xen/interface/xen.h>
   32.33 +#include <xen/interface/xenoprof.h>
   32.34 +
   32.35 +static int xenoprof_start(void);
   32.36 +static void xenoprof_stop(void);
   32.37 +
   32.38 +void * vm_map_xen_pages(unsigned long maddr, int vm_size, pgprot_t prot);
   32.39 +
   32.40 +static int xenoprof_enabled = 0;
   32.41 +static int num_events = 0;
   32.42 +static int is_primary = 0;
   32.43 +
   32.44 +/* sample buffers shared with Xen */
   32.45 +xenoprof_buf_t * xenoprof_buf[MAX_VIRT_CPUS];
   32.46 +/* Shared buffer area */
   32.47 +char * shared_buffer;
   32.48 +/* Number of buffers in shared area (one per VCPU) */
   32.49 +int nbuf;
   32.50 +/* Mappings of VIRQ_XENOPROF to irq number (per cpu) */
   32.51 +int ovf_irq[NR_CPUS];
   32.52 +/* cpu model type string - copied from Xen memory space on XENOPROF_init command */
   32.53 +char cpu_type[XENOPROF_CPU_TYPE_SIZE];
   32.54 +
   32.55 +#ifdef CONFIG_PM
   32.56 +
   32.57 +static int xenoprof_suspend(struct sys_device * dev, pm_message_t state)
   32.58 +{
   32.59 +	if (xenoprof_enabled == 1)
   32.60 +		xenoprof_stop();
   32.61 +	return 0;
   32.62 +}
   32.63 +
   32.64 +
   32.65 +static int xenoprof_resume(struct sys_device * dev)
   32.66 +{
   32.67 +	if (xenoprof_enabled == 1)
   32.68 +		xenoprof_start();
   32.69 +	return 0;
   32.70 +}
   32.71 +
   32.72 +
   32.73 +static struct sysdev_class oprofile_sysclass = {
   32.74 +	set_kset_name("oprofile"),
   32.75 +	.resume		= xenoprof_resume,
   32.76 +	.suspend	= xenoprof_suspend
   32.77 +};
   32.78 +
   32.79 +
   32.80 +static struct sys_device device_oprofile = {
   32.81 +	.id	= 0,
   32.82 +	.cls	= &oprofile_sysclass,
   32.83 +};
   32.84 +
   32.85 +
   32.86 +static int __init init_driverfs(void)
   32.87 +{
   32.88 +	int error;
   32.89 +	if (!(error = sysdev_class_register(&oprofile_sysclass)))
   32.90 +		error = sysdev_register(&device_oprofile);
   32.91 +	return error;
   32.92 +}
   32.93 +
   32.94 +
   32.95 +static void __exit exit_driverfs(void)
   32.96 +{
   32.97 +	sysdev_unregister(&device_oprofile);
   32.98 +	sysdev_class_unregister(&oprofile_sysclass);
   32.99 +}
  32.100 +
  32.101 +#else
  32.102 +#define init_driverfs() do { } while (0)
  32.103 +#define exit_driverfs() do { } while (0)
  32.104 +#endif /* CONFIG_PM */
  32.105 +
  32.106 +unsigned long long oprofile_samples = 0;
  32.107 +
  32.108 +static irqreturn_t 
  32.109 +xenoprof_ovf_interrupt(int irq, void * dev_id, struct pt_regs * regs)
  32.110 +{
  32.111 +	int head, tail, size;
  32.112 +	xenoprof_buf_t * buf;
  32.113 +	int cpu;
  32.114 +
  32.115 +	cpu = smp_processor_id();
  32.116 +	buf = xenoprof_buf[cpu];
  32.117 +
  32.118 +	head = buf->event_head;
  32.119 +	tail = buf->event_tail;
  32.120 +	size = buf->event_size;
  32.121 +
  32.122 +	if (tail > head) {
  32.123 +		while (tail < size) {
  32.124 +			oprofile_add_pc(buf->event_log[tail].eip,
  32.125 +					buf->event_log[tail].mode,
  32.126 +					buf->event_log[tail].event);
  32.127 +			oprofile_samples++;
  32.128 +			tail++;
  32.129 +		}
  32.130 +		tail = 0;
  32.131 +	}
  32.132 +	while (tail < head) {
  32.133 +		oprofile_add_pc(buf->event_log[tail].eip,
  32.134 +				buf->event_log[tail].mode,
  32.135 +				buf->event_log[tail].event);
  32.136 +		oprofile_samples++;
  32.137 +		tail++;
  32.138 +	}
  32.139 +
  32.140 +	buf->event_tail = tail;
  32.141 +
  32.142 +	return IRQ_HANDLED;
  32.143 +}
  32.144 +
  32.145 +
  32.146 +static void unbind_virq_cpu(void * info)
  32.147 +{
  32.148 +	int cpu = smp_processor_id();
  32.149 +	if (ovf_irq[cpu] >= 0) {
  32.150 +		unbind_from_irqhandler(ovf_irq[cpu], NULL);
  32.151 +		ovf_irq[cpu] = -1;
  32.152 +	}
  32.153 +}
  32.154 +
  32.155 +
  32.156 +static void unbind_virq(void)
  32.157 +{
  32.158 +	on_each_cpu(unbind_virq_cpu, NULL, 0, 1);
  32.159 +}
  32.160 +
  32.161 +
  32.162 +int bind_virq_error;
  32.163 +
  32.164 +static void bind_virq_cpu(void * info)
  32.165 +{
  32.166 +	int result;
  32.167 +	int cpu = smp_processor_id();
  32.168 +
  32.169 +	result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
  32.170 +					 cpu,
  32.171 +					 xenoprof_ovf_interrupt,
  32.172 +					 SA_INTERRUPT,
  32.173 +					 "xenoprof",
  32.174 +					 NULL);
  32.175 +
  32.176 +	if (result<0) {
  32.177 +		bind_virq_error = result;
  32.178 +		printk("xenoprof.c: binding VIRQ_XENOPROF to IRQ failed on CPU "
  32.179 +		       "%d\n", cpu);
  32.180 +	} else {
  32.181 +		ovf_irq[cpu] = result;
  32.182 +	}
  32.183 +}
  32.184 +
  32.185 +
  32.186 +static int bind_virq(void)
  32.187 +{
  32.188 +	bind_virq_error = 0;
  32.189 +	on_each_cpu(bind_virq_cpu, NULL, 0, 1);
  32.190 +	if (bind_virq_error) {
  32.191 +		unbind_virq();
  32.192 +		return bind_virq_error;
  32.193 +	} else {
  32.194 +		return 0;
  32.195 +	}
  32.196 +}
  32.197 +
  32.198 +
  32.199 +static int xenoprof_setup(void)
  32.200 +{
  32.201 +	int ret;
  32.202 +
  32.203 +	ret = bind_virq();
  32.204 +	if (ret)
  32.205 +		return ret;
  32.206 +
  32.207 +	if (is_primary) {
  32.208 +		ret = HYPERVISOR_xenoprof_op(XENOPROF_reserve_counters,
  32.209 +					     (unsigned long)NULL,
  32.210 +					     (unsigned long)NULL);
  32.211 +		if (ret)
  32.212 +			goto err;
  32.213 +
  32.214 +		ret = HYPERVISOR_xenoprof_op(XENOPROF_setup_events,
  32.215 +					     (unsigned long)&counter_config,
  32.216 +					     (unsigned long)num_events);
  32.217 +		if (ret)
  32.218 +			goto err;
  32.219 +	}
  32.220 +
  32.221 +	ret = HYPERVISOR_xenoprof_op(XENOPROF_enable_virq,
  32.222 +				     (unsigned long)NULL,
  32.223 +				     (unsigned long)NULL);
  32.224 +	if (ret)
  32.225 +		goto err;
  32.226 +
  32.227 +	xenoprof_enabled = 1;
  32.228 +	return 0;
  32.229 + err:
  32.230 +	unbind_virq();
  32.231 +	return ret;
  32.232 +}
  32.233 +
  32.234 +
  32.235 +static void xenoprof_shutdown(void)
  32.236 +{
  32.237 +	xenoprof_enabled = 0;
  32.238 +
  32.239 +	HYPERVISOR_xenoprof_op(XENOPROF_disable_virq,
  32.240 +			       (unsigned long)NULL,
  32.241 +			       (unsigned long)NULL);
  32.242 +
  32.243 +	if (is_primary) {
  32.244 +		HYPERVISOR_xenoprof_op(XENOPROF_release_counters,
  32.245 +				       (unsigned long)NULL,
  32.246 +				       (unsigned long)NULL);
  32.247 +	}
  32.248 +
  32.249 +	unbind_virq();
  32.250 +}
  32.251 +
  32.252 +
  32.253 +static int xenoprof_start(void)
  32.254 +{
  32.255 +	int ret = 0;
  32.256 +
  32.257 +	if (is_primary)
  32.258 +		ret = HYPERVISOR_xenoprof_op(XENOPROF_start,
  32.259 +					     (unsigned long)NULL,
  32.260 +					     (unsigned long)NULL);
  32.261 +	return ret;
  32.262 +}
  32.263 +
  32.264 +
  32.265 +static void xenoprof_stop(void)
  32.266 +{
  32.267 +	if (is_primary)
  32.268 +		HYPERVISOR_xenoprof_op(XENOPROF_stop,
  32.269 +				       (unsigned long)NULL,
  32.270 +				       (unsigned long)NULL);
  32.271 +}
  32.272 +
  32.273 +
  32.274 +static int xenoprof_set_active(int * active_domains,
  32.275 +			  unsigned int adomains)
  32.276 +{
  32.277 +	int ret = 0;
  32.278 +	if (is_primary)
  32.279 +		ret = HYPERVISOR_xenoprof_op(XENOPROF_set_active,
  32.280 +					     (unsigned long)active_domains,
  32.281 +					     (unsigned long)adomains);
  32.282 +	return ret;
  32.283 +}
  32.284 +
  32.285 +
  32.286 +struct op_counter_config counter_config[OP_MAX_COUNTER];
  32.287 +
  32.288 +static int xenoprof_create_files(struct super_block * sb, struct dentry * root)
  32.289 +{
  32.290 +	unsigned int i;
  32.291 +
  32.292 +	for (i = 0; i < num_events; ++i) {
  32.293 +		struct dentry * dir;
  32.294 +		char buf[2];
  32.295 + 
  32.296 +		snprintf(buf, 2, "%d", i);
  32.297 +		dir = oprofilefs_mkdir(sb, root, buf);
  32.298 +		oprofilefs_create_ulong(sb, dir, "enabled",
  32.299 +					&counter_config[i].enabled);
  32.300 +		oprofilefs_create_ulong(sb, dir, "event",
  32.301 +					&counter_config[i].event);
  32.302 +		oprofilefs_create_ulong(sb, dir, "count",
  32.303 +					&counter_config[i].count);
  32.304 +		oprofilefs_create_ulong(sb, dir, "unit_mask",
  32.305 +					&counter_config[i].unit_mask);
  32.306 +		oprofilefs_create_ulong(sb, dir, "kernel",
  32.307 +					&counter_config[i].kernel);
  32.308 +		oprofilefs_create_ulong(sb, dir, "user",
  32.309 +					&counter_config[i].user);
  32.310 +	}
  32.311 +
  32.312 +	return 0;
  32.313 +}
  32.314 +
  32.315 +
  32.316 +struct oprofile_operations xenoprof_ops = {
  32.317 +	.create_files 	= xenoprof_create_files,
  32.318 +	.set_active	= xenoprof_set_active,
  32.319 +	.setup 		= xenoprof_setup,
  32.320 +	.shutdown	= xenoprof_shutdown,
  32.321 +	.start		= xenoprof_start,
  32.322 +	.stop		= xenoprof_stop
  32.323 +};
  32.324 +
  32.325 +
  32.326 +/* in order to get driverfs right */
  32.327 +static int using_xenoprof;
  32.328 +
  32.329 +int __init oprofile_arch_init(struct oprofile_operations * ops)
  32.330 +{
  32.331 +	xenoprof_init_result_t result;
  32.332 +	xenoprof_buf_t * buf;
  32.333 +	int max_samples = 16;
  32.334 +	int vm_size;
  32.335 +	int npages;
  32.336 +	int i;
  32.337 +
  32.338 +	int ret = HYPERVISOR_xenoprof_op(XENOPROF_init,
  32.339 +					 (unsigned long)max_samples,
  32.340 +					 (unsigned long)&result);
  32.341 +
  32.342 +	if (!ret) {
  32.343 +		pgprot_t prot = __pgprot(_KERNPG_TABLE);
  32.344 +
  32.345 +		num_events = result.num_events;
  32.346 +		is_primary = result.is_primary;
  32.347 +		nbuf = result.nbuf;
  32.348 +
  32.349 +		npages = (result.bufsize * nbuf - 1) / PAGE_SIZE + 1;
  32.350 +		vm_size = npages * PAGE_SIZE;
  32.351 +
  32.352 +		shared_buffer = (char *) vm_map_xen_pages(result.buf_maddr,
  32.353 +							  vm_size, prot);
  32.354 +		if (!shared_buffer) {
  32.355 +			ret = -ENOMEM;
  32.356 +			goto out;
  32.357 +		}
  32.358 +
  32.359 +		for (i=0; i< nbuf; i++) {
  32.360 +			buf = (xenoprof_buf_t*) 
  32.361 +				&shared_buffer[i * result.bufsize];
  32.362 +			BUG_ON(buf->vcpu_id >= MAX_VIRT_CPUS);
  32.363 +			xenoprof_buf[buf->vcpu_id] = buf;
  32.364 +		}
  32.365 +
  32.366 +		/*  cpu_type is detected by Xen */
  32.367 +		cpu_type[XENOPROF_CPU_TYPE_SIZE-1] = 0;
  32.368 +		strncpy(cpu_type, result.cpu_type, XENOPROF_CPU_TYPE_SIZE - 1);
  32.369 +		xenoprof_ops.cpu_type = cpu_type;
  32.370 +
  32.371 +		init_driverfs();
  32.372 +		using_xenoprof = 1;
  32.373 +		*ops = xenoprof_ops;
  32.374 +
  32.375 +		for (i=0; i<NR_CPUS; i++)
  32.376 +			ovf_irq[i] = -1;
  32.377 +	}
  32.378 + out:
  32.379 +	printk(KERN_INFO "oprofile_arch_init: ret %d, events %d, "
  32.380 +	       "is_primary %d\n", ret, num_events, is_primary);
  32.381 +	return ret;
  32.382 +}
  32.383 +
  32.384 +
  32.385 +void __exit oprofile_arch_exit(void)
  32.386 +{
  32.387 +	if (using_xenoprof)
  32.388 +		exit_driverfs();
  32.389 +
  32.390 +	if (shared_buffer) {
  32.391 +		vunmap(shared_buffer);
  32.392 +		shared_buffer = NULL;
  32.393 +	}
  32.394 +	if (is_primary)
  32.395 +		HYPERVISOR_xenoprof_op(XENOPROF_shutdown,
  32.396 +				       (unsigned long)NULL,
  32.397 +				       (unsigned long)NULL);
  32.398 +}
    33.1 --- a/linux-2.6-xen-sparse/arch/ia64/Kconfig	Tue Apr 11 13:55:47 2006 -0600
    33.2 +++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig	Tue Apr 11 18:54:18 2006 -0600
    33.3 @@ -79,8 +79,13 @@ config XEN_BLKDEV_FRONTEND
    33.4  	bool
    33.5  	default y
    33.6  
    33.7 +config XEN_BACKEND
    33.8 +	depends on XEN
    33.9 +	bool
   33.10 +	default y
   33.11 +
   33.12  config XEN_BLKDEV_BACKEND
   33.13 -	depends on XEN
   33.14 +	depends on XEN && XEN_BACKEND
   33.15  	bool
   33.16  	default y
   33.17  
   33.18 @@ -91,6 +96,11 @@ config XEN_SYSFS
   33.19  	help
   33.20  		Xen hypervisor attributes will show up under /sys/hypervisor/.
   33.21  
   33.22 +config XEN_INTERFACE_VERSION
   33.23 +	hex
   33.24 +	depends on XEN
   33.25 +	default 0x00030101
   33.26 +
   33.27  config SCHED_NO_NO_OMIT_FRAME_POINTER
   33.28  	bool
   33.29  	default y
    34.1 --- a/linux-2.6-xen-sparse/arch/ia64/Makefile	Tue Apr 11 13:55:47 2006 -0600
    34.2 +++ b/linux-2.6-xen-sparse/arch/ia64/Makefile	Tue Apr 11 18:54:18 2006 -0600
    34.3 @@ -42,6 +42,12 @@ ifeq ($(call cc-version),0304)
    34.4  endif
    34.5  
    34.6  CFLAGS += $(cflags-y)
    34.7 +
    34.8 +cppflags-$(CONFIG_XEN) += \
    34.9 +	-D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
   34.10 +
   34.11 +CPPFLAGS += $(cppflags-y)
   34.12 +
   34.13  head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
   34.14  
   34.15  libs-y				+= arch/ia64/lib/
    35.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/coreMakefile	Tue Apr 11 13:55:47 2006 -0600
    35.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/coreMakefile	Tue Apr 11 18:54:18 2006 -0600
    35.3 @@ -10,7 +10,7 @@ CPPFLAGS_vmlinux.lds += -U$(XENARCH)
    35.4  	@ln -fsn $(srctree)/arch/$(XENARCH)/kernel/vmlinux.lds.S $@
    35.5  
    35.6  
    35.7 -obj-y   := gnttab.o
    35.8 +obj-y   := gnttab.o features.o
    35.9  obj-$(CONFIG_PROC_FS) += xen_proc.o
   35.10  
   35.11  ifeq ($(ARCH),ia64)
    36.1 --- a/linux-2.6-xen-sparse/arch/x86_64/Makefile	Tue Apr 11 13:55:47 2006 -0600
    36.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/Makefile	Tue Apr 11 18:54:18 2006 -0600
    36.3 @@ -31,6 +31,10 @@ cflags-$(CONFIG_MK8) += $(call cc-option
    36.4  cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
    36.5  CFLAGS += $(cflags-y)
    36.6  
    36.7 +cppflags-$(CONFIG_XEN) += \
    36.8 +	-D__XEN_INTERFACE_VERSION__=$(CONFIG_XEN_INTERFACE_VERSION)
    36.9 +CPPFLAGS += $(cppflags-y)
   36.10 +
   36.11  CFLAGS += -m64
   36.12  CFLAGS += -mno-red-zone
   36.13  CFLAGS += -mcmodel=kernel
   36.14 @@ -71,7 +75,7 @@ boot := arch/x86_64/boot
   36.15  	fdimage fdimage144 fdimage288 archclean
   36.16  
   36.17  ifdef CONFIG_XEN
   36.18 -CPPFLAGS := -D__KERNEL__ -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(LINUXINCLUDE)
   36.19 +CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS)
   36.20  head-y := arch/x86_64/kernel/head-xen.o arch/x86_64/kernel/head64-xen.o arch/x86_64/kernel/init_task.o
   36.21  LDFLAGS_vmlinux := -e _start
   36.22  boot := arch/i386/boot-xen
    37.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Tue Apr 11 13:55:47 2006 -0600
    37.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Tue Apr 11 18:54:18 2006 -0600
    37.3 @@ -520,13 +520,13 @@ retint_check:
    37.4  	CFI_REMEMBER_STATE
    37.5  	jnz  retint_careful
    37.6  retint_restore_args:
    37.7 -        movb EVENT_MASK-REST_SKIP(%rsp), %al
    37.8 -        notb %al			# %al == ~saved_mask
    37.9 -        XEN_GET_VCPU_INFO(%rsi)
   37.10 -        andb evtchn_upcall_mask(%rsi),%al
   37.11 -	andb $1,%al			# %al == mask & ~saved_mask
   37.12 -	jnz restore_all_enable_events	# != 0 => reenable event delivery      
   37.13 -        XEN_PUT_VCPU_INFO(%rsi)
   37.14 +	movl EFLAGS-REST_SKIP(%rsp), %eax
   37.15 +	shr $9, %eax			# EAX[0] == IRET_EFLAGS.IF
   37.16 +	XEN_GET_VCPU_INFO(%rsi)
   37.17 +	andb evtchn_upcall_mask(%rsi),%al
   37.18 +	andb $1,%al			# EAX[0] == IRET_EFLAGS.IF & event_mask
   37.19 +	jnz restore_all_enable_events	#        != 0 => enable event delivery
   37.20 +	XEN_PUT_VCPU_INFO(%rsi)
   37.21  		
   37.22  	RESTORE_ARGS 0,8,0
   37.23  	HYPERVISOR_IRET 0
   37.24 @@ -584,7 +584,7 @@ retint_kernel:
   37.25   */		
   37.26  	.macro apicinterrupt num,func
   37.27  	INTR_FRAME
   37.28 -	pushq 0x8000000000000000+$\num
   37.29 +	pushq $~(\num)
   37.30  	CFI_ADJUST_CFA_OFFSET 8
   37.31  	interrupt \func
   37.32  	jmp error_entry
   37.33 @@ -803,12 +803,11 @@ ENTRY(hypervisor_callback)
   37.34  # So, on entry to the handler we detect whether we interrupted an
   37.35  # existing activation in its critical region -- if so, we pop the current
   37.36  # activation and restart the handler using the previous one.
   37.37 -ENTRY(do_hypervisor_callback)   # do_hyperviosr_callback(struct *pt_regs)
   37.38 +ENTRY(do_hypervisor_callback)   # do_hypervisor_callback(struct *pt_regs)
   37.39  # Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
   37.40  # see the correct pointer to the pt_regs
   37.41  	movq %rdi, %rsp            # we don't return, adjust the stack frame
   37.42 -11:	movb $0, EVENT_MASK(%rdi)
   37.43 -	movq %gs:pda_irqstackptr,%rax
   37.44 +11:	movq %gs:pda_irqstackptr,%rax
   37.45  	incl %gs:pda_irqcount
   37.46  	cmovzq %rax,%rsp
   37.47  	pushq %rdi
   37.48 @@ -853,15 +852,44 @@ ecrit:  /**** END OF CRITICAL REGION ***
   37.49  # When the kernel is interrupted in the critical section, the kernel 
   37.50  # will do IRET in that case, and everything will be restored at that point, 
   37.51  # i.e. it just resumes from the next instruction interrupted with the same context. 
   37.52 -	
   37.53 +
   37.54  # Hypervisor uses this for application faults while it executes.
   37.55 -# Unlike i386 there is no need to reload the saved segment selectors:
   37.56 -# Xen already reloaded all valid ones and zeroed the others.
   37.57 +# We get here for two reasons:
   37.58 +#  1. Fault while reloading DS, ES, FS or GS
   37.59 +#  2. Fault while executing IRET
   37.60 +# Category 1 we do not need to fix up as Xen has already reloaded all segment
   37.61 +# registers that could be reloaded and zeroed the others.
   37.62 +# Category 2 we fix up by killing the current process. We cannot use the
   37.63 +# normal Linux return path in this case because if we use the IRET hypercall
   37.64 +# to pop the stack frame we end up in an infinite loop of failsafe callbacks.
   37.65 +# We distinguish between categories by comparing each saved segment register
   37.66 +# with its current contents: any discrepancy means we in category 1.
   37.67  ENTRY(failsafe_callback)
   37.68 -	addq $0x30,%rsp /* skip %rcx,%r11,%ds,%es,%fs,%gs */
   37.69 +	movw %ds,%cx
   37.70 +	cmpw %cx,0x10(%rsp)
   37.71 +	jne 1f
   37.72 +	movw %es,%cx
   37.73 +	cmpw %cx,0x18(%rsp)
   37.74 +	jne 1f
   37.75 +	movw %fs,%cx
   37.76 +	cmpw %cx,0x20(%rsp)
   37.77 +	jne 1f
   37.78 +	movw %gs,%cx
   37.79 +	cmpw %cx,0x28(%rsp)
   37.80 +	jne 1f
   37.81 +	/* All segments match their saved values => Category 2 (Bad IRET). */
   37.82 +	movq (%rsp),%rcx
   37.83 +	movq 8(%rsp),%r11
   37.84 +	addq $0x30,%rsp
   37.85 +	movq $-9999,%rdi	/* better code? */
   37.86 +	jmp do_exit			
   37.87 +1:	/* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */
   37.88 +	movq (%rsp),%rcx
   37.89 +	movq 8(%rsp),%r11
   37.90 +	addq $0x30,%rsp
   37.91 +	pushq $0
   37.92  	SAVE_ALL
   37.93 -	jmp  error_exit
   37.94 - 
   37.95 +	jmp error_exit
   37.96  #if 0	      
   37.97          .section __ex_table,"a"
   37.98          .align 8
    38.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/irq-xen.c	Tue Apr 11 13:55:47 2006 -0600
    38.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/irq-xen.c	Tue Apr 11 18:54:18 2006 -0600
    38.3 @@ -97,7 +97,7 @@ skip:
    38.4  asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
    38.5  {	
    38.6  	/* high bit used in ret_from_ code  */
    38.7 -        int irq = regs->orig_rax & __IRQ_MASK(BITS_PER_LONG - 1);
    38.8 +	unsigned irq = ~regs->orig_rax;
    38.9  
   38.10  	exit_idle();
   38.11  	irq_enter();
    39.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Tue Apr 11 13:55:47 2006 -0600
    39.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Tue Apr 11 18:54:18 2006 -0600
    39.3 @@ -131,7 +131,7 @@ void xen_idle(void)
    39.4  		smp_mb__after_clear_bit();
    39.5  		stop_hz_timer();
    39.6  		/* Blocking includes an implicit local_irq_enable(). */
    39.7 -		HYPERVISOR_sched_op(SCHEDOP_block, 0);
    39.8 +		HYPERVISOR_block();
    39.9  		start_hz_timer();
   39.10  		set_thread_flag(TIF_POLLING_NRFLAG);
   39.11  	}
    40.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c	Tue Apr 11 13:55:47 2006 -0600
    40.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c	Tue Apr 11 18:54:18 2006 -0600
    40.3 @@ -999,7 +999,7 @@ void __init setup_arch(char **cmdline_p)
    40.4  static int
    40.5  xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
    40.6  {
    40.7 -	HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
    40.8 +	HYPERVISOR_shutdown(SHUTDOWN_crash);
    40.9  	/* we're never actually going to get here... */
   40.10  	return NOTIFY_DONE;
   40.11  }
    41.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/xen_entry.S	Tue Apr 11 13:55:47 2006 -0600
    41.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/xen_entry.S	Tue Apr 11 18:54:18 2006 -0600
    41.3 @@ -2,7 +2,7 @@
    41.4   * Copied from arch/xen/i386/kernel/entry.S
    41.5   */                        
    41.6  /* Offsets into shared_info_t. */                
    41.7 -#define evtchn_upcall_pending		0
    41.8 +#define evtchn_upcall_pending		/* 0 */
    41.9  #define evtchn_upcall_mask		1
   41.10  
   41.11  #define sizeof_vcpu_shift		6
   41.12 @@ -35,7 +35,6 @@
   41.13      				XEN_PUT_VCPU_INFO(reg)
   41.14  #define XEN_TEST_PENDING(reg)	testb $0xFF,evtchn_upcall_pending(reg)
   41.15  
   41.16 -EVENT_MASK      = (CS+4)
   41.17  VGCF_IN_SYSCALL = (1<<8)
   41.18          
   41.19  	
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/oprofile/Makefile	Tue Apr 11 18:54:18 2006 -0600
    42.3 @@ -0,0 +1,22 @@
    42.4 +#
    42.5 +# oprofile for x86-64.
    42.6 +# Just reuse the one from i386. 
    42.7 +#
    42.8 +
    42.9 +obj-$(CONFIG_OPROFILE) += oprofile.o
   42.10 + 
   42.11 +DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
   42.12 +	oprof.o cpu_buffer.o buffer_sync.o \
   42.13 +	event_buffer.o oprofile_files.o \
   42.14 +	oprofilefs.o oprofile_stats.o \
   42.15 +	timer_int.o )
   42.16 +
   42.17 +ifdef CONFIG_XEN
   42.18 +OPROFILE-y := xenoprof.o
   42.19 +else
   42.20 +OPROFILE-y := init.o backtrace.o
   42.21 +OPROFILE-$(CONFIG_X86_LOCAL_APIC) += nmi_int.o op_model_athlon.o op_model_p4.o \
   42.22 +				     op_model_ppro.o
   42.23 +OPROFILE-$(CONFIG_X86_IO_APIC)    += nmi_timer_int.o 
   42.24 +endif
   42.25 +oprofile-y = $(DRIVER_OBJS) $(addprefix ../../i386/oprofile/, $(OPROFILE-y))
    43.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Apr 11 13:55:47 2006 -0600
    43.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Tue Apr 11 18:54:18 2006 -0600
    43.3 @@ -10,12 +10,11 @@ config XEN
    43.4  	help
    43.5  	  This is the Linux Xen port.
    43.6  
    43.7 -config NO_IDLE_HZ
    43.8 -	bool
    43.9 -	depends on XEN
   43.10 -	default y
   43.11 +if XEN
   43.12 +config XEN_INTERFACE_VERSION
   43.13 +	hex
   43.14 +	default 0x00030101
   43.15  
   43.16 -if XEN
   43.17  menu "XEN"
   43.18  
   43.19  config XEN_PRIVILEGED_GUEST
   43.20 @@ -29,9 +28,16 @@ config XEN_UNPRIVILEGED_GUEST
   43.21  	bool
   43.22  	default !XEN_PRIVILEGED_GUEST
   43.23  
   43.24 +config XEN_BACKEND
   43.25 +        tristate "Backend driver support"
   43.26 +        default y
   43.27 +        help
   43.28 +          Support for backend device drivers that provide I/O services
   43.29 +          to other virtual machines.
   43.30 +
   43.31  config XEN_PCIDEV_BACKEND
   43.32  	tristate "PCI device backend driver"
   43.33 -	depends PCI
   43.34 +	depends on PCI && XEN_BACKEND
   43.35  	default XEN_PRIVILEGED_GUEST
   43.36  	help
   43.37  	  The PCI device backend driver allows the kernel to export arbitrary
   43.38 @@ -71,6 +77,7 @@ config XEN_PCIDEV_BE_DEBUG
   43.39  
   43.40  config XEN_BLKDEV_BACKEND
   43.41  	tristate "Block-device backend driver"
   43.42 +        depends on XEN_BACKEND
   43.43  	default y
   43.44  	help
   43.45  	  The block-device backend driver allows the kernel to export its
   43.46 @@ -92,6 +99,7 @@ config XEN_BLKDEV_TAP_BE
   43.47  
   43.48  config XEN_NETDEV_BACKEND
   43.49  	tristate "Network-device backend driver"
   43.50 +        depends on XEN_BACKEND
   43.51  	default y
   43.52  	help
   43.53  	  The network-device backend driver allows the kernel to export its
   43.54 @@ -121,6 +129,7 @@ config XEN_NETDEV_LOOPBACK
   43.55  
   43.56  config XEN_TPMDEV_BACKEND
   43.57  	tristate "TPM-device backend driver"
   43.58 +        depends on XEN_BACKEND
   43.59  	default n
   43.60  	help
   43.61  	  The TPM-device backend driver
   43.62 @@ -156,6 +165,7 @@ config XEN_NETDEV_FRONTEND
   43.63  
   43.64  config XEN_BLKDEV_TAP
   43.65  	tristate "Block device tap driver"
   43.66 +        depends on XEN_BACKEND
   43.67  	default n
   43.68  	help
   43.69  	  This driver allows a VM to interact on block device channels
   43.70 @@ -191,7 +201,6 @@ config XEN_DISABLE_SERIAL
   43.71  
   43.72  config XEN_SYSFS
   43.73  	tristate "Export Xen attributes in sysfs"
   43.74 -	depends on XEN
   43.75  	depends on SYSFS
   43.76  	default y
   43.77  	help
   43.78 @@ -207,4 +216,8 @@ config HAVE_ARCH_DEV_ALLOC_SKB
   43.79  	bool
   43.80  	default y
   43.81  
   43.82 +config NO_IDLE_HZ
   43.83 +	bool
   43.84 +	default y
   43.85 +
   43.86  endif
    44.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Apr 11 13:55:47 2006 -0600
    44.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Apr 11 18:54:18 2006 -0600
    44.3 @@ -215,52 +215,26 @@ static void print_stats(blkif_t *blkif)
    44.4  
    44.5  int blkif_schedule(void *arg)
    44.6  {
    44.7 -	blkif_t          *blkif = arg;
    44.8 +	blkif_t *blkif = arg;
    44.9  
   44.10  	blkif_get(blkif);
   44.11 +
   44.12  	if (debug_lvl)
   44.13  		printk(KERN_DEBUG "%s: started\n", current->comm);
   44.14 -	for (;;) {
   44.15 -		if (kthread_should_stop()) {
   44.16 -			/* asked to quit? */
   44.17 -			if (!atomic_read(&blkif->io_pending))
   44.18 -				break;
   44.19 -			if (debug_lvl)
   44.20 -				printk(KERN_DEBUG "%s: I/O pending, "
   44.21 -				       "delaying exit\n", current->comm);
   44.22 -		}
   44.23  
   44.24 -		if (!atomic_read(&blkif->io_pending)) {
   44.25 -			/* Wait for work to do. */
   44.26 -			wait_event_interruptible(
   44.27 -				blkif->wq,
   44.28 -				(atomic_read(&blkif->io_pending) ||
   44.29 -				 kthread_should_stop()));
   44.30 -		} else if (list_empty(&pending_free)) {
   44.31 -			/* Wait for pending_req becoming available. */
   44.32 -			wait_event_interruptible(
   44.33 -				pending_free_wq,
   44.34 -				!list_empty(&pending_free));
   44.35 -		}
   44.36 +	while (!kthread_should_stop()) {
   44.37 +		wait_event_interruptible(
   44.38 +			blkif->wq,
   44.39 +			blkif->waiting_reqs || kthread_should_stop());
   44.40 +		wait_event_interruptible(
   44.41 +			pending_free_wq,
   44.42 +			!list_empty(&pending_free) || kthread_should_stop());
   44.43  
   44.44 -		if (blkif->status != CONNECTED) {
   44.45 -			/* make sure we are connected */
   44.46 -			if (debug_lvl)
   44.47 -				printk(KERN_DEBUG "%s: not connected "
   44.48 -				       "(%d pending)\n",
   44.49 -				       current->comm,
   44.50 -				       atomic_read(&blkif->io_pending));
   44.51 -			wait_event_interruptible(
   44.52 -				blkif->wq,
   44.53 -				(blkif->status == CONNECTED ||
   44.54 -				 kthread_should_stop()));
   44.55 -			continue;
   44.56 -		}
   44.57 +		blkif->waiting_reqs = 0;
   44.58 +		smp_mb(); /* clear flag *before* checking for work */
   44.59  
   44.60 -		/* Schedule I/O */
   44.61 -		atomic_set(&blkif->io_pending, 0);
   44.62  		if (do_block_io_op(blkif))
   44.63 -			atomic_inc(&blkif->io_pending);
   44.64 +			blkif->waiting_reqs = 1;
   44.65  		unplug_queue(blkif);
   44.66  
   44.67  		if (log_stats && time_after(jiffies, blkif->st_print))
   44.68 @@ -271,8 +245,10 @@ int blkif_schedule(void *arg)
   44.69  		print_stats(blkif);
   44.70  	if (debug_lvl)
   44.71  		printk(KERN_DEBUG "%s: exiting\n", current->comm);
   44.72 +
   44.73  	blkif->xenblkd = NULL;
   44.74  	blkif_put(blkif);
   44.75 +
   44.76  	return 0;
   44.77  }
   44.78  
   44.79 @@ -311,12 +287,15 @@ static int end_block_io_op(struct bio *b
   44.80   * NOTIFICATION FROM GUEST OS.
   44.81   */
   44.82  
   44.83 +static void blkif_notify_work(blkif_t *blkif)
   44.84 +{
   44.85 +	blkif->waiting_reqs = 1;
   44.86 +	wake_up(&blkif->wq);
   44.87 +}
   44.88 +
   44.89  irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
   44.90  {
   44.91 -	blkif_t *blkif = dev_id;
   44.92 -
   44.93 -	atomic_inc(&blkif->io_pending);
   44.94 -	wake_up(&blkif->wq);
   44.95 +	blkif_notify_work(dev_id);
   44.96  	return IRQ_HANDLED;
   44.97  }
   44.98  
   44.99 @@ -536,10 +515,8 @@ static void make_response(blkif_t *blkif
  44.100  	}
  44.101  	spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
  44.102  
  44.103 -	if (more_to_do) {
  44.104 -		atomic_inc(&blkif->io_pending);
  44.105 -		wake_up(&blkif->wq);
  44.106 -	}
  44.107 +	if (more_to_do)
  44.108 +		blkif_notify_work(blkif);
  44.109  	if (notify)
  44.110  		notify_remote_via_irq(blkif->irq);
  44.111  }
    45.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Apr 11 13:55:47 2006 -0600
    45.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Tue Apr 11 18:54:18 2006 -0600
    45.3 @@ -72,7 +72,6 @@ typedef struct blkif_st {
    45.4  	/* Back pointer to the backend_info. */
    45.5  	struct backend_info *be; 
    45.6  	/* Private fields. */
    45.7 -	enum { DISCONNECTED, CONNECTED } status;
    45.8  #ifdef CONFIG_XEN_BLKDEV_TAP_BE
    45.9  	/* Is this a blktap frontend */
   45.10  	unsigned int     is_blktap;
   45.11 @@ -82,7 +81,7 @@ typedef struct blkif_st {
   45.12  
   45.13  	wait_queue_head_t   wq;
   45.14  	struct task_struct  *xenblkd;
   45.15 -	atomic_t            io_pending;
   45.16 +	unsigned int        waiting_reqs;
   45.17  	request_queue_t     *plug;
   45.18  
   45.19  	/* statistics */
   45.20 @@ -133,8 +132,6 @@ void blkif_xenbus_init(void);
   45.21  irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs);
   45.22  int blkif_schedule(void *arg);
   45.23  
   45.24 -void update_blkif_status(blkif_t *blkif); 
   45.25 -
   45.26  #endif /* __BLKIF__BACKEND__COMMON_H__ */
   45.27  
   45.28  /*
    46.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Apr 11 13:55:47 2006 -0600
    46.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Tue Apr 11 18:54:18 2006 -0600
    46.3 @@ -45,7 +45,6 @@ blkif_t *alloc_blkif(domid_t domid)
    46.4  
    46.5  	memset(blkif, 0, sizeof(*blkif));
    46.6  	blkif->domid = domid;
    46.7 -	blkif->status = DISCONNECTED;
    46.8  	spin_lock_init(&blkif->blk_ring_lock);
    46.9  	atomic_set(&blkif->refcnt, 1);
   46.10  	init_waitqueue_head(&blkif->wq);
   46.11 @@ -138,9 +137,6 @@ int blkif_map(blkif_t *blkif, unsigned l
   46.12  	blkif->irq = bind_evtchn_to_irqhandler(
   46.13  		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
   46.14  
   46.15 -	/* We're potentially connected now */
   46.16 -	update_blkif_status(blkif); 
   46.17 -
   46.18  	return 0;
   46.19  }
   46.20  
    47.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Apr 11 13:55:47 2006 -0600
    47.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Tue Apr 11 18:54:18 2006 -0600
    47.3 @@ -17,7 +17,6 @@
    47.4      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    47.5  */
    47.6  
    47.7 -
    47.8  #include <stdarg.h>
    47.9  #include <linux/module.h>
   47.10  #include <linux/kthread.h>
   47.11 @@ -25,36 +24,52 @@
   47.12  #include "common.h"
   47.13  
   47.14  #undef DPRINTK
   47.15 -#define DPRINTK(fmt, args...) \
   47.16 -    pr_debug("blkback/xenbus (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
   47.17 -
   47.18 +#define DPRINTK(fmt, args...)				\
   47.19 +	pr_debug("blkback/xenbus (%s:%d) " fmt ".\n",	\
   47.20 +		 __FUNCTION__, __LINE__, ##args)
   47.21  
   47.22  struct backend_info
   47.23  {
   47.24  	struct xenbus_device *dev;
   47.25  	blkif_t *blkif;
   47.26  	struct xenbus_watch backend_watch;
   47.27 -
   47.28  	unsigned major;
   47.29  	unsigned minor;
   47.30  	char *mode;
   47.31  };
   47.32  
   47.33 -
   47.34 -static void maybe_connect(struct backend_info *);
   47.35  static void connect(struct backend_info *);
   47.36  static int connect_ring(struct backend_info *);
   47.37  static void backend_changed(struct xenbus_watch *, const char **,
   47.38  			    unsigned int);
   47.39  
   47.40  
   47.41 -void update_blkif_status(blkif_t *blkif)
   47.42 +static void update_blkif_status(blkif_t *blkif)
   47.43  { 
   47.44 -	if(blkif->irq && blkif->vbd.bdev) {
   47.45 -		blkif->status = CONNECTED; 
   47.46 -		(void)blkif_be_int(0, blkif, NULL); 
   47.47 +	int err;
   47.48 +
   47.49 +	/* Not ready to connect? */
   47.50 +	if (!blkif->irq || !blkif->vbd.bdev)
   47.51 +		return;
   47.52 +
   47.53 +	/* Already connected? */
   47.54 +	if (blkif->be->dev->state == XenbusStateConnected)
   47.55 +		return;
   47.56 +
   47.57 +	/* Attempt to connect: exit if we fail to. */
   47.58 +	connect(blkif->be);
   47.59 +	if (blkif->be->dev->state != XenbusStateConnected)
   47.60 +		return;
   47.61 +
   47.62 +	blkif->xenblkd = kthread_run(blkif_schedule, blkif,
   47.63 +				     "xvd %d %02x:%02x",
   47.64 +				     blkif->domid,
   47.65 +				     blkif->be->major, blkif->be->minor);
   47.66 +	if (IS_ERR(blkif->xenblkd)) {
   47.67 +		err = PTR_ERR(blkif->xenblkd);
   47.68 +		blkif->xenblkd = NULL;
   47.69 +		xenbus_dev_error(blkif->be->dev, err, "start xenblkd");
   47.70  	}
   47.71 -	maybe_connect(blkif->be); 
   47.72  }
   47.73  
   47.74  
   47.75 @@ -91,7 +106,6 @@ static int blkback_remove(struct xenbus_
   47.76  		be->backend_watch.node = NULL;
   47.77  	}
   47.78  	if (be->blkif) {
   47.79 -		be->blkif->status = DISCONNECTED; 
   47.80  		if (be->blkif->xenblkd)
   47.81  			kthread_stop(be->blkif->xenblkd);
   47.82  		blkif_put(be->blkif);
   47.83 @@ -142,7 +156,7 @@ static int blkback_probe(struct xenbus_d
   47.84  	if (err)
   47.85  		goto fail;
   47.86  
   47.87 -	err = xenbus_switch_state(dev, XBT_NULL, XenbusStateInitWait);
   47.88 +	err = xenbus_switch_state(dev, XenbusStateInitWait);
   47.89  	if (err)
   47.90  		goto fail;
   47.91  
   47.92 @@ -185,8 +199,8 @@ static void backend_changed(struct xenbu
   47.93  		return;
   47.94  	}
   47.95  
   47.96 -	if (be->major && be->minor &&
   47.97 -	    (be->major != major || be->minor != minor)) {
   47.98 +	if ((be->major || be->minor) &&
   47.99 +	    ((be->major != major) || (be->minor != minor))) {
  47.100  		printk(KERN_WARNING
  47.101  		       "blkback: changing physical device (from %x:%x to "
  47.102  		       "%x:%x) not supported.\n", be->major, be->minor,
  47.103 @@ -220,17 +234,6 @@ static void backend_changed(struct xenbu
  47.104  			return;
  47.105  		}
  47.106  
  47.107 -		be->blkif->xenblkd = kthread_run(blkif_schedule, be->blkif,
  47.108 -						 "xvd %d %02x:%02x",
  47.109 -						 be->blkif->domid,
  47.110 -						 be->major, be->minor);
  47.111 -		if (IS_ERR(be->blkif->xenblkd)) {
  47.112 -			err = PTR_ERR(be->blkif->xenblkd);
  47.113 -			be->blkif->xenblkd = NULL;
  47.114 -			xenbus_dev_error(dev, err, "start xenblkd");
  47.115 -			return;
  47.116 -		}
  47.117 -
  47.118  		device_create_file(&dev->dev, &dev_attr_physical_device);
  47.119  		device_create_file(&dev->dev, &dev_attr_mode);
  47.120  
  47.121 @@ -253,19 +256,24 @@ static void frontend_changed(struct xenb
  47.122  
  47.123  	switch (frontend_state) {
  47.124  	case XenbusStateInitialising:
  47.125 -	case XenbusStateConnected:
  47.126  		break;
  47.127  
  47.128  	case XenbusStateInitialised:
  47.129 +	case XenbusStateConnected:
  47.130 +		/* Ensure we connect even when two watches fire in 
  47.131 +		   close successsion and we miss the intermediate value 
  47.132 +		   of frontend_state. */
  47.133 +		if (dev->state == XenbusStateConnected)
  47.134 +			break;
  47.135 +
  47.136  		err = connect_ring(be);
  47.137 -		if (err) {
  47.138 -			return;
  47.139 -		}
  47.140 -		update_blkif_status(be->blkif); 
  47.141 +		if (err)
  47.142 +			break;
  47.143 +		update_blkif_status(be->blkif);
  47.144  		break;
  47.145  
  47.146  	case XenbusStateClosing:
  47.147 -		xenbus_switch_state(dev, XBT_NULL, XenbusStateClosing);
  47.148 +		xenbus_switch_state(dev, XenbusStateClosing);
  47.149  		break;
  47.150  
  47.151  	case XenbusStateClosed:
  47.152 @@ -285,14 +293,6 @@ static void frontend_changed(struct xenb
  47.153  /* ** Connection ** */
  47.154  
  47.155  
  47.156 -static void maybe_connect(struct backend_info *be)
  47.157 -{
  47.158 -	if ((be->major != 0 || be->minor != 0) &&
  47.159 -	    be->blkif->status == CONNECTED)
  47.160 -		connect(be);
  47.161 -}
  47.162 -
  47.163 -
  47.164  /**
  47.165   * Write the physical details regarding the block device to the store, and
  47.166   * switch to Connected state.
  47.167 @@ -338,15 +338,17 @@ again:
  47.168  		goto abort;
  47.169  	}
  47.170  
  47.171 -	err = xenbus_switch_state(dev, xbt, XenbusStateConnected);
  47.172 -	if (err)
  47.173 -		goto abort;
  47.174 -
  47.175  	err = xenbus_transaction_end(xbt, 0);
  47.176  	if (err == -EAGAIN)
  47.177  		goto again;
  47.178  	if (err)
  47.179  		xenbus_dev_fatal(dev, err, "ending transaction");
  47.180 +
  47.181 +	err = xenbus_switch_state(dev, XenbusStateConnected);
  47.182 +	if (err)
  47.183 +		xenbus_dev_fatal(dev, err, "switching to Connected state",
  47.184 +				 dev->nodename);
  47.185 +
  47.186  	return;
  47.187   abort:
  47.188  	xenbus_transaction_end(xbt, 1);
    48.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Apr 11 13:55:47 2006 -0600
    48.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Apr 11 18:54:18 2006 -0600
    48.3 @@ -176,10 +176,6 @@ again:
    48.4  		goto abort_transaction;
    48.5  	}
    48.6  
    48.7 -	err = xenbus_switch_state(dev, xbt, XenbusStateInitialised);
    48.8 -	if (err)
    48.9 -		goto abort_transaction;
   48.10 -
   48.11  	err = xenbus_transaction_end(xbt, 0);
   48.12  	if (err) {
   48.13  		if (err == -EAGAIN)
   48.14 @@ -188,6 +184,8 @@ again:
   48.15  		goto destroy_blkring;
   48.16  	}
   48.17  
   48.18 +	xenbus_switch_state(dev, XenbusStateInitialised);
   48.19 +
   48.20  	return 0;
   48.21  
   48.22   abort_transaction:
   48.23 @@ -324,7 +322,7 @@ static void connect(struct blkfront_info
   48.24  		return;
   48.25  	}
   48.26  
   48.27 -	(void)xenbus_switch_state(info->xbdev, XBT_NULL, XenbusStateConnected);
   48.28 +	(void)xenbus_switch_state(info->xbdev, XenbusStateConnected);
   48.29  
   48.30  	/* Kick pending requests. */
   48.31  	spin_lock_irq(&blkif_io_lock);
   48.32 @@ -349,7 +347,7 @@ static void blkfront_closing(struct xenb
   48.33  
   48.34  	xlvbd_del(info);
   48.35  
   48.36 -	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
   48.37 +	xenbus_switch_state(dev, XenbusStateClosed);
   48.38  }
   48.39  
   48.40  
   48.41 @@ -755,7 +753,7 @@ static void blkif_recover(struct blkfron
   48.42  
   48.43  	kfree(copy);
   48.44  
   48.45 -	(void)xenbus_switch_state(info->xbdev, XBT_NULL, XenbusStateConnected);
   48.46 +	(void)xenbus_switch_state(info->xbdev, XenbusStateConnected);
   48.47  
   48.48  	/* Now safe for us to use the shared ring */
   48.49  	spin_lock_irq(&blkif_io_lock);
    49.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Tue Apr 11 13:55:47 2006 -0600
    49.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Tue Apr 11 18:54:18 2006 -0600
    49.3 @@ -170,9 +170,9 @@ static inline void exit_idle(void) {}
    49.4  #include <asm/idle.h>
    49.5  #define IRQ_REG orig_rax
    49.6  #endif
    49.7 -#define do_IRQ(irq, regs) do {					\
    49.8 -	(regs)->IRQ_REG = (irq) | (1UL << (BITS_PER_LONG - 1));	\
    49.9 -	do_IRQ((regs));						\
   49.10 +#define do_IRQ(irq, regs) do {		\
   49.11 +	(regs)->IRQ_REG = ~(irq);	\
   49.12 +	do_IRQ((regs));			\
   49.13  } while (0)
   49.14  #endif
   49.15  
    50.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Tue Apr 11 13:55:47 2006 -0600
    50.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Tue Apr 11 18:54:18 2006 -0600
    50.3 @@ -395,6 +395,9 @@ gnttab_resume(void)
    50.4  	setup.frame_list = frames;
    50.5  
    50.6  	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
    50.7 +	if (rc == -ENOSYS)
    50.8 +		return -ENOSYS;
    50.9 +
   50.10  	BUG_ON(rc || setup.status);
   50.11  
   50.12  #ifndef __ia64__
   50.13 @@ -436,7 +439,8 @@ gnttab_init(void)
   50.14  	if (xen_init() < 0)
   50.15  		return -ENODEV;
   50.16  
   50.17 -	BUG_ON(gnttab_resume());
   50.18 +	if (gnttab_resume() < 0)
   50.19 +		return -ENODEV;
   50.20  
   50.21  	for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
   50.22  		gnttab_list[i] = i + 1;
    51.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue Apr 11 13:55:47 2006 -0600
    51.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Tue Apr 11 18:54:18 2006 -0600
    51.3 @@ -15,6 +15,7 @@
    51.4  #include <xen/xenbus.h>
    51.5  #include <linux/cpu.h>
    51.6  #include <linux/kthread.h>
    51.7 +#include <xen/gnttab.h>
    51.8  #include <xen/xencons.h>
    51.9  
   51.10  #if defined(__i386__) || defined(__x86_64__)
   51.11 @@ -41,7 +42,7 @@ void machine_emergency_restart(void)
   51.12  {
   51.13  	/* We really want to get pending console data out before we die. */
   51.14  	xencons_force_flush();
   51.15 -	HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_reboot);
   51.16 +	HYPERVISOR_shutdown(SHUTDOWN_reboot);
   51.17  }
   51.18  
   51.19  void machine_restart(char * __unused)
   51.20 @@ -58,7 +59,11 @@ void machine_power_off(void)
   51.21  {
   51.22  	/* We really want to get pending console data out before we die. */
   51.23  	xencons_force_flush();
   51.24 -	HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_poweroff);
   51.25 +#if defined(__i386__) || defined(__x86_64__)
   51.26 +	if (pm_power_off)
   51.27 +		pm_power_off();
   51.28 +#endif
   51.29 +	HYPERVISOR_shutdown(SHUTDOWN_poweroff);
   51.30  }
   51.31  
   51.32  int reboot_thru_bios = 0;	/* for dmi_scan.c */
   51.33 @@ -76,31 +81,41 @@ static int shutting_down = SHUTDOWN_INVA
   51.34  static void __shutdown_handler(void *unused);
   51.35  static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
   51.36  
   51.37 -#ifndef CONFIG_HOTPLUG_CPU
   51.38 -#define cpu_down(x) (-EOPNOTSUPP)
   51.39 -#define cpu_up(x) (-EOPNOTSUPP)
   51.40 +#ifdef CONFIG_SMP
   51.41 +int  smp_suspend(void);
   51.42 +void smp_resume(void);
   51.43 +#else
   51.44 +#define smp_suspend()	(0)
   51.45 +#define smp_resume()	((void)0)
   51.46  #endif
   51.47  
   51.48 +/* Ensure we run on the idle task page tables so that we will
   51.49 +   switch page tables before running user space. This is needed
   51.50 +   on architectures with separate kernel and user page tables
   51.51 +   because the user page table pointer is not saved/restored. */
   51.52 +static void switch_idle_mm(void)
   51.53 +{
   51.54 +	struct mm_struct *mm = current->active_mm;
   51.55 +
   51.56 +	if (mm == &init_mm)
   51.57 +		return;
   51.58 +
   51.59 +	atomic_inc(&init_mm.mm_count);
   51.60 +	switch_mm(mm, &init_mm, current);
   51.61 +	current->active_mm = &init_mm;
   51.62 +	mmdrop(mm);
   51.63 +}
   51.64  
   51.65  static int __do_suspend(void *ignore)
   51.66  {
   51.67 -	int i, j, k, fpp;
   51.68 +	int i, j, k, fpp, err;
   51.69  
   51.70  	extern unsigned long max_pfn;
   51.71  	extern unsigned long *pfn_to_mfn_frame_list_list;
   51.72  	extern unsigned long *pfn_to_mfn_frame_list[];
   51.73  
   51.74 -	extern int gnttab_suspend(void);
   51.75 -	extern int gnttab_resume(void);
   51.76  	extern void time_resume(void);
   51.77  
   51.78 -#ifdef CONFIG_SMP
   51.79 -	cpumask_t prev_online_cpus;
   51.80 -	int vcpu_prepare(int vcpu);
   51.81 -#endif
   51.82 -
   51.83 -	int err = 0;
   51.84 -
   51.85  	BUG_ON(smp_processor_id() != 0);
   51.86  	BUG_ON(in_interrupt());
   51.87  
   51.88 @@ -110,50 +125,21 @@ static int __do_suspend(void *ignore)
   51.89  		return -EOPNOTSUPP;
   51.90  	}
   51.91  
   51.92 -#if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
   51.93 -	if (num_online_cpus() > 1) {
   51.94 -		printk(KERN_WARNING "Can't suspend SMP guests "
   51.95 -		       "without CONFIG_HOTPLUG_CPU\n");
   51.96 -		return -EOPNOTSUPP;
   51.97 -	}
   51.98 -#endif
   51.99 +	err = smp_suspend();
  51.100 +	if (err)
  51.101 +		return err;
  51.102  
  51.103  	xenbus_suspend();
  51.104  
  51.105 -	lock_cpu_hotplug();
  51.106 -#ifdef CONFIG_SMP
  51.107 -	/*
  51.108 -	 * Take all other CPUs offline. We hold the hotplug mutex to
  51.109 -	 * avoid other processes bringing up CPUs under our feet.
  51.110 -	 */
  51.111 -	cpus_clear(prev_online_cpus);
  51.112 -	while (num_online_cpus() > 1) {
  51.113 -		for_each_online_cpu(i) {
  51.114 -			if (i == 0)
  51.115 -				continue;
  51.116 -			unlock_cpu_hotplug();
  51.117 -			err = cpu_down(i);
  51.118 -			lock_cpu_hotplug();
  51.119 -			if (err != 0) {
  51.120 -				printk(KERN_CRIT "Failed to take all CPUs "
  51.121 -				       "down: %d.\n", err);
  51.122 -				goto out_reenable_cpus;
  51.123 -			}
  51.124 -			cpu_set(i, prev_online_cpus);
  51.125 -		}
  51.126 -	}
  51.127 -#endif
  51.128 -
  51.129  	preempt_disable();
  51.130  
  51.131  #ifdef __i386__
  51.132  	kmem_cache_shrink(pgd_cache);
  51.133 +#endif
  51.134  	mm_pin_all();
  51.135 -#endif
  51.136  
  51.137  	__cli();
  51.138  	preempt_enable();
  51.139 -	unlock_cpu_hotplug();
  51.140  
  51.141  	gnttab_suspend();
  51.142  
  51.143 @@ -199,34 +185,15 @@ static int __do_suspend(void *ignore)
  51.144  
  51.145  	time_resume();
  51.146  
  51.147 +	switch_idle_mm();
  51.148 +
  51.149  	__sti();
  51.150  
  51.151  	xencons_resume();
  51.152  
  51.153 -#ifdef CONFIG_SMP
  51.154 -	for_each_cpu(i)
  51.155 -		vcpu_prepare(i);
  51.156 -
  51.157 -#endif
  51.158 -
  51.159 -	/*
  51.160 -	 * Only resume xenbus /after/ we've prepared our VCPUs; otherwise
  51.161 -	 * the VCPU hotplug callback can race with our vcpu_prepare
  51.162 -	 */
  51.163  	xenbus_resume();
  51.164  
  51.165 -#ifdef CONFIG_SMP
  51.166 - out_reenable_cpus:
  51.167 -	for_each_cpu_mask(i, prev_online_cpus) {
  51.168 -		j = cpu_up(i);
  51.169 -		if ((j != 0) && !cpu_online(i)) {
  51.170 -			printk(KERN_CRIT "Failed to bring cpu "
  51.171 -			       "%d back up (%d).\n",
  51.172 -			       i, j);
  51.173 -			err = j;
  51.174 -		}
  51.175 -	}
  51.176 -#endif
  51.177 +	smp_resume();
  51.178  
  51.179  	return err;
  51.180  }
  51.181 @@ -334,7 +301,6 @@ static void shutdown_handler(struct xenb
  51.182  	kfree(str);
  51.183  }
  51.184  
  51.185 -#ifdef CONFIG_MAGIC_SYSRQ
  51.186  static void sysrq_handler(struct xenbus_watch *watch, const char **vec,
  51.187  			  unsigned int len)
  51.188  {
  51.189 @@ -360,45 +326,35 @@ static void sysrq_handler(struct xenbus_
  51.190  	if (err == -EAGAIN)
  51.191  		goto again;
  51.192  
  51.193 -	if (sysrq_key != '\0') {
  51.194 +#ifdef CONFIG_MAGIC_SYSRQ
  51.195 +	if (sysrq_key != '\0')
  51.196  		handle_sysrq(sysrq_key, NULL, NULL);
  51.197 -	}
  51.198 +#endif
  51.199  }
  51.200 -#endif
  51.201  
  51.202  static struct xenbus_watch shutdown_watch = {
  51.203  	.node = "control/shutdown",
  51.204  	.callback = shutdown_handler
  51.205  };
  51.206  
  51.207 -#ifdef CONFIG_MAGIC_SYSRQ
  51.208  static struct xenbus_watch sysrq_watch = {
  51.209  	.node ="control/sysrq",
  51.210  	.callback = sysrq_handler
  51.211  };
  51.212 -#endif
  51.213  
  51.214  static int setup_shutdown_watcher(struct notifier_block *notifier,
  51.215                                    unsigned long event,
  51.216                                    void *data)
  51.217  {
  51.218 -	int err1 = 0;
  51.219 -#ifdef CONFIG_MAGIC_SYSRQ
  51.220 -	int err2 = 0;
  51.221 -#endif
  51.222 +	int err;
  51.223  
  51.224 -	err1 = register_xenbus_watch(&shutdown_watch);
  51.225 -#ifdef CONFIG_MAGIC_SYSRQ
  51.226 -	err2 = register_xenbus_watch(&sysrq_watch);
  51.227 -#endif
  51.228 -
  51.229 -	if (err1)
  51.230 +	err = register_xenbus_watch(&shutdown_watch);
  51.231 +	if (err)
  51.232  		printk(KERN_ERR "Failed to set shutdown watcher\n");
  51.233  
  51.234 -#ifdef CONFIG_MAGIC_SYSRQ
  51.235 -	if (err2)
  51.236 +	err = register_xenbus_watch(&sysrq_watch);
  51.237 +	if (err)
  51.238  		printk(KERN_ERR "Failed to set sysrq watcher\n");
  51.239 -#endif
  51.240  
  51.241  	return NOTIFY_DONE;
  51.242  }
    52.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Tue Apr 11 13:55:47 2006 -0600
    52.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Tue Apr 11 18:54:18 2006 -0600
    52.3 @@ -79,6 +79,15 @@ EXPORT_SYMBOL(x86_cpu_to_apicid);
    52.4  unsigned int maxcpus = NR_CPUS;
    52.5  #endif
    52.6  
    52.7 +/*
    52.8 + * Set of CPUs that remote admin software will allow us to bring online.
    52.9 + * Notified to us via xenbus.
   52.10 + */
   52.11 +static cpumask_t xenbus_allowed_cpumask;
   52.12 +
   52.13 +/* Set of CPUs that local admin will allow us to bring online. */
   52.14 +static cpumask_t local_allowed_cpumask = CPU_MASK_ALL;
   52.15 +
   52.16  void __init prefill_possible_map(void)
   52.17  {
   52.18  	int i, rc;
   52.19 @@ -146,7 +155,7 @@ static void cpu_bringup(void)
   52.20  	cpu_idle();
   52.21  }
   52.22  
   52.23 -void vcpu_prepare(int vcpu)
   52.24 +static void vcpu_prepare(int vcpu)
   52.25  {
   52.26  	vcpu_guest_context_t ctxt;
   52.27  	struct task_struct *idle = idle_task(vcpu);
   52.28 @@ -278,6 +287,8 @@ void __init smp_prepare_cpus(unsigned in
   52.29  		vcpu_prepare(cpu);
   52.30  	}
   52.31  
   52.32 +	xenbus_allowed_cpumask = cpu_present_map;
   52.33 +
   52.34  	/* Currently, Xen gives no dynamic NUMA/HT info. */
   52.35  	for (cpu = 1; cpu < NR_CPUS; cpu++) {
   52.36  		cpu_sibling_map[cpu] = cpumask_of_cpu(cpu);
   52.37 @@ -301,6 +312,15 @@ void __devinit smp_prepare_boot_cpu(void
   52.38  	cpu_online_map   = cpumask_of_cpu(0);
   52.39  }
   52.40  
   52.41 +static int local_cpu_hotplug_request(void)
   52.42 +{
   52.43 +	/*
   52.44 +	 * We assume a CPU hotplug request comes from local admin if it is made
   52.45 +	 * via a userspace process (i.e., one with a real mm_struct).
   52.46 +	 */
   52.47 +	return (current->mm != NULL);
   52.48 +}
   52.49 +
   52.50  #ifdef CONFIG_HOTPLUG_CPU
   52.51  
   52.52  /*
   52.53 @@ -331,8 +351,10 @@ static void vcpu_hotplug(unsigned int cp
   52.54  	}
   52.55  
   52.56  	if (strcmp(state, "online") == 0) {
   52.57 +		cpu_set(cpu, xenbus_allowed_cpumask);
   52.58  		(void)cpu_up(cpu);
   52.59  	} else if (strcmp(state, "offline") == 0) {
   52.60 +		cpu_clear(cpu, xenbus_allowed_cpumask);
   52.61  		(void)cpu_down(cpu);
   52.62  	} else {
   52.63  		printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n",
   52.64 @@ -353,6 +375,22 @@ static void handle_vcpu_hotplug_event(
   52.65  	}
   52.66  }
   52.67  
   52.68 +static int smpboot_cpu_notify(struct notifier_block *notifier,
   52.69 +			      unsigned long action, void *hcpu)
   52.70 +{
   52.71 +	int cpu = (long)hcpu;
   52.72 +
   52.73 +	/*
   52.74 +	 * We do this in a callback notifier rather than __cpu_disable()
   52.75 +	 * because local_cpu_hotplug_request() does not work in the latter
   52.76 +	 * as it's always executed from within a stopmachine kthread.
   52.77 +	 */
   52.78 +	if ((action == CPU_DOWN_PREPARE) && local_cpu_hotplug_request())
   52.79 +		cpu_clear(cpu, local_allowed_cpumask);
   52.80 +
   52.81 +	return NOTIFY_OK;
   52.82 +}
   52.83 +
   52.84  static int setup_cpu_watcher(struct notifier_block *notifier,
   52.85  			      unsigned long event, void *data)
   52.86  {
   52.87 @@ -360,7 +398,8 @@ static int setup_cpu_watcher(struct noti
   52.88  
   52.89  	static struct xenbus_watch cpu_watch = {
   52.90  		.node = "cpu",
   52.91 -		.callback = handle_vcpu_hotplug_event };
   52.92 +		.callback = handle_vcpu_hotplug_event,
   52.93 +		.flags = XBWF_new_thread };
   52.94  	(void)register_xenbus_watch(&cpu_watch);
   52.95  
   52.96  	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
   52.97 @@ -375,14 +414,62 @@ static int setup_cpu_watcher(struct noti
   52.98  
   52.99  static int __init setup_vcpu_hotplug_event(void)
  52.100  {
  52.101 +	static struct notifier_block hotplug_cpu = {
  52.102 +		.notifier_call = smpboot_cpu_notify };
  52.103  	static struct notifier_block xsn_cpu = {
  52.104  		.notifier_call = setup_cpu_watcher };
  52.105 +
  52.106 +	register_cpu_notifier(&hotplug_cpu);
  52.107  	register_xenstore_notifier(&xsn_cpu);
  52.108 +
  52.109  	return 0;
  52.110  }
  52.111  
  52.112  arch_initcall(setup_vcpu_hotplug_event);
  52.113  
  52.114 +int smp_suspend(void)
  52.115 +{
  52.116 +	int i, err;
  52.117 +
  52.118 +	lock_cpu_hotplug();
  52.119 +
  52.120 +	/*
  52.121 +	 * Take all other CPUs offline. We hold the hotplug mutex to
  52.122 +	 * avoid other processes bringing up CPUs under our feet.
  52.123 +	 */
  52.124 +	while (num_online_cpus() > 1) {
  52.125 +		unlock_cpu_hotplug();
  52.126 +		for_each_online_cpu(i) {
  52.127 +			if (i == 0)
  52.128 +				continue;
  52.129 +			err = cpu_down(i);
  52.130 +			if (err) {
  52.131 +				printk(KERN_CRIT "Failed to take all CPUs "
  52.132 +				       "down: %d.\n", err);
  52.133 +				for_each_cpu(i)
  52.134 +					vcpu_hotplug(i);
  52.135 +				return err;
  52.136 +			}
  52.137 +		}
  52.138 +		lock_cpu_hotplug();
  52.139 +	}
  52.140 +
  52.141 +	return 0;
  52.142 +}
  52.143 +
  52.144 +void smp_resume(void)
  52.145 +{
  52.146 +	int i;
  52.147 +
  52.148 +	for_each_cpu(i)
  52.149 +		vcpu_prepare(i);
  52.150 +
  52.151 +	unlock_cpu_hotplug();
  52.152 +
  52.153 +	for_each_cpu(i)
  52.154 +		vcpu_hotplug(i);
  52.155 +}
  52.156 +
  52.157  int __cpu_disable(void)
  52.158  {
  52.159  	cpumask_t map = cpu_online_map;
  52.160 @@ -415,6 +502,20 @@ void __cpu_die(unsigned int cpu)
  52.161  
  52.162  #else /* !CONFIG_HOTPLUG_CPU */
  52.163  
  52.164 +int smp_suspend(void)
  52.165 +{
  52.166 +	if (num_online_cpus() > 1) {
  52.167 +		printk(KERN_WARNING "Can't suspend SMP guests "
  52.168 +		       "without CONFIG_HOTPLUG_CPU\n");
  52.169 +		return -EOPNOTSUPP;
  52.170 +	}
  52.171 +	return 0;
  52.172 +}
  52.173 +
  52.174 +void smp_resume(void)
  52.175 +{
  52.176 +}
  52.177 +
  52.178  int __cpu_disable(void)
  52.179  {
  52.180  	return -ENOSYS;
  52.181 @@ -429,6 +530,20 @@ void __cpu_die(unsigned int cpu)
  52.182  
  52.183  int __devinit __cpu_up(unsigned int cpu)
  52.184  {
  52.185 +	int rc;
  52.186 +
  52.187 +	if (local_cpu_hotplug_request()) {
  52.188 +		cpu_set(cpu, local_allowed_cpumask);
  52.189 +		if (!cpu_isset(cpu, xenbus_allowed_cpumask)) {
  52.190 +			printk("%s: attempt to bring up CPU %u disallowed by "
  52.191 +			       "remote admin.\n", __FUNCTION__, cpu);
  52.192 +			return -EBUSY;
  52.193 +		}
  52.194 +	} else if (!cpu_isset(cpu, local_allowed_cpumask) ||
  52.195 +		   !cpu_isset(cpu, xenbus_allowed_cpumask)) {
  52.196 +		return -EBUSY;
  52.197 +	}
  52.198 +
  52.199  #ifdef CONFIG_SMP_ALTERNATIVES
  52.200  	if (num_online_cpus() == 1)
  52.201  		prepare_for_smp();
  52.202 @@ -436,7 +551,9 @@ int __devinit __cpu_up(unsigned int cpu)
  52.203  
  52.204  	xen_smp_intr_init(cpu);
  52.205  	cpu_set(cpu, cpu_online_map);
  52.206 -	if (HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL) != 0)
  52.207 +
  52.208 +	rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL);
  52.209 +	if (rc != 0)
  52.210  		BUG();
  52.211  
  52.212  	return 0;
    53.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Tue Apr 11 13:55:47 2006 -0600
    53.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Tue Apr 11 18:54:18 2006 -0600
    53.3 @@ -97,7 +97,6 @@ typedef struct netif_st {
    53.4  #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
    53.5  #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
    53.6  
    53.7 -void netif_creditlimit(netif_t *netif);
    53.8  void netif_disconnect(netif_t *netif);
    53.9  
   53.10  netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
    54.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Apr 11 13:55:47 2006 -0600
    54.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Apr 11 18:54:18 2006 -0600
    54.3 @@ -31,6 +31,7 @@
    54.4   */
    54.5  
    54.6  #include "common.h"
    54.7 +#include <linux/ethtool.h>
    54.8  #include <linux/rtnetlink.h>
    54.9  
   54.10  static void __netif_up(netif_t *netif)
   54.11 @@ -71,6 +72,12 @@ static int net_close(struct net_device *
   54.12  	return 0;
   54.13  }
   54.14  
   54.15 +static struct ethtool_ops network_ethtool_ops =
   54.16 +{
   54.17 +	.get_tx_csum = ethtool_op_get_tx_csum,
   54.18 +	.set_tx_csum = ethtool_op_set_tx_csum,
   54.19 +};
   54.20 +
   54.21  netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN])
   54.22  {
   54.23  	int err = 0, i;
   54.24 @@ -101,7 +108,9 @@ netif_t *alloc_netif(domid_t domid, unsi
   54.25  	dev->get_stats       = netif_be_get_stats;
   54.26  	dev->open            = net_open;
   54.27  	dev->stop            = net_close;
   54.28 -	dev->features        = NETIF_F_NO_CSUM;
   54.29 +	dev->features        = NETIF_F_IP_CSUM;
   54.30 +
   54.31 +	SET_ETHTOOL_OPS(dev, &network_ethtool_ops);
   54.32  
   54.33  	/* Disable queuing. */
   54.34  	dev->tx_queue_len = 0;
   54.35 @@ -293,25 +302,6 @@ void free_netif(netif_t *netif)
   54.36  	schedule_work(&netif->free_work);
   54.37  }
   54.38  
   54.39 -void netif_creditlimit(netif_t *netif)
   54.40 -{
   54.41 -#if 0
   54.42 -	/* Set the credit limit (reset remaining credit to new limit). */
   54.43 -	netif->credit_bytes     = creditlimit->credit_bytes;
   54.44 -	netif->remaining_credit = creditlimit->credit_bytes;
   54.45 -	netif->credit_usec      = creditlimit->period_usec;
   54.46 -
   54.47 -	if (netif->status == CONNECTED) {
   54.48 -		/*
   54.49 -		 * Schedule work so that any packets waiting under previous
   54.50 -		 * credit limit are dealt with (acts as a replenishment point).
   54.51 -		 */
   54.52 -		netif->credit_timeout.expires = jiffies;
   54.53 -		netif_schedule_work(netif);
   54.54 -	}
   54.55 -#endif
   54.56 -}
   54.57 -
   54.58  void netif_disconnect(netif_t *netif)
   54.59  {
   54.60  	switch (netif->status) {
    55.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Tue Apr 11 13:55:47 2006 -0600
    55.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Tue Apr 11 18:54:18 2006 -0600
    55.3 @@ -100,10 +100,10 @@ static int loopback_start_xmit(struct sk
    55.4  		/* Defer checksum calculation. */
    55.5  		skb->proto_csum_blank = 1;
    55.6  		/* Must be a local packet: assert its integrity. */
    55.7 -		skb->proto_csum_valid = 1;
    55.8 +		skb->proto_data_valid = 1;
    55.9  	}
   55.10  
   55.11 -	skb->ip_summed = skb->proto_csum_valid ?
   55.12 +	skb->ip_summed = skb->proto_data_valid ?
   55.13  		CHECKSUM_UNNECESSARY : CHECKSUM_NONE;
   55.14  
   55.15  	skb->pkt_type = PACKET_HOST; /* overridden by eth_type_trans() */
   55.16 @@ -121,6 +121,12 @@ static struct net_device_stats *loopback
   55.17  	return &np->stats;
   55.18  }
   55.19  
   55.20 +static struct ethtool_ops network_ethtool_ops =
   55.21 +{
   55.22 +	.get_tx_csum = ethtool_op_get_tx_csum,
   55.23 +	.set_tx_csum = ethtool_op_set_tx_csum,
   55.24 +};
   55.25 +
   55.26  static void loopback_construct(struct net_device *dev, struct net_device *lo)
   55.27  {
   55.28  	struct net_private *np = netdev_priv(dev);
   55.29 @@ -134,7 +140,11 @@ static void loopback_construct(struct ne
   55.30  
   55.31  	dev->tx_queue_len    = 0;
   55.32  
   55.33 -	dev->features        = NETIF_F_HIGHDMA | NETIF_F_LLTX;
   55.34 +	dev->features        = (NETIF_F_HIGHDMA |
   55.35 +				NETIF_F_LLTX |
   55.36 +				NETIF_F_IP_CSUM);
   55.37 +
   55.38 +	SET_ETHTOOL_OPS(dev, &network_ethtool_ops);
   55.39  
   55.40  	/*
   55.41  	 * We do not set a jumbo MTU on the interface. Otherwise the network
   55.42 @@ -147,12 +157,6 @@ static void loopback_construct(struct ne
   55.43  	/*dev->mtu             = 16*1024;*/
   55.44  }
   55.45  
   55.46 -static struct ethtool_ops network_ethtool_ops =
   55.47 -{
   55.48 -	.get_tx_csum = ethtool_op_get_tx_csum,
   55.49 -	.set_tx_csum = ethtool_op_set_tx_csum,
   55.50 -};
   55.51 -
   55.52  static int __init make_loopback(int i)
   55.53  {
   55.54  	struct net_device *dev1, *dev2;
   55.55 @@ -172,11 +176,6 @@ static int __init make_loopback(int i)
   55.56  	loopback_construct(dev1, dev2);
   55.57  	loopback_construct(dev2, dev1);
   55.58  
   55.59 -	dev1->features |= NETIF_F_NO_CSUM;
   55.60 -	dev2->features |= NETIF_F_IP_CSUM;
   55.61 -
   55.62 -	SET_ETHTOOL_OPS(dev2, &network_ethtool_ops);
   55.63 -
   55.64  	/*
   55.65  	 * Initialise a dummy MAC address for the 'dummy backend' interface. We
   55.66  	 * choose the numerically largest non-broadcast address to prevent the
    56.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Apr 11 13:55:47 2006 -0600
    56.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Apr 11 18:54:18 2006 -0600
    56.3 @@ -171,7 +171,7 @@ int netif_be_start_xmit(struct sk_buff *
    56.4  				     skb->len + hlen);
    56.5  		BUG_ON(ret);
    56.6  		nskb->dev = skb->dev;
    56.7 -		nskb->proto_csum_valid = skb->proto_csum_valid;
    56.8 +		nskb->proto_data_valid = skb->proto_data_valid;
    56.9  		dev_kfree_skb(skb);
   56.10  		skb = nskb;
   56.11  	}
   56.12 @@ -213,7 +213,7 @@ static void net_rx_action(unsigned long 
   56.13  {
   56.14  	netif_t *netif = NULL; 
   56.15  	s8 status;
   56.16 -	u16 size, id, irq;
   56.17 +	u16 size, id, irq, flags;
   56.18  	multicall_entry_t *mcl;
   56.19  	mmu_update_t *mmu;
   56.20  	gnttab_transfer_t *gop;
   56.21 @@ -301,9 +301,6 @@ static void net_rx_action(unsigned long 
   56.22  		netif   = netdev_priv(skb->dev);
   56.23  		size    = skb->tail - skb->data;
   56.24  
   56.25 -		/* Rederive the machine addresses. */
   56.26 -		new_mfn = mcl->args[1] >> PAGE_SHIFT;
   56.27 -		old_mfn = gop->mfn;
   56.28  		atomic_set(&(skb_shinfo(skb)->dataref), 1);
   56.29  		skb_shinfo(skb)->nr_frags = 0;
   56.30  		skb_shinfo(skb)->frag_list = NULL;
   56.31 @@ -328,10 +325,14 @@ static void net_rx_action(unsigned long 
   56.32  		}
   56.33  		irq = netif->irq;
   56.34  		id = RING_GET_REQUEST(&netif->rx, netif->rx.rsp_prod_pvt)->id;
   56.35 +		flags = 0;
   56.36 +		if (skb->ip_summed == CHECKSUM_HW) /* local packet? */
   56.37 +			flags |= NETRXF_csum_blank | NETRXF_data_validated;
   56.38 +		else if (skb->proto_data_valid) /* remote but checksummed? */
   56.39 +			flags |= NETRXF_data_validated;
   56.40  		if (make_rx_response(netif, id, status,
   56.41  				     (unsigned long)skb->data & ~PAGE_MASK,
   56.42 -				     size, skb->proto_csum_valid ?
   56.43 -				     NETRXF_data_validated : 0) &&
   56.44 +				     size, flags) &&
   56.45  		    (rx_notify[irq] == 0)) {
   56.46  			rx_notify[irq] = 1;
   56.47  			notify_list[notify_nr++] = irq;
   56.48 @@ -655,11 +656,16 @@ static void net_tx_action(unsigned long 
   56.49  		skb->protocol = eth_type_trans(skb, skb->dev);
   56.50  
   56.51  		/*
   56.52 -                 * No checking needed on localhost, but remember the field is
   56.53 -                 * blank. 
   56.54 -                 */
   56.55 -		skb->ip_summed        = CHECKSUM_UNNECESSARY;
   56.56 -		skb->proto_csum_valid = 1;
   56.57 +		 * Old frontends do not assert data_validated but we
   56.58 +		 * can infer it from csum_blank so test both flags.
   56.59 +		 */
   56.60 +		if (txreq.flags & (NETTXF_data_validated|NETTXF_csum_blank)) {
   56.61 +			skb->ip_summed = CHECKSUM_UNNECESSARY;
   56.62 +			skb->proto_data_valid = 1;
   56.63 +		} else {
   56.64 +			skb->ip_summed = CHECKSUM_NONE;
   56.65 +			skb->proto_data_valid = 0;
   56.66 +		}
   56.67  		skb->proto_csum_blank = !!(txreq.flags & NETTXF_csum_blank);
   56.68  
   56.69  		netif->stats.rx_bytes += txreq.size;
    57.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Tue Apr 11 13:55:47 2006 -0600
    57.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Tue Apr 11 18:54:18 2006 -0600
    57.3 @@ -92,7 +92,7 @@ static int netback_probe(struct xenbus_d
    57.4  	if (err)
    57.5  		goto fail;
    57.6  
    57.7 -	err = xenbus_switch_state(dev, XBT_NULL, XenbusStateInitWait);
    57.8 +	err = xenbus_switch_state(dev, XenbusStateInitWait);
    57.9  	if (err) {
   57.10  		goto fail;
   57.11  	}
   57.12 @@ -209,7 +209,7 @@ static void frontend_changed(struct xenb
   57.13  		break;
   57.14  
   57.15  	case XenbusStateClosing:
   57.16 -		xenbus_switch_state(dev, XBT_NULL, XenbusStateClosing);
   57.17 +		xenbus_switch_state(dev, XenbusStateClosing);
   57.18  		break;
   57.19  
   57.20  	case XenbusStateClosed:
   57.21 @@ -233,9 +233,44 @@ static void frontend_changed(struct xenb
   57.22  
   57.23  static void maybe_connect(struct backend_info *be)
   57.24  {
   57.25 -	if (be->netif != NULL && be->frontend_state == XenbusStateConnected) {
   57.26 +	if (be->netif && (be->frontend_state == XenbusStateConnected))
   57.27  		connect(be);
   57.28 -	}
   57.29 +}
   57.30 +
   57.31 +static void xen_net_read_rate(struct xenbus_device *dev,
   57.32 +			      unsigned long *bytes, unsigned long *usec)
   57.33 +{
   57.34 +	char *s, *e;
   57.35 +	unsigned long b, u;
   57.36 +	char *ratestr;
   57.37 +
   57.38 +	/* Default to unlimited bandwidth. */
   57.39 +	*bytes = ~0UL;
   57.40 +	*usec = 0;
   57.41 +
   57.42 +	ratestr = xenbus_read(XBT_NULL, dev->nodename, "rate", NULL);
   57.43 +	if (IS_ERR(ratestr))
   57.44 +		return;
   57.45 +
   57.46 +	s = ratestr;
   57.47 +	b = simple_strtoul(s, &e, 10);
   57.48 +	if ((s == e) || (*e != ','))
   57.49 +		goto fail;
   57.50 +
   57.51 +	s = e + 1;
   57.52 +	u = simple_strtoul(s, &e, 10);
   57.53 +	if ((s == e) || (*e != '\0'))
   57.54 +		goto fail;
   57.55 +
   57.56 +	*bytes = b;
   57.57 +	*usec = u;
   57.58 +
   57.59 +	kfree(ratestr);
   57.60 +	return;
   57.61 +
   57.62 + fail:
   57.63 +	WPRINTK("Failed to parse network rate limit. Traffic unlimited.\n");
   57.64 +	kfree(ratestr);
   57.65  }
   57.66  
   57.67  
   57.68 @@ -254,7 +289,11 @@ static void connect(struct backend_info 
   57.69  		return;
   57.70  	}
   57.71  
   57.72 -	xenbus_switch_state(dev, XBT_NULL, XenbusStateConnected);
   57.73 +	xen_net_read_rate(dev, &be->netif->credit_bytes,
   57.74 +			  &be->netif->credit_usec);
   57.75 +	be->netif->remaining_credit = be->netif->credit_bytes;
   57.76 +
   57.77 +	xenbus_switch_state(dev, XenbusStateConnected);
   57.78  }
   57.79  
   57.80  
    58.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 11 13:55:47 2006 -0600
    58.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 11 18:54:18 2006 -0600
    58.3 @@ -300,13 +300,6 @@ again:
    58.4  		goto abort_transaction;
    58.5  	}
    58.6  
    58.7 -	err = xenbus_printf(xbt, dev->nodename,
    58.8 -			    "state", "%d", XenbusStateConnected);
    58.9 -	if (err) {
   58.10 -		message = "writing frontend XenbusStateConnected";
   58.11 -		goto abort_transaction;
   58.12 -	}
   58.13 -
   58.14  	err = xenbus_transaction_end(xbt, 0);
   58.15  	if (err) {
   58.16  		if (err == -EAGAIN)
   58.17 @@ -315,6 +308,8 @@ again:
   58.18  		goto destroy_ring;
   58.19  	}
   58.20  
   58.21 +	xenbus_switch_state(dev, XenbusStateConnected);
   58.22 +
   58.23  	return 0;
   58.24  
   58.25   abort_transaction:
   58.26 @@ -696,7 +691,12 @@ static int network_start_xmit(struct sk_
   58.27  	tx->gref = np->grant_tx_ref[id] = ref;
   58.28  	tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
   58.29  	tx->size = skb->len;
   58.30 -	tx->flags = (skb->ip_summed == CHECKSUM_HW) ? NETTXF_csum_blank : 0;
   58.31 +
   58.32 +	tx->flags = 0;
   58.33 +	if (skb->ip_summed == CHECKSUM_HW) /* local packet? */
   58.34 +		tx->flags |= NETTXF_csum_blank | NETTXF_data_validated;
   58.35 +	if (skb->proto_data_valid) /* remote but checksummed? */
   58.36 +		tx->flags |= NETTXF_data_validated;
   58.37  
   58.38  	np->tx.req_prod_pvt = i + 1;
   58.39  	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&np->tx, notify);
   58.40 @@ -811,8 +811,18 @@ static int netif_poll(struct net_device 
   58.41  		skb->len  = rx->status;
   58.42  		skb->tail = skb->data + skb->len;
   58.43  
   58.44 -		if (rx->flags & NETRXF_data_validated)
   58.45 +		/*
   58.46 +		 * Old backends do not assert data_validated but we
   58.47 +		 * can infer it from csum_blank so test both flags.
   58.48 +		 */
   58.49 +		if (rx->flags & (NETRXF_data_validated|NETRXF_csum_blank)) {
   58.50  			skb->ip_summed = CHECKSUM_UNNECESSARY;
   58.51 +			skb->proto_data_valid = 1;
   58.52 +		} else {
   58.53 +			skb->ip_summed = CHECKSUM_NONE;
   58.54 +			skb->proto_data_valid = 0;
   58.55 +		}
   58.56 +		skb->proto_csum_blank = !!(rx->flags & NETRXF_csum_blank);
   58.57  
   58.58  		np->stats.rx_packets++;
   58.59  		np->stats.rx_bytes += rx->status;
   58.60 @@ -978,8 +988,8 @@ static void network_connect(struct net_d
   58.61  	 * the RX ring because some of our pages are currently flipped out
   58.62  	 * so we can't just free the RX skbs.
   58.63  	 * NB2. Freelist index entries are always going to be less than
   58.64 -	 *  __PAGE_OFFSET, whereas pointers to skbs will always be equal or
   58.65 -	 * greater than __PAGE_OFFSET: we use this property to distinguish
   58.66 +	 *  PAGE_OFFSET, whereas pointers to skbs will always be equal or
   58.67 +	 * greater than PAGE_OFFSET: we use this property to distinguish
   58.68  	 * them.
   58.69  	 */
   58.70  
   58.71 @@ -990,7 +1000,7 @@ static void network_connect(struct net_d
   58.72  	 * interface has been down.
   58.73  	 */
   58.74  	for (requeue_idx = 0, i = 1; i <= NET_TX_RING_SIZE; i++) {
   58.75 -		if ((unsigned long)np->tx_skbs[i] < __PAGE_OFFSET)
   58.76 +		if ((unsigned long)np->tx_skbs[i] < PAGE_OFFSET)
   58.77  			continue;
   58.78  
   58.79  		skb = np->tx_skbs[i];
   58.80 @@ -1006,8 +1016,11 @@ static void network_connect(struct net_d
   58.81  		tx->gref = np->grant_tx_ref[i];
   58.82  		tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
   58.83  		tx->size = skb->len;
   58.84 -		tx->flags = (skb->ip_summed == CHECKSUM_HW) ?
   58.85 -			NETTXF_csum_blank : 0;
   58.86 +		tx->flags = 0;
   58.87 +		if (skb->ip_summed == CHECKSUM_HW) /* local packet? */
   58.88 +			tx->flags |= NETTXF_csum_blank | NETTXF_data_validated;
   58.89 +		if (skb->proto_data_valid) /* remote but checksummed? */
   58.90 +			tx->flags |= NETTXF_data_validated;
   58.91  
   58.92  		np->stats.tx_bytes += skb->len;
   58.93  		np->stats.tx_packets++;
   58.94 @@ -1018,7 +1031,7 @@ static void network_connect(struct net_d
   58.95  
   58.96  	/* Rebuild the RX buffer freelist and the RX ring itself. */
   58.97  	for (requeue_idx = 0, i = 1; i <= NET_RX_RING_SIZE; i++) {
   58.98 -		if ((unsigned long)np->rx_skbs[i] < __PAGE_OFFSET)
   58.99 +		if ((unsigned long)np->rx_skbs[i] < PAGE_OFFSET)
  58.100  			continue;
  58.101  		gnttab_grant_foreign_transfer_ref(
  58.102  			np->grant_rx_ref[i], np->xbdev->otherend_id,
  58.103 @@ -1216,7 +1229,7 @@ static void netfront_closing(struct xenb
  58.104  
  58.105  	close_netdev(info);
  58.106  
  58.107 -	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
  58.108 +	xenbus_switch_state(dev, XenbusStateClosed);
  58.109  }
  58.110  
  58.111  
    59.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c	Tue Apr 11 13:55:47 2006 -0600
    59.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/conf_space.c	Tue Apr 11 18:54:18 2006 -0600
    59.3 @@ -106,7 +106,7 @@ static inline int valid_request(int offs
    59.4  }
    59.5  
    59.6  static inline u32 merge_value(u32 val, u32 new_val, u32 new_val_mask,
    59.7 -			      u32 offset)
    59.8 +			      int offset)
    59.9  {
   59.10  	if (offset >= 0) {
   59.11  		new_val_mask <<= (offset * 8);
   59.12 @@ -180,7 +180,8 @@ int pciback_config_read(struct pci_dev *
   59.13  
   59.14  		if ((req_start >= field_start && req_start < field_end)
   59.15  		    || (req_end > field_start && req_end <= field_end)) {
   59.16 -			err = conf_space_read(dev, cfg_entry, offset, &tmp_val);
   59.17 +			err = conf_space_read(dev, cfg_entry, field_start,
   59.18 +					      &tmp_val);
   59.19  			if (err)
   59.20  				goto out;
   59.21  
   59.22 @@ -228,14 +229,16 @@ int pciback_config_write(struct pci_dev 
   59.23  		    || (req_end > field_start && req_end <= field_end)) {
   59.24  			tmp_val = 0;
   59.25  
   59.26 -			err = pciback_config_read(dev, offset, size, &tmp_val);
   59.27 +			err = pciback_config_read(dev, field_start,
   59.28 +						  field->size, &tmp_val);
   59.29  			if (err)
   59.30  				break;
   59.31  
   59.32  			tmp_val = merge_value(tmp_val, value, get_mask(size),
   59.33 -					      field_start - req_start);
   59.34 +					      req_start - field_start);
   59.35  
   59.36 -			err = conf_space_write(dev, cfg_entry, offset, tmp_val);
   59.37 +			err = conf_space_write(dev, cfg_entry, field_start,
   59.38 +					       tmp_val);
   59.39  			handled = 1;
   59.40  		}
   59.41  	}
    60.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Tue Apr 11 13:55:47 2006 -0600
    60.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Tue Apr 11 18:54:18 2006 -0600
    60.3 @@ -16,7 +16,7 @@ static struct pciback_device *alloc_pdev
    60.4  {
    60.5  	struct pciback_device *pdev;
    60.6  
    60.7 -	pdev = kmalloc(sizeof(struct pciback_device), GFP_KERNEL);
    60.8 +	pdev = kzalloc(sizeof(struct pciback_device), GFP_KERNEL);
    60.9  	if (pdev == NULL)
   60.10  		goto out;
   60.11  	dev_dbg(&xdev->dev, "allocated pdev @ 0x%p\n", pdev);
   60.12 @@ -137,7 +137,7 @@ static int pciback_attach(struct pciback
   60.13  
   60.14  	dev_dbg(&pdev->xdev->dev, "Connecting...\n");
   60.15  
   60.16 -	err = xenbus_switch_state(pdev->xdev, XBT_NULL, XenbusStateConnected);
   60.17 +	err = xenbus_switch_state(pdev->xdev, XenbusStateConnected);
   60.18  	if (err)
   60.19  		xenbus_dev_fatal(pdev->xdev, err,
   60.20  				 "Error switching to connected state!");
   60.21 @@ -165,7 +165,7 @@ static void pciback_frontend_changed(str
   60.22  		break;
   60.23  
   60.24  	case XenbusStateClosing:
   60.25 -		xenbus_switch_state(xdev, XBT_NULL, XenbusStateClosing);
   60.26 +		xenbus_switch_state(xdev, XenbusStateClosing);
   60.27  		break;
   60.28  
   60.29  	case XenbusStateClosed:
   60.30 @@ -341,7 +341,7 @@ static int pciback_setup_backend(struct 
   60.31  		goto out;
   60.32  	}
   60.33  
   60.34 -	err = xenbus_switch_state(pdev->xdev, XBT_NULL, XenbusStateInitialised);
   60.35 +	err = xenbus_switch_state(pdev->xdev, XenbusStateInitialised);
   60.36  	if (err)
   60.37  		xenbus_dev_fatal(pdev->xdev, err,
   60.38  				 "Error switching to initialised state!");
   60.39 @@ -386,7 +386,7 @@ static int pciback_xenbus_probe(struct x
   60.40  	}
   60.41  
   60.42  	/* wait for xend to configure us */
   60.43 -	err = xenbus_switch_state(dev, XBT_NULL, XenbusStateInitWait);
   60.44 +	err = xenbus_switch_state(dev, XenbusStateInitWait);
   60.45  	if (err)
   60.46  		goto out;
   60.47  
    61.1 --- a/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c	Tue Apr 11 13:55:47 2006 -0600
    61.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/xenbus.c	Tue Apr 11 18:54:18 2006 -0600
    61.3 @@ -96,10 +96,6 @@ static int pcifront_publish_info(struct 
    61.4  	if (!err)
    61.5  		err = xenbus_printf(trans, pdev->xdev->nodename,
    61.6  				    "magic", XEN_PCI_MAGIC);
    61.7 -	if (!err)
    61.8 -		err =
    61.9 -		    xenbus_switch_state(pdev->xdev, trans,
   61.10 -					XenbusStateInitialised);
   61.11  
   61.12  	if (err) {
   61.13  		xenbus_transaction_end(trans, 1);
   61.14 @@ -118,6 +114,8 @@ static int pcifront_publish_info(struct 
   61.15  		}
   61.16  	}
   61.17  
   61.18 +	xenbus_switch_state(pdev->xdev, XenbusStateInitialised);
   61.19 +
   61.20  	dev_dbg(&pdev->xdev->dev, "publishing successful!\n");
   61.21  
   61.22        out:
   61.23 @@ -186,7 +184,7 @@ static int pcifront_try_connect(struct p
   61.24  		}
   61.25  	}
   61.26  
   61.27 -	err = xenbus_switch_state(pdev->xdev, XBT_NULL, XenbusStateConnected);
   61.28 +	err = xenbus_switch_state(pdev->xdev, XenbusStateConnected);
   61.29  	if (err)
   61.30  		goto out;
   61.31  
   61.32 @@ -205,8 +203,7 @@ static int pcifront_try_disconnect(struc
   61.33  	prev_state = xenbus_read_driver_state(pdev->xdev->nodename);
   61.34  
   61.35  	if (prev_state < XenbusStateClosing)
   61.36 -		err = xenbus_switch_state(pdev->xdev, XBT_NULL,
   61.37 -					XenbusStateClosing);
   61.38 +		err = xenbus_switch_state(pdev->xdev, XenbusStateClosing);
   61.39  
   61.40  	if (!err && prev_state == XenbusStateConnected)
   61.41  		pcifront_disconnect(pdev);
    62.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Tue Apr 11 13:55:47 2006 -0600
    62.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Tue Apr 11 18:54:18 2006 -0600
    62.3 @@ -277,6 +277,7 @@ static int __init privcmd_init(void)
    62.4  	set_bit(__HYPERVISOR_mmu_update,       hypercall_permission_map);
    62.5  	set_bit(__HYPERVISOR_mmuext_op,        hypercall_permission_map);
    62.6  	set_bit(__HYPERVISOR_xen_version,      hypercall_permission_map);
    62.7 +	set_bit(__HYPERVISOR_sched_op,         hypercall_permission_map);
    62.8  
    62.9  	privcmd_intf = create_xen_proc_entry("privcmd", 0400);
   62.10  	if (privcmd_intf != NULL)
    63.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Tue Apr 11 13:55:47 2006 -0600
    63.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Tue Apr 11 18:54:18 2006 -0600
    63.3 @@ -55,6 +55,7 @@ static int tpmback_remove(struct xenbus_
    63.4  		be->backend_watch.node = NULL;
    63.5  	}
    63.6  	if (be->tpmif) {
    63.7 +		vtpm_release_packets(be->tpmif, 0);
    63.8  		tpmif_put(be->tpmif);
    63.9  		be->tpmif = NULL;
   63.10  	}
   63.11 @@ -87,7 +88,7 @@ static int tpmback_probe(struct xenbus_d
   63.12  		goto fail;
   63.13  	}
   63.14  
   63.15 -	err = xenbus_switch_state(dev, XBT_NULL, XenbusStateInitWait);
   63.16 +	err = xenbus_switch_state(dev, XenbusStateInitWait);
   63.17  	if (err) {
   63.18  		goto fail;
   63.19  	}
   63.20 @@ -175,7 +176,7 @@ static void frontend_changed(struct xenb
   63.21  		break;
   63.22  
   63.23  	case XenbusStateClosing:
   63.24 -		xenbus_switch_state(dev, XBT_NULL, XenbusStateClosing);
   63.25 +		xenbus_switch_state(dev, XenbusStateClosing);
   63.26  		break;
   63.27  
   63.28  	case XenbusStateClosed:
   63.29 @@ -247,18 +248,15 @@ again:
   63.30  		goto abort;
   63.31  	}
   63.32  
   63.33 -	err = xenbus_switch_state(dev, xbt, XenbusStateConnected);
   63.34 -	if (err)
   63.35 -		goto abort;
   63.36 -
   63.37 -	be->tpmif->status = CONNECTED;
   63.38 -
   63.39  	err = xenbus_transaction_end(xbt, 0);
   63.40  	if (err == -EAGAIN)
   63.41  		goto again;
   63.42 -	if (err) {
   63.43 +	if (err)
   63.44  		xenbus_dev_fatal(be->dev, err, "end of transaction");
   63.45 -	}
   63.46 +
   63.47 +	err = xenbus_switch_state(dev, XenbusStateConnected);
   63.48 +	if (!err)
   63.49 +		be->tpmif->status = CONNECTED;
   63.50  	return;
   63.51  abort:
   63.52  	xenbus_transaction_end(xbt, 1);
    64.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Tue Apr 11 13:55:47 2006 -0600
    64.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Tue Apr 11 18:54:18 2006 -0600
    64.3 @@ -65,14 +65,18 @@ static irqreturn_t tpmif_int(int irq,
    64.4                               void *tpm_priv,
    64.5                               struct pt_regs *ptregs);
    64.6  static void tpmif_rx_action(unsigned long unused);
    64.7 -static void tpmif_connect(struct tpm_private *tp, domid_t domid);
    64.8 +static int tpmif_connect(struct xenbus_device *dev,
    64.9 +                         struct tpm_private *tp,
   64.10 +                         domid_t domid);
   64.11  static DECLARE_TASKLET(tpmif_rx_tasklet, tpmif_rx_action, 0);
   64.12 -static int tpm_allocate_buffers(struct tpm_private *tp);
   64.13 +static int tpmif_allocate_tx_buffers(struct tpm_private *tp);
   64.14 +static void tpmif_free_tx_buffers(struct tpm_private *tp);
   64.15  static void tpmif_set_connected_state(struct tpm_private *tp,
   64.16                                        u8 newstate);
   64.17  static int tpm_xmit(struct tpm_private *tp,
   64.18                      const u8 * buf, size_t count, int userbuffer,
   64.19                      void *remember);
   64.20 +static void destroy_tpmring(struct tpm_private *tp);
   64.21  
   64.22  #define DPRINTK(fmt, args...) \
   64.23      pr_debug("xen_tpm_fr (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args)
   64.24 @@ -81,6 +85,8 @@ static int tpm_xmit(struct tpm_private *
   64.25  #define WPRINTK(fmt, args...) \
   64.26      printk(KERN_WARNING "xen_tpm_fr: " fmt, ##args)
   64.27  
   64.28 +#define GRANT_INVALID_REF	0
   64.29 +
   64.30  
   64.31  static inline int
   64.32  tx_buffer_copy(struct tx_buffer *txb, const u8 * src, int len,
   64.33 @@ -119,6 +125,14 @@ static inline struct tx_buffer *tx_buffe
   64.34  }
   64.35  
   64.36  
   64.37 +static inline void tx_buffer_free(struct tx_buffer *txb)
   64.38 +{
   64.39 +	if (txb) {
   64.40 +		free_page((long)txb->data);
   64.41 +		kfree(txb);
   64.42 +	}
   64.43 +}
   64.44 +
   64.45  /**************************************************************
   64.46   Utility function for the tpm_private structure
   64.47  **************************************************************/
   64.48 @@ -128,23 +142,29 @@ static inline void tpm_private_init(stru
   64.49  	init_waitqueue_head(&tp->wait_q);
   64.50  }
   64.51  
   64.52 +static inline void tpm_private_free(void)
   64.53 +{
   64.54 +	tpmif_free_tx_buffers(my_priv);
   64.55 +	kfree(my_priv);
   64.56 +	my_priv = NULL;
   64.57 +}
   64.58 +
   64.59  static struct tpm_private *tpm_private_get(void)
   64.60  {
   64.61 +	int err;
   64.62  	if (!my_priv) {
   64.63  		my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL);
   64.64  		if (my_priv) {
   64.65  			tpm_private_init(my_priv);
   64.66 +			err = tpmif_allocate_tx_buffers(my_priv);
   64.67 +			if (err < 0) {
   64.68 +				tpm_private_free();
   64.69 +			}
   64.70  		}
   64.71  	}
   64.72  	return my_priv;
   64.73  }
   64.74  
   64.75 -static inline void tpm_private_free(void)
   64.76 -{
   64.77 -	kfree(my_priv);
   64.78 -	my_priv = NULL;
   64.79 -}
   64.80 -
   64.81  /**************************************************************
   64.82  
   64.83   The interface to let the tpm plugin register its callback
   64.84 @@ -233,6 +253,8 @@ static int setup_tpmring(struct xenbus_d
   64.85  	tpmif_tx_interface_t *sring;
   64.86  	int err;
   64.87  
   64.88 +	tp->ring_ref = GRANT_INVALID_REF;
   64.89 +
   64.90  	sring = (void *)__get_free_page(GFP_KERNEL);
   64.91  	if (!sring) {
   64.92  		xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
   64.93 @@ -240,8 +262,6 @@ static int setup_tpmring(struct xenbus_d
   64.94  	}
   64.95  	tp->tx = sring;
   64.96  
   64.97 -	tpm_allocate_buffers(tp);
   64.98 -
   64.99  	err = xenbus_grant_ring(dev, virt_to_mfn(tp->tx));
  64.100  	if (err < 0) {
  64.101  		free_page((unsigned long)sring);
  64.102 @@ -251,14 +271,13 @@ static int setup_tpmring(struct xenbus_d
  64.103  	}
  64.104  	tp->ring_ref = err;
  64.105  
  64.106 -	err = xenbus_alloc_evtchn(dev, &tp->evtchn);
  64.107 +	err = tpmif_connect(dev, tp, dev->otherend_id);
  64.108  	if (err)
  64.109  		goto fail;
  64.110  
  64.111 -	tpmif_connect(tp, dev->otherend_id);
  64.112 -
  64.113  	return 0;
  64.114  fail:
  64.115 +	destroy_tpmring(tp);
  64.116  	return err;
  64.117  }
  64.118  
  64.119 @@ -266,14 +285,17 @@ fail:
  64.120  static void destroy_tpmring(struct tpm_private *tp)
  64.121  {
  64.122  	tpmif_set_connected_state(tp, 0);
  64.123 -	if (tp->tx != NULL) {
  64.124 +
  64.125 +	if (tp->ring_ref != GRANT_INVALID_REF) {
  64.126  		gnttab_end_foreign_access(tp->ring_ref, 0,
  64.127  					  (unsigned long)tp->tx);
  64.128 +		tp->ring_ref = GRANT_INVALID_REF;
  64.129  		tp->tx = NULL;
  64.130  	}
  64.131  
  64.132  	if (tp->irq)
  64.133 -		unbind_from_irqhandler(tp->irq, NULL);
  64.134 +		unbind_from_irqhandler(tp->irq, tp);
  64.135 +
  64.136  	tp->evtchn = tp->irq = 0;
  64.137  }
  64.138  
  64.139 @@ -377,6 +399,9 @@ static int tpmfront_probe(struct xenbus_
  64.140  	int handle;
  64.141  	struct tpm_private *tp = tpm_private_get();
  64.142  
  64.143 +	if (!tp)
  64.144 +		return -ENOMEM;
  64.145 +
  64.146  	err = xenbus_scanf(XBT_NULL, dev->nodename,
  64.147  	                   "handle", "%i", &handle);
  64.148  	if (XENBUS_EXIST_ERR(err))
  64.149 @@ -402,15 +427,14 @@ static int tpmfront_probe(struct xenbus_
  64.150  
  64.151  static int tpmfront_remove(struct xenbus_device *dev)
  64.152  {
  64.153 -	struct tpm_private *tp = dev->data;
  64.154 +	struct tpm_private *tp = (struct tpm_private *)dev->data;
  64.155  	destroy_tpmring(tp);
  64.156  	return 0;
  64.157  }
  64.158  
  64.159 -static int
  64.160 -tpmfront_suspend(struct xenbus_device *dev)
  64.161 +static int tpmfront_suspend(struct xenbus_device *dev)
  64.162  {
  64.163 -	struct tpm_private *tp = dev->data;
  64.164 +	struct tpm_private *tp = (struct tpm_private *)dev->data;
  64.165  	u32 ctr;
  64.166  
  64.167  	/* lock, so no app can send */
  64.168 @@ -437,29 +461,35 @@ tpmfront_suspend(struct xenbus_device *d
  64.169  	return 0;
  64.170  }
  64.171  
  64.172 -static int
  64.173 -tpmfront_resume(struct xenbus_device *dev)
  64.174 +static int tpmfront_resume(struct xenbus_device *dev)
  64.175  {
  64.176 -	struct tpm_private *tp = dev->data;
  64.177 +	struct tpm_private *tp = (struct tpm_private *)dev->data;
  64.178 +	destroy_tpmring(tp);
  64.179  	return talk_to_backend(dev, tp);
  64.180  }
  64.181  
  64.182 -static void
  64.183 -tpmif_connect(struct tpm_private *tp, domid_t domid)
  64.184 +static int tpmif_connect(struct xenbus_device *dev,
  64.185 +                         struct tpm_private *tp,
  64.186 +                         domid_t domid)
  64.187  {
  64.188  	int err;
  64.189  
  64.190  	tp->backend_id = domid;
  64.191  
  64.192 +	err = xenbus_alloc_evtchn(dev, &tp->evtchn);
  64.193 +	if (err)
  64.194 +		return err;
  64.195 +
  64.196  	err = bind_evtchn_to_irqhandler(tp->evtchn,
  64.197  					tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
  64.198  					tp);
  64.199  	if (err <= 0) {
  64.200  		WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
  64.201 -		return;
  64.202 +		return err;
  64.203  	}
  64.204  
  64.205  	tp->irq = err;
  64.206 +	return 0;
  64.207  }
  64.208  
  64.209  static struct xenbus_device_id tpmfront_ids[] = {
  64.210 @@ -488,19 +518,30 @@ static void __exit exit_tpm_xenbus(void)
  64.211  	xenbus_unregister_driver(&tpmfront);
  64.212  }
  64.213  
  64.214 -
  64.215 -static int
  64.216 -tpm_allocate_buffers(struct tpm_private *tp)
  64.217 +static int tpmif_allocate_tx_buffers(struct tpm_private *tp)
  64.218  {
  64.219  	unsigned int i;
  64.220  
  64.221 -	for (i = 0; i < TPMIF_TX_RING_SIZE; i++)
  64.222 +	for (i = 0; i < TPMIF_TX_RING_SIZE; i++) {
  64.223  		tp->tx_buffers[i] = tx_buffer_alloc();
  64.224 -	return 1;
  64.225 +		if (!tp->tx_buffers[i]) {
  64.226 +			tpmif_free_tx_buffers(tp);
  64.227 +			return -ENOMEM;
  64.228 +		}
  64.229 +	}
  64.230 +	return 0;
  64.231  }
  64.232  
  64.233 -static void
  64.234 -tpmif_rx_action(unsigned long priv)
  64.235 +static void tpmif_free_tx_buffers(struct tpm_private *tp)
  64.236 +{
  64.237 +	unsigned int i;
  64.238 +
  64.239 +	for (i = 0; i < TPMIF_TX_RING_SIZE; i++) {
  64.240 +		tx_buffer_free(tp->tx_buffers[i]);
  64.241 +	}
  64.242 +}
  64.243 +
  64.244 +static void tpmif_rx_action(unsigned long priv)
  64.245  {
  64.246  	struct tpm_private *tp = (struct tpm_private *)priv;
  64.247  
  64.248 @@ -545,8 +586,7 @@ exit:
  64.249  }
  64.250  
  64.251  
  64.252 -static irqreturn_t
  64.253 -tpmif_int(int irq, void *tpm_priv, struct pt_regs *ptregs)
  64.254 +static irqreturn_t tpmif_int(int irq, void *tpm_priv, struct pt_regs *ptregs)
  64.255  {
  64.256  	struct tpm_private *tp = tpm_priv;
  64.257  	unsigned long flags;
  64.258 @@ -560,10 +600,9 @@ tpmif_int(int irq, void *tpm_priv, struc
  64.259  }
  64.260  
  64.261  
  64.262 -static int
  64.263 -tpm_xmit(struct tpm_private *tp,
  64.264 -         const u8 * buf, size_t count, int isuserbuffer,
  64.265 -         void *remember)
  64.266 +static int tpm_xmit(struct tpm_private *tp,
  64.267 +                    const u8 * buf, size_t count, int isuserbuffer,
  64.268 +                    void *remember)
  64.269  {
  64.270  	tpmif_tx_request_t *tx;
  64.271  	TPMIF_RING_IDX i;
  64.272 @@ -693,8 +732,7 @@ static void tpmif_set_connected_state(st
  64.273   * =================================================================
  64.274   */
  64.275  
  64.276 -static int __init
  64.277 -tpmif_init(void)
  64.278 +static int __init tpmif_init(void)
  64.279  {
  64.280  	IPRINTK("Initialising the vTPM driver.\n");
  64.281  	if ( gnttab_alloc_grant_references ( TPMIF_TX_RING_SIZE,
  64.282 @@ -709,8 +747,7 @@ tpmif_init(void)
  64.283  
  64.284  module_init(tpmif_init);
  64.285  
  64.286 -static void __exit
  64.287 -tpmif_exit(void)
  64.288 +static void __exit tpmif_exit(void)
  64.289  {
  64.290  	exit_tpm_xenbus();
  64.291  	gnttab_free_grant_references(gref_head);
    65.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile	Tue Apr 11 13:55:47 2006 -0600
    65.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile	Tue Apr 11 18:54:18 2006 -0600
    65.3 @@ -1,4 +1,8 @@
    65.4  obj-y	+= xenbus.o
    65.5 +obj-$(CONFIG_XEN_BACKEND) += xenbus_be.o
    65.6 +
    65.7 +xenbus_be-objs =
    65.8 +xenbus_be-objs += xenbus_backend_client.o
    65.9  
   65.10  xenbus-objs =
   65.11  xenbus-objs += xenbus_client.o
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_backend_client.c	Tue Apr 11 18:54:18 2006 -0600
    66.3 @@ -0,0 +1,173 @@
    66.4 +/******************************************************************************
    66.5 + * Backend-client-facing interface for the Xenbus driver.  In other words, the
    66.6 + * interface between the Xenbus and the device-specific code in the backend
    66.7 + * driver.
    66.8 + *
    66.9 + * Copyright (C) 2005-2006 XenSource Ltd
   66.10 + * 
   66.11 + * This program is free software; you can redistribute it and/or
   66.12 + * modify it under the terms of the GNU General Public License version 2
   66.13 + * as published by the Free Software Foundation; or, when distributed
   66.14 + * separately from the Linux kernel or incorporated into other
   66.15 + * software packages, subject to the following license:
   66.16 + * 
   66.17 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   66.18 + * of this source file (the "Software"), to deal in the Software without
   66.19 + * restriction, including without limitation the rights to use, copy, modify,
   66.20 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   66.21 + * and to permit persons to whom the Software is furnished to do so, subject to
   66.22 + * the following conditions:
   66.23 + * 
   66.24 + * The above copyright notice and this permission notice shall be included in
   66.25 + * all copies or substantial portions of the Software.
   66.26 + * 
   66.27 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   66.28 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   66.29 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   66.30 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   66.31 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   66.32 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   66.33 + * IN THE SOFTWARE.
   66.34 + */
   66.35 +
   66.36 +#include <xen/gnttab.h>
   66.37 +#include <xen/xenbus.h>
   66.38 +#include <xen/driver_util.h>
   66.39 +
   66.40 +/* Based on Rusty Russell's skeleton driver's map_page */
   66.41 +int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
   66.42 +{
   66.43 +	struct gnttab_map_grant_ref op = {
   66.44 +		.flags = GNTMAP_host_map,
   66.45 +		.ref   = gnt_ref,
   66.46 +		.dom   = dev->otherend_id,
   66.47 +	};
   66.48 +	struct vm_struct *area;
   66.49 +
   66.50 +	*vaddr = NULL;
   66.51 +
   66.52 +	area = alloc_vm_area(PAGE_SIZE);
   66.53 +	if (!area)
   66.54 +		return -ENOMEM;
   66.55 +
   66.56 +	op.host_addr = (unsigned long)area->addr;
   66.57 +
   66.58 +	lock_vm_area(area);
   66.59 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   66.60 +	unlock_vm_area(area);
   66.61 +
   66.62 +	if (op.status != GNTST_okay) {
   66.63 +		free_vm_area(area);
   66.64 +		xenbus_dev_fatal(dev, op.status,
   66.65 +				 "mapping in shared page %d from domain %d",
   66.66 +				 gnt_ref, dev->otherend_id);
   66.67 +		return op.status;
   66.68 +	}
   66.69 +
   66.70 +	/* Stuff the handle in an unused field */
   66.71 +	area->phys_addr = (unsigned long)op.handle;
   66.72 +
   66.73 +	*vaddr = area->addr;
   66.74 +	return 0;
   66.75 +}
   66.76 +EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
   66.77 +
   66.78 +
   66.79 +int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
   66.80 +		   grant_handle_t *handle, void *vaddr)
   66.81 +{
   66.82 +	struct gnttab_map_grant_ref op = {
   66.83 +		.host_addr = (unsigned long)vaddr,
   66.84 +		.flags     = GNTMAP_host_map,
   66.85 +		.ref       = gnt_ref,
   66.86 +		.dom       = dev->otherend_id,
   66.87 +	};
   66.88 +
   66.89 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   66.90 +
   66.91 +	if (op.status != GNTST_okay) {
   66.92 +		xenbus_dev_fatal(dev, op.status,
   66.93 +				 "mapping in shared page %d from domain %d",
   66.94 +				 gnt_ref, dev->otherend_id);
   66.95 +	} else
   66.96 +		*handle = op.handle;
   66.97 +
   66.98 +	return op.status;
   66.99 +}
  66.100 +EXPORT_SYMBOL_GPL(xenbus_map_ring);
  66.101 +
  66.102 +
  66.103 +/* Based on Rusty Russell's skeleton driver's unmap_page */
  66.104 +int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
  66.105 +{
  66.106 +	struct vm_struct *area;
  66.107 +	struct gnttab_unmap_grant_ref op = {
  66.108 +		.host_addr = (unsigned long)vaddr,
  66.109 +	};
  66.110 +
  66.111 +	/* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
  66.112 +	 * method so that we don't have to muck with vmalloc internals here.
  66.113 +	 * We could force the user to hang on to their struct vm_struct from
  66.114 +	 * xenbus_map_ring_valloc, but these 6 lines considerably simplify
  66.115 +	 * this API.
  66.116 +	 */
  66.117 +	read_lock(&vmlist_lock);
  66.118 +	for (area = vmlist; area != NULL; area = area->next) {
  66.119 +		if (area->addr == vaddr)
  66.120 +			break;
  66.121 +	}
  66.122 +	read_unlock(&vmlist_lock);
  66.123 +
  66.124 +	if (!area) {
  66.125 +		xenbus_dev_error(dev, -ENOENT,
  66.126 +				 "can't find mapped virtual address %p", vaddr);
  66.127 +		return GNTST_bad_virt_addr;
  66.128 +	}
  66.129 +
  66.130 +	op.handle = (grant_handle_t)area->phys_addr;
  66.131 +
  66.132 +	lock_vm_area(area);
  66.133 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  66.134 +	unlock_vm_area(area);
  66.135 +
  66.136 +	if (op.status == GNTST_okay)
  66.137 +		free_vm_area(area);
  66.138 +	else
  66.139 +		xenbus_dev_error(dev, op.status,
  66.140 +				 "unmapping page at handle %d error %d",
  66.141 +				 (int16_t)area->phys_addr, op.status);
  66.142 +
  66.143 +	return op.status;
  66.144 +}
  66.145 +EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
  66.146 +
  66.147 +
  66.148 +int xenbus_unmap_ring(struct xenbus_device *dev,
  66.149 +		     grant_handle_t handle, void *vaddr)
  66.150 +{
  66.151 +	struct gnttab_unmap_grant_ref op = {
  66.152 +		.host_addr = (unsigned long)vaddr,
  66.153 +		.handle    = handle,
  66.154 +	};
  66.155 +
  66.156 +	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  66.157 +
  66.158 +	if (op.status != GNTST_okay)
  66.159 +		xenbus_dev_error(dev, op.status,
  66.160 +				 "unmapping page at handle %d error %d",
  66.161 +				 handle, op.status);
  66.162 +
  66.163 +	return op.status;
  66.164 +}
  66.165 +EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
  66.166 +
  66.167 +
  66.168 +/*
  66.169 + * Local variables:
  66.170 + *  c-file-style: "linux"
  66.171 + *  indent-tabs-mode: t
  66.172 + *  c-indent-level: 8
  66.173 + *  c-basic-offset: 8
  66.174 + *  tab-width: 8
  66.175 + * End:
  66.176 + */
    67.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Tue Apr 11 13:55:47 2006 -0600
    67.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Tue Apr 11 18:54:18 2006 -0600
    67.3 @@ -84,9 +84,7 @@ int xenbus_watch_path2(struct xenbus_dev
    67.4  EXPORT_SYMBOL_GPL(xenbus_watch_path2);
    67.5  
    67.6  
    67.7 -int xenbus_switch_state(struct xenbus_device *dev,
    67.8 -			xenbus_transaction_t xbt,
    67.9 -			XenbusState state)
   67.10 +int xenbus_switch_state(struct xenbus_device *dev, XenbusState state)
   67.11  {
   67.12  	/* We check whether the state is currently set to the given value, and
   67.13  	   if not, then the state is set.  We don't want to unconditionally
   67.14 @@ -94,6 +92,12 @@ int xenbus_switch_state(struct xenbus_de
   67.15  	   unnecessarily.  Furthermore, if the node has gone, we don't write
   67.16  	   to it, as the device will be tearing down, and we don't want to
   67.17  	   resurrect that directory.
   67.18 +
   67.19 +	   Note that, because of this cached value of our state, this function
   67.20 +	   will not work inside a Xenstore transaction (something it was
   67.21 +	   trying to in the past) because dev->state would not get reset if
   67.22 +	   the transaction was aborted.
   67.23 +
   67.24  	 */
   67.25  
   67.26  	int current_state;
   67.27 @@ -102,12 +106,12 @@ int xenbus_switch_state(struct xenbus_de
   67.28  	if (state == dev->state)
   67.29  		return 0;
   67.30  
   67.31 -	err = xenbus_scanf(xbt, dev->nodename, "state", "%d",
   67.32 -			       &current_state);
   67.33 +	err = xenbus_scanf(XBT_NULL, dev->nodename, "state", "%d",
   67.34 +			   &current_state);
   67.35  	if (err != 1)
   67.36  		return 0;
   67.37  
   67.38 -	err = xenbus_printf(xbt, dev->nodename, "state", "%d", state);
   67.39 +	err = xenbus_printf(XBT_NULL, dev->nodename, "state", "%d", state);
   67.40  	if (err) {
   67.41  		if (state != XenbusStateClosing) /* Avoid looping */
   67.42  			xenbus_dev_fatal(dev, err, "writing new state");
   67.43 @@ -193,7 +197,7 @@ void xenbus_dev_fatal(struct xenbus_devi
   67.44  	_dev_error(dev, err, fmt, ap);
   67.45  	va_end(ap);
   67.46  
   67.47 -	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosing);
   67.48 +	xenbus_switch_state(dev, XenbusStateClosing);
   67.49  }
   67.50  EXPORT_SYMBOL_GPL(xenbus_dev_fatal);
   67.51  
   67.52 @@ -257,134 +261,6 @@ int xenbus_free_evtchn(struct xenbus_dev
   67.53  }
   67.54  
   67.55  
   67.56 -/* Based on Rusty Russell's skeleton driver's map_page */
   67.57 -int xenbus_map_ring_valloc(struct xenbus_device *dev, int gnt_ref, void **vaddr)
   67.58 -{
   67.59 -	struct gnttab_map_grant_ref op = {
   67.60 -		.flags = GNTMAP_host_map,
   67.61 -		.ref   = gnt_ref,
   67.62 -		.dom   = dev->otherend_id,
   67.63 -	};
   67.64 -	struct vm_struct *area;
   67.65 -
   67.66 -	*vaddr = NULL;
   67.67 -
   67.68 -	area = alloc_vm_area(PAGE_SIZE);
   67.69 -	if (!area)
   67.70 -		return -ENOMEM;
   67.71 -
   67.72 -	op.host_addr = (unsigned long)area->addr;
   67.73 -
   67.74 -	lock_vm_area(area);
   67.75 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   67.76 -	unlock_vm_area(area);
   67.77 -
   67.78 -	if (op.status != GNTST_okay) {
   67.79 -		free_vm_area(area);
   67.80 -		xenbus_dev_fatal(dev, op.status,
   67.81 -				 "mapping in shared page %d from domain %d",
   67.82 -				 gnt_ref, dev->otherend_id);
   67.83 -		return op.status;
   67.84 -	}
   67.85 -
   67.86 -	/* Stuff the handle in an unused field */
   67.87 -	area->phys_addr = (unsigned long)op.handle;
   67.88 -
   67.89 -	*vaddr = area->addr;
   67.90 -	return 0;
   67.91 -}
   67.92 -EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc);
   67.93 -
   67.94 -
   67.95 -int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
   67.96 -		   grant_handle_t *handle, void *vaddr)
   67.97 -{
   67.98 -	struct gnttab_map_grant_ref op = {
   67.99 -		.host_addr = (unsigned long)vaddr,
  67.100 -		.flags     = GNTMAP_host_map,
  67.101 -		.ref       = gnt_ref,
  67.102 -		.dom       = dev->otherend_id,
  67.103 -	};
  67.104 -
  67.105 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
  67.106 -
  67.107 -	if (op.status != GNTST_okay) {
  67.108 -		xenbus_dev_fatal(dev, op.status,
  67.109 -				 "mapping in shared page %d from domain %d",
  67.110 -				 gnt_ref, dev->otherend_id);
  67.111 -	} else
  67.112 -		*handle = op.handle;
  67.113 -
  67.114 -	return op.status;
  67.115 -}
  67.116 -EXPORT_SYMBOL_GPL(xenbus_map_ring);
  67.117 -
  67.118 -
  67.119 -/* Based on Rusty Russell's skeleton driver's unmap_page */
  67.120 -int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr)
  67.121 -{
  67.122 -	struct vm_struct *area;
  67.123 -	struct gnttab_unmap_grant_ref op = {
  67.124 -		.host_addr = (unsigned long)vaddr,
  67.125 -	};
  67.126 -
  67.127 -	/* It'd be nice if linux/vmalloc.h provided a find_vm_area(void *addr)
  67.128 -	 * method so that we don't have to muck with vmalloc internals here.
  67.129 -	 * We could force the user to hang on to their struct vm_struct from
  67.130 -	 * xenbus_map_ring_valloc, but these 6 lines considerably simplify
  67.131 -	 * this API.
  67.132 -	 */
  67.133 -	read_lock(&vmlist_lock);
  67.134 -	for (area = vmlist; area != NULL; area = area->next) {
  67.135 -		if (area->addr == vaddr)
  67.136 -			break;
  67.137 -	}
  67.138 -	read_unlock(&vmlist_lock);
  67.139 -
  67.140 -	if (!area) {
  67.141 -		xenbus_dev_error(dev, -ENOENT,
  67.142 -				 "can't find mapped virtual address %p", vaddr);
  67.143 -		return GNTST_bad_virt_addr;
  67.144 -	}
  67.145 -
  67.146 -	op.handle = (grant_handle_t)area->phys_addr;
  67.147 -
  67.148 -	lock_vm_area(area);
  67.149 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  67.150 -	unlock_vm_area(area);
  67.151 -
  67.152 -	if (op.status == GNTST_okay)
  67.153 -		free_vm_area(area);
  67.154 -	else
  67.155 -		xenbus_dev_error(dev, op.status,
  67.156 -				 "unmapping page at handle %d error %d",
  67.157 -				 (int16_t)area->phys_addr, op.status);
  67.158 -
  67.159 -	return op.status;
  67.160 -}
  67.161 -EXPORT_SYMBOL_GPL(xenbus_unmap_ring_vfree);
  67.162 -
  67.163 -
  67.164 -int xenbus_unmap_ring(struct xenbus_device *dev,
  67.165 -		     grant_handle_t handle, void *vaddr)
  67.166 -{
  67.167 -	struct gnttab_unmap_grant_ref op = {
  67.168 -		.host_addr = (unsigned long)vaddr,
  67.169 -		.handle    = handle,
  67.170 -	};
  67.171 -
  67.172 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
  67.173 -
  67.174 -	if (op.status != GNTST_okay)
  67.175 -		xenbus_dev_error(dev, op.status,
  67.176 -				 "unmapping page at handle %d error %d",
  67.177 -				 handle, op.status);
  67.178 -
  67.179 -	return op.status;
  67.180 -}
  67.181 -EXPORT_SYMBOL_GPL(xenbus_unmap_ring);
  67.182 -
  67.183 -
  67.184  XenbusState xenbus_read_driver_state(const char *path)
  67.185  {
  67.186  	XenbusState result;
    68.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Apr 11 13:55:47 2006 -0600
    68.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Apr 11 18:54:18 2006 -0600
    68.3 @@ -3,7 +3,7 @@
    68.4   *
    68.5   * Copyright (C) 2005 Rusty Russell, IBM Corporation
    68.6   * Copyright (C) 2005 Mike Wray, Hewlett-Packard
    68.7 - * Copyright (C) 2005 XenSource Ltd
    68.8 + * Copyright (C) 2005, 2006 XenSource Ltd
    68.9   * 
   68.10   * This program is free software; you can redistribute it and/or
   68.11   * modify it under the terms of the GNU General Public License version 2
   68.12 @@ -49,6 +49,7 @@
   68.13  #include <xen/xenbus.h>
   68.14  #include <xen/xen_proc.h>
   68.15  #include <xen/evtchn.h>
   68.16 +#include <xen/features.h>
   68.17  
   68.18  #include "xenbus_comms.h"
   68.19  
   68.20 @@ -364,7 +365,7 @@ static int xenbus_dev_probe(struct devic
   68.21  	return 0;
   68.22  fail:
   68.23  	xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename);
   68.24 -	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
   68.25 +	xenbus_switch_state(dev, XenbusStateClosed);
   68.26  	return -ENODEV;
   68.27  }
   68.28  
   68.29 @@ -381,7 +382,7 @@ static int xenbus_dev_remove(struct devi
   68.30  	if (drv->remove)
   68.31  		drv->remove(dev);
   68.32  
   68.33 -	xenbus_switch_state(dev, XBT_NULL, XenbusStateClosed);
   68.34 +	xenbus_switch_state(dev, XenbusStateClosed);
   68.35  	return 0;
   68.36  }
   68.37  
   68.38 @@ -882,7 +883,7 @@ static int all_devices_ready_(struct dev
   68.39  	int *result = data;
   68.40  
   68.41  	if (xendev->state != XenbusStateConnected) {
   68.42 -		result = 0;
   68.43 +		*result = 0;
   68.44  		return 1;
   68.45  	}
   68.46  
   68.47 @@ -901,8 +902,6 @@ static int all_devices_ready(void)
   68.48  
   68.49  void xenbus_probe(void *unused)
   68.50  {
   68.51 -	int i;
   68.52 -
   68.53  	BUG_ON((xenstored_ready <= 0));
   68.54  
   68.55  	/* Enumerate devices in xenstore. */
   68.56 @@ -915,28 +914,6 @@ void xenbus_probe(void *unused)
   68.57  
   68.58  	/* Notify others that xenstore is up */
   68.59  	notifier_call_chain(&xenstore_chain, 0, NULL);
   68.60 -
   68.61 -	/* On a 10 second timeout, waiting for all devices currently
   68.62 -	   configured.  We need to do this to guarantee that the filesystems
   68.63 -	   and / or network devices needed for boot are available, before we
   68.64 -	   can allow the boot to proceed.
   68.65 -
   68.66 -	   A possible improvement here would be to have the tools add a
   68.67 -	   per-device flag to the store entry, indicating whether it is needed
   68.68 -	   at boot time.  This would allow people who knew what they were
   68.69 -	   doing to accelerate their boot slightly, but of course needs tools
   68.70 -	   or manual intervention to set up those flags correctly.
   68.71 -	 */
   68.72 -	for (i = 0; i < 10 * HZ; i++) {
   68.73 -		if (all_devices_ready())
   68.74 -			return;
   68.75 -
   68.76 -		set_current_state(TASK_INTERRUPTIBLE);
   68.77 -		schedule_timeout(1);
   68.78 -	}
   68.79 -
   68.80 -	printk(KERN_WARNING
   68.81 -	       "XENBUS: Timeout connecting to devices!\n");
   68.82  }
   68.83  
   68.84  
   68.85 @@ -983,6 +960,7 @@ static int xsd_port_read(char *page, cha
   68.86  static int __init xenbus_probe_init(void)
   68.87  {
   68.88  	int err = 0, dom0;
   68.89 +	unsigned long page = 0;
   68.90  
   68.91  	DPRINTK("");
   68.92  
   68.93 @@ -991,11 +969,9 @@ static int __init xenbus_probe_init(void
   68.94  		return -ENODEV;
   68.95  	}
   68.96  
   68.97 -	/* Register ourselves with the kernel bus & device subsystems */
   68.98 +	/* Register ourselves with the kernel bus subsystem */
   68.99  	bus_register(&xenbus_frontend.bus);
  68.100  	bus_register(&xenbus_backend.bus);
  68.101 -	device_register(&xenbus_frontend.dev);
  68.102 -	device_register(&xenbus_backend.dev);
  68.103  
  68.104  	/*
  68.105  	 * Domain0 doesn't have a store_evtchn or store_mfn yet.
  68.106 @@ -1003,11 +979,7 @@ static int __init xenbus_probe_init(void
  68.107  	dom0 = (xen_start_info->store_evtchn == 0);
  68.108  
  68.109  	if (dom0) {
  68.110 -
  68.111 -		unsigned long page;
  68.112  		evtchn_op_t op = { 0 };
  68.113 -		int ret;
  68.114 -
  68.115  
  68.116  		/* Allocate page. */
  68.117  		page = get_zeroed_page(GFP_KERNEL);
  68.118 @@ -1023,8 +995,10 @@ static int __init xenbus_probe_init(void
  68.119  		op.u.alloc_unbound.dom        = DOMID_SELF;
  68.120  		op.u.alloc_unbound.remote_dom = 0;
  68.121  
  68.122 -		ret = HYPERVISOR_event_channel_op(&op);
  68.123 -		BUG_ON(ret);
  68.124 +		err = HYPERVISOR_event_channel_op(&op);
  68.125 +		if (err == -ENOSYS)
  68.126 +			goto err;
  68.127 +		BUG_ON(err);
  68.128  		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
  68.129  
  68.130  		/* And finally publish the above info in /proc/xen */
  68.131 @@ -1047,17 +1021,65 @@ static int __init xenbus_probe_init(void
  68.132  	if (err) {
  68.133  		printk(KERN_WARNING
  68.134  		       "XENBUS: Error initializing xenstore comms: %i\n", err);
  68.135 -		return err;
  68.136 +		goto err;
  68.137  	}
  68.138  
  68.139 +	/* Register ourselves with the kernel device subsystem */
  68.140 +	device_register(&xenbus_frontend.dev);
  68.141 +	device_register(&xenbus_backend.dev);
  68.142 +
  68.143  	if (!dom0)
  68.144  		xenbus_probe(NULL);
  68.145  
  68.146  	return 0;
  68.147 +
  68.148 + err:
  68.149 +	if (page)
  68.150 +		free_page(page);
  68.151 +
  68.152 +	/*
  68.153 +         * Do not unregister the xenbus front/backend buses here. The
  68.154 +         * buses must exist because front/backend drivers will use
  68.155 +         * them when they are registered.
  68.156 +         */
  68.157 +
  68.158 +	return err;
  68.159  }
  68.160  
  68.161  postcore_initcall(xenbus_probe_init);
  68.162  
  68.163 +
  68.164 +/*
  68.165 + * On a 10 second timeout, wait for all devices currently configured.  We need
  68.166 + * to do this to guarantee that the filesystems and / or network devices
  68.167 + * needed for boot are available, before we can allow the boot to proceed.
  68.168 + *
  68.169 + * This needs to be on a late_initcall, to happen after the frontend device
  68.170 + * drivers have been initialised, but before the root fs is mounted.
  68.171 + *
  68.172 + * A possible improvement here would be to have the tools add a per-device
  68.173 + * flag to the store entry, indicating whether it is needed at boot time.
  68.174 + * This would allow people who knew what they were doing to accelerate their
  68.175 + * boot slightly, but of course needs tools or manual intervention to set up
  68.176 + * those flags correctly.
  68.177 + */
  68.178 +static int __init wait_for_devices(void)
  68.179 +{
  68.180 +	unsigned long timeout = jiffies + 10*HZ;
  68.181 +
  68.182 +	while (time_before(jiffies, timeout)) {
  68.183 +		if (all_devices_ready())
  68.184 +			return 0;
  68.185 +		schedule_timeout_interruptible(HZ/10);
  68.186 +	}
  68.187 +
  68.188 +	printk(KERN_WARNING "XENBUS: Timeout connecting to devices!\n");
  68.189 +	return 0;
  68.190 +}
  68.191 +
  68.192 +late_initcall(wait_for_devices);
  68.193 +
  68.194 +
  68.195  /*
  68.196   * Local variables:
  68.197   *  c-file-style: "linux"
    69.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Tue Apr 11 13:55:47 2006 -0600
    69.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Tue Apr 11 18:54:18 2006 -0600
    69.3 @@ -685,6 +685,24 @@ void xs_resume(void)
    69.4  	up_write(&xs_state.suspend_mutex);
    69.5  }
    69.6  
    69.7 +static int xenwatch_handle_callback(void *data)
    69.8 +{
    69.9 +	struct xs_stored_msg *msg = data;
   69.10 +
   69.11 +	msg->u.watch.handle->callback(msg->u.watch.handle,
   69.12 +				      (const char **)msg->u.watch.vec,
   69.13 +				      msg->u.watch.vec_size);
   69.14 +
   69.15 +	kfree(msg->u.watch.vec);
   69.16 +	kfree(msg);
   69.17 +
   69.18 +	/* Kill this kthread if we were spawned just for this callback. */
   69.19 +	if (current->pid != xenwatch_pid)
   69.20 +		do_exit(0);
   69.21 +
   69.22 +	return 0;
   69.23 +}
   69.24 +
   69.25  static int xenwatch_thread(void *unused)
   69.26  {
   69.27  	struct list_head *ent;
   69.28 @@ -707,12 +725,11 @@ static int xenwatch_thread(void *unused)
   69.29  
   69.30  		if (ent != &watch_events) {
   69.31  			msg = list_entry(ent, struct xs_stored_msg, list);
   69.32 -			msg->u.watch.handle->callback(
   69.33 -				msg->u.watch.handle,
   69.34 -				(const char **)msg->u.watch.vec,
   69.35 -				msg->u.watch.vec_size);
   69.36 -			kfree(msg->u.watch.vec);
   69.37 -			kfree(msg);
   69.38 +			if (msg->u.watch.handle->flags & XBWF_new_thread)
   69.39 +				kthread_run(xenwatch_handle_callback,
   69.40 +					    msg, "xenwatch_cb");
   69.41 +			else
   69.42 +				xenwatch_handle_callback(msg);
   69.43  		}
   69.44  
   69.45  		mutex_unlock(&xenwatch_mutex);
    70.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h	Tue Apr 11 13:55:47 2006 -0600
    70.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h	Tue Apr 11 18:54:18 2006 -0600
    70.3 @@ -33,10 +33,9 @@
    70.4  #ifndef __HYPERCALL_H__
    70.5  #define __HYPERCALL_H__
    70.6  
    70.7 -#include <xen/interface/xen.h>
    70.8 -#include <xen/interface/sched.h>
    70.9 -#include <xen/interface/nmi.h>
   70.10 -#include <linux/errno.h>
   70.11 +#ifndef __HYPERVISOR_H__
   70.12 +# error "please don't include this file directly"
   70.13 +#endif
   70.14  
   70.15  #define __STR(x) #x
   70.16  #define STR(x) __STR(x)
   70.17 @@ -167,35 +166,17 @@ HYPERVISOR_fpu_taskswitch(
   70.18  }
   70.19  
   70.20  static inline int
   70.21 -HYPERVISOR_sched_op(
   70.22 +HYPERVISOR_sched_op_compat(
   70.23  	int cmd, unsigned long arg)
   70.24  {
   70.25 -	return _hypercall2(int, sched_op, cmd, arg);
   70.26 -}
   70.27 -
   70.28 -static inline int
   70.29 -HYPERVISOR_sched_op_new(
   70.30 -	int cmd, void *arg)
   70.31 -{
   70.32 -	return _hypercall2(int, sched_op_new, cmd, arg);
   70.33 +	return _hypercall2(int, sched_op_compat, cmd, arg);
   70.34  }
   70.35  
   70.36  static inline int
   70.37 -HYPERVISOR_poll(
   70.38 -	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
   70.39 +HYPERVISOR_sched_op(
   70.40 +	int cmd, void *arg)
   70.41  {
   70.42 -	struct sched_poll sched_poll = {
   70.43 -		.ports = ports,
   70.44 -		.nr_ports = nr_ports,
   70.45 -		.timeout = jiffies_to_st(timeout)
   70.46 -	};
   70.47 -
   70.48 -	int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
   70.49 -
   70.50 -	if (rc == -ENOSYS)
   70.51 -		rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
   70.52 -
   70.53 -	return rc;
   70.54 +	return _hypercall2(int, sched_op, cmd, arg);
   70.55  }
   70.56  
   70.57  static inline long
   70.58 @@ -327,8 +308,18 @@ static inline int
   70.59  HYPERVISOR_suspend(
   70.60  	unsigned long srec)
   70.61  {
   70.62 -	return _hypercall3(int, sched_op, SCHEDOP_shutdown,
   70.63 -			   SHUTDOWN_suspend, srec);
   70.64 +	struct sched_shutdown sched_shutdown = {
   70.65 +		.reason = SHUTDOWN_suspend
   70.66 +	};
   70.67 +
   70.68 +	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
   70.69 +			     &sched_shutdown, srec);
   70.70 +
   70.71 +	if (rc == -ENOSYS)
   70.72 +		rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
   70.73 +				 SHUTDOWN_suspend, srec);
   70.74 +
   70.75 +	return rc;
   70.76  }
   70.77  
   70.78  static inline int
   70.79 @@ -338,6 +329,21 @@ HYPERVISOR_nmi_op(
   70.80  	return _hypercall2(int, nmi_op, op, arg);
   70.81  }
   70.82  
   70.83 +static inline int
   70.84 +HYPERVISOR_callback_op(
   70.85 +	int cmd, void *arg)
   70.86 +{
   70.87 +	return _hypercall2(int, callback_op, cmd, arg);
   70.88 +}
   70.89 +
   70.90 +static inline int
   70.91 +HYPERVISOR_xenoprof_op(
   70.92 +	int op, unsigned long arg1, unsigned long arg2)
   70.93 +{
   70.94 +	return _hypercall3(int, xenoprof_op, op, arg1, arg2);
   70.95 +}
   70.96 +
   70.97 +
   70.98  #endif /* __HYPERCALL_H__ */
   70.99  
  70.100  /*
    71.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Tue Apr 11 13:55:47 2006 -0600
    71.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Tue Apr 11 18:54:18 2006 -0600
    71.3 @@ -37,8 +37,11 @@
    71.4  #include <linux/types.h>
    71.5  #include <linux/kernel.h>
    71.6  #include <linux/version.h>
    71.7 +#include <linux/errno.h>
    71.8  #include <xen/interface/xen.h>
    71.9  #include <xen/interface/dom0_ops.h>
   71.10 +#include <xen/interface/sched.h>
   71.11 +#include <xen/interface/nmi.h>
   71.12  #include <asm/ptrace.h>
   71.13  #include <asm/page.h>
   71.14  #if defined(__i386__)
   71.15 @@ -115,6 +118,64 @@ u64 jiffies_to_st(unsigned long jiffies)
   71.16  
   71.17  #define xen_init()	(0)
   71.18  
   71.19 +static inline int
   71.20 +HYPERVISOR_yield(
   71.21 +	void)
   71.22 +{
   71.23 +	int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
   71.24 +
   71.25 +	if (rc == -ENOSYS)
   71.26 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
   71.27 +
   71.28 +	return rc;
   71.29 +}
   71.30 +
   71.31 +static inline int
   71.32 +HYPERVISOR_block(
   71.33 +	void)
   71.34 +{
   71.35 +	int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
   71.36 +
   71.37 +	if (rc == -ENOSYS)
   71.38 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
   71.39 +
   71.40 +	return rc;
   71.41 +}
   71.42 +
   71.43 +static inline int
   71.44 +HYPERVISOR_shutdown(
   71.45 +	unsigned int reason)
   71.46 +{
   71.47 +	struct sched_shutdown sched_shutdown = {
   71.48 +		.reason = reason
   71.49 +	};
   71.50 +
   71.51 +	int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
   71.52 +
   71.53 +	if (rc == -ENOSYS)
   71.54 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
   71.55 +
   71.56 +	return rc;
   71.57 +}
   71.58 +
   71.59 +static inline int
   71.60 +HYPERVISOR_poll(
   71.61 +	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
   71.62 +{
   71.63 +	struct sched_poll sched_poll = {
   71.64 +		.ports = ports,
   71.65 +		.nr_ports = nr_ports,
   71.66 +		.timeout = jiffies_to_st(timeout)
   71.67 +	};
   71.68 +
   71.69 +	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
   71.70 +
   71.71 +	if (rc == -ENOSYS)
   71.72 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
   71.73 +
   71.74 +	return rc;
   71.75 +}
   71.76 +
   71.77  static inline void
   71.78  MULTI_update_va_mapping(
   71.79      multicall_entry_t *mcl, unsigned long va,
    72.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/io.h	Tue Apr 11 13:55:47 2006 -0600
    72.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/io.h	Tue Apr 11 18:54:18 2006 -0600
    72.3 @@ -102,6 +102,7 @@ static inline void * phys_to_virt(unsign
    72.4   */
    72.5  #define page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
    72.6  #define page_to_phys(page)	 (phys_to_machine(page_to_pseudophys(page)))
    72.7 +#define page_to_bus(page)	 (phys_to_machine(page_to_pseudophys(page)))
    72.8  
    72.9  #define bio_to_pseudophys(bio)	 (page_to_pseudophys(bio_page((bio))) + \
   72.10  				  (unsigned long) bio_offset((bio)))
    73.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h	Tue Apr 11 13:55:47 2006 -0600
    73.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/setup_arch_post.h	Tue Apr 11 18:54:18 2006 -0600
    73.3 @@ -6,6 +6,8 @@
    73.4   *	use of all of the static functions.
    73.5   **/
    73.6  
    73.7 +#include <xen/interface/callback.h>
    73.8 +
    73.9  static char * __init machine_specific_memory_setup(void)
   73.10  {
   73.11  	unsigned long max_pfn = xen_start_info->nr_pages;
   73.12 @@ -23,6 +25,14 @@ extern void nmi(void);
   73.13  static void __init machine_specific_arch_setup(void)
   73.14  {
   73.15  	struct xen_platform_parameters pp;
   73.16 +	struct callback_register event = {
   73.17 +		.type = CALLBACKTYPE_event,
   73.18 +		.address = { __KERNEL_CS, (unsigned long)hypervisor_callback },
   73.19 +	};
   73.20 +	struct callback_register failsafe = {
   73.21 +		.type = CALLBACKTYPE_failsafe,
   73.22 +		.address = { __KERNEL_CS, (unsigned long)failsafe_callback },
   73.23 +	};
   73.24  	struct xennmi_callback cb;
   73.25  
   73.26  	if (xen_feature(XENFEAT_auto_translated_physmap) &&
   73.27 @@ -32,9 +42,8 @@ static void __init machine_specific_arch
   73.28  		memset(empty_zero_page, 0, sizeof(empty_zero_page));
   73.29  	}
   73.30  
   73.31 -	HYPERVISOR_set_callbacks(
   73.32 -	    __KERNEL_CS, (unsigned long)hypervisor_callback,
   73.33 -	    __KERNEL_CS, (unsigned long)failsafe_callback);
   73.34 +	HYPERVISOR_callback_op(CALLBACKOP_register, &event);
   73.35 +	HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
   73.36  
   73.37  	cb.handler_address = (unsigned long)&nmi;
   73.38  	HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
    74.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Tue Apr 11 13:55:47 2006 -0600
    74.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Tue Apr 11 18:54:18 2006 -0600
    74.3 @@ -33,11 +33,9 @@
    74.4  #ifndef __HYPERCALL_H__
    74.5  #define __HYPERCALL_H__
    74.6  
    74.7 -#include <xen/interface/xen.h>
    74.8 -#include <xen/interface/sched.h>
    74.9 -#include <xen/interface/dom0_ops.h>
   74.10 -#include <linux/errno.h>
   74.11 -#include <asm/hypervisor.h> // for jiffies_to_st()
   74.12 +#ifndef __HYPERVISOR_H__
   74.13 +# error "please don't include this file directly"
   74.14 +#endif
   74.15  
   74.16  /* FIXME: temp place to hold these page related macros */
   74.17  #include <asm/page.h>
   74.18 @@ -165,35 +163,17 @@
   74.19  })
   74.20  
   74.21  static inline int
   74.22 -HYPERVISOR_sched_op(
   74.23 +HYPERVISOR_sched_op_compat(
   74.24      int cmd, unsigned long arg)
   74.25  {
   74.26 -	return _hypercall2(int, sched_op, cmd, arg);
   74.27 -}
   74.28 -
   74.29 -static inline int
   74.30 -HYPERVISOR_sched_op_new(
   74.31 -	int cmd, void *arg)
   74.32 -{
   74.33 -	return _hypercall2(int, sched_op_new, cmd, arg);
   74.34 +	return _hypercall2(int, sched_op_compat, cmd, arg);
   74.35  }
   74.36  
   74.37  static inline int
   74.38 -HYPERVISOR_poll(
   74.39 -	evtchn_port_t *ports, unsigned int nr_ports, unsigned long timeout)
   74.40 +HYPERVISOR_sched_op(
   74.41 +	int cmd, void *arg)
   74.42  {
   74.43 -	struct sched_poll sched_poll = {
   74.44 -		.ports = ports,
   74.45 -		.nr_ports = nr_ports,
   74.46 -		.timeout = jiffies_to_st(timeout)
   74.47 -	};
   74.48 -
   74.49 -	int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
   74.50 -
   74.51 -	if (rc == -ENOSYS)
   74.52 -		rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
   74.53 -
   74.54 -	return rc;
   74.55 +	return _hypercall2(int, sched_op, cmd, arg);
   74.56  }
   74.57  
   74.58  static inline long
   74.59 @@ -273,8 +253,18 @@ static inline int
   74.60  HYPERVISOR_suspend(
   74.61  	unsigned long srec)
   74.62  {
   74.63 -    return _hypercall3(int, sched_op, SCHEDOP_shutdown,
   74.64 -			SHUTDOWN_suspend, srec);
   74.65 +	struct sched_shutdown sched_shutdown = {
   74.66 +		.reason = SHUTDOWN_suspend
   74.67 +	};
   74.68 +
   74.69 +	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
   74.70 +			     &sched_shutdown, srec);
   74.71 +
   74.72 +	if (rc == -ENOSYS)
   74.73 +		rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
   74.74 +				 SHUTDOWN_suspend, srec);
   74.75 +
   74.76 +	return rc;
   74.77  }
   74.78  
   74.79  extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
    75.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Apr 11 13:55:47 2006 -0600
    75.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Apr 11 18:54:18 2006 -0600
    75.3 @@ -37,8 +37,10 @@
    75.4  #include <linux/types.h>
    75.5  #include <linux/kernel.h>
    75.6  #include <linux/version.h>
    75.7 +#include <linux/errno.h>
    75.8  #include <xen/interface/xen.h>
    75.9  #include <xen/interface/dom0_ops.h>
   75.10 +#include <xen/interface/sched.h>
   75.11  #include <asm/ptrace.h>
   75.12  #include <asm/page.h>
   75.13  #include <asm/xen/privop.h> // for running_on_xen
   75.14 @@ -55,6 +57,64 @@ int xen_init(void);
   75.15  
   75.16  #include <asm/hypercall.h>
   75.17  
   75.18 +static inline int
   75.19 +HYPERVISOR_yield(
   75.20 +	void)
   75.21 +{
   75.22 +	int rc = HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
   75.23 +
   75.24 +	if (rc == -ENOSYS)
   75.25 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
   75.26 +
   75.27 +	return rc;
   75.28 +}
   75.29 +
   75.30 +static inline int
   75.31 +HYPERVISOR_block(
   75.32 +	void)
   75.33 +{
   75.34 +	int rc = HYPERVISOR_sched_op(SCHEDOP_block, NULL);
   75.35 +
   75.36 +	if (rc == -ENOSYS)
   75.37 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_block, 0);
   75.38 +
   75.39 +	return rc;
   75.40 +}
   75.41 +
   75.42 +static inline int
   75.43 +HYPERVISOR_shutdown(
   75.44 +	unsigned int reason)
   75.45 +{
   75.46 +	struct sched_shutdown sched_shutdown = {
   75.47 +		.reason = reason
   75.48 +	};
   75.49 +
   75.50 +	int rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
   75.51 +
   75.52 +	if (rc == -ENOSYS)
   75.53 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_shutdown, reason);
   75.54 +
   75.55 +	return rc;
   75.56 +}
   75.57 +
   75.58 +static inline int
   75.59 +HYPERVISOR_poll(
   75.60 +	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
   75.61 +{
   75.62 +	struct sched_poll sched_poll = {
   75.63 +		.ports = ports,
   75.64 +		.nr_ports = nr_ports,
   75.65 +		.timeout = jiffies_to_st(timeout)
   75.66 +	};
   75.67 +
   75.68 +	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
   75.69 +
   75.70 +	if (rc == -ENOSYS)
   75.71 +		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
   75.72 +
   75.73 +	return rc;
   75.74 +}
   75.75 +
   75.76  // for drivers/xen/privcmd/privcmd.c
   75.77  #define direct_remap_pfn_range(a,b,c,d,e,f) remap_pfn_range(a,b,c,d,e)
   75.78  #define	pfn_to_mfn(x)	(x)
    76.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h	Tue Apr 11 13:55:47 2006 -0600
    76.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h	Tue Apr 11 18:54:18 2006 -0600
    76.3 @@ -37,10 +37,9 @@
    76.4  #ifndef __HYPERCALL_H__
    76.5  #define __HYPERCALL_H__
    76.6  
    76.7 -#include <xen/interface/xen.h>
    76.8 -#include <xen/interface/sched.h>
    76.9 -#include <xen/interface/nmi.h>
   76.10 -#include <linux/errno.h>
   76.11 +#ifndef __HYPERVISOR_H__
   76.12 +# error "please don't include this file directly"
   76.13 +#endif
   76.14  
   76.15  #define __STR(x) #x
   76.16  #define STR(x) __STR(x)
   76.17 @@ -172,35 +171,17 @@ HYPERVISOR_fpu_taskswitch(
   76.18  }
   76.19  
   76.20  static inline int
   76.21 -HYPERVISOR_sched_op(
   76.22 +HYPERVISOR_sched_op_compat(
   76.23  	int cmd, unsigned long arg)
   76.24  {
   76.25 -	return _hypercall2(int, sched_op, cmd, arg);
   76.26 -}
   76.27 -
   76.28 -static inline int
   76.29 -HYPERVISOR_sched_op_new(
   76.30 -	int cmd, void *arg)
   76.31 -{
   76.32 -	return _hypercall2(int, sched_op_new, cmd, arg);
   76.33 +	return _hypercall2(int, sched_op_compat, cmd, arg);
   76.34  }
   76.35  
   76.36  static inline int
   76.37 -HYPERVISOR_poll(
   76.38 -	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
   76.39 +HYPERVISOR_sched_op(
   76.40 +	int cmd, void *arg)
   76.41  {
   76.42 -	struct sched_poll sched_poll = {
   76.43 -		.ports = ports,
   76.44 -		.nr_ports = nr_ports,
   76.45 -		.timeout = jiffies_to_st(timeout)
   76.46 -	};
   76.47 -
   76.48 -	int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
   76.49 -
   76.50 -	if (rc == -ENOSYS)
   76.51 -		rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
   76.52 -
   76.53 -	return rc;
   76.54 +	return _hypercall2(int, sched_op, cmd, arg);
   76.55  }
   76.56  
   76.57  static inline long
   76.58 @@ -328,8 +309,18 @@ static inline int
   76.59  HYPERVISOR_suspend(
   76.60  	unsigned long srec)
   76.61  {
   76.62 -	return _hypercall3(int, sched_op, SCHEDOP_shutdown,
   76.63 -			   SHUTDOWN_suspend, srec);
   76.64 +	struct sched_shutdown sched_shutdown = {
   76.65 +		.reason = SHUTDOWN_suspend
   76.66 +	};
   76.67 +
   76.68 +	int rc = _hypercall3(int, sched_op, SCHEDOP_shutdown,
   76.69 +			     &sched_shutdown, srec);
   76.70 +
   76.71 +	if (rc == -ENOSYS)
   76.72 +		rc = _hypercall3(int, sched_op_compat, SCHEDOP_shutdown,
   76.73 +				 SHUTDOWN_suspend, srec);
   76.74 +
   76.75 +	return rc;
   76.76  }
   76.77  
   76.78  static inline int
   76.79 @@ -339,6 +330,20 @@ HYPERVISOR_nmi_op(
   76.80  	return _hypercall2(int, nmi_op, op, arg);
   76.81  }
   76.82  
   76.83 +static inline int
   76.84 +HYPERVISOR_callback_op(
   76.85 +	int cmd, void *arg)
   76.86 +{
   76.87 +	return _hypercall2(int, callback_op, cmd, arg);
   76.88 +}
   76.89 +
   76.90 +static inline int
   76.91 +HYPERVISOR_xenoprof_op(
   76.92 +	int op, unsigned long arg1, unsigned long arg2)
   76.93 +{
   76.94 +	return _hypercall3(int, xenoprof_op, op, arg1, arg2);
   76.95 +}
   76.96 +
   76.97  #endif /* __HYPERCALL_H__ */
   76.98  
   76.99  /*
    77.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/io.h	Tue Apr 11 13:55:47 2006 -0600
    77.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/io.h	Tue Apr 11 18:54:18 2006 -0600
    77.3 @@ -130,6 +130,7 @@ static inline void * phys_to_virt(unsign
    77.4   */
    77.5  #define page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
    77.6  #define page_to_phys(page)	 (phys_to_machine(page_to_pseudophys(page)))
    77.7 +#define page_to_bus(page)	 (phys_to_machine(page_to_pseudophys(page)))
    77.8  
    77.9  #define bio_to_pseudophys(bio)	 (page_to_pseudophys(bio_page((bio))) + \
   77.10  				  (unsigned long) bio_offset((bio)))
    78.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h	Tue Apr 11 13:55:47 2006 -0600
    78.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/setup_arch_post.h	Tue Apr 11 18:54:18 2006 -0600
    78.3 @@ -6,20 +6,33 @@
    78.4   *	use of all of the static functions.
    78.5   **/
    78.6  
    78.7 +#include <xen/interface/callback.h>
    78.8 +
    78.9  extern void hypervisor_callback(void);
   78.10  extern void failsafe_callback(void);
   78.11  extern void nmi(void);
   78.12  
   78.13  static void __init machine_specific_arch_setup(void)
   78.14  {
   78.15 +	struct callback_register event = {
   78.16 +		.type = CALLBACKTYPE_event,
   78.17 +		.address = (unsigned long) hypervisor_callback,
   78.18 +	};
   78.19 +	struct callback_register failsafe = {
   78.20 +		.type = CALLBACKTYPE_failsafe,
   78.21 +		.address = (unsigned long)failsafe_callback,
   78.22 +	};
   78.23 +	struct callback_register syscall = {
   78.24 +		.type = CALLBACKTYPE_syscall,
   78.25 +		.address = (unsigned long)system_call,
   78.26 +	};
   78.27  #ifdef CONFIG_X86_LOCAL_APIC
   78.28  	struct xennmi_callback cb;
   78.29  #endif
   78.30  
   78.31 -	HYPERVISOR_set_callbacks(
   78.32 -                (unsigned long) hypervisor_callback,
   78.33 -                (unsigned long) failsafe_callback,
   78.34 -                (unsigned long) system_call);
   78.35 +	HYPERVISOR_callback_op(CALLBACKOP_register, &event);
   78.36 +	HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
   78.37 +	HYPERVISOR_callback_op(CALLBACKOP_register, &syscall);
   78.38  
   78.39  #ifdef CONFIG_X86_LOCAL_APIC
   78.40  	cb.handler_address = (unsigned long)&nmi;
    79.1 --- a/linux-2.6-xen-sparse/include/linux/irq.h	Tue Apr 11 13:55:47 2006 -0600
    79.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.3 @@ -1,244 +0,0 @@
    79.4 -#ifndef __irq_h
    79.5 -#define __irq_h
    79.6 -
    79.7 -/*
    79.8 - * Please do not include this file in generic code.  There is currently
    79.9 - * no requirement for any architecture to implement anything held
   79.10 - * within this file.
   79.11 - *
   79.12 - * Thanks. --rmk
   79.13 - */
   79.14 -
   79.15 -#include <linux/config.h>
   79.16 -#include <linux/smp.h>
   79.17 -
   79.18 -#if !defined(CONFIG_S390)
   79.19 -
   79.20 -#include <linux/linkage.h>
   79.21 -#include <linux/cache.h>
   79.22 -#include <linux/spinlock.h>
   79.23 -#include <linux/cpumask.h>
   79.24 -
   79.25 -#include <asm/irq.h>
   79.26 -#include <asm/ptrace.h>
   79.27 -
   79.28 -/*
   79.29 - * IRQ line status.
   79.30 - */
   79.31 -#define IRQ_INPROGRESS	1	/* IRQ handler active - do not enter! */
   79.32 -#define IRQ_DISABLED	2	/* IRQ disabled - do not enter! */
   79.33 -#define IRQ_PENDING	4	/* IRQ pending - replay on enable */
   79.34 -#define IRQ_REPLAY	8	/* IRQ has been replayed but not acked yet */
   79.35 -#define IRQ_AUTODETECT	16	/* IRQ is being autodetected */
   79.36 -#define IRQ_WAITING	32	/* IRQ not yet seen - for autodetection */
   79.37 -#define IRQ_LEVEL	64	/* IRQ level triggered */
   79.38 -#define IRQ_MASKED	128	/* IRQ masked - shouldn't be seen again */
   79.39 -#if defined(ARCH_HAS_IRQ_PER_CPU)
   79.40 -# define IRQ_PER_CPU	256	/* IRQ is per CPU */
   79.41 -# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
   79.42 -#else
   79.43 -# define CHECK_IRQ_PER_CPU(var) 0
   79.44 -#endif
   79.45 -
   79.46 -/*
   79.47 - * Interrupt controller descriptor. This is all we need
   79.48 - * to describe about the low-level hardware. 
   79.49 - */
   79.50 -struct hw_interrupt_type {
   79.51 -	const char * typename;
   79.52 -	unsigned int (*startup)(unsigned int irq);
   79.53 -	void (*shutdown)(unsigned int irq);
   79.54 -	void (*enable)(unsigned int irq);
   79.55 -	void (*disable)(unsigned int irq);
   79.56 -	void (*ack)(unsigned int irq);
   79.57 -	void (*end)(unsigned int irq);
   79.58 -	void (*set_affinity)(unsigned int irq, cpumask_t dest);
   79.59 -	/* Currently used only by UML, might disappear one day.*/
   79.60 -#ifdef CONFIG_IRQ_RELEASE_METHOD
   79.61 -	void (*release)(unsigned int irq, void *dev_id);
   79.62 -#endif
   79.63 -};
   79.64 -
   79.65 -typedef struct hw_interrupt_type  hw_irq_controller;
   79.66 -
   79.67 -/*
   79.68 - * This is the "IRQ descriptor", which contains various information
   79.69 - * about the irq, including what kind of hardware handling it has,
   79.70 - * whether it is disabled etc etc.
   79.71 - *
   79.72 - * Pad this out to 32 bytes for cache and indexing reasons.
   79.73 - */
   79.74 -typedef struct irq_desc {
   79.75 -	hw_irq_controller *handler;
   79.76 -	void *handler_data;
   79.77 -	struct irqaction *action;	/* IRQ action list */
   79.78 -	unsigned int status;		/* IRQ status */
   79.79 -	unsigned int depth;		/* nested irq disables */
   79.80 -	unsigned int irq_count;		/* For detecting broken interrupts */
   79.81 -	unsigned int irqs_unhandled;
   79.82 -	spinlock_t lock;
   79.83 -#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
   79.84 -	unsigned int move_irq;		/* Flag need to re-target intr dest*/
   79.85 -#endif
   79.86 -} ____cacheline_aligned irq_desc_t;
   79.87 -
   79.88 -extern irq_desc_t irq_desc [NR_IRQS];
   79.89 -
   79.90 -/* Return a pointer to the irq descriptor for IRQ.  */
   79.91 -static inline irq_desc_t *
   79.92 -irq_descp (int irq)
   79.93 -{
   79.94 -	return irq_desc + irq;
   79.95 -}
   79.96 -
   79.97 -#include <asm/hw_irq.h> /* the arch dependent stuff */
   79.98 -
   79.99 -extern int setup_irq(unsigned int irq, struct irqaction * new);
  79.100 -#ifdef CONFIG_XEN
  79.101 -extern int teardown_irq(unsigned int irq, struct irqaction * old);
  79.102 -#endif
  79.103 -
  79.104 -#ifdef CONFIG_GENERIC_HARDIRQS
  79.105 -extern cpumask_t irq_affinity[NR_IRQS];
  79.106 -
  79.107 -#ifdef CONFIG_SMP
  79.108 -static inline void set_native_irq_info(int irq, cpumask_t mask)
  79.109 -{
  79.110 -	irq_affinity[irq] = mask;
  79.111 -}
  79.112 -#else
  79.113 -static inline void set_native_irq_info(int irq, cpumask_t mask)
  79.114 -{
  79.115 -}
  79.116 -#endif
  79.117 -
  79.118 -#ifdef CONFIG_SMP
  79.119 -
  79.120 -#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
  79.121 -extern cpumask_t pending_irq_cpumask[NR_IRQS];
  79.122 -
  79.123 -static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
  79.124 -{
  79.125 -	irq_desc_t *desc = irq_desc + irq;
  79.126 -	unsigned long flags;
  79.127 -
  79.128 -	spin_lock_irqsave(&desc->lock, flags);
  79.129 -	desc->move_irq = 1;
  79.130 -	pending_irq_cpumask[irq] = mask;
  79.131 -	spin_unlock_irqrestore(&desc->lock, flags);
  79.132 -}
  79.133 -
  79.134 -static inline void
  79.135 -move_native_irq(int irq)
  79.136 -{
  79.137 -	cpumask_t tmp;
  79.138 -	irq_desc_t *desc = irq_descp(irq);
  79.139 -
  79.140 -	if (likely (!desc->move_irq))
  79.141 -		return;
  79.142 -
  79.143 -	desc->move_irq = 0;
  79.144 -
  79.145 -	if (likely(cpus_empty(pending_irq_cpumask[irq])))
  79.146 -		return;
  79.147 -
  79.148 -	if (!desc->handler->set_affinity)
  79.149 -		return;
  79.150 -
  79.151 -	/* note - we hold the desc->lock */
  79.152 -	cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
  79.153 -
  79.154 -	/*
  79.155 -	 * If there was a valid mask to work with, please
  79.156 -	 * do the disable, re-program, enable sequence.
  79.157 -	 * This is *not* particularly important for level triggered
  79.158 -	 * but in a edge trigger case, we might be setting rte
  79.159 -	 * when an active trigger is comming in. This could
  79.160 -	 * cause some ioapics to mal-function.
  79.161 -	 * Being paranoid i guess!
  79.162 -	 */
  79.163 -	if (unlikely(!cpus_empty(tmp))) {
  79.164 -		desc->handler->disable(irq);
  79.165 -		desc->handler->set_affinity(irq,tmp);
  79.166 -		desc->handler->enable(irq);
  79.167 -	}
  79.168 -	cpus_clear(pending_irq_cpumask[irq]);
  79.169 -}
  79.170 -
  79.171 -#ifdef CONFIG_PCI_MSI
  79.172 -/*
  79.173 - * Wonder why these are dummies?
  79.174 - * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
  79.175 - * counter part after translating the vector to irq info. We need to perform
  79.176 - * this operation on the real irq, when we dont use vector, i.e when
  79.177 - * pci_use_vector() is false.
  79.178 - */
  79.179 -static inline void move_irq(int irq)
  79.180 -{
  79.181 -}
  79.182 -
  79.183 -static inline void set_irq_info(int irq, cpumask_t mask)
  79.184 -{
  79.185 -}
  79.186 -
  79.187 -#else // CONFIG_PCI_MSI
  79.188 -
  79.189 -static inline void move_irq(int irq)
  79.190 -{
  79.191 -	move_native_irq(irq);
  79.192 -}
  79.193 -
  79.194 -static inline void set_irq_info(int irq, cpumask_t mask)
  79.195 -{
  79.196 -	set_native_irq_info(irq, mask);
  79.197 -}
  79.198 -#endif // CONFIG_PCI_MSI
  79.199 -
  79.200 -#else	// CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE
  79.201 -
  79.202 -#define move_irq(x)
  79.203 -#define move_native_irq(x)
  79.204 -#define set_pending_irq(x,y)
  79.205 -static inline void set_irq_info(int irq, cpumask_t mask)
  79.206 -{
  79.207 -	set_native_irq_info(irq, mask);
  79.208 -}
  79.209 -
  79.210 -#endif // CONFIG_GENERIC_PENDING_IRQ
  79.211 -
  79.212 -#else // CONFIG_SMP
  79.213 -
  79.214 -#define move_irq(x)
  79.215 -#define move_native_irq(x)
  79.216 -
  79.217 -#endif // CONFIG_SMP
  79.218 -
  79.219 -extern int no_irq_affinity;
  79.220 -extern int noirqdebug_setup(char *str);
  79.221 -
  79.222 -extern fastcall int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
  79.223 -					struct irqaction *action);
  79.224 -extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
  79.225 -extern void note_interrupt(unsigned int irq, irq_desc_t *desc,
  79.226 -					int action_ret, struct pt_regs *regs);
  79.227 -extern int can_request_irq(unsigned int irq, unsigned long irqflags);
  79.228 -
  79.229 -extern void init_irq_proc(void);
  79.230 -
  79.231 -#ifdef CONFIG_AUTO_IRQ_AFFINITY
  79.232 -extern int select_smp_affinity(unsigned int irq);
  79.233 -#else
  79.234 -static inline int
  79.235 -select_smp_affinity(unsigned int irq)
  79.236 -{
  79.237 -	return 1;
  79.238 -}
  79.239 -#endif
  79.240 -
  79.241 -#endif
  79.242 -
  79.243 -extern hw_irq_controller no_irq_type;  /* needed in every arch ? */
  79.244 -
  79.245 -#endif
  79.246 -
  79.247 -#endif /* __irq_h */
    80.1 --- a/linux-2.6-xen-sparse/include/linux/skbuff.h	Tue Apr 11 13:55:47 2006 -0600
    80.2 +++ b/linux-2.6-xen-sparse/include/linux/skbuff.h	Tue Apr 11 18:54:18 2006 -0600
    80.3 @@ -189,7 +189,7 @@ enum {
    80.4   *	@local_df: allow local fragmentation
    80.5   *	@cloned: Head may be cloned (check refcnt to be sure)
    80.6   *	@nohdr: Payload reference only, must not modify header
    80.7 - *	@proto_csum_valid: Protocol csum validated since arriving at localhost
    80.8 + *	@proto_data_valid: Protocol data validated since arriving at localhost
    80.9   *	@proto_csum_blank: Protocol csum must be added before leaving localhost
   80.10   *	@pkt_type: Packet class
   80.11   *	@fclone: skbuff clone status
   80.12 @@ -271,7 +271,7 @@ struct sk_buff {
   80.13  				ipvs_property:1;
   80.14  #else
   80.15  				ipvs_property:1,
   80.16 -				proto_csum_valid:1,
   80.17 +				proto_data_valid:1,
   80.18  				proto_csum_blank:1;
   80.19  #endif
   80.20  	__be16			protocol;
    81.1 --- a/linux-2.6-xen-sparse/include/xen/gnttab.h	Tue Apr 11 13:55:47 2006 -0600
    81.2 +++ b/linux-2.6-xen-sparse/include/xen/gnttab.h	Tue Apr 11 18:54:18 2006 -0600
    81.3 @@ -110,6 +110,9 @@ void gnttab_grant_foreign_transfer_ref(g
    81.4  #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
    81.5  #endif
    81.6  
    81.7 +int gnttab_suspend(void);
    81.8 +int gnttab_resume(void);
    81.9 +
   81.10  #endif /* __ASM_GNTTAB_H__ */
   81.11  
   81.12  /*
    82.1 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Tue Apr 11 13:55:47 2006 -0600
    82.2 +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Tue Apr 11 18:54:18 2006 -0600
    82.3 @@ -55,8 +55,17 @@ struct xenbus_watch
    82.4  	/* Callback (executed in a process context with no locks held). */
    82.5  	void (*callback)(struct xenbus_watch *,
    82.6  			 const char **vec, unsigned int len);
    82.7 +
    82.8 +	/* See XBWF_ definitions below. */
    82.9 +	unsigned long flags;
   82.10  };
   82.11  
   82.12 +/*
   82.13 + * Execute callback in its own kthread. Useful if the callback is long
   82.14 + * running or heavily serialised, to avoid taking out the main xenwatch thread
   82.15 + * for a long period of time (or even unwittingly causing a deadlock).
   82.16 + */
   82.17 +#define XBWF_new_thread	1
   82.18  
   82.19  /* A xenbus device. */
   82.20  struct xenbus_device {
   82.21 @@ -195,14 +204,10 @@ int xenbus_watch_path2(struct xenbus_dev
   82.22  
   82.23  /**
   82.24   * Advertise in the store a change of the given driver to the given new_state.
   82.25 - * Perform the change inside the given transaction xbt.  xbt may be NULL, in
   82.26 - * which case this is performed inside its own transaction.  Return 0 on
   82.27 - * success, or -errno on error.  On error, the device will switch to
   82.28 - * XenbusStateClosing, and the error will be saved in the store.
   82.29 + * Return 0 on success, or -errno on error.  On error, the device will switch
   82.30 + * to XenbusStateClosing, and the error will be saved in the store.
   82.31   */
   82.32 -int xenbus_switch_state(struct xenbus_device *dev,
   82.33 -			xenbus_transaction_t xbt,
   82.34 -			XenbusState new_state);
   82.35 +int xenbus_switch_state(struct xenbus_device *dev, XenbusState new_state);
   82.36  
   82.37  
   82.38  /**
    83.1 --- a/linux-2.6-xen-sparse/kernel/irq/manage.c	Tue Apr 11 13:55:47 2006 -0600
    83.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.3 @@ -1,425 +0,0 @@
    83.4 -/*
    83.5 - * linux/kernel/irq/manage.c
    83.6 - *
    83.7 - * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
    83.8 - *
    83.9 - * This file contains driver APIs to the irq subsystem.
   83.10 - */
   83.11 -
   83.12 -#include <linux/config.h>
   83.13 -#include <linux/irq.h>
   83.14 -#include <linux/module.h>
   83.15 -#include <linux/random.h>
   83.16 -#include <linux/interrupt.h>
   83.17 -
   83.18 -#include "internals.h"
   83.19 -
   83.20 -#ifdef CONFIG_SMP
   83.21 -
   83.22 -cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
   83.23 -
   83.24 -#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
   83.25 -cpumask_t __cacheline_aligned pending_irq_cpumask[NR_IRQS];
   83.26 -#endif
   83.27 -
   83.28 -/**
   83.29 - *	synchronize_irq - wait for pending IRQ handlers (on other CPUs)
   83.30 - *	@irq: interrupt number to wait for
   83.31 - *
   83.32 - *	This function waits for any pending IRQ handlers for this interrupt
   83.33 - *	to complete before returning. If you use this function while
   83.34 - *	holding a resource the IRQ handler may need you will deadlock.
   83.35 - *
   83.36 - *	This function may be called - with care - from IRQ context.
   83.37 - */
   83.38 -void synchronize_irq(unsigned int irq)
   83.39 -{
   83.40 -	struct irq_desc *desc = irq_desc + irq;
   83.41 -
   83.42 -	if (irq >= NR_IRQS)
   83.43 -		return;
   83.44 -
   83.45 -	while (desc->status & IRQ_INPROGRESS)
   83.46 -		cpu_relax();
   83.47 -}
   83.48 -
   83.49 -EXPORT_SYMBOL(synchronize_irq);
   83.50 -
   83.51 -#endif
   83.52 -
   83.53 -/**
   83.54 - *	disable_irq_nosync - disable an irq without waiting
   83.55 - *	@irq: Interrupt to disable
   83.56 - *
   83.57 - *	Disable the selected interrupt line.  Disables and Enables are
   83.58 - *	nested.
   83.59 - *	Unlike disable_irq(), this function does not ensure existing
   83.60 - *	instances of the IRQ handler have completed before returning.
   83.61 - *
   83.62 - *	This function may be called from IRQ context.
   83.63 - */
   83.64 -void disable_irq_nosync(unsigned int irq)
   83.65 -{
   83.66 -	irq_desc_t *desc = irq_desc + irq;
   83.67 -	unsigned long flags;
   83.68 -
   83.69 -	if (irq >= NR_IRQS)
   83.70 -		return;
   83.71 -
   83.72 -	spin_lock_irqsave(&desc->lock, flags);
   83.73 -	if (!desc->depth++) {
   83.74 -		desc->status |= IRQ_DISABLED;
   83.75 -		desc->handler->disable(irq);
   83.76 -	}
   83.77 -	spin_unlock_irqrestore(&desc->lock, flags);
   83.78 -}
   83.79 -
   83.80 -EXPORT_SYMBOL(disable_irq_nosync);
   83.81 -
   83.82 -/**
   83.83 - *	disable_irq - disable an irq and wait for completion
   83.84 - *	@irq: Interrupt to disable
   83.85 - *
   83.86 - *	Disable the selected interrupt line.  Enables and Disables are
   83.87 - *	nested.
   83.88 - *	This function waits for any pending IRQ handlers for this interrupt
   83.89 - *	to complete before returning. If you use this function while
   83.90 - *	holding a resource the IRQ handler may need you will deadlock.
   83.91 - *
   83.92 - *	This function may be called - with care - from IRQ context.
   83.93 - */
   83.94 -void disable_irq(unsigned int irq)
   83.95 -{
   83.96 -	irq_desc_t *desc = irq_desc + irq;
   83.97 -
   83.98 -	if (irq >= NR_IRQS)
   83.99 -		return;
  83.100 -
  83.101 -	disable_irq_nosync(irq);
  83.102 -	if (desc->action)
  83.103 -		synchronize_irq(irq);
  83.104 -}
  83.105 -
  83.106 -EXPORT_SYMBOL(disable_irq);
  83.107 -
  83.108 -/**
  83.109 - *	enable_irq - enable handling of an irq
  83.110 - *	@irq: Interrupt to enable
  83.111 - *
  83.112 - *	Undoes the effect of one call to disable_irq().  If this
  83.113 - *	matches the last disable, processing of interrupts on this
  83.114 - *	IRQ line is re-enabled.
  83.115 - *
  83.116 - *	This function may be called from IRQ context.
  83.117 - */
  83.118 -void enable_irq(unsigned int irq)
  83.119 -{
  83.120 -	irq_desc_t *desc = irq_desc + irq;
  83.121 -	unsigned long flags;
  83.122 -
  83.123 -	if (irq >= NR_IRQS)
  83.124 -		return;
  83.125 -
  83.126 -	spin_lock_irqsave(&desc->lock, flags);
  83.127 -	switch (desc->depth) {
  83.128 -	case 0:
  83.129 -		WARN_ON(1);
  83.130 -		break;
  83.131 -	case 1: {
  83.132 -		unsigned int status = desc->status & ~IRQ_DISABLED;
  83.133 -
  83.134 -		desc->status = status;
  83.135 -		if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
  83.136 -			desc->status = status | IRQ_REPLAY;
  83.137 -			hw_resend_irq(desc->handler,irq);
  83.138 -		}
  83.139 -		desc->handler->enable(irq);
  83.140 -		/* fall-through */
  83.141 -	}
  83.142 -	default:
  83.143 -		desc->depth--;
  83.144 -	}
  83.145 -	spin_unlock_irqrestore(&desc->lock, flags);
  83.146 -}
  83.147 -
  83.148 -EXPORT_SYMBOL(enable_irq);
  83.149 -
  83.150 -/*
  83.151 - * Internal function that tells the architecture code whether a
  83.152 - * particular irq has been exclusively allocated or is available
  83.153 - * for driver use.
  83.154 - */
  83.155 -int can_request_irq(unsigned int irq, unsigned long irqflags)
  83.156 -{
  83.157 -	struct irqaction *action;
  83.158 -
  83.159 -	if (irq >= NR_IRQS)
  83.160 -		return 0;
  83.161 -
  83.162 -	action = irq_desc[irq].action;
  83.163 -	if (action)
  83.164 -		if (irqflags & action->flags & SA_SHIRQ)
  83.165 -			action = NULL;
  83.166 -
  83.167 -	return !action;
  83.168 -}
  83.169 -
  83.170 -/**
  83.171 - *	setup_irq - register an irqaction structure
  83.172 - *	@irq: Interrupt to register
  83.173 - *	@irqaction: The irqaction structure to be registered
  83.174 - *
  83.175 - *	Normally called by request_irq, this function can be used
  83.176 - *	directly to allocate special interrupts that are part of the
  83.177 - *	architecture.
  83.178 - */
  83.179 -int setup_irq(unsigned int irq, struct irqaction * new)
  83.180 -{
  83.181 -	struct irq_desc *desc = irq_desc + irq;
  83.182 -	struct irqaction *old, **p;
  83.183 -	unsigned long flags;
  83.184 -	int shared = 0;
  83.185 -
  83.186 -	if (irq >= NR_IRQS)
  83.187 -		return -EINVAL;
  83.188 -
  83.189 -	if (desc->handler == &no_irq_type)
  83.190 -		return -ENOSYS;
  83.191 -	/*
  83.192 -	 * Some drivers like serial.c use request_irq() heavily,
  83.193 -	 * so we have to be careful not to interfere with a
  83.194 -	 * running system.
  83.195 -	 */
  83.196 -	if (new->flags & SA_SAMPLE_RANDOM) {
  83.197 -		/*
  83.198 -		 * This function might sleep, we want to call it first,
  83.199 -		 * outside of the atomic block.
  83.200 -		 * Yes, this might clear the entropy pool if the wrong
  83.201 -		 * driver is attempted to be loaded, without actually
  83.202 -		 * installing a new handler, but is this really a problem,
  83.203 -		 * only the sysadmin is able to do this.
  83.204 -		 */
  83.205 -		rand_initialize_irq(irq);
  83.206 -	}
  83.207 -
  83.208 -	/*
  83.209 -	 * The following block of code has to be executed atomically
  83.210 -	 */
  83.211 -	spin_lock_irqsave(&desc->lock,flags);
  83.212 -	p = &desc->action;
  83.213 -	if ((old = *p) != NULL) {
  83.214 -		/* Can't share interrupts unless both agree to */
  83.215 -		if (!(old->flags & new->flags & SA_SHIRQ)) {
  83.216 -			spin_unlock_irqrestore(&desc->lock,flags);
  83.217 -			return -EBUSY;
  83.218 -		}
  83.219 -
  83.220 -		/* add new interrupt at end of irq queue */
  83.221 -		do {
  83.222 -			p = &old->next;
  83.223 -			old = *p;
  83.224 -		} while (old);
  83.225 -		shared = 1;
  83.226 -	}
  83.227 -
  83.228 -	*p = new;
  83.229 -
  83.230 -	if (!shared) {
  83.231 -		desc->depth = 0;
  83.232 -		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
  83.233 -				  IRQ_WAITING | IRQ_INPROGRESS);
  83.234 -		if (desc->handler->startup)
  83.235 -			desc->handler->startup(irq);
  83.236 -		else
  83.237 -			desc->handler->enable(irq);
  83.238 -	}
  83.239 -	spin_unlock_irqrestore(&desc->lock,flags);
  83.240 -
  83.241 -	new->irq = irq;
  83.242 -	register_irq_proc(irq);
  83.243 -	new->dir = NULL;
  83.244 -	register_handler_proc(irq, new);
  83.245 -
  83.246 -	return 0;
  83.247 -}
  83.248 -
  83.249 -/*
  83.250 - *	teardown_irq - unregister an irqaction
  83.251 - *	@irq: Interrupt line being freed
  83.252 - *	@old: Pointer to the irqaction that is to be unregistered
  83.253 - *
  83.254 - *	This function is called by free_irq and does the actual
  83.255 - *	business of unregistering the handler. It exists as a 
  83.256 - *	seperate function to enable handlers to be unregistered 
  83.257 - *	for irqactions that have been allocated statically at 
  83.258 - *	boot time.
  83.259 - *
  83.260 - *	This function must not be called from interrupt context.
  83.261 - */
  83.262 -#ifndef CONFIG_XEN
  83.263 -static
  83.264 -#endif
  83.265 -int teardown_irq(unsigned int irq, struct irqaction * old)
  83.266 -{
  83.267 -	struct irq_desc *desc;
  83.268 -	struct irqaction **p;
  83.269 -	unsigned long flags;
  83.270 -
  83.271 -	if (irq >= NR_IRQS)
  83.272 -		return -ENOENT;
  83.273 -
  83.274 -	desc = irq_desc + irq;
  83.275 -	spin_lock_irqsave(&desc->lock,flags);
  83.276 -	p = &desc->action;
  83.277 -	for (;;) {
  83.278 -		struct irqaction * action = *p;
  83.279 -
  83.280 -		if (action) {
  83.281 -			struct irqaction **pp = p;
  83.282 -
  83.283 -			p = &action->next;
  83.284 -			if (action != old)
  83.285 -				continue;
  83.286 -
  83.287 -			/* Found it - now remove it from the list of entries */
  83.288 -			*pp = action->next;
  83.289 -
  83.290 -			/* Currently used only by UML, might disappear one day.*/
  83.291 -#ifdef CONFIG_IRQ_RELEASE_METHOD
  83.292 -			if (desc->handler->release)
  83.293 -				desc->handler->release(irq, dev_id);
  83.294 -#endif
  83.295 -
  83.296 -			if (!desc->action) {
  83.297 -				desc->status |= IRQ_DISABLED;
  83.298 -				if (desc->handler->shutdown)
  83.299 -					desc->handler->shutdown(irq);
  83.300 -				else
  83.301 -					desc->handler->disable(irq);
  83.302 -			}
  83.303 -			spin_unlock_irqrestore(&desc->lock,flags);
  83.304 -			unregister_handler_proc(irq, action);
  83.305 -
  83.306 -			/* Make sure it's not being used on another CPU */
  83.307 -			synchronize_irq(irq);
  83.308 -			return 0;
  83.309 -		}
  83.310 -		printk(KERN_ERR "Trying to teardown free IRQ%d\n",irq);
  83.311 -		spin_unlock_irqrestore(&desc->lock,flags);
  83.312 -		return -ENOENT;
  83.313 -	}
  83.314 -}
  83.315 -
  83.316 -/**
  83.317 - *	free_irq - free an interrupt
  83.318 - *	@irq: Interrupt line to free
  83.319 - *	@dev_id: Device identity to free
  83.320 - *
  83.321 - *	Remove an interrupt handler. The handler is removed and if the
  83.322 - *	interrupt line is no longer in use by any driver it is disabled.
  83.323 - *	On a shared IRQ the caller must ensure the interrupt is disabled
  83.324 - *	on the card it drives before calling this function. The function
  83.325 - *	does not return until any executing interrupts for this IRQ
  83.326 - *	have completed.
  83.327 - *
  83.328 - *	This function must not be called from interrupt context.
  83.329 - */
  83.330 -void free_irq(unsigned int irq, void *dev_id)
  83.331 -{
  83.332 -	struct irq_desc *desc;
  83.333 -	struct irqaction *action;
  83.334 -	unsigned long flags;
  83.335 -
  83.336 -	if (irq >= NR_IRQS)
  83.337 -		return;
  83.338 -
  83.339 -	desc = irq_desc + irq;
  83.340 -	spin_lock_irqsave(&desc->lock,flags);
  83.341 -	for (action = desc->action; action != NULL; action = action->next) {
  83.342 -		if (action->dev_id != dev_id)
  83.343 -			continue;
  83.344 -
  83.345 -		spin_unlock_irqrestore(&desc->lock,flags);
  83.346 -
  83.347 -		if (teardown_irq(irq, action) == 0)
  83.348 -			kfree(action);
  83.349 -		return;
  83.350 -	}
  83.351 -	printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
  83.352 -	spin_unlock_irqrestore(&desc->lock,flags);
  83.353 -	return;
  83.354 -}
  83.355 -
  83.356 -EXPORT_SYMBOL(free_irq);
  83.357 -
  83.358 -/**
  83.359 - *	request_irq - allocate an interrupt line
  83.360 - *	@irq: Interrupt line to allocate
  83.361 - *	@handler: Function to be called when the IRQ occurs
  83.362 - *	@irqflags: Interrupt type flags
  83.363 - *	@devname: An ascii name for the claiming device
  83.364 - *	@dev_id: A cookie passed back to the handler function
  83.365 - *
  83.366 - *	This call allocates interrupt resources and enables the
  83.367 - *	interrupt line and IRQ handling. From the point this
  83.368 - *	call is made your handler function may be invoked. Since
  83.369 - *	your handler function must clear any interrupt the board
  83.370 - *	raises, you must take care both to initialise your hardware
  83.371 - *	and to set up the interrupt handler in the right order.
  83.372 - *
  83.373 - *	Dev_id must be globally unique. Normally the address of the
  83.374 - *	device data structure is used as the cookie. Since the handler
  83.375 - *	receives this value it makes sense to use it.
  83.376 - *
  83.377 - *	If your interrupt is shared you must pass a non NULL dev_id
  83.378 - *	as this is required when freeing the interrupt.
  83.379 - *
  83.380 - *	Flags:
  83.381 - *
  83.382 - *	SA_SHIRQ		Interrupt is shared
  83.383 - *	SA_INTERRUPT		Disable local interrupts while processing
  83.384 - *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
  83.385 - *
  83.386 - */
  83.387 -int request_irq(unsigned int irq,
  83.388 -		irqreturn_t (*handler)(int, void *, struct pt_regs *),
  83.389 -		unsigned long irqflags, const char * devname, void *dev_id)
  83.390 -{
  83.391 -	struct irqaction * action;
  83.392 -	int retval;
  83.393 -
  83.394 -	/*
  83.395 -	 * Sanity-check: shared interrupts must pass in a real dev-ID,
  83.396 -	 * otherwise we'll have trouble later trying to figure out
  83.397 -	 * which interrupt is which (messes up the interrupt freeing
  83.398 -	 * logic etc).
  83.399 -	 */
  83.400 -	if ((irqflags & SA_SHIRQ) && !dev_id)
  83.401 -		return -EINVAL;
  83.402 -	if (irq >= NR_IRQS)
  83.403 -		return -EINVAL;
  83.404 -	if (!handler)
  83.405 -		return -EINVAL;
  83.406 -
  83.407 -	action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
  83.408 -	if (!action)
  83.409 -		return -ENOMEM;
  83.410 -
  83.411 -	action->handler = handler;
  83.412 -	action->flags = irqflags;
  83.413 -	cpus_clear(action->mask);
  83.414 -	action->name = devname;
  83.415 -	action->next = NULL;
  83.416 -	action->dev_id = dev_id;
  83.417 -
  83.418 -	select_smp_affinity(irq);
  83.419 -
  83.420 -	retval = setup_irq(irq, action);
  83.421 -	if (retval)
  83.422 -		kfree(action);
  83.423 -
  83.424 -	return retval;
  83.425 -}
  83.426 -
  83.427 -EXPORT_SYMBOL(request_irq);
  83.428 -
    84.1 --- a/linux-2.6-xen-sparse/lib/Kconfig.debug	Tue Apr 11 13:55:47 2006 -0600
    84.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.3 @@ -1,224 +0,0 @@
    84.4 -
    84.5 -config PRINTK_TIME
    84.6 -	bool "Show timing information on printks"
    84.7 -	help
    84.8 -	  Selecting this option causes timing information to be
    84.9 -	  included in printk output.  This allows you to measure
   84.10 -	  the interval between kernel operations, including bootup
   84.11 -	  operations.  This is useful for identifying long delays
   84.12 -	  in kernel startup.
   84.13 -
   84.14 -
   84.15 -config MAGIC_SYSRQ
   84.16 -	bool "Magic SysRq key"
   84.17 -	depends on !UML
   84.18 -	help
   84.19 -	  If you say Y here, you will have some control over the system even
   84.20 -	  if the system crashes for example during kernel debugging (e.g., you
   84.21 -	  will be able to flush the buffer cache to disk, reboot the system
   84.22 -	  immediately or dump some status information). This is accomplished
   84.23 -	  by pressing various keys while holding SysRq (Alt+PrintScreen). It
   84.24 -	  also works on a serial console (on PC hardware at least), if you
   84.25 -	  send a BREAK and then within 5 seconds a command keypress. The
   84.26 -	  keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
   84.27 -	  unless you really know what this hack does.
   84.28 -
   84.29 -config DEBUG_KERNEL
   84.30 -	bool "Kernel debugging"
   84.31 -	help
   84.32 -	  Say Y here if you are developing drivers or trying to debug and
   84.33 -	  identify kernel problems.
   84.34 -
   84.35 -config LOG_BUF_SHIFT
   84.36 -	int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
   84.37 -	range 12 21
   84.38 -	default 17 if S390
   84.39 -	default 16 if X86_NUMAQ || IA64
   84.40 -	default 15 if SMP
   84.41 -	default 14
   84.42 -	help
   84.43 -	  Select kernel log buffer size as a power of 2.
   84.44 -	  Defaults and Examples:
   84.45 -	  	     17 => 128 KB for S/390
   84.46 -		     16 => 64 KB for x86 NUMAQ or IA-64
   84.47 -	             15 => 32 KB for SMP
   84.48 -	             14 => 16 KB for uniprocessor
   84.49 -		     13 =>  8 KB
   84.50 -		     12 =>  4 KB
   84.51 -
   84.52 -config DETECT_SOFTLOCKUP
   84.53 -	bool "Detect Soft Lockups"
   84.54 -	depends on DEBUG_KERNEL
   84.55 -	default y
   84.56 -	help
   84.57 -	  Say Y here to enable the kernel to detect "soft lockups",
   84.58 -	  which are bugs that cause the kernel to loop in kernel
   84.59 -	  mode for more than 10 seconds, without giving other tasks a
   84.60 -	  chance to run.
   84.61 -
   84.62 -	  When a soft-lockup is detected, the kernel will print the
   84.63 -	  current stack trace (which you should report), but the
   84.64 -	  system will stay locked up. This feature has negligible
   84.65 -	  overhead.
   84.66 -
   84.67 -	  (Note that "hard lockups" are separate type of bugs that
   84.68 -	   can be detected via the NMI-watchdog, on platforms that
   84.69 -	   support it.)
   84.70 -
   84.71 -config SCHEDSTATS
   84.72 -	bool "Collect scheduler statistics"
   84.73 -	depends on DEBUG_KERNEL && PROC_FS
   84.74 -	help
   84.75 -	  If you say Y here, additional code will be inserted into the
   84.76 -	  scheduler and related routines to collect statistics about
   84.77 -	  scheduler behavior and provide them in /proc/schedstat.  These
   84.78 -	  stats may be useful for both tuning and debugging the scheduler
   84.79 -	  If you aren't debugging the scheduler or trying to tune a specific
   84.80 -	  application, you can say N to avoid the very slight overhead
   84.81 -	  this adds.
   84.82 -
   84.83 -config DEBUG_SLAB
   84.84 -	bool "Debug memory allocations"
   84.85 -	depends on DEBUG_KERNEL && SLAB
   84.86 -	help
   84.87 -	  Say Y here to have the kernel do limited verification on memory
   84.88 -	  allocation as well as poisoning memory on free to catch use of freed
   84.89 -	  memory. This can make kmalloc/kfree-intensive workloads much slower.
   84.90 -
   84.91 -config DEBUG_PREEMPT
   84.92 -	bool "Debug preemptible kernel"
   84.93 -	depends on DEBUG_KERNEL && PREEMPT
   84.94 -	default y
   84.95 -	help
   84.96 -	  If you say Y here then the kernel will use a debug variant of the
   84.97 -	  commonly used smp_processor_id() function and will print warnings
   84.98 -	  if kernel code uses it in a preemption-unsafe way. Also, the kernel
   84.99 -	  will detect preemption count underflows.
  84.100 -
  84.101 -config DEBUG_MUTEXES
  84.102 -	bool "Mutex debugging, deadlock detection"
  84.103 -	default y
  84.104 -	depends on DEBUG_KERNEL
  84.105 -	help
  84.106 -	 This allows mutex semantics violations and mutex related deadlocks
  84.107 -	 (lockups) to be detected and reported automatically.
  84.108 -
  84.109 -config DEBUG_SPINLOCK
  84.110 -	bool "Spinlock debugging"
  84.111 -	depends on DEBUG_KERNEL
  84.112 -	help
  84.113 -	  Say Y here and build SMP to catch missing spinlock initialization
  84.114 -	  and certain other kinds of spinlock errors commonly made.  This is
  84.115 -	  best used in conjunction with the NMI watchdog so that spinlock
  84.116 -	  deadlocks are also debuggable.
  84.117 -
  84.118 -config DEBUG_SPINLOCK_SLEEP
  84.119 -	bool "Sleep-inside-spinlock checking"
  84.120 -	depends on DEBUG_KERNEL
  84.121 -	help
  84.122 -	  If you say Y here, various routines which may sleep will become very
  84.123 -	  noisy if they are called with a spinlock held.
  84.124 -
  84.125 -config DEBUG_KOBJECT
  84.126 -	bool "kobject debugging"
  84.127 -	depends on DEBUG_KERNEL
  84.128 -	help
  84.129 -	  If you say Y here, some extra kobject debugging messages will be sent
  84.130 -	  to the syslog. 
  84.131 -
  84.132 -config DEBUG_HIGHMEM
  84.133 -	bool "Highmem debugging"
  84.134 -	depends on DEBUG_KERNEL && HIGHMEM
  84.135 -	help
  84.136 -	  This options enables addition error checking for high memory systems.
  84.137 -	  Disable for production systems.
  84.138 -
  84.139 -config DEBUG_BUGVERBOSE
  84.140 -	bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
  84.141 -	depends on BUG
  84.142 -	depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || X86_32 || FRV
  84.143 -	default !EMBEDDED
  84.144 -	help
  84.145 -	  Say Y here to make BUG() panics output the file name and line number
  84.146 -	  of the BUG call as well as the EIP and oops trace.  This aids
  84.147 -	  debugging but costs about 70-100K of memory.
  84.148 -
  84.149 -config DEBUG_INFO
  84.150 -	bool "Compile the kernel with debug info"
  84.151 -	depends on DEBUG_KERNEL && !X86_64_XEN
  84.152 -	help
  84.153 -          If you say Y here the resulting kernel image will include
  84.154 -	  debugging info resulting in a larger kernel image.
  84.155 -	  Say Y here only if you plan to debug the kernel.
  84.156 -
  84.157 -	  If unsure, say N.
  84.158 -
  84.159 -config DEBUG_IOREMAP
  84.160 -	bool "Enable ioremap() debugging"
  84.161 -	depends on DEBUG_KERNEL && PARISC
  84.162 -	help
  84.163 -	  Enabling this option will cause the kernel to distinguish between
  84.164 -	  ioremapped and physical addresses.  It will print a backtrace (at
  84.165 -	  most one every 10 seconds), hopefully allowing you to see which
  84.166 -	  drivers need work.  Fixing all these problems is a prerequisite
  84.167 -	  for turning on USE_HPPA_IOREMAP.  The warnings are harmless;
  84.168 -	  the kernel has enough information to fix the broken drivers
  84.169 -	  automatically, but we'd like to make it more efficient by not
  84.170 -	  having to do that.
  84.171 -
  84.172 -config DEBUG_FS
  84.173 -	bool "Debug Filesystem"
  84.174 -	depends on DEBUG_KERNEL && SYSFS
  84.175 -	help
  84.176 -	  debugfs is a virtual file system that kernel developers use to put
  84.177 -	  debugging files into.  Enable this option to be able to read and
  84.178 -	  write to these files.
  84.179 -
  84.180 -	  If unsure, say N.
  84.181 -
  84.182 -config DEBUG_VM
  84.183 -	bool "Debug VM"
  84.184 -	depends on DEBUG_KERNEL
  84.185 -	help
  84.186 -	  Enable this to turn on extended checks in the virtual-memory system
  84.187 -          that may impact performance.
  84.188 -
  84.189 -	  If unsure, say N.
  84.190 -
  84.191 -config FRAME_POINTER
  84.192 -	bool "Compile the kernel with frame pointers"
  84.193 -	depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML)
  84.194 -	default y if DEBUG_INFO && UML
  84.195 -	help
  84.196 -	  If you say Y here the resulting kernel image will be slightly larger
  84.197 -	  and slower, but it might give very useful debugging information on
  84.198 -	  some architectures or if you use external debuggers.
  84.199 -	  If you don't debug the kernel, you can say N.
  84.200 -
  84.201 -config FORCED_INLINING
  84.202 -	bool "Force gcc to inline functions marked 'inline'"
  84.203 -	depends on DEBUG_KERNEL
  84.204 -	default y
  84.205 -	help
  84.206 -	  This option determines if the kernel forces gcc to inline the functions
  84.207 -	  developers have marked 'inline'. Doing so takes away freedom from gcc to
  84.208 -	  do what it thinks is best, which is desirable for the gcc 3.x series of
  84.209 -	  compilers. The gcc 4.x series have a rewritten inlining algorithm and
  84.210 -	  disabling this option will generate a smaller kernel there. Hopefully
  84.211 -	  this algorithm is so good that allowing gcc4 to make the decision can
  84.212 -	  become the default in the future, until then this option is there to
  84.213 -	  test gcc for this.
  84.214 -
  84.215 -config RCU_TORTURE_TEST
  84.216 -	tristate "torture tests for RCU"
  84.217 -	depends on DEBUG_KERNEL
  84.218 -	default n
  84.219 -	help
  84.220 -	  This option provides a kernel module that runs torture tests
  84.221 -	  on the RCU infrastructure.  The kernel module may be built
  84.222 -	  after the fact on the running kernel to be tested, if desired.
  84.223 -
  84.224 -	  Say Y here if you want RCU torture tests to start automatically
  84.225 -	  at boot time (you probably don't).
  84.226 -	  Say M if you want the RCU torture tests to build as a module.
  84.227 -	  Say N if you are unsure.
    85.1 --- a/linux-2.6-xen-sparse/net/core/dev.c	Tue Apr 11 13:55:47 2006 -0600
    85.2 +++ b/linux-2.6-xen-sparse/net/core/dev.c	Tue Apr 11 18:54:18 2006 -0600
    85.3 @@ -1649,12 +1649,12 @@ int netif_receive_skb(struct sk_buff *sk
    85.4  #ifdef CONFIG_XEN
    85.5  	switch (skb->ip_summed) {
    85.6  	case CHECKSUM_UNNECESSARY:
    85.7 -		skb->proto_csum_valid = 1;
    85.8 +		skb->proto_data_valid = 1;
    85.9  		break;
   85.10  	case CHECKSUM_HW:
   85.11  		/* XXX Implement me. */
   85.12  	default:
   85.13 -		skb->proto_csum_valid = 0;
   85.14 +		skb->proto_data_valid = 0;
   85.15  		break;
   85.16  	}
   85.17  #endif
    86.1 --- a/linux-2.6-xen-sparse/net/core/skbuff.c	Tue Apr 11 13:55:47 2006 -0600
    86.2 +++ b/linux-2.6-xen-sparse/net/core/skbuff.c	Tue Apr 11 18:54:18 2006 -0600
    86.3 @@ -428,7 +428,7 @@ struct sk_buff *skb_clone(struct sk_buff
    86.4  	n->cloned = 1;
    86.5  	n->nohdr = 0;
    86.6  #ifdef CONFIG_XEN
    86.7 -	C(proto_csum_valid);
    86.8 +	C(proto_data_valid);
    86.9  	C(proto_csum_blank);
   86.10  #endif
   86.11  	C(pkt_type);
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/patches/linux-2.6.16/x86-increase-interrupt-vector-range.patch	Tue Apr 11 18:54:18 2006 -0600
    87.3 @@ -0,0 +1,107 @@
    87.4 +Subject: Increase x86 interrupt vector range
    87.5 +
    87.6 +Remove the limit of 256 interrupt vectors by changing the value
    87.7 +stored in orig_{e,r}ax to be the negated interrupt vector.
    87.8 +The orig_{e,r}ax needs to be < 0 to allow the signal code to
    87.9 +distinguish between return from interrupt and return from syscall.
   87.10 +With this change applied, NR_IRQS can be > 256.
   87.11 +
   87.12 +Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
   87.13 +---
   87.14 + arch/i386/kernel/entry.S    |    4 ++--
   87.15 + arch/i386/kernel/irq.c      |    4 ++--
   87.16 + arch/x86_64/kernel/entry.S  |    2 +-
   87.17 + arch/x86_64/kernel/irq.c    |    4 ++--
   87.18 + arch/x86_64/kernel/smp.c    |    4 ++--
   87.19 + include/asm-x86_64/hw_irq.h |    2 +-
   87.20 + 6 files changed, 10 insertions(+), 10 deletions(-)
   87.21 +
   87.22 +diff -r 7d239c83edea arch/i386/kernel/entry.S
   87.23 +--- a/arch/i386/kernel/entry.S	Mon Mar 20 06:00:20 2006 +0000
   87.24 ++++ b/arch/i386/kernel/entry.S	Fri Mar 31 17:01:35 2006 +0100
   87.25 +@@ -406,7 +406,7 @@ ENTRY(irq_entries_start)
   87.26 + ENTRY(irq_entries_start)
   87.27 + .rept NR_IRQS
   87.28 + 	ALIGN
   87.29 +-1:	pushl $vector-256
   87.30 ++1:	pushl $~(vector)
   87.31 + 	jmp common_interrupt
   87.32 + .data
   87.33 + 	.long 1b
   87.34 +@@ -423,7 +423,7 @@ common_interrupt:
   87.35 + 
   87.36 + #define BUILD_INTERRUPT(name, nr)	\
   87.37 + ENTRY(name)				\
   87.38 +-	pushl $nr-256;			\
   87.39 ++	pushl $~(nr);			\
   87.40 + 	SAVE_ALL			\
   87.41 + 	movl %esp,%eax;			\
   87.42 + 	call smp_/**/name;		\
   87.43 +diff -r 7d239c83edea arch/i386/kernel/irq.c
   87.44 +--- a/arch/i386/kernel/irq.c	Mon Mar 20 06:00:20 2006 +0000
   87.45 ++++ b/arch/i386/kernel/irq.c	Fri Mar 31 17:01:35 2006 +0100
   87.46 +@@ -53,8 +53,8 @@ static union irq_ctx *softirq_ctx[NR_CPU
   87.47 +  */
   87.48 + fastcall unsigned int do_IRQ(struct pt_regs *regs)
   87.49 + {	
   87.50 +-	/* high bits used in ret_from_ code */
   87.51 +-	int irq = regs->orig_eax & 0xff;
   87.52 ++	/* high bit used in ret_from_ code */
   87.53 ++	int irq = ~regs->orig_eax;
   87.54 + #ifdef CONFIG_4KSTACKS
   87.55 + 	union irq_ctx *curctx, *irqctx;
   87.56 + 	u32 *isp;
   87.57 +diff -r 7d239c83edea arch/x86_64/kernel/entry.S
   87.58 +--- a/arch/x86_64/kernel/entry.S	Mon Mar 20 06:00:20 2006 +0000
   87.59 ++++ b/arch/x86_64/kernel/entry.S	Fri Mar 31 17:01:35 2006 +0100
   87.60 +@@ -609,7 +609,7 @@ retint_kernel:
   87.61 +  */		
   87.62 + 	.macro apicinterrupt num,func
   87.63 + 	INTR_FRAME
   87.64 +-	pushq $\num-256
   87.65 ++	pushq $~(\num)
   87.66 + 	CFI_ADJUST_CFA_OFFSET 8
   87.67 + 	interrupt \func
   87.68 + 	jmp ret_from_intr
   87.69 +diff -r 7d239c83edea arch/x86_64/kernel/irq.c
   87.70 +--- a/arch/x86_64/kernel/irq.c	Mon Mar 20 06:00:20 2006 +0000
   87.71 ++++ b/arch/x86_64/kernel/irq.c	Fri Mar 31 17:01:35 2006 +0100
   87.72 +@@ -96,8 +96,8 @@ skip:
   87.73 +  */
   87.74 + asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
   87.75 + {	
   87.76 +-	/* high bits used in ret_from_ code  */
   87.77 +-	unsigned irq = regs->orig_rax & 0xff;
   87.78 ++	/* high bit used in ret_from_ code  */
   87.79 ++	unsigned irq = ~regs->orig_rax;
   87.80 + 
   87.81 + 	exit_idle();
   87.82 + 	irq_enter();
   87.83 +diff -r 7d239c83edea arch/x86_64/kernel/smp.c
   87.84 +--- a/arch/x86_64/kernel/smp.c	Mon Mar 20 06:00:20 2006 +0000
   87.85 ++++ b/arch/x86_64/kernel/smp.c	Fri Mar 31 17:01:35 2006 +0100
   87.86 +@@ -135,10 +135,10 @@ asmlinkage void smp_invalidate_interrupt
   87.87 + 
   87.88 + 	cpu = smp_processor_id();
   87.89 + 	/*
   87.90 +-	 * orig_rax contains the interrupt vector - 256.
   87.91 ++	 * orig_rax contains the negated interrupt vector.
   87.92 + 	 * Use that to determine where the sender put the data.
   87.93 + 	 */
   87.94 +-	sender = regs->orig_rax + 256 - INVALIDATE_TLB_VECTOR_START;
   87.95 ++	sender = ~regs->orig_rax - INVALIDATE_TLB_VECTOR_START;
   87.96 + 	f = &per_cpu(flush_state, sender);
   87.97 + 
   87.98 + 	if (!cpu_isset(cpu, f->flush_cpumask))
   87.99 +diff -r 7d239c83edea include/asm-x86_64/hw_irq.h
  87.100 +--- a/include/asm-x86_64/hw_irq.h	Mon Mar 20 06:00:20 2006 +0000
  87.101 ++++ b/include/asm-x86_64/hw_irq.h	Fri Mar 31 17:01:35 2006 +0100
  87.102 +@@ -127,7 +127,7 @@ __asm__( \
  87.103 + __asm__( \
  87.104 + "\n.p2align\n" \
  87.105 + "IRQ" #nr "_interrupt:\n\t" \
  87.106 +-	"push $" #nr "-256 ; " \
  87.107 ++	"push $~(" #nr ") ; " \
  87.108 + 	"jmp common_interrupt");
  87.109 + 
  87.110 + #if defined(CONFIG_X86_IO_APIC)
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/patches/linux-2.6.16/xenoprof-generic.patch	Tue Apr 11 18:54:18 2006 -0600
    88.3 @@ -0,0 +1,384 @@
    88.4 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/buffer_sync.c ./drivers/oprofile/buffer_sync.c
    88.5 +--- ../pristine-linux-2.6.16/drivers/oprofile/buffer_sync.c	2006-03-20 05:53:29.000000000 +0000
    88.6 ++++ ./drivers/oprofile/buffer_sync.c	2006-04-03 15:53:05.000000000 +0100
    88.7 +@@ -6,6 +6,10 @@
    88.8 +  *
    88.9 +  * @author John Levon <levon@movementarian.org>
   88.10 +  *
   88.11 ++ * Modified by Aravind Menon for Xen
   88.12 ++ * These modifications are:
   88.13 ++ * Copyright (C) 2005 Hewlett-Packard Co.
   88.14 ++ *
   88.15 +  * This is the core of the buffer management. Each
   88.16 +  * CPU buffer is processed and entered into the
   88.17 +  * global event buffer. Such processing is necessary
   88.18 +@@ -275,15 +279,24 @@ static void add_cpu_switch(int i)
   88.19 + 	last_cookie = INVALID_COOKIE;
   88.20 + }
   88.21 + 
   88.22 +-static void add_kernel_ctx_switch(unsigned int in_kernel)
   88.23 ++static void add_cpu_mode_switch(unsigned int cpu_mode)
   88.24 + {
   88.25 + 	add_event_entry(ESCAPE_CODE);
   88.26 +-	if (in_kernel)
   88.27 +-		add_event_entry(KERNEL_ENTER_SWITCH_CODE); 
   88.28 +-	else
   88.29 +-		add_event_entry(KERNEL_EXIT_SWITCH_CODE); 
   88.30 ++	switch (cpu_mode) {
   88.31 ++	case CPU_MODE_USER:
   88.32 ++		add_event_entry(USER_ENTER_SWITCH_CODE);
   88.33 ++		break;
   88.34 ++	case CPU_MODE_KERNEL:
   88.35 ++		add_event_entry(KERNEL_ENTER_SWITCH_CODE);
   88.36 ++		break;
   88.37 ++	case CPU_MODE_XEN:
   88.38 ++		add_event_entry(XEN_ENTER_SWITCH_CODE);
   88.39 ++		break;
   88.40 ++	default:
   88.41 ++		break;
   88.42 ++	}
   88.43 + }
   88.44 +- 
   88.45 ++
   88.46 + static void
   88.47 + add_user_ctx_switch(struct task_struct const * task, unsigned long cookie)
   88.48 + {
   88.49 +@@ -348,9 +361,9 @@ static int add_us_sample(struct mm_struc
   88.50 +  * for later lookup from userspace.
   88.51 +  */
   88.52 + static int
   88.53 +-add_sample(struct mm_struct * mm, struct op_sample * s, int in_kernel)
   88.54 ++add_sample(struct mm_struct * mm, struct op_sample * s, int cpu_mode)
   88.55 + {
   88.56 +-	if (in_kernel) {
   88.57 ++	if (cpu_mode >= CPU_MODE_KERNEL) {
   88.58 + 		add_sample_entry(s->eip, s->event);
   88.59 + 		return 1;
   88.60 + 	} else if (mm) {
   88.61 +@@ -496,7 +509,7 @@ void sync_buffer(int cpu)
   88.62 + 	struct mm_struct *mm = NULL;
   88.63 + 	struct task_struct * new;
   88.64 + 	unsigned long cookie = 0;
   88.65 +-	int in_kernel = 1;
   88.66 ++	int cpu_mode = 1;
   88.67 + 	unsigned int i;
   88.68 + 	sync_buffer_state state = sb_buffer_start;
   88.69 + 	unsigned long available;
   88.70 +@@ -513,12 +526,12 @@ void sync_buffer(int cpu)
   88.71 + 		struct op_sample * s = &cpu_buf->buffer[cpu_buf->tail_pos];
   88.72 +  
   88.73 + 		if (is_code(s->eip)) {
   88.74 +-			if (s->event <= CPU_IS_KERNEL) {
   88.75 ++			if (s->event <= CPU_MODE_XEN) {
   88.76 + 				/* kernel/userspace switch */
   88.77 +-				in_kernel = s->event;
   88.78 ++				cpu_mode = s->event;
   88.79 + 				if (state == sb_buffer_start)
   88.80 + 					state = sb_sample_start;
   88.81 +-				add_kernel_ctx_switch(s->event);
   88.82 ++				add_cpu_mode_switch(s->event);
   88.83 + 			} else if (s->event == CPU_TRACE_BEGIN) {
   88.84 + 				state = sb_bt_start;
   88.85 + 				add_trace_begin();
   88.86 +@@ -536,7 +549,7 @@ void sync_buffer(int cpu)
   88.87 + 			}
   88.88 + 		} else {
   88.89 + 			if (state >= sb_bt_start &&
   88.90 +-			    !add_sample(mm, s, in_kernel)) {
   88.91 ++			    !add_sample(mm, s, cpu_mode)) {
   88.92 + 				if (state == sb_bt_start) {
   88.93 + 					state = sb_bt_ignore;
   88.94 + 					atomic_inc(&oprofile_stats.bt_lost_no_mapping);
   88.95 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/cpu_buffer.c ./drivers/oprofile/cpu_buffer.c
   88.96 +--- ../pristine-linux-2.6.16/drivers/oprofile/cpu_buffer.c	2006-03-20 05:53:29.000000000 +0000
   88.97 ++++ ./drivers/oprofile/cpu_buffer.c	2006-04-03 15:53:05.000000000 +0100
   88.98 +@@ -6,6 +6,10 @@
   88.99 +  *
  88.100 +  * @author John Levon <levon@movementarian.org>
  88.101 +  *
  88.102 ++ * Modified by Aravind Menon for Xen
  88.103 ++ * These modifications are:
  88.104 ++ * Copyright (C) 2005 Hewlett-Packard Co.
  88.105 ++ *
  88.106 +  * Each CPU has a local buffer that stores PC value/event
  88.107 +  * pairs. We also log context switches when we notice them.
  88.108 +  * Eventually each CPU's buffer is processed into the global
  88.109 +@@ -58,7 +62,7 @@ int alloc_cpu_buffers(void)
  88.110 + 			goto fail;
  88.111 +  
  88.112 + 		b->last_task = NULL;
  88.113 +-		b->last_is_kernel = -1;
  88.114 ++		b->last_cpu_mode = -1;
  88.115 + 		b->tracing = 0;
  88.116 + 		b->buffer_size = buffer_size;
  88.117 + 		b->tail_pos = 0;
  88.118 +@@ -114,7 +118,7 @@ void cpu_buffer_reset(struct oprofile_cp
  88.119 + 	 * collected will populate the buffer with proper
  88.120 + 	 * values to initialize the buffer
  88.121 + 	 */
  88.122 +-	cpu_buf->last_is_kernel = -1;
  88.123 ++	cpu_buf->last_cpu_mode = -1;
  88.124 + 	cpu_buf->last_task = NULL;
  88.125 + }
  88.126 + 
  88.127 +@@ -164,13 +168,13 @@ add_code(struct oprofile_cpu_buffer * bu
  88.128 +  * because of the head/tail separation of the writer and reader
  88.129 +  * of the CPU buffer.
  88.130 +  *
  88.131 +- * is_kernel is needed because on some architectures you cannot
  88.132 ++ * cpu_mode is needed because on some architectures you cannot
  88.133 +  * tell if you are in kernel or user space simply by looking at
  88.134 +- * pc. We tag this in the buffer by generating kernel enter/exit
  88.135 +- * events whenever is_kernel changes
  88.136 ++ * pc. We tag this in the buffer by generating kernel/user (and xen)
  88.137 ++ *  enter events whenever cpu_mode changes
  88.138 +  */
  88.139 + static int log_sample(struct oprofile_cpu_buffer * cpu_buf, unsigned long pc,
  88.140 +-		      int is_kernel, unsigned long event)
  88.141 ++		      int cpu_mode, unsigned long event)
  88.142 + {
  88.143 + 	struct task_struct * task;
  88.144 + 
  88.145 +@@ -181,16 +185,16 @@ static int log_sample(struct oprofile_cp
  88.146 + 		return 0;
  88.147 + 	}
  88.148 + 
  88.149 +-	is_kernel = !!is_kernel;
  88.150 ++	WARN_ON(cpu_mode > CPU_MODE_XEN);
  88.151 + 
  88.152 + 	task = current;
  88.153 + 
  88.154 + 	/* notice a switch from user->kernel or vice versa */
  88.155 +-	if (cpu_buf->last_is_kernel != is_kernel) {
  88.156 +-		cpu_buf->last_is_kernel = is_kernel;
  88.157 +-		add_code(cpu_buf, is_kernel);
  88.158 ++	if (cpu_buf->last_cpu_mode != cpu_mode) {
  88.159 ++		cpu_buf->last_cpu_mode = cpu_mode;
  88.160 ++		add_code(cpu_buf, cpu_mode);
  88.161 + 	}
  88.162 +-
  88.163 ++	
  88.164 + 	/* notice a task switch */
  88.165 + 	if (cpu_buf->last_task != task) {
  88.166 + 		cpu_buf->last_task = task;
  88.167 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/cpu_buffer.h ./drivers/oprofile/cpu_buffer.h
  88.168 +--- ../pristine-linux-2.6.16/drivers/oprofile/cpu_buffer.h	2006-03-20 05:53:29.000000000 +0000
  88.169 ++++ ./drivers/oprofile/cpu_buffer.h	2006-04-03 15:53:05.000000000 +0100
  88.170 +@@ -36,7 +36,7 @@ struct oprofile_cpu_buffer {
  88.171 + 	volatile unsigned long tail_pos;
  88.172 + 	unsigned long buffer_size;
  88.173 + 	struct task_struct * last_task;
  88.174 +-	int last_is_kernel;
  88.175 ++	int last_cpu_mode;
  88.176 + 	int tracing;
  88.177 + 	struct op_sample * buffer;
  88.178 + 	unsigned long sample_received;
  88.179 +@@ -51,7 +51,9 @@ extern struct oprofile_cpu_buffer cpu_bu
  88.180 + void cpu_buffer_reset(struct oprofile_cpu_buffer * cpu_buf);
  88.181 + 
  88.182 + /* transient events for the CPU buffer -> event buffer */
  88.183 +-#define CPU_IS_KERNEL 1
  88.184 +-#define CPU_TRACE_BEGIN 2
  88.185 ++#define CPU_MODE_USER    0
  88.186 ++#define CPU_MODE_KERNEL  1
  88.187 ++#define CPU_MODE_XEN     2
  88.188 ++#define CPU_TRACE_BEGIN  3
  88.189 + 
  88.190 + #endif /* OPROFILE_CPU_BUFFER_H */
  88.191 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/event_buffer.h ./drivers/oprofile/event_buffer.h
  88.192 +--- ../pristine-linux-2.6.16/drivers/oprofile/event_buffer.h	2006-03-20 05:53:29.000000000 +0000
  88.193 ++++ ./drivers/oprofile/event_buffer.h	2006-04-03 15:53:05.000000000 +0100
  88.194 +@@ -29,11 +29,12 @@ void wake_up_buffer_waiter(void);
  88.195 + #define CPU_SWITCH_CODE 		2
  88.196 + #define COOKIE_SWITCH_CODE 		3
  88.197 + #define KERNEL_ENTER_SWITCH_CODE	4
  88.198 +-#define KERNEL_EXIT_SWITCH_CODE		5
  88.199 ++#define USER_ENTER_SWITCH_CODE		5
  88.200 + #define MODULE_LOADED_CODE		6
  88.201 + #define CTX_TGID_CODE			7
  88.202 + #define TRACE_BEGIN_CODE		8
  88.203 + #define TRACE_END_CODE			9
  88.204 ++#define XEN_ENTER_SWITCH_CODE		10
  88.205 +  
  88.206 + #define INVALID_COOKIE ~0UL
  88.207 + #define NO_COOKIE 0UL
  88.208 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/oprof.c ./drivers/oprofile/oprof.c
  88.209 +--- ../pristine-linux-2.6.16/drivers/oprofile/oprof.c	2006-03-20 05:53:29.000000000 +0000
  88.210 ++++ ./drivers/oprofile/oprof.c	2006-04-03 15:53:05.000000000 +0100
  88.211 +@@ -5,6 +5,10 @@
  88.212 +  * @remark Read the file COPYING
  88.213 +  *
  88.214 +  * @author John Levon <levon@movementarian.org>
  88.215 ++ *
  88.216 ++ * Modified by Aravind Menon for Xen
  88.217 ++ * These modifications are:
  88.218 ++ * Copyright (C) 2005 Hewlett-Packard Co.
  88.219 +  */
  88.220 + 
  88.221 + #include <linux/kernel.h>
  88.222 +@@ -19,7 +23,7 @@
  88.223 + #include "cpu_buffer.h"
  88.224 + #include "buffer_sync.h"
  88.225 + #include "oprofile_stats.h"
  88.226 +- 
  88.227 ++
  88.228 + struct oprofile_operations oprofile_ops;
  88.229 + 
  88.230 + unsigned long oprofile_started;
  88.231 +@@ -33,6 +37,17 @@ static DECLARE_MUTEX(start_sem);
  88.232 +  */
  88.233 + static int timer = 0;
  88.234 + 
  88.235 ++extern unsigned int adomains;
  88.236 ++extern int active_domains[MAX_OPROF_DOMAINS];
  88.237 ++
  88.238 ++int oprofile_set_active(void)
  88.239 ++{
  88.240 ++	if (oprofile_ops.set_active)
  88.241 ++		return oprofile_ops.set_active(active_domains, adomains);
  88.242 ++
  88.243 ++	return -EINVAL;
  88.244 ++}
  88.245 ++
  88.246 + int oprofile_setup(void)
  88.247 + {
  88.248 + 	int err;
  88.249 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/oprof.h ./drivers/oprofile/oprof.h
  88.250 +--- ../pristine-linux-2.6.16/drivers/oprofile/oprof.h	2006-03-20 05:53:29.000000000 +0000
  88.251 ++++ ./drivers/oprofile/oprof.h	2006-04-03 15:53:05.000000000 +0100
  88.252 +@@ -35,5 +35,7 @@ void oprofile_create_files(struct super_
  88.253 + void oprofile_timer_init(struct oprofile_operations * ops);
  88.254 + 
  88.255 + int oprofile_set_backtrace(unsigned long depth);
  88.256 ++
  88.257 ++int oprofile_set_active(void);
  88.258 +  
  88.259 + #endif /* OPROF_H */
  88.260 +diff -pruN ../pristine-linux-2.6.16/drivers/oprofile/oprofile_files.c ./drivers/oprofile/oprofile_files.c
  88.261 +--- ../pristine-linux-2.6.16/drivers/oprofile/oprofile_files.c	2006-03-20 05:53:29.000000000 +0000
  88.262 ++++ ./drivers/oprofile/oprofile_files.c	2006-04-03 15:53:05.000000000 +0100
  88.263 +@@ -5,15 +5,21 @@
  88.264 +  * @remark Read the file COPYING
  88.265 +  *
  88.266 +  * @author John Levon <levon@movementarian.org>
  88.267 ++ *
  88.268 ++ * Modified by Aravind Menon for Xen
  88.269 ++ * These modifications are:
  88.270 ++ * Copyright (C) 2005 Hewlett-Packard Co.	
  88.271 +  */
  88.272 + 
  88.273 + #include <linux/fs.h>
  88.274 + #include <linux/oprofile.h>
  88.275 ++#include <asm/uaccess.h>
  88.276 ++#include <linux/ctype.h>
  88.277 + 
  88.278 + #include "event_buffer.h"
  88.279 + #include "oprofile_stats.h"
  88.280 + #include "oprof.h"
  88.281 +- 
  88.282 ++
  88.283 + unsigned long fs_buffer_size = 131072;
  88.284 + unsigned long fs_cpu_buffer_size = 8192;
  88.285 + unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
  88.286 +@@ -117,11 +123,79 @@ static ssize_t dump_write(struct file * 
  88.287 + static struct file_operations dump_fops = {
  88.288 + 	.write		= dump_write,
  88.289 + };
  88.290 +- 
  88.291 ++
  88.292 ++#define TMPBUFSIZE 512
  88.293 ++
  88.294 ++unsigned int adomains = 0;
  88.295 ++long active_domains[MAX_OPROF_DOMAINS];
  88.296 ++
  88.297 ++static ssize_t adomain_write(struct file * file, char const __user * buf, 
  88.298 ++			     size_t count, loff_t * offset)
  88.299 ++{
  88.300 ++	char tmpbuf[TMPBUFSIZE];
  88.301 ++	char * startp = tmpbuf;
  88.302 ++	char * endp = tmpbuf;
  88.303 ++	int i;
  88.304 ++	unsigned long val;
  88.305 ++	
  88.306 ++	if (*offset)
  88.307 ++		return -EINVAL;	
  88.308 ++	if (!count)
  88.309 ++		return 0;
  88.310 ++	if (count > TMPBUFSIZE - 1)
  88.311 ++		return -EINVAL;
  88.312 ++
  88.313 ++	memset(tmpbuf, 0x0, TMPBUFSIZE);
  88.314 ++
  88.315 ++	if (copy_from_user(tmpbuf, buf, count))
  88.316 ++		return -EFAULT;
  88.317 ++	
  88.318 ++	for (i = 0; i < MAX_OPROF_DOMAINS; i++)
  88.319 ++		active_domains[i] = -1;
  88.320 ++	adomains = 0;
  88.321 ++
  88.322 ++	while (1) {
  88.323 ++		val = simple_strtol(startp, &endp, 0);
  88.324 ++		if (endp == startp)
  88.325 ++			break;
  88.326 ++		while (ispunct(*endp))
  88.327 ++			endp++;
  88.328 ++		active_domains[adomains++] = val;
  88.329 ++		if (adomains >= MAX_OPROF_DOMAINS)
  88.330 ++			break;
  88.331 ++		startp = endp;
  88.332 ++	}
  88.333 ++	if (oprofile_set_active())
  88.334 ++		return -EINVAL; 
  88.335 ++	return count;
  88.336 ++}
  88.337 ++
  88.338 ++static ssize_t adomain_read(struct file * file, char __user * buf, 
  88.339 ++			    size_t count, loff_t * offset)
  88.340 ++{
  88.341 ++	char tmpbuf[TMPBUFSIZE];
  88.342 ++	size_t len = 0;
  88.343 ++	int i;
  88.344 ++	/* This is all screwed up if we run out of space */
  88.345 ++	for (i = 0; i < adomains; i++) 
  88.346 ++		len += snprintf(tmpbuf + len, TMPBUFSIZE - len, 
  88.347 ++				"%u ", (unsigned int)active_domains[i]);
  88.348 ++	len += snprintf(tmpbuf + len, TMPBUFSIZE - len, "\n");
  88.349 ++	return simple_read_from_buffer((void __user *)buf, count, 
  88.350 ++				       offset, tmpbuf, len);
  88.351 ++}
  88.352 ++
  88.353 ++
  88.354 ++static struct file_operations active_domain_ops = {
  88.355 ++	.read		= adomain_read,
  88.356 ++	.write		= adomain_write,
  88.357 ++};
  88.358 ++
  88.359 + void oprofile_create_files(struct super_block * sb, struct dentry * root)
  88.360 + {
  88.361 + 	oprofilefs_create_file(sb, root, "enable", &enable_fops);
  88.362 + 	oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
  88.363 ++	oprofilefs_create_file(sb, root, "active_domains", &active_domain_ops);
  88.364 + 	oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
  88.365 + 	oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size);
  88.366 + 	oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed);
  88.367 +diff -pruN ../pristine-linux-2.6.16/include/linux/oprofile.h ./include/linux/oprofile.h
  88.368 +--- ../pristine-linux-2.6.16/include/linux/oprofile.h	2006-03-20 05:53:29.000000000 +0000
  88.369 ++++ ./include/linux/oprofile.h	2006-04-03 15:53:05.000000000 +0100
  88.370 +@@ -16,6 +16,8 @@
  88.371 + #include <linux/types.h>
  88.372 + #include <linux/spinlock.h>
  88.373 + #include <asm/atomic.h>
  88.374 ++
  88.375 ++#include <xen/interface/xenoprof.h>
  88.376 +  
  88.377 + struct super_block;
  88.378 + struct dentry;
  88.379 +@@ -27,6 +29,8 @@ struct oprofile_operations {
  88.380 + 	/* create any necessary configuration files in the oprofile fs.
  88.381 + 	 * Optional. */
  88.382 + 	int (*create_files)(struct super_block * sb, struct dentry * root);
  88.383 ++	/* setup active domains with Xen */
  88.384 ++	int (*set_active)(int *active_domains, unsigned int adomains);
  88.385 + 	/* Do any necessary interrupt setup. Optional. */
  88.386 + 	int (*setup)(void);
  88.387 + 	/* Do any necessary interrupt shutdown. Optional. */
    89.1 --- a/tools/Makefile	Tue Apr 11 13:55:47 2006 -0600
    89.2 +++ b/tools/Makefile	Tue Apr 11 18:54:18 2006 -0600
    89.3 @@ -24,14 +24,14 @@ SUBDIRS += python
    89.4  SUBDIRS += pygrub
    89.5  endif
    89.6  
    89.7 -.PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean
    89.8 -
    89.9 +.PHONY: all
   89.10  all: check
   89.11  	@set -e; for subdir in $(SUBDIRS); do \
   89.12  		$(MAKE) -C $$subdir $@; \
   89.13  	done
   89.14  	$(MAKE) ioemu
   89.15  
   89.16 +.PHONY: install
   89.17  install: check
   89.18  	@set -e; for subdir in $(SUBDIRS); do \
   89.19  		$(MAKE) -C $$subdir $@; \
   89.20 @@ -39,18 +39,22 @@ install: check
   89.21  	$(MAKE) ioemuinstall
   89.22  	$(INSTALL_DIR) -p $(DESTDIR)/var/xen/dump
   89.23  
   89.24 +.PHONY: clean
   89.25  clean: check_clean
   89.26  	@set -e; for subdir in $(SUBDIRS); do \
   89.27  		$(MAKE) -C $$subdir $@; \
   89.28  	done
   89.29  	$(MAKE) ioemuclean
   89.30  
   89.31 +.PHONY: check
   89.32  check:
   89.33  	$(MAKE) -C check
   89.34  
   89.35 +.PHONY: check_clean
   89.36  check_clean:
   89.37  	$(MAKE) -C check clean
   89.38  
   89.39 +.PHONY: ioemu ioemuinstall ioemuclean
   89.40  ifndef XEN_NO_IOEMU
   89.41  ioemu ioemuinstall ioemuclean:
   89.42  	[ -f ioemu/config-host.h ] || \
    90.1 --- a/tools/Rules.mk	Tue Apr 11 13:55:47 2006 -0600
    90.2 +++ b/tools/Rules.mk	Tue Apr 11 18:54:18 2006 -0600
    90.3 @@ -12,6 +12,8 @@ XEN_LIBXENSTAT     = $(XEN_ROOT)/tools/x
    90.4  
    90.5  X11_LDPATH = -L/usr/X11R6/$(LIBDIR)
    90.6  
    90.7 +CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030101
    90.8 +
    90.9  %.opic: %.c
   90.10  	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
   90.11  
   90.12 @@ -21,6 +23,7 @@ X11_LDPATH = -L/usr/X11R6/$(LIBDIR)
   90.13  %.o: %.cc
   90.14  	$(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
   90.15  
   90.16 +.PHONY: mk-symlinks
   90.17  mk-symlinks: LINUX_ROOT=$(XEN_ROOT)/linux-2.6-xen-sparse
   90.18  mk-symlinks:
   90.19  	mkdir -p xen
    91.1 --- a/tools/blktap/Makefile	Tue Apr 11 13:55:47 2006 -0600
    91.2 +++ b/tools/blktap/Makefile	Tue Apr 11 18:54:18 2006 -0600
    91.3 @@ -39,11 +39,13 @@ IBINS   :=
    91.4  
    91.5  LIB      = libblktap.so libblktap.so.$(MAJOR) libblktap.so.$(MAJOR).$(MINOR)
    91.6  
    91.7 +.PHONY: all
    91.8  all: mk-symlinks libblktap.so #blkdump
    91.9  	@set -e; for subdir in $(SUBDIRS); do \
   91.10  		$(MAKE) -C $$subdir $@;       \
   91.11  	done
   91.12  
   91.13 +.PHONY: install
   91.14  install: all
   91.15  	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
   91.16  	$(INSTALL_DIR) -p $(DESTDIR)/usr/include
   91.17 @@ -54,12 +56,14 @@ install: all
   91.18  		$(MAKE) -C $$subdir $@;       \
   91.19  	done
   91.20  
   91.21 +.PHONY: clean
   91.22  clean:
   91.23  	rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS blkdump
   91.24  	@set -e; for subdir in $(SUBDIRS); do \
   91.25  		$(MAKE) -C $$subdir $@;       \
   91.26  	done
   91.27  
   91.28 +.PHONY: rpm
   91.29  rpm: all
   91.30  	rm -rf staging
   91.31  	mkdir staging
   91.32 @@ -82,6 +86,7 @@ blkdump: libblktap.so
   91.33  
   91.34  .PHONY: TAGS clean install mk-symlinks rpm
   91.35  
   91.36 +.PHONY: TAGS
   91.37  TAGS:
   91.38  	etags -t $(SRCS) *.h
   91.39  
    92.1 --- a/tools/blktap/parallax/Makefile	Tue Apr 11 13:55:47 2006 -0600
    92.2 +++ b/tools/blktap/parallax/Makefile	Tue Apr 11 18:54:18 2006 -0600
    92.3 @@ -43,11 +43,14 @@ DEPS     = .*.d
    92.4  OBJS     = $(patsubst %.c,%.o,$(SRCS))
    92.5  IBINS    = parallax $(VDI_TOOLS)
    92.6  
    92.7 +.PHONY: all
    92.8  all: $(VDI_TOOLS) parallax blockstored
    92.9  
   92.10 +.PHONY: install
   92.11  install: all
   92.12  	$(INSTALL_PROG) $(IBINS) $(DESTDIR)$(PARALLAX_INSTALL_DIR)
   92.13  
   92.14 +.PHONY: clean
   92.15  clean:
   92.16  	rm -rf *.o *~ $(DEPS) xen TAGS $(VDI_TOOLS) parallax vdi_unittest
   92.17  
   92.18 @@ -57,5 +60,4 @@ parallax: $(PLX_SRCS)
   92.19  ${VDI_TOOLS}: %: %.c $(VDI_SRCS)
   92.20  	$(CC) $(CFLAGS) -o $@ $@.c $(LDFLAGS) $(VDI_SRCS)
   92.21  
   92.22 -.PHONY: TAGS clean install rpm
   92.23  -include $(DEPS)
    93.1 --- a/tools/blktap/ublkback/Makefile	Tue Apr 11 13:55:47 2006 -0600
    93.2 +++ b/tools/blktap/ublkback/Makefile	Tue Apr 11 18:54:18 2006 -0600
    93.3 @@ -21,12 +21,16 @@ DEPS     = .*.d
    93.4  
    93.5  OBJS     = $(patsubst %.c,%.o,$(SRCS))
    93.6  
    93.7 +.PHONY: all
    93.8  all: $(IBIN)
    93.9  
   93.10  LINUX_ROOT := $(wildcard $(XEN_ROOT)/linux-2.6.*-xen-sparse)
   93.11  
   93.12 +.PHONY: install
   93.13  install:
   93.14  	$(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INSTALL_DIR)
   93.15 +
   93.16 +.PHONY: clean
   93.17  clean:
   93.18  	rm -rf *.o*~ $(DEPS) xen TAGS $(IBIN)
   93.19  
   93.20 @@ -34,6 +38,4 @@ ublkback:
   93.21  	$(CC) $(CFLAGS) -o ublkback -L$(XEN_LIBXC) -L. -L..  \
   93.22  	      -lblktap -laio ublkback.c ublkbacklib.c -pg
   93.23  
   93.24 -.PHONY: clean install
   93.25 -
   93.26  -include $(DEPS)
    94.1 --- a/tools/check/Makefile	Tue Apr 11 13:55:47 2006 -0600
    94.2 +++ b/tools/check/Makefile	Tue Apr 11 18:54:18 2006 -0600
    94.3 @@ -1,7 +1,9 @@
    94.4  
    94.5 +.PHONY: all
    94.6  all: build
    94.7  
    94.8  # Check this machine is OK for building on.
    94.9 +.PHONY: build
   94.10  build:
   94.11  	./chk build
   94.12  
   94.13 @@ -9,8 +11,10 @@ build:
   94.14  # DO NOT use this check from 'make install' in the parent
   94.15  # directory, as that target can be used to make an installable
   94.16  # copy rather than actually installing.
   94.17 +.PHONY: install
   94.18  install:
   94.19  	./chk install
   94.20  
   94.21 +.PHONY: clean
   94.22  clean:
   94.23 -	./chk clean
   94.24 \ No newline at end of file
   94.25 +	./chk clean
    95.1 --- a/tools/console/Makefile	Tue Apr 11 13:55:47 2006 -0600
    95.2 +++ b/tools/console/Makefile	Tue Apr 11 18:54:18 2006 -0600
    95.3 @@ -16,8 +16,10 @@ CFLAGS  += -I $(XEN_XENSTORE)
    95.4  
    95.5  BIN      = xenconsoled xenconsole
    95.6  
    95.7 +.PHONY: all
    95.8  all: $(BIN)
    95.9  
   95.10 +.PHONY: clean
   95.11  clean:
   95.12  	$(RM) *.a *.so *.o *.rpm $(BIN)
   95.13  	$(RM) client/*.o daemon/*.o
   95.14 @@ -30,6 +32,7 @@ xenconsole: $(patsubst %.c,%.o,$(wildcar
   95.15  	$(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
   95.16  	      -lxenctrl -lxenstore
   95.17  
   95.18 +.PHONY: install
   95.19  install: $(BIN)
   95.20  	$(INSTALL_DIR) -p $(DESTDIR)/$(DAEMON_INSTALL_DIR)
   95.21  	$(INSTALL_PROG) xenconsoled $(DESTDIR)/$(DAEMON_INSTALL_DIR)
    96.1 --- a/tools/console/client/main.c	Tue Apr 11 13:55:47 2006 -0600
    96.2 +++ b/tools/console/client/main.c	Tue Apr 11 18:54:18 2006 -0600
    96.3 @@ -36,7 +36,6 @@
    96.4  #include <errno.h>
    96.5  #include <pty.h>
    96.6  
    96.7 -#include "xenctrl.h"
    96.8  #include "xs.h"
    96.9  
   96.10  #define ESCAPE_CHARACTER 0x1d
   96.11 @@ -92,7 +91,7 @@ static void restore_term(int fd, struct 
   96.12  	tcsetattr(fd, TCSAFLUSH, old);
   96.13  }
   96.14  
   96.15 -static int console_loop(int xc_handle, domid_t domid, int fd)
   96.16 +static int console_loop(int fd)
   96.17  {
   96.18  	int ret;
   96.19  
   96.20 @@ -161,7 +160,6 @@ int main(int argc, char **argv)
   96.21  {
   96.22  	struct termios attr;
   96.23  	int domid;
   96.24 -	int xc_handle;
   96.25  	char *sopt = "h";
   96.26  	int ch;
   96.27  	int opt_ind=0;
   96.28 @@ -206,11 +204,6 @@ int main(int argc, char **argv)
   96.29  		err(errno, "Could not contact XenStore");
   96.30  	}
   96.31  
   96.32 -	xc_handle = xc_interface_open();
   96.33 -	if (xc_handle == -1) {
   96.34 -		err(errno, "xc_interface_open()");
   96.35 -	}
   96.36 -	
   96.37  	signal(SIGTERM, sighandler);
   96.38  
   96.39  	path = xs_get_domain_path(xs, domid);
   96.40 @@ -260,7 +253,7 @@ int main(int argc, char **argv)
   96.41  	free(path);
   96.42  
   96.43  	init_term(STDIN_FILENO, &attr);
   96.44 -	console_loop(xc_handle, domid, spty);
   96.45 +	console_loop(spty);
   96.46  	restore_term(STDIN_FILENO, &attr);
   96.47  
   96.48  	return 0;
    97.1 --- a/tools/console/daemon/io.c	Tue Apr 11 13:55:47 2006 -0600
    97.2 +++ b/tools/console/daemon/io.c	Tue Apr 11 18:54:18 2006 -0600
    97.3 @@ -434,26 +434,37 @@ void enum_domains(void)
    97.4  	}
    97.5  }
    97.6  
    97.7 +static int ring_free_bytes(struct domain *dom)
    97.8 +{
    97.9 +	struct xencons_interface *intf = dom->interface;
   97.10 +	XENCONS_RING_IDX cons, prod, space;
   97.11 +
   97.12 +	cons = intf->in_cons;
   97.13 +	prod = intf->in_prod;
   97.14 +	mb();
   97.15 +
   97.16 +	space = prod - cons;
   97.17 +	if (space > sizeof(intf->in))
   97.18 +		return 0; /* ring is screwed: ignore it */
   97.19 +
   97.20 +	return (sizeof(intf->in) - space);
   97.21 +}
   97.22 +
   97.23  static void handle_tty_read(struct domain *dom)
   97.24  {
   97.25  	ssize_t len = 0;
   97.26  	char msg[80];
   97.27  	int i;
   97.28  	struct xencons_interface *intf = dom->interface;
   97.29 -	XENCONS_RING_IDX cons, prod;
   97.30 +	XENCONS_RING_IDX prod;
   97.31  
   97.32 -	cons = intf->in_cons;
   97.33 -	prod = intf->in_prod;
   97.34 -	mb();
   97.35 +	len = ring_free_bytes(dom);
   97.36 +	if (len == 0)
   97.37 +		return;
   97.38  
   97.39 -	if (sizeof(intf->in) > (prod - cons))
   97.40 -		len = sizeof(intf->in) - (prod - cons);
   97.41  	if (len > sizeof(msg))
   97.42  		len = sizeof(msg);
   97.43  
   97.44 -	if (len == 0)
   97.45 -		return;
   97.46 -
   97.47  	len = read(dom->tty_fd, msg, len);
   97.48  	if (len < 1) {
   97.49  		close(dom->tty_fd);
   97.50 @@ -465,6 +476,7 @@ static void handle_tty_read(struct domai
   97.51  			shutdown_domain(dom);
   97.52  		}
   97.53  	} else if (domain_is_valid(dom->domid)) {
   97.54 +		prod = intf->in_prod;
   97.55  		for (i = 0; i < len; i++) {
   97.56  			intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
   97.57  				msg[i];
   97.58 @@ -514,7 +526,7 @@ static void handle_ring_read(struct doma
   97.59  	(void)write_sync(dom->evtchn_fd, &v, sizeof(v));
   97.60  }
   97.61  
   97.62 -static void handle_xs(int fd)
   97.63 +static void handle_xs(void)
   97.64  {
   97.65  	char **vec;
   97.66  	int domid;
   97.67 @@ -560,7 +572,7 @@ void handle_io(void)
   97.68  			}
   97.69  
   97.70  			if (d->tty_fd != -1) {
   97.71 -				if (!d->is_dead)
   97.72 +				if (!d->is_dead && ring_free_bytes(d))
   97.73  					FD_SET(d->tty_fd, &readfds);
   97.74  
   97.75  				if (!buffer_empty(&d->buffer))
   97.76 @@ -572,7 +584,7 @@ void handle_io(void)
   97.77  		ret = select(max_fd + 1, &readfds, &writefds, 0, NULL);
   97.78  
   97.79  		if (FD_ISSET(xs_fileno(xs), &readfds))
   97.80 -			handle_xs(xs_fileno(xs));
   97.81 +			handle_xs();
   97.82  
   97.83  		for (d = dom_head; d; d = n) {
   97.84  			n = d->next;
    98.1 --- a/tools/console/testsuite/Makefile	Tue Apr 11 13:55:47 2006 -0600
    98.2 +++ b/tools/console/testsuite/Makefile	Tue Apr 11 18:54:18 2006 -0600
    98.3 @@ -3,10 +3,12 @@ include $(XEN_ROOT)/tools/Rules.mk
    98.4  
    98.5  LDFLAGS=-static
    98.6  
    98.7 +.PHONY: all
    98.8  all: console-dom0 console-domU procpipe
    98.9  
   98.10  console-dom0: console-dom0.o
   98.11  console-domU: console-domU.o
   98.12  procpipe: procpipe.o
   98.13  
   98.14 +.PHONY: clean
   98.15  clean:; $(RM) *.o console-domU console-dom0 procpipe
    99.1 --- a/tools/debugger/gdb/README	Tue Apr 11 13:55:47 2006 -0600
    99.2 +++ b/tools/debugger/gdb/README	Tue Apr 11 18:54:18 2006 -0600
    99.3 @@ -1,16 +1,17 @@
    99.4  
    99.5 -DomU GDB server for 32-bit (PAE and non-PAE) systems
    99.6 +DomU & HVM GDB server for 32-bit (PAE and non-PAE) and x86_64 systems
    99.7  ----------------------------------------------------
    99.8  
    99.9  Lines marked below with [*] are optional, if you want full
   99.10  source-level debugging of your kernel image.
   99.11  
   99.12  To build the GDB server:
   99.13 + 0. Build rest of the Xen first from the base directory
   99.14   1. Run ./gdbbuild from within this directory.
   99.15   2. Copy ./gdb-6.2.1-linux-i386-xen/gdb/gdbserver/gdbserver-xen
   99.16      to your test machine.
   99.17  
   99.18 -To build a debuggable guest kernel image:
   99.19 +To build a debuggable guest domU kernel image:
   99.20   1. cd linux-2.6.xx-xenU
   99.21   2. make menuconfig
   99.22   3. From within the configurator, enable the following options:
   99.23 @@ -28,7 +29,7 @@ To debug a running guest:
   99.24      # bt
   99.25      # disass
   99.26  
   99.27 -To debug a crashed guest:
   99.28 +To debug a crashed domU guest:
   99.29   1. Add '(enable-dump yes)' to /etc/xen/xend-config.sxp before
   99.30      starting xend.
   99.31   2. When the domain crashes, a core file is written to
   100.1 --- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c	Tue Apr 11 13:55:47 2006 -0600
   100.2 +++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c	Tue Apr 11 18:54:18 2006 -0600
   100.3 @@ -287,6 +287,21 @@ handle_v_requests (char *own_buf, char *
   100.4  }
   100.5  
   100.6  void
   100.7 +handle_breakpoint_requests (char *own_buf, char *status, unsigned char *signal)
   100.8 +{
   100.9 +  /*  Currently we only support software breakpoints */
  100.10 +    switch (own_buf[1]) {
  100.11 +        case '0': /* software breakpoint, int3 based */
  100.12 +	      own_buf[0] = '\0';
  100.13 +            break;
  100.14 +        case '1': /* hardware breakpoint */
  100.15 +        default:
  100.16 +		  write_enn (own_buf);
  100.17 +            break;
  100.18 +    }
  100.19 +}
  100.20 +
  100.21 +void
  100.22  myresume (int step, int sig)
  100.23  {
  100.24    struct thread_resume resume_info[2];
  100.25 @@ -322,6 +337,18 @@ gdbserver_usage (void)
  100.26  	 "HOST:PORT to listen for a TCP connection.\n");
  100.27  }
  100.28  
  100.29 +extern control_c_pressed_flag;
  100.30 +#include <signal.h>
  100.31 +
  100.32 +void ctrl_c_handler(int signo)
  100.33 +{
  100.34 +    printf("Ctrl-C pressed: Quit from the attached gdb first\n");
  100.35 +    control_c_pressed_flag = 1;
  100.36 +}
  100.37 +
  100.38 +struct sigaction ctrl_c_sigaction = { .sa_handler = ctrl_c_handler };
  100.39 +struct sigaction old_sigaction;
  100.40 +
  100.41  int
  100.42  main (int argc, char *argv[])
  100.43  {
  100.44 @@ -396,9 +423,11 @@ main (int argc, char *argv[])
  100.45  	}
  100.46      }
  100.47  
  100.48 +
  100.49    while (1)
  100.50      {
  100.51        remote_open (argv[1]);
  100.52 +      sigaction(SIGINT, &ctrl_c_sigaction, &old_sigaction);
  100.53  
  100.54      restart:
  100.55        setjmp (toplevel);
  100.56 @@ -587,6 +616,9 @@ main (int argc, char *argv[])
  100.57  	      /* Extended (long) request.  */
  100.58  	      handle_v_requests (own_buf, &status, &signal);
  100.59  	      break;
  100.60 +	    case 'Z':
  100.61 +	      handle_breakpoint_requests (own_buf, &status, &signal);
  100.62 +	      break;
  100.63  	    default:
  100.64  	      /* It is a request we don't understand.  Respond with an
  100.65  	         empty packet so that gdb knows that we don't support this
  100.66 @@ -643,5 +675,6 @@ main (int argc, char *argv[])
  100.67  			   "GDBserver will reopen the connection.\n");
  100.68  	  remote_close ();
  100.69  	}
  100.70 +    sigaction(SIGINT, &old_sigaction, NULL);
  100.71      }
  100.72  }
   101.1 --- a/tools/debugger/libxendebug/Makefile	Tue Apr 11 13:55:47 2006 -0600
   101.2 +++ b/tools/debugger/libxendebug/Makefile	Tue Apr 11 18:54:18 2006 -0600
   101.3 @@ -26,10 +26,14 @@ PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS
   101.4  LIB      := libxendebug.a libxendebug.so
   101.5  LIB      += libxendebug.so.$(MAJOR) libxendebug.so.$(MAJOR).$(MINOR)
   101.6  
   101.7 +.PHONY: all
   101.8  all: build
   101.9 +
  101.10 +.PHONY: build
  101.11  build:
  101.12  	$(MAKE) $(LIB)
  101.13  
  101.14 +.PHONY: install
  101.15  install: build
  101.16  	[ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
  101.17  	[ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
  101.18 @@ -39,14 +43,15 @@ install: build
  101.19  	ln -sf libxendebug.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxendebug.so
  101.20  	$(INSTALL_DATA) xendebug.h $(DESTDIR)/usr/include
  101.21  
  101.22 -.PHONY: TAGS clean rpm install all
  101.23 -
  101.24 +.PHONY: TAGS
  101.25  TAGS:
  101.26  	etags -t $(SRCS) *.h
  101.27  
  101.28 +.PHONY: clean
  101.29  clean:
  101.30  	rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
  101.31  
  101.32 +.PHONY: rpm
  101.33  rpm: build
  101.34  	rm -rf staging
  101.35  	mkdir staging
   102.1 --- a/tools/debugger/pdb/Makefile	Tue Apr 11 13:55:47 2006 -0600
   102.2 +++ b/tools/debugger/pdb/Makefile	Tue Apr 11 18:54:18 2006 -0600
   102.3 @@ -33,6 +33,7 @@ LIBS       += unix str
   102.4  
   102.5  # bc = byte-code, dc = debug byte-code
   102.6  # patches = patch linux domU source code
   102.7 +.PHONY: all 
   102.8  all : dc
   102.9  
  102.10  SOURCES    += pdb_caml_xc.c 
  102.11 @@ -51,5 +52,6 @@ RESULT      = pdb
  102.12  include $(OCAMLMAKEFILE)
  102.13  
  102.14  PATCHDIR    = ./linux-2.6-patches
  102.15 +.PHONY: patches 
  102.16  patches :
  102.17  	make -C $(PATCHDIR) patches
   103.1 --- a/tools/debugger/pdb/linux-2.6-module/Makefile	Tue Apr 11 13:55:47 2006 -0600
   103.2 +++ b/tools/debugger/pdb/linux-2.6-module/Makefile	Tue Apr 11 18:54:18 2006 -0600
   103.3 @@ -10,10 +10,12 @@ CFLAGS += -g
   103.4  CFLAGS += -Wall
   103.5  CFLAGS += -Werror
   103.6  
   103.7 +.PHONY: module 
   103.8  module : 
   103.9  #	make KBUILD_VERBOSE=1 ARCH=xen -C $(KDIR) M=$(PWD) modules
  103.10  	make                  ARCH=xen -C $(KDIR) M=$(PWD) modules
  103.11  
  103.12 +.PHONY: clean 
  103.13  clean :
  103.14  	make -C $(KDIR) M=$(PWD) clean
  103.15  
   104.1 --- a/tools/debugger/pdb/linux-2.6-patches/Makefile	Tue Apr 11 13:55:47 2006 -0600
   104.2 +++ b/tools/debugger/pdb/linux-2.6-patches/Makefile	Tue Apr 11 18:54:18 2006 -0600
   104.3 @@ -3,6 +3,7 @@ LINUX_DIR  = linux-2.6.12-xenU
   104.4  KDIR       = $(XEN_ROOT)/$(LINUX_DIR)
   104.5  PATCH_DIR  = $(CURDIR)
   104.6  
   104.7 +.PHONY: patches 
   104.8  patches : patches-done
   104.9  
  104.10  patches-done :
   105.1 --- a/tools/examples/Makefile	Tue Apr 11 13:55:47 2006 -0600
   105.2 +++ b/tools/examples/Makefile	Tue Apr 11 18:54:18 2006 -0600
   105.3 @@ -50,11 +50,16 @@ HOTPLUGS=install-hotplug
   105.4  endif
   105.5  endif
   105.6  
   105.7 +.PHONY: all
   105.8  all:
   105.9 +
  105.10 +.PHONY: build
  105.11  build:
  105.12  
  105.13 +.PHONY: install
  105.14  install: all install-initd install-configs install-scripts $(HOTPLUGS)
  105.15  
  105.16 +.PHONY: install-initd
  105.17  install-initd:
  105.18  	[ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d
  105.19  	[ -d $(DESTDIR)/etc/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)/etc/sysconfig
  105.20 @@ -62,6 +67,7 @@ install-initd:
  105.21  	$(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)/etc/init.d
  105.22  	$(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/etc/sysconfig/xendomains
  105.23  
  105.24 +.PHONY: install-configs
  105.25  install-configs: $(XEN_CONFIGS)
  105.26  	[ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \
  105.27  		$(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
  105.28 @@ -72,6 +78,7 @@ install-configs: $(XEN_CONFIGS)
  105.29  	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \
  105.30  	done
  105.31  
  105.32 +.PHONY: install-scripts
  105.33  install-scripts:
  105.34  	[ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
  105.35  		$(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
  105.36 @@ -84,6 +91,7 @@ install-scripts:
  105.37  	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
  105.38  	done
  105.39  
  105.40 +.PHONY: install-hotplug
  105.41  install-hotplug:
  105.42  	[ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \
  105.43  		$(INSTALL_DIR) $(DESTDIR)$(XEN_HOTPLUG_DIR)
  105.44 @@ -92,6 +100,7 @@ install-hotplug:
  105.45  	    $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_HOTPLUG_DIR); \
  105.46  	done
  105.47  
  105.48 +.PHONY: install-udev
  105.49  install-udev:
  105.50  	[ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
  105.51  		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
  105.52 @@ -102,4 +111,5 @@ install-udev:
  105.53  	        ln -sf ../$$i . ) \
  105.54  	done
  105.55  
  105.56 +.PHONY: clean
  105.57  clean:
   106.1 --- a/tools/examples/README.incompatibilities	Tue Apr 11 13:55:47 2006 -0600
   106.2 +++ b/tools/examples/README.incompatibilities	Tue Apr 11 18:54:18 2006 -0600
   106.3 @@ -24,6 +24,13 @@ Gentoo doesn't have ifup/ifdown; appropr
   106.4  xen-network-common.sh.
   106.5  
   106.6  
   106.7 +ip
   106.8 +--
   106.9 +
  106.10 +Newer ip commands (from iproute2) do not accept the abbreviated syntax "ip r a
  106.11 +..." etc.  "ip route add ..." must be used instead.
  106.12 +
  106.13 +
  106.14  sed
  106.15  ---
  106.16  
   107.1 --- a/tools/examples/block	Tue Apr 11 13:55:47 2006 -0600
   107.2 +++ b/tools/examples/block	Tue Apr 11 18:54:18 2006 -0600
   107.3 @@ -72,7 +72,7 @@ check_sharing()
   107.4    then
   107.5      toskip="^$"
   107.6    else
   107.7 -    toskip="^[^ ]* [^ ]* [^ ]* ro "
   107.8 +    toskip="^[^ ]* [^ ]* [^ ]* ro[, ]"
   107.9    fi
  107.10  
  107.11    for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ')
   108.1 --- a/tools/examples/init.d/xend	Tue Apr 11 13:55:47 2006 -0600
   108.2 +++ b/tools/examples/init.d/xend	Tue Apr 11 18:54:18 2006 -0600
   108.3 @@ -7,7 +7,7 @@
   108.4  # chkconfig: 2345 98 01
   108.5  # description: Starts and stops the Xen control daemon.
   108.6  
   108.7 -if ! [ -e /proc/xen/privcmd ]; then
   108.8 +if ! grep -q "control_d" /proc/xen/capabilities ; then
   108.9  	exit 0
  108.10  fi
  108.11  
   109.1 --- a/tools/examples/vif-route	Tue Apr 11 13:55:47 2006 -0600
   109.2 +++ b/tools/examples/vif-route	Tue Apr 11 18:54:18 2006 -0600
   109.3 @@ -29,11 +29,11 @@ case "$command" in
   109.4      online)
   109.5          ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up
   109.6          echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
   109.7 -        ipcmd='a'
   109.8 +        ipcmd='add'
   109.9          ;;
  109.10      offline)
  109.11          ifdown ${vif}
  109.12 -        ipcmd='d'
  109.13 +        ipcmd='del'
  109.14          ;;
  109.15  esac
  109.16  
  109.17 @@ -41,7 +41,7 @@ if [ "${ip}" ] ; then
  109.18      # If we've been given a list of IP addresses, then add routes from dom0 to
  109.19      # the guest using those addresses.
  109.20      for addr in ${ip} ; do
  109.21 -      ip r ${ipcmd} ${addr} dev ${vif} src ${main_ip}
  109.22 +      ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip}
  109.23      done 
  109.24  fi
  109.25  
   110.1 --- a/tools/examples/vtpm-common.sh	Tue Apr 11 13:55:47 2006 -0600
   110.2 +++ b/tools/examples/vtpm-common.sh	Tue Apr 11 18:54:18 2006 -0600
   110.3 @@ -261,12 +261,6 @@ function vtpm_create_instance () {
   110.4  
   110.5  	if [ "$REASON" == "create" ]; then
   110.6  		vtpm_reset $instance
   110.7 -	elif [ "$REASON" == "resume" ]; then
   110.8 -		vtpm_setup $instance
   110.9 -	else
  110.10 -		#default case for 'now'
  110.11 -		#vtpm_reset $instance
  110.12 -		true
  110.13  	fi
  110.14  	xenstore_write $XENBUS_PATH/instance $instance
  110.15  }
   111.1 --- a/tools/firmware/Makefile	Tue Apr 11 13:55:47 2006 -0600
   111.2 +++ b/tools/firmware/Makefile	Tue Apr 11 18:54:18 2006 -0600
   111.3 @@ -13,8 +13,7 @@ SUBDIRS += acpi
   111.4  SUBDIRS += vmxassist
   111.5  SUBDIRS += hvmloader
   111.6  
   111.7 -.PHONY: all install clean
   111.8 -
   111.9 +.PHONY: all
  111.10  all:
  111.11  	@set -e; if ! `which bcc 1>/dev/null 2>/dev/null`; then \
  111.12  	echo "***********************************************************"; \
  111.13 @@ -28,10 +27,12 @@ all:
  111.14  	fi
  111.15  
  111.16  
  111.17 +.PHONY: install
  111.18  install: all
  111.19  	[ -d $(INSTALL_DIR) ] || install -d -m0755 $(INSTALL_DIR)
  111.20  	[ ! -e $(TARGET) ] || install -m0644 $(TARGET) $(INSTALL_DIR)
  111.21  
  111.22 +.PHONY: clean
  111.23  clean: 
  111.24  	@set -e; for subdir in $(SUBDIRS); do \
  111.25  		$(MAKE) -C $$subdir $@; \
   112.1 --- a/tools/firmware/acpi/Makefile	Tue Apr 11 13:55:47 2006 -0600
   112.2 +++ b/tools/firmware/acpi/Makefile	Tue Apr 11 18:54:18 2006 -0600
   112.3 @@ -33,6 +33,7 @@ IASL_VER=acpica-unix-20050513
   112.4  IASL_URL=http://developer.intel.com/technology/iapc/acpi/downloads/$(IASL_VER).tar.gz
   112.5  
   112.6  vpath iasl $(PATH)
   112.7 +.PHONY: all
   112.8  all:$(ACPI_BIN)
   112.9  
  112.10  acpi_dsdt.c:acpi_dsdt.asl
  112.11 @@ -42,6 +43,7 @@ acpi_dsdt.c:acpi_dsdt.asl
  112.12  	echo "int DsdtLen=sizeof(AmlCode);" >> acpi_dsdt.c
  112.13  	rm *.aml
  112.14  
  112.15 +.PHONY: iasl
  112.16  iasl:
  112.17  	@echo
  112.18  	@echo "ACPI ASL compiler(iasl) is needed"
  112.19 @@ -60,8 +62,10 @@ iasl:
  112.20  $(ACPI_BIN):$(ACPI_GEN)
  112.21  	./$(ACPI_GEN) $(ACPI_BIN)
  112.22  
  112.23 +.PHONY: clean
  112.24  clean:
  112.25  	rm -rf *.o $(ACPI_GEN) $(ACPI_BIN) $(IASL_VER) 
  112.26  	rm -rf  $(IASL_VER).tar.gz
  112.27  
  112.28 +.PHONY: install
  112.29  install: all
   113.1 --- a/tools/firmware/hvmloader/Makefile	Tue Apr 11 13:55:47 2006 -0600
   113.2 +++ b/tools/firmware/hvmloader/Makefile	Tue Apr 11 18:54:18 2006 -0600
   113.3 @@ -21,6 +21,7 @@
   113.4  # External CFLAGS can do more harm than good.
   113.5  CFLAGS :=
   113.6  
   113.7 +XEN_TARGET_ARCH = x86_32
   113.8  XEN_ROOT = ../../..
   113.9  include $(XEN_ROOT)/Config.mk
  113.10  
  113.11 @@ -38,10 +39,10 @@ CFLAGS  += $(call test-gcc-flag,$(CC),-f
  113.12  CFLAGS  += $(call test-gcc-flag,$(CC),-fno-stack-protector-all)
  113.13  
  113.14  OBJCOPY  = objcopy
  113.15 -CFLAGS  += $(DEFINES) -I. $(XENINC) -Wall -fno-builtin -O2 -msoft-float
  113.16 -CFLAGS  += -m32 -march=i686
  113.17 +CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
  113.18  LDFLAGS  = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
  113.19  
  113.20 +.PHONY: all
  113.21  all: hvmloader
  113.22  
  113.23  hvmloader: roms.h hvmloader.c acpi_madt.c
  113.24 @@ -57,6 +58,7 @@ roms.h:	../rombios/BIOS-bochs-latest ../
  113.25  	./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h
  113.26  	./mkhex acpi ../acpi/acpi.bin >> roms.h
  113.27  
  113.28 +.PHONY: clean
  113.29  clean:
  113.30  	rm -f roms.h acpi.h
  113.31  	rm -f hvmloader hvmloader.tmp hvmloader.o $(OBJECTS)
   114.1 --- a/tools/firmware/rombios/Makefile	Tue Apr 11 13:55:47 2006 -0600
   114.2 +++ b/tools/firmware/rombios/Makefile	Tue Apr 11 18:54:18 2006 -0600
   114.3 @@ -3,10 +3,13 @@ BIOS_BUILDS = BIOS-bochs-latest
   114.4  #BIOS_BUILDS += BIOS-bochs-4-processors
   114.5  #BIOS_BUILDS += BIOS-bochs-8-processors
   114.6  
   114.7 +.PHONY: all
   114.8  all: bios
   114.9  
  114.10 +.PHONY: bios
  114.11  bios: biossums ${BIOS_BUILDS}
  114.12  
  114.13 +.PHONY: clean
  114.14  clean:
  114.15  	rm -f  *.o *.a *.s rombios.bin _rombios*_.c
  114.16  	rm -f  as86-sym.txt ld86-sym.txt 
   115.1 --- a/tools/firmware/vgabios/Makefile	Tue Apr 11 13:55:47 2006 -0600
   115.2 +++ b/tools/firmware/vgabios/Makefile	Tue Apr 11 18:54:18 2006 -0600
   115.3 @@ -10,17 +10,22 @@ RELVERS = `pwd | sed "s-.*/--" | sed "s/
   115.4  
   115.5  VGABIOS_DATE = "-DVGABIOS_DATE=\"$(RELDATE)\""
   115.6  
   115.7 +.PHONY: all
   115.8  all: bios cirrus-bios
   115.9  
  115.10 +.PHONY: bios
  115.11  bios: biossums vgabios.bin vgabios.debug.bin 
  115.12  
  115.13 +.PHONY: cirrus-bios
  115.14  cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin
  115.15  
  115.16 +.PHONY: clean
  115.17  clean:
  115.18  	rm -f biossums *.o *.s *.ld86 \
  115.19            temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak
  115.20  	rm -f VGABIOS-lgpl-latest*.bin
  115.21  
  115.22 +.PHONY: release
  115.23  release: 
  115.24  	VGABIOS_VERS=\"-DVGABIOS_VERS=\\\"$(RELVERS)\\\"\" make bios cirrus-bios
  115.25  	/bin/rm -f  *.o *.s *.ld86 \
   116.1 --- a/tools/firmware/vmxassist/Makefile	Tue Apr 11 13:55:47 2006 -0600
   116.2 +++ b/tools/firmware/vmxassist/Makefile	Tue Apr 11 18:54:18 2006 -0600
   116.3 @@ -21,6 +21,7 @@
   116.4  # External CFLAGS can do more harm than good.
   116.5  CFLAGS :=
   116.6  
   116.7 +XEN_TARGET_ARCH = x86_32
   116.8  XEN_ROOT = ../../..
   116.9  include $(XEN_ROOT)/Config.mk
  116.10  
  116.11 @@ -37,12 +38,12 @@ CFLAGS  += $(call test-gcc-flag,$(CC),-f
  116.12  
  116.13  CPP      = cpp -P
  116.14  OBJCOPY  = objcopy -p -O binary -R .note -R .comment -R .bss -S --gap-fill=0
  116.15 -CFLAGS  += $(DEFINES) -I. $(XENINC) -Wall -fno-builtin -O2 -msoft-float
  116.16 -CFLAGS  += -m32 -march=i686
  116.17 +CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
  116.18  LDFLAGS  = -m elf_i386
  116.19  
  116.20  OBJECTS = head.o trap.o vm86.o setup.o util.o
  116.21  
  116.22 +.PHONY: all
  116.23  all: vmxassist.bin
  116.24  
  116.25  vmxassist.bin: vmxassist.ld $(OBJECTS)
  116.26 @@ -53,27 +54,28 @@ vmxassist.bin: vmxassist.ld $(OBJECTS)
  116.27  	dd if=vmxassist.tmp of=vmxassist.bin ibs=512 conv=sync
  116.28  	rm -f vmxassist.tmp
  116.29  
  116.30 -head.o: machine.h head.S
  116.31 +head.o: machine.h vm86.h head.S
  116.32  	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c head.S
  116.33  
  116.34 -trap.o: machine.h offsets.h trap.S
  116.35 +trap.o: machine.h vm86.h offsets.h trap.S
  116.36  	$(CC) $(CFLAGS) -D__ASSEMBLY__ $(DEFINES) -c trap.S
  116.37  
  116.38 -vm86.o: machine.h vm86.c
  116.39 +vm86.o: machine.h vm86.h vm86.c
  116.40  	$(CC) $(CFLAGS) -c vm86.c
  116.41  
  116.42 -setup.o: machine.h setup.c
  116.43 +setup.o: machine.h vm86.h setup.c
  116.44  	$(CC) $(CFLAGS) -c setup.c
  116.45  
  116.46 -util.o: machine.h util.c
  116.47 +util.o: machine.h vm86.h util.c
  116.48  	$(CC) $(CFLAGS) -c util.c
  116.49  
  116.50  offsets.h: gen
  116.51  	./gen > offsets.h
  116.52  
  116.53 -gen:	gen.c
  116.54 +gen:	vm86.h gen.c
  116.55  	$(HOSTCC) $(HOSTCFLAGS) -I. $(XENINC) -o gen gen.c
  116.56  
  116.57 +.PHONY: clean
  116.58  clean:
  116.59  	rm -f vmxassist vmxassist.tmp vmxassist.bin vmxassist.run vmxassist.sym head.s
  116.60  	rm -f $(OBJECTS)
   117.1 --- a/tools/firmware/vmxassist/trap.S	Tue Apr 11 13:55:47 2006 -0600
   117.2 +++ b/tools/firmware/vmxassist/trap.S	Tue Apr 11 18:54:18 2006 -0600
   117.3 @@ -18,6 +18,7 @@
   117.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
   117.5   */
   117.6  #include "machine.h"
   117.7 +#include "vm86.h"
   117.8  #include "offsets.h"
   117.9  
  117.10  /*
   118.1 --- a/tools/firmware/vmxassist/util.c	Tue Apr 11 13:55:47 2006 -0600
   118.2 +++ b/tools/firmware/vmxassist/util.c	Tue Apr 11 18:54:18 2006 -0600
   118.3 @@ -18,7 +18,6 @@
   118.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
   118.5   */
   118.6  #include <stdarg.h>
   118.7 -#include <vm86.h>
   118.8  
   118.9  #include "util.h"
  118.10  #include "machine.h"
   119.1 --- a/tools/firmware/vmxassist/vm86.c	Tue Apr 11 13:55:47 2006 -0600
   119.2 +++ b/tools/firmware/vmxassist/vm86.c	Tue Apr 11 18:54:18 2006 -0600
   119.3 @@ -34,7 +34,7 @@
   119.4  #define	SEG_FS		0x0040
   119.5  #define	SEG_GS		0x0080
   119.6  
   119.7 -unsigned prev_eip = 0;
   119.8 +static unsigned prev_eip = 0;
   119.9  enum vm86_mode mode = 0;
  119.10  
  119.11  #ifdef DEBUG
  119.12 @@ -50,23 +50,41 @@ char *states[] = {
  119.13  static char *rnames[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
  119.14  #endif /* DEBUG */
  119.15  
  119.16 -unsigned
  119.17 +static unsigned
  119.18  address(struct regs *regs, unsigned seg, unsigned off)
  119.19  {
  119.20  	unsigned long long entry;
  119.21 -	unsigned addr;
  119.22 +	unsigned seg_base, seg_limit;
  119.23 +	unsigned entry_low, entry_high;
  119.24  
  119.25 -	if (seg == 0)
  119.26 -		return off;
  119.27 +	if (seg == 0) {
  119.28 +		if (mode == VM86_REAL || mode == VM86_REAL_TO_PROTECTED)
  119.29 +			return off;
  119.30 +		else
  119.31 +			panic("segment is zero, but not in real mode!\n");
  119.32 +	}
  119.33  
  119.34 -	if (seg > oldctx.gdtr_limit)
  119.35 +	if (mode == VM86_REAL || seg > oldctx.gdtr_limit ||
  119.36 +	    (mode == VM86_REAL_TO_PROTECTED && regs->cs == seg))
  119.37  		return ((seg & 0xFFFF) << 4) + off;
  119.38  
  119.39  	entry = ((unsigned long long *) oldctx.gdtr_base)[seg >> 3];
  119.40 -	addr = (((entry >> (56-24)) & 0xFF000000) |
  119.41 -		((entry >> (32-16)) & 0x00FF0000) |
  119.42 -		((entry >> (   16)) & 0x0000FFFF)) + off;
  119.43 -	return addr;
  119.44 +	entry_high = entry >> 32;
  119.45 +	entry_low = entry & 0xFFFFFFFF;
  119.46 +
  119.47 +	seg_base  = (entry_high & 0xFF000000) | ((entry >> 16) & 0xFFFFFF);
  119.48 +	seg_limit = (entry_high & 0xF0000) | (entry_low & 0xFFFF);
  119.49 +
  119.50 +	if (entry_high & 0x8000 &&
  119.51 +	    ((entry_high & 0x800000 && off >> 12 <= seg_limit) ||
  119.52 +	    (!(entry_high & 0x800000) && off <= seg_limit)))
  119.53 +		return seg_base + off;
  119.54 +
  119.55 +	panic("should never reach here in function address():\n\t"
  119.56 +	      "entry=0x%08x%08x, mode=%d, seg=0x%08x, offset=0x%08x\n",
  119.57 +	      entry_high, entry_low, mode, seg, off);
  119.58 +
  119.59 +	return 0;
  119.60  }
  119.61  
  119.62  #ifdef DEBUG
  119.63 @@ -194,7 +212,7 @@ fetch8(struct regs *regs)
  119.64  	return read8(addr);
  119.65  }
  119.66  
  119.67 -unsigned
  119.68 +static unsigned
  119.69  getreg32(struct regs *regs, int r)
  119.70  {
  119.71  	switch (r & 7) {
  119.72 @@ -210,13 +228,13 @@ getreg32(struct regs *regs, int r)
  119.73  	return ~0;
  119.74  }
  119.75  
  119.76 -unsigned
  119.77 +static unsigned
  119.78  getreg16(struct regs *regs, int r)
  119.79  {
  119.80  	return MASK16(getreg32(regs, r));
  119.81  }
  119.82  
  119.83 -unsigned
  119.84 +static unsigned
  119.85  getreg8(struct regs *regs, int r)
  119.86  {
  119.87  	switch (r & 7) {
  119.88 @@ -232,7 +250,7 @@ getreg8(struct regs *regs, int r)
  119.89  	return ~0;
  119.90  }
  119.91  
  119.92 -void
  119.93 +static void
  119.94  setreg32(struct regs *regs, int r, unsigned v)
  119.95  {
  119.96  	switch (r & 7) {
  119.97 @@ -247,13 +265,13 @@ setreg32(struct regs *regs, int r, unsig
  119.98  	}
  119.99  }
 119.100  
 119.101 -void
 119.102 +static void
 119.103  setreg16(struct regs *regs, int r, unsigned v)
 119.104  {
 119.105  	setreg32(regs, r, (getreg32(regs, r) & ~0xFFFF) | MASK16(v));
 119.106  }
 119.107  
 119.108 -void
 119.109 +static void
 119.110  setreg8(struct regs *regs, int r, unsigned v)
 119.111  {
 119.112  	v &= 0xFF;
 119.113 @@ -269,7 +287,7 @@ setreg8(struct regs *regs, int r, unsign
 119.114  	}
 119.115  }
 119.116  
 119.117 -unsigned
 119.118 +static unsigned
 119.119  segment(unsigned prefix, struct regs *regs, unsigned seg)
 119.120  {
 119.121  	if (prefix & SEG_ES)
 119.122 @@ -287,7 +305,7 @@ segment(unsigned prefix, struct regs *re
 119.123  	return seg;
 119.124  }
 119.125  
 119.126 -unsigned
 119.127 +static unsigned
 119.128  sib(struct regs *regs, int mod, unsigned byte)
 119.129  {
 119.130  	unsigned scale = (byte >> 6) & 3;
 119.131 @@ -319,7 +337,7 @@ sib(struct regs *regs, int mod, unsigned
 119.132  /*
 119.133   * Operand (modrm) decode
 119.134   */
 119.135 -unsigned
 119.136 +static unsigned
 119.137  operand(unsigned prefix, struct regs *regs, unsigned modrm)
 119.138  {
 119.139  	int mod, disp = 0, seg;
 119.140 @@ -418,7 +436,7 @@ operand(unsigned prefix, struct regs *re
 119.141  /*
 119.142   * Load new IDT
 119.143   */
 119.144 -int
 119.145 +static int
 119.146  lidt(struct regs *regs, unsigned prefix, unsigned modrm)
 119.147  {
 119.148  	unsigned eip = regs->eip - 3;
 119.149 @@ -438,7 +456,7 @@ lidt(struct regs *regs, unsigned prefix,
 119.150  /*
 119.151   * Load new GDT
 119.152   */
 119.153 -int
 119.154 +static int
 119.155  lgdt(struct regs *regs, unsigned prefix, unsigned modrm)
 119.156  {
 119.157  	unsigned eip = regs->eip - 3;
 119.158 @@ -458,7 +476,7 @@ lgdt(struct regs *regs, unsigned prefix,
 119.159  /*
 119.160   * Modify CR0 either through an lmsw instruction.
 119.161   */
 119.162 -int
 119.163 +static int
 119.164  lmsw(struct regs *regs, unsigned prefix, unsigned modrm)
 119.165  {
 119.166  	unsigned eip = regs->eip - 3;
 119.167 @@ -481,7 +499,7 @@ lmsw(struct regs *regs, unsigned prefix,
 119.168   * We need to handle moves that address memory beyond the 64KB segment
 119.169   * limit that VM8086 mode enforces.
 119.170   */
 119.171 -int
 119.172 +static int
 119.173  movr(struct regs *regs, unsigned prefix, unsigned opc)
 119.174  {
 119.175  	unsigned eip = regs->eip - 1;
 119.176 @@ -546,7 +564,7 @@ movr(struct regs *regs, unsigned prefix,
 119.177  /*
 119.178   * Move to and from a control register.
 119.179   */
 119.180 -int
 119.181 +static int
 119.182  movcr(struct regs *regs, unsigned prefix, unsigned opc)
 119.183  {
 119.184  	unsigned eip = regs->eip - 2;
 119.185 @@ -618,7 +636,7 @@ static inline void set_eflags_ZF(unsigne
 119.186   * We need to handle cmp opcodes that address memory beyond the 64KB
 119.187   * segment limit that VM8086 mode enforces.
 119.188   */
 119.189 -int
 119.190 +static int
 119.191  cmp(struct regs *regs, unsigned prefix, unsigned opc)
 119.192  {
 119.193  	unsigned eip = regs->eip - 1;
 119.194 @@ -658,7 +676,7 @@ cmp(struct regs *regs, unsigned prefix, 
 119.195   * We need to handle test opcodes that address memory beyond the 64KB
 119.196   * segment limit that VM8086 mode enforces.
 119.197   */
 119.198 -int
 119.199 +static int
 119.200  test(struct regs *regs, unsigned prefix, unsigned opc)
 119.201  {
 119.202  	unsigned eip = regs->eip - 1;
 119.203 @@ -691,7 +709,7 @@ test(struct regs *regs, unsigned prefix,
 119.204   * We need to handle pop opcodes that address memory beyond the 64KB
 119.205   * segment limit that VM8086 mode enforces.
 119.206   */
 119.207 -int
 119.208 +static int
 119.209  pop(struct regs *regs, unsigned prefix, unsigned opc)
 119.210  {
 119.211  	unsigned eip = regs->eip - 1;
 119.212 @@ -721,7 +739,7 @@ pop(struct regs *regs, unsigned prefix, 
 119.213  /*
 119.214   * Emulate a segment load in protected mode
 119.215   */
 119.216 -int
 119.217 +static int
 119.218  load_seg(unsigned long sel, uint32_t *base, uint32_t *limit, union vmcs_arbytes *arbytes)
 119.219  {
 119.220  	unsigned long long entry;
 119.221 @@ -768,7 +786,7 @@ load_seg(unsigned long sel, uint32_t *ba
 119.222  /*
 119.223   * Transition to protected mode
 119.224   */
 119.225 -void
 119.226 +static void
 119.227  protected_mode(struct regs *regs)
 119.228  {
 119.229  	regs->eflags &= ~(EFLAGS_TF|EFLAGS_VM);
 119.230 @@ -842,7 +860,7 @@ protected_mode(struct regs *regs)
 119.231  /*
 119.232   * Start real-mode emulation
 119.233   */
 119.234 -void
 119.235 +static void
 119.236  real_mode(struct regs *regs)
 119.237  {
 119.238  	regs->eflags |= EFLAGS_VM | 0x02;
 119.239 @@ -935,7 +953,7 @@ set_mode(struct regs *regs, enum vm86_mo
 119.240  	TRACE((regs, 0, states[mode]));
 119.241  }
 119.242  
 119.243 -void
 119.244 +static void
 119.245  jmpl(struct regs *regs, int prefix)
 119.246  {
 119.247  	unsigned n = regs->eip;
 119.248 @@ -963,7 +981,7 @@ jmpl(struct regs *regs, int prefix)
 119.249  		panic("jmpl");
 119.250  }
 119.251  
 119.252 -void
 119.253 +static void
 119.254  retl(struct regs *regs, int prefix)
 119.255  {
 119.256  	unsigned cs, eip;
 119.257 @@ -990,7 +1008,7 @@ retl(struct regs *regs, int prefix)
 119.258  		panic("retl");
 119.259  }
 119.260  
 119.261 -void
 119.262 +static void
 119.263  interrupt(struct regs *regs, int n)
 119.264  {
 119.265  	TRACE((regs, 0, "external interrupt %d", n));
 119.266 @@ -1008,7 +1026,7 @@ interrupt(struct regs *regs, int n)
 119.267   * interrupt vectors. The following simple state machine catches
 119.268   * these attempts and rewrites them.
 119.269   */
 119.270 -int
 119.271 +static int
 119.272  outbyte(struct regs *regs, unsigned prefix, unsigned opc)
 119.273  {
 119.274  	static char icw2[2] = { 0 };
 119.275 @@ -1059,7 +1077,7 @@ outbyte(struct regs *regs, unsigned pref
 119.276  	return 1;
 119.277  }
 119.278  
 119.279 -int
 119.280 +static int
 119.281  inbyte(struct regs *regs, unsigned prefix, unsigned opc)
 119.282  {
 119.283  	int port;
 119.284 @@ -1086,7 +1104,7 @@ enum { OPC_INVALID, OPC_EMULATED };
 119.285   * a small subset of the opcodes, and not all opcodes are implemented for each
 119.286   * of the four modes we can operate in.
 119.287   */
 119.288 -int
 119.289 +static int
 119.290  opcode(struct regs *regs)
 119.291  {
 119.292  	unsigned eip = regs->eip;
 119.293 @@ -1246,7 +1264,7 @@ opcode(struct regs *regs)
 119.294  			if ((mode == VM86_REAL_TO_PROTECTED) ||
 119.295  			    (mode == VM86_PROTECTED_TO_REAL)) {
 119.296  				retl(regs, prefix);
 119.297 -				return OPC_EMULATED;
 119.298 +				return OPC_INVALID;
 119.299  			}
 119.300  			goto invalid;
 119.301  
 119.302 @@ -1284,7 +1302,7 @@ opcode(struct regs *regs)
 119.303  			if ((mode == VM86_REAL_TO_PROTECTED) ||
 119.304  			    (mode == VM86_PROTECTED_TO_REAL)) {
 119.305  				jmpl(regs, prefix);
 119.306 -				return OPC_EMULATED;
 119.307 +				return OPC_INVALID;
 119.308  			}
 119.309  			goto invalid;
 119.310  
   120.1 --- a/tools/firmware/vmxassist/vm86.h	Tue Apr 11 13:55:47 2006 -0600
   120.2 +++ b/tools/firmware/vmxassist/vm86.h	Tue Apr 11 18:54:18 2006 -0600
   120.3 @@ -58,7 +58,6 @@ extern struct vmx_assist_context oldctx;
   120.4  extern struct vmx_assist_context newctx;
   120.5  
   120.6  extern void emulate(struct regs *);
   120.7 -extern void interrupt(struct regs *, int);
   120.8  extern void dump_regs(struct regs *);
   120.9  extern void trace(struct regs *, int, char *, ...);
  120.10  
   121.1 --- a/tools/guest-headers/Makefile	Tue Apr 11 13:55:47 2006 -0600
   121.2 +++ b/tools/guest-headers/Makefile	Tue Apr 11 18:54:18 2006 -0600
   121.3 @@ -2,12 +2,16 @@
   121.4  XEN_ROOT=../..
   121.5  linuxsparsetree = $(XEN_ROOT)/linux-2.6-xen-sparse
   121.6  
   121.7 +.PHONY: all
   121.8  all:
   121.9  
  121.10 +.PHONY: check
  121.11  check:
  121.12  
  121.13 +.PHONY: install
  121.14  install:
  121.15  	mkdir -p $(DESTDIR)/usr/include/xen/linux
  121.16  	install -m0644 $(linuxsparsetree)/include/xen/public/*.h $(DESTDIR)/usr/include/xen/linux
  121.17  
  121.18 +.PHONY: clean
  121.19  clean:
   122.1 --- a/tools/ioemu/Makefile	Tue Apr 11 13:55:47 2006 -0600
   122.2 +++ b/tools/ioemu/Makefile	Tue Apr 11 18:54:18 2006 -0600
   122.3 @@ -19,6 +19,7 @@ LDFLAGS+=-static
   122.4  endif
   122.5  #DOCS=qemu-doc.html qemu-tech.html qemu.1
   122.6  
   122.7 +.PHONY: all
   122.8  all: $(DOCS) HEADERS
   122.9  	for d in $(TARGET_DIRS); do \
  122.10  	$(MAKE) -C $$d $@ || exit 1 ; \
  122.11 @@ -30,6 +31,7 @@ qemu-img: qemu-img.c block.c block-cow.c
  122.12  dyngen$(EXESUF): dyngen.c
  122.13  	$(HOST_CC) $(CFLAGS) $(DEFINES) -o $@ $^
  122.14  
  122.15 +.PHONY: clean
  122.16  clean:
  122.17  # avoid old build problems by removing potentially incorrect old files
  122.18  	rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h 
  122.19 @@ -41,6 +43,7 @@ clean:
  122.20  	rm -f config-host.mak config-host.h
  122.21  	rm -f keysym_adapter_sdl.h keysym_adapter_vnc.h
  122.22  
  122.23 +.PHONY: distclean
  122.24  distclean: clean
  122.25  	rm -f config-host.mak config-host.h
  122.26  	rm -f keysym_adapter_sdl.h keysym_adapter_vnc.h
  122.27 @@ -52,6 +55,7 @@ KEYMAPS=da     en-gb  et  fr     fr-ch  
  122.28  ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
  122.29  common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr
  122.30  
  122.31 +.PHONY: install
  122.32  install: all 
  122.33  	mkdir -p "$(bindir)"
  122.34  	mkdir -p "$(DESTDIR)/$(datadir)"
  122.35 @@ -62,9 +66,11 @@ install: all
  122.36          done
  122.37  
  122.38  # various test targets
  122.39 +.PHONY: test speed test2
  122.40  test speed test2: all
  122.41  	$(MAKE) -C tests $@
  122.42  
  122.43 +.PHONY: TAGS
  122.44  TAGS: 
  122.45  	etags *.[ch] tests/*.[ch]
  122.46  
  122.47 @@ -79,6 +85,7 @@ qemu.1: qemu-doc.texi
  122.48  FILE=qemu-$(shell cat VERSION)
  122.49  
  122.50  # tar release (use 'make -k tar' on a checkouted tree)
  122.51 +.PHONY: tar
  122.52  tar:
  122.53  	rm -rf /tmp/$(FILE)
  122.54  	cp -r . /tmp/$(FILE)
  122.55 @@ -86,6 +93,7 @@ tar:
  122.56  	rm -rf /tmp/$(FILE)
  122.57  
  122.58  # generate a binary distribution
  122.59 +.PHONY: tarbin
  122.60  tarbin:
  122.61  	( cd $(DESTDIR) ; tar zcvf ~/qemu-$(VERSION)-i386.tar.gz \
  122.62  	$(DESTDIR)/$(bindir)/qemu $(DESTDIR)/$(bindir)/qemu-fast \
  122.63 @@ -100,6 +108,7 @@ ifneq ($(wildcard .depend),)
  122.64  include .depend
  122.65  endif
  122.66  
  122.67 +.PHONY: HEADERS
  122.68  HEADERS:
  122.69  
  122.70  ifdef CONFIG_SDL
   123.1 --- a/tools/ioemu/hw/vga.c	Tue Apr 11 13:55:47 2006 -0600
   123.2 +++ b/tools/ioemu/hw/vga.c	Tue Apr 11 18:54:18 2006 -0600
   123.3 @@ -1369,10 +1369,16 @@ static inline unsigned int cpuid_edx(uns
   123.4  {
   123.5      unsigned int eax, edx;
   123.6  
   123.7 -    __asm__("cpuid"
   123.8 +#ifdef __x86_64__
   123.9 +#define __bx "rbx"
  123.10 +#else
  123.11 +#define __bx "ebx"
  123.12 +#endif
  123.13 +    __asm__("push %%"__bx"; cpuid; pop %%"__bx
  123.14              : "=a" (eax), "=d" (edx)
  123.15              : "0" (op)
  123.16 -            : "bx", "cx");
  123.17 +            : "cx");
  123.18 +#undef __bx
  123.19  
  123.20      return edx;
  123.21  }
   124.1 --- a/tools/ioemu/target-i386-dm/Makefile	Tue Apr 11 13:55:47 2006 -0600
   124.2 +++ b/tools/ioemu/target-i386-dm/Makefile	Tue Apr 11 18:54:18 2006 -0600
   124.3 @@ -329,6 +329,7 @@ sdl.o: sdl.c keyboard_rdesktop.c
   124.4  sdlaudio.o: sdlaudio.c
   124.5  	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
   124.6  
   124.7 +.PHONY: depend
   124.8  depend: $(SRCS)
   124.9  	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
  124.10  
  124.11 @@ -382,12 +383,15 @@ mixeng.o: mixeng.c mixeng.h mixeng_templ
  124.12  %.o: %.S
  124.13  	$(CC) $(DEFINES) -c -o $@ $<
  124.14  
  124.15 +.PHONY: clean
  124.16  clean:
  124.17  	rm -rf *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe slirp
  124.18  	rm -rf config.mak config.h
  124.19  
  124.20 +.PHONY: distclean
  124.21  distclean: clean
  124.22  
  124.23 +.PHONY: install
  124.24  install: all 
  124.25  	if [ ! -d $(INSTALL_DIR) ];then mkdir -p $(INSTALL_DIR);fi
  124.26  	if [ ! -d $(DESTDIR)$(configdir) ];then mkdir -p $(DESTDIR)$(configdir);fi
   125.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Tue Apr 11 13:55:47 2006 -0600
   125.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Tue Apr 11 18:54:18 2006 -0600
   125.3 @@ -409,12 +409,20 @@ int xc_handle;
   125.4  void
   125.5  destroy_hvm_domain(void)
   125.6  {
   125.7 -    extern FILE* logfile;
   125.8 -    char destroy_cmd[32];
   125.9 -
  125.10 -    sprintf(destroy_cmd, "xm destroy %d", domid);
  125.11 -    if (system(destroy_cmd) == -1)
  125.12 -        fprintf(logfile, "%s failed.!\n", destroy_cmd);
  125.13 +   int xcHandle;
  125.14 +   int sts;
  125.15 + 
  125.16 +   xcHandle = xc_interface_open();
  125.17 +   if (xcHandle < 0)
  125.18 +     fprintf(logfile, "Cannot acquire xenctrl handle\n");
  125.19 +   else {
  125.20 +     sts = xc_domain_shutdown(xcHandle, domid, SHUTDOWN_poweroff);
  125.21 +     if (sts != 0)
  125.22 +       fprintf(logfile, "? xc_domain_shutdown failed to issue poweroff, sts %d, errno %d\n", sts, errno);
  125.23 +     else
  125.24 +       fprintf(logfile, "Issued domain %d poweroff\n", domid);
  125.25 +     xc_interface_close(xcHandle);
  125.26 +   }
  125.27  }
  125.28  
  125.29  fd_set wakeup_rfds;
  125.30 @@ -480,13 +488,24 @@ int main_loop(void)
  125.31  
  125.32  static void qemu_hvm_reset(void *unused)
  125.33  {
  125.34 -    char cmd[64];
  125.35 +   int xcHandle;
  125.36 +   int sts;
  125.37  
  125.38 -    /* pause domain first, to avoid repeated reboot request*/
  125.39 -    xc_domain_pause(xc_handle, domid);
  125.40 +   /* pause domain first, to avoid repeated reboot request*/
  125.41 +   xc_domain_pause(xc_handle, domid);
  125.42  
  125.43 -    sprintf(cmd, "xm shutdown -R %d", domid);
  125.44 -    system(cmd);
  125.45 +   xcHandle = xc_interface_open();
  125.46 +   if (xcHandle < 0)
  125.47 +     fprintf(logfile, "Cannot acquire xenctrl handle\n");
  125.48 +   else {
  125.49 +     sts = xc_domain_shutdown(xcHandle, domid, SHUTDOWN_reboot);
  125.50 +     if (sts != 0)
  125.51 +       fprintf(logfile, "? xc_domain_shutdown failed to issue reboot, sts %d\n", sts);
  125.52 +     else
  125.53 +       fprintf(logfile, "Issued domain %d reboot\n", domid);
  125.54 +     xc_interface_close(xcHandle);
  125.55 +   }
  125.56 + 
  125.57  }
  125.58  
  125.59  CPUState * cpu_init()
   126.1 --- a/tools/ioemu/vl.c	Tue Apr 11 13:55:47 2006 -0600
   126.2 +++ b/tools/ioemu/vl.c	Tue Apr 11 18:54:18 2006 -0600
   126.3 @@ -2556,8 +2556,10 @@ static int set_mm_mapping(int xc_handle,
   126.4          return -1;
   126.5      }
   126.6  
   126.7 +#if 0 /* Generates lots of log file output - turn on for debugging */
   126.8      for (i = 0; i < nr_pages; i++)
   126.9          fprintf(stderr, "set_map result i %x result %lx\n", i, extent_start[i]);
  126.10 +#endif
  126.11  
  126.12      return 0;
  126.13  }
  126.14 @@ -3244,8 +3246,17 @@ int main(int argc, char **argv)
  126.15      /* we always create the cdrom drive, even if no disk is there */
  126.16      bdrv_init();
  126.17      if (has_cdrom) {
  126.18 -        bs_table[2] = bdrv_new("cdrom");
  126.19 -        bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM);
  126.20 +        int fd;
  126.21 +        if ( (fd = open(hd_filename[2], O_RDONLY | O_BINARY)) < 0) {
  126.22 +                hd_filename[2]=NULL;
  126.23 +                bs_table[2]=NULL;
  126.24 +                fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]);
  126.25 +        }
  126.26 +        else {
  126.27 +                close(fd);
  126.28 +                bs_table[2] = bdrv_new("cdrom");
  126.29 +                bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM);
  126.30 +        }
  126.31      }
  126.32  
  126.33      /* open the virtual block devices */
   127.1 --- a/tools/libxc/Makefile	Tue Apr 11 13:55:47 2006 -0600
   127.2 +++ b/tools/libxc/Makefile	Tue Apr 11 18:54:18 2006 -0600
   127.3 @@ -67,10 +67,14 @@ LIB += libxenctrl.so libxenctrl.so.$(MAJ
   127.4  LIB += libxenguest.a
   127.5  LIB += libxenguest.so libxenguest.so.$(MAJOR) libxenguest.so.$(MAJOR).$(MINOR)
   127.6  
   127.7 +.PHONY: all
   127.8  all: build
   127.9 +
  127.10 +.PHONY: build
  127.11  build: check-for-zlib mk-symlinks
  127.12  	$(MAKE) $(LIB)
  127.13  
  127.14 +.PHONY: check-for-zlib
  127.15  check-for-zlib:
  127.16  	@if [ ! -e /usr/include/zlib.h ]; then \
  127.17  	echo "***********************************************************"; \
  127.18 @@ -79,6 +83,7 @@ check-for-zlib:
  127.19  	false; \
  127.20  	fi
  127.21  
  127.22 +.PHONY: install
  127.23  install: build
  127.24  	[ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
  127.25  	[ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
  127.26 @@ -94,14 +99,15 @@ install: build
  127.27  	ln -sf libxenguest.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenguest.so
  127.28  	$(INSTALL_DATA) xenguest.h $(DESTDIR)/usr/include
  127.29  
  127.30 -.PHONY: TAGS clean rpm install all
  127.31 -
  127.32 +.PHONY: TAGS
  127.33  TAGS:
  127.34  	etags -t *.c *.h
  127.35  
  127.36 +.PHONY: clean
  127.37  clean:
  127.38  	rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
  127.39  
  127.40 +.PHONY: rpm
  127.41  rpm: build
  127.42  	rm -rf staging
  127.43  	mkdir staging
   128.1 --- a/tools/libxc/xc_domain.c	Tue Apr 11 13:55:47 2006 -0600
   128.2 +++ b/tools/libxc/xc_domain.c	Tue Apr 11 18:54:18 2006 -0600
   128.3 @@ -58,6 +58,35 @@ int xc_domain_destroy(int xc_handle,
   128.4      return do_dom0_op(xc_handle, &op);
   128.5  }
   128.6  
   128.7 +int xc_domain_shutdown(int xc_handle,
   128.8 +                       uint32_t domid,
   128.9 +                       int reason)
  128.10 +{
  128.11 +    int ret = -1;
  128.12 +    sched_remote_shutdown_t arg;
  128.13 +    DECLARE_HYPERCALL;
  128.14 +
  128.15 +    hypercall.op     = __HYPERVISOR_sched_op;
  128.16 +    hypercall.arg[0] = (unsigned long)SCHEDOP_remote_shutdown;
  128.17 +    hypercall.arg[1] = (unsigned long)&arg;
  128.18 +    arg.domain_id = domid;
  128.19 +    arg.reason = reason;
  128.20 +
  128.21 +    if ( mlock(&arg, sizeof(arg)) != 0 )
  128.22 +    {
  128.23 +        PERROR("Could not lock memory for Xen hypercall");
  128.24 +        goto out1;
  128.25 +    }
  128.26 +
  128.27 +    ret = do_xen_hypercall(xc_handle, &hypercall);
  128.28 +
  128.29 +    safe_munlock(&arg, sizeof(arg));
  128.30 +
  128.31 + out1:
  128.32 +    return ret;
  128.33 +}
  128.34 +
  128.35 +
  128.36  int xc_vcpu_setaffinity(int xc_handle,
  128.37                          uint32_t domid, 
  128.38                          int vcpu,
   129.1 --- a/tools/libxc/xc_linux_build.c	Tue Apr 11 13:55:47 2006 -0600
   129.2 +++ b/tools/libxc/xc_linux_build.c	Tue Apr 11 18:54:18 2006 -0600
   129.3 @@ -110,10 +110,10 @@ static int parse_features(
   129.4  
   129.5          if ( i == XENFEAT_NR_SUBMAPS*32 )
   129.6          {
   129.7 -            ERROR("Unknown feature \"%.*s\".\n", (int)(p-feats), feats);
   129.8 +            ERROR("Unknown feature \"%.*s\".", (int)(p-feats), feats);
   129.9              if ( req )
  129.10              {
  129.11 -                ERROR("Kernel requires an unknown hypervisor feature.\n");
  129.12 +                ERROR("Kernel requires an unknown hypervisor feature.");
  129.13                  return -EINVAL;
  129.14              }
  129.15          }
  129.16 @@ -579,6 +579,31 @@ static int setup_guest(int xc_handle,
  129.17      return -1;
  129.18  }
  129.19  #else /* x86 */
  129.20 +
  129.21 +/* Check if the platform supports the guest kernel format */
  129.22 +static int compat_check(int xc_handle, struct domain_setup_info *dsi)
  129.23 +{
  129.24 +    xen_capabilities_info_t xen_caps = "";
  129.25 +
  129.26 +    if (xc_version(xc_handle, XENVER_capabilities, &xen_caps) != 0) {
  129.27 +        ERROR("Cannot determine host capabilities.");
  129.28 +        return 0;
  129.29 +    }
  129.30 +
  129.31 +    if (strstr(xen_caps, "xen-3.0-x86_32p")) {
  129.32 +        if (!dsi->pae_kernel) {
  129.33 +            ERROR("Non PAE-kernel on PAE host.");
  129.34 +            return 0;
  129.35 +        }
  129.36 +    } else if (dsi->pae_kernel) {
  129.37 +        ERROR("PAE-kernel on non-PAE host.");
  129.38 +        return 0;
  129.39 +    }
  129.40 +
  129.41 +    return 1;
  129.42 +}
  129.43 +
  129.44 +
  129.45  static int setup_guest(int xc_handle,
  129.46                         uint32_t dom,
  129.47                         const char *image, unsigned long image_size,
  129.48 @@ -635,10 +660,13 @@ static int setup_guest(int xc_handle,
  129.49  
  129.50      if ( (dsi.v_start & (PAGE_SIZE-1)) != 0 )
  129.51      {
  129.52 -        PERROR("Guest OS must load to a page boundary.\n");
  129.53 +        PERROR("Guest OS must load to a page boundary.");
  129.54          goto error_out;
  129.55      }
  129.56  
  129.57 +    if (!compat_check(xc_handle, &dsi))
  129.58 +        goto error_out;
  129.59 +
  129.60      /* Parse and validate kernel features. */
  129.61      p = strstr(dsi.xen_guest_string, "FEATURES=");
  129.62      if ( p != NULL )
  129.63 @@ -647,7 +675,7 @@ static int setup_guest(int xc_handle,
  129.64                               supported_features,
  129.65                               required_features) )
  129.66          {
  129.67 -            ERROR("Failed to parse guest kernel features.\n");
  129.68 +            ERROR("Failed to parse guest kernel features.");
  129.69              goto error_out;
  129.70          }
  129.71  
  129.72 @@ -659,7 +687,7 @@ static int setup_guest(int xc_handle,
  129.73      {
  129.74          if ( (supported_features[i]&required_features[i]) != required_features[i] )
  129.75          {
  129.76 -            ERROR("Guest kernel does not support a required feature.\n");
  129.77 +            ERROR("Guest kernel does not support a required feature.");
  129.78              goto error_out;
  129.79          }
  129.80      }
   130.1 --- a/tools/libxc/xc_linux_restore.c	Tue Apr 11 13:55:47 2006 -0600
   130.2 +++ b/tools/libxc/xc_linux_restore.c	Tue Apr 11 18:54:18 2006 -0600
   130.3 @@ -646,18 +646,14 @@ int xc_linux_restore(int xc_handle, int 
   130.4          goto out;
   130.5      }
   130.6  
   130.7 -    if ((pt_levels == 2) && ((pfn_type[pfn]&LTABTYPE_MASK) != L2TAB)) { 
   130.8 +    if ( (pfn_type[pfn] & LTABTYPE_MASK) != 
   130.9 +         ((unsigned long)pt_levels<<LTAB_SHIFT) ) {
  130.10          ERR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx",
  130.11 -            pfn, max_pfn, pfn_type[pfn], (unsigned long)L2TAB);
  130.12 +            pfn, max_pfn, pfn_type[pfn], 
  130.13 +            (unsigned long)pt_levels<<LTAB_SHIFT); 
  130.14          goto out;
  130.15      }
  130.16  
  130.17 -    if ((pt_levels == 3) && ((pfn_type[pfn]&LTABTYPE_MASK) != L3TAB)) { 
  130.18 -        ERR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx",
  130.19 -            pfn, max_pfn, pfn_type[pfn], (unsigned long)L3TAB);
  130.20 -        goto out;
  130.21 -    }
  130.22 -    
  130.23      ctxt.ctrlreg[3] = p2m[pfn] << PAGE_SHIFT;
  130.24  
  130.25      /* clear any pending events and the selector */
   131.1 --- a/tools/libxc/xc_load_elf.c	Tue Apr 11 13:55:47 2006 -0600
   131.2 +++ b/tools/libxc/xc_load_elf.c	Tue Apr 11 18:54:18 2006 -0600
   131.3 @@ -69,6 +69,21 @@ static int parseelfimage(const char *ima
   131.4          return -EINVAL;
   131.5      }
   131.6  
   131.7 +    if (
   131.8 +#if defined(__i386__)
   131.9 +        (ehdr->e_ident[EI_CLASS] != ELFCLASS32) ||
  131.10 +        (ehdr->e_machine != EM_386) ||
  131.11 +#elif defined(__x86_64__)
  131.12 +        (ehdr->e_ident[EI_CLASS] != ELFCLASS64) ||
  131.13 +        (ehdr->e_machine != EM_X86_64) ||
  131.14 +#endif
  131.15 +        (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) ||
  131.16 +        (ehdr->e_type != ET_EXEC) )
  131.17 +    {
  131.18 +        ERROR("Kernel not a Xen-compatible Elf image.");
  131.19 +        return -EINVAL;
  131.20 +    }
  131.21 +
  131.22      if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize )
  131.23      {
  131.24          ERROR("ELF program headers extend beyond end of image.");
   132.1 --- a/tools/libxc/xc_ptrace.c	Tue Apr 11 13:55:47 2006 -0600
   132.2 +++ b/tools/libxc/xc_ptrace.c	Tue Apr 11 18:54:18 2006 -0600
   132.3 @@ -153,6 +153,79 @@ online_vcpus_changed(cpumap_t cpumap)
   132.4  }
   132.5  
   132.6  /* --------------------- */
   132.7 +/* XXX application state */
   132.8 +static long                     nr_pages = 0;
   132.9 +static unsigned long           *page_array = NULL;
  132.10 +
  132.11 +static void *
  132.12 +map_domain_va_32(
  132.13 +    int xc_handle,
  132.14 +    int cpu,
  132.15 +    void *guest_va,
  132.16 +    int perm)
  132.17 +{
  132.18 +    unsigned long pde, page;
  132.19 +    unsigned long va = (unsigned long)guest_va;
  132.20 +
  132.21 +    static unsigned long  cr3_phys[MAX_VIRT_CPUS];
  132.22 +    static uint32_t *cr3_virt[MAX_VIRT_CPUS];
  132.23 +    static unsigned long  pde_phys[MAX_VIRT_CPUS];
  132.24 +    static uint32_t *pde_virt[MAX_VIRT_CPUS];
  132.25 +    static unsigned long  page_phys[MAX_VIRT_CPUS];
  132.26 +    static uint32_t *page_virt[MAX_VIRT_CPUS];    
  132.27 +    static int            prev_perm[MAX_VIRT_CPUS];
  132.28 +
  132.29 +   if (ctxt[cpu].ctrlreg[3] == 0)
  132.30 +       return NULL;
  132.31 +   if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
  132.32 +    {
  132.33 +        cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
  132.34 +        if ( cr3_virt[cpu] )
  132.35 +            munmap(cr3_virt[cpu], PAGE_SIZE);
  132.36 +        cr3_virt[cpu] = xc_map_foreign_range(
  132.37 +            xc_handle, current_domid, PAGE_SIZE, PROT_READ,
  132.38 +            cr3_phys[cpu] >> PAGE_SHIFT);
  132.39 +        if ( cr3_virt[cpu] == NULL )
  132.40 +            return NULL;
  132.41 +    }
  132.42 +    if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
  132.43 +        return NULL;
  132.44 +    if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
  132.45 +        pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
  132.46 +    if ( pde != pde_phys[cpu] )
  132.47 +    {
  132.48 +        pde_phys[cpu] = pde;
  132.49 +        if ( pde_virt[cpu] )
  132.50 +            munmap(pde_virt[cpu], PAGE_SIZE);
  132.51 +        pde_virt[cpu] = xc_map_foreign_range(
  132.52 +            xc_handle, current_domid, PAGE_SIZE, PROT_READ,
  132.53 +            pde_phys[cpu] >> PAGE_SHIFT);
  132.54 +        if ( pde_virt[cpu] == NULL )
  132.55 +            return NULL;
  132.56 +    }
  132.57 +    if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
  132.58 +        return NULL;
  132.59 +    if (ctxt[cpu].flags & VGCF_HVM_GUEST)
  132.60 +        page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
  132.61 +    if ( (page != page_phys[cpu]) || (perm != prev_perm[cpu]) )
  132.62 +    {
  132.63 +        page_phys[cpu] = page;
  132.64 +        if ( page_virt[cpu] )
  132.65 +            munmap(page_virt[cpu], PAGE_SIZE);
  132.66 +        page_virt[cpu] = xc_map_foreign_range(
  132.67 +            xc_handle, current_domid, PAGE_SIZE, perm,
  132.68 +            page_phys[cpu] >> PAGE_SHIFT);
  132.69 +        if ( page_virt[cpu] == NULL )
  132.70 +        {
  132.71 +            page_phys[cpu] = 0;
  132.72 +            return NULL;
  132.73 +        }
  132.74 +        prev_perm[cpu] = perm;
  132.75 +    } 
  132.76 +
  132.77 +    return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
  132.78 +}
  132.79 +
  132.80  
  132.81  static void *
  132.82  map_domain_va_pae(
  132.83 @@ -165,28 +238,31 @@ map_domain_va_pae(
  132.84      uint64_t *l3, *l2, *l1;
  132.85      static void *v;
  132.86  
  132.87 -    if (fetch_regs(xc_handle, cpu, NULL))
  132.88 -        return NULL;
  132.89 -
  132.90      l3 = xc_map_foreign_range(
  132.91          xc_handle, current_domid, PAGE_SIZE, PROT_READ, ctxt[cpu].ctrlreg[3] >> PAGE_SHIFT);
  132.92      if ( l3 == NULL )
  132.93          return NULL;
  132.94  
  132.95      l2p = l3[l3_table_offset_pae(va)] >> PAGE_SHIFT;
  132.96 +    l2p = page_array[l2p];
  132.97      l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l2p);
  132.98 +    munmap(l3, PAGE_SIZE);
  132.99      if ( l2 == NULL )
 132.100          return NULL;
 132.101  
 132.102      l1p = l2[l2_table_offset_pae(va)] >> PAGE_SHIFT;
 132.103 +    l1p = page_array[l1p];
 132.104      l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p);
 132.105 +    munmap(l2, PAGE_SIZE);
 132.106      if ( l1 == NULL )
 132.107          return NULL;
 132.108  
 132.109      p = l1[l1_table_offset_pae(va)] >> PAGE_SHIFT;
 132.110 +    p = page_array[p];
 132.111      if ( v != NULL )
 132.112          munmap(v, PAGE_SIZE);
 132.113      v = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p);
 132.114 +    munmap(l1, PAGE_SIZE);
 132.115      if ( v == NULL )
 132.116          return NULL;
 132.117  
 132.118 @@ -195,46 +271,58 @@ map_domain_va_pae(
 132.119  
 132.120  #ifdef __x86_64__
 132.121  static void *
 132.122 -map_domain_va(
 132.123 +map_domain_va_64(
 132.124      int xc_handle,
 132.125      int cpu,
 132.126      void *guest_va,
 132.127      int perm)
 132.128  {
 132.129 -    unsigned long l3p, l2p, l1p, p, va = (unsigned long)guest_va;
 132.130 +    unsigned long l3p, l2p, l1p, l1e, p, va = (unsigned long)guest_va;
 132.131      uint64_t *l4, *l3, *l2, *l1;
 132.132      static void *v;
 132.133  
 132.134      if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
 132.135 -        return map_domain_va_pae(xc_handle, cpu, guest_va, perm);
 132.136 +        return map_domain_va_32(xc_handle, cpu, guest_va, perm);
 132.137  
 132.138 -    if (fetch_regs(xc_handle, cpu, NULL))
 132.139 -        return NULL;
 132.140 -
 132.141 -    l4 = xc_map_foreign_range(
 132.142 -        xc_handle, current_domid, PAGE_SIZE, PROT_READ, ctxt[cpu].ctrlreg[3] >> PAGE_SHIFT);
 132.143 +    l4 = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE, 
 132.144 +            PROT_READ, ctxt[cpu].ctrlreg[3] >> PAGE_SHIFT);
 132.145      if ( l4 == NULL )
 132.146          return NULL;
 132.147  
 132.148      l3p = l4[l4_table_offset(va)] >> PAGE_SHIFT;
 132.149 +    l3p = page_array[l3p];
 132.150      l3 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l3p);
 132.151 +    munmap(l4, PAGE_SIZE);
 132.152      if ( l3 == NULL )
 132.153          return NULL;
 132.154  
 132.155      l2p = l3[l3_table_offset(va)] >> PAGE_SHIFT;
 132.156 +    l2p = page_array[l2p];
 132.157      l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l2p);
 132.158 +    munmap(l3, PAGE_SIZE);
 132.159      if ( l2 == NULL )
 132.160          return NULL;
 132.161  
 132.162 -    l1p = l2[l2_table_offset(va)] >> PAGE_SHIFT;
 132.163 -    l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p);
 132.164 -    if ( l1 == NULL )
 132.165 -        return NULL;
 132.166 +    l1 = NULL;
 132.167 +    l1e = l2[l2_table_offset(va)];
 132.168 +    l1p = l1e >> PAGE_SHIFT;
 132.169 +    if (l1e & 0x80)  { /* 2M pages */
 132.170 +        p = (l1p + l1_table_offset(va));
 132.171 +    } else { /* 4K pages */
 132.172 +        l1p = page_array[l1p];
 132.173 +        l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p);
 132.174 +        munmap(l2, PAGE_SIZE);
 132.175 +        if ( l1 == NULL )
 132.176 +            return NULL;
 132.177  
 132.178 -    p = l1[l1_table_offset(va)] >> PAGE_SHIFT;
 132.179 +        p = l1[l1_table_offset(va)] >> PAGE_SHIFT;
 132.180 +    }
 132.181 +    p = page_array[p];
 132.182      if ( v != NULL )
 132.183          munmap(v, PAGE_SIZE);
 132.184      v = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p);
 132.185 +    if (l1)
 132.186 +        munmap(l1, PAGE_SIZE);
 132.187      if ( v == NULL )
 132.188          return NULL;
 132.189  
 132.190 @@ -242,11 +330,6 @@ map_domain_va(
 132.191  }
 132.192  #endif
 132.193  
 132.194 -#ifdef __i386__
 132.195 -/* XXX application state */
 132.196 -static long                     nr_pages = 0;
 132.197 -static unsigned long           *page_array = NULL;
 132.198 -
 132.199  static void *
 132.200  map_domain_va(
 132.201      int xc_handle,
 132.202 @@ -254,20 +337,9 @@ map_domain_va(
 132.203      void *guest_va,
 132.204      int perm)
 132.205  {
 132.206 -
 132.207 -    unsigned long pde, page;
 132.208 -    unsigned long va = (unsigned long)guest_va;
 132.209 +    unsigned long va = (unsigned long) guest_va;
 132.210      long npgs = xc_get_tot_pages(xc_handle, current_domid);
 132.211 -
 132.212 -
 132.213 -    static uint32_t  cr3_phys[MAX_VIRT_CPUS];
 132.214 -    static unsigned long *cr3_virt[MAX_VIRT_CPUS];
 132.215 -    static unsigned long  pde_phys[MAX_VIRT_CPUS];
 132.216 -    static unsigned long *pde_virt[MAX_VIRT_CPUS];
 132.217 -    static unsigned long  page_phys[MAX_VIRT_CPUS];
 132.218 -    static unsigned long *page_virt[MAX_VIRT_CPUS];    
 132.219 -    static int            prev_perm[MAX_VIRT_CPUS];
 132.220 -    static enum { MODE_UNKNOWN, MODE_32, MODE_PAE, MODE_64 } mode;
 132.221 +    static enum { MODE_UNKNOWN, MODE_64, MODE_32, MODE_PAE } mode;
 132.222  
 132.223      if ( mode == MODE_UNKNOWN )
 132.224      {
 132.225 @@ -281,9 +353,6 @@ map_domain_va(
 132.226              mode = MODE_32;
 132.227      }
 132.228  
 132.229 -    if ( mode == MODE_PAE )
 132.230 -        return map_domain_va_pae(xc_handle, cpu, guest_va, perm);
 132.231 -
 132.232      if ( nr_pages != npgs )
 132.233      {
 132.234          if ( nr_pages > 0 )
 132.235 @@ -305,60 +374,34 @@ map_domain_va(
 132.236      if (fetch_regs(xc_handle, cpu, NULL))
 132.237          return NULL;
 132.238  
 132.239 -    if (paging_enabled(&ctxt[cpu])) {
 132.240 -       if ( ctxt[cpu].ctrlreg[3] != cr3_phys[cpu] )
 132.241 -        {
 132.242 -            cr3_phys[cpu] = ctxt[cpu].ctrlreg[3];
 132.243 -            if ( cr3_virt[cpu] )
 132.244 -                munmap(cr3_virt[cpu], PAGE_SIZE);
 132.245 -            cr3_virt[cpu] = xc_map_foreign_range(
 132.246 -                xc_handle, current_domid, PAGE_SIZE, PROT_READ,
 132.247 -                cr3_phys[cpu] >> PAGE_SHIFT);
 132.248 -            if ( cr3_virt[cpu] == NULL )
 132.249 -                return NULL;
 132.250 -        }
 132.251 -        if ( (pde = cr3_virt[cpu][vtopdi(va)]) == 0 )
 132.252 +    if (!paging_enabled(&ctxt[cpu])) { 
 132.253 +        static void * v;
 132.254 +        unsigned long page;
 132.255 +
 132.256 +        if ( v != NULL )
 132.257 +            munmap(v, PAGE_SIZE);
 132.258 +
 132.259 +        page = page_array[va >> PAGE_SHIFT] << PAGE_SHIFT;
 132.260 +
 132.261 +        v = xc_map_foreign_range( xc_handle, current_domid, PAGE_SIZE, 
 132.262 +                perm, page >> PAGE_SHIFT);
 132.263 +    
 132.264 +        if ( v == NULL )
 132.265              return NULL;
 132.266 -        if ( (ctxt[cpu].flags & VGCF_HVM_GUEST) && paging_enabled(&ctxt[cpu]) )
 132.267 -            pde = page_array[pde >> PAGE_SHIFT] << PAGE_SHIFT;
 132.268 -        if ( pde != pde_phys[cpu] )
 132.269 -        {
 132.270 -            pde_phys[cpu] = pde;
 132.271 -            if ( pde_virt[cpu] )
 132.272 -                munmap(pde_virt[cpu], PAGE_SIZE);
 132.273 -            pde_virt[cpu] = xc_map_foreign_range(
 132.274 -                xc_handle, current_domid, PAGE_SIZE, PROT_READ,
 132.275 -                pde_phys[cpu] >> PAGE_SHIFT);
 132.276 -            if ( pde_virt[cpu] == NULL )
 132.277 -                return NULL;
 132.278 -        }
 132.279 -        if ( (page = pde_virt[cpu][vtopti(va)]) == 0 )
 132.280 -            return NULL;
 132.281 -    } else {
 132.282 -        page = va;
 132.283 +
 132.284 +        return (void *)(((unsigned long)v) | (va & BSD_PAGE_MASK));
 132.285      }
 132.286 -    if (ctxt[cpu].flags & VGCF_HVM_GUEST)
 132.287 -        page = page_array[page >> PAGE_SHIFT] << PAGE_SHIFT;
 132.288 -    if ( (page != page_phys[cpu]) || (perm != prev_perm[cpu]) )
 132.289 -    {
 132.290 -        page_phys[cpu] = page;
 132.291 -        if ( page_virt[cpu] )
 132.292 -            munmap(page_virt[cpu], PAGE_SIZE);
 132.293 -        page_virt[cpu] = xc_map_foreign_range(
 132.294 -            xc_handle, current_domid, PAGE_SIZE, perm,
 132.295 -            page_phys[cpu] >> PAGE_SHIFT);
 132.296 -        if ( page_virt[cpu] == NULL )
 132.297 -        {
 132.298 -            page_phys[cpu] = 0;
 132.299 -            return NULL;
 132.300 -        }
 132.301 -        prev_perm[cpu] = perm;
 132.302 -    } 
 132.303 -
 132.304 -    return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
 132.305 +#ifdef __x86_64__
 132.306 +    if ( mode == MODE_64 )
 132.307 +        return map_domain_va_64(xc_handle, cpu, guest_va, perm);
 132.308 +#endif
 132.309 +    if ( mode == MODE_PAE )
 132.310 +        return map_domain_va_pae(xc_handle, cpu, guest_va, perm);
 132.311 +    /* else ( mode == MODE_32 ) */
 132.312 +    return map_domain_va_32(xc_handle, cpu, guest_va, perm);
 132.313  }
 132.314  
 132.315 -#endif
 132.316 +int control_c_pressed_flag = 0;
 132.317  
 132.318  static int 
 132.319  __xc_waitdomain(
 132.320 @@ -378,7 +421,6 @@ static int
 132.321      op.cmd = DOM0_GETDOMAININFO;
 132.322      op.u.getdomaininfo.domain = domain;
 132.323      
 132.324 -    
 132.325   retry:
 132.326      retval = do_dom0_op(xc_handle, &op);
 132.327      if ( retval || (op.u.getdomaininfo.domain != domain) )
 132.328 @@ -391,12 +433,17 @@ static int
 132.329      if ( options & WNOHANG )
 132.330          goto done;
 132.331  
 132.332 +    if (control_c_pressed_flag) {
 132.333 +        xc_domain_pause(xc_handle, domain);
 132.334 +        control_c_pressed_flag = 0;
 132.335 +        goto done;
 132.336 +    }
 132.337 +
 132.338      if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) )
 132.339      {
 132.340          nanosleep(&ts,NULL);
 132.341          goto retry;
 132.342      }
 132.343 -    /* XXX check for ^C here */
 132.344   done:
 132.345      if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
 132.346          printf("get_online_cpumap failed\n");
 132.347 @@ -470,7 +517,7 @@ xc_ptrace(
 132.348          break;
 132.349  
 132.350      case PTRACE_SETREGS:
 132.351 -        if (!current_isfile)
 132.352 +        if (current_isfile)
 132.353                  goto out_unspported; /* XXX not yet supported */
 132.354          SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].user_regs);
 132.355          if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu, 
 132.356 @@ -492,7 +539,7 @@ xc_ptrace(
 132.357  
 132.358      case PTRACE_CONT:
 132.359      case PTRACE_DETACH:
 132.360 -        if (!current_isfile)
 132.361 +        if (current_isfile)
 132.362              goto out_unspported; /* XXX not yet supported */
 132.363          if ( request != PTRACE_SINGLESTEP )
 132.364          {
   133.1 --- a/tools/libxc/xc_ptrace.h	Tue Apr 11 13:55:47 2006 -0600
   133.2 +++ b/tools/libxc/xc_ptrace.h	Tue Apr 11 18:54:18 2006 -0600
   133.3 @@ -31,7 +31,7 @@ struct gdb_regs
   133.4    unsigned long orig_rax;
   133.5    unsigned long rip;
   133.6    unsigned long xcs;
   133.7 -  unsigned long eflags;
   133.8 +  unsigned long rflags;
   133.9    unsigned long rsp;
  133.10    unsigned long xss;
  133.11    unsigned long fs_base;
  133.12 @@ -61,7 +61,7 @@ struct gdb_regs
  133.13      pt.rax = xc.rax;                            \
  133.14      pt.rip = xc.rip;                            \
  133.15      pt.xcs = xc.cs;                             \
  133.16 -    pt.eflags = xc.eflags;                      \
  133.17 +    pt.rflags = xc.rflags;                      \
  133.18      pt.rsp = xc.rsp;                            \
  133.19      pt.xss = xc.ss;                             \
  133.20      pt.xes = xc.es;                             \
  133.21 @@ -89,7 +89,7 @@ struct gdb_regs
  133.22      xc.rax = pt->rax;                           \
  133.23      xc.rip = pt->rip;                           \
  133.24      xc.cs = pt->xcs;                            \
  133.25 -    xc.eflags = pt->eflags;                     \
  133.26 +    xc.rflags = pt->rflags & 0xffffffff;        \
  133.27      xc.rsp = pt->rsp;                           \
  133.28      xc.ss = pt->xss;                            \
  133.29      xc.es = pt->xes;                            \
   134.1 --- a/tools/libxc/xenctrl.h	Tue Apr 11 13:55:47 2006 -0600
   134.2 +++ b/tools/libxc/xenctrl.h	Tue Apr 11 18:54:18 2006 -0600
   134.3 @@ -206,6 +206,21 @@ int xc_domain_unpause(int xc_handle,
   134.4  int xc_domain_destroy(int xc_handle, 
   134.5                        uint32_t domid);
   134.6  
   134.7 +/**
   134.8 + * This function will shutdown a domain. This is intended for use in
   134.9 + * fully-virtualized domains where this operation is analogous to the
  134.10 + * sched_op operations in a paravirtualized domain. The caller is
  134.11 + * expected to give the reason for the shutdown.
  134.12 + *
  134.13 + * @parm xc_handle a handle to an open hypervisor interface
  134.14 + * @parm domid the domain id to destroy
  134.15 + * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
  134.16 + * @return 0 on success, -1 on failure
  134.17 + */
  134.18 +int xc_domain_shutdown(int xc_handle, 
  134.19 +                       uint32_t domid,
  134.20 +                       int reason);
  134.21 +
  134.22  int xc_vcpu_setaffinity(int xc_handle,
  134.23                          uint32_t domid,
  134.24                          int vcpu,
   135.1 --- a/tools/misc/Makefile	Tue Apr 11 13:55:47 2006 -0600
   135.2 +++ b/tools/misc/Makefile	Tue Apr 11 18:54:18 2006 -0600
   135.3 @@ -18,7 +18,10 @@ TARGETS  = xenperf xc_shadow
   135.4  INSTALL_BIN  = $(TARGETS) xencons
   135.5  INSTALL_SBIN = netfix xm xen-bugtool xend xenperf
   135.6  
   135.7 +.PHONY: all
   135.8  all: build
   135.9 +
  135.10 +.PHONY: build
  135.11  build: $(TARGETS)
  135.12  	$(MAKE) -C miniterm
  135.13  	$(MAKE) -C cpuperf
  135.14 @@ -27,6 +30,7 @@ ifneq ($(XEN_TARGET_ARCH),ia64)
  135.15  endif
  135.16  	$(MAKE) -C lomount
  135.17  
  135.18 +.PHONY: install
  135.19  install: build
  135.20  	[ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
  135.21  	[ -d $(DESTDIR)/usr/sbin ] || $(INSTALL_DIR) $(DESTDIR)/usr/sbin
  135.22 @@ -39,6 +43,7 @@ install: build
  135.23  #       Likewise mbootpack
  135.24  #	$(MAKE) -C mbootpack install
  135.25  
  135.26 +.PHONY: clean
  135.27  clean:
  135.28  	$(RM) *.o $(TARGETS) *~
  135.29  	$(MAKE) -C miniterm clean
   136.1 --- a/tools/misc/cpuperf/Makefile	Tue Apr 11 13:55:47 2006 -0600
   136.2 +++ b/tools/misc/cpuperf/Makefile	Tue Apr 11 18:54:18 2006 -0600
   136.3 @@ -26,8 +26,10 @@ TARGETS      = cpuperf-xen cpuperf-perfc
   136.4  INSTALL_BIN  = $(TARGETS)
   136.5  
   136.6  
   136.7 +.PHONY: all
   136.8  all: $(TARGETS)
   136.9  
  136.10 +.PHONY: clean
  136.11  clean:
  136.12  	$(RM) *.o $(TARGETS)
  136.13  
  136.14 @@ -40,6 +42,7 @@ cpuperf-xen: cpuperf.c $(HDRS) Makefile
  136.15  cpuperf-perfcntr: cpuperf.c $(HDRS) Makefile
  136.16  	$(CC) $(CFLAGS) -DPERFCNTR -o $@ $<
  136.17  
  136.18 +.PHONY: install
  136.19  install: all
  136.20  	$(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin
  136.21  
   137.1 --- a/tools/misc/lomount/Makefile	Tue Apr 11 13:55:47 2006 -0600
   137.2 +++ b/tools/misc/lomount/Makefile	Tue Apr 11 18:54:18 2006 -0600
   137.3 @@ -13,12 +13,17 @@ OBJS     = $(patsubst %.c,%.o,$(wildcard
   137.4  
   137.5  BIN      = lomount
   137.6  
   137.7 +.PHONY: all
   137.8  all: build
   137.9 +
  137.10 +.PHONY: build
  137.11  build: $(BIN)
  137.12  
  137.13 +.PHONY: install
  137.14  install: build
  137.15  	$(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)/usr/bin
  137.16  
  137.17 +.PHONY: clean
  137.18  clean:
  137.19  	$(RM) *.a *.so *.o *.rpm $(BIN)
  137.20  
   138.1 --- a/tools/misc/mbootpack/Makefile	Tue Apr 11 13:55:47 2006 -0600
   138.2 +++ b/tools/misc/mbootpack/Makefile	Tue Apr 11 18:54:18 2006 -0600
   138.3 @@ -8,9 +8,13 @@ INSTALL_DIR	= $(INSTALL) -d -m0755
   138.4  XEN_ROOT=../../..
   138.5  include $(XEN_ROOT)/tools/Rules.mk
   138.6  
   138.7 +.PHONY: all
   138.8  all: build
   138.9 +
  138.10 +.PHONY: build
  138.11  build: mbootpack
  138.12  
  138.13 +.PHONY: install
  138.14  install: build
  138.15  	$(INSTALL_PROG) mbootpack $(DESTDIR)/usr/bin
  138.16  
  138.17 @@ -33,6 +37,7 @@ DEPS     = .*.d
  138.18  mbootpack: $(OBJS)
  138.19  	$(HOSTCC) -o $@ $(filter-out %.a, $^)
  138.20  
  138.21 +.PHONY: clean
  138.22  clean:
  138.23  	$(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c
  138.24  
  138.25 @@ -60,7 +65,6 @@ buildimage.c: bzimage_header.c
  138.26  %.o: %.c
  138.27  	$(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@
  138.28  
  138.29 -.PHONY: all clean gdb
  138.30  .PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS)
  138.31  .SUFFIXES: 
  138.32  
   139.1 --- a/tools/misc/miniterm/Makefile	Tue Apr 11 13:55:47 2006 -0600
   139.2 +++ b/tools/misc/miniterm/Makefile	Tue Apr 11 18:54:18 2006 -0600
   139.3 @@ -7,12 +7,15 @@ INSTALL_DIR	= $(INSTALL) -d -m0755
   139.4  
   139.5  TARGET = miniterm
   139.6  
   139.7 +.PHONY: all
   139.8  all: $(TARGET)
   139.9  
  139.10 +.PHONY: install
  139.11  install: all
  139.12  	[ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
  139.13  	$(INSTALL_PROG) $(TARGET) $(DESTDIR)/usr/bin
  139.14  
  139.15 +.PHONY: clean
  139.16  clean:
  139.17  	$(RM) *.o $(TARGET) *~
  139.18  
   140.1 --- a/tools/misc/nsplitd/Makefile	Tue Apr 11 13:55:47 2006 -0600
   140.2 +++ b/tools/misc/nsplitd/Makefile	Tue Apr 11 18:54:18 2006 -0600
   140.3 @@ -8,10 +8,13 @@ OBJS     = $(patsubst %.c,%.o,$(wildcard
   140.4  
   140.5  TARGET   = nsplitd
   140.6  
   140.7 +.PHONY: all
   140.8  all: $(TARGET)
   140.9  
  140.10 +.PHONY: install
  140.11  install: all
  140.12  
  140.13 +.PHONY: clean
  140.14  clean:
  140.15  	$(RM) *.o $(TARGET) *~
  140.16  
   141.1 --- a/tools/pygrub/Makefile	Tue Apr 11 13:55:47 2006 -0600
   141.2 +++ b/tools/pygrub/Makefile	Tue Apr 11 18:54:18 2006 -0600
   141.3 @@ -2,10 +2,13 @@
   141.4  XEN_ROOT = ../..
   141.5  include $(XEN_ROOT)/tools/Rules.mk
   141.6  
   141.7 +.PHONY: all
   141.8  all: build
   141.9 +.PHONY: build
  141.10  build:
  141.11  	CFLAGS="$(CFLAGS)" python setup.py build
  141.12  
  141.13 +.PHONY: install
  141.14  ifndef XEN_PYTHON_NATIVE_INSTALL
  141.15  install: all
  141.16  	CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr"
  141.17 @@ -14,5 +17,6 @@ install: all
  141.18  	CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)"
  141.19  endif
  141.20  
  141.21 +.PHONY: clean
  141.22  clean:
  141.23 -	rm -rf build tmp *.pyc *.pyo *.o *.a *~
  141.24 +	rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out
   142.1 --- a/tools/pygrub/src/fsys/ext2/ext2module.c	Tue Apr 11 13:55:47 2006 -0600
   142.2 +++ b/tools/pygrub/src/fsys/ext2/ext2module.c	Tue Apr 11 18:54:18 2006 -0600
   142.3 @@ -213,7 +213,9 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args
   142.4      int flags = 0, superblock = 0, offset = 0, err;
   142.5      unsigned int block_size = 0;
   142.6      ext2_filsys efs;
   142.7 +#ifdef HAVE_EXT2FS_OPEN2
   142.8      char offsetopt[30];
   142.9 +#endif
  142.10  
  142.11      if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|iiii", kwlist, 
  142.12                                       &name, &flags, &superblock, 
  142.13 @@ -225,19 +227,27 @@ ext2_fs_open (Ext2Fs *fs, PyObject *args
  142.14          return NULL;
  142.15      }
  142.16  
  142.17 -    if (offset != 0) {
  142.18 +#ifdef HAVE_EXT2FS_OPEN2
  142.19 +    if (offset == 0) {
  142.20 +        offsetopt[0] = '\0';
  142.21 +    }
  142.22 +    else {
  142.23          snprintf(offsetopt, 29, "offset=%d", offset);
  142.24      }
  142.25  
  142.26 -#ifdef HAVE_EXT2FS_OPEN2
  142.27      err = ext2fs_open2(name, offsetopt, flags, superblock, block_size, 
  142.28                         unix_io_manager, &efs);
  142.29  #else
  142.30 +    if (offset != 0) {
  142.31 +        PyErr_SetString(PyExc_ValueError, "offset argument not supported");
  142.32 +        return NULL;
  142.33 +    }
  142.34 +
  142.35      err = ext2fs_open(name, flags, superblock, block_size,
  142.36                        unix_io_manager, &efs);
  142.37  #endif
  142.38      if (err) {
  142.39 -        PyErr_SetString(PyExc_ValueError, "unable to open file");
  142.40 +        PyErr_SetString(PyExc_ValueError, "unable to open filesystem");
  142.41          return NULL;
  142.42      }
  142.43  
   143.1 --- a/tools/python/Makefile	Tue Apr 11 13:55:47 2006 -0600
   143.2 +++ b/tools/python/Makefile	Tue Apr 11 18:54:18 2006 -0600
   143.3 @@ -1,12 +1,14 @@
   143.4  XEN_ROOT = ../..
   143.5  include $(XEN_ROOT)/tools/Rules.mk
   143.6  
   143.7 -.PHONY: all build install clean
   143.8 +.PHONY: all
   143.9 +all: build
  143.10  
  143.11 -all: build
  143.12 +.PHONY: build
  143.13  build:
  143.14  	CFLAGS="$(CFLAGS)" python setup.py build
  143.15  
  143.16 +.PHONY: install
  143.17  ifndef XEN_PYTHON_NATIVE_INSTALL
  143.18  install: all
  143.19  	CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --force
  143.20 @@ -15,8 +17,10 @@ install: all
  143.21  	CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
  143.22  endif
  143.23  
  143.24 +.PHONY: test
  143.25  test:
  143.26  	export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); python test.py -b -u
  143.27  
  143.28 +.PHONY: clean
  143.29  clean:
  143.30  	rm -rf build *.pyc *.pyo *.o *.a *~
   144.1 --- a/tools/python/xen/util/diagnose.py	Tue Apr 11 13:55:47 2006 -0600
   144.2 +++ b/tools/python/xen/util/diagnose.py	Tue Apr 11 18:54:18 2006 -0600
   144.3 @@ -41,7 +41,7 @@ def diagnose(dom):
   144.4      global dompath
   144.5      
   144.6      try:
   144.7 -        domain = server.xend_domain(dom)
   144.8 +        domain = server.xend.domain(dom)
   144.9          state = sxp.child_value(domain, 'state')
  144.10          domid = int(sxp.child_value(domain, 'domid'))
  144.11          name = sxp.child_value(domain, 'name')
   145.1 --- a/tools/python/xen/util/xmlrpclib2.py	Tue Apr 11 13:55:47 2006 -0600
   145.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Tue Apr 11 18:54:18 2006 -0600
   145.3 @@ -20,12 +20,19 @@
   145.4  An enhanced XML-RPC client/server interface for Python.
   145.5  """
   145.6  
   145.7 +import string
   145.8 +import types
   145.9 +
  145.10  from httplib import HTTPConnection, HTTP
  145.11  from xmlrpclib import Transport
  145.12  from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
  145.13 -import xmlrpclib, socket, os, traceback
  145.14 +import xmlrpclib, socket, os, stat
  145.15  import SocketServer
  145.16  
  145.17 +import xen.xend.XendClient
  145.18 +from xen.xend.XendLogging import log
  145.19 +
  145.20 +
  145.21  # A new ServerProxy that also supports httpu urls.  An http URL comes in the
  145.22  # form:
  145.23  #
  145.24 @@ -48,6 +55,18 @@ class UnixTransport(Transport):
  145.25      def make_connection(self, host):
  145.26          return HTTPUnix(self.__handler)
  145.27  
  145.28 +
  145.29 +# See _marshalled_dispatch below.
  145.30 +def conv_string(x):
  145.31 +    if (isinstance(x, types.StringType) or
  145.32 +        isinstance(x, unicode)):
  145.33 +        s = string.replace(x, "'", r"\047")
  145.34 +        exec "s = '" + s + "'"
  145.35 +        return s
  145.36 +    else:
  145.37 +        return x
  145.38 +
  145.39 +
  145.40  class ServerProxy(xmlrpclib.ServerProxy):
  145.41      def __init__(self, uri, transport=None, encoding=None, verbose=0,
  145.42                   allow_none=1):
  145.43 @@ -59,9 +78,18 @@ class ServerProxy(xmlrpclib.ServerProxy)
  145.44          xmlrpclib.ServerProxy.__init__(self, uri, transport, encoding,
  145.45                                         verbose, allow_none)
  145.46  
  145.47 +
  145.48 +    def __request(self, methodname, params):
  145.49 +        response = xmlrpclib.ServerProxy.__request(self, methodname, params)
  145.50 +
  145.51 +        if isinstance(response, tuple):
  145.52 +            return tuple([conv_string(x) for x in response])
  145.53 +        else:
  145.54 +            return conv_string(response)
  145.55 +
  145.56 +
  145.57  # This is a base XML-RPC server for TCP.  It sets allow_reuse_address to
  145.58 -# true, and has an improved marshaller that serializes unknown exceptions
  145.59 -# with full traceback information.
  145.60 +# true, and has an improved marshaller that logs and serializes exceptions.
  145.61  
  145.62  class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
  145.63      allow_reuse_address = True
  145.64 @@ -74,16 +102,28 @@ class TCPXMLRPCServer(SocketServer.Threa
  145.65              else:
  145.66                  response = self._dispatch(method, params)
  145.67  
  145.68 +            # With either Unicode or normal strings, we can only transmit
  145.69 +            # \t, \n, \r, \u0020-\ud7ff, \ue000-\ufffd, and \u10000-\u10ffff
  145.70 +            # in an XML document.  xmlrpclib does not escape these values
  145.71 +            # properly, and then breaks when it comes to parse the document.
  145.72 +            # To hack around this problem, we use repr here and exec above
  145.73 +            # to transmit the string using Python encoding.
  145.74 +            # Thanks to David Mertz <mertz@gnosis.cx> for the trick (buried
  145.75 +            # in xml_pickle.py).
  145.76 +            if (isinstance(response, types.StringType) or
  145.77 +                isinstance(response, unicode)):
  145.78 +                response = repr(response)[1:-1]
  145.79 +
  145.80              response = (response,)
  145.81              response = xmlrpclib.dumps(response,
  145.82                                         methodresponse=1,
  145.83                                         allow_none=1)
  145.84          except xmlrpclib.Fault, fault:
  145.85              response = xmlrpclib.dumps(fault)
  145.86 -        except:
  145.87 +        except Exception, exn:
  145.88 +            log.exception(exn)
  145.89              response = xmlrpclib.dumps(
  145.90 -                xmlrpclib.Fault(1, traceback.format_exc())
  145.91 -                )
  145.92 +                xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
  145.93  
  145.94          return response
  145.95  
  145.96 @@ -102,10 +142,13 @@ class UnixXMLRPCServer(TCPXMLRPCServer):
  145.97      address_family = socket.AF_UNIX
  145.98  
  145.99      def __init__(self, addr, logRequests):
 145.100 -        if self.allow_reuse_address:
 145.101 -            try:
 145.102 +        parent = os.path.dirname(addr)
 145.103 +        if os.path.exists(parent):
 145.104 +            os.chown(parent, os.geteuid(), os.getegid())
 145.105 +            os.chmod(parent, stat.S_IRWXU)
 145.106 +            if self.allow_reuse_address and os.path.exists(addr):
 145.107                  os.unlink(addr)
 145.108 -            except OSError, exc:
 145.109 -                pass
 145.110 +        else:
 145.111 +            os.makedirs(parent, stat.S_IRWXU)
 145.112          TCPXMLRPCServer.__init__(self, addr, UnixXMLRPCRequestHandler,
 145.113                                   logRequests)
   146.1 --- a/tools/python/xen/xend/XendClient.py	Tue Apr 11 13:55:47 2006 -0600
   146.2 +++ b/tools/python/xen/xend/XendClient.py	Tue Apr 11 18:54:18 2006 -0600
   146.3 @@ -19,10 +19,10 @@
   146.4  
   146.5  from xen.util.xmlrpclib2 import ServerProxy
   146.6  
   146.7 -XML_RPC_SOCKET = "/var/run/xend-xmlrpc.sock"
   146.8 +XML_RPC_SOCKET = "/var/run/xend/xmlrpc.sock"
   146.9  
  146.10  ERROR_INTERNAL = 1
  146.11  ERROR_GENERIC = 2
  146.12  ERROR_INVALID_DOMAIN = 3
  146.13  
  146.14 -server = ServerProxy('httpu:///var/run/xend-xmlrpc.sock')
  146.15 +server = ServerProxy('httpu:///var/run/xend/xmlrpc.sock')
   147.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Apr 11 13:55:47 2006 -0600
   147.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Apr 11 18:54:18 2006 -0600
   147.3 @@ -34,7 +34,7 @@ import XendDomainInfo
   147.4  
   147.5  from xen.xend import XendRoot
   147.6  from xen.xend import XendCheckpoint
   147.7 -from xen.xend.XendError import XendError
   147.8 +from xen.xend.XendError import XendError, XendInvalidDomain
   147.9  from xen.xend.XendLogging import log
  147.10  from xen.xend.xenstore.xstransact import xstransact
  147.11  from xen.xend.xenstore.xswatch import xswatch
  147.12 @@ -357,6 +357,8 @@ class XendDomain:
  147.13          """Unpause domain execution."""
  147.14          try:
  147.15              dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.16 +            if not dominfo:
  147.17 +                raise XendInvalidDomain(str(domid))
  147.18              log.info("Domain %s (%d) unpaused.", dominfo.getName(),
  147.19                       dominfo.getDomid())
  147.20              return dominfo.unpause()
  147.21 @@ -368,6 +370,8 @@ class XendDomain:
  147.22          """Pause domain execution."""
  147.23          try:
  147.24              dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.25 +            if not dominfo:
  147.26 +                raise XendInvalidDomain(str(domid))
  147.27              log.info("Domain %s (%d) paused.", dominfo.getName(),
  147.28                       dominfo.getDomid())
  147.29              return dominfo.pause()
  147.30 @@ -395,6 +399,8 @@ class XendDomain:
  147.31          """Start domain migration."""
  147.32  
  147.33          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.34 +        if not dominfo:
  147.35 +            raise XendInvalidDomain(str(domid))
  147.36  
  147.37          if dominfo.getDomid() == PRIV_DOMAIN:
  147.38              raise XendError("Cannot migrate privileged domain %i" % domid)
  147.39 @@ -420,6 +426,8 @@ class XendDomain:
  147.40  
  147.41          try:
  147.42              dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.43 +            if not dominfo:
  147.44 +                raise XendInvalidDomain(str(domid))
  147.45  
  147.46              if dominfo.getDomid() == PRIV_DOMAIN:
  147.47                  raise XendError("Cannot save privileged domain %i" % domid)
  147.48 @@ -440,9 +448,9 @@ class XendDomain:
  147.49          @param cpumap:  string repr of list of usable cpus
  147.50          """
  147.51          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.52 -        # convert cpumap string into a list of ints
  147.53 -        cpumap = map(lambda x: int(x),
  147.54 -                     cpumap.replace("[", "").replace("]", "").split(","))
  147.55 +        if not dominfo:
  147.56 +            raise XendInvalidDomain(str(domid))
  147.57 +
  147.58          try:
  147.59              return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
  147.60          except Exception, ex:
  147.61 @@ -453,6 +461,8 @@ class XendDomain:
  147.62          """Set BVT (Borrowed Virtual Time) scheduler parameters for a domain.
  147.63          """
  147.64          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.65 +        if not dominfo:
  147.66 +            raise XendInvalidDomain(str(domid))
  147.67          try:
  147.68              return xc.bvtsched_domain_set(dom=dominfo.getDomid(),
  147.69                                            mcuadv=mcuadv,
  147.70 @@ -466,6 +476,8 @@ class XendDomain:
  147.71          """Get BVT (Borrowed Virtual Time) scheduler parameters for a domain.
  147.72          """
  147.73          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.74 +        if not dominfo:
  147.75 +            raise XendInvalidDomain(str(domid))
  147.76          try:
  147.77              return xc.bvtsched_domain_get(dominfo.getDomid())
  147.78          except Exception, ex:
  147.79 @@ -477,6 +489,8 @@ class XendDomain:
  147.80          """Set Simple EDF scheduler parameters for a domain.
  147.81          """
  147.82          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.83 +        if not dominfo:
  147.84 +            raise XendInvalidDomain(str(domid))
  147.85          try:
  147.86              return xc.sedf_domain_set(dominfo.getDomid(), period, slice_,
  147.87                                        latency, extratime, weight)
  147.88 @@ -487,8 +501,9 @@ class XendDomain:
  147.89          """Get Simple EDF scheduler parameters for a domain.
  147.90          """
  147.91          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
  147.92 +        if not dominfo:
  147.93 +            raise XendInvalidDomain(str(domid))
  147.94          try:
  147.95 -            
  147.96              sedf_info = xc.sedf_domain_get(dominfo.getDomid())
  147.97              # return sxpr
  147.98              return ['sedf',
  147.99 @@ -509,6 +524,8 @@ class XendDomain:
 147.100          @return: 0 on success, -1 on error
 147.101          """
 147.102          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
 147.103 +        if not dominfo:
 147.104 +            raise XendInvalidDomain(str(domid))
 147.105          maxmem = int(mem) * 1024
 147.106          try:
 147.107              return xc.domain_setmaxmem(dominfo.getDomid(), maxmem)
 147.108 @@ -523,6 +540,8 @@ class XendDomain:
 147.109          @return: 0 on success, -1 on error
 147.110          """
 147.111          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
 147.112 +        if not dominfo:
 147.113 +            raise XendInvalidDomain(str(domid))
 147.114          nr_ports = last - first + 1
 147.115          try:
 147.116              return xc.domain_ioport_permission(dominfo.getDomid(),
 147.117 @@ -540,6 +559,8 @@ class XendDomain:
 147.118          @return: 0 on success, -1 on error
 147.119          """
 147.120          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
 147.121 +        if not dominfo:
 147.122 +            raise XendInvalidDomain(str(domid))
 147.123          nr_ports = last - first + 1
 147.124          try:
 147.125              return xc.domain_ioport_permission(dominfo.getDomid(),
   148.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 11 13:55:47 2006 -0600
   148.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 11 18:54:18 2006 -0600
   148.3 @@ -333,7 +333,7 @@ def parseConfig(config):
   148.4                  else:
   148.5                      # remove this element from the list 
   148.6                      if c[0] == '^':
   148.7 -                        cpus = [x for x in cpus if x != int(c[1])]
   148.8 +                        cpus = [x for x in cpus if x != int(c[1:])]
   148.9                      else:
  148.10                          cpus.append(int(c))
  148.11  
   149.1 --- a/tools/python/xen/xend/balloon.py	Tue Apr 11 13:55:47 2006 -0600
   149.2 +++ b/tools/python/xen/xend/balloon.py	Tue Apr 11 18:54:18 2006 -0600
   149.3 @@ -152,7 +152,7 @@ def free(required):
   149.4                             'I cannot release any more.  I need %d MiB but '
   149.5                             'only have %d.') %
   149.6                            (need_mem, free_mem))
   149.7 -        elif new_alloc >= dom0_min_mem:
   149.8 +        elif new_alloc < dom0_min_mem:
   149.9              raise VmError(
  149.10                  ('I need %d MiB, but dom0_min_mem is %d and shrinking to '
  149.11                   '%d MiB would leave only %d MiB free.') %
   150.1 --- a/tools/python/xen/xend/server/DevController.py	Tue Apr 11 13:55:47 2006 -0600
   150.2 +++ b/tools/python/xen/xend/server/DevController.py	Tue Apr 11 18:54:18 2006 -0600
   150.3 @@ -85,6 +85,13 @@ class DevController:
   150.4                                                       front)
   150.5  
   150.6          import xen.xend.XendDomain
   150.7 +        xd = xen.xend.XendDomain.instance()
   150.8 +        backdom_name = sxp.child_value(config, 'backend')
   150.9 +        if backdom_name is None:
  150.10 +            backdom = xen.xend.XendDomain.PRIV_DOMAIN
  150.11 +        else:
  150.12 +            bd = xd.domain_lookup_by_name_or_id_nr(backdom_name)
  150.13 +            backdom = bd.getDomid()
  150.14          count = 0
  150.15          while True:
  150.16              t = xstransact()
  150.17 @@ -112,9 +119,13 @@ class DevController:
  150.18  
  150.19                  t.mkdir(backpath)
  150.20                  t.set_permissions(backpath,
  150.21 -                                  {'dom': xen.xend.XendDomain.PRIV_DOMAIN },
  150.22 +                                  {'dom': backdom },
  150.23                                    {'dom'  : self.vm.getDomid(),
  150.24                                     'read' : True })
  150.25 +                t.mkdir(frontpath)
  150.26 +                t.set_permissions(frontpath,
  150.27 +                                  {'dom': self.vm.getDomid()},
  150.28 +                                  {'dom': backdom, 'read': True})
  150.29  
  150.30                  t.write2(frontpath, front)
  150.31                  t.write2(backpath,  back)
   151.1 --- a/tools/python/xen/xend/server/XMLRPCServer.py	Tue Apr 11 13:55:47 2006 -0600
   151.2 +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Tue Apr 11 18:54:18 2006 -0600
   151.3 @@ -24,6 +24,7 @@ from xen.util.xmlrpclib2 import UnixXMLR
   151.4  
   151.5  from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
   151.6  from xen.xend.XendError import *
   151.7 +from types import ListType
   151.8  
   151.9  def lookup(domid):
  151.10      info = XendDomain.instance().domain_lookup_by_name_or_id(domid)
  151.11 @@ -35,24 +36,36 @@ def dispatch(domid, fn, args):
  151.12      info = lookup(domid)
  151.13      return getattr(info, fn)(*args)
  151.14  
  151.15 +# vcpu_avail is a long and is not needed by the clients.  It's far easier
  151.16 +# to just remove it then to try and marshal the long.
  151.17 +def fixup_sxpr(sexpr):
  151.18 +    ret = []
  151.19 +    for k in sexpr:
  151.20 +        if type(k) is ListType:
  151.21 +            if len(k) != 2 or k[0] != 'vcpu_avail':
  151.22 +                ret.append(fixup_sxpr(k))
  151.23 +        else:
  151.24 +            ret.append(k)
  151.25 +    return ret
  151.26 +
  151.27  def domain(domid):
  151.28      info = lookup(domid)
  151.29 -    return info.sxpr()
  151.30 +    return fixup_sxpr(info.sxpr())
  151.31  
  151.32  def domains(detail=1):
  151.33      if detail < 1:
  151.34          return XendDomain.instance().list_names()
  151.35      else:
  151.36          domains = XendDomain.instance().list_sorted()
  151.37 -        return map(lambda dom: dom.sxpr(), domains)
  151.38 +        return map(lambda dom: fixup_sxpr(dom.sxpr()), domains)
  151.39  
  151.40  def domain_create(config):
  151.41      info = XendDomain.instance().domain_create(config)
  151.42 -    return info.sxpr()
  151.43 +    return fixup_sxpr(info.sxpr())
  151.44  
  151.45  def domain_restore(src):
  151.46      info = XendDomain.instance().domain_restore(src)
  151.47 -    return info.sxpr()    
  151.48 +    return fixup_sxpr(info.sxpr())
  151.49  
  151.50  def get_log():
  151.51      f = open(XendLogging.getLogFilename(), 'r')
   152.1 --- a/tools/python/xen/xend/server/netif.py	Tue Apr 11 13:55:47 2006 -0600
   152.2 +++ b/tools/python/xen/xend/server/netif.py	Tue Apr 11 18:54:18 2006 -0600
   152.3 @@ -22,6 +22,7 @@
   152.4  
   152.5  import os
   152.6  import random
   152.7 +import re
   152.8  
   152.9  from xen.xend import sxp
  152.10  from xen.xend import XendRoot
  152.11 @@ -50,6 +51,86 @@ def randomMAC():
  152.12              random.randint(0x00, 0xff) ]
  152.13      return ':'.join(map(lambda x: "%02x" % x, mac))
  152.14  
  152.15 +rate_re = re.compile("^([0-9]+)([GMK]?)([Bb])/s(@([0-9]+)([mu]?)s)?$")
  152.16 +
  152.17 +def parseRate(ratestr):
  152.18 +    """if parsing fails this will return default of unlimited rate"""
  152.19 +    bytes_per_interval = 0xffffffffL # 0xffffffff # big default
  152.20 +    interval_usecs     = 0L          # disabled
  152.21 +
  152.22 +    m = rate_re.match(ratestr)
  152.23 +    if m:
  152.24 +        bytes_per_sec = long(m.group(1))
  152.25 +
  152.26 +        if m.group(2) == 'G':
  152.27 +            bytes_per_sec *= 1000 * 1000 * 1000
  152.28 +        elif m.group(2) == 'M':
  152.29 +            bytes_per_sec *= 1000 * 1000
  152.30 +        elif m.group(2) == 'K':
  152.31 +            bytes_per_sec *= 1000
  152.32 +
  152.33 +        if m.group(3) == 'b':
  152.34 +            bytes_per_sec /= 8
  152.35 +
  152.36 +        if m.group(5) is None:
  152.37 +            interval_usecs = 50000L      # 50ms default
  152.38 +        else:
  152.39 +            interval_usecs = long(m.group(5))
  152.40 +            if m.group(6) == '':
  152.41 +                interval_usecs *= 1000 * 1000
  152.42 +            elif m.group(6) == 'm':
  152.43 +                interval_usecs *= 1000
  152.44 +
  152.45 +        bytes_per_interval = (bytes_per_sec * interval_usecs) / 1000000L
  152.46 +
  152.47 +        # overflow / underflow checking: default to unlimited rate
  152.48 +        if bytes_per_interval == 0 or bytes_per_interval > 0xffffffffL or \
  152.49 +           interval_usecs == 0 or interval_usecs > 0xffffffffL:
  152.50 +            bytes_per_interval = 0xffffffffL
  152.51 +            interval_usecs     = 0L
  152.52 +
  152.53 +    return "%lu,%lu" % (bytes_per_interval, interval_usecs)
  152.54 +
  152.55 +
  152.56 +write_rate_G_re = re.compile('^([0-9]+)000000000(B/s@[0-9]+us)$')
  152.57 +write_rate_M_re = re.compile('^([0-9]+)000000(B/s@[0-9]+us)$')
  152.58 +write_rate_K_re = re.compile('^([0-9]+)000(B/s@[0-9]+us)$')
  152.59 +write_rate_s_re = re.compile('^([0-9]+[GMK]?B/s@[0-9]+)000000us$')
  152.60 +write_rate_m_re = re.compile('^([0-9]+[GMK]?B/s@[0-9]+)000us$')
  152.61 +
  152.62 +def formatRate(rate):
  152.63 +    (bytes_per_interval, interval_usecs) = map(long, rate.split(','))
  152.64 +
  152.65 +    if interval_usecs != 0:
  152.66 +        bytes_per_second = (bytes_per_interval * 1000 * 1000) / interval_usecs
  152.67 +    else:
  152.68 +        bytes_per_second = 0xffffffffL
  152.69 +
  152.70 +    ratestr = "%uB/s@%uus" % (bytes_per_second, interval_usecs)
  152.71 +
  152.72 +    # look for '000's
  152.73 +    m = write_rate_G_re.match(ratestr)
  152.74 +    if m:
  152.75 +        ratestr = m.group(1) + "G" + m.group(2)
  152.76 +    else:
  152.77 +        m = write_rate_M_re.match(ratestr)
  152.78 +        if m:
  152.79 +            ratestr = m.group(1) + "M" + m.group(2)
  152.80 +        else:
  152.81 +            m = write_rate_K_re.match(ratestr)
  152.82 +            if m:
  152.83 +                ratestr = m.group(1) + "K" + m.group(2)
  152.84 +
  152.85 +    m = write_rate_s_re.match(ratestr)
  152.86 +    if m:
  152.87 +        ratestr = m.group(1) + "s"
  152.88 +    else:
  152.89 +        m = write_rate_m_re.match(ratestr)
  152.90 +        if m:
  152.91 +            ratestr = m.group(1) + "ms"
  152.92 +
  152.93 +    return ratestr
  152.94 +
  152.95  
  152.96  class NetifController(DevController):
  152.97      """Network interface controller. Handles all network devices for a domain.
  152.98 @@ -75,6 +156,7 @@ class NetifController(DevController):
  152.99          bridge  = sxp.child_value(config, 'bridge')
 152.100          mac     = sxp.child_value(config, 'mac')
 152.101          vifname = sxp.child_value(config, 'vifname')
 152.102 +        rate    = sxp.child_value(config, 'rate')
 152.103          ipaddr  = _get_config_ipaddr(config)
 152.104  
 152.105          devid = self.allocateDeviceID()
 152.106 @@ -98,6 +180,8 @@ class NetifController(DevController):
 152.107              back['bridge'] = bridge
 152.108          if vifname:
 152.109              back['vifname'] = vifname
 152.110 +        if rate:
 152.111 +            back['rate'] = parseRate(rate)
 152.112  
 152.113          return (devid, back, front)
 152.114  
 152.115 @@ -107,8 +191,8 @@ class NetifController(DevController):
 152.116  
 152.117          result = DevController.configuration(self, devid)
 152.118  
 152.119 -        (script, ip, bridge, mac, typ, vifname) = self.readBackend(
 152.120 -            devid, 'script', 'ip', 'bridge', 'mac', 'type', 'vifname')
 152.121 +        (script, ip, bridge, mac, typ, vifname, rate) = self.readBackend(
 152.122 +            devid, 'script', 'ip', 'bridge', 'mac', 'type', 'vifname', 'rate')
 152.123  
 152.124          if script:
 152.125              result.append(['script',
 152.126 @@ -125,5 +209,7 @@ class NetifController(DevController):
 152.127              result.append(['type', typ])
 152.128          if vifname:
 152.129              result.append(['vifname', vifname])
 152.130 +        if rate:
 152.131 +            result.append(['rate', formatRate(rate)])
 152.132  
 152.133          return result
   153.1 --- a/tools/python/xen/xend/server/pciif.py	Tue Apr 11 13:55:47 2006 -0600
   153.2 +++ b/tools/python/xen/xend/server/pciif.py	Tue Apr 11 18:54:18 2006 -0600
   153.3 @@ -115,7 +115,7 @@ class PciController(DevController):
   153.4              dev = PciDevice(domain, bus, slot, func)
   153.5          except Exception, e:
   153.6              raise VmError("pci: failed to locate device and "+
   153.7 -                    "parse it's resources - %s"+str(e))
   153.8 +                    "parse it's resources - "+str(e))
   153.9  
  153.10          if dev.driver!='pciback':
  153.11              raise VmError(("pci: PCI Backend does not own device "+ \
  153.12 @@ -131,7 +131,7 @@ class PciController(DevController):
  153.13                      nr_ports = size, allow_access = True)
  153.14              if rc<0:
  153.15                  raise VmError(('pci: failed to configure I/O ports on device '+
  153.16 -                            '%s - errno=%d')&(dev.name,rc))
  153.17 +                            '%s - errno=%d')%(dev.name,rc))
  153.18              
  153.19          for (start, size) in dev.iomem:
  153.20              # Convert start/size from bytes to page frame sizes
  153.21 @@ -147,7 +147,7 @@ class PciController(DevController):
  153.22                      allow_access = True)
  153.23              if rc<0:
  153.24                  raise VmError(('pci: failed to configure I/O memory on device '+
  153.25 -                            '%s - errno=%d')&(dev.name,rc))
  153.26 +                            '%s - errno=%d')%(dev.name,rc))
  153.27  
  153.28          if dev.irq>0:
  153.29              log.debug('pci: enabling irq %d'%dev.irq)
  153.30 @@ -155,7 +155,7 @@ class PciController(DevController):
  153.31                      allow_access = True)
  153.32              if rc<0:
  153.33                  raise VmError(('pci: failed to configure irq on device '+
  153.34 -                            '%s - errno=%d')&(dev.name,rc))
  153.35 +                            '%s - errno=%d')%(dev.name,rc))
  153.36  
  153.37      def waitForBackend(self,devid):
  153.38          return (0, "ok - no hotplug")
   154.1 --- a/tools/python/xen/xend/tests/test_uuid.py	Tue Apr 11 13:55:47 2006 -0600
   154.2 +++ b/tools/python/xen/xend/tests/test_uuid.py	Tue Apr 11 18:54:18 2006 -0600
   154.3 @@ -21,9 +21,9 @@ class test_uuid(unittest.TestCase):
   154.4              self.assertEqual(uuid.toString(inp), expected)
   154.5              self.assertEqual(uuid.fromString(expected), inp)
   154.6  
   154.7 -        t([0 for _ in range(0, 16)], "00000000-00000000-00000000-00000000")
   154.8 +        t([0 for _ in range(0, 16)], "00000000-0000-0000-0000-000000000000")
   154.9          t([185, 158, 125, 206, 250, 178, 125, 57, 2, 6, 162, 74, 178, 236,
  154.10 -           196, 5], "b99e7dce-fab27d39-0206a24a-b2ecc405")
  154.11 +           196, 5], "b99e7dce-fab2-7d39-0206-a24ab2ecc405")
  154.12  
  154.13  
  154.14  def test_suite():
   155.1 --- a/tools/python/xen/xm/create.py	Tue Apr 11 13:55:47 2006 -0600
   155.2 +++ b/tools/python/xen/xm/create.py	Tue Apr 11 18:54:18 2006 -0600
   155.3 @@ -27,9 +27,11 @@ import socket
   155.4  import commands
   155.5  import time
   155.6  import re
   155.7 +import xmlrpclib
   155.8  
   155.9  from xen.xend import sxp
  155.10  from xen.xend import PrettyPrint
  155.11 +import xen.xend.XendClient
  155.12  from xen.xend.XendClient import server
  155.13  from xen.xend.XendBootloader import bootloader
  155.14  from xen.util import blkif
  155.15 @@ -550,7 +552,7 @@ def configure_vifs(config_devs, vals):
  155.16  
  155.17          def f(k):
  155.18              if k not in ['backend', 'bridge', 'ip', 'mac', 'script', 'type',
  155.19 -                         'vifname']:
  155.20 +                         'vifname', 'rate']:
  155.21                  err('Invalid vif option: ' + k)
  155.22  
  155.23              config_vif.append([k, d[k]])
  155.24 @@ -814,6 +816,14 @@ def make_domain(opts, config):
  155.25  
  155.26      try:
  155.27          dominfo = server.xend.domain.create(config)
  155.28 +    except xmlrpclib.Fault, ex:
  155.29 +        import signal
  155.30 +        if vncpid:
  155.31 +            os.kill(vncpid, signal.SIGKILL)
  155.32 +        if ex.faultCode == xen.xend.XendClient.ERROR_INVALID_DOMAIN:
  155.33 +            err("the domain '%s' does not exist." % ex.faultString)
  155.34 +        else:
  155.35 +            err("%s" % ex.faultString)
  155.36      except Exception, ex:
  155.37          import signal
  155.38          if vncpid:
  155.39 @@ -824,6 +834,9 @@ def make_domain(opts, config):
  155.40  
  155.41      try:
  155.42          server.xend.domain.waitForDevices(dom)
  155.43 +    except xmlrpclib.Fault, ex:
  155.44 +        server.xend.domain.destroy(dom)
  155.45 +        err("%s" % ex.faultString)
  155.46      except:
  155.47          server.xend.domain.destroy(dom)
  155.48          err("Device creation failed for domain %s" % dom)
  155.49 @@ -837,6 +850,18 @@ def make_domain(opts, config):
  155.50      opts.info("Started domain %s" % (dom))
  155.51      return int(sxp.child_value(dominfo, 'domid'))
  155.52  
  155.53 +
  155.54 +def get_xauthority():
  155.55 +    xauth = os.getenv("XAUTHORITY")
  155.56 +    if not xauth:
  155.57 +        home = os.getenv("HOME")
  155.58 +        if not home:
  155.59 +            import posix, pwd
  155.60 +            home = pwd.getpwuid(posix.getuid())[5]
  155.61 +        xauth = home + "/.Xauthority"
  155.62 +    return xauth
  155.63 +
  155.64 +
  155.65  def parseCommandLine(argv):
  155.66      gopts.reset()
  155.67      args = gopts.parse(argv)
  155.68 @@ -851,7 +876,7 @@ def parseCommandLine(argv):
  155.69          gopts.vals.display = os.getenv("DISPLAY")
  155.70  
  155.71      if not gopts.vals.xauthority:
  155.72 -        gopts.vals.xauthority = os.getenv("XAUTHORITY")
  155.73 +        gopts.vals.xauthority = get_xauthority()
  155.74  
  155.75      # Process remaining args as config variables.
  155.76      for arg in args:
   156.1 --- a/tools/python/xen/xm/main.py	Tue Apr 11 13:55:47 2006 -0600
   156.2 +++ b/tools/python/xen/xm/main.py	Tue Apr 11 18:54:18 2006 -0600
   156.3 @@ -291,18 +291,6 @@ def int_unit(str, dest):
   156.4  def err(msg):
   156.5      print >>sys.stderr, "Error:", msg
   156.6  
   156.7 -def handle_xend_error(cmd, args, ex):
   156.8 -    non_option = filter(lambda x: x[0] != '-', args)
   156.9 -    dom = len(non_option) > 0 and non_option[0] or None
  156.10 -
  156.11 -    error = str(ex)
  156.12 -    if error == "Not found" and dom != None:
  156.13 -        err("Domain '%s' not found when running 'xm %s'" % (dom, cmd))
  156.14 -    else:
  156.15 -        err(error)
  156.16 -
  156.17 -    sys.exit(1)
  156.18 -    
  156.19  
  156.20  #########################################################################
  156.21  #
  156.22 @@ -1106,9 +1094,10 @@ def main(argv=sys.argv):
  156.23              sys.exit(1)
  156.24          except xmlrpclib.Fault, ex:
  156.25              if ex.faultCode == xen.xend.XendClient.ERROR_INVALID_DOMAIN:
  156.26 -                print "Error: the domain '%s' does not exist." % ex.faultString
  156.27 +                print  >>sys.stderr, (
  156.28 +                    "Error: the domain '%s' does not exist." % ex.faultString)
  156.29              else:
  156.30 -                print "Error: %s" % ex.faultString
  156.31 +                print  >>sys.stderr, "Error: %s" % ex.faultString
  156.32              sys.exit(1)
  156.33          except:
  156.34              print "Unexpected error:", sys.exc_info()[0]
   157.1 --- a/tools/python/xen/xm/tests/test_create.py	Tue Apr 11 13:55:47 2006 -0600
   157.2 +++ b/tools/python/xen/xm/tests/test_create.py	Tue Apr 11 18:54:18 2006 -0600
   157.3 @@ -51,6 +51,7 @@ class test_create(unittest.TestCase):
   157.4                   'path'      : '.:/etc/xen',
   157.5                   'builder'   : 'linux',
   157.6                   'nics'      : -1,
   157.7 +                 'xauthority': xen.xm.create.get_xauthority(),
   157.8                   })
   157.9  
  157.10  
  157.11 @@ -99,6 +100,8 @@ on_crash    = 'destroy'
  157.12                   'interface'   : 'eth0',
  157.13                   'path'        : '.:/etc/xen',
  157.14                   'builder'     : 'linux',
  157.15 +
  157.16 +                 'xauthority'  : xen.xm.create.get_xauthority(),
  157.17                 })
  157.18  
  157.19  
  157.20 @@ -138,6 +141,8 @@ cpu_weight = 0.75
  157.21                   'path'       : '.:/etc/xen',
  157.22                   'builder'    : 'linux',
  157.23                   'nics'       : -1,
  157.24 +
  157.25 +                 'xauthority' : xen.xm.create.get_xauthority(),
  157.26                   })
  157.27              
  157.28  
  157.29 @@ -188,6 +193,8 @@ ne2000=0
  157.30                   'dhcp'        : 'off',
  157.31                   'interface'   : 'eth0',
  157.32                   'path'        : '.:/etc/xen',
  157.33 +
  157.34 +                 'xauthority'  : xen.xm.create.get_xauthority(),
  157.35                 })
  157.36  
  157.37  
   158.1 --- a/tools/security/Makefile	Tue Apr 11 13:55:47 2006 -0600
   158.2 +++ b/tools/security/Makefile	Tue Apr 11 18:54:18 2006 -0600
   158.3 @@ -54,8 +54,10 @@ ACM_POLICY_SUFFIX = security_policy.xml
   158.4  ACM_LABEL_SUFFIX  = security_label_template.xml
   158.5  
   158.6  ifeq ($(ACM_SECURITY),y)
   158.7 +.PHONY: all
   158.8  all: build
   158.9  
  158.10 +.PHONY: install
  158.11  install: all $(ACM_CONFIG_FILE)
  158.12  	$(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
  158.13  	$(INSTALL_PROG) -p $(ACM_INST_TOOLS) $(DESTDIR)/usr/sbin
  158.14 @@ -79,11 +81,14 @@ else
  158.15  	python python/setup.py install --root="$(DESTDIR)"
  158.16  endif
  158.17  else
  158.18 +.PHONY: all
  158.19  all:
  158.20  
  158.21 +.PHONY: install
  158.22  install:
  158.23  endif
  158.24  
  158.25 +.PHONY: build
  158.26  build: mk-symlinks $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
  158.27  	python python/setup.py build
  158.28  	chmod 700 $(ACM_SCRIPTS)
  158.29 @@ -100,6 +105,7 @@ get_decision: $(OBJS_GETD)
  158.30  xensec_gen: xensec_gen.py
  158.31  	cp -f $^ $@
  158.32  
  158.33 +.PHONY: clean
  158.34  clean:
  158.35  	$(RM) $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
  158.36  	$(RM) $(ACM_OBJS)
  158.37 @@ -107,8 +113,10 @@ clean:
  158.38  	$(RM) -r xen
  158.39  	$(RM) -r build
  158.40  
  158.41 +.PHONY: mrproper
  158.42  mrproper: clean
  158.43  
  158.44 +.PHONY: boot_install
  158.45  boot_install: install
  158.46  	$(ACM_SCRIPT_DIR)/updategrub.sh $(POLICY) $(KERNEL_VERSION)
  158.47  
   159.1 --- a/tools/sv/Makefile	Tue Apr 11 13:55:47 2006 -0600
   159.2 +++ b/tools/sv/Makefile	Tue Apr 11 18:54:18 2006 -0600
   159.3 @@ -1,2 +1,3 @@
   159.4  
   159.5 +.PHONY: all
   159.6  all:
   160.1 --- a/tools/tests/Makefile	Tue Apr 11 13:55:47 2006 -0600
   160.2 +++ b/tools/tests/Makefile	Tue Apr 11 18:54:18 2006 -0600
   160.3 @@ -6,14 +6,17 @@ TARGET := test_x86_emulator
   160.4  
   160.5  HOSTCFLAGS += -D__TEST_HARNESS__
   160.6  
   160.7 +.PHONY: all
   160.8  all: $(TARGET)
   160.9  
  160.10  $(TARGET): x86_emulate.o test_x86_emulator.o
  160.11  	$(HOSTCC) -o $@ $^
  160.12  
  160.13 +.PHONY: clean
  160.14  clean:
  160.15  	rm -rf $(TARGET) *.o *~ core
  160.16  
  160.17 +.PHONY: install
  160.18  install:
  160.19  
  160.20  x86_emulate.o: $(XEN_ROOT)/xen/arch/x86/x86_emulate.c
   161.1 --- a/tools/vnet/Makefile	Tue Apr 11 13:55:47 2006 -0600
   161.2 +++ b/tools/vnet/Makefile	Tue Apr 11 18:54:18 2006 -0600
   161.3 @@ -5,10 +5,6 @@ export VNET_ROOT = $(shell pwd)
   161.4  include $(VNET_ROOT)/Make.env
   161.5  endif
   161.6  
   161.7 -.PHONY: all compile install dist clean pristine
   161.8 -.PHONY: gc-all gc-install gc-clean
   161.9 -.PHONY: help
  161.10 -
  161.11  SUBDIRS:=
  161.12  SUBDIRS+= examples
  161.13  SUBDIRS+= scripts
  161.14 @@ -17,11 +13,13 @@ SUBDIRS+= libxutil
  161.15  SUBDIRS+= vnetd
  161.16  SUBDIRS+= vnet-module
  161.17  
  161.18 +.PHONY: all
  161.19  all: compile
  161.20  
  161.21  gc.tar.gz:
  161.22  	wget http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/$@
  161.23  
  161.24 +.PHONY: gc
  161.25  gc: gc.tar.gz
  161.26  	tar xfz gc.tar.gz
  161.27  	ln -sf gc?.? gc
  161.28 @@ -31,10 +29,13 @@ gc: gc.tar.gz
  161.29  	make -C gc
  161.30  	DESTDIR="" make -C gc install
  161.31  
  161.32 +.PHONY: gc-all
  161.33  gc-all: $(GC_LIB_A)
  161.34  
  161.35 +.PHONY: gc-install
  161.36  gc-install:
  161.37  
  161.38 +.PHONY: gc-clean
  161.39  gc-clean:
  161.40  	-@$(RM) -r gc?.? gc
  161.41  
  161.42 @@ -50,19 +51,25 @@ subtgt = $(patsubst %,%-$(1),$(SUBDIRS))
  161.43  %-install:
  161.44  	$(call submak,install)
  161.45  
  161.46 +.PHONY: compile
  161.47  compile: $(call subtgt,all)
  161.48  
  161.49 +.PHONY: install
  161.50  install: DESTDIR=
  161.51  install: dist
  161.52  
  161.53 +.PHONY: dist
  161.54  dist: compile $(call subtgt,install)
  161.55  
  161.56 +.PHONY: clean
  161.57  clean: $(call subtgt,clean)
  161.58  	-@$(RM) -r build
  161.59  
  161.60 +.PHONY: pristine
  161.61  pristine: clean
  161.62  	-@$(RM) gc.tar.gz
  161.63  
  161.64 +.PHONY: help
  161.65  help:
  161.66  	@echo 'Cleaning targets:'
  161.67  	@echo '  clean     - clean subdirs and remove the build dir'
   162.1 --- a/tools/vnet/doc/Makefile	Tue Apr 11 13:55:47 2006 -0600
   162.2 +++ b/tools/vnet/doc/Makefile	Tue Apr 11 18:54:18 2006 -0600
   162.3 @@ -23,8 +23,10 @@ DOC_MAN5	:= $(patsubst man/%.pod.5,man5/
   162.4  
   162.5  .PHONY: all man clean install
   162.6  
   162.7 +.PHONY: all
   162.8  all: man
   162.9  
  162.10 +.PHONY: man
  162.11  man:
  162.12  	@if which $(POD2MAN) 1>/dev/null 2>/dev/null; then \
  162.13  	$(MAKE) $(DOC_MAN1) $(DOC_MAN5); fi
  162.14 @@ -39,10 +41,12 @@ man5/%.5: man/%.pod.5 Makefile
  162.15  	$(POD2MAN) --release=$(VERSION) --name=`echo $@ | sed 's/^man5.//'| \
  162.16  		sed 's/.5//'` -s 5 -c $(HEADER) $< $@
  162.17  
  162.18 +.PHONY: clean
  162.19  clean:
  162.20  	@$(RM) -rf man5
  162.21  	@$(RM) -rf man1
  162.22  
  162.23 +.PHONY:  install
  162.24   install: all
  162.25  	$(INSTALL_DIR) $(DESTDIR)$(MAN_DIR)
  162.26  	$(CP) -dR man1 $(DESTDIR)$(MAN_DIR)
   163.1 --- a/tools/vnet/examples/Makefile	Tue Apr 11 13:55:47 2006 -0600
   163.2 +++ b/tools/vnet/examples/Makefile	Tue Apr 11 18:54:18 2006 -0600
   163.3 @@ -7,13 +7,14 @@ INSTALL_DIR	= $(INSTALL) -d -m0755
   163.4  
   163.5  XEN_SCRIPT_DIR  = $(DESTDIR)/etc/xen/scripts
   163.6  
   163.7 -.PHONY: all install clean
   163.8 -
   163.9 +.PHONY: all
  163.10  all:
  163.11  
  163.12 +.PHONY: install
  163.13  install:
  163.14  	$(INSTALL_DIR) $(XEN_SCRIPT_DIR)
  163.15  	$(INSTALL_PROG) network-vnet $(XEN_SCRIPT_DIR)
  163.16  	$(INSTALL_PROG) vnet-insert $(XEN_SCRIPT_DIR)
  163.17  
  163.18 -clean:
  163.19 \ No newline at end of file
  163.20 +.PHONY: clean
  163.21 +clean:
   164.1 --- a/tools/vnet/libxutil/Makefile	Tue Apr 11 13:55:47 2006 -0600
   164.2 +++ b/tools/vnet/libxutil/Makefile	Tue Apr 11 18:54:18 2006 -0600
   164.3 @@ -42,8 +42,10 @@ LIB      += libxutil.so.$(MAJOR)
   164.4  LIB      += libxutil.so.$(MAJOR).$(MINOR)
   164.5  LIB      += libxutil.a
   164.6  
   164.7 +.PHONY: all
   164.8  all: build
   164.9  
  164.10 +.PHONY: build
  164.11  build: #check-for-zlib
  164.12  	$(MAKE) $(LIB)
  164.13  
  164.14 @@ -61,6 +63,7 @@ libxutil.so.$(MAJOR).$(MINOR): $(PIC_OBJ
  164.15  libxutil.a: $(LIB_OBJS)
  164.16  	$(AR) rc $@ $^
  164.17  
  164.18 +.PHONY: check-for-zlib
  164.19  check-for-zlib:
  164.20  	@if [ ! -e /usr/include/zlib.h ]; then \
  164.21  	echo "***********************************************************"; \
  164.22 @@ -69,6 +72,7 @@ check-for-zlib:
  164.23  	false; \
  164.24  	fi
  164.25  
  164.26 +.PHONY: install
  164.27  install: build
  164.28  	[ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
  164.29  	$(INSTALL_PROG) libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
  164.30 @@ -76,6 +80,7 @@ install: build
  164.31  	ln -sf libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxutil.so.$(MAJOR)
  164.32  	ln -sf libxutil.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxutil.so
  164.33  
  164.34 +.PHONY: clean
  164.35  clean:
  164.36  	-@$(RM) *.a *.so* *.o *.opic *.rpm 
  164.37  	-@$(RM) *~
   165.1 --- a/tools/vnet/scripts/Makefile	Tue Apr 11 13:55:47 2006 -0600
   165.2 +++ b/tools/vnet/scripts/Makefile	Tue Apr 11 18:54:18 2006 -0600
   165.3 @@ -7,12 +7,13 @@ INSTALL_DIR	= $(INSTALL) -d -m0755
   165.4  
   165.5  SBIN_DIR        = $(DESTDIR)/usr/sbin
   165.6  
   165.7 -.PHONY: all install clean
   165.8 -
   165.9 +.PHONY: all
  165.10  all:
  165.11  
  165.12 +.PHONY: install
  165.13  install:
  165.14  	$(INSTALL_DIR) $(SBIN_DIR)
  165.15  	$(INSTALL_PROG) vn $(SBIN_DIR)
  165.16  
  165.17 -clean:
  165.18 \ No newline at end of file
  165.19 +.PHONY: clean
  165.20 +clean:
   166.1 --- a/tools/vnet/vnetd/Makefile	Tue Apr 11 13:55:47 2006 -0600
   166.2 +++ b/tools/vnet/vnetd/Makefile	Tue Apr 11 18:54:18 2006 -0600
   166.3 @@ -19,6 +19,7 @@
   166.4  VNET_ROOT = $(shell cd .. && pwd)
   166.5  include $(VNET_ROOT)/Make.env
   166.6  
   166.7 +.PHONY: all
   166.8  all: vnetd
   166.9  
  166.10  #----------------------------------------------------------------------------
  166.11 @@ -104,10 +105,12 @@ VNETD_LIBS:= $(GC_LIB_A)
  166.12  vnetd: $(VNETD_OBJ)
  166.13  	$(CC) $(CFLAGS) -o $@ $^ $(VNETD_LIBS) -ldl -lpthread
  166.14  
  166.15 +.PHONY: install
  166.16  install: vnetd
  166.17  	mkdir -p $(DESTDIR)$(VNETD_INSTALL_DIR)
  166.18  	install -m 0755 vnetd $(DESTDIR)$(VNETD_INSTALL_DIR)
  166.19  
  166.20 +.PHONY: clean
  166.21  clean:
  166.22  	-@$(RM) *.a *.o *~
  166.23  	-@$(RM) vnetd
   167.1 --- a/tools/vtpm/Makefile	Tue Apr 11 13:55:47 2006 -0600
   167.2 +++ b/tools/vtpm/Makefile	Tue Apr 11 18:54:18 2006 -0600
   167.3 @@ -13,14 +13,18 @@ TPM_EMULATOR_TARFILE = tpm_emulator-0.2b
   167.4  
   167.5  GMP_HEADER = /usr/include/gmp.h
   167.6  
   167.7 +.PHONY: all
   167.8  all: build
   167.9  
  167.10 +.PHONY: build
  167.11  build: $(TPM_EMULATOR_DIR) $(VTPM_DIR) build_sub
  167.12  
  167.13 +.PHONY: install
  167.14  install: build
  167.15  	$(MAKE) -C $(TPM_EMULATOR_DIR) $@
  167.16  	$(MAKE) -C $(VTPM_DIR) $@
  167.17  
  167.18 +.PHONY: clean
  167.19  clean:
  167.20  	@if [ -d $(TPM_EMULATOR_DIR) ]; \
  167.21  		then $(MAKE) -C $(TPM_EMULATOR_DIR) clean; \
  167.22 @@ -29,6 +33,7 @@ clean:
  167.23  		then $(MAKE) -C $(VTPM_DIR) clean; \
  167.24  	fi
  167.25  
  167.26 +.PHONY: mrproper
  167.27  mrproper:
  167.28  	rm -f $(TPM_EMULATOR_TARFILE)
  167.29  	rm -rf $(TPM_EMULATOR_DIR)
  167.30 @@ -58,6 +63,7 @@ mrproper:
  167.31  	patch -p1 < ../tpm_emulator-0.2b-x86_64.patch; \
  167.32  	patch -p1 <../vtpm.patch
  167.33  
  167.34 +.PHONY: build_sub
  167.35  build_sub:
  167.36  	@if [ -e $(GMP_HEADER) ]; then \
  167.37  		$(MAKE) -C $(VTPM_DIR); \
   168.1 --- a/tools/vtpm_manager/Makefile	Tue Apr 11 13:55:47 2006 -0600
   168.2 +++ b/tools/vtpm_manager/Makefile	Tue Apr 11 18:54:18 2006 -0600
   168.3 @@ -6,8 +6,10 @@ include $(XEN_ROOT)/tools/vtpm_manager/R
   168.4  SUBDIRS		= crypto tcs util manager
   168.5  OPENSSL_HEADER	= /usr/include/openssl/crypto.h
   168.6  
   168.7 +.PHONY: all
   168.8  all: build
   168.9  
  168.10 +.PHONY: build
  168.11  build:
  168.12  	@if [ -e $(OPENSSL_HEADER) ]; then \
  168.13  		@set -e; for subdir in $(SUBDIRS); do \
  168.14 @@ -17,17 +19,20 @@ build:
  168.15  		echo "*** Cannot build vtpm_manager: OpenSSL developement files missing."; \
  168.16  	fi
  168.17  
  168.18 +.PHONY: install
  168.19  install: build
  168.20  	@set -e; for subdir in $(SUBDIRS); do \
  168.21  		$(MAKE) -C $$subdir $@; \
  168.22  	done
  168.23  
  168.24 +.PHONY: clean
  168.25  clean:
  168.26  	@set -e; for subdir in $(SUBDIRS); do \
  168.27  		$(MAKE) -C $$subdir $@; \
  168.28  	done
  168.29  
  168.30  
  168.31 +.PHONY: mrproper
  168.32  mrproper:
  168.33  	@set -e; for subdir in $(SUBDIRS); do \
  168.34  		$(MAKE) -C $$subdir $@; \
   169.1 --- a/tools/vtpm_manager/crypto/Makefile	Tue Apr 11 13:55:47 2006 -0600
   169.2 +++ b/tools/vtpm_manager/crypto/Makefile	Tue Apr 11 18:54:18 2006 -0600
   169.3 @@ -3,15 +3,20 @@ include $(XEN_ROOT)/tools/vtpm_manager/R
   169.4  
   169.5  BIN		= libtcpaCrypto.a
   169.6  
   169.7 +.PHONY: all
   169.8  all: build
   169.9  
  169.10 +.PHONY: build
  169.11  build: $(BIN)
  169.12  
  169.13 +.PHONY: install
  169.14  install: build
  169.15  
  169.16 +.PHONY: clean
  169.17  clean:
  169.18  	rm -f *.a *.so *.o *.rpm $(DEP_FILES)
  169.19  
  169.20 +.PHONY: mrproper
  169.21  mrproper: clean
  169.22  	rm -f *~
  169.23  
   170.1 --- a/tools/vtpm_manager/manager/Makefile	Tue Apr 11 13:55:47 2006 -0600
   170.2 +++ b/tools/vtpm_manager/manager/Makefile	Tue Apr 11 18:54:18 2006 -0600
   170.3 @@ -3,19 +3,24 @@ include $(XEN_ROOT)/tools/vtpm_manager/R
   170.4  
   170.5  BIN		= vtpm_managerd
   170.6  
   170.7 +.PHONY: all
   170.8  all: build
   170.9  
  170.10 +.PHONY: build
  170.11  build: $(BIN)
  170.12  
  170.13 +.PHONY: install
  170.14  install: build
  170.15  	if [ ! -d "$(DESTDIR)/var/vtpm/fifos" ]; \
  170.16  		then mkdir -p $(DESTDIR)/var/vtpm/fifos; \
  170.17  	fi
  170.18  	$(INSTALL_PROG) $(BIN) $(TOOLS_INSTALL_DIR)
  170.19  
  170.20 +.PHONY: clean
  170.21  clean:
  170.22  	rm -f *.a *.so *.o *.rpm $(DEP_FILES)
  170.23  
  170.24 +.PHONY: mrproper
  170.25  mrproper: clean
  170.26  	rm -f $(BIN) *~
  170.27  
   171.1 --- a/tools/vtpm_manager/tcs/Makefile	Tue Apr 11 13:55:47 2006 -0600
   171.2 +++ b/tools/vtpm_manager/tcs/Makefile	Tue Apr 11 18:54:18 2006 -0600
   171.3 @@ -3,15 +3,20 @@ include $(XEN_ROOT)/tools/vtpm_manager/R
   171.4  
   171.5  BIN		= libTCS.a
   171.6  
   171.7 +.PHONY: all
   171.8  all: build
   171.9  
  171.10 +.PHONY: build
  171.11  build: $(BIN)
  171.12  
  171.13 +.PHONY: install
  171.14  install: build
  171.15  
  171.16 +.PHONY: clean
  171.17  clean:
  171.18  	rm -f *.a *.so *.o *.rpm $(DEP_FILES)
  171.19  
  171.20 +.PHONY: mrproper
  171.21  mrproper: clean
  171.22  	rm -f *~
  171.23  
   172.1 --- a/tools/vtpm_manager/util/Makefile	Tue Apr 11 13:55:47 2006 -0600
   172.2 +++ b/tools/vtpm_manager/util/Makefile	Tue Apr 11 18:54:18 2006 -0600
   172.3 @@ -3,15 +3,20 @@ include $(XEN_ROOT)/tools/vtpm_manager/R
   172.4  
   172.5  BIN		= libTCGUtils.a
   172.6  
   172.7 +.PHONY: all
   172.8  all: build
   172.9  
  172.10 +.PHONY: build
  172.11  build: $(BIN)
  172.12  
  172.13 +.PHONY: install
  172.14  install: build
  172.15  
  172.16 +.PHONY: clean
  172.17  clean:
  172.18  	rm -f *.a *.so *.o *.rpm $(DEP_FILES)
  172.19  
  172.20 +.PHONY: mrproper
  172.21  mrproper: clean
  172.22  	rm -f *~
  172.23  
   173.1 --- a/tools/xcutils/Makefile	Tue Apr 11 13:55:47 2006 -0600
   173.2 +++ b/tools/xcutils/Makefile	Tue Apr 11 18:54:18 2006 -0600
   173.3 @@ -32,6 +32,8 @@ LDLIBS			= -L$(XEN_LIBXC) -lxenguest -lx
   173.4  
   173.5  .PHONY: all
   173.6  all: build
   173.7 +
   173.8 +.PHONY: build
   173.9  build: $(PROGRAMS)
  173.10  
  173.11  $(PROGRAMS): %: %.o
  173.12 @@ -44,6 +46,7 @@ install: build
  173.13  	$(INSTALL_PROG) $(PROGRAMS) $(DESTDIR)$(PROGRAMS_INSTALL_DIR)
  173.14  
  173.15  
  173.16 +.PHONY: clean
  173.17  clean:
  173.18  	$(RM) *.o $(PROGRAMS)
  173.19  	$(RM) $(PROG_DEP)
   174.1 --- a/tools/xenmon/Makefile	Tue Apr 11 13:55:47 2006 -0600
   174.2 +++ b/tools/xenmon/Makefile	Tue Apr 11 18:54:18 2006 -0600
   174.3 @@ -28,16 +28,20 @@ LDFLAGS += -L $(XEN_LIBXC)
   174.4  BIN = setmask xenbaked
   174.5  SCRIPTS = xenmon.py
   174.6  
   174.7 +.PHONY: all
   174.8  all: build
   174.9  
  174.10 +.PHONY: build
  174.11  build: $(BIN)
  174.12  
  174.13 +.PHONY: install
  174.14  install: xenbaked setmask
  174.15  	[ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir)
  174.16  	$(INSTALL_PROG) xenbaked $(DESTDIR)$(sbindir)/xenbaked
  174.17  	$(INSTALL_PROG) setmask  $(DESTDIR)$(sbindir)/setmask
  174.18  	$(INSTALL_PROG) xenmon.py  $(DESTDIR)$(sbindir)/xenmon.py
  174.19  
  174.20 +.PHONY: clean
  174.21  clean:
  174.22  	rm -f $(BIN)
  174.23  
   175.1 --- a/tools/xenstat/libxenstat/Makefile	Tue Apr 11 13:55:47 2006 -0600
   175.2 +++ b/tools/xenstat/libxenstat/Makefile	Tue Apr 11 18:54:18 2006 -0600
   175.3 @@ -41,6 +41,7 @@ WARN_FLAGS=-Wall -Werror
   175.4  CFLAGS+=-Isrc -I$(XEN_LIBXC) -I$(XEN_XENSTORE)
   175.5  LDFLAGS+=-Lsrc
   175.6  
   175.7 +.PHONY: all
   175.8  all: $(LIB)
   175.9  
  175.10  $(LIB): $(OBJECTS)
  175.11 @@ -62,6 +63,7 @@ src/libxenstat.so.$(MAJOR): $(LIB)
  175.12  src/libxenstat.so: src/libxenstat.so.$(MAJOR)
  175.13  	$(MAKE_LINK) $(<F) $@
  175.14  
  175.15 +.PHONY: install
  175.16  install: all
  175.17  #install: all
  175.18  #	$(INSTALL_DATA) src/xenstat.h $(DESTDIR)$(includedir)/xenstat.h
  175.19 @@ -84,6 +86,7 @@ BINDINGS=$(PYLIB) $(PYMOD) $(PERLLIB) $(
  175.20  BINDINGSRC=$(PYSRC) $(PERLSRC)
  175.21  
  175.22  # The all-bindings target builds all the language bindings
  175.23 +.PHONY: all-bindings
  175.24  all-bindings: perl-bindings python-bindings
  175.25  
  175.26  # The install-bindings target installs all the language bindings
  175.27 @@ -110,6 +113,7 @@ install-python-bindings: $(PYLIB) $(PYMO
  175.28  	$(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py
  175.29  
  175.30  ifeq ($(XENSTAT_PYTHON_BINDINGS),y)
  175.31 +.PHONY: all
  175.32  all: python-bindings
  175.33  install: install-python-bindings
  175.34  endif
  175.35 @@ -122,8 +126,10 @@ PERL_FLAGS=`perl -MConfig -e 'print "$$C
  175.36  $(PERLLIB): $(PERLSRC)
  175.37  	$(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) -shared -lxenstat -o $@ $<
  175.38  
  175.39 +.PHONY: perl-bindings
  175.40  perl-bindings: $(PERLLIB) $(PERLMOD)
  175.41  
  175.42 +.PHONY: install-perl-bindings
  175.43  perllibdir=$(prefix)/lib/perl5
  175.44  perlmoddir=$(prefix)/share/perl5
  175.45  install-perl-bindings: $(PERLLIB) $(PERLMOD)
  175.46 @@ -131,10 +137,14 @@ install-perl-bindings: $(PERLLIB) $(PERL
  175.47  	$(INSTALL_PROG) $(PERLMOD) $(DESTDIR)$(perlmoddir)/xenstat.pm
  175.48  
  175.49  ifeq ($(XENSTAT_PERL_BINDINGS),y)
  175.50 +.PHONY: all
  175.51  all: perl-bindings
  175.52 +
  175.53 +.PHONY: install
  175.54  install: install-perl-bindings
  175.55  endif
  175.56  
  175.57 +.PHONY: clean
  175.58  clean:
  175.59  	rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS) \
  175.60  	      $(BINDINGS) $(BINDINGSRC)
   176.1 --- a/tools/xenstat/xentop/Makefile	Tue Apr 11 13:55:47 2006 -0600
   176.2 +++ b/tools/xenstat/xentop/Makefile	Tue Apr 11 18:54:18 2006 -0600
   176.3 @@ -14,6 +14,7 @@ XEN_ROOT=../../..
   176.4  include $(XEN_ROOT)/tools/Rules.mk
   176.5  
   176.6  ifneq ($(XENSTAT_XENTOP),y)
   176.7 +.PHONY: all install xentop
   176.8  all install xentop:
   176.9  else
  176.10  
  176.11 @@ -30,15 +31,16 @@ CFLAGS += -DGCC_PRINTF -Wall -Werror -I$
  176.12  LDFLAGS += -L$(XEN_LIBXENSTAT)
  176.13  LDLIBS += -lxenstat -lncurses
  176.14  
  176.15 +.PHONY: all
  176.16  all: xentop
  176.17  
  176.18 -xentop: xentop.o
  176.19 -
  176.20 +.PHONY: install
  176.21  install: xentop xentop.1
  176.22  	$(INSTALL_PROG) xentop $(DESTDIR)$(sbindir)/xentop
  176.23  	$(INSTALL_DATA) xentop.1 $(DESTDIR)$(man1dir)/xentop.1
  176.24  
  176.25  endif
  176.26  
  176.27 +.PHONY: clean
  176.28  clean:
  176.29  	rm -f xentop xentop.o
   177.1 --- a/tools/xenstore/Makefile	Tue Apr 11 13:55:47 2006 -0600
   177.2 +++ b/tools/xenstore/Makefile	Tue Apr 11 18:54:18 2006 -0600
   177.3 @@ -27,11 +27,13 @@ CLIENTS := xenstore-exists xenstore-list
   177.4  CLIENTS += xenstore-write
   177.5  CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS))
   177.6  
   177.7 +.PHONY: all
   177.8  all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls
   177.9  
  177.10  test_interleaved_transactions: test_interleaved_transactions.o
  177.11  	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
  177.12  
  177.13 +.PHONY: testcode
  177.14  testcode: xs_test xenstored_test xs_random
  177.15  
  177.16  xenstored: xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o
  177.17 @@ -63,6 +65,7 @@ xs_crashme: xs_crashme.o xs_lib.o talloc
  177.18  
  177.19  speedtest: speedtest.o xs.o xs_lib.o utils.o talloc.o
  177.20  
  177.21 +.PHONY: check-speed
  177.22  check-speed: speedtest xenstored_test $(TESTDIR)
  177.23  	$(TESTENV) time ./speedtest 100
  177.24  
  177.25 @@ -80,6 +83,7 @@ talloc_test.o: talloc.c
  177.26  libxenstore.so: xs.opic xs_lib.opic
  177.27  	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenstore.so -shared -o $@ $^ -lpthread
  177.28  
  177.29 +.PHONY: clean
  177.30  clean: testsuite-clean
  177.31  	rm -f *.o *.opic *.so
  177.32  	rm -f xenstored xs_random xs_stress xs_crashme
  177.33 @@ -87,55 +91,69 @@ clean: testsuite-clean
  177.34  	rm -f $(CLIENTS)
  177.35  	$(RM) $(PROG_DEP)
  177.36  
  177.37 +.PHONY: print-dir
  177.38  print-dir:
  177.39  	@echo -n tools/xenstore: 
  177.40  
  177.41 +.PHONY: print-end
  177.42  print-end:
  177.43  	@echo
  177.44  
  177.45 +.PHONY: check
  177.46  check: print-dir testsuite-fast randomcheck-fast print-end
  177.47  
  177.48 +.PHONY: fullcheck
  177.49  fullcheck: testsuite-run randomcheck stresstest
  177.50  
  177.51  $(TESTDIR):
  177.52  	mkdir $@
  177.53  
  177.54 +.PHONY: testsuite-run
  177.55  testsuite-run: xenstored_test xs_test $(TESTDIR)
  177.56  	$(TESTENV) testsuite/test.sh && echo
  177.57  
  177.58 +.PHONY: testsuite-fast
  177.59  testsuite-fast: xenstored_test xs_test $(TESTDIR)
  177.60  	@$(TESTENV) testsuite/test.sh --fast
  177.61  
  177.62 +.PHONY: testsuite-clean
  177.63  testsuite-clean:
  177.64  	rm -rf $(TESTDIR)
  177.65  
  177.66  # Make this visible so they can see repeat tests without --fast if they
  177.67  # fail.
  177.68  RANDSEED=$(shell date +%s)
  177.69 +.PHONY: randomcheck
  177.70  randomcheck: xs_random xenstored_test $(TESTDIR)
  177.71  	$(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED) && echo
  177.72  	$(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED) && echo
  177.73  #	$(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED)
  177.74  
  177.75 +.PHONY: crashme
  177.76  crashme:  xs_crashme xenstored_test $(TESTDIR)
  177.77  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
  177.78  	export $(TESTENV); ./xs_crashme 5000 $(RANDSEED) 2>/dev/null
  177.79  	if [ -n "`cat /tmp/xs_crashme.vglog*`" ]; then echo Valgrind complained; cat /tmp/xs_crashme.vglog*; exit 1; fi
  177.80  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
  177.81  
  177.82 +.PHONY: randomcheck-fast
  177.83  randomcheck-fast: xs_random xenstored_test $(TESTDIR)
  177.84  	@$(TESTENV) ./xs_random --fast /tmp/xs_random 2000 $(RANDSEED)
  177.85  
  177.86 +.PHONY: stresstest
  177.87  stresstest: xs_stress xenstored_test $(TESTDIR)
  177.88  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
  177.89  	export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret
  177.90  
  177.91 +.PHONY: TAGS
  177.92  TAGS:
  177.93  	etags `find . -name '*.[ch]'`
  177.94  
  177.95 +.PHONY: tarball
  177.96  tarball: clean
  177.97  	cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/
  177.98  
  177.99 +.PHONY: install
 177.100  install: all
 177.101  	$(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored
 177.102  	$(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored
   178.1 --- a/tools/xenstore/xenstored_core.c	Tue Apr 11 13:55:47 2006 -0600
   178.2 +++ b/tools/xenstore/xenstored_core.c	Tue Apr 11 18:54:18 2006 -0600
   178.3 @@ -469,6 +469,7 @@ static bool write_node(struct connection
   178.4  
   178.5  	/* TDB should set errno, but doesn't even set ecode AFAICT. */
   178.6  	if (tdb_store(tdb_context(conn), key, data, TDB_REPLACE) != 0) {
   178.7 +		corrupt(conn, "Write of %s = %s failed", key, data);
   178.8  		errno = ENOSPC;
   178.9  		return false;
  178.10  	}
   179.1 --- a/tools/xentrace/Makefile	Tue Apr 11 13:55:47 2006 -0600
   179.2 +++ b/tools/xentrace/Makefile	Tue Apr 11 18:54:18 2006 -0600
   179.3 @@ -28,9 +28,13 @@ ifeq ($(XEN_TARGET_ARCH),x86_64)
   179.4  LIBBIN  += xenctx
   179.5  endif
   179.6  
   179.7 +.PHONY: all
   179.8  all: build
   179.9 +
  179.10 +.PHONY: build
  179.11  build: $(BIN) $(LIBBIN)
  179.12  
  179.13 +.PHONY: install
  179.14  install: build
  179.15  	[ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
  179.16  	[ -z "$(LIBBIN)" ] || [ -d $(DESTDIR)/usr/$(LIBDIR)/xen/bin ] || \
  179.17 @@ -44,6 +48,7 @@ install: build
  179.18  	$(INSTALL_DATA) $(MAN1) $(DESTDIR)/usr/share/man/man1
  179.19  	$(INSTALL_DATA) $(MAN8) $(DESTDIR)/usr/share/man/man8
  179.20  
  179.21 +.PHONY: clean
  179.22  clean:
  179.23  	$(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN)
  179.24  
   180.1 --- a/tools/xm-test/README	Tue Apr 11 13:55:47 2006 -0600
   180.2 +++ b/tools/xm-test/README	Tue Apr 11 18:54:18 2006 -0600
   180.3 @@ -140,9 +140,11 @@ and test lists as required. Default grou
   180.4     # ./runtest.sh -g <groupname> <logfile>
   180.5  
   180.6  * NOTE: There is a quick set of tests in group mode, that was added to
   180.7 -run certain casenames and tests. It is not a substitute for the full
   180.8 +run certain casenames and tests, and there is a "medium" group, which is a
   180.9 +medium-length run (around 20 minutes).  Neither is a substitute for the full
  180.10  xm-test test suite.
  180.11     # ./runtest.sh -g quick <logfile>
  180.12 +   # ./runtest.sh -g medium <logfile>
  180.13  
  180.14  
  180.15  
   181.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   181.2 +++ b/tools/xm-test/grouptest/medium	Tue Apr 11 18:54:18 2006 -0600
   181.3 @@ -0,0 +1,25 @@
   181.4 +block-create 09_block_attach_and_dettach_device_check_data_pos.test
   181.5 +block-list
   181.6 +console
   181.7 +destroy 01_destroy_basic_pos.test 02_destroy_noparm_neg.test 03_destroy_nonexist_neg.test 04_destroy_badparm_neg.test 05_destroy_byid_pos.test 06_destroy_dom0_neg.test
   181.8 +dmesg
   181.9 +domid
  181.10 +domname
  181.11 +enforce_dom0_cpus
  181.12 +help
  181.13 +info
  181.14 +list
  181.15 +memmax
  181.16 +memset 01_memset_basic_pos.test 02_memset_badparm_neg.test 04_memset_smallmem_pos.test
  181.17 +migrate
  181.18 +network-attach 03_network_attach_detach_multiple_pos.test
  181.19 +reboot
  181.20 +restore 02_restore_badparm_neg.test 03_restore_badfilename_neg.test 04_restore_withdevices_pos.test
  181.21 +save
  181.22 +sedf
  181.23 +shutdown
  181.24 +sysrq 01_sysrq_basic_neg.test 02_sysrq_sync_pos.test
  181.25 +unpause
  181.26 +vcpu-disable
  181.27 +vcpu-pin
  181.28 +vtpm
   182.1 --- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py	Tue Apr 11 13:55:47 2006 -0600
   182.2 +++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py	Tue Apr 11 18:54:18 2006 -0600
   182.3 @@ -46,6 +46,7 @@ except ConsoleError, e:
   182.4      FAIL(str(e))
   182.5  
   182.6  if re.search("No such file",run["output"]):
   182.7 +    vtpm_cleanup(domName)
   182.8      FAIL("TPM frontend support not compiled into (domU?) kernel")
   182.9  
  182.10  console.closeConsole()
   183.1 --- a/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Tue Apr 11 13:55:47 2006 -0600
   183.2 +++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Tue Apr 11 18:54:18 2006 -0600
   183.3 @@ -47,6 +47,7 @@ except ConsoleError, e:
   183.4      FAIL(str(e))
   183.5  
   183.6  if re.search("No such file",run["output"]):
   183.7 +    vtpm_cleanup(domName)
   183.8      FAIL("TPM frontend support not compiled into (domU?) kernel")
   183.9  
  183.10  console.closeConsole()
   184.1 --- a/xen/Makefile	Tue Apr 11 13:55:47 2006 -0600
   184.2 +++ b/xen/Makefile	Tue Apr 11 18:54:18 2006 -0600
   184.3 @@ -1,30 +1,27 @@
   184.4 -INSTALL			= install
   184.5 -INSTALL_DATA		= $(INSTALL) -m0644
   184.6 -INSTALL_DIR		= $(INSTALL) -d -m0755
   184.7 -
   184.8  # This is the correct place to edit the build version.
   184.9  # All other places this is stored (eg. compile.h) should be autogenerated.
  184.10 -export XEN_VERSION       = 3
  184.11 -export XEN_SUBVERSION    = 0
  184.12 -export XEN_EXTRAVERSION  = -unstable
  184.13 -export XEN_FULLVERSION   = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
  184.14 -
  184.15 -export BASEDIR          := $(CURDIR)
  184.16 -
  184.17 -include Rules.mk
  184.18 +export XEN_VERSION      := 3
  184.19 +export XEN_SUBVERSION   := 0
  184.20 +export XEN_EXTRAVERSION := -unstable
  184.21 +export XEN_FULLVERSION  := $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
  184.22  
  184.23 -default: build
  184.24 -$(TARGET).gz: $(TARGET)
  184.25 -	gzip -f -9 < $< > $@.new
  184.26 -	mv $@.new $@
  184.27 +export BASEDIR := $(CURDIR)
  184.28  
  184.29 -debug:	
  184.30 -	objdump -D -S $(TARGET)-syms > $(TARGET).s
  184.31 +.PHONY: default
  184.32 +default: build
  184.33  
  184.34 -dist: install
  184.35 +ifeq ($(XEN_ROOT),)
  184.36  
  184.37 +.PHONY: build install clean
  184.38 +build install clean:
  184.39 +	make -f Rules.mk $@
  184.40 +
  184.41 +else
  184.42 +
  184.43 +.PHONY: build
  184.44  build: $(TARGET).gz
  184.45  
  184.46 +.PHONY: install
  184.47  install: $(TARGET).gz
  184.48  	[ -d $(DESTDIR)/boot ] || $(INSTALL_DIR) $(DESTDIR)/boot
  184.49  	$(INSTALL_DATA) $(TARGET).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_FULLVERSION).gz
  184.50 @@ -38,27 +35,42 @@ install: $(TARGET).gz
  184.51  	$(INSTALL_DATA) include/public/io/*.h $(DESTDIR)/usr/include/xen/io
  184.52  	$(INSTALL_DATA) include/public/COPYING $(DESTDIR)/usr/include/xen
  184.53  
  184.54 -clean: delete-unfresh-files
  184.55 +.PHONY: clean
  184.56 +clean:: delete-unfresh-files
  184.57  	$(MAKE) -C tools clean
  184.58 -	$(MAKE) -C common clean
  184.59 -	$(MAKE) -C drivers clean
  184.60 -	$(MAKE) -C acm clean
  184.61 -	$(MAKE) -C arch/$(TARGET_ARCH) clean
  184.62 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C common clean
  184.63 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean
  184.64 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C acm clean
  184.65 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) clean
  184.66  	rm -f include/asm *.o $(TARGET)* *~ core
  184.67  	rm -f include/asm-*/asm-offsets.h
  184.68  	rm -f include/xen/acm_policy.h
  184.69  
  184.70 +endif
  184.71 +
  184.72 +.PHONY: dist
  184.73 +dist: install
  184.74 +
  184.75 +.PHONY: debug
  184.76 +debug:
  184.77 +	objdump -D -S $(TARGET)-syms > $(TARGET).s
  184.78 +
  184.79 +$(TARGET).gz: $(TARGET)
  184.80 +	gzip -f -9 < $< > $@.new
  184.81 +	mv $@.new $@
  184.82 +
  184.83  $(TARGET): delete-unfresh-files
  184.84  	$(MAKE) -C tools
  184.85 -	$(MAKE) include/xen/compile.h
  184.86 -	$(MAKE) include/xen/acm_policy.h
  184.87 +	$(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h
  184.88 +	$(MAKE) -f $(BASEDIR)/Rules.mk include/xen/acm_policy.h
  184.89  	[ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
  184.90 -	$(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
  184.91 -	$(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
  184.92 -	$(MAKE) -C arch/$(TARGET_ARCH) $(TARGET)
  184.93 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s
  184.94 +	$(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h
  184.95 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $(TARGET)
  184.96  
  184.97  # drivers/char/console.o contains static banner/compile info. Blow it away.
  184.98  # Don't refresh these files during e.g., 'sudo make install'
  184.99 +.PHONY: delete-unfresh-files
 184.100  delete-unfresh-files:
 184.101  	@if [ ! -r include/xen/compile.h -o -O include/xen/compile.h ]; then \
 184.102  		rm -f include/xen/{banner,compile}.h; \
 184.103 @@ -115,8 +127,6 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h
 184.104  	  echo ""; \
 184.105  	  echo "#endif") <$< >$@
 184.106  
 184.107 -.PHONY: default debug install dist clean delete-unfresh-files TAGS tags
 184.108 -
 184.109  SUBDIRS = acm arch/$(TARGET_ARCH) common drivers 
 184.110  define all_sources
 184.111      ( find include/asm-$(TARGET_ARCH) -name SCCS -prune -o -name '*.h' -print; \
 184.112 @@ -124,12 +134,20 @@ define all_sources
 184.113              -name config \) -prune -o -name '*.h' -print; \
 184.114        find $(SUBDIRS) -name SCCS -prune -o -name '*.[chS]' -print )
 184.115  endef
 184.116 +
 184.117 +.PHONY: TAGS
 184.118  TAGS: 
 184.119  	$(all_sources) | etags -
 184.120 +
 184.121 +.PHONY: tags
 184.122  tags: 
 184.123  	$(all_sources) | xargs ctags
 184.124 +
 184.125 +.PHONY: cscope
 184.126  cscope: 
 184.127  	$(all_sources) > cscope.files
 184.128  	cscope -k -b -q
 184.129 +
 184.130 +.PHONY: MAP
 184.131  MAP:
 184.132  	$(NM) $(TARGET) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
   185.1 --- a/xen/Post.mk	Tue Apr 11 13:55:47 2006 -0600
   185.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   185.3 @@ -1,27 +0,0 @@
   185.4 -# Ensure each subdirectory has exactly one trailing slash.
   185.5 -subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n)))
   185.6 -subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y)))
   185.7 -
   185.8 -# Add explicitly declared subdirectories to the object list.
   185.9 -obj-y += $(patsubst %,%/built_in.o,$(subdir-y))
  185.10 -
  185.11 -# Add implicitly declared subdirectories (in the object list) to the
  185.12 -# subdirectory list, and rewrite the object-list entry.
  185.13 -subdir-y += $(filter %/,$(obj-y))
  185.14 -obj-y    := $(patsubst %/,%/built-in.o,$(obj-y))
  185.15 -
  185.16 -subdir-all := $(subdir-y) $(subdir-n)
  185.17 -
  185.18 -built_in.o: $(obj-y)
  185.19 -	$(LD) $(LDFLAGS) -r -o $@ $^
  185.20 -
  185.21 -.PHONY: FORCE
  185.22 -FORCE:
  185.23 -
  185.24 -%/built_in.o: FORCE
  185.25 -	$(MAKE) -C $*
  185.26 -
  185.27 -clean:: $(addprefix _clean_, $(subdir-all)) FORCE
  185.28 -	rm -f *.o *~ core
  185.29 -_clean_%/: FORCE
  185.30 -	$(MAKE) -C $* clean
   186.1 --- a/xen/Rules.mk	Tue Apr 11 13:55:47 2006 -0600
   186.2 +++ b/xen/Rules.mk	Tue Apr 11 18:54:18 2006 -0600
   186.3 @@ -26,18 +26,24 @@ override TARGET_SUBARCH  := $(XEN_TARGET
   186.4  override COMPILE_ARCH    := $(patsubst x86%,x86,$(XEN_COMPILE_ARCH))
   186.5  override TARGET_ARCH     := $(patsubst x86%,x86,$(XEN_TARGET_ARCH))
   186.6  
   186.7 -TARGET  := $(BASEDIR)/xen
   186.8 -HDRS    := $(wildcard $(BASEDIR)/include/xen/*.h)
   186.9 -HDRS    += $(wildcard $(BASEDIR)/include/public/*.h)
  186.10 -HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h)
  186.11 -HDRS    += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h)
  186.12 -# Do not depend on auto-generated header files.
  186.13 -HDRS    := $(subst $(BASEDIR)/include/asm-$(TARGET_ARCH)/asm-offsets.h,,$(HDRS))
  186.14 -HDRS    := $(subst $(BASEDIR)/include/xen/banner.h,,$(HDRS))
  186.15 -HDRS    := $(subst $(BASEDIR)/include/xen/compile.h,,$(HDRS))
  186.16 +TARGET := $(BASEDIR)/xen
  186.17 +
  186.18 +HDRS := $(wildcard $(BASEDIR)/include/xen/*.h)
  186.19 +HDRS += $(wildcard $(BASEDIR)/include/public/*.h)
  186.20 +HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h)
  186.21 +HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h)
  186.22 +
  186.23 +INSTALL      := install
  186.24 +INSTALL_DATA := $(INSTALL) -m0644
  186.25 +INSTALL_DIR  := $(INSTALL) -d -m0755
  186.26  
  186.27  include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
  186.28  
  186.29 +# Do not depend on auto-generated header files.
  186.30 +HDRS := $(subst $(BASEDIR)/include/asm-$(TARGET_ARCH)/asm-offsets.h,,$(HDRS))
  186.31 +HDRS := $(subst $(BASEDIR)/include/xen/banner.h,,$(HDRS))
  186.32 +HDRS := $(subst $(BASEDIR)/include/xen/compile.h,,$(HDRS))
  186.33 +
  186.34  # Note that link order matters!
  186.35  ALL_OBJS-y               += $(BASEDIR)/common/built_in.o
  186.36  ALL_OBJS-y               += $(BASEDIR)/drivers/built_in.o
  186.37 @@ -51,11 +57,50 @@ CFLAGS-$(crash_debug)  += -DCRASH_DEBUG
  186.38  CFLAGS-$(perfc)        += -DPERF_COUNTERS
  186.39  CFLAGS-$(perfc_arrays) += -DPERF_ARRAYS
  186.40  
  186.41 +ifneq ($(max_phys_cpus),)
  186.42 +CFLAGS-y               += -DMAX_PHYS_CPUS=$(max_phys_cpus)
  186.43 +endif
  186.44 +
  186.45 +AFLAGS-y               += -D__ASSEMBLY__
  186.46 +
  186.47  ALL_OBJS := $(ALL_OBJS-y)
  186.48  CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
  186.49 +AFLAGS   := $(strip $(AFLAGS) $(AFLAGS-y))
  186.50 +
  186.51 +include Makefile
  186.52 +
  186.53 +# Ensure each subdirectory has exactly one trailing slash.
  186.54 +subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n)))
  186.55 +subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y)))
  186.56 +
  186.57 +# Add explicitly declared subdirectories to the object list.
  186.58 +obj-y += $(patsubst %/,%/built_in.o,$(subdir-y))
  186.59 +
  186.60 +# Add implicitly declared subdirectories (in the object list) to the
  186.61 +# subdirectory list, and rewrite the object-list entry.
  186.62 +subdir-y += $(filter %/,$(obj-y))
  186.63 +obj-y    := $(patsubst %/,%/built-in.o,$(obj-y))
  186.64 +
  186.65 +subdir-all := $(subdir-y) $(subdir-n)
  186.66 +
  186.67 +built_in.o: $(obj-y)
  186.68 +	$(LD) $(LDFLAGS) -r -o $@ $^
  186.69 +
  186.70 +# Force execution of pattern rules (for which PHONY cannot be directly used).
  186.71 +.PHONY: FORCE
  186.72 +FORCE:
  186.73 +
  186.74 +%/built_in.o: FORCE
  186.75 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o
  186.76 +
  186.77 +.PHONY: clean
  186.78 +clean:: $(addprefix _clean_, $(subdir-all))
  186.79 +	rm -f *.o *~ core
  186.80 +_clean_%/: FORCE
  186.81 +	$(MAKE) -f $(BASEDIR)/Rules.mk -C $* clean
  186.82  
  186.83  %.o: %.c $(HDRS) Makefile
  186.84  	$(CC) $(CFLAGS) -c $< -o $@
  186.85  
  186.86  %.o: %.S $(HDRS) Makefile
  186.87 -	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
  186.88 +	$(CC) $(CFLAGS) $(AFLAGS) -c $< -o $@
   187.1 --- a/xen/acm/Makefile	Tue Apr 11 13:55:47 2006 -0600
   187.2 +++ b/xen/acm/Makefile	Tue Apr 11 18:54:18 2006 -0600
   187.3 @@ -1,9 +1,5 @@
   187.4 -include $(BASEDIR)/Rules.mk
   187.5 -
   187.6  obj-y += acm_core.o 
   187.7  obj-y += acm_policy.o
   187.8  obj-y += acm_simple_type_enforcement_hooks.o
   187.9  obj-y += acm_chinesewall_hooks.o
  187.10  obj-y += acm_null_hooks.o
  187.11 -
  187.12 -include $(BASEDIR)/Post.mk
   188.1 --- a/xen/arch/ia64/Makefile	Tue Apr 11 13:55:47 2006 -0600
   188.2 +++ b/xen/arch/ia64/Makefile	Tue Apr 11 18:54:18 2006 -0600
   188.3 @@ -1,21 +1,17 @@
   188.4 -include $(BASEDIR)/Rules.mk
   188.5 -
   188.6  subdir-y += xen
   188.7  subdir-y += vmx
   188.8  subdir-y += linux
   188.9  subdir-y += linux-xen
  188.10  
  188.11 -include $(BASEDIR)/Post.mk
  188.12 -
  188.13  $(TARGET)-syms: linux-xen/head.o $(ALL_OBJS) xen.lds.s
  188.14  	$(LD) $(LDFLAGS) -T xen.lds.s -N \
  188.15  		-Map map.out linux-xen/head.o $(ALL_OBJS) -o $@
  188.16  	$(NM) -n $@ | $(BASEDIR)/tools/symbols > $(BASEDIR)/xen-syms.S
  188.17 -	$(MAKE) $(BASEDIR)/xen-syms.o
  188.18 +	$(MAKE) -f $(BASEDIR)/Rules.mk $(BASEDIR)/xen-syms.o
  188.19  	$(LD) $(LDFLAGS) -T xen.lds.s -N \
  188.20  		-Map map.out linux-xen/head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
  188.21  	$(NM) -n $@ | $(BASEDIR)/tools/symbols >$(BASEDIR)/xen-syms.S
  188.22 -	$(MAKE) $(BASEDIR)/xen-syms.o
  188.23 +	$(MAKE) -f $(BASEDIR)/Rules.mk $(BASEDIR)/xen-syms.o
  188.24  	$(LD) $(LDFLAGS) -T xen.lds.s -N \
  188.25  		-Map map.out linux-xen/head.o $(ALL_OBJS) $(BASEDIR)/xen-syms.o -o $@
  188.26  	rm -f $(BASEDIR)/xen-syms.S $(BASEDIR)/xen-syms.o
  188.27 @@ -78,10 +74,11 @@ asm-xsi-offsets.s: asm-xsi-offsets.c $(H
  188.28  
  188.29  # I'm sure a Makefile wizard would know a better way to do this
  188.30  xen.lds.s: xen/xen.lds.S
  188.31 -	$(CC) -E $(CPPFLAGS) -P -DXEN -D__ASSEMBLY__ \
  188.32 +	$(CC) -E $(CPPFLAGS) -P -DXEN $(AFLAGS) \
  188.33  		-o xen.lds.s xen/xen.lds.S
  188.34  
  188.35 -clean:: FORCE
  188.36 +.PHONY: clean
  188.37 +clean::
  188.38  	rm -f *.o *~ core  xen.lds.s $(BASEDIR)/include/asm-ia64/.offsets.h.stamp asm-offsets.s map.out
  188.39  	rm -f asm-xsi-offsets.s $(BASEDIR)/include/asm-ia64/asm-xsi-offsets.h
  188.40  	rm -f $(BASEDIR)/System.map
   189.1 --- a/xen/arch/ia64/linux-xen/Makefile	Tue Apr 11 13:55:47 2006 -0600
   189.2 +++ b/xen/arch/ia64/linux-xen/Makefile	Tue Apr 11 18:54:18 2006 -0600
   189.3 @@ -1,5 +1,3 @@
   189.4 -include $(BASEDIR)/Rules.mk
   189.5 -
   189.6  obj-y += efi.o
   189.7  obj-y += entry.o
   189.8  obj-y += irq_ia64.o
   189.9 @@ -15,5 +13,3 @@ obj-y += time.o
  189.10  obj-y += tlb.o
  189.11  obj-y += unaligned.o
  189.12  obj-y += unwind.o
  189.13 -
  189.14 -include $(BASEDIR)/Post.mk
   190.1 --- a/xen/arch/ia64/linux/Makefile	Tue Apr 11 13:55:47 2006 -0600
   190.2 +++ b/xen/arch/ia64/linux/Makefile	Tue Apr 11 18:54:18 2006 -0600
   190.3 @@ -1,6 +1,3 @@
   190.4 -include $(BASEDIR)/Rules.mk
   190.5 -
   190.6 -
   190.7  obj-y += bitop.o
   190.8  obj-y += clear_page.o
   190.9  obj-y += cmdline.o
  190.10 @@ -26,8 +23,6 @@ obj-y += __udivdi3.o
  190.11  obj-y += __moddi3.o
  190.12  obj-y += __umoddi3.o
  190.13  
  190.14 -include $(BASEDIR)/Post.mk
  190.15 -
  190.16  ## variants of divide/modulo
  190.17  ## see files in xen/arch/ia64/linux/lib (linux/arch/ia64/lib)
  190.18  __divdi3.o: idiv64.S
   191.1 --- a/xen/arch/ia64/tools/privop/Makefile	Tue Apr 11 13:55:47 2006 -0600
   191.2 +++ b/xen/arch/ia64/tools/privop/Makefile	Tue Apr 11 18:54:18 2006 -0600
   191.3 @@ -1,10 +1,12 @@
   191.4  CC=gcc
   191.5  CFLAGS=-O -Wall
   191.6  
   191.7 +.PHONY: all
   191.8  all: postat
   191.9  
  191.10  postat: postat.c pohcalls.o
  191.11  
  191.12 +.PHONY: clean
  191.13  clean:
  191.14  	$(RM) -f *.o postat *.s *~
  191.15  
   192.1 --- a/xen/arch/ia64/vmx/Makefile	Tue Apr 11 13:55:47 2006 -0600
   192.2 +++ b/xen/arch/ia64/vmx/Makefile	Tue Apr 11 18:54:18 2006 -0600
   192.3 @@ -1,5 +1,3 @@
   192.4 -include $(BASEDIR)/Rules.mk
   192.5 -
   192.6  obj-y += hvm_vioapic.o
   192.7  obj-y += mm.o
   192.8  obj-y += mmio.o
   192.9 @@ -19,5 +17,3 @@ obj-y += vmx_vcpu.o
  192.10  obj-y += vmx_virt.o
  192.11  obj-y += vmx_vsa.o
  192.12  obj-y += vtlb.o
  192.13 -
  192.14 -include $(BASEDIR)/Post.mk
   193.1 --- a/xen/arch/ia64/vmx/vmx_hypercall.c	Tue Apr 11 13:55:47 2006 -0600
   193.2 +++ b/xen/arch/ia64/vmx/vmx_hypercall.c	Tue Apr 11 18:54:18 2006 -0600
   193.3 @@ -35,7 +35,7 @@
   193.4  #include <asm/dom_fw.h>
   193.5  #include <xen/domain.h>
   193.6  
   193.7 -extern long do_sched_op(int cmd, unsigned long arg);
   193.8 +extern long do_sched_op_compat(int cmd, unsigned long arg);
   193.9  extern unsigned long domain_mpa_to_imva(struct domain *,unsigned long mpaddr);
  193.10  
  193.11  void hyper_not_support(void)
  193.12 @@ -83,13 +83,13 @@ void hyper_dom_mem_op(void)
  193.13  }
  193.14  
  193.15  
  193.16 -void hyper_sched_op(void)
  193.17 +void hyper_sched_op_compat(void)
  193.18  {
  193.19      VCPU *vcpu=current;
  193.20      u64 r32,r33,ret;
  193.21      vcpu_get_gr_nat(vcpu,16,&r32);
  193.22      vcpu_get_gr_nat(vcpu,17,&r33);
  193.23 -    ret=do_sched_op(r32,r33);
  193.24 +    ret=do_sched_op_compat(r32,r33);
  193.25      vcpu_set_gr(vcpu, 8, ret, 0);
  193.26  
  193.27      vmx_vcpu_increment_iip(vcpu);
   194.1 --- a/xen/arch/ia64/vmx/vmx_ivt.S	Tue Apr 11 13:55:47 2006 -0600
   194.2 +++ b/xen/arch/ia64/vmx/vmx_ivt.S	Tue Apr 11 18:54:18 2006 -0600
   194.3 @@ -1125,7 +1125,7 @@ hyper_call_table:
   194.4      data8 hyper_not_support     //hyper_stack_switch
   194.5      data8 hyper_not_support     //hyper_set_callbacks
   194.6      data8 hyper_not_support     //hyper_fpu_taskswitch     /*  5 */
   194.7 -    data8 hyper_sched_op
   194.8 +    data8 hyper_sched_op_compat
   194.9      data8 hyper_dom0_op
  194.10      data8 hyper_not_support     //hyper_set_debugreg
  194.11      data8 hyper_not_support     //hyper_get_debugreg
   195.1 --- a/xen/arch/ia64/vmx/vmx_support.c	Tue Apr 11 13:55:47 2006 -0600
   195.2 +++ b/xen/arch/ia64/vmx/vmx_support.c	Tue Apr 11 18:54:18 2006 -0600
   195.3 @@ -43,7 +43,7 @@ void vmx_wait_io(void)
   195.4      do {
   195.5  	if (!test_bit(port,
   195.6  		&d->shared_info->evtchn_pending[0]))
   195.7 -            do_sched_op(SCHEDOP_block, 0);
   195.8 +            do_sched_op_compat(SCHEDOP_block, 0);
   195.9  
  195.10  	/* Unblocked when some event is coming. Clear pending indication
  195.11  	 * immediately if deciding to go for io assist
   196.1 --- a/xen/arch/ia64/xen/Makefile	Tue Apr 11 13:55:47 2006 -0600
   196.2 +++ b/xen/arch/ia64/xen/Makefile	Tue Apr 11 18:54:18 2006 -0600
   196.3 @@ -1,5 +1,3 @@
   196.4 -include $(BASEDIR)/Rules.mk
   196.5 -
   196.6  obj-y += acpi.o
   196.7  obj-y += dom0_ops.o
   196.8  obj-y += domain.o
   196.9 @@ -26,5 +24,3 @@ obj-y += xentime.o
  196.10  obj-y += flushd.o
  196.11  
  196.12  obj-$(crash_debug) += gdbstub.o
  196.13 -
  196.14 -include $(BASEDIR)/Post.mk
   197.1 --- a/xen/arch/ia64/xen/hypercall.c	Tue Apr 11 13:55:47 2006 -0600
   197.2 +++ b/xen/arch/ia64/xen/hypercall.c	Tue Apr 11 18:54:18 2006 -0600
   197.3 @@ -38,7 +38,7 @@ hypercall_t ia64_hypercall_table[] =
   197.4  	(hypercall_t)do_ni_hypercall,		/* do_stack_switch */
   197.5  	(hypercall_t)do_ni_hypercall,		/* do_set_callbacks */
   197.6  	(hypercall_t)do_ni_hypercall,		/* do_fpu_taskswitch */		/*  5 */
   197.7 -	(hypercall_t)do_ni_hypercall,		/* do_sched_op */
   197.8 +	(hypercall_t)do_sched_op_compat,
   197.9  	(hypercall_t)do_dom0_op,
  197.10  	(hypercall_t)do_ni_hypercall,		/* do_set_debugreg */
  197.11  	(hypercall_t)do_ni_hypercall,		/* do_get_debugreg */
  197.12 @@ -61,7 +61,7 @@ hypercall_t ia64_hypercall_table[] =
  197.13  	(hypercall_t)do_ni_hypercall,		/* do_mmuext_op */
  197.14  	(hypercall_t)do_ni_hypercall,		/* do_acm_op */
  197.15  	(hypercall_t)do_ni_hypercall,		/* do_nmi_op */
  197.16 -	(hypercall_t)do_ni_hypercall,		/*  */
  197.17 +	(hypercall_t)do_sched_op,
  197.18  	(hypercall_t)do_ni_hypercall,		/*  */				/* 30 */
  197.19  	(hypercall_t)do_ni_hypercall		/*  */
  197.20  	};
  197.21 @@ -70,6 +70,11 @@ static int
  197.22  xen_hypercall (struct pt_regs *regs)
  197.23  {
  197.24  	switch (regs->r2) {
  197.25 +	    case __HYPERVISOR_sched_op_compat:
  197.26 +		regs->r8 = do_sched_op_compat((int) regs->r14,
  197.27 +		                              (unsigned long) regs->r15);
  197.28 +		break;
  197.29 +
  197.30  	    case __HYPERVISOR_dom0_op:
  197.31  		regs->r8 = do_dom0_op(guest_handle_from_ptr(regs->r14,
  197.32  							    dom0_op_t));
  197.33 @@ -105,6 +110,11 @@ xen_hypercall (struct pt_regs *regs)
  197.34  			multicall_entry_t), (unsigned int) regs->r15);
  197.35  		break;
  197.36  
  197.37 +	    case __HYPERVISOR_sched_op:
  197.38 +		regs->r8 = do_sched_op((int) regs->r14,
  197.39 +		                       guest_handle_from_ptr(regs->r15, void));
  197.40 +		break;
  197.41 +
  197.42  	    default:
  197.43  		printf("unknown xen hypercall %lx\n", regs->r2);
  197.44  		regs->r8 = do_ni_hypercall();
  197.45 @@ -148,7 +158,7 @@ fw_hypercall (struct pt_regs *regs)
  197.46  			}
  197.47  			else {
  197.48  				pal_halt_light_count++;
  197.49 -				do_sched_op(SCHEDOP_yield, 0);
  197.50 +				do_sched_op_compat(SCHEDOP_yield, 0);
  197.51  			}
  197.52  			regs->r8 = 0;
  197.53  			regs->r9 = 0;
   198.1 --- a/xen/arch/ia64/xen/irq.c	Tue Apr 11 13:55:47 2006 -0600
   198.2 +++ b/xen/arch/ia64/xen/irq.c	Tue Apr 11 18:54:18 2006 -0600
   198.3 @@ -416,25 +416,20 @@ void __do_IRQ_guest(int irq)
   198.4  int pirq_guest_unmask(struct domain *d)
   198.5  {
   198.6      irq_desc_t    *desc;
   198.7 -    int            i, j, pirq;
   198.8 -    u32            m;
   198.9 +    int            pirq;
  198.10      shared_info_t *s = d->shared_info;
  198.11  
  198.12 -    for ( i = 0; i < ARRAY_SIZE(d->pirq_mask); i++ )
  198.13 +    for ( pirq = find_first_bit(d->pirq_mask, NR_PIRQS);
  198.14 +          pirq < NR_PIRQS;
  198.15 +          pirq = find_next_bit(d->pirq_mask, NR_PIRQS, pirq+1) )
  198.16      {
  198.17 -        m = d->pirq_mask[i];
  198.18 -        while ( (j = ffs(m)) != 0 )
  198.19 -        {
  198.20 -            m &= ~(1 << --j);
  198.21 -            pirq = (i << 5) + j;
  198.22 -            desc = &irq_desc[pirq];
  198.23 -            spin_lock_irq(&desc->lock);
  198.24 -            if ( !test_bit(d->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) &&
  198.25 -                 test_and_clear_bit(pirq, &d->pirq_mask) &&
  198.26 -                 (--((irq_guest_action_t *)desc->action)->in_flight == 0) )
  198.27 -                desc->handler->end(pirq);
  198.28 -            spin_unlock_irq(&desc->lock);
  198.29 -        }
  198.30 +        desc = &irq_desc[pirq];
  198.31 +        spin_lock_irq(&desc->lock);
  198.32 +        if ( !test_bit(d->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) &&
  198.33 +             test_and_clear_bit(pirq, &d->pirq_mask) &&
  198.34 +             (--((irq_guest_action_t *)desc->action)->in_flight == 0) )
  198.35 +            desc->handler->end(pirq);
  198.36 +        spin_unlock_irq(&desc->lock);
  198.37      }
  198.38  
  198.39      return 0;
   199.1 --- a/xen/arch/ia64/xen/xentime.c	Tue Apr 11 13:55:47 2006 -0600
   199.2 +++ b/xen/arch/ia64/xen/xentime.c	Tue Apr 11 18:54:18 2006 -0600
   199.3 @@ -84,7 +84,13 @@ s_time_t get_s_time(void)
   199.4      return now; 
   199.5  }
   199.6  
   199.7 -void update_dom_time(struct vcpu *v)
   199.8 +void update_vcpu_system_time(struct vcpu *v)
   199.9 +{
  199.10 +    /* N-op here, and let dom0 to manage system time directly */
  199.11 +    return;
  199.12 +}
  199.13 +
  199.14 +void update_domain_wallclock_time(struct domain *d)
  199.15  {
  199.16      /* N-op here, and let dom0 to manage system time directly */
  199.17      return;
  199.18 @@ -239,6 +245,6 @@ int reprogram_timer(s_time_t timeout)
  199.19  
  199.20  void send_timer_event(struct vcpu *v)
  199.21  {
  199.22 -	send_guest_virq(v, VIRQ_TIMER);
  199.23 +	send_guest_vcpu_virq(v, VIRQ_TIMER);
  199.24  }
  199.25  
   200.1 --- a/xen/arch/x86/Makefile	Tue Apr 11 13:55:47 2006 -0600
   200.2 +++ b/xen/arch/x86/Makefile	Tue Apr 11 18:54:18 2006 -0600
   200.3 @@ -1,9 +1,8 @@
   200.4 -include $(BASEDIR)/Rules.mk
   200.5 -
   200.6  subdir-y += acpi
   200.7  subdir-y += cpu
   200.8  subdir-y += genapic
   200.9  subdir-y += hvm
  200.10 +subdir-y += oprofile
  200.11  
  200.12  subdir-$(x86_32) += x86_32
  200.13  subdir-$(x86_64) += x86_64
  200.14 @@ -30,6 +29,7 @@ obj-y += nmi.o
  200.15  obj-y += physdev.o
  200.16  obj-y += rwlock.o
  200.17  obj-y += setup.o
  200.18 +obj-y += shutdown.o
  200.19  obj-y += smp.o
  200.20  obj-y += smpboot.o
  200.21  obj-y += string.o
  200.22 @@ -49,8 +49,6 @@ obj-$(x86_64) += shadow.o shadow_public.
  200.23  
  200.24  obj-$(crash_debug) += gdbstub.o
  200.25  
  200.26 -include $(BASEDIR)/Post.mk
  200.27 -
  200.28  $(TARGET): $(TARGET)-syms boot/mkelf32
  200.29  	./boot/mkelf32 $(TARGET)-syms $(TARGET) 0x100000 \