direct-io.hg

changeset 7762:b5c95258fe59

Merge with xen-unstable-ia64.hg
author kaf24@firebug.cl.cam.ac.uk
date Fri Nov 11 10:47:43 2005 +0100 (2005-11-11)
parents 2f98977d9f85 0b4596caf761
children cc1c250e672d
files
line diff
     1.1 --- a/docs/src/user.tex	Thu Nov 10 15:24:29 2005 -0600
     1.2 +++ b/docs/src/user.tex	Fri Nov 11 10:47:43 2005 +0100
     1.3 @@ -9,7 +9,6 @@
     1.4  \latexhtml{\newcommand{\path}[1]{{\small {\tt #1}}}}{\newcommand{\path}[1]{{\tt #1}}}
     1.5  
     1.6  
     1.7 -
     1.8  \begin{document}
     1.9  
    1.10  % TITLE PAGE
    1.11 @@ -21,24 +20,24 @@
    1.12  \vfill
    1.13  \vfill
    1.14  \begin{tabular}{l}
    1.15 -{\Huge \bf Users' manual} \\[4mm]
    1.16 -{\huge Xen v2.0 for x86} \\[80mm]
    1.17 +{\Huge \bf Users' Manual} \\[4mm]
    1.18 +{\huge Xen v3.0} \\[80mm]
    1.19  
    1.20 -{\Large Xen is Copyright (c) 2002-2004, The Xen Team} \\[3mm]
    1.21 +{\Large Xen is Copyright (c) 2002-2005, The Xen Team} \\[3mm]
    1.22  {\Large University of Cambridge, UK} \\[20mm]
    1.23  \end{tabular}
    1.24  \end{center}
    1.25  
    1.26 -{\bf
    1.27 -DISCLAIMER: This documentation is currently under active development
    1.28 -and as such there may be mistakes and omissions --- watch out for
    1.29 -these and please report any you find to the developer's mailing list.
    1.30 -Contributions of material, suggestions and corrections are welcome.
    1.31 -}
    1.32 +{\bf DISCLAIMER: This documentation is currently under active
    1.33 +  development and as such there may be mistakes and omissions ---
    1.34 +  watch out for these and please report any you find to the
    1.35 +  developers' mailing list.  Contributions of material, suggestions
    1.36 +  and corrections are welcome.}
    1.37  
    1.38  \vfill
    1.39  \cleardoublepage
    1.40  
    1.41 +
    1.42  % TABLE OF CONTENTS
    1.43  \pagestyle{plain}
    1.44  \pagenumbering{roman}
    1.45 @@ -46,6 +45,7 @@ Contributions of material, suggestions a
    1.46    \tableofcontents }
    1.47  \cleardoublepage
    1.48  
    1.49 +
    1.50  % PREPARE FOR MAIN TEXT
    1.51  \pagenumbering{arabic}
    1.52  \raggedbottom
    1.53 @@ -68,7 +68,7 @@ Contributions of material, suggestions a
    1.54  %% Chapter Installation moved to installation.tex
    1.55  \include{src/user/installation}
    1.56  
    1.57 -%% Chapter Starting Additional Domains  moved to start_addl_dom.tex
    1.58 +%% Chapter Starting Additional Domains moved to start_addl_dom.tex
    1.59  \include{src/user/start_addl_dom}
    1.60  
    1.61  %% Chapter Domain Management Tools moved to domain_mgmt.tex
    1.62 @@ -87,6 +87,9 @@ Contributions of material, suggestions a
    1.63  %% Chapter Domain Configuration moved to domain_configuration.tex
    1.64  \include{src/user/domain_configuration}
    1.65  
    1.66 +%% Chapter Securing Xen
    1.67 +\include{src/user/securing_xen}
    1.68 +
    1.69  %% Chapter Build, Boot and Debug Options moved to build.tex
    1.70  \include{src/user/build}
    1.71  
    1.72 @@ -99,25 +102,25 @@ that bug reports, suggestions and contri
    1.73  software (or the documentation) should be sent to the Xen developers'
    1.74  mailing list (address below).
    1.75  
    1.76 +
    1.77  \section{Other Documentation}
    1.78  
    1.79  For developers interested in porting operating systems to Xen, the
    1.80 -{\em Xen Interface Manual} is distributed in the \path{docs/}
    1.81 -directory of the Xen source distribution.  
    1.82 +\emph{Xen Interface Manual} is distributed in the \path{docs/}
    1.83 +directory of the Xen source distribution.
    1.84  
    1.85 -%Various HOWTOs are available in \path{docs/HOWTOS} but this content is
    1.86 -%being integrated into this manual.
    1.87 +% Various HOWTOs are available in \path{docs/HOWTOS} but this content
    1.88 +% is being integrated into this manual.
    1.89  
    1.90  
    1.91  \section{Online References}
    1.92  
    1.93  The official Xen web site is found at:
    1.94 -\begin{quote}
    1.95 -{\tt http://www.cl.cam.ac.uk/netos/xen/}
    1.96 +\begin{quote} {\tt http://www.cl.cam.ac.uk/netos/xen/}
    1.97  \end{quote}
    1.98  
    1.99 -This contains links to the latest versions of all on-line 
   1.100 -documentation (including the lateset version of the FAQ). 
   1.101 +This contains links to the latest versions of all online
   1.102 +documentation, including the latest version of the FAQ.
   1.103  
   1.104  
   1.105  \section{Mailing Lists}
   1.106 @@ -126,17 +129,17 @@ There are currently four official Xen ma
   1.107  
   1.108  \begin{description}
   1.109  \item[xen-devel@lists.xensource.com] Used for development
   1.110 -discussions and bug reports.  Subscribe at: \\
   1.111 -{\small {\tt http://lists.xensource.com/xen-devel}}
   1.112 +  discussions and bug reports.  Subscribe at: \\
   1.113 +  {\small {\tt http://lists.xensource.com/xen-devel}}
   1.114  \item[xen-users@lists.xensource.com] Used for installation and usage
   1.115 -discussions and requests for help.  Subscribe at: \\
   1.116 -{\small {\tt http://lists.xensource.com/xen-users}}
   1.117 +  discussions and requests for help.  Subscribe at: \\
   1.118 +  {\small {\tt http://lists.xensource.com/xen-users}}
   1.119  \item[xen-announce@lists.xensource.com] Used for announcements only.
   1.120 -Subscribe at: \\
   1.121 -{\small {\tt http://lists.xensource.com/xen-announce}}
   1.122 -\item[xen-changelog@lists.xensource.com]  Changelog feed
   1.123 -from the unstable and 2.0 trees - developer oriented.  Subscribe at: \\
   1.124 -{\small {\tt http://lists.xensource.com/xen-changelog}}
   1.125 +  Subscribe at: \\
   1.126 +  {\small {\tt http://lists.xensource.com/xen-announce}}
   1.127 +\item[xen-changelog@lists.xensource.com] Changelog feed
   1.128 +  from the unstable and 2.0 trees - developer oriented.  Subscribe at: \\
   1.129 +  {\small {\tt http://lists.xensource.com/xen-changelog}}
   1.130  \end{description}
   1.131  
   1.132  
   1.133 @@ -149,11 +152,11 @@ from the unstable and 2.0 trees - develo
   1.134  %% Chapter Installing Xen on Red Hat moved to redhat.tex
   1.135  \include{src/user/redhat}
   1.136  
   1.137 -
   1.138  %% Chapter Glossary of Terms moved to glossary.tex
   1.139  \include{src/user/glossary}
   1.140  
   1.141  
   1.142 +
   1.143  \end{document}
   1.144  
   1.145  
   1.146 @@ -181,36 +184,35 @@ from the unstable and 2.0 trees - develo
   1.147  %% # import xenctl.utils
   1.148  %% # help(xenctl.utils)
   1.149  
   1.150 -%% You can use these modules to write your own custom scripts or you can
   1.151 -%% customise the scripts supplied in the Xen distribution.
   1.152 +%% You can use these modules to write your own custom scripts or you
   1.153 +%% can customise the scripts supplied in the Xen distribution.
   1.154  
   1.155  
   1.156  
   1.157  % Explain about AGP GART
   1.158  
   1.159  
   1.160 -%% If you're not intending to configure the new domain with an IP address
   1.161 -%% on your LAN, then you'll probably want to use NAT. The
   1.162 -%% 'xen_nat_enable' installs a few useful iptables rules into domain0 to
   1.163 -%% enable NAT. [NB: We plan to support RSIP in future]
   1.164 -
   1.165 +%% If you're not intending to configure the new domain with an IP
   1.166 +%% address on your LAN, then you'll probably want to use NAT. The
   1.167 +%% 'xen_nat_enable' installs a few useful iptables rules into domain0
   1.168 +%% to enable NAT. [NB: We plan to support RSIP in future]
   1.169  
   1.170  
   1.171  
   1.172  %% Installing the file systems from the CD
   1.173  %% =======================================
   1.174  
   1.175 -%% If you haven't got an existing Linux installation onto which you can
   1.176 -%% just drop down the Xen and Xenlinux images, then the file systems on
   1.177 -%% the CD provide a quick way of doing an install. However, you would be
   1.178 -%% better off in the long run doing a proper install of your preferred
   1.179 -%% distro and installing Xen onto that, rather than just doing the hack
   1.180 -%% described below:
   1.181 +%% If you haven't got an existing Linux installation onto which you
   1.182 +%% can just drop down the Xen and Xenlinux images, then the file
   1.183 +%% systems on the CD provide a quick way of doing an install. However,
   1.184 +%% you would be better off in the long run doing a proper install of
   1.185 +%% your preferred distro and installing Xen onto that, rather than
   1.186 +%% just doing the hack described below:
   1.187  
   1.188 -%% Choose one or two partitions, depending on whether you want a separate
   1.189 -%% /usr or not. Make file systems on it/them e.g.: 
   1.190 -%%   mkfs -t ext3 /dev/hda3
   1.191 -%%   [or mkfs -t ext2 /dev/hda3 && tune2fs -j /dev/hda3 if using an old
   1.192 +%% Choose one or two partitions, depending on whether you want a
   1.193 +%% separate /usr or not. Make file systems on it/them e.g.:
   1.194 +%% mkfs -t ext3 /dev/hda3
   1.195 +%% [or mkfs -t ext2 /dev/hda3 && tune2fs -j /dev/hda3 if using an old
   1.196  %% version of mkfs]
   1.197  
   1.198  %% Next, mount the file system(s) e.g.:
   1.199 @@ -224,12 +226,14 @@ from the unstable and 2.0 trees - develo
   1.200  %% configuration. Changing the password file (etc/shadow) is probably a
   1.201  %% good idea too.
   1.202  
   1.203 -%% To install the usr file system, copy the file system from CD on /usr,
   1.204 -%% though leaving out the "XenDemoCD" and "boot" directories:
   1.205 -%%   cd /usr && cp -a X11R6 etc java libexec root src bin dict kerberos local sbin tmp doc include lib man share /mnt/usr
   1.206 +%% To install the usr file system, copy the file system from CD on
   1.207 +%% /usr, though leaving out the "XenDemoCD" and "boot" directories:
   1.208 +%%   cd /usr && cp -a X11R6 etc java libexec root src bin dict kerberos
   1.209 +%%    local sbin tmp doc include lib man share /mnt/usr
   1.210  
   1.211  %% If you intend to boot off these file systems (i.e. use them for
   1.212 -%% domain 0), then you probably want to copy the /usr/boot directory on
   1.213 -%% the cd over the top of the current symlink to /boot on your root
   1.214 -%% filesystem (after deleting the current symlink) i.e.:
   1.215 +%% domain 0), then you probably want to copy the /usr/boot
   1.216 +%% directory on the cd over the top of the current symlink to /boot
   1.217 +%% on your root filesystem (after deleting the current symlink)
   1.218 +%% i.e.:
   1.219  %%   cd /mnt/root ; rm boot ; cp -a /usr/boot .
     2.1 --- a/docs/src/user/installation.tex	Thu Nov 10 15:24:29 2005 -0600
     2.2 +++ b/docs/src/user/installation.tex	Fri Nov 11 10:47:43 2005 +0100
     2.3 @@ -17,7 +17,7 @@ want to run more than one virtual machin
     2.4  required if you wish to build from source.
     2.5  \begin{itemize}
     2.6  \item A working Linux distribution using the GRUB bootloader and
     2.7 -  running on a P6-class (or newer) CPU.
     2.8 +  running on a P6-class or newer CPU\@.
     2.9  \item [$\dag$] The \path{iproute2} package.
    2.10  \item [$\dag$] The Linux bridge-utils\footnote{Available from {\tt
    2.11        http://bridge.sourceforge.net}} (e.g., \path{/sbin/brctl})
    2.12 @@ -30,29 +30,29 @@ required if you wish to build from sourc
    2.13    alternatively it can be installed by running `{\sl make
    2.14      install-twisted}' in the root of the Xen source tree.
    2.15  \item [$*$] Build tools (gcc v3.2.x or v3.3.x, binutils, GNU make).
    2.16 -\item [$*$] Development installation of libcurl (e.g., libcurl-devel)
    2.17 -\item [$*$] Development installation of zlib (e.g., zlib-dev).
    2.18 -\item [$*$] Development installation of Python v2.2 or later (e.g.,
    2.19 +\item [$*$] Development installation of libcurl (e.g.,\ libcurl-devel).
    2.20 +\item [$*$] Development installation of zlib (e.g.,\ zlib-dev).
    2.21 +\item [$*$] Development installation of Python v2.2 or later (e.g.,\ 
    2.22    python-dev).
    2.23  \item [$*$] \LaTeX\ and transfig are required to build the
    2.24    documentation.
    2.25  \end{itemize}
    2.26  
    2.27 -Once you have satisfied the relevant prerequisites, you can now
    2.28 -install either a binary or source distribution of Xen.
    2.29 +Once you have satisfied these prerequisites, you can now install
    2.30 +either a binary or source distribution of Xen.
    2.31  
    2.32  
    2.33  \section{Installing from Binary Tarball}
    2.34  
    2.35  Pre-built tarballs are available for download from the Xen download
    2.36 -page
    2.37 -\begin{quote} {\tt http://xen.sf.net}
    2.38 +page:
    2.39 +\begin{quote} {\tt http://www.xensource.com/downloads/}
    2.40  \end{quote}
    2.41  
    2.42  Once you've downloaded the tarball, simply unpack and install:
    2.43  \begin{verbatim}
    2.44 -# tar zxvf xen-2.0-install.tgz
    2.45 -# cd xen-2.0-install
    2.46 +# tar zxvf xen-3.0-install.tgz
    2.47 +# cd xen-3.0-install
    2.48  # sh ./install.sh
    2.49  \end{verbatim}
    2.50  
    2.51 @@ -62,48 +62,29 @@ as described in Section~\ref{s:configure
    2.52  
    2.53  \section{Installing from Source}
    2.54  
    2.55 -This section describes how to obtain, build, and install Xen from
    2.56 +This section describes how to obtain, build and install Xen from
    2.57  source.
    2.58  
    2.59  \subsection{Obtaining the Source}
    2.60  
    2.61 -The Xen source tree is available as either a compressed source tar
    2.62 -ball or as a clone of our master BitKeeper repository.
    2.63 +The Xen source tree is available as either a compressed source tarball
    2.64 +or as a clone of our master Mercurial repository.
    2.65  
    2.66  \begin{description}
    2.67  \item[Obtaining the Source Tarball]\mbox{} \\
    2.68 -  Stable versions (and daily snapshots) of the Xen source tree are
    2.69 -  available as compressed tarballs from the Xen download page
    2.70 -  \begin{quote} {\tt http://xen.sf.net}
    2.71 +  Stable versions and daily snapshots of the Xen source tree are
    2.72 +  available from the Xen download page:
    2.73 +  \begin{quote} {\tt \tt http://www.xensource.com/downloads/}
    2.74    \end{quote}
    2.75 -
    2.76 -\item[Using BitKeeper]\mbox{} \\
    2.77 -  If you wish to install Xen from a clone of our latest BitKeeper
    2.78 -  repository then you will need to install the BitKeeper tools.
    2.79 -  Download instructions for BitKeeper can be obtained by filling out
    2.80 -  the form at:
    2.81 -  \begin{quote} {\tt http://www.bitmover.com/cgi-bin/download.cgi}
    2.82 -\end{quote}
    2.83 -The public master BK repository for the 2.0 release lives at:
    2.84 -\begin{quote} {\tt bk://xen.bkbits.net/xen-2.0.bk}
    2.85 -\end{quote} 
    2.86 -You can use BitKeeper to download it and keep it updated with the
    2.87 -latest features and fixes.
    2.88 -
    2.89 -Change to the directory in which you want to put the source code, then
    2.90 -run:
    2.91 -\begin{verbatim}
    2.92 -# bk clone bk://xen.bkbits.net/xen-2.0.bk
    2.93 -\end{verbatim}
    2.94 -
    2.95 -Under your current directory, a new directory named \path{xen-2.0.bk}
    2.96 -has been created, which contains all the source code for Xen, the OS
    2.97 -ports, and the control tools. You can update your repository with the
    2.98 -latest changes at any time by running:
    2.99 -\begin{verbatim}
   2.100 -# cd xen-2.0.bk # to change into the local repository
   2.101 -# bk pull       # to update the repository
   2.102 -\end{verbatim}
   2.103 +\item[Obtaining the source via Mercurial]\mbox{} \\
   2.104 +  The source tree may also be obtained via the public Mercurial
   2.105 +  repository hosted at:
   2.106 +  \begin{quote}{\tt http://xenbits.xensource.com}.
   2.107 +  \end{quote} See the instructions and the Getting Started Guide
   2.108 +  referenced at:
   2.109 +  \begin{quote}
   2.110 +    {\tt http://www.xensource.com/downloads/}.
   2.111 +  \end{quote}
   2.112  \end{description}
   2.113  
   2.114  % \section{The distribution}
   2.115 @@ -124,7 +105,7 @@ latest changes at any time by running:
   2.116  
   2.117  \subsection{Building from Source}
   2.118  
   2.119 -The top-level Xen Makefile includes a target `world' that will do the
   2.120 +The top-level Xen Makefile includes a target ``world'' that will do the
   2.121  following:
   2.122  
   2.123  \begin{itemize}
   2.124 @@ -132,17 +113,17 @@ following:
   2.125  \item Build the control tools, including \xend.
   2.126  \item Download (if necessary) and unpack the Linux 2.6 source code,
   2.127    and patch it for use with Xen.
   2.128 -\item Build a Linux kernel to use in domain 0 and a smaller
   2.129 +\item Build a Linux kernel to use in domain~0 and a smaller
   2.130    unprivileged kernel, which can optionally be used for unprivileged
   2.131    virtual machines.
   2.132  \end{itemize}
   2.133  
   2.134  After the build has completed you should have a top-level directory
   2.135 -called \path{dist/} in which all resulting targets will be placed; of
   2.136 -particular interest are the two kernels XenLinux kernel images, one
   2.137 -with a `-xen0' extension which contains hardware device drivers and
   2.138 -drivers for Xen's virtual devices, and one with a `-xenU' extension
   2.139 -that just contains the virtual ones. These are found in
   2.140 +called \path{dist/} in which all resulting targets will be placed. Of
   2.141 +particular interest are the two XenLinux kernel images, one with a
   2.142 +``-xen0'' extension which contains hardware device drivers and drivers
   2.143 +for Xen's virtual devices, and one with a ``-xenU'' extension that
   2.144 +just contains the virtual ones. These are found in
   2.145  \path{dist/install/boot/} along with the image for Xen itself and the
   2.146  configuration files used during the build.
   2.147  
   2.148 @@ -150,17 +131,15 @@ The NetBSD port can be built using:
   2.149  \begin{quote}
   2.150  \begin{verbatim}
   2.151  # make netbsd20
   2.152 -\end{verbatim}
   2.153 -\end{quote}
   2.154 +\end{verbatim}\end{quote}
   2.155  NetBSD port is built using a snapshot of the netbsd-2-0 cvs branch.
   2.156 -The snapshot is downloaded as part of the build process, if it is not
   2.157 +The snapshot is downloaded as part of the build process if it is not
   2.158  yet present in the \path{NETBSD\_SRC\_PATH} search path.  The build
   2.159 -process also downloads a toolchain which includes all the tools
   2.160 +process also downloads a toolchain which includes all of the tools
   2.161  necessary to build the NetBSD kernel under Linux.
   2.162  
   2.163 -To customize further the set of kernels built you need to edit the
   2.164 -top-level Makefile. Look for the line:
   2.165 -
   2.166 +To customize the set of kernels built you need to edit the top-level
   2.167 +Makefile. Look for the line:
   2.168  \begin{quote}
   2.169  \begin{verbatim}
   2.170  KERNELS ?= mk.linux-2.6-xen0 mk.linux-2.6-xenU
   2.171 @@ -189,7 +168,6 @@ kernel containing only virtual device dr
   2.172  %% After untaring the pristine kernel tree, the makefile uses the {\tt
   2.173  %%   mkbuildtree} script to add the Xen patches to the kernel.
   2.174  
   2.175 -
   2.176  %% \framebox{\parbox{5in}{
   2.177  %%     {\bf Distro specific:} \\
   2.178  %%     {\it Gentoo} --- if not using udev (most installations,
   2.179 @@ -201,7 +179,7 @@ kernel containing only virtual device dr
   2.180  % If you have an SMP machine you may wish to give the {\tt '-j4'}
   2.181  % argument to make to get a parallel build.
   2.182  
   2.183 -If you wish to build a customized XenLinux kernel (e.g. to support
   2.184 +If you wish to build a customized XenLinux kernel (e.g.\ to support
   2.185  additional devices or enable distribution-required features), you can
   2.186  use the standard Linux configuration mechanisms, specifying that the
   2.187  architecture being built for is \path{xen}, e.g:
   2.188 @@ -215,21 +193,21 @@ architecture being built for is \path{xe
   2.189  \end{quote}
   2.190  
   2.191  You can also copy an existing Linux configuration (\path{.config})
   2.192 -into \path{linux-2.6.11-xen0} and execute:
   2.193 +into e.g.\ \path{linux-2.6.11-xen0} and execute:
   2.194  \begin{quote}
   2.195  \begin{verbatim}
   2.196  # make ARCH=xen oldconfig
   2.197  \end{verbatim}
   2.198  \end{quote}
   2.199  
   2.200 -You may be prompted with some Xen-specific options; we advise
   2.201 +You may be prompted with some Xen-specific options. We advise
   2.202  accepting the defaults for these options.
   2.203  
   2.204 -Note that the only difference between the two types of Linux kernel
   2.205 -that are built is the configuration file used for each.  The `U'
   2.206 +Note that the only difference between the two types of Linux kernels
   2.207 +that are built is the configuration file used for each.  The ``U''
   2.208  suffixed (unprivileged) versions don't contain any of the physical
   2.209  hardware device drivers, leading to a 30\% reduction in size; hence
   2.210 -you may prefer these for your non-privileged domains.  The `0'
   2.211 +you may prefer these for your non-privileged domains.  The ``0''
   2.212  suffixed privileged versions can be used to boot the system, as well
   2.213  as in driver domains and unprivileged domains.
   2.214  
   2.215 @@ -259,10 +237,10 @@ destinations.
   2.216  
   2.217  The \path{dist/install/boot} directory will also contain the config
   2.218  files used for building the XenLinux kernels, and also versions of Xen
   2.219 -and XenLinux kernels that contain debug symbols (\path{xen-syms-2.0.6}
   2.220 -and \path{vmlinux-syms-2.6.11.11-xen0}) which are essential for
   2.221 -interpreting crash dumps.  Retain these files as the developers may
   2.222 -wish to see them if you post on the mailing list.
   2.223 +and XenLinux kernels that contain debug symbols such as
   2.224 +(\path{xen-syms-2.0.6} and \path{vmlinux-syms-2.6.11.11-xen0}) which
   2.225 +are essential for interpreting crash dumps.  Retain these files as the
   2.226 +developers may wish to see them if you post on the mailing list.
   2.227  
   2.228  
   2.229  \section{Configuration}
   2.230 @@ -280,23 +258,23 @@ distribution.  The entry should look som
   2.231  
   2.232  {\small
   2.233  \begin{verbatim}
   2.234 -title Xen 2.0 / XenLinux 2.6
   2.235 -  kernel /boot/xen-2.0.gz dom0_mem=131072
   2.236 +title Xen 3.0 / XenLinux 2.6
   2.237 +  kernel /boot/xen-3.0.gz dom0_mem=131072
   2.238    module /boot/vmlinuz-2.6-xen0 root=/dev/sda4 ro console=tty0
   2.239  \end{verbatim}
   2.240  }
   2.241  
   2.242  The kernel line tells GRUB where to find Xen itself and what boot
   2.243 -parameters should be passed to it (in this case, setting domain 0's
   2.244 +parameters should be passed to it (in this case, setting the domain~0
   2.245  memory allocation in kilobytes and the settings for the serial port).
   2.246  For more details on the various Xen boot parameters see
   2.247  Section~\ref{s:xboot}.
   2.248  
   2.249  The module line of the configuration describes the location of the
   2.250  XenLinux kernel that Xen should start and the parameters that should
   2.251 -be passed to it (these are standard Linux parameters, identifying the
   2.252 +be passed to it. Tthese are standard Linux parameters, identifying the
   2.253  root device and specifying it be initially mounted read only and
   2.254 -instructing that console output be sent to the screen).  Some
   2.255 +instructing that console output be sent to the screen. Some
   2.256  distributions such as SuSE do not require the \path{ro} parameter.
   2.257  
   2.258  %% \framebox{\parbox{5in}{
   2.259 @@ -307,25 +285,22 @@ distributions such as SuSE do not requir
   2.260  
   2.261  
   2.262  If you want to use an initrd, just add another \path{module} line to
   2.263 -the configuration, as usual:
   2.264 -
   2.265 +the configuration, like:
   2.266  {\small
   2.267  \begin{verbatim}
   2.268    module /boot/my_initrd.gz
   2.269  \end{verbatim}
   2.270  }
   2.271  
   2.272 -As always when installing a new kernel, it is recommended that you do
   2.273 -not delete existing menu options from \path{menu.lst} --- you may want
   2.274 -to boot your old Linux kernel in future, particularly if you have
   2.275 -problems.
   2.276 +When installing a new kernel, it is recommended that you do not delete
   2.277 +existing menu options from \path{menu.lst}, as you may wish to boot
   2.278 +your old Linux kernel in future, particularly if you have problems.
   2.279  
   2.280  \subsection{Serial Console (optional)}
   2.281  
   2.282  %% kernel /boot/xen-2.0.gz dom0_mem=131072 com1=115200,8n1
   2.283  %% module /boot/vmlinuz-2.6-xen0 root=/dev/sda4 ro
   2.284  
   2.285 -
   2.286  In order to configure Xen serial console output, it is necessary to
   2.287  add an boot option to your GRUB config; e.g.\ replace the above kernel
   2.288  line with:
   2.289 @@ -343,24 +318,23 @@ One can also configure XenLinux to share
   2.290  achieve this append ``\path{console=ttyS0}'' to your module line.
   2.291  
   2.292  If you wish to be able to log in over the XenLinux serial console it
   2.293 -is necessary to add a line into \path{/etc/inittab}, just as per
   2.294 -regular Linux. Simply add the line:
   2.295 +is necessary to add a line into \path{/etc/inittab}. Add the line:
   2.296  \begin{quote} {\small {\tt c:2345:respawn:/sbin/mingetty ttyS0}}
   2.297  \end{quote}
   2.298  
   2.299 -and you should be able to log in. Note that to successfully log in as
   2.300 -root over the serial line will require adding \path{ttyS0} to
   2.301 -\path{/etc/securetty} in most modern distributions.
   2.302 +and you should be able to log in. To successfully log in as root over
   2.303 +the serial line will require adding \path{ttyS0} to
   2.304 +\path{/etc/securetty} if it is not already there.
   2.305  
   2.306  \subsection{TLS Libraries}
   2.307  
   2.308  Users of the XenLinux 2.6 kernel should disable Thread Local Storage
   2.309 -(e.g.\ by doing a \path{mv /lib/tls /lib/tls.disabled}) before
   2.310 -attempting to run with a XenLinux kernel\footnote{If you boot without
   2.311 +(TLS) (e.g.\ by doing a \path{mv /lib/tls /lib/tls.disabled}) before
   2.312 +attempting to boot a XenLinux kernel\footnote{If you boot without
   2.313    first disabling TLS, you will get a warning message during the boot
   2.314    process. In this case, simply perform the rename after the machine
   2.315    is up and then run \texttt{/sbin/ldconfig} to make it take effect.}.
   2.316 -You can always reenable it by restoring the directory to its original
   2.317 +You can always reenable TLS by restoring the directory to its original
   2.318  location (i.e.\ \path{mv /lib/tls.disabled /lib/tls}).
   2.319  
   2.320  The reason for this is that the current TLS implementation uses
   2.321 @@ -369,19 +343,19 @@ not disabled, an emulation mode is used 
   2.322  performance substantially.
   2.323  
   2.324  We hope that this issue can be resolved by working with Linux
   2.325 -distribution vendors to implement a minor backward-compatible change
   2.326 +distributions to implement a minor backward-compatible change
   2.327  to the TLS library.
   2.328  
   2.329  
   2.330  \section{Booting Xen}
   2.331  
   2.332  It should now be possible to restart the system and use Xen.  Reboot
   2.333 -as usual but choose the new Xen option when the Grub screen appears.
   2.334 +and choose the new Xen option when the Grub screen appears.
   2.335  
   2.336  What follows should look much like a conventional Linux boot.  The
   2.337  first portion of the output comes from Xen itself, supplying low level
   2.338 -information about itself and the machine it is running on.  The
   2.339 -following portion of the output comes from XenLinux.
   2.340 +information about itself and the underlying hardware.  The last
   2.341 +portion of the output comes from XenLinux.
   2.342  
   2.343  You may see some errors during the XenLinux boot.  These are not
   2.344  necessarily anything to worry about --- they may result from kernel
   2.345 @@ -389,5 +363,5 @@ configuration differences between your X
   2.346  usually use.
   2.347  
   2.348  When the boot completes, you should be able to log into your system as
   2.349 -usual.  If you are unable to log in to your system running Xen, you
   2.350 -should still be able to reboot with your normal Linux kernel.
   2.351 +usual.  If you are unable to log in, you should still be able to
   2.352 +reboot with your normal Linux kernel.
     3.1 --- a/docs/src/user/introduction.tex	Thu Nov 10 15:24:29 2005 -0600
     3.2 +++ b/docs/src/user/introduction.tex	Fri Nov 11 10:47:43 2005 +0100
     3.3 @@ -2,7 +2,7 @@
     3.4  
     3.5  
     3.6  Xen is a \emph{paravirtualising} virtual machine monitor (VMM), or
     3.7 -`hypervisor', for the x86 processor architecture.  Xen can securely
     3.8 +``hypervisor'', for the x86 processor architecture.  Xen can securely
     3.9  execute multiple virtual machines on a single physical system with
    3.10  close-to-native performance.  The virtual machine technology
    3.11  facilitates enterprise-grade functionality, including:
    3.12 @@ -11,7 +11,7 @@ facilitates enterprise-grade functionali
    3.13  \item Virtual machines with performance close to native hardware.
    3.14  \item Live migration of running virtual machines between physical
    3.15    hosts.
    3.16 -\item Excellent hardware support (supports most Linux device drivers).
    3.17 +\item Excellent hardware support. Supports most Linux device drivers.
    3.18  \item Sandboxed, re-startable device drivers.
    3.19  \end{itemize}
    3.20  
    3.21 @@ -28,7 +28,7 @@ system kernels must explicitly support X
    3.22  space applications and libraries \emph{do not} require modification.
    3.23  
    3.24  Xen support is available for increasingly many operating systems:
    3.25 -right now, Linux and NetBSD are available for Xen 2.0.
    3.26 +right now, Linux and NetBSD are available for Xen 3.0.
    3.27  A FreeBSD port is undergoing testing and will be incorporated into the
    3.28  release soon. Other OS ports, including Plan 9, are in progress.  We
    3.29  hope that that arch-xen patches will be incorporated into the
    3.30 @@ -43,14 +43,14 @@ Possible usage scenarios for Xen include
    3.31  \item [Multiple OS configurations.] Run multiple operating systems
    3.32    simultaneously, for instance for compatibility or QA purposes.
    3.33  \item [Server consolidation.] Move multiple servers onto a single
    3.34 -  physical host with performance and fault isolation provided at
    3.35 +  physical host with performance and fault isolation provided at the
    3.36    virtual machine boundaries.
    3.37  \item [Cluster computing.] Management at VM granularity provides more
    3.38    flexibility than separately managing each physical host, but better
    3.39    control and isolation than single-system image solutions,
    3.40    particularly by using live migration for load balancing.
    3.41  \item [Hardware support for custom OSes.] Allow development of new
    3.42 -  OSes while benefiting from the wide-ranging hardware support of
    3.43 +  OSes while benefitting from the wide-ranging hardware support of
    3.44    existing OSes such as Linux.
    3.45  \end{description}
    3.46  
    3.47 @@ -58,44 +58,44 @@ Possible usage scenarios for Xen include
    3.48  \section{Structure of a Xen-Based System}
    3.49  
    3.50  A Xen system has multiple layers, the lowest and most privileged of
    3.51 -which is Xen itself. 
    3.52 +which is Xen itself.
    3.53  
    3.54 -Xen in turn may host multiple \emph{guest} operating systems, each of
    3.55 -which is executed within a secure virtual machine (in Xen terminology,
    3.56 -a \emph{domain}). Domains are scheduled by Xen to make effective use
    3.57 -of the available physical CPUs.  Each guest OS manages its own
    3.58 -applications, which includes responsibility for scheduling each
    3.59 -application within the time allotted to the VM by Xen.
    3.60 +Xen may host multiple \emph{guest} operating systems, each of which is
    3.61 +executed within a secure virtual machine. In Xen terminology, a
    3.62 +\emph{domain}. Domains are scheduled by Xen to make effective use of
    3.63 +the available physical CPUs.  Each guest OS manages its own
    3.64 +applications. This management includes the responsibility of
    3.65 +scheduling each application within the time allotted to the VM by Xen.
    3.66  
    3.67 -The first domain, \emph{domain 0}, is created automatically when the
    3.68 -system boots and has special management privileges. Domain 0 builds
    3.69 +The first domain, \emph{domain~0}, is created automatically when the
    3.70 +system boots and has special management privileges. Domain~0 builds
    3.71  other domains and manages their virtual devices. It also performs
    3.72  administrative tasks such as suspending, resuming and migrating other
    3.73  virtual machines.
    3.74  
    3.75 -Within domain 0, a process called \emph{xend} runs to manage the
    3.76 -system.  \Xend is responsible for managing virtual machines and
    3.77 -providing access to their consoles.  Commands are issued to \xend over
    3.78 -an HTTP interface, either from a command-line tool or from a web
    3.79 +Within domain~0, a process called \emph{xend} runs to manage the
    3.80 +system.  \Xend\ is responsible for managing virtual machines and
    3.81 +providing access to their consoles.  Commands are issued to \xend\ 
    3.82 +over an HTTP interface, either from a command-line tool or from a web
    3.83  browser.
    3.84  
    3.85  
    3.86  \section{Hardware Support}
    3.87  
    3.88  Xen currently runs only on the x86 architecture, requiring a `P6' or
    3.89 -newer processor (e.g. Pentium Pro, Celeron, Pentium II, Pentium III,
    3.90 -Pentium IV, Xeon, AMD Athlon, AMD Duron).  Multiprocessor machines are
    3.91 -supported, and we also have basic support for HyperThreading (SMT),
    3.92 +newer processor (e.g.\ Pentium Pro, Celeron, Pentium~II, Pentium~III,
    3.93 +Pentium~IV, Xeon, AMD~Athlon, AMD~Duron).  Multiprocessor machines are
    3.94 +supported, and there is basic support for HyperThreading (SMT),
    3.95  although this remains a topic for ongoing research. A port
    3.96 -specifically for x86/64 is in progress, although Xen already runs on
    3.97 -such systems in 32-bit legacy mode. In addition a port to the IA64
    3.98 +specifically for x86/64 is in progress. Xen already runs on such
    3.99 +systems in 32-bit legacy mode. In addition, a port to the IA64
   3.100  architecture is approaching completion. We hope to add other
   3.101  architectures such as PPC and ARM in due course.
   3.102  
   3.103  Xen can currently use up to 4GB of memory.  It is possible for x86
   3.104  machines to address up to 64GB of physical memory but there are no
   3.105 -current plans to support these systems: The x86/64 port is the planned
   3.106 -route to supporting larger memory sizes.
   3.107 +plans to support these systems: The x86/64 port is the planned route
   3.108 +to supporting larger memory sizes.
   3.109  
   3.110  Xen offloads most of the hardware support issues to the guest OS
   3.111  running in Domain~0.  Xen itself contains only the code required to
   3.112 @@ -112,23 +112,22 @@ other hardware by configuring your XenLi
   3.113  
   3.114  Xen was originally developed by the Systems Research Group at the
   3.115  University of Cambridge Computer Laboratory as part of the XenoServers
   3.116 -project, funded by the UK-EPSRC.
   3.117 +project, funded by the UK-EPSRC\@.
   3.118  
   3.119 -XenoServers aim to provide a `public infrastructure for global
   3.120 -distributed computing', and Xen plays a key part in that, allowing us
   3.121 -to efficiently partition a single machine to enable multiple
   3.122 -independent clients to run their operating systems and applications in
   3.123 -an environment providing protection, resource isolation and
   3.124 -accounting.  The project web page contains further information along
   3.125 -with pointers to papers and technical reports:
   3.126 +XenoServers aim to provide a ``public infrastructure for global
   3.127 +distributed computing''. Xen plays a key part in that, allowing one to
   3.128 +efficiently partition a single machine to enable multiple independent
   3.129 +clients to run their operating systems and applications in an
   3.130 +environment. This environment provides protection, resource isolation
   3.131 +and accounting.  The project web page contains further information
   3.132 +along with pointers to papers and technical reports:
   3.133  \path{http://www.cl.cam.ac.uk/xeno}
   3.134  
   3.135 -Xen has since grown into a fully-fledged project in its own right,
   3.136 -enabling us to investigate interesting research issues regarding the
   3.137 -best techniques for virtualising resources such as the CPU, memory,
   3.138 -disk and network.  The project has been bolstered by support from
   3.139 -Intel Research Cambridge, and HP Labs, who are now working closely
   3.140 -with us.
   3.141 +Xen has grown into a fully-fledged project in its own right, enabling
   3.142 +us to investigate interesting research issues regarding the best
   3.143 +techniques for virtualising resources such as the CPU, memory, disk
   3.144 +and network.  The project has been bolstered by support from Intel
   3.145 +Research Cambridge and HP Labs, who are now working closely with us.
   3.146  
   3.147  Xen was first described in a paper presented at SOSP in
   3.148  2003\footnote{\tt
   3.149 @@ -137,7 +136,7 @@ first public release (1.0) was made that
   3.150  significantly matured and is now used in production scenarios on many
   3.151  sites.
   3.152  
   3.153 -Xen 2.0 features greatly enhanced hardware support, configuration
   3.154 +Xen 3.0 features greatly enhanced hardware support, configuration
   3.155  flexibility, usability and a larger complement of supported operating
   3.156  systems. This latest release takes Xen a step closer to becoming the
   3.157  definitive open source solution for virtualisation.
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/docs/src/user/securing_xen.tex	Fri Nov 11 10:47:43 2005 +0100
     4.3 @@ -0,0 +1,85 @@
     4.4 +\chapter{Securing Xen}
     4.5 +
     4.6 +This chapter describes how to secure a Xen system. It describes a number
     4.7 +of scenarios and provides a corresponding set of best practices. It
     4.8 +begins with a section devoted to understanding the security implications
     4.9 +of a Xen system.
    4.10 +
    4.11 +
    4.12 +\section{Xen Security Considerations}
    4.13 +
    4.14 +When deploying a Xen system, one must be sure to secure the management
    4.15 +domain (Domain-0) as much as possible. If the management domain is
    4.16 +compromised, all other domains are also vulnerable. The following are a
    4.17 +set of best practices for Domain-0:
    4.18 +
    4.19 +\begin{enumerate}
    4.20 +\item \textbf{Run the smallest number of necessary services.} The less
    4.21 +  things that are present in a management partition, the better.
    4.22 +  Remember, a service running as root in the management domain has full
    4.23 +  access to all other domains on the system.
    4.24 +\item \textbf{Use a firewall to restrict the traffic to the management
    4.25 +    domain.} A firewall with default-reject rules will help prevent
    4.26 +  attacks on the management domain.
    4.27 +\item \textbf{Do not allow users to access Domain-0.} The Linux kernel
    4.28 +  has been known to have local-user root exploits. If you allow normal
    4.29 +  users to access Domain-0 (even as unprivileged users) you run the risk
    4.30 +  of a kernel exploit making all of your domains vulnerable.
    4.31 +\end{enumerate}
    4.32 +
    4.33 +\section{Security Scenarios}
    4.34 +
    4.35 +
    4.36 +\subsection{The Isolated Management Network}
    4.37 +
    4.38 +In this scenario, each node has two network cards in the cluster. One
    4.39 +network card is connected to the outside world and one network card is a
    4.40 +physically isolated management network specifically for Xen instances to
    4.41 +use.
    4.42 +
    4.43 +As long as all of the management partitions are trusted equally, this is
    4.44 +the most secure scenario. No additional configuration is needed other
    4.45 +than forcing Xend to bind to the management interface for relocation.
    4.46 +
    4.47 +\textbf{FIXME:} What is the option to allow for this?
    4.48 +
    4.49 +
    4.50 +\subsection{A Subnet Behind a Firewall}
    4.51 +
    4.52 +In this scenario, each node has only one network card but the entire
    4.53 +cluster sits behind a firewall. This firewall should do at least the
    4.54 +following:
    4.55 +
    4.56 +\begin{enumerate}
    4.57 +\item Prevent IP spoofing from outside of the subnet.
    4.58 +\item Prevent access to the relocation port of any of the nodes in the
    4.59 +  cluster except from within the cluster.
    4.60 +\end{enumerate}
    4.61 +
    4.62 +The following iptables rules can be used on each node to prevent
    4.63 +migrations to that node from outside the subnet assuming the main
    4.64 +firewall does not do this for you:
    4.65 +
    4.66 +\begin{verbatim}
    4.67 +# this command disables all access to the Xen relocation
    4.68 +# port:
    4.69 +iptables -A INPUT -p tcp --destination-port 8002 -j REJECT
    4.70 +
    4.71 +# this command enables Xen relocations only from the specific
    4.72 +# subnet:
    4.73 +iptables -I INPUT -p tcp -{}-source 192.168.1.1/8 \
    4.74 +    --destination-port 8002 -j ACCEPT
    4.75 +\end{verbatim}
    4.76 +
    4.77 +\subsection{Nodes on an Untrusted Subnet}
    4.78 +
    4.79 +Migration on an untrusted subnet is not safe in current versions of Xen.
    4.80 +It may be possible to perform migrations through a secure tunnel via an
    4.81 +VPN or SSH. The only safe option in the absence of a secure tunnel is to
    4.82 +disable migration completely. The easiest way to do this is with
    4.83 +iptables:
    4.84 +
    4.85 +\begin{verbatim}
    4.86 +# this command disables all access to the Xen relocation port
    4.87 +iptables -A INPUT -p tcp -{}-destination-port 8002 -j REJECT
    4.88 +\end{verbatim}
     5.1 --- a/docs/src/user/start_addl_dom.tex	Thu Nov 10 15:24:29 2005 -0600
     5.2 +++ b/docs/src/user/start_addl_dom.tex	Fri Nov 11 10:47:43 2005 +0100
     5.3 @@ -40,8 +40,7 @@ configuration file. We provide two examp
     5.4  a starting point:
     5.5  \begin{itemize}
     5.6  \item \path{/etc/xen/xmexample1} is a simple template configuration
     5.7 -  file for describing a single VM.
     5.8 -
     5.9 +  file for describing a single VM\@.
    5.10  \item \path{/etc/xen/xmexample2} file is a template description that
    5.11    is intended to be reused for multiple virtual machines.  Setting the
    5.12    value of the \path{vmid} variable on the \path{xm} command line
    5.13 @@ -54,17 +53,17 @@ you may wish to edit include:
    5.14  \begin{quote}
    5.15  \begin{description}
    5.16  \item[kernel] Set this to the path of the kernel you compiled for use
    5.17 -  with Xen (e.g.\ \path{kernel = `/boot/vmlinuz-2.6-xenU'})
    5.18 +  with Xen (e.g.\ \path{kernel = ``/boot/vmlinuz-2.6-xenU''})
    5.19  \item[memory] Set this to the size of the domain's memory in megabytes
    5.20    (e.g.\ \path{memory = 64})
    5.21  \item[disk] Set the first entry in this list to calculate the offset
    5.22 -  of the domain's root partition, based on the domain ID.  Set the
    5.23 +  of the domain's root partition, based on the domain ID\@.  Set the
    5.24    second to the location of \path{/usr} if you are sharing it between
    5.25 -  domains (e.g.\ \path{disk = [`phy:your\_hard\_drive\%d,sda1,w' \%
    5.26 +  domains (e.g.\ \path{disk = ['phy:your\_hard\_drive\%d,sda1,w' \%
    5.27      (base\_partition\_number + vmid),
    5.28 -    `phy:your\_usr\_partition,sda6,r' ]}
    5.29 +    'phy:your\_usr\_partition,sda6,r' ]}
    5.30  \item[dhcp] Uncomment the dhcp variable, so that the domain will
    5.31 -  receive its IP address from a DHCP server (e.g.\ \path{dhcp=`dhcp'})
    5.32 +  receive its IP address from a DHCP server (e.g.\ \path{dhcp=``dhcp''})
    5.33  \end{description}
    5.34  \end{quote}
    5.35  
    5.36 @@ -72,7 +71,7 @@ You may also want to edit the {\bf vif} 
    5.37  the MAC address of the virtual ethernet interface yourself.  For
    5.38  example:
    5.39  \begin{quote}
    5.40 -\verb_vif = [`mac=00:06:AA:F6:BB:B3']_
    5.41 +\verb_vif = ['mac=00:06:AA:F6:BB:B3']_
    5.42  \end{quote}
    5.43  If you do not set this variable, \xend\ will automatically generate a
    5.44  random MAC address from an unused range.
    5.45 @@ -116,6 +115,7 @@ distribution once they have mastered the
    5.46    section of the project's SourceForge site (see
    5.47    \path{http://sf.net/projects/xen/}).
    5.48  \item Create a configuration file like the following:
    5.49 +  \begin{quote}
    5.50  \begin{verbatim}
    5.51  kernel = "/boot/vmlinuz-2.6-xenU"
    5.52  memory = 64
    5.53 @@ -124,11 +124,14 @@ nics = 1
    5.54  ip = "1.2.3.4"
    5.55  disk = ['file:/path/to/ttylinux/rootfs,sda1,w']
    5.56  root = "/dev/sda1 ro"
    5.57 -\end{verbatim}
    5.58 +\end{verbatim}    
    5.59 +  \end{quote}
    5.60  \item Now start the domain and connect to its console:
    5.61 +  \begin{quote}
    5.62  \begin{verbatim}
    5.63  xm create configfile -c
    5.64  \end{verbatim}
    5.65 +  \end{quote}
    5.66  \item Login as root, password root.
    5.67  \end{enumerate}
    5.68  
     6.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Thu Nov 10 15:24:29 2005 -0600
     6.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Fri Nov 11 10:47:43 2005 +0100
     6.3 @@ -81,7 +81,7 @@ VM_MASK		= 0x00020000
     6.4  #define evtchn_upcall_pending		/* 0 */
     6.5  #define evtchn_upcall_mask		1
     6.6  
     6.7 -#define sizeof_vcpu_shift		3
     6.8 +#define sizeof_vcpu_shift		4
     6.9  
    6.10  #ifdef CONFIG_SMP
    6.11  #define preempt_disable(reg)	incl TI_preempt_count(reg)
    6.12 @@ -813,35 +813,9 @@ ENTRY(alignment_check)
    6.13  	pushl $do_alignment_check
    6.14  	jmp error_code
    6.15  
    6.16 -# This handler is special, because it gets an extra value on its stack,
    6.17 -# which is the linear faulting address.
    6.18 -# fastcall register usage:  %eax = pt_regs, %edx = error code,
    6.19 -#			    %ecx = fault address
    6.20  ENTRY(page_fault)
    6.21 -	pushl %ds
    6.22 -	pushl %eax
    6.23 -	xorl %eax, %eax
    6.24 -	pushl %ebp
    6.25 -	pushl %edi
    6.26 -	pushl %esi
    6.27 -	pushl %edx
    6.28 -	decl %eax			/* eax = -1 */
    6.29 -	pushl %ecx
    6.30 -	pushl %ebx
    6.31 -	cld
    6.32 -	pushl %es
    6.33 -#	UNWIND_ESPFIX_STACK
    6.34 -	popl %edi
    6.35 -	movl ES(%esp), %ecx		/* get the faulting address */
    6.36 -	movl ORIG_EAX(%esp), %edx	/* get the error code */
    6.37 -	movl %eax, ORIG_EAX(%esp)
    6.38 -	movl %edi, ES(%esp)
    6.39 -	movl $(__KERNEL_DS),%eax
    6.40 -	movl %eax, %ds
    6.41 -	movl %eax, %es
    6.42 -	movl %esp,%eax			/* pt_regs pointer */
    6.43 -	call do_page_fault
    6.44 -	jmp ret_from_exception
    6.45 +	pushl $do_page_fault
    6.46 +	jmp error_code
    6.47  
    6.48  #ifdef CONFIG_X86_MCE
    6.49  ENTRY(machine_check)
     7.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Thu Nov 10 15:24:29 2005 -0600
     7.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Fri Nov 11 10:47:43 2005 +0100
     7.3 @@ -650,7 +650,7 @@ fastcall void do_int3(struct pt_regs *re
     7.4  
     7.5  static inline void conditional_sti(struct pt_regs *regs)
     7.6  {
     7.7 -	if ((uint8_t)(regs->xcs >> 16) == 0)
     7.8 +	if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
     7.9  		local_irq_enable();
    7.10  }
    7.11  
    7.12 @@ -972,7 +972,7 @@ void __init trap_init_f00f_bug(void)
    7.13  
    7.14  
    7.15  /*
    7.16 - * NB. All these are "trap gates" (i.e. events_mask isn't cleared) except
    7.17 + * NB. All these are "trap gates" (i.e. events_mask isn't set) except
    7.18   * for those that specify <dpl>|4 in the second field.
    7.19   */
    7.20  static trap_info_t trap_table[] = {
    7.21 @@ -988,7 +988,7 @@ static trap_info_t trap_table[] = {
    7.22  	{ 11, 0, __KERNEL_CS, (unsigned long)segment_not_present	},
    7.23  	{ 12, 0, __KERNEL_CS, (unsigned long)stack_segment		},
    7.24  	{ 13, 0, __KERNEL_CS, (unsigned long)general_protection		},
    7.25 -	{ 14, 0, __KERNEL_CS, (unsigned long)page_fault			},
    7.26 +	{ 14, 0|4, __KERNEL_CS, (unsigned long)page_fault		},
    7.27  	{ 15, 0, __KERNEL_CS, (unsigned long)fixup_4gb_segment		},
    7.28  	{ 16, 0, __KERNEL_CS, (unsigned long)coprocessor_error		},
    7.29  	{ 17, 0, __KERNEL_CS, (unsigned long)alignment_check		},
     8.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c	Thu Nov 10 15:24:29 2005 -0600
     8.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c	Fri Nov 11 10:47:43 2005 +0100
     8.3 @@ -208,6 +208,7 @@ fastcall void do_invalid_op(struct pt_re
     8.4  static void dump_fault_path(unsigned long address)
     8.5  {
     8.6  	unsigned long *p, page;
     8.7 +	unsigned long mfn; 
     8.8  
     8.9  	preempt_disable();
    8.10  	page = __pa(per_cpu(cur_pgd, smp_processor_id()));
    8.11 @@ -217,20 +218,22 @@ static void dump_fault_path(unsigned lon
    8.12  	p += (address >> 30) * 2;
    8.13  	printk(KERN_ALERT "%08lx -> *pde = %08lx:%08lx\n", page, p[1], p[0]);
    8.14  	if (p[0] & 1) {
    8.15 -		page = p[0] & PAGE_MASK;
    8.16 +		mfn  = (p[0] >> PAGE_SHIFT) | ((p[1] & 0x7) << 20); 
    8.17 +		page = mfn_to_pfn(mfn) << PAGE_SHIFT; 
    8.18 +		p  = (unsigned long *)__va(page);
    8.19  		address &= 0x3fffffff;
    8.20 -		page = machine_to_phys(page);
    8.21 -		p  = (unsigned long *)__va(page);
    8.22  		p += (address >> 21) * 2;
    8.23 -		printk(KERN_ALERT "%08lx -> *pme = %08lx:%08lx\n", page, p[1], p[0]);
    8.24 +		printk(KERN_ALERT "%08lx -> *pme = %08lx:%08lx\n", 
    8.25 +		       page, p[1], p[0]);
    8.26  #ifndef CONFIG_HIGHPTE
    8.27  		if (p[0] & 1) {
    8.28 -			page = p[0] & PAGE_MASK;
    8.29 +			mfn  = (p[0] >> PAGE_SHIFT) | ((p[1] & 0x7) << 20); 
    8.30 +			page = mfn_to_pfn(mfn) << PAGE_SHIFT; 
    8.31 +			p  = (unsigned long *) __va(page);
    8.32  			address &= 0x001fffff;
    8.33 -			page = machine_to_phys(page);
    8.34 -			p  = (unsigned long *) __va(page);
    8.35  			p += (address >> 12) * 2;
    8.36 -			printk(KERN_ALERT "%08lx -> *pte = %08lx:%08lx\n", page, p[1], p[0]);
    8.37 +			printk(KERN_ALERT "%08lx -> *pte = %08lx:%08lx\n",
    8.38 +			       page, p[1], p[0]);
    8.39  		}
    8.40  #endif
    8.41  	}
    8.42 @@ -279,15 +282,18 @@ static void dump_fault_path(unsigned lon
    8.43   *	bit 1 == 0 means read, 1 means write
    8.44   *	bit 2 == 0 means kernel, 1 means user-mode
    8.45   */
    8.46 -fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code,
    8.47 -			      unsigned long address)
    8.48 +fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code)
    8.49  {
    8.50  	struct task_struct *tsk;
    8.51  	struct mm_struct *mm;
    8.52  	struct vm_area_struct * vma;
    8.53 +	unsigned long address;
    8.54  	int write;
    8.55  	siginfo_t info;
    8.56  
    8.57 +	address = HYPERVISOR_shared_info->vcpu_data[
    8.58 +		smp_processor_id()].arch.cr2;
    8.59 +
    8.60  	/* Set the "privileged fault" bit to something sane. */
    8.61  	error_code &= ~4;
    8.62  	error_code |= (regs->xcs & 2) << 1;
    8.63 @@ -297,11 +303,9 @@ fastcall void do_page_fault(struct pt_re
    8.64  	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
    8.65  					SIGSEGV) == NOTIFY_STOP)
    8.66  		return;
    8.67 -#if 0
    8.68  	/* It's safe to allow irq's after cr2 has been saved */
    8.69  	if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
    8.70  		local_irq_enable();
    8.71 -#endif
    8.72  
    8.73  	tsk = current;
    8.74  
     9.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Nov 10 15:24:29 2005 -0600
     9.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Fri Nov 11 10:47:43 2005 +0100
     9.3 @@ -342,8 +342,8 @@ int xen_create_contiguous_region(
     9.4  		mfn = pte_mfn(*pte);
     9.5  		BUG_ON(HYPERVISOR_update_va_mapping(
     9.6  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
     9.7 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
     9.8 -			INVALID_P2M_ENTRY;
     9.9 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
    9.10 +			INVALID_P2M_ENTRY);
    9.11  		BUG_ON(HYPERVISOR_memory_op(
    9.12  			XENMEM_decrease_reservation, &reservation) != 1);
    9.13  	}
    9.14 @@ -361,7 +361,7 @@ int xen_create_contiguous_region(
    9.15  			vstart + (i*PAGE_SIZE),
    9.16  			pfn_pte_ma(mfn+i, PAGE_KERNEL), 0));
    9.17  		xen_machphys_update(mfn+i, (__pa(vstart)>>PAGE_SHIFT)+i);
    9.18 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn+i;
    9.19 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn+i);
    9.20  	}
    9.21  
    9.22  	flush_tlb_all();
    9.23 @@ -383,7 +383,7 @@ int xen_create_contiguous_region(
    9.24  			vstart + (i*PAGE_SIZE),
    9.25  			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
    9.26  		xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
    9.27 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
    9.28 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
    9.29  	}
    9.30  
    9.31  	flush_tlb_all();
    9.32 @@ -422,8 +422,8 @@ void xen_destroy_contiguous_region(unsig
    9.33  		mfn = pte_mfn(*pte);
    9.34  		BUG_ON(HYPERVISOR_update_va_mapping(
    9.35  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
    9.36 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
    9.37 -			INVALID_P2M_ENTRY;
    9.38 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i,
    9.39 +			INVALID_P2M_ENTRY);
    9.40  		BUG_ON(HYPERVISOR_memory_op(
    9.41  			XENMEM_decrease_reservation, &reservation) != 1);
    9.42  	}
    9.43 @@ -436,7 +436,7 @@ void xen_destroy_contiguous_region(unsig
    9.44  			vstart + (i*PAGE_SIZE),
    9.45  			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
    9.46  		xen_machphys_update(mfn, (__pa(vstart)>>PAGE_SHIFT)+i);
    9.47 -		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] = mfn;
    9.48 +		set_phys_to_machine((__pa(vstart)>>PAGE_SHIFT)+i, mfn);
    9.49  	}
    9.50  
    9.51  	flush_tlb_all();
    10.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S	Thu Nov 10 15:24:29 2005 -0600
    10.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S	Fri Nov 11 10:47:43 2005 +0100
    10.3 @@ -874,42 +874,8 @@ 1:      RESTORE_ARGS
    10.4  	ret
    10.5  	CFI_ENDPROC
    10.6  
    10.7 -
    10.8 - /*
    10.9 - * Copy error_entry because of the different stack frame
   10.10 - */                        
   10.11  ENTRY(page_fault)
   10.12 -        movq (%rsp),%rcx
   10.13 -        movq 8(%rsp),%r11
   10.14 -        addq $0x10,%rsp         # now %rsp points to %cr2
   10.15 -        pushq %rax
   10.16 -        leaq do_page_fault(%rip),%rax
   10.17 -	cld	
   10.18 -	subq  $13*8,%rsp
   10.19 -	movq %rdx,12*8(%rsp)    # save %rdx
   10.20 -	movq 13*8(%rsp),%rdx	# load rax
   10.21 -	movq %rcx,11*8(%rsp)
   10.22 -	movq %rdx,10*8(%rsp)	# store rax
   10.23 -        movq %rsi,13*8(%rsp)    # now save %rsi
   10.24 -        movq 14*8(%rsp),%rdx    # load %cr2, 3rd argument
   10.25 -	movq %r8, 9*8(%rsp)
   10.26 -	movq %r9, 8*8(%rsp)
   10.27 -	movq %r10,7*8(%rsp)
   10.28 -	movq %r11,6*8(%rsp)
   10.29 -	movq %rbx,5*8(%rsp) 
   10.30 -	movq %rbp,4*8(%rsp) 
   10.31 -	movq %r12,3*8(%rsp) 
   10.32 -	movq %r13,2*8(%rsp) 
   10.33 -	movq %r14,1*8(%rsp) 
   10.34 -	movq %r15,(%rsp)
   10.35 -#if 0        
   10.36 -	cmpl $__KERNEL_CS,CS(%rsp)
   10.37 -	je  error_kernelspace
   10.38 -#endif
   10.39 -        /*
   10.40 -         * 1st and 2nd arguments are set by error_call_handler
   10.41 -         */
   10.42 -        jmp error_call_handler
   10.43 +	errorentry do_page_fault
   10.44  
   10.45  ENTRY(coprocessor_error)
   10.46  	zeroentry do_coprocessor_error
   10.47 @@ -948,24 +914,15 @@ ENTRY(nmi)
   10.48  paranoid_exit:
   10.49  	testl %ebx,%ebx				/* swapgs needed? */
   10.50  	jnz paranoid_restore
   10.51 +	testl $3,CS(%rsp)
   10.52 +	jnz   paranoid_userspace
   10.53  paranoid_swapgs:	
   10.54 -/*	swapgs */
   10.55 +	swapgs
   10.56  paranoid_restore:	
   10.57  	RESTORE_ALL 8
   10.58 -/*	iretq */
   10.59 +	iretq
   10.60  paranoid_userspace:	
   10.61  	GET_THREAD_INFO(%rcx)
   10.62 -#	movl threadinfo_flags(%rcx),%edx
   10.63 -#	testl $_TIF_NEED_RESCHED,%edx
   10.64 -#	jnz paranoid_resched
   10.65 -#	testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
   10.66 -#	jnz paranoid_signal
   10.67 -#	jmp paranoid_swapgs
   10.68 -#paranoid_resched:		
   10.69 -#/*	sti */
   10.70 -#	call schedule
   10.71 -#	jmp paranoid_exit
   10.72 -#paranoid_signal:		
   10.73  	movl threadinfo_flags(%rcx),%ebx
   10.74  	andl $_TIF_WORK_MASK,%ebx
   10.75  	jz paranoid_swapgs
   10.76 @@ -975,13 +932,10 @@ paranoid_userspace:
   10.77  	testl $_TIF_NEED_RESCHED,%ebx
   10.78  	jnz paranoid_schedule
   10.79  	movl %ebx,%edx			/* arg3: thread flags */
   10.80 -/*	sti */
   10.81 -#	xorl %esi,%esi /* oldset */
   10.82 -#	movq %rsp,%rdi /* &pt_regs */
   10.83 +	sti
   10.84  	xorl %esi,%esi 			/* arg2: oldset */
   10.85  	movq %rsp,%rdi 			/* arg1: &pt_regs */
   10.86  	call do_notify_resume
   10.87 -#	jmp paranoid_exit
   10.88  	cli
   10.89  	jmp paranoid_userspace
   10.90  paranoid_schedule:
   10.91 @@ -1057,4 +1011,3 @@ ENTRY(machine_check)
   10.92  ENTRY(call_debug)
   10.93         zeroentry do_call_debug
   10.94  
   10.95 -
    11.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/traps.c	Thu Nov 10 15:24:29 2005 -0600
    11.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/traps.c	Fri Nov 11 10:47:43 2005 +0100
    11.3 @@ -905,30 +905,33 @@ void do_call_debug(struct pt_regs *regs)
    11.4  }
    11.5  
    11.6  
    11.7 +/*
    11.8 + * NB. All these are "interrupt gates" (i.e. events_mask is set) because we
    11.9 + * specify <dpl>|4 in the second field.
   11.10 + */
   11.11  static trap_info_t trap_table[] = {
   11.12 -        {  0, 0, (__KERNEL_CS|0x3), (unsigned long)divide_error               },
   11.13 -        {  1, 0, (__KERNEL_CS|0x3), (unsigned long)debug                      },
   11.14 -        {  3, 3, (__KERNEL_CS|0x3), (unsigned long)int3                       },
   11.15 -        {  4, 3, (__KERNEL_CS|0x3), (unsigned long)overflow                   },
   11.16 -        {  5, 3, (__KERNEL_CS|0x3), (unsigned long)bounds                     },
   11.17 -        {  6, 0, (__KERNEL_CS|0x3), (unsigned long)invalid_op                 },
   11.18 -        {  7, 0, (__KERNEL_CS|0x3), (unsigned long)device_not_available       },
   11.19 -        {  9, 0, (__KERNEL_CS|0x3), (unsigned long)coprocessor_segment_overrun},
   11.20 -        { 10, 0, (__KERNEL_CS|0x3), (unsigned long)invalid_TSS                },
   11.21 -        { 11, 0, (__KERNEL_CS|0x3), (unsigned long)segment_not_present        },
   11.22 -        { 12, 0, (__KERNEL_CS|0x3), (unsigned long)stack_segment              },
   11.23 -        { 13, 0, (__KERNEL_CS|0x3), (unsigned long)general_protection         },
   11.24 -        { 14, 0, (__KERNEL_CS|0x3), (unsigned long)page_fault                 },
   11.25 -        { 15, 0, (__KERNEL_CS|0x3), (unsigned long)spurious_interrupt_bug     },
   11.26 -        { 16, 0, (__KERNEL_CS|0x3), (unsigned long)coprocessor_error          },
   11.27 -        { 17, 0, (__KERNEL_CS|0x3), (unsigned long)alignment_check            },
   11.28 +        {  0, 0|4, (__KERNEL_CS|0x3), (unsigned long)divide_error               },
   11.29 +        {  1, 0|4, (__KERNEL_CS|0x3), (unsigned long)debug                      },
   11.30 +        {  3, 3|4, (__KERNEL_CS|0x3), (unsigned long)int3                       },
   11.31 +        {  4, 3|4, (__KERNEL_CS|0x3), (unsigned long)overflow                   },
   11.32 +        {  5, 3|4, (__KERNEL_CS|0x3), (unsigned long)bounds                     },
   11.33 +        {  6, 0|4, (__KERNEL_CS|0x3), (unsigned long)invalid_op                 },
   11.34 +        {  7, 0|4, (__KERNEL_CS|0x3), (unsigned long)device_not_available       },
   11.35 +        {  9, 0|4, (__KERNEL_CS|0x3), (unsigned long)coprocessor_segment_overrun},
   11.36 +        { 10, 0|4, (__KERNEL_CS|0x3), (unsigned long)invalid_TSS                },
   11.37 +        { 11, 0|4, (__KERNEL_CS|0x3), (unsigned long)segment_not_present        },
   11.38 +        { 12, 0|4, (__KERNEL_CS|0x3), (unsigned long)stack_segment              },
   11.39 +        { 13, 0|4, (__KERNEL_CS|0x3), (unsigned long)general_protection         },
   11.40 +        { 14, 0|4, (__KERNEL_CS|0x3), (unsigned long)page_fault                 },
   11.41 +        { 15, 0|4, (__KERNEL_CS|0x3), (unsigned long)spurious_interrupt_bug     },
   11.42 +        { 16, 0|4, (__KERNEL_CS|0x3), (unsigned long)coprocessor_error          },
   11.43 +        { 17, 0|4, (__KERNEL_CS|0x3), (unsigned long)alignment_check            },
   11.44  #ifdef CONFIG_X86_MCE
   11.45 -        { 18, 0, (__KERNEL_CS|0x3), (unsigned long)machine_check              },
   11.46 +        { 18, 0|4, (__KERNEL_CS|0x3), (unsigned long)machine_check              },
   11.47  #endif
   11.48 -        { 19, 0, (__KERNEL_CS|0x3), (unsigned long)simd_coprocessor_error     },
   11.49 -        { SYSCALL_VECTOR, 3, (__KERNEL_CS|0x3), (unsigned long)system_call   },
   11.50 +        { 19, 0|4, (__KERNEL_CS|0x3), (unsigned long)simd_coprocessor_error     },
   11.51  #ifdef CONFIG_IA32_EMULATION
   11.52 -	{ IA32_SYSCALL_VECTOR, 3, (__KERNEL_CS|0x3), (unsigned long)ia32_syscall},
   11.53 +	{ IA32_SYSCALL_VECTOR, 3|4, (__KERNEL_CS|0x3), (unsigned long)ia32_syscall},
   11.54  #endif
   11.55          {  0, 0,           0, 0                                              }
   11.56  };
    12.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c	Thu Nov 10 15:24:29 2005 -0600
    12.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c	Fri Nov 11 10:47:43 2005 +0100
    12.3 @@ -128,8 +128,10 @@ EXPORT_SYMBOL(get_wchan);
    12.4  
    12.5  EXPORT_SYMBOL(rtc_lock);
    12.6  
    12.7 -/* EXPORT_SYMBOL_GPL(set_nmi_callback);
    12.8 -   EXPORT_SYMBOL_GPL(unset_nmi_callback); */
    12.9 +#ifdef CONFIG_X86_LOCAL_APIC
   12.10 +EXPORT_SYMBOL_GPL(set_nmi_callback);
   12.11 +EXPORT_SYMBOL_GPL(unset_nmi_callback);
   12.12 +#endif
   12.13  
   12.14  /* Export string functions. We normally rely on gcc builtin for most of these,
   12.15     but gcc sometimes decides not to inline them. */    
    13.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S	Thu Nov 10 15:24:29 2005 -0600
    13.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S	Fri Nov 11 10:47:43 2005 +0100
    13.3 @@ -5,7 +5,7 @@
    13.4  #define evtchn_upcall_pending		0
    13.5  #define evtchn_upcall_mask		1
    13.6  
    13.7 -#define sizeof_vcpu_shift		4
    13.8 +#define sizeof_vcpu_shift		5
    13.9  
   13.10  #ifdef CONFIG_SMP
   13.11  //#define preempt_disable(reg)	incl threadinfo_preempt_count(reg)
    14.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c	Thu Nov 10 15:24:29 2005 -0600
    14.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c	Fri Nov 11 10:47:43 2005 +0100
    14.3 @@ -318,12 +318,12 @@ int exception_trace = 1;
    14.4   *	bit 2 == 0 means kernel, 1 means user-mode
    14.5   *      bit 3 == 1 means fault was an instruction fetch
    14.6   */
    14.7 -asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code,
    14.8 -       unsigned long address)
    14.9 +asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
   14.10  {
   14.11  	struct task_struct *tsk;
   14.12  	struct mm_struct *mm;
   14.13  	struct vm_area_struct * vma;
   14.14 +	unsigned long address;
   14.15  	const struct exception_table_entry *fixup;
   14.16  	int write;
   14.17  	siginfo_t info;
   14.18 @@ -342,6 +342,11 @@ asmlinkage void do_page_fault(struct pt_
   14.19  		}
   14.20  	}
   14.21  #endif
   14.22 +
   14.23 +	/* get the address */
   14.24 +	address = HYPERVISOR_shared_info->vcpu_data[
   14.25 +		smp_processor_id()].arch.cr2;
   14.26 +
   14.27  	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
   14.28  					SIGSEGV) == NOTIFY_STOP)
   14.29  		return;
    15.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Nov 10 15:24:29 2005 -0600
    15.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Fri Nov 11 10:47:43 2005 +0100
    15.3 @@ -210,7 +210,7 @@ static int increase_reservation(unsigned
    15.4  		BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
    15.5  
    15.6  		/* Update P->M and M->P tables. */
    15.7 -		phys_to_machine_mapping[pfn] = mfn_list[i];
    15.8 +		set_phys_to_machine(pfn, mfn_list[i]);
    15.9  		xen_machphys_update(mfn_list[i], pfn);
   15.10              
   15.11  		/* Link back into the page tables if not highmem. */
   15.12 @@ -295,7 +295,7 @@ static int decrease_reservation(unsigned
   15.13  	/* No more mappings: invalidate P2M and add to balloon. */
   15.14  	for (i = 0; i < nr_pages; i++) {
   15.15  		pfn = mfn_to_pfn(mfn_list[i]);
   15.16 -		phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
   15.17 +		set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
   15.18  		balloon_append(pfn_to_page(pfn));
   15.19  	}
   15.20  
   15.21 @@ -515,8 +515,7 @@ static int dealloc_pte_fn(
   15.22  		.domid        = DOMID_SELF
   15.23  	};
   15.24  	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
   15.25 -	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
   15.26 -		INVALID_P2M_ENTRY;
   15.27 +	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
   15.28  	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
   15.29  	BUG_ON(ret != 1);
   15.30  	return 0;
    16.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Nov 10 15:24:29 2005 -0600
    16.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Fri Nov 11 10:47:43 2005 +0100
    16.3 @@ -386,9 +386,9 @@ static void dispatch_rw_block_io(blkif_t
    16.4  #ifdef __ia64__
    16.5  			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
    16.6  #else
    16.7 -			phys_to_machine_mapping[__pa(MMAP_VADDR(
    16.8 -				pending_idx, i)) >> PAGE_SHIFT] =
    16.9 -				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
   16.10 +			set_phys_to_machine(__pa(MMAP_VADDR(
   16.11 +				pending_idx, i)) >> PAGE_SHIFT,
   16.12 +				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
   16.13  #endif
   16.14  			fas        = req->frame_and_sects[i];
   16.15  			seg[i].buf = map[i].dev_bus_addr | 
    17.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Nov 10 15:24:29 2005 -0600
    17.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Fri Nov 11 10:47:43 2005 +0100
    17.3 @@ -777,8 +777,8 @@ static void dispatch_rw_block_io(blkif_t
    17.4  		/* Set the necessary mappings in p2m and in the VM_FOREIGN 
    17.5  		 * vm_area_struct to allow user vaddr -> struct page lookups
    17.6  		 * to work.  This is needed for direct IO to foreign pages. */
    17.7 -		phys_to_machine_mapping[__pa(kvaddr) >> PAGE_SHIFT] =
    17.8 -			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
    17.9 +		set_phys_to_machine(__pa(kvaddr) >> PAGE_SHIFT,
   17.10 +				FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
   17.11  
   17.12  		offset = (uvaddr - blktap_vma->vm_start) >> PAGE_SHIFT;
   17.13  		((struct page **)blktap_vma->vm_private_data)[offset] =
    18.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Thu Nov 10 15:24:29 2005 -0600
    18.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Nov 11 10:47:43 2005 +0100
    18.3 @@ -241,11 +241,7 @@ console_initcall(xen_console_init);
    18.4  #endif
    18.5  
    18.6  /*** Useful function for console debugging -- goes straight to Xen. ***/
    18.7 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
    18.8  asmlinkage int xprintk(const char *fmt, ...)
    18.9 -#else
   18.10 -asmlinkage int xprintk(const char *fmt, ...)
   18.11 -#endif
   18.12  {
   18.13  	va_list args;
   18.14  	int printk_len;
    19.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Nov 10 15:24:29 2005 -0600
    19.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Fri Nov 11 10:47:43 2005 +0100
    19.3 @@ -248,8 +248,7 @@ static void net_rx_action(unsigned long 
    19.4  		 * Set the new P2M table entry before reassigning the old data
    19.5  		 * page. Heed the comment in pgtable-2level.h:pte_page(). :-)
    19.6  		 */
    19.7 -		phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] =
    19.8 -			new_mfn;
    19.9 +		set_phys_to_machine(__pa(skb->data) >> PAGE_SHIFT, new_mfn);
   19.10  
   19.11  		MULTI_update_va_mapping(mcl, vdata,
   19.12  					pfn_pte_ma(new_mfn, PAGE_KERNEL), 0);
   19.13 @@ -631,9 +630,9 @@ static void net_tx_action(unsigned long 
   19.14  				pending_idx;
   19.15  			continue;
   19.16  		}
   19.17 -		phys_to_machine_mapping[
   19.18 -			__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
   19.19 -			FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT);
   19.20 +		set_phys_to_machine(
   19.21 +			__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
   19.22 +			FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
   19.23  		grant_tx_ref[pending_idx] = mop->handle;
   19.24  
   19.25  		data_len = (txreq.size > PKT_PROT_LEN) ?
    20.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Nov 10 15:24:29 2005 -0600
    20.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Nov 11 10:47:43 2005 +0100
    20.3 @@ -342,8 +342,7 @@ static void network_alloc_rx_buffers(str
    20.4  		rx_pfn_array[i] = virt_to_mfn(skb->head);
    20.5  
    20.6  		/* Remove this page from map before passing back to Xen. */
    20.7 -		phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
    20.8 -			= INVALID_P2M_ENTRY;
    20.9 +		set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
   20.10  
   20.11  		MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
   20.12  					__pte(0), 0);
   20.13 @@ -570,7 +569,7 @@ static int netif_poll(struct net_device 
   20.14  					pfn_pte_ma(mfn, PAGE_KERNEL), 0);
   20.15  		mcl++;
   20.16  
   20.17 -		phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = mfn;
   20.18 +		set_phys_to_machine(__pa(skb->head) >> PAGE_SHIFT, mfn);
   20.19  
   20.20  		__skb_queue_tail(&rxq, skb);
   20.21  	}
    21.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Nov 10 15:24:29 2005 -0600
    21.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Fri Nov 11 10:47:43 2005 +0100
    21.3 @@ -296,9 +296,8 @@ static int
    21.4  			DPRINTK(" Grant table operation failure !\n");
    21.5  			return 0;
    21.6  		}
    21.7 -		phys_to_machine_mapping[__pa(MMAP_VADDR(tpmif,i)) >>
    21.8 -					PAGE_SHIFT] =
    21.9 -			FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT);
   21.10 +		set_phys_to_machine(__pa(MMAP_VADDR(tpmif,i)) >> PAGE_SHIFT,
   21.11 +			FOREIGN_FRAME(map_op.dev_bus_addr >> PAGE_SHIFT));
   21.12  
   21.13  		tocopy = MIN(size - offset, PAGE_SIZE);
   21.14  
    22.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Nov 10 15:24:29 2005 -0600
    22.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Fri Nov 11 10:47:43 2005 +0100
    22.3 @@ -86,6 +86,11 @@ static inline unsigned long mfn_to_pfn(u
    22.4  	return pfn;
    22.5  }
    22.6  
    22.7 +static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
    22.8 +{
    22.9 +	phys_to_machine_mapping[pfn] = mfn;
   22.10 +}
   22.11 +
   22.12  /* Definitions for machine and pseudophysical addresses. */
   22.13  #ifdef CONFIG_X86_PAE
   22.14  typedef unsigned long long paddr_t;
    23.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Thu Nov 10 15:24:29 2005 -0600
    23.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Fri Nov 11 10:47:43 2005 +0100
    23.3 @@ -88,6 +88,11 @@ static inline unsigned long mfn_to_pfn(u
    23.4  	return pfn;
    23.5  }
    23.6  
    23.7 +static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
    23.8 +{
    23.9 +	phys_to_machine_mapping[pfn] = mfn;
   23.10 +}
   23.11 +
   23.12  /* Definitions for machine and pseudophysical addresses. */
   23.13  typedef unsigned long paddr_t;
   23.14  typedef unsigned long maddr_t;
    24.1 --- a/tools/examples/network-bridge	Thu Nov 10 15:24:29 2005 -0600
    24.2 +++ b/tools/examples/network-bridge	Fri Nov 11 10:47:43 2005 +0100
    24.3 @@ -16,29 +16,38 @@
    24.4  #
    24.5  # Usage:
    24.6  #
    24.7 -# network (start|stop|status) {VAR=VAL}*
    24.8 +# network-bridge (start|stop|status) {VAR=VAL}*
    24.9  #
   24.10  # Vars:
   24.11  #
   24.12 -# vifnum     Virtual device number to use (default 0). Numbers >=1
   24.13 +# vifnum     Virtual device number to use (default 0). Numbers >=8
   24.14  #            require the netback driver to have nloopbacks set to a
   24.15 -#            higher value than its default of 1.
   24.16 +#            higher value than its default of 8.
   24.17  # bridge     The bridge to use (default xenbr${vifnum}).
   24.18  # netdev     The interface to add to the bridge (default eth${vifnum}).
   24.19  # antispoof  Whether to use iptables to prevent spoofing (default no).
   24.20  #
   24.21 +# Internal Vars:
   24.22 +# pdev="p${netdev}"
   24.23 +# vdev="veth${vifnum}"
   24.24 +# vif0="vif0.${vifnum}"
   24.25 +#
   24.26  # start:
   24.27 -# Creates the bridge and enslaves netdev to it.
   24.28 -# Copies the IP addresses from netdev to the bridge.
   24.29 -# Deletes the routes to netdev and adds them on bridge.
   24.30 +# Creates the bridge
   24.31 +# Copies the IP and MAC addresses from netdev to vdev
   24.32 +# Renames netdev to be pdev 
   24.33 +# Renames vdev to be netdev 
   24.34 +# Enslaves pdev, vdev to bridge
   24.35  #
   24.36  # stop:
   24.37 -# Removes netdev from the bridge.
   24.38 -# Deletes the routes to bridge and adds them to netdev.
   24.39 +# Removes netdev from the bridge
   24.40 +# Transfers addresses, routes from netdev to pdev
   24.41 +# Renames netdev to vdev
   24.42 +# Renames pdev to netdev 
   24.43 +# Deletes bridge
   24.44  #
   24.45  # status:
   24.46 -# Print ifconfig for netdev and bridge.
   24.47 -# Print routes.
   24.48 +# Print addresses, interfaces, routes
   24.49  #
   24.50  #============================================================================
   24.51  
   24.52 @@ -97,7 +106,7 @@ s/inet/ip addr add/
   24.53  s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/[0-9]\+\)@\1@
   24.54  s/${src}/dev ${dst}/
   24.55  " | sh -e
   24.56 -    # Remove automatic routes on destionation device
   24.57 +    # Remove automatic routes on destination device
   24.58      ip route list | sed -ne "
   24.59  /dev ${dst}\( \|$\)/ {
   24.60    s/^/ip route del /
   24.61 @@ -105,17 +114,6 @@ s/${src}/dev ${dst}/
   24.62  }" | sh -e
   24.63  }
   24.64  
   24.65 -# Usage: del_addrs src
   24.66 -del_addrs () {
   24.67 -    local src=$1
   24.68 -    ip addr show dev ${src} | egrep '^ *inet ' | sed -e "
   24.69 -s/inet/ip addr del/
   24.70 -s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)/[0-9]\+@\1@
   24.71 -s/${src}/dev ${src}/
   24.72 -" | sh -e
   24.73 -    ip link set dev ${dst} up
   24.74 -}
   24.75 -
   24.76  # Usage: transfer_routes src dst
   24.77  # Get all IP routes to device $src, delete them, and
   24.78  # add the same routes to device $dst.
    25.1 --- a/tools/examples/xmexample.vmx	Thu Nov 10 15:24:29 2005 -0600
    25.2 +++ b/tools/examples/xmexample.vmx	Fri Nov 11 10:47:43 2005 +0100
    25.3 @@ -35,7 +35,11 @@ vcpus=1
    25.4  
    25.5  # Optionally define mac and/or bridge for the network interfaces.
    25.6  # Random MACs are assigned if not given.
    25.7 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ]
    25.8 +# nics default is 1
    25.9 +#vif = [ 'type=ioemu, mac=aa:00:00:00:00:11, bridge=xenbr0' ]
   25.10 +nics=1 
   25.11 +# type=ioemu specify the NIC is an ioemu device not netfront
   25.12 +vif = [ 'type=ioemu, bridge=xenbr0' ]
   25.13  
   25.14  #----------------------------------------------------------------------------
   25.15  # Define the disk devices you want the domain to have access to, and
   25.16 @@ -117,6 +121,11 @@ vncviewer=1
   25.17  #nographic=0
   25.18  
   25.19  
   25.20 +#-----------------------------------------------------------------------------
   25.21 +#   serial port re-direct to pty deivce, /dev/pts/n 
   25.22 +#   then xm console or minicom can connect
   25.23 +#serial='pty'
   25.24 +
   25.25  #----------------------------------------------------------------------------
   25.26  # enable ne2000, default = 0(use pcnet)
   25.27  ne2000=0
    26.1 --- a/tools/ioemu/target-i386-dm/Makefile	Thu Nov 10 15:24:29 2005 -0600
    26.2 +++ b/tools/ioemu/target-i386-dm/Makefile	Fri Nov 11 10:47:43 2005 +0100
    26.3 @@ -7,7 +7,7 @@ INSTALL_DIR := $(DESTDIR)/usr/$(LIBDIR)/
    26.4  TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
    26.5  VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
    26.6  DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
    26.7 -DEFINES+= -I$(XEN_ROOT)/tools/libxc
    26.8 +DEFINES+= -I$(XEN_ROOT)/tools/libxc -I$(XEN_ROOT)/tools/xenstore
    26.9  ifdef CONFIG_USER_ONLY
   26.10  VPATH+=:$(SRC_PATH)/linux-user
   26.11  DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
   26.12 @@ -188,7 +188,7 @@ endif
   26.13  #########################################################
   26.14  
   26.15  DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
   26.16 -LIBS+=-lm -L../../libxc -lxenctrl -lxenguest
   26.17 +LIBS+=-lm -L../../libxc -lxenctrl -lxenguest -L../../xenstore -lxenstore
   26.18  ifndef CONFIG_USER_ONLY
   26.19  LIBS+=-lz
   26.20  endif
    27.1 --- a/tools/ioemu/target-i386-dm/qemu-ifup	Thu Nov 10 15:24:29 2005 -0600
    27.2 +++ b/tools/ioemu/target-i386-dm/qemu-ifup	Fri Nov 11 10:47:43 2005 +0100
    27.3 @@ -7,4 +7,4 @@ echo 'config qemu network with xen bridg
    27.4  echo $*
    27.5  
    27.6  ifconfig $1 0.0.0.0 up
    27.7 -brctl addif xenbr0 $1
    27.8 +brctl addif $2 $1
    28.1 --- a/tools/ioemu/vl.c	Thu Nov 10 15:24:29 2005 -0600
    28.2 +++ b/tools/ioemu/vl.c	Fri Nov 11 10:47:43 2005 +0100
    28.3 @@ -76,6 +76,7 @@
    28.4  #endif /* CONFIG_SDL */
    28.5  
    28.6  #include "xenctrl.h"
    28.7 +#include "xs.h"
    28.8  #include "exec-all.h"
    28.9  
   28.10  //#define DO_TB_FLUSH
   28.11 @@ -123,6 +124,7 @@ int domid = -1;
   28.12  static char network_script[1024];
   28.13  int pit_min_timer_count = 0;
   28.14  int nb_nics;
   28.15 +char bridge[16];
   28.16  NetDriverState nd_table[MAX_NICS];
   28.17  QEMUTimer *gui_timer;
   28.18  QEMUTimer *polling_timer;
   28.19 @@ -1171,6 +1173,48 @@ CharDriverState *qemu_chr_open_stdio(voi
   28.20      return chr;
   28.21  }
   28.22  
   28.23 +int store_console_dev(int domid, char *pts)
   28.24 +{
   28.25 +    int xc_handle;
   28.26 +    unsigned int len = 0;
   28.27 +    struct xs_handle *xs;
   28.28 +    char *path;
   28.29 +
   28.30 +    xs = xs_daemon_open();
   28.31 +    if (xs == NULL) {
   28.32 +        fprintf(logfile, "Could not contact XenStore\n");
   28.33 +        return -1;
   28.34 +    }
   28.35 +
   28.36 +    xc_handle = xc_interface_open();
   28.37 +    if (xc_handle == -1) {
   28.38 +        fprintf(logfile, "xc_interface_open() error\n");
   28.39 +        return -1;
   28.40 +    }
   28.41 +    
   28.42 +    path = xs_get_domain_path(xs, domid);
   28.43 +    if (path == NULL) {
   28.44 +        fprintf(logfile, "xs_get_domain_path() error\n");
   28.45 +        return -1;
   28.46 +    }
   28.47 +    path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
   28.48 +    if (path == NULL) {
   28.49 +        fprintf(logfile, "realloc error\n");
   28.50 +        return -1;
   28.51 +    }
   28.52 +    strcat(path, "/console/tty");
   28.53 +    if (!xs_write(xs, NULL, path, pts, strlen(pts))) {
   28.54 +        fprintf(logfile, "xs_write for console fail");
   28.55 +        return -1;
   28.56 +    }
   28.57 +    
   28.58 +    free(path);
   28.59 +    xs_daemon_close(xs);
   28.60 +    close(xc_handle);
   28.61 +
   28.62 +    return 0;
   28.63 +}
   28.64 +
   28.65  #if defined(__linux__)
   28.66  CharDriverState *qemu_chr_open_pty(void)
   28.67  {
   28.68 @@ -1182,6 +1226,7 @@ CharDriverState *qemu_chr_open_pty(void)
   28.69          return NULL;
   28.70      }
   28.71      fprintf(stderr, "char device redirected to %s\n", slave_name);
   28.72 +    store_console_dev(domid, slave_name);
   28.73      return qemu_chr_open_fd(master_fd, master_fd);
   28.74  }
   28.75  #else
   28.76 @@ -1542,7 +1587,7 @@ static void tun_add_read_packet(NetDrive
   28.77  static int net_tun_init(NetDriverState *nd)
   28.78  {
   28.79      int pid, status;
   28.80 -    char *args[3];
   28.81 +    char *args[4];
   28.82      char **parg;
   28.83      extern int highest_fds;
   28.84  
   28.85 @@ -1558,6 +1603,7 @@ static int net_tun_init(NetDriverState *
   28.86              parg = args;
   28.87              *parg++ = network_script;
   28.88              *parg++ = nd->ifname;
   28.89 +            *parg++ = bridge;
   28.90              *parg++ = NULL;
   28.91              execv(network_script, args);
   28.92              exit(1);
   28.93 @@ -2163,6 +2209,7 @@ void help(void)
   28.94             "Network options:\n"
   28.95             "-nics n         simulate 'n' network cards [default=1]\n"
   28.96             "-macaddr addr   set the mac address of the first interface\n"
   28.97 +           "-bridge  br     set the bridge interface for nic\n"
   28.98             "-n script       set tap/tun network init script [default=%s]\n"
   28.99             "-tun-fd fd      use this fd as already opened tap/tun interface\n"
  28.100  #ifdef CONFIG_SLIRP
  28.101 @@ -2253,6 +2300,7 @@ enum {
  28.102  
  28.103      QEMU_OPTION_nics,
  28.104      QEMU_OPTION_macaddr,
  28.105 +    QEMU_OPTION_bridge,
  28.106      QEMU_OPTION_n,
  28.107      QEMU_OPTION_tun_fd,
  28.108      QEMU_OPTION_user_net,
  28.109 @@ -2323,6 +2371,7 @@ const QEMUOption qemu_options[] = {
  28.110  
  28.111      { "nics", HAS_ARG, QEMU_OPTION_nics},
  28.112      { "macaddr", HAS_ARG, QEMU_OPTION_macaddr},
  28.113 +    { "bridge", HAS_ARG, QEMU_OPTION_bridge},
  28.114      { "n", HAS_ARG, QEMU_OPTION_n },
  28.115      { "tun-fd", HAS_ARG, QEMU_OPTION_tun_fd },
  28.116  #ifdef CONFIG_SLIRP
  28.117 @@ -2701,7 +2750,9 @@ int main(int argc, char **argv)
  28.118                  break;
  28.119              case QEMU_OPTION_nographic:
  28.120                  pstrcpy(monitor_device, sizeof(monitor_device), "stdio");
  28.121 -                pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "stdio");
  28.122 +                if(!strcmp(serial_devices[0], "vc"))
  28.123 +                    pstrcpy(serial_devices[0], sizeof(serial_devices[0]),
  28.124 +                            "stdio");
  28.125                  nographic = 1;
  28.126                  break;
  28.127  #ifdef CONFIG_VNC
  28.128 @@ -2779,6 +2830,9 @@ int main(int argc, char **argv)
  28.129                      exit(1);
  28.130                  }
  28.131                  break;
  28.132 +            case QEMU_OPTION_bridge:
  28.133 +                pstrcpy(bridge, sizeof(bridge), optarg);
  28.134 +                break;
  28.135              case QEMU_OPTION_macaddr:
  28.136                  {
  28.137                      const char *p;
    29.1 --- a/tools/libxc/Makefile	Thu Nov 10 15:24:29 2005 -0600
    29.2 +++ b/tools/libxc/Makefile	Fri Nov 11 10:47:43 2005 +0100
    29.3 @@ -102,6 +102,7 @@ install: build
    29.4  	$(INSTALL_DATA) libxenguest.a $(DESTDIR)/usr/$(LIBDIR)
    29.5  	ln -sf libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxenguest.so.$(MAJOR)
    29.6  	ln -sf libxenguest.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenguest.so
    29.7 +	$(INSTALL_DATA) xenguest.h $(DESTDIR)/usr/include
    29.8  
    29.9  .PHONY: TAGS clean rpm install all
   29.10  
    30.1 --- a/tools/libxc/xc_vmx_build.c	Thu Nov 10 15:24:29 2005 -0600
    30.2 +++ b/tools/libxc/xc_vmx_build.c	Fri Nov 11 10:47:43 2005 +0100
    30.3 @@ -565,8 +565,10 @@ static int setup_guest(int xc_handle,
    30.4      return 0;
    30.5  
    30.6   error_out:
    30.7 -    free(mmu);
    30.8 -    free(page_array);
    30.9 +    if ( mmu != NULL )
   30.10 +        free(mmu);
   30.11 +    if ( page_array != NULL )
   30.12 +        free(page_array);
   30.13      return -1;
   30.14  }
   30.15  
   30.16 @@ -627,7 +629,7 @@ int xc_vmx_build(int xc_handle,
   30.17  
   30.18      if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
   30.19      {
   30.20 -        PERROR("xc_vmx_build: ctxt mlock failed");
   30.21 +        PERROR("%s: ctxt mlock failed", __func__);
   30.22          return 1;
   30.23      }
   30.24  
   30.25 @@ -661,7 +663,8 @@ int xc_vmx_build(int xc_handle,
   30.26          goto error_out;
   30.27      }
   30.28  
   30.29 -    free(image);
   30.30 +    if ( image != NULL )
   30.31 +        free(image);
   30.32  
   30.33      ctxt->flags = VGCF_VMX_GUEST;
   30.34      /* FPU is set up to default initial state. */
   30.35 @@ -707,7 +710,8 @@ int xc_vmx_build(int xc_handle,
   30.36      return rc;
   30.37  
   30.38   error_out:
   30.39 -    free(image);
   30.40 +    if ( image != NULL )
   30.41 +        free(image);
   30.42  
   30.43      return -1;
   30.44  }
    31.1 --- a/tools/pygrub/setup.py	Thu Nov 10 15:24:29 2005 -0600
    31.2 +++ b/tools/pygrub/setup.py	Fri Nov 11 10:47:43 2005 +0100
    31.3 @@ -34,6 +34,8 @@ if os.path.exists("/usr/include/reiserfs
    31.4      fsys_mods.append(reiser)
    31.5      fsys_pkgs.append("grub.fsys.reiser")
    31.6  
    31.7 +pkgs = ['grub', 'grub.fsys']
    31.8 +pkgs.extend(fsys_pkgs)
    31.9  setup(name='pygrub',
   31.10        version='0.3',
   31.11        description='Boot loader that looks a lot like grub for Xen',
   31.12 @@ -42,8 +44,7 @@ setup(name='pygrub',
   31.13        license='GPL',
   31.14        package_dir={'grub': 'src'},
   31.15        scripts = ["src/pygrub"],
   31.16 -      packages=['grub',
   31.17 -                'grub.fsys'].extend(fsys_pkgs),
   31.18 +      packages=pkgs,
   31.19        ext_modules = fsys_mods
   31.20        )
   31.21                 
    32.1 --- a/tools/pygrub/src/pygrub	Thu Nov 10 15:24:29 2005 -0600
    32.2 +++ b/tools/pygrub/src/pygrub	Fri Nov 11 10:47:43 2005 +0100
    32.3 @@ -89,8 +89,8 @@ def get_active_offset(file):
    32.4      buf = os.read(fd, 512)
    32.5      for poff in (446, 462, 478, 494): # partition offsets
    32.6          # active partition has 0x80 as the first byte
    32.7 -        if struct.unpack("<c", buf[p:p+1]) == ('\x80',):
    32.8 -            return struct.unpack("<", buf[p+8:p+12])[0] * SECTOR_SIZE
    32.9 +        if struct.unpack("<c", buf[poff:poff+1]) == ('\x80',):
   32.10 +            return struct.unpack("<L", buf[poff+8:poff+12])[0] * SECTOR_SIZE
   32.11      return -1
   32.12  
   32.13  def get_config(fn):
   32.14 @@ -113,11 +113,13 @@ def get_config(fn):
   32.15              break
   32.16  
   32.17      if fs is not None:
   32.18 -        if fs.file_exist("/boot/grub/menu.lst"):
   32.19 -            grubfile = "/boot/grub/menu.lst"
   32.20 -        elif fs.file_exist("/boot/grub/grub.conf"):
   32.21 -            grubfile = "/boot/grub/grub.conf"
   32.22 -        else:
   32.23 +        grubfile = None
   32.24 +        for f in ("/boot/grub/menu.lst", "/boot/grub/grub.conf",
   32.25 +                  "/grub/menu.lst", "/grub/grub.conf"):
   32.26 +            if fs.file_exist(f):
   32.27 +                grubfile = f
   32.28 +                break
   32.29 +        if grubfile is None:
   32.30              raise RuntimeError, "we couldn't find /boot/grub{menu.lst,grub.conf} " + \
   32.31                                  "in the image provided. halt!"
   32.32          f = fs.open_file(grubfile)
   32.33 @@ -169,7 +171,7 @@ def main(cf = None):
   32.34  #        if c == ord('q'):
   32.35  #            selected = -1
   32.36  #            break
   32.37 -        elif c == ord('c'):
   32.38 +        if c == ord('c'):
   32.39              # FIXME: needs to go to command line mode
   32.40              continue
   32.41          elif c == ord('a'):
   32.42 @@ -261,7 +263,7 @@ if __name__ == "__main__":
   32.43  
   32.44      offset = 0
   32.45      if is_disk_image(file):
   32.46 -        offset = get_active_offset(fn)
   32.47 +        offset = get_active_offset(file)
   32.48          if offset == -1:
   32.49              raise RuntimeError, "Unable to find active partition on disk"
   32.50  
    33.1 --- a/tools/python/xen/xend/image.py	Thu Nov 10 15:24:29 2005 -0600
    33.2 +++ b/tools/python/xen/xend/image.py	Fri Nov 11 10:47:43 2005 +0100
    33.3 @@ -258,6 +258,7 @@ class VmxImageHandler(ImageHandler):
    33.4              log.debug("args: %s, val: %s" % (a,v))
    33.5  
    33.6          # Handle disk/network related options
    33.7 +        mac = None
    33.8          for (name, info) in deviceConfig:
    33.9              if name == 'vbd':
   33.10                 uname = sxp.child_value(info, 'uname')
   33.11 @@ -276,11 +277,21 @@ class VmxImageHandler(ImageHandler):
   33.12                 ret.append("-%s" % vbddev)
   33.13                 ret.append("%s" % vbdparam)
   33.14              if name == 'vif':
   33.15 +               type = sxp.child_value(info, 'type')
   33.16 +               if type != 'ioemu':
   33.17 +                   continue
   33.18 +               if mac != None:
   33.19 +                   continue
   33.20                 mac = sxp.child_value(info, 'mac')
   33.21 +               bridge = sxp.child_value(info, 'bridge')
   33.22                 if mac == None:
   33.23                     mac = randomMAC()
   33.24 +               if bridge == None:
   33.25 +                   bridge = 'xenbr0'
   33.26                 ret.append("-macaddr")
   33.27                 ret.append("%s" % mac)
   33.28 +               ret.append("-bridge")
   33.29 +               ret.append("%s" % bridge)
   33.30              if name == 'vtpm':
   33.31                 instance = sxp.child_value(info, 'instance')
   33.32                 ret.append("-instance")
    34.1 --- a/tools/python/xen/xend/server/netif.py	Thu Nov 10 15:24:29 2005 -0600
    34.2 +++ b/tools/python/xen/xend/server/netif.py	Fri Nov 11 10:47:43 2005 +0100
    34.3 @@ -71,6 +71,9 @@ class NetifController(DevController):
    34.4          script = os.path.join(xroot.network_script_dir,
    34.5                                sxp.child_value(config, 'script',
    34.6                                                xroot.get_vif_script()))
    34.7 +        type = sxp.child_value(config, 'type')
    34.8 +        if type == 'ioemu':
    34.9 +            return (None,{},{})
   34.10          bridge = sxp.child_value(config, 'bridge')
   34.11          mac    = sxp.child_value(config, 'mac')
   34.12          ipaddr = _get_config_ipaddr(config)
    35.1 --- a/tools/python/xen/xm/create.py	Thu Nov 10 15:24:29 2005 -0600
    35.2 +++ b/tools/python/xen/xm/create.py	Fri Nov 11 10:47:43 2005 +0100
    35.3 @@ -255,10 +255,11 @@ gopts.var('ipaddr', val="IPADDR",
    35.4            fn=append_value, default=[],
    35.5            use="Add an IP address to the domain.")
    35.6  
    35.7 -gopts.var('vif', val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
    35.8 +gopts.var('vif', val="type=TYPE,mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
    35.9            fn=append_value, default=[],
   35.10            use="""Add a network interface with the given MAC address and bridge.
   35.11            The vif is configured by calling the given configuration script.
   35.12 +          If type is not specified, default is netfront not ioemu device.
   35.13            If mac is not specified a random MAC address is used.
   35.14            The MAC address of the backend interface can be selected with be_mac.
   35.15            If not specified then the network backend chooses it's own MAC address.
   35.16 @@ -356,10 +357,6 @@ gopts.var('cdrom', val='FILE',
   35.17            fn=set_value, default='',
   35.18            use="Path to cdrom")
   35.19  
   35.20 -gopts.var('macaddr', val='MACADDR',
   35.21 -          fn=set_value, default='',
   35.22 -          use="Macaddress of the first network interface")
   35.23 -
   35.24  gopts.var('boot', val="a|b|c|d",
   35.25            fn=set_value, default='c',
   35.26            use="Default boot device")
   35.27 @@ -512,6 +509,7 @@ def configure_vifs(config_devs, vals):
   35.28              backend = d.get('backend')
   35.29              ip = d.get('ip')
   35.30              vifname = d.get('vifname')
   35.31 +            type = d.get('type')
   35.32          else:
   35.33              mac = None
   35.34              be_mac = None
   35.35 @@ -520,6 +518,7 @@ def configure_vifs(config_devs, vals):
   35.36              backend = None
   35.37              ip = None
   35.38              vifname = None
   35.39 +            type = None
   35.40          config_vif = ['vif']
   35.41          if mac:
   35.42              config_vif.append(['mac', mac])
   35.43 @@ -535,6 +534,8 @@ def configure_vifs(config_devs, vals):
   35.44              config_vif.append(['backend', backend])
   35.45          if ip:
   35.46              config_vif.append(['ip', ip])
   35.47 +        if type:
   35.48 +            config_vif.append(['type', type])
   35.49          config_devs.append(['device', config_vif])
   35.50  
   35.51  def configure_vfr(config, vals):
   35.52 @@ -549,7 +550,7 @@ def configure_vmx(config_image, vals):
   35.53      """Create the config for VMX devices.
   35.54      """
   35.55      args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
   35.56 -             'localtime', 'serial', 'macaddr', 'stdvga', 'isa', 'nographic',
   35.57 +             'localtime', 'serial', 'stdvga', 'isa', 'nographic',
   35.58               'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic']
   35.59      for a in args:
   35.60          if (vals.__dict__[a]):
   35.61 @@ -662,7 +663,7 @@ def preprocess_vifs(vals):
   35.62              (k, v) = b.strip().split('=', 1)
   35.63              k = k.strip()
   35.64              v = v.strip()
   35.65 -            if k not in ['mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 'vifname']:
   35.66 +            if k not in ['type', 'mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 'vifname']:
   35.67                  err('Invalid vif specifier: ' + vif)
   35.68              d[k] = v
   35.69          vifs.append(d)
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/tools/python/xen/xm/tests/__init__.py	Fri Nov 11 10:47:43 2005 +0100
    36.3 @@ -0,0 +1,2 @@
    36.4 +
    36.5 +
    37.1 --- a/tools/xenstore/xenstored_core.c	Thu Nov 10 15:24:29 2005 -0600
    37.2 +++ b/tools/xenstore/xenstored_core.c	Fri Nov 11 10:47:43 2005 +0100
    37.3 @@ -56,6 +56,7 @@ extern int eventchn_fd; /* in xenstored_
    37.4  static bool verbose;
    37.5  LIST_HEAD(connections);
    37.6  static int tracefd = -1;
    37.7 +static int reopen_log_pipe[2];
    37.8  static char *tracefile = NULL;
    37.9  static TDB_CONTEXT *tdb_ctx;
   37.10  
   37.11 @@ -243,21 +244,35 @@ void trace(const char *fmt, ...)
   37.12  	talloc_free(str);
   37.13  }
   37.14  
   37.15 -void reopen_log()
   37.16 +
   37.17 +/**
   37.18 + * Signal handler for SIGHUP, which requests that the trace log is reopened
   37.19 + * (in the main loop).  A single byte is written to reopen_log_pipe, to awaken
   37.20 + * the select() in the main loop.
   37.21 + */
   37.22 +static void trigger_reopen_log(int signal __attribute__((unused)))
   37.23  {
   37.24 -	if (!tracefile)
   37.25 -		return;
   37.26 +	char c = 'A';
   37.27 +	write(reopen_log_pipe[1], &c, 1);
   37.28 +}
   37.29 +
   37.30  
   37.31 -	if (tracefd > 0)
   37.32 -		close(tracefd);
   37.33 -	tracefd = open(tracefile, O_WRONLY|O_CREAT|O_APPEND, 0600);
   37.34 -	if (tracefd < 0) {
   37.35 -		perror("Could not open tracefile");
   37.36 -		return;
   37.37 +static void reopen_log()
   37.38 +{
   37.39 +	if (tracefile) {
   37.40 +		if (tracefd > 0)
   37.41 +			close(tracefd);
   37.42 +
   37.43 +		tracefd = open(tracefile, O_WRONLY|O_CREAT|O_APPEND, 0600);
   37.44 +
   37.45 +		if (tracefd < 0)
   37.46 +			perror("Could not open tracefile");
   37.47 +		else
   37.48 +			write(tracefd, "\n***\n", strlen("\n***\n"));
   37.49  	}
   37.50 -	write(tracefd, "\n***\n", strlen("\n***\n"));
   37.51  }
   37.52  
   37.53 +
   37.54  static bool write_messages(struct connection *conn)
   37.55  {
   37.56  	int ret;
   37.57 @@ -331,29 +346,33 @@ static int destroy_conn(void *_conn)
   37.58  	return 0;
   37.59  }
   37.60  
   37.61 +
   37.62 +static void set_fd(int fd, fd_set *set, int *max)
   37.63 +{
   37.64 +	FD_SET(fd, set);
   37.65 +	if (fd > *max)
   37.66 +		*max = fd;
   37.67 +}
   37.68 +
   37.69 +
   37.70  static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock)
   37.71  {
   37.72  	struct connection *i;
   37.73 -	int max;
   37.74 +	int max = -1;
   37.75  
   37.76  	FD_ZERO(inset);
   37.77  	FD_ZERO(outset);
   37.78 -	FD_SET(sock, inset);
   37.79 -	max = sock;
   37.80 -	FD_SET(ro_sock, inset);
   37.81 -	if (ro_sock > max)
   37.82 -		max = ro_sock;
   37.83 -	FD_SET(eventchn_fd, inset);
   37.84 -	if (eventchn_fd > max)
   37.85 -		max = eventchn_fd;
   37.86 +
   37.87 +	set_fd(sock,               inset, &max);
   37.88 +	set_fd(ro_sock,            inset, &max);
   37.89 +	set_fd(eventchn_fd,        inset, &max);
   37.90 +	set_fd(reopen_log_pipe[0], inset, &max);
   37.91  	list_for_each_entry(i, &connections, list) {
   37.92  		if (i->domain)
   37.93  			continue;
   37.94 -		FD_SET(i->fd, inset);
   37.95 +		set_fd(i->fd, inset, &max);
   37.96  		if (!list_empty(&i->out_list))
   37.97  			FD_SET(i->fd, outset);
   37.98 -		if (i->fd > max)
   37.99 -			max = i->fd;
  37.100  	}
  37.101  	return max;
  37.102  }
  37.103 @@ -1570,6 +1589,10 @@ int main(int argc, char *argv[])
  37.104  	    || listen(*ro_sock, 1) != 0)
  37.105  		barf_perror("Could not listen on sockets");
  37.106  
  37.107 +	if (pipe(reopen_log_pipe)) {
  37.108 +		barf_perror("pipe");
  37.109 +	}
  37.110 +
  37.111  	/* Setup the database */
  37.112  	setup_structure();
  37.113  
  37.114 @@ -1592,7 +1615,7 @@ int main(int argc, char *argv[])
  37.115  		close(STDERR_FILENO);
  37.116  	}
  37.117  
  37.118 -	signal(SIGHUP, reopen_log);
  37.119 +	signal(SIGHUP, trigger_reopen_log);
  37.120  
  37.121  #ifdef TESTING
  37.122  	signal(SIGUSR1, stop_failtest);
  37.123 @@ -1612,6 +1635,12 @@ int main(int argc, char *argv[])
  37.124  			barf_perror("Select failed");
  37.125  		}
  37.126  
  37.127 +		if (FD_ISSET(reopen_log_pipe[0], &inset)) {
  37.128 +			char c;
  37.129 +			read(reopen_log_pipe[0], &c, 1);
  37.130 +			reopen_log();
  37.131 +		}
  37.132 +
  37.133  		if (FD_ISSET(*sock, &inset))
  37.134  			accept_connection(*sock, true);
  37.135  
    38.1 --- a/tools/xm-test/lib/XmTestLib/Console.py	Thu Nov 10 15:24:29 2005 -0600
    38.2 +++ b/tools/xm-test/lib/XmTestLib/Console.py	Fri Nov 11 10:47:43 2005 +0100
    38.3 @@ -23,13 +23,13 @@
    38.4       a _very_ specific value, set in the PROMPT
    38.5       variable of this script
    38.6  """
    38.7 -import sys;
    38.8 -import os;
    38.9 -import pty;
   38.10 -import tty;
   38.11 -import termios;
   38.12 -import fcntl;
   38.13 -import select;
   38.14 +import sys
   38.15 +import os
   38.16 +import pty
   38.17 +import tty
   38.18 +import termios
   38.19 +import fcntl
   38.20 +import select
   38.21  
   38.22  from Test import *
   38.23  
   38.24 @@ -52,15 +52,15 @@ class XmConsole:
   38.25                              are included in the history buffer
   38.26          """
   38.27  
   38.28 -        self.TIMEOUT          = 30;
   38.29 -        self.PROMPT           = "@%@%> ";
   38.30 -        self.domain           = domain;
   38.31 -        self.historyBuffer    = [];
   38.32 -        self.historyLines     = 0;
   38.33 -        self.historyLimit     = historyLimit;
   38.34 -        self.historySaveAll   = historySaveAll;
   38.35 -        self.historySaveCmds  = historySaveCmds;
   38.36 -        self.debugMe          = False;
   38.37 +        self.TIMEOUT          = 30
   38.38 +        self.PROMPT           = "@%@%> "
   38.39 +        self.domain           = domain
   38.40 +        self.historyBuffer    = []
   38.41 +        self.historyLines     = 0
   38.42 +        self.historyLimit     = historyLimit
   38.43 +        self.historySaveAll   = historySaveAll
   38.44 +        self.historySaveCmds  = historySaveCmds
   38.45 +        self.debugMe          = False
   38.46          self.limit            = None
   38.47  
   38.48          consoleCmd = ["/usr/sbin/xm", "xm", "console", domain]
   38.49 @@ -68,62 +68,62 @@ class XmConsole:
   38.50          if verbose:
   38.51              print "Console executing: " + str(consoleCmd)
   38.52  
   38.53 -        pid, fd = pty.fork();
   38.54 +        pid, fd = pty.fork()
   38.55  
   38.56          if pid == 0:
   38.57 -            os.execvp("/usr/sbin/xm", consoleCmd[1:]);
   38.58 +            os.execvp("/usr/sbin/xm", consoleCmd[1:])
   38.59  
   38.60 -        self.consolePid = pid;
   38.61 -        self.consoleFd  = fd;
   38.62 +        self.consolePid = pid
   38.63 +        self.consoleFd  = fd
   38.64  
   38.65 -        tty.setraw(self.consoleFd, termios.TCSANOW);
   38.66 +        tty.setraw(self.consoleFd, termios.TCSANOW)
   38.67              
   38.68          bytes = self.__chewall(self.consoleFd)
   38.69          if bytes < 0:
   38.70              raise ConsoleError("Console didn't respond")
   38.71  
   38.72      def __addToHistory(self, line):
   38.73 -        self.historyBuffer.append(line);
   38.74 -        self.historyLines += 1;
   38.75 +        self.historyBuffer.append(line)
   38.76 +        self.historyLines += 1
   38.77          if self.historyLines > self.historyLimit:
   38.78 -            self.historyBuffer = self.historyBuffer[1:];
   38.79 -            self.historyLines -= 1;
   38.80 +            self.historyBuffer = self.historyBuffer[1:]
   38.81 +            self.historyLines -= 1
   38.82  
   38.83  
   38.84      def clearHistory(self):
   38.85          """Clear the history buffer"""
   38.86 -        self.historyBuffer = [];
   38.87 -        self.historyLines = 0;
   38.88 +        self.historyBuffer = []
   38.89 +        self.historyLines = 0
   38.90  
   38.91  
   38.92      def getHistory(self):
   38.93          """Returns a string containing the entire history buffer"""
   38.94 -        output = "";
   38.95 +        output = ""
   38.96  
   38.97          for line in self.historyBuffer:
   38.98 -            output += line + "\n";
   38.99 +            output += line + "\n"
  38.100  
  38.101 -        return output;
  38.102 +        return output
  38.103  
  38.104  
  38.105      def setTimeout(self, timeout):
  38.106          """Sets the timeout used to determine if a remote command
  38.107          has blocked"""
  38.108 -        self.TIMEOUT = timeout;
  38.109 +        self.TIMEOUT = timeout
  38.110  
  38.111  
  38.112      def setPrompt(self, prompt):
  38.113          """Sets the string key used to delimit the end of command
  38.114          output"""
  38.115 -        self.PROMPT = prompt;
  38.116 +        self.PROMPT = prompt
  38.117  
  38.118  
  38.119      def __chewall(self, fd):
  38.120 -        timeout = 0;
  38.121 -        bytes   = 0;
  38.122 +        timeout = 0
  38.123 +        bytes   = 0
  38.124          
  38.125          while timeout < 3:
  38.126 -            i, o, e = select.select([fd], [], [], 1);
  38.127 +            i, o, e = select.select([fd], [], [], 1)
  38.128              if fd in i:
  38.129                  try:
  38.130                      foo = os.read(fd, 1)
  38.131 @@ -143,7 +143,7 @@ class XmConsole:
  38.132          if self.debugMe:
  38.133              print "Ignored %i bytes of miscellaneous console output" % bytes
  38.134          
  38.135 -        return bytes;
  38.136 +        return bytes
  38.137  
  38.138  
  38.139      def __runCmd(self, command, saveHistory=True):
  38.140 @@ -152,15 +152,15 @@ class XmConsole:
  38.141          lines  = 0
  38.142          bytes  = 0
  38.143  
  38.144 -        self.__chewall(self.consoleFd);
  38.145 +        self.__chewall(self.consoleFd)
  38.146  
  38.147          if verbose:
  38.148              print "[%s] Sending `%s'" % (self.domain, command)
  38.149  
  38.150 -        os.write(self.consoleFd, "%s\n" % command);
  38.151 +        os.write(self.consoleFd, "%s\n" % command)
  38.152  
  38.153          while 1==1:
  38.154 -            i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT);
  38.155 +            i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT)
  38.156  
  38.157              if self.consoleFd in i:
  38.158                  try:
  38.159 @@ -182,59 +182,59 @@ class XmConsole:
  38.160                  if lines > 0:
  38.161                      output += line + "\n"
  38.162                      if saveHistory:
  38.163 -                        self.__addToHistory(line);
  38.164 +                        self.__addToHistory(line)
  38.165                  elif self.historySaveCmds and saveHistory:
  38.166 -                    self.__addToHistory("*" + line);
  38.167 -                lines += 1;
  38.168 -                line = "";
  38.169 +                    self.__addToHistory("*" + line)
  38.170 +                lines += 1
  38.171 +                line = ""
  38.172              elif str == "\r":
  38.173                  pass # ignore \r's
  38.174              else:
  38.175 -                line += str;
  38.176 +                line += str
  38.177  
  38.178              if line == self.PROMPT:
  38.179 -                break;
  38.180 +                break
  38.181  
  38.182 -        return output;
  38.183 +        return output
  38.184  
  38.185  
  38.186      def runCmd(self, command):
  38.187          """Runs a command on the remote terminal and returns the output
  38.188          as well as the return code.  For example:
  38.189          
  38.190 -        ret = c.runCmd("ls");
  38.191 -        print ret["output"];
  38.192 -        sys.exit(run["return"]);
  38.193 +        ret = c.runCmd("ls")
  38.194 +        print ret["output"]
  38.195 +        sys.exit(run["return"])
  38.196          
  38.197          """
  38.198  
  38.199          # Allow exceptions to bubble up
  38.200 -        realOutput = self.__runCmd(command);
  38.201 -        retOutput  = self.__runCmd("echo $?", saveHistory=False);
  38.202 +        realOutput = self.__runCmd(command)
  38.203 +        retOutput  = self.__runCmd("echo $?", saveHistory=False)
  38.204  
  38.205          try:
  38.206 -            retCode =  int(retOutput);
  38.207 +            retCode =  int(retOutput)
  38.208          except:
  38.209 -            retCode = 255;
  38.210 +            retCode = 255
  38.211          return {
  38.212              "output": realOutput,
  38.213              "return": retCode,
  38.214 -            };
  38.215 +            }
  38.216  
  38.217      def sendInput(self, input):
  38.218          """Sends input to the remote terminal, but doesn't check
  38.219          for a return code"""
  38.220 -        realOutput = self.__runCmd(input);
  38.221 +        realOutput = self.__runCmd(input)
  38.222          return {
  38.223              "output": realOutput,
  38.224              "return": 0,
  38.225 -            };
  38.226 +            }
  38.227  
  38.228      def closeConsole(self):
  38.229          """Closes the console connection and ensures that the console
  38.230          process is killed"""
  38.231 -        os.close(self.consoleFd);
  38.232 -        os.kill(self.consolePid, 2);
  38.233 +        os.close(self.consoleFd)
  38.234 +        os.kill(self.consolePid, 2)
  38.235  
  38.236  
  38.237      def setLimit(self, limit):
  38.238 @@ -254,23 +254,23 @@ if __name__ == "__main__":
  38.239      code as the domU command.
  38.240      """
  38.241  
  38.242 -    verbose = True;
  38.243 +    verbose = True
  38.244      
  38.245      try:
  38.246 -        t = XmConsole(sys.argv[1]);
  38.247 +        t = XmConsole(sys.argv[1])
  38.248      except ConsoleError, e:
  38.249          print "Failed to attach to console (%s)" % str(e)
  38.250          sys.exit(255)
  38.251  
  38.252      try:
  38.253 -        run = t.runCmd(sys.argv[2]);
  38.254 +        run = t.runCmd(sys.argv[2])
  38.255      except ConsoleError, e:
  38.256          print "Console failed (%)" % str(e)
  38.257          sys.exit(255)
  38.258          
  38.259 -    t.closeConsole();
  38.260 +    t.closeConsole()
  38.261      
  38.262 -    print run["output"],;
  38.263 -    sys.exit(run["return"]);
  38.264 +    print run["output"],
  38.265 +    sys.exit(run["return"])
  38.266      
  38.267          
    39.1 --- a/tools/xm-test/lib/XmTestReport/xmtest.py	Thu Nov 10 15:24:29 2005 -0600
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,3 +0,0 @@
    39.4 -#!/usr/bin/python
    39.5 -
    39.6 -XM_TEST_VERSION = "0.4.0"
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/tools/xm-test/mergereport	Fri Nov 11 10:47:43 2005 +0100
    40.3 @@ -0,0 +1,25 @@
    40.4 +#!/bin/sh
    40.5 +
    40.6 +# Dan Smith <danms@us.ibm.com> - 16-Sep-2005
    40.7 +#
    40.8 +# This script takes all the .report files in the current
    40.9 +# directory and generates a summary table, showing the 
   40.10 +# number of PASS, FAIL, XPASS, and XFAIL tests in each 
   40.11 +# report
   40.12 +
   40.13 +
   40.14 +echo "            Platform | PASS | FAIL | XPASS | XFAIL |"
   40.15 +echo "---------------------+------+------+-------+-------+"
   40.16 +
   40.17 +for r in *.report; do
   40.18 +    
   40.19 +    mach=$(basename $r .report)
   40.20 +    pass=$(cat $r | grep '  PASS' | cut -d : -f 2 | sed 's/  *//')
   40.21 +    fail=$(cat $r | grep '  FAIL' | cut -d : -f 2 | sed 's/  *//')
   40.22 +    xpas=$(cat $r | grep ' XPASS' | cut -d : -f 2 | sed 's/  *//')
   40.23 +    xfal=$(cat $r | grep ' XFAIL' | cut -d : -f 2 | sed 's/  *//')
   40.24 +
   40.25 +    printf "%20s | %4s | %4s | %5s | %5s |\n" "$mach" "$pass" \
   40.26 +           "$fail" "$xpas" "$xfal"
   40.27 +
   40.28 +done
    41.1 --- a/tools/xm-test/runtest.sh	Thu Nov 10 15:24:29 2005 -0600
    41.2 +++ b/tools/xm-test/runtest.sh	Fri Nov 11 10:47:43 2005 +0100
    41.3 @@ -1,215 +1,259 @@
    41.4  #!/bin/sh
    41.5  
    41.6 -usage() {
    41.7 -    echo "Usage: $0 [opts] <logfile>"
    41.8 -    echo "  Where opts are:"
    41.9 -    echo "  -d         : do not submit a report for this run"
   41.10 -    echo "  -b         : do not ask any questions (batch mode)"
   41.11 -    echo "  -e <email> : set email address for report"
   41.12 -}
   41.13  ##
   41.14  ## Test driver script
   41.15  ##
   41.16  
   41.17 -#
   41.18 -# Defaults
   41.19 -#
   41.20 -MAXFAIL=10
   41.21 -report=yes
   41.22 -batch=no
   41.23 +usage() {
   41.24 +    echo "Usage: $0 [opts] <report>"
   41.25 +    echo "  Where report is a name that will be used for report files"
   41.26 +    echo ""
   41.27 +    echo "  Where opts are:"
   41.28 +    echo "  -d          : do not submit a report for this run"
   41.29 +    echo "  -b          : do not ask any questions (batch mode)"
   41.30 +    echo "  -q          : run a quick test set"
   41.31 +    echo "  -e <email>  : set email address for report"
   41.32 +    echo "  -s <report> : just submit report <report>"
   41.33 +}
   41.34 +
   41.35 +# Just submit the report
   41.36 +submit_report() {
   41.37  
   41.38 -#
   41.39 -# Resolve options
   41.40 -#
   41.41 -while [ $# -gt 0 ]
   41.42 -do
   41.43 -    case "$1" in
   41.44 -    -d)
   41.45 -        echo "(Skipping report submission)"
   41.46 -        report=no
   41.47 -        ;;
   41.48 -    -b)
   41.49 -        echo "(Batch mode)"
   41.50 -        batch=yes
   41.51 -        ;;
   41.52 -    -e)
   41.53 -        shift
   41.54 -        echo $1 > contact_info
   41.55 -        echo "(Email set to $1)"
   41.56 -        ;;
   41.57 -    *)
   41.58 -        LOGFILE=$1
   41.59 -        break
   41.60 -        ;;
   41.61 -    esac
   41.62 -    shift
   41.63 -done
   41.64 +    reportfile=$1
   41.65 +
   41.66 +    ./lib/XmTestReport/Report.py $reportfile
   41.67 +}
   41.68 +
   41.69 +# Generate XML result report from output file
   41.70 +make_result_report() {
   41.71 +    output=$1
   41.72 +    reportfile=$2
   41.73 +    if ! ./lib/XmTestReport/ResultReport.py $output > $reportfile; then
   41.74 +	echo "Unable to generate clean ResultReport"
   41.75 +	echo "Take a look at $report"
   41.76 +	exit 1
   41.77 +    fi
   41.78 +}
   41.79  
   41.80 -#
   41.81 -# Usage
   41.82 -#
   41.83 -if [ -z $LOGFILE ]; then
   41.84 -	usage
   41.85 +# Collect environment information for XML report
   41.86 +make_environment_report() {
   41.87 +    os=$1
   41.88 +    prog=$2
   41.89 +    if ! ./lib/XmTestReport/OSReport.py > $os; then
   41.90 +	echo "Unable to generate clean OSReport"
   41.91 +	echo "Take a look at $os"
   41.92  	exit 1
   41.93 -fi
   41.94 +    fi
   41.95 +    if ! ./lib/XmTestReport/ProgReport.py > $prog; then
   41.96 +	echo "Unable to generate clean ProgReport"
   41.97 +	echo "Take a look at $prog"
   41.98 +	exit 1
   41.99 +    fi
  41.100 +}
  41.101  
  41.102 -#
  41.103 -# Output files
  41.104 -#
  41.105 -OSREPORTTEMP=${LOGFILE}.os.xml
  41.106 -PROGREPORTTEMP=${LOGFILE}.prog.xml
  41.107 -RESULTREPORTTEMP=${LOGFILE}.result.xml
  41.108 -OUTPUT=${LOGFILE}.output
  41.109 -SUMMARY=${LOGFILE}.summary
  41.110 -PASSFAIL=${LOGFILE}.passfail
  41.111 -REPORT=${LOGFILE}.report
  41.112 -FAILURES=${LOGFILE}.failures
  41.113 -		
  41.114 -#
  41.115 -# Make sure we're root
  41.116 -#
  41.117 -uid=$(id -u)
  41.118 -if [ $uid != 0 ]; then 
  41.119 -    echo "ERROR: I must be run as root!"
  41.120 -    exit 1
  41.121 -fi
  41.122 +# Check conditions needed to actually run the tests
  41.123 +runnable_tests() {	
  41.124 +    # Make sure we're root
  41.125 +    uid=$(id -u)
  41.126 +    if [ $uid != 0 ]; then 
  41.127 +	echo "ERROR: I must be run as root!"
  41.128 +	exit 1
  41.129 +    fi
  41.130  
  41.131 -#
  41.132 -# See if the ramdisk has been built
  41.133 -#
  41.134 -rdsize=$(stat -c %s ramdisk/initrd.img 2>/dev/null)
  41.135 -if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
  41.136 -    echo "Cannot find a valid ramdisk.  You need to run \"make\" or"
  41.137 -    echo "copy in a previously-built ramdisk to the ramdisk/ directory"
  41.138 -    exit 1
  41.139 -fi
  41.140 +    # See if the ramdisk has been built
  41.141 +    rdsize=$(stat -c %s ramdisk/initrd.img 2>/dev/null)
  41.142 +    if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
  41.143 +	echo "Cannot find a valid ramdisk.  You need to run \"make\" or"
  41.144 +	echo "copy in a previously-built ramdisk to the ramdisk/ directory"
  41.145 +	exit 1
  41.146 +    fi
  41.147 +
  41.148 +    # See if xend is running
  41.149 +    if ! xm list >/dev/null 2>&1; then
  41.150 +	echo "'xm list' failed: is xend running?"
  41.151 +	exit 1
  41.152 +    fi
  41.153 +    
  41.154 +}
  41.155  
  41.156 -#
  41.157 -# See if xend is running
  41.158 -#
  41.159 -if ! xm list >/dev/null 2>&1; then
  41.160 -    echo "'xm list' failed: is xend running?"
  41.161 -    exit 1
  41.162 -fi
  41.163 +# Get contact info if needed
  41.164 +get_contact_info() {
  41.165 +    
  41.166 +    if [ ! -f contact_info ]; then
  41.167 +	if [ "$batch" = "yes" ]; then
  41.168 +	    echo "Unable to read contact_info!"
  41.169 +	    echo "Please run me once interactively before using batch mode!"
  41.170 +	    exit 1
  41.171 +	else
  41.172 +	    echo "Please provide your email address so that we can "
  41.173 +	    echo "contact you if we need further information concerning"
  41.174 +	    echo "your results.  Any information provided will be"
  41.175 +	    echo "kept private.  If you wish to remain anonymous, please"
  41.176 +	    echo "hit [ENTER] now."
  41.177 +	    
  41.178 +	    while ! echo "$EMAIL" | grep -q '@'; do
  41.179 +		echo
  41.180 +		echo -n "Your email address: "
  41.181 +		read EMAIL
  41.182 +		if [ -z $EMAIL ]; then
  41.183 +		    EMAIL="anonymous@somewhere.com"
  41.184 +		fi
  41.185 +	    done
  41.186 +	    echo $EMAIL > contact_info
  41.187 +	fi
  41.188 +    fi
  41.189 +}
  41.190  
  41.191 -#
  41.192 -#  Make sure permissions are correct
  41.193 -#
  41.194 -chmod a+x lib/XmTestReport/*
  41.195 -chmod a+x mkreport mergereport
  41.196 +# Run the tests
  41.197 +run_tests() {
  41.198 +    output=$1
  41.199 +    echo Running tests...
  41.200 +    TEST_VERBOSE=1 make -k check > $output 2>&1
  41.201 +}
  41.202  
  41.203 -#
  41.204 -# Get contact info if needed
  41.205 -#
  41.206 -if [ ! -f contact_info ]; then
  41.207 -    if [ "$batch" = "yes" ]; then
  41.208 -	echo "Unable to read contact_info!"
  41.209 -	echo "Please run me once interactively before using batch mode!"
  41.210 -	exit 1
  41.211 -    else
  41.212 -	echo "Please provide your email address so that we can "
  41.213 -	echo "contact you if we need further information concerning"
  41.214 -	echo "your results.  Any information provided will be"
  41.215 -	echo "kept private.  If you wish to remain anonymous, please"
  41.216 -	echo "hit [ENTER] now."
  41.217 -	
  41.218 -	while ! echo "$EMAIL" | grep -q '@'; do
  41.219 -	    echo
  41.220 -	    echo -n "Your email address: "
  41.221 -	    read EMAIL
  41.222 -	    if [ -z $EMAIL ]; then
  41.223 -		EMAIL="anonymous@somewhere.com"
  41.224 -	    fi
  41.225 -	done
  41.226 -	echo $EMAIL > contact_info
  41.227 -    fi
  41.228 -fi
  41.229 +run_tests_quick() {
  41.230 +
  41.231 +    output=$1
  41.232 +
  41.233 +    create_tests="01_create_basic_pos.test 07_create_mem64_pos.test 10_create_fastdestroy.test 14_create_blockroot_pos.test"
  41.234 +    unpause_tests="01_unpause_basic_pos.test"
  41.235 +    memset_tests="01_memset_basic_pos.test 03_memset_random_pos.test"
  41.236 +    help_tests="06_help_allcmds.test"
  41.237 +    testgroups="create unpause memset help"
  41.238 +
  41.239 +    echo "*** Quick test" > $output
  41.240 +    for group in $testgroups; do
  41.241 +	eval $(echo list=\$${group}_tests)
  41.242 +	echo "*** Running tests [$list] from $group"
  41.243 +	(cd tests/$group && TEST_VERBOSE=1 make -k check TESTS="$list") >> $output 2>&1
  41.244 +    done
  41.245 +
  41.246 +}
  41.247  
  41.248 -#
  41.249 -# Collect environment information for XML report
  41.250 -#
  41.251 -if ! ./lib/XmTestReport/OSReport.py > $OSREPORTTEMP; then
  41.252 -    echo "Unable to generate clean OSReport"
  41.253 -    echo "Take a look at $OSREPORTTEMP"
  41.254 -    exit 1
  41.255 -fi
  41.256 -if ! ./lib/XmTestReport/ProgReport.py > $PROGREPORTTEMP; then
  41.257 -    echo "Unable to generate clean ProgReport"
  41.258 -    echo "Take a look at $PROGREPORTTEMP"
  41.259 -    exit 1
  41.260 -fi
  41.261 -
  41.262 -#
  41.263 -# Run the tests
  41.264 -#
  41.265 -export TEST_VERBOSE=1
  41.266 -echo Running tests...
  41.267 -make -k check > $OUTPUT 2>&1
  41.268 -
  41.269 -#
  41.270  # Generate some plain-text reports
  41.271 -#
  41.272 -echo "Making PASS/FAIL report ($PASSFAIL)..."
  41.273 -cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $PASSFAIL
  41.274 -
  41.275 -echo "Making FAIL report ($FAILURES)..."
  41.276 -cat $PASSFAIL | egrep '(REASON|FAIL)' > $FAILURES
  41.277 -
  41.278 -NUMPASS=`grep -c PASS $OUTPUT`
  41.279 -NUMFAIL=`grep -c FAIL $OUTPUT`
  41.280 -NUMXPASS=`grep -c XPASS $OUTPUT`
  41.281 -NUMXFAIL=`grep -c XFAIL $OUTPUT`
  41.282 -cat > $SUMMARY << EOF
  41.283 +make_text_reports() {
  41.284 +    passfail=$1
  41.285 +    failures=$2
  41.286 +    output=$3
  41.287 +    reportfile=$4
  41.288 +    summary=summary.tmp
  41.289 +    echo "Making PASS/FAIL report ($passfail)..."
  41.290 +    cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $passfail
  41.291 +    
  41.292 +    echo "Making FAIL report ($failures)..."
  41.293 +    cat $passfail | egrep '(REASON|FAIL)' > $failures
  41.294 +    
  41.295 +    NUMPASS=`grep -c PASS $output`
  41.296 +    NUMFAIL=`grep -c FAIL $output`
  41.297 +    NUMXPASS=`grep -c XPASS $output`
  41.298 +    NUMXFAIL=`grep -c XFAIL $output`
  41.299 +    cat > $summary << EOF
  41.300  Xm-test execution summary:
  41.301    PASS:  $NUMPASS
  41.302    FAIL:  $NUMFAIL
  41.303    XPASS: $NUMXPASS
  41.304    XFAIL: $NUMXFAIL
  41.305  EOF
  41.306 +    
  41.307 +    cat $summary > $reportfile
  41.308 +    
  41.309 +    echo -e '\n\nDetails:\n' >> $reportfile
  41.310 +    
  41.311 +    ./mkreport $passfail >> $reportfile
  41.312  
  41.313 -cat $SUMMARY > $REPORT
  41.314 +    rm $summary
  41.315 +}
  41.316  
  41.317 -echo -e '\n\nDetails:\n' >> $REPORT
  41.318 - 
  41.319 -./mkreport $PASSFAIL >> $REPORT
  41.320 +############
  41.321 +### Main ###
  41.322 +############
  41.323 +
  41.324 +# Defaults
  41.325 +MAXFAIL=10
  41.326 +report=yes
  41.327 +batch=no
  41.328 +run=yes
  41.329  
  41.330 -#
  41.331 -# Check to see if it's worth reporting these results
  41.332 -#
  41.333 -#if  [ "$batch"  =   "no" ] && 
  41.334 -#    [ "$report" =   "yes" ] && 
  41.335 -#    [ $NUMFAIL  -gt $MAXFAIL ]; then
  41.336 -#    echo "NOTE: $NUMFAIL tests failed, which may be erroneous.  It may"
  41.337 -#    echo "be a good idea to review the report before sending.  If you"
  41.338 -#    echo "choose not to submit the report, it will be saved for your review"
  41.339 -#    echo "and later submission."
  41.340 -#    echo
  41.341 -#    echo -n "Submit anyway? [y/n] "
  41.342 -#    read ANSWER
  41.343 -#    if [ "$ANSWER" = "n" ]; then
  41.344 -#	report=no
  41.345 -#    fi
  41.346 -#fi
  41.347 +# Resolve options
  41.348 +while [ $# -gt 0 ]
  41.349 +  do
  41.350 +  case "$1" in
  41.351 +      -d)
  41.352 +	  echo "(Skipping report submission)"
  41.353 +	  report=no
  41.354 +	  ;;
  41.355 +      -b)
  41.356 +	  echo "(Batch mode)"
  41.357 +	  batch=yes
  41.358 +	  ;;
  41.359 +      -e)
  41.360 +	  shift
  41.361 +	  echo $1 > contact_info
  41.362 +	  echo "(Email set to $1)"
  41.363 +	  ;;
  41.364 +      -q)
  41.365 +	  run=quick
  41.366 +	  ;;
  41.367 +      -s)
  41.368 +	  run=no
  41.369 +	  ;;
  41.370 +      *)
  41.371 +	  REPORT=$1
  41.372 +	  break
  41.373 +	  ;;
  41.374 +  esac
  41.375 +  shift
  41.376 +done
  41.377  
  41.378 -#
  41.379 -# Generate the XML result report
  41.380 -#
  41.381 -if ! ./lib/XmTestReport/ResultReport.py $OUTPUT > $RESULTREPORTTEMP; then
  41.382 -    echo "Unable to generate clean ResultReport"
  41.383 -    echo "Take a look at $RESULTREPORTTEMP"
  41.384 -    exit 1
  41.385 +# Usage
  41.386 +if [ -z $REPORT ]; then
  41.387 +	usage
  41.388 +	exit 1
  41.389  fi
  41.390  
  41.391 -#
  41.392 -# Maybe submit report and save the combined XML file
  41.393 -#
  41.394 -if [ "$report" = "yes" ]; then
  41.395 -    echo "Sending report..."
  41.396 -    ./lib/XmTestReport/Report.py -D $OSREPORTTEMP $PROGREPORTTEMP \
  41.397 -                                    $RESULTREPORTTEMP > $1.xml
  41.398 -    echo "Report also saved in $1.xml"
  41.399 -else
  41.400 -    echo "Saving report to $1.xml..."
  41.401 -    ./lib/XmTestReport/Report.py -d $OSREPORTTEMP $PROGREPORTTEMP \
  41.402 -                                    $RESULTREPORTTEMP > $1.xml
  41.403 +# Output files
  41.404 +OSREPORTTEMP=${REPORT}.os.xml
  41.405 +PROGREPORTTEMP=${REPORT}.prog.xml
  41.406 +RESULTREPORTTEMP=${REPORT}.result.xml
  41.407 +XMLREPORT=${REPORT}.xml
  41.408 +OUTPUT=${REPORT}.output
  41.409 +SUMMARY=${REPORT}.summary
  41.410 +PASSFAIL=${REPORT}.passfail
  41.411 +TXTREPORT=${REPORT}.report
  41.412 +FAILURES=${REPORT}.failures
  41.413 +	
  41.414 +#  Make sure permissions are correct
  41.415 +chmod a+x lib/XmTestReport/*
  41.416 +chmod a+x mkreport mergereport
  41.417 +
  41.418 +if [ ! -f contact_info ]; then
  41.419 +    if [ "$batch" = "yes" ]; then
  41.420 +	echo "Unable to read contact_info"
  41.421 +	echo "You must run me interactively once!"
  41.422 +	exit 1
  41.423 +    else
  41.424 +	get_contact_info
  41.425 +    fi
  41.426  fi
  41.427 +
  41.428 +if [ "$run" != "no" ]; then
  41.429 +    runnable_tests
  41.430 +    make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
  41.431 +    if [ "$run" = "yes" ]; then
  41.432 +	run_tests $OUTPUT
  41.433 +    else
  41.434 +	run_tests_quick $OUTPUT
  41.435 +    fi
  41.436 +    make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
  41.437 +    make_result_report $OUTPUT $RESULTREPORTTEMP
  41.438 +    cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
  41.439 +    rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
  41.440 +fi
  41.441 +
  41.442 +if [ "$report" = "yes" ] && [ "$run" = "yes" ]; then
  41.443 +    if [ ! -f "$XMLREPORT" ]; then
  41.444 +	echo "No such file: $XMLREPORT"
  41.445 +	exit 1
  41.446 +    fi
  41.447 +    submit_report $XMLREPORT
  41.448 +fi
    42.1 --- a/tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py	Thu Nov 10 15:24:29 2005 -0600
    42.2 +++ b/tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py	Fri Nov 11 10:47:43 2005 +0100
    42.3 @@ -36,7 +36,9 @@ except ConsoleError, e:
    42.4      saveLog(console.getHistory())
    42.5      FAIL(str(e))
    42.6      
    42.7 -os.system("mkfs.ext2 -F /dev/ram1")
    42.8 +s, o = traceCommand("mke2fs -q -F /dev/ram1")
    42.9 +if s != 0:
   42.10 +    FAIL("mke2fs returned %i != 0" % s)
   42.11  
   42.12  for i in range(10):
   42.13  	status, output = traceCommand("xm block-attach %s phy:ram1 hda1 w" % domain.getName())
    43.1 --- a/tools/xm-test/tests/create/log	Thu Nov 10 15:24:29 2005 -0600
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,14 +0,0 @@
    43.4 --- BEGIN XmTest Log @Fri Oct 28 13:00:55 PDT 2005
    43.5 -*input
    43.6 -
    43.7 -
    43.8 -BusyBox v1.01 (2005.10.27-17:34+0000) Built-in shell (ash)
    43.9 -Enter 'help' for a list of built-in commands.
   43.10 -
   43.11 --sh: can't access tty; job control turned off
   43.12 -*ls
   43.13 -CVS         etc         linuxrc     opt         sbin        var
   43.14 -bin         home        lost+found  proc        tmp
   43.15 -dev         lib         mnt         root        usr
   43.16 -
   43.17 --- END XmTest Log
    44.1 --- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Thu Nov 10 15:24:29 2005 -0600
    44.2 +++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Fri Nov 11 10:47:43 2005 +0100
    44.3 @@ -5,13 +5,20 @@
    44.4  
    44.5  from XmTestLib import *
    44.6  
    44.7 -domain = XmTestDomain()
    44.8 +import re
    44.9 +
   44.10 +domain = XmTestDomain(extraOpts={"nics":2})
   44.11  
   44.12  domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
   44.13 +domain.configAddDisk("phy:/dev/ram1", "hdb2", "w")
   44.14  
   44.15 -s, o = traceCommand("mkfs /dev/ram0")
   44.16 +s, o = traceCommand("mke2fs -q /dev/ram0")
   44.17  if s != 0:
   44.18 -    FAIL("Unable to mkfs /dev/ram0 in dom0")
   44.19 +    FAIL("Unable to mke2fs /dev/ram0 in dom0")
   44.20 +
   44.21 +s, o = traceCommand("mke2fs -q /dev/ram1")
   44.22 +if s != 0:
   44.23 +    FAIL("Unable to mke2fs /dev/ram1 in dom0")
   44.24  
   44.25  try:
   44.26      domain.start()
   44.27 @@ -22,13 +29,38 @@ try:
   44.28      console = XmConsole(domain.getName())
   44.29      console.sendInput("foo")
   44.30  
   44.31 -    run = console.runCmd("mount /dev/hda1 /mnt")
   44.32 +    run = console.runCmd("mkdir /mnt/a /mnt/b")
   44.33 +    if run["return"] != 0:
   44.34 +        FAIL("Unable to mkdir /mnt/a /mnt/b")
   44.35 +
   44.36 +    run = console.runCmd("mount /dev/hda1 /mnt/a")
   44.37      if run["return"] != 0:
   44.38          FAIL("Unable to mount /dev/hda1")
   44.39  
   44.40 -    run = console.runCmd("echo bar > /mnt/foo")
   44.41 +    run = console.runCmd("mount /dev/hdb2 /mnt/b")
   44.42 +    if run["return"] != 0:
   44.43 +        FAIL("Unable to mount /dev/hdb2")
   44.44 +
   44.45 +    run = console.runCmd("echo hda1 > /mnt/a/foo")
   44.46 +    if run["return"] != 0:
   44.47 +        FAIL("Unable to write to block device hda1!")
   44.48 +
   44.49 +    run = console.runCmd("echo hdb2 > /mnt/b/foo")
   44.50      if run["return"] != 0:
   44.51 -        FAIL("Unable to write to block device!")
   44.52 +        FAIL("Unable to write to block device hdb2!")
   44.53 +
   44.54 +    run = console.runCmd("ifconfig eth0 169.254.0.1 netmask 255.255.255.0")
   44.55 +    if run["return"] != 0:
   44.56 +        FAIL("Unable to configure DomU's eth0")
   44.57 +
   44.58 +    run = console.runCmd("ifconfig eth1 169.254.1.1 netmask 255.255.255.0")
   44.59 +    if run["return"] != 0:
   44.60 +        FAIL("Unable to configure DomU's eth1")
   44.61 +
   44.62 +    run = console.runCmd("ifconfig lo 127.0.0.1")
   44.63 +    if run["return"] != 0:
   44.64 +        FAIL("Unable to configure DomU's lo")
   44.65 +
   44.66  
   44.67  except ConsoleError, e:
   44.68      FAIL(str(e))
   44.69 @@ -63,9 +95,31 @@ try:
   44.70      if run["return"] != 0:
   44.71          FAIL("ls failed on restored domain")
   44.72      
   44.73 -    run = console.runCmd("cat /mnt/foo | grep bar")
   44.74 +    run = console.runCmd("cat /mnt/a/foo")
   44.75 +    if run["return"] != 0:
   44.76 +        FAIL("Unable to read from block device hda1")
   44.77 +    if not re.search("hda1", run["output"]):
   44.78 +        FAIL("Failed to read correct data from hda1")
   44.79 +
   44.80 +    run = console.runCmd("cat /mnt/b/foo")
   44.81      if run["return"] != 0:
   44.82 -        FAIL("Unable to read from block device")
   44.83 +        FAIL("Unable to read from block device hdb2")
   44.84 +    if not re.search("hdb2", run["output"]):
   44.85 +        FAIL("Failed to read correct data from hdb2")
   44.86 +
   44.87 +    run = console.runCmd("ifconfig")
   44.88 +    if not re.search("eth0", run["output"]):
   44.89 +        FAIL("DomU's eth0 disappeared")
   44.90 +    if not re.search("169.254.0.1", run["output"]):
   44.91 +        FAIL("DomU's eth0 lost its IP")
   44.92 +    if not re.search("eth1", run["output"]):
   44.93 +        FAIL("DomU's eth1 disappeared")
   44.94 +    if not re.search("169.254.1.1", run["output"]):
   44.95 +        FAIL("DomU's eth1 lost its IP")
   44.96 +    if not re.search("Loopback", run["output"]):
   44.97 +        FAIL("DomU's lo disappeared")
   44.98 +    if not re.search("127.0.0.1", run["output"]):
   44.99 +        FAIL("DomU's lo lost its IP")
  44.100  
  44.101  except ConsoleError, e:
  44.102      FAIL(str(e))
    45.1 --- a/xen/arch/x86/dm/vmx_vioapic.c	Thu Nov 10 15:24:29 2005 -0600
    45.2 +++ b/xen/arch/x86/dm/vmx_vioapic.c	Fri Nov 11 10:47:43 2005 +0100
    45.3 @@ -158,6 +158,14 @@ static unsigned long vmx_vioapic_read(st
    45.4      return result;
    45.5  }
    45.6  
    45.7 +static void vmx_vioapic_update_imr(struct vmx_vioapic *s, int index)
    45.8 +{
    45.9 +   if (s->redirtbl[index].RedirForm.mask)
   45.10 +       set_bit(index, &s->imr);
   45.11 +   else
   45.12 +       clear_bit(index, &s->imr);
   45.13 +}
   45.14 +
   45.15  static void vmx_vioapic_write_indirect(struct vmx_vioapic *s,
   45.16                                        unsigned long addr,
   45.17                                        unsigned long length,
   45.18 @@ -200,6 +208,7 @@ static void vmx_vioapic_write_indirect(s
   45.19                      redir_content = ((redir_content >> 32) << 32) |
   45.20                                      (val & 0xffffffff);
   45.21                  s->redirtbl[redir_index].value = redir_content;
   45.22 +                vmx_vioapic_update_imr(s, redir_index);
   45.23              } else  {
   45.24                  printk("vmx_vioapic_write_indirect "
   45.25                    "error register %x\n", s->ioregsel);
   45.26 @@ -264,8 +273,10 @@ static void vmx_vioapic_reset(vmx_vioapi
   45.27  
   45.28      memset(s, 0, sizeof(vmx_vioapic_t));
   45.29  
   45.30 -    for (i = 0; i < IOAPIC_NUM_PINS; i++)
   45.31 +    for (i = 0; i < IOAPIC_NUM_PINS; i++) {
   45.32          s->redirtbl[i].RedirForm.mask = 0x1;
   45.33 +        vmx_vioapic_update_imr(s, i);
   45.34 +    }
   45.35  }
   45.36  
   45.37  static void ioapic_update_config(vmx_vioapic_t *s,
   45.38 @@ -422,7 +433,13 @@ static void ioapic_deliver(vmx_vioapic_t
   45.39  
   45.40          target = apic_round_robin(
   45.41                  s->domain, dest_mode, vector, deliver_bitmask);
   45.42 -        ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
   45.43 +        if (target)
   45.44 +            ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
   45.45 +        else{
   45.46 +            VMX_DBG_LOG(DBG_LEVEL_IOAPIC, "ioapic deliver "
   45.47 +              "null round robin mask %x vector %x delivery_mode %x\n",
   45.48 +              deliver_bitmask, vector, deliver_bitmask);
   45.49 +        }
   45.50          break;
   45.51      }
   45.52  
   45.53 @@ -457,7 +474,7 @@ static int ioapic_get_highest_irq(vmx_vi
   45.54  
   45.55      ASSERT(s);
   45.56  
   45.57 -    irqs = s->irr & ~s->isr;
   45.58 +    irqs = s->irr & ~s->isr & ~s->imr;
   45.59      return __fls(irqs);
   45.60  }
   45.61  
   45.62 @@ -471,7 +488,7 @@ static void service_ioapic(vmx_vioapic_t
   45.63          VMX_DBG_LOG(DBG_LEVEL_IOAPIC, "service_ioapic "
   45.64            "highest irqno %x\n", irqno);
   45.65  
   45.66 -        if (!s->redirtbl[irqno].RedirForm.mask) {
   45.67 +        if (!test_bit(irqno, &s->imr)) {
   45.68              ioapic_deliver(s, irqno);
   45.69          }
   45.70  
   45.71 @@ -490,7 +507,7 @@ void vmx_vioapic_do_irqs(struct domain *
   45.72      if (!vmx_apic_support(d))
   45.73          return;
   45.74  
   45.75 -    s->irr |= irqs;
   45.76 +    s->irr |= irqs & ~s->imr;
   45.77      service_ioapic(s);
   45.78  }
   45.79  
   45.80 @@ -584,7 +601,9 @@ int vmx_vioapic_add_lapic(struct vlapic 
   45.81          domain_crash_synchronous();
   45.82      }
   45.83  
   45.84 -    s->lapic_info[s->lapic_count ++] = vlapic;
   45.85 +    /* update count later for race condition on interrupt */
   45.86 +    s->lapic_info[s->lapic_count] = vlapic;
   45.87 +    s->lapic_count ++;
   45.88  
   45.89      return s->lapic_count;
   45.90  }
    46.1 --- a/xen/arch/x86/domain.c	Thu Nov 10 15:24:29 2005 -0600
    46.2 +++ b/xen/arch/x86/domain.c	Fri Nov 11 10:47:43 2005 +0100
    46.3 @@ -407,6 +407,7 @@ int arch_set_info_guest(
    46.4          /* VMX uses the initially provided page tables as the P2M map. */
    46.5          if ( !pagetable_get_paddr(d->arch.phys_table) )
    46.6              d->arch.phys_table = v->arch.guest_table;
    46.7 +        v->arch.guest_table = mk_pagetable(0);
    46.8  
    46.9          /* Initialize monitor page table */
   46.10          v->arch.monitor_table = mk_pagetable(0);
   46.11 @@ -646,7 +647,7 @@ long do_switch_to_user(void)
   46.12  
   46.13      regs->rip    = stu.rip;
   46.14      regs->cs     = stu.cs | 3; /* force guest privilege */
   46.15 -    regs->rflags = stu.rflags;
   46.16 +    regs->rflags = (stu.rflags & ~(EF_IOPL|EF_VM)) | EF_IE;
   46.17      regs->rsp    = stu.rsp;
   46.18      regs->ss     = stu.ss | 3; /* force guest privilege */
   46.19  
    47.1 --- a/xen/arch/x86/setup.c	Thu Nov 10 15:24:29 2005 -0600
    47.2 +++ b/xen/arch/x86/setup.c	Fri Nov 11 10:47:43 2005 +0100
    47.3 @@ -430,6 +430,10 @@ void __init __start_xen(multiboot_info_t
    47.4      /* Sanity check for unwanted bloat of dom0_op_t structure. */
    47.5      BUG_ON(sizeof(((dom0_op_t *)0)->u) != sizeof(((dom0_op_t *)0)->u.pad));
    47.6  
    47.7 +    BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
    47.8 +    BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
    47.9 +    BUG_ON(sizeof(vcpu_info_t) != (sizeof(unsigned long) * 4));
   47.10 +
   47.11      init_frametable();
   47.12  
   47.13      end_boot_allocator();
    48.1 --- a/xen/arch/x86/shadow32.c	Thu Nov 10 15:24:29 2005 -0600
    48.2 +++ b/xen/arch/x86/shadow32.c	Fri Nov 11 10:47:43 2005 +0100
    48.3 @@ -997,7 +997,8 @@ int __shadow_mode_enable(struct domain *
    48.4      if ( new_modes & SHM_log_dirty )
    48.5      {
    48.6          ASSERT( !d->arch.shadow_dirty_bitmap );
    48.7 -        d->arch.shadow_dirty_bitmap_size = (d->max_pages + 63) & ~63;
    48.8 +        d->arch.shadow_dirty_bitmap_size = 
    48.9 +            (d->shared_info->arch.max_pfn +  63) & ~63;
   48.10          d->arch.shadow_dirty_bitmap = 
   48.11              xmalloc_array(unsigned long, d->arch.shadow_dirty_bitmap_size /
   48.12                                           (8 * sizeof(unsigned long)));
   48.13 @@ -1287,34 +1288,28 @@ static int shadow_mode_table_op(
   48.14          d->arch.shadow_dirty_net_count   = 0;
   48.15          d->arch.shadow_dirty_block_count = 0;
   48.16   
   48.17 -        if ( (d->max_pages > sc->pages) || 
   48.18 -             (sc->dirty_bitmap == NULL) || 
   48.19 +        if ( (sc->dirty_bitmap == NULL) || 
   48.20               (d->arch.shadow_dirty_bitmap == NULL) )
   48.21          {
   48.22              rc = -EINVAL;
   48.23              break;
   48.24          }
   48.25 - 
   48.26 -        sc->pages = d->max_pages;
   48.27 +
   48.28 +        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   48.29 +            sc->pages = d->arch.shadow_dirty_bitmap_size; 
   48.30  
   48.31  #define chunk (8*1024) /* Transfer and clear in 1kB chunks for L1 cache. */
   48.32 -        for ( i = 0; i < d->max_pages; i += chunk )
   48.33 +        for ( i = 0; i < sc->pages; i += chunk )
   48.34          {
   48.35 -            int bytes = ((((d->max_pages - i) > chunk) ?
   48.36 -                          chunk : (d->max_pages - i)) + 7) / 8;
   48.37 +            int bytes = ((((sc->pages - i) > chunk) ?
   48.38 +                          chunk : (sc->pages - i)) + 7) / 8;
   48.39       
   48.40              if (copy_to_user(
   48.41                      sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
   48.42                      d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   48.43                      bytes))
   48.44              {
   48.45 -                // copy_to_user can fail when copying to guest app memory.
   48.46 -                // app should zero buffer after mallocing, and pin it
   48.47                  rc = -EINVAL;
   48.48 -                memset(
   48.49 -                    d->arch.shadow_dirty_bitmap + 
   48.50 -                    (i/(8*sizeof(unsigned long))),
   48.51 -                    0, (d->max_pages/8) - (i/(8*sizeof(unsigned long))));
   48.52                  break;
   48.53              }
   48.54  
   48.55 @@ -1331,17 +1326,19 @@ static int shadow_mode_table_op(
   48.56          sc->stats.dirty_net_count   = d->arch.shadow_dirty_net_count;
   48.57          sc->stats.dirty_block_count = d->arch.shadow_dirty_block_count;
   48.58   
   48.59 -        if ( (d->max_pages > sc->pages) || 
   48.60 -             (sc->dirty_bitmap == NULL) || 
   48.61 +
   48.62 +        if ( (sc->dirty_bitmap == NULL) || 
   48.63               (d->arch.shadow_dirty_bitmap == NULL) )
   48.64          {
   48.65              rc = -EINVAL;
   48.66              break;
   48.67          }
   48.68   
   48.69 -        sc->pages = d->max_pages;
   48.70 -        if (copy_to_user(
   48.71 -            sc->dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
   48.72 +        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   48.73 +            sc->pages = d->arch.shadow_dirty_bitmap_size; 
   48.74 +
   48.75 +        if (copy_to_user(sc->dirty_bitmap, 
   48.76 +                         d->arch.shadow_dirty_bitmap, (sc->pages+7)/8))
   48.77          {
   48.78              rc = -EINVAL;
   48.79              break;
    49.1 --- a/xen/arch/x86/shadow_public.c	Thu Nov 10 15:24:29 2005 -0600
    49.2 +++ b/xen/arch/x86/shadow_public.c	Fri Nov 11 10:47:43 2005 +0100
    49.3 @@ -1009,7 +1009,8 @@ int __shadow_mode_enable(struct domain *
    49.4      if ( new_modes & SHM_log_dirty )
    49.5      {
    49.6          ASSERT( !d->arch.shadow_dirty_bitmap );
    49.7 -        d->arch.shadow_dirty_bitmap_size = (d->max_pages + 63) & ~63;
    49.8 +        d->arch.shadow_dirty_bitmap_size = 
    49.9 +            (d->shared_info->arch.max_pfn +  63) & ~63;
   49.10          d->arch.shadow_dirty_bitmap = 
   49.11              xmalloc_array(unsigned long, d->arch.shadow_dirty_bitmap_size /
   49.12                            (8 * sizeof(unsigned long)));
   49.13 @@ -1163,34 +1164,29 @@ static int shadow_mode_table_op(
   49.14          d->arch.shadow_dirty_net_count   = 0;
   49.15          d->arch.shadow_dirty_block_count = 0;
   49.16   
   49.17 -        if ( (d->max_pages > sc->pages) || 
   49.18 -             (sc->dirty_bitmap == NULL) || 
   49.19 +
   49.20 +        if ( (sc->dirty_bitmap == NULL) || 
   49.21               (d->arch.shadow_dirty_bitmap == NULL) )
   49.22          {
   49.23              rc = -EINVAL;
   49.24              break;
   49.25          }
   49.26 - 
   49.27 -        sc->pages = d->max_pages;
   49.28 +
   49.29 +        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   49.30 +            sc->pages = d->arch.shadow_dirty_bitmap_size; 
   49.31  
   49.32  #define chunk (8*1024) /* Transfer and clear in 1kB chunks for L1 cache. */
   49.33 -        for ( i = 0; i < d->max_pages; i += chunk )
   49.34 +        for ( i = 0; i < sc->pages; i += chunk )
   49.35          {
   49.36 -            int bytes = ((((d->max_pages - i) > chunk) ?
   49.37 -                          chunk : (d->max_pages - i)) + 7) / 8;
   49.38 +            int bytes = ((((sc->pages - i) > chunk) ?
   49.39 +                          chunk : (sc->pages - i)) + 7) / 8;
   49.40  
   49.41              if (copy_to_user(
   49.42                  sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
   49.43                  d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
   49.44                  bytes))
   49.45              {
   49.46 -                // copy_to_user can fail when copying to guest app memory.
   49.47 -                // app should zero buffer after mallocing, and pin it
   49.48                  rc = -EINVAL;
   49.49 -                memset(
   49.50 -                    d->arch.shadow_dirty_bitmap + 
   49.51 -                    (i/(8*sizeof(unsigned long))),
   49.52 -                    0, (d->max_pages/8) - (i/(8*sizeof(unsigned long))));
   49.53                  break;
   49.54              }
   49.55              memset(
   49.56 @@ -1206,17 +1202,18 @@ static int shadow_mode_table_op(
   49.57          sc->stats.dirty_net_count   = d->arch.shadow_dirty_net_count;
   49.58          sc->stats.dirty_block_count = d->arch.shadow_dirty_block_count;
   49.59   
   49.60 -        if ( (d->max_pages > sc->pages) || 
   49.61 -             (sc->dirty_bitmap == NULL) || 
   49.62 +        if ( (sc->dirty_bitmap == NULL) || 
   49.63               (d->arch.shadow_dirty_bitmap == NULL) )
   49.64          {
   49.65              rc = -EINVAL;
   49.66              break;
   49.67          }
   49.68   
   49.69 -        sc->pages = d->max_pages;
   49.70 -        if (copy_to_user(
   49.71 -            sc->dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
   49.72 +        if(sc->pages > d->arch.shadow_dirty_bitmap_size)
   49.73 +            sc->pages = d->arch.shadow_dirty_bitmap_size; 
   49.74 +
   49.75 +        if (copy_to_user(sc->dirty_bitmap, 
   49.76 +                         d->arch.shadow_dirty_bitmap, (sc->pages+7)/8))
   49.77          {
   49.78              rc = -EINVAL;
   49.79              break;
    50.1 --- a/xen/arch/x86/traps.c	Thu Nov 10 15:24:29 2005 -0600
    50.2 +++ b/xen/arch/x86/traps.c	Fri Nov 11 10:47:43 2005 +0100
    50.3 @@ -412,16 +412,16 @@ void propagate_page_fault(unsigned long 
    50.4      struct vcpu *v = current;
    50.5      struct trap_bounce *tb = &v->arch.trap_bounce;
    50.6  
    50.7 +    v->arch.guest_context.ctrlreg[2] = addr;
    50.8 +    v->vcpu_info->arch.cr2           = addr;
    50.9 +
   50.10      ti = &v->arch.guest_context.trap_ctxt[TRAP_page_fault];
   50.11 -    tb->flags = TBF_EXCEPTION | TBF_EXCEPTION_ERRCODE | TBF_EXCEPTION_CR2;
   50.12 -    tb->cr2        = addr;
   50.13 +    tb->flags = TBF_EXCEPTION | TBF_EXCEPTION_ERRCODE;
   50.14      tb->error_code = error_code;
   50.15      tb->cs         = ti->cs;
   50.16      tb->eip        = ti->address;
   50.17      if ( TI_GET_IF(ti) )
   50.18          tb->flags |= TBF_INTERRUPT;
   50.19 -
   50.20 -    v->arch.guest_context.ctrlreg[2] = addr;
   50.21  }
   50.22  
   50.23  static int handle_perdomain_mapping_fault(
   50.24 @@ -931,6 +931,7 @@ static int emulate_privileged_op(struct 
   50.25  
   50.26          case 2: /* Write CR2 */
   50.27              v->arch.guest_context.ctrlreg[2] = *reg;
   50.28 +            v->vcpu_info->arch.cr2           = *reg;
   50.29              break;
   50.30              
   50.31          case 3: /* Write CR3 */
    51.1 --- a/xen/arch/x86/vmx_io.c	Thu Nov 10 15:24:29 2005 -0600
    51.2 +++ b/xen/arch/x86/vmx_io.c	Fri Nov 11 10:47:43 2005 +0100
    51.3 @@ -459,14 +459,56 @@ static void vmx_mmio_assist(struct cpu_u
    51.4          }
    51.5          break;
    51.6  
    51.7 -    case INSTR_MOVZ:
    51.8 +    case INSTR_MOVZX:
    51.9          if (dst & REGISTER) {
   51.10 -            index = operand_index(dst);
   51.11              switch (size) {
   51.12 -            case BYTE: p->u.data = p->u.data & 0xFFULL; break;
   51.13 -            case WORD: p->u.data = p->u.data & 0xFFFFULL; break;
   51.14 -            case LONG: p->u.data = p->u.data & 0xFFFFFFFFULL; break;
   51.15 +            case BYTE:
   51.16 +                p->u.data &= 0xFFULL;
   51.17 +                break;
   51.18 +
   51.19 +            case WORD:
   51.20 +                p->u.data &= 0xFFFFULL;
   51.21 +                break;
   51.22 +
   51.23 +            case LONG:
   51.24 +                p->u.data &= 0xFFFFFFFFULL;
   51.25 +                break;
   51.26 +
   51.27 +            default:
   51.28 +                printk("Impossible source operand size of movzx instr: %d\n", size);
   51.29 +                domain_crash_synchronous();
   51.30              }
   51.31 +            index = operand_index(dst);
   51.32 +            set_reg_value(operand_size(dst), index, 0, regs, p->u.data);
   51.33 +        }
   51.34 +        break;
   51.35 +
   51.36 +    case INSTR_MOVSX:
   51.37 +        if (dst & REGISTER) {
   51.38 +            switch (size) {
   51.39 +            case BYTE:
   51.40 +                p->u.data &= 0xFFULL;
   51.41 +                if ( p->u.data & 0x80ULL )
   51.42 +                    p->u.data |= 0xFFFFFFFFFFFFFF00ULL;
   51.43 +                break;
   51.44 +
   51.45 +            case WORD:
   51.46 +                p->u.data &= 0xFFFFULL;
   51.47 +                if ( p->u.data & 0x8000ULL )
   51.48 +                    p->u.data |= 0xFFFFFFFFFFFF0000ULL;
   51.49 +                break;
   51.50 +
   51.51 +            case LONG:
   51.52 +                p->u.data &= 0xFFFFFFFFULL;
   51.53 +                if ( p->u.data & 0x80000000ULL )
   51.54 +                    p->u.data |= 0xFFFFFFFF00000000ULL;
   51.55 +                break;
   51.56 +
   51.57 +            default:
   51.58 +                printk("Impossible source operand size of movsx instr: %d\n", size);
   51.59 +                domain_crash_synchronous();
   51.60 +            }
   51.61 +            index = operand_index(dst);
   51.62              set_reg_value(operand_size(dst), index, 0, regs, p->u.data);
   51.63          }
   51.64          break;
    52.1 --- a/xen/arch/x86/vmx_platform.c	Thu Nov 10 15:24:29 2005 -0600
    52.2 +++ b/xen/arch/x86/vmx_platform.c	Fri Nov 11 10:47:43 2005 +0100
    52.3 @@ -581,25 +581,39 @@ static int vmx_decode(int vm86, unsigned
    52.4      }
    52.5  
    52.6      switch (*++opcode) {
    52.7 -    case 0xB6: /* movz m8, r16/r32 */
    52.8 -        instr->instr = INSTR_MOVZ;
    52.9 +    case 0xB6: /* movzx m8, r16/r32/r64 */
   52.10 +        instr->instr = INSTR_MOVZX;
   52.11          GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
   52.12          index = get_index(opcode + 1, rex);
   52.13          instr->operand[0] = mk_operand(BYTE, 0, 0, MEMORY);
   52.14          instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
   52.15          return DECODE_success;
   52.16  
   52.17 -    case 0xB7: /* movz m16/m32, r32/r64 */
   52.18 -        instr->instr = INSTR_MOVZ;
   52.19 +    case 0xB7: /* movzx m16/m32, r32/r64 */
   52.20 +        instr->instr = INSTR_MOVZX;
   52.21 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
   52.22          index = get_index(opcode + 1, rex);
   52.23 -        if (rex & 0x8) {
   52.24 -            instr->op_size = LONG;
   52.25 -            instr->operand[1] = mk_operand(QUAD, index, 0, REGISTER);
   52.26 -        } else {
   52.27 -            instr->op_size = WORD;
   52.28 -            instr->operand[1] = mk_operand(LONG, index, 0, REGISTER);
   52.29 -        }
   52.30 -        instr->operand[0] = mk_operand(instr->op_size, 0, 0, MEMORY);
   52.31 +        if (rex & 0x8)
   52.32 +            instr->operand[0] = mk_operand(LONG, 0, 0, MEMORY);
   52.33 +        else
   52.34 +            instr->operand[0] = mk_operand(WORD, 0, 0, MEMORY);
   52.35 +        instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
   52.36 +        return DECODE_success;
   52.37 +
   52.38 +    case 0xBE: /* movsx m8, r16/r32/r64 */
   52.39 +        instr->instr = INSTR_MOVSX;
   52.40 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
   52.41 +        index = get_index(opcode + 1, rex);
   52.42 +        instr->operand[0] = mk_operand(BYTE, 0, 0, MEMORY);
   52.43 +        instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
   52.44 +        return DECODE_success;
   52.45 +
   52.46 +    case 0xBF: /* movsx m16, r32/r64 */
   52.47 +        instr->instr = INSTR_MOVSX;
   52.48 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
   52.49 +        index = get_index(opcode + 1, rex);
   52.50 +        instr->operand[0] = mk_operand(WORD, 0, 0, MEMORY);
   52.51 +        instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
   52.52          return DECODE_success;
   52.53  
   52.54      case 0xA3: /* bt r32, m32 */
   52.55 @@ -702,7 +716,7 @@ static void mmio_operands(int type, unsi
   52.56          send_mmio_req(type, gpa, 1, inst->op_size, value, IOREQ_WRITE, 0);
   52.57      } else if (inst->operand[0] & MEMORY) { /* dest is register */
   52.58          /* send the request and wait for the value */
   52.59 -        if (inst->instr == INSTR_MOVZ)
   52.60 +        if ( (inst->instr == INSTR_MOVZX) || (inst->instr == INSTR_MOVSX) )
   52.61              send_mmio_req(type, gpa, 1, size_reg, 0, IOREQ_READ, 0);
   52.62          else
   52.63              send_mmio_req(type, gpa, 1, inst->op_size, 0, IOREQ_READ, 0);
   52.64 @@ -827,7 +841,8 @@ void handle_mmio(unsigned long va, unsig
   52.65          break;
   52.66      }
   52.67  
   52.68 -    case INSTR_MOVZ:
   52.69 +    case INSTR_MOVZX:
   52.70 +    case INSTR_MOVSX:
   52.71          mmio_operands(IOREQ_TYPE_COPY, gpa, &mmio_inst, mmio_opp, regs);
   52.72          break;
   52.73  
    53.1 --- a/xen/arch/x86/vmx_vlapic.c	Thu Nov 10 15:24:29 2005 -0600
    53.2 +++ b/xen/arch/x86/vmx_vlapic.c	Fri Nov 11 10:47:43 2005 +0100
    53.3 @@ -119,22 +119,35 @@ uint32_t vlapic_update_ppr(struct vlapic
    53.4  }
    53.5  
    53.6  /* This only for fixed delivery mode */
    53.7 -int vlapic_match_dest(struct vlapic *target, struct vlapic *source,
    53.8 -                      int short_hand, int dest, int dest_mode,
    53.9 -                      int delivery_mode)
   53.10 +static int vlapic_match_dest(struct vcpu *v, struct vlapic *source,
   53.11 +                             int short_hand, int dest, int dest_mode,
   53.12 +                             int delivery_mode)
   53.13  {
   53.14      int result = 0;
   53.15 +    struct vlapic *target = VLAPIC(v);
   53.16  
   53.17      VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_match_dest: "
   53.18                  "target %p source %p dest %x dest_mode %x short_hand %x "
   53.19                  "delivery_mode %x",
   53.20                  target, source, dest, dest_mode, short_hand, delivery_mode);
   53.21  
   53.22 +    if ( unlikely(!target) &&
   53.23 +         ( (delivery_mode != VLAPIC_DELIV_MODE_INIT) &&
   53.24 +           (delivery_mode != VLAPIC_DELIV_MODE_STARTUP) &&
   53.25 +           (delivery_mode != VLAPIC_DELIV_MODE_NMI) )) {
   53.26 +        VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_match_dest "
   53.27 +                    "uninitialized target v %p delivery_mode %x dest %x\n",
   53.28 +                    v, delivery_mode, dest);
   53.29 +        return result;
   53.30 +    }
   53.31 +
   53.32      switch (short_hand) {
   53.33      case VLAPIC_NO_SHORTHAND:
   53.34          if (!dest_mode) {   /* Physical */
   53.35 -            result = (target->id == dest);
   53.36 +            result = ((target ? target->id : v->vcpu_id ) == dest);
   53.37          } else {            /* Logical */
   53.38 +            if (!target)
   53.39 +                break;
   53.40              if (((target->dest_format >> 28) & 0xf) == 0xf) {   /* Flat mode */
   53.41                  result = (target->logical_dest >> 24) & dest;
   53.42              } else {
   53.43 @@ -176,17 +189,18 @@ int vlapic_match_dest(struct vlapic *tar
   53.44   * Add a pending IRQ into lapic.
   53.45   * Return 1 if successfully added and 0 if discarded.
   53.46   */
   53.47 -int vlapic_accept_irq(struct vlapic *vlapic, int delivery_mode,
   53.48 -                      int vector, int level, int trig_mode)
   53.49 +static int vlapic_accept_irq(struct vcpu *v, int delivery_mode,
   53.50 +                             int vector, int level, int trig_mode)
   53.51  {
   53.52 -    int	result = 1;
   53.53 +    int	result = 0;
   53.54 +    struct vlapic *vlapic = VLAPIC(v);
   53.55  
   53.56      switch (delivery_mode) {
   53.57      case VLAPIC_DELIV_MODE_FIXED:
   53.58      case VLAPIC_DELIV_MODE_LPRI:
   53.59          /* FIXME add logic for vcpu on reset */
   53.60 -        if (!vlapic->vcpu || !vlapic_enabled(vlapic))
   53.61 -            return 0;
   53.62 +        if (unlikely(!vlapic || !vlapic_enabled(vlapic)))
   53.63 +            return result;
   53.64  
   53.65          if (test_and_set_bit(vector, &vlapic->irr[0])) {
   53.66              printk("<vlapic_accept_irq>"
   53.67 @@ -199,6 +213,7 @@ int vlapic_accept_irq(struct vlapic *vla
   53.68              }
   53.69          }
   53.70          evtchn_set_pending(vlapic->vcpu, iopacket_port(vlapic->domain));
   53.71 +        result = 1;
   53.72          break;
   53.73  
   53.74      case VLAPIC_DELIV_MODE_RESERVED:
   53.75 @@ -269,15 +284,12 @@ struct vlapic* apic_round_robin(struct d
   53.76  
   53.77      old = next = d->arch.vmx_platform.round_info[vector];
   53.78  
   53.79 -    next++;
   53.80 -    if (next == MAX_VIRT_CPUS || !d->vcpu[next])
   53.81 -        next = 0;
   53.82 -
   53.83      do {
   53.84          /* the vcpu array is arranged according to vcpu_id */
   53.85          if (test_bit(next, &bitmap)) {
   53.86              target = d->vcpu[next]->arch.arch_vmx.vlapic;
   53.87 -            if (!vlapic_enabled(target)) {
   53.88 +
   53.89 +            if (!target || !vlapic_enabled(target)) {
   53.90                  printk("warning: targe round robin local apic disabled\n");
   53.91                  /* XXX should we domain crash?? Or should we return NULL */
   53.92              }
   53.93 @@ -285,7 +297,9 @@ struct vlapic* apic_round_robin(struct d
   53.94          }
   53.95  
   53.96          next ++;
   53.97 -        if (next == MAX_VIRT_CPUS || !d->vcpu[next])
   53.98 +        if (!d->vcpu[next] ||
   53.99 +            !test_bit(_VCPUF_initialised, &d->vcpu[next]->vcpu_flags) ||
  53.100 +            next == MAX_VIRT_CPUS)
  53.101              next = 0;
  53.102      }while(next != old);
  53.103  
  53.104 @@ -319,7 +333,7 @@ int vlapic_check_vector(struct vlapic *v
  53.105  {
  53.106      if ((dm == VLAPIC_DELIV_MODE_FIXED) && (vector < 16)) {
  53.107          vlapic->err_status |= 0x40;
  53.108 -        vlapic_accept_irq(vlapic, VLAPIC_DELIV_MODE_FIXED,
  53.109 +        vlapic_accept_irq(vlapic->vcpu, VLAPIC_DELIV_MODE_FIXED,
  53.110            vlapic_lvt_vector(vlapic, VLAPIC_LVT_ERROR), 0, 0);
  53.111          printk("<vlapic_check_vector>: check fail\n");
  53.112          return 0;
  53.113 @@ -340,7 +354,6 @@ void vlapic_ipi(struct vlapic *vlapic)
  53.114  
  53.115      struct vlapic *target;
  53.116      struct vcpu *v = NULL;
  53.117 -    int result = 0;
  53.118      uint32_t lpr_map;
  53.119  
  53.120      VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "vlapic_ipi: "
  53.121 @@ -352,32 +365,27 @@ void vlapic_ipi(struct vlapic *vlapic)
  53.122                  delivery_mode, vector);
  53.123  
  53.124      for_each_vcpu ( vlapic->domain, v ) {
  53.125 -        target = VLAPIC(v);
  53.126 -        if (vlapic_match_dest(target, vlapic, short_hand,
  53.127 +        if (vlapic_match_dest(v, vlapic, short_hand,
  53.128                                dest, dest_mode, delivery_mode)) {
  53.129              if (delivery_mode == VLAPIC_DELIV_MODE_LPRI) {
  53.130                  set_bit(v->vcpu_id, &lpr_map);
  53.131 -            }else
  53.132 -                result = vlapic_accept_irq(target, delivery_mode,
  53.133 -                  vector, level, trig_mode);
  53.134 +            } else
  53.135 +                vlapic_accept_irq(v, delivery_mode,
  53.136 +                                  vector, level, trig_mode);
  53.137          }
  53.138      }
  53.139  
  53.140      if (delivery_mode == VLAPIC_DELIV_MODE_LPRI) {
  53.141 -        extern struct vlapic*
  53.142 -          apic_round_robin(struct domain *d,
  53.143 -            uint8_t dest_mode, uint8_t vector, uint32_t bitmap);
  53.144 -
  53.145          v = vlapic->vcpu;
  53.146          target = apic_round_robin(v->domain, dest_mode, vector, lpr_map);
  53.147  
  53.148          if (target)
  53.149 -            vlapic_accept_irq(target, delivery_mode,
  53.150 -              vector, level, trig_mode);
  53.151 +            vlapic_accept_irq(target->vcpu, delivery_mode,
  53.152 +                              vector, level, trig_mode);
  53.153      }
  53.154  }
  53.155  
  53.156 -void vlapic_begin_timer(struct vlapic *vlapic)
  53.157 +static void vlapic_begin_timer(struct vlapic *vlapic)
  53.158  {
  53.159      s_time_t cur = NOW(), offset;
  53.160  
  53.161 @@ -559,7 +567,9 @@ static unsigned long vlapic_read(struct 
  53.162  
  53.163      if ( len != 4) {
  53.164          /* some bugs on kernel cause read this with byte*/
  53.165 -        printk("Local APIC read with len = %lx, should be 4 instead\n", len);
  53.166 +        VMX_DBG_LOG(DBG_LEVEL_VLAPIC,
  53.167 +                    "Local APIC read with len = %lx, should be 4 instead\n",
  53.168 +                    len);
  53.169      }
  53.170  
  53.171      alignment = offset & 0x3;
  53.172 @@ -737,12 +747,13 @@ static void vlapic_write(struct vcpu *v,
  53.173          vlapic->timer_current = val;
  53.174          vlapic->timer_current_update = NOW();
  53.175  
  53.176 +        vlapic_begin_timer(vlapic);
  53.177 +
  53.178          VMX_DBG_LOG(DBG_LEVEL_VLAPIC, "timer_init %x timer_current %x"
  53.179                      "timer_current_update %08x%08x",
  53.180                      vlapic->timer_initial, vlapic->timer_current,
  53.181                      (uint32_t)(vlapic->timer_current_update >> 32),
  53.182                      (uint32_t)vlapic->timer_current_update);
  53.183 -                    vlapic_begin_timer(vlapic);
  53.184          break;
  53.185  
  53.186      case APIC_TDCR:
  53.187 @@ -827,6 +838,7 @@ void vlapic_timer_fn(void *data)
  53.188          }
  53.189          else
  53.190              vlapic->intr_pending_count[vlapic_lvt_vector(vlapic, VLAPIC_LVT_TIMER)]++;
  53.191 +        evtchn_set_pending(vlapic->vcpu, iopacket_port(vlapic->domain));
  53.192      }
  53.193  
  53.194      vlapic->timer_current_update = NOW();
    54.1 --- a/xen/arch/x86/vmx_vmcs.c	Thu Nov 10 15:24:29 2005 -0600
    54.2 +++ b/xen/arch/x86/vmx_vmcs.c	Fri Nov 11 10:47:43 2005 +0100
    54.3 @@ -332,7 +332,7 @@ static void vmx_do_launch(struct vcpu *v
    54.4      error |= __vmwrite(GUEST_TR_BASE, 0);
    54.5      error |= __vmwrite(GUEST_TR_LIMIT, 0xff);
    54.6  
    54.7 -    __vmwrite(GUEST_CR3, pagetable_get_paddr(v->arch.guest_table));
    54.8 +    __vmwrite(GUEST_CR3, pagetable_get_paddr(v->domain->arch.phys_table));
    54.9      __vmwrite(HOST_CR3, pagetable_get_paddr(v->arch.monitor_table));
   54.10      __vmwrite(HOST_RSP, (unsigned long)get_stack_bottom());
   54.11  
    55.1 --- a/xen/arch/x86/x86_32/asm-offsets.c	Thu Nov 10 15:24:29 2005 -0600
    55.2 +++ b/xen/arch/x86/x86_32/asm-offsets.c	Fri Nov 11 10:47:43 2005 +0100
    55.3 @@ -75,7 +75,6 @@ void __dummy__(void)
    55.4      BLANK();
    55.5  
    55.6      OFFSET(TRAPBOUNCE_error_code, struct trap_bounce, error_code);
    55.7 -    OFFSET(TRAPBOUNCE_cr2, struct trap_bounce, cr2);
    55.8      OFFSET(TRAPBOUNCE_flags, struct trap_bounce, flags);
    55.9      OFFSET(TRAPBOUNCE_cs, struct trap_bounce, cs);
   55.10      OFFSET(TRAPBOUNCE_eip, struct trap_bounce, eip);
    56.1 --- a/xen/arch/x86/x86_32/entry.S	Thu Nov 10 15:24:29 2005 -0600
    56.2 +++ b/xen/arch/x86/x86_32/entry.S	Fri Nov 11 10:47:43 2005 +0100
    56.3 @@ -156,7 +156,7 @@ 1:
    56.4           * By this time, all the setups in the VMCS must be complete.
    56.5           */
    56.6          .if \launch
    56.7 -        /* VMLUANCH */
    56.8 +        /* VMLAUNCH */
    56.9          .byte 0x0f,0x01,0xc2
   56.10          pushf
   56.11          call vm_launch_fail
   56.12 @@ -394,37 +394,37 @@ FLT14:  movl %eax,%gs:(%esi)
   56.13          shll $16,%eax                    # Bits 16-23: saved_upcall_mask
   56.14          movw UREGS_cs+4(%esp),%ax        # Bits  0-15: CS
   56.15  FLT15:  movl %eax,%gs:4(%esi) 
   56.16 +        test $0x00FF0000,%eax            # Bits 16-23: saved_upcall_mask
   56.17 +        setz %ch                         # %ch == !saved_upcall_mask
   56.18          movl UREGS_eflags+4(%esp),%eax
   56.19 +        andl $~X86_EFLAGS_IF,%eax
   56.20 +        shlb $1,%ch                      # Bit 9 (EFLAGS.IF)
   56.21 +        orb  %ch,%ah                     # Fold EFLAGS.IF into %eax
   56.22  FLT16:  movl %eax,%gs:8(%esi)
   56.23          test $TBF_EXCEPTION_ERRCODE,%cl
   56.24          jz   1f
   56.25          subl $4,%esi                    # push error_code onto guest frame
   56.26          movl TRAPBOUNCE_error_code(%edx),%eax
   56.27  FLT17:  movl %eax,%gs:(%esi)
   56.28 -        testb $TBF_EXCEPTION_CR2,%cl
   56.29 -        jz   2f
   56.30 -        subl $4,%esi                    # push %cr2 onto guest frame
   56.31 -        movl TRAPBOUNCE_cr2(%edx),%eax
   56.32 -FLT18:  movl %eax,%gs:(%esi)
   56.33  1:      testb $TBF_FAILSAFE,%cl
   56.34          jz   2f
   56.35          subl $16,%esi                # add DS/ES/FS/GS to failsafe stack frame
   56.36          testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp)
   56.37          jz   nvm86_2
   56.38          xorl %eax,%eax               # VM86: we write zero selector values
   56.39 -FLT19:  movl %eax,%gs:(%esi) 
   56.40 -FLT20:  movl %eax,%gs:4(%esi)
   56.41 -FLT21:  movl %eax,%gs:8(%esi) 
   56.42 -FLT22:  movl %eax,%gs:12(%esi)
   56.43 +FLT18:  movl %eax,%gs:(%esi) 
   56.44 +FLT19:  movl %eax,%gs:4(%esi)
   56.45 +FLT20:  movl %eax,%gs:8(%esi) 
   56.46 +FLT21:  movl %eax,%gs:12(%esi)
   56.47          jmp  2f
   56.48  nvm86_2:movl UREGS_ds+4(%esp),%eax   # non-VM86: write real selector values
   56.49 -FLT23:  movl %eax,%gs:(%esi) 
   56.50 +FLT22:  movl %eax,%gs:(%esi) 
   56.51          movl UREGS_es+4(%esp),%eax
   56.52 -FLT24:  movl %eax,%gs:4(%esi)
   56.53 +FLT23:  movl %eax,%gs:4(%esi)
   56.54          movl UREGS_fs+4(%esp),%eax
   56.55 -FLT25:  movl %eax,%gs:8(%esi) 
   56.56 +FLT24:  movl %eax,%gs:8(%esi) 
   56.57          movl UREGS_gs+4(%esp),%eax
   56.58 -FLT26:  movl %eax,%gs:12(%esi)
   56.59 +FLT25:  movl %eax,%gs:12(%esi)
   56.60  2:      testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp)
   56.61          jz   nvm86_3
   56.62          xorl %eax,%eax      /* zero DS-GS, just as a real CPU would */
   56.63 @@ -456,7 +456,6 @@ nvm86_3:/* Rewrite our stack frame and r
   56.64          .long FLT20,domain_crash_synchronous , FLT21,domain_crash_synchronous
   56.65          .long FLT22,domain_crash_synchronous , FLT23,domain_crash_synchronous
   56.66          .long FLT24,domain_crash_synchronous , FLT25,domain_crash_synchronous
   56.67 -        .long FLT26,domain_crash_synchronous
   56.68  .previous
   56.69  
   56.70          ALIGN
    57.1 --- a/xen/arch/x86/x86_64/asm-offsets.c	Thu Nov 10 15:24:29 2005 -0600
    57.2 +++ b/xen/arch/x86/x86_64/asm-offsets.c	Fri Nov 11 10:47:43 2005 +0100
    57.3 @@ -75,7 +75,6 @@ void __dummy__(void)
    57.4      BLANK();
    57.5  
    57.6      OFFSET(TRAPBOUNCE_error_code, struct trap_bounce, error_code);
    57.7 -    OFFSET(TRAPBOUNCE_cr2, struct trap_bounce, cr2);
    57.8      OFFSET(TRAPBOUNCE_flags, struct trap_bounce, flags);
    57.9      OFFSET(TRAPBOUNCE_cs, struct trap_bounce, cs);
   57.10      OFFSET(TRAPBOUNCE_eip, struct trap_bounce, eip);
    58.1 --- a/xen/arch/x86/x86_64/entry.S	Thu Nov 10 15:24:29 2005 -0600
    58.2 +++ b/xen/arch/x86/x86_64/entry.S	Fri Nov 11 10:47:43 2005 +0100
    58.3 @@ -352,8 +352,6 @@ 1:      movb  TRAPBOUNCE_flags(%rdx),%cl
    58.4  FLT2:   movq  %rax,32(%rsi)             # SS
    58.5          movq  UREGS_rsp+8(%rsp),%rax
    58.6  FLT3:   movq  %rax,24(%rsi)             # RSP
    58.7 -        movq  UREGS_eflags+8(%rsp),%rax
    58.8 -FLT4:   movq  %rax,16(%rsi)             # RFLAGS
    58.9          movq  VCPU_vcpu_info(%rbx),%rax
   58.10          pushq VCPUINFO_upcall_mask(%rax)
   58.11          testb $TBF_INTERRUPT,%cl
   58.12 @@ -362,7 +360,15 @@ FLT4:   movq  %rax,16(%rsi)             
   58.13          popq  %rax
   58.14          shlq  $32,%rax                  # Bits 32-39: saved_upcall_mask
   58.15          movw  UREGS_cs+8(%rsp),%ax      # Bits  0-15: CS
   58.16 -FLT5:   movq  %rax,8(%rsi)              # CS/saved_upcall_mask
   58.17 +FLT4:   movq  %rax,8(%rsi)              # CS / saved_upcall_mask
   58.18 +        shrq  $32,%rax
   58.19 +        testb $0xFF,%al                 # Bits 0-7: saved_upcall_mask
   58.20 +        setz  %ch                       # %ch == !saved_upcall_mask
   58.21 +        movq  UREGS_eflags+8(%rsp),%rax
   58.22 +        andq  $~X86_EFLAGS_IF,%rax
   58.23 +        shlb  $1,%ch                    # Bit 9 (EFLAGS.IF)
   58.24 +        orb   %ch,%ah                   # Fold EFLAGS.IF into %eax
   58.25 +FLT5:   movq  %rax,16(%rsi)             # RFLAGS
   58.26          movq  UREGS_rip+8(%rsp),%rax
   58.27  FLT6:   movq  %rax,(%rsi)               # RIP
   58.28          testb $TBF_EXCEPTION_ERRCODE,%cl
   58.29 @@ -370,27 +376,22 @@ FLT6:   movq  %rax,(%rsi)               
   58.30          subq  $8,%rsi
   58.31          movl  TRAPBOUNCE_error_code(%rdx),%eax
   58.32  FLT7:   movq  %rax,(%rsi)               # ERROR CODE
   58.33 -        testb $TBF_EXCEPTION_CR2,%cl
   58.34 -        jz    2f
   58.35 -        subq  $8,%rsi
   58.36 -        movq  TRAPBOUNCE_cr2(%rdx),%rax
   58.37 -FLT8:   movq  %rax,(%rsi)               # CR2
   58.38  1:      testb $TBF_FAILSAFE,%cl
   58.39          jz    2f
   58.40          subq  $32,%rsi
   58.41          movl  %gs,%eax
   58.42 -FLT9:   movq  %rax,24(%rsi)             # GS
   58.43 +FLT8:   movq  %rax,24(%rsi)             # GS
   58.44          movl  %fs,%eax
   58.45 -FLT10:  movq  %rax,16(%rsi)             # FS
   58.46 +FLT9:   movq  %rax,16(%rsi)             # FS
   58.47          movl  %es,%eax
   58.48 -FLT11:  movq  %rax,8(%rsi)              # ES
   58.49 +FLT10:  movq  %rax,8(%rsi)              # ES
   58.50          movl  %ds,%eax
   58.51 -FLT12:  movq  %rax,(%rsi)               # DS
   58.52 +FLT11:  movq  %rax,(%rsi)               # DS
   58.53  2:      subq  $16,%rsi
   58.54          movq  UREGS_r11+8(%rsp),%rax
   58.55 -FLT13:  movq  %rax,8(%rsi)              # R11
   58.56 +FLT12:  movq  %rax,8(%rsi)              # R11
   58.57          movq  UREGS_rcx+8(%rsp),%rax
   58.58 -FLT14:  movq  %rax,(%rsi)               # RCX
   58.59 +FLT13:  movq  %rax,(%rsi)               # RCX
   58.60          /* Rewrite our stack frame and return to guest-OS mode. */
   58.61          /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */
   58.62          movl  $TRAP_syscall,UREGS_entry_vector+8(%rsp)
   58.63 @@ -411,7 +412,6 @@ FLT14:  movq  %rax,(%rsi)               
   58.64          .quad  FLT8,domain_crash_synchronous ,  FLT9,domain_crash_synchronous
   58.65          .quad FLT10,domain_crash_synchronous , FLT11,domain_crash_synchronous
   58.66          .quad FLT12,domain_crash_synchronous , FLT13,domain_crash_synchronous
   58.67 -        .quad FLT14,domain_crash_synchronous
   58.68  .previous
   58.69  
   58.70          ALIGN
    59.1 --- a/xen/include/asm-x86/domain.h	Thu Nov 10 15:24:29 2005 -0600
    59.2 +++ b/xen/include/asm-x86/domain.h	Fri Nov 11 10:47:43 2005 +0100
    59.3 @@ -8,7 +8,6 @@
    59.4  
    59.5  struct trap_bounce {
    59.6      unsigned long  error_code;
    59.7 -    unsigned long  cr2;
    59.8      unsigned short flags; /* TBF_ */
    59.9      unsigned short cs;
   59.10      unsigned long  eip;
    60.1 --- a/xen/include/asm-x86/processor.h	Thu Nov 10 15:24:29 2005 -0600
    60.2 +++ b/xen/include/asm-x86/processor.h	Fri Nov 11 10:47:43 2005 +0100
    60.3 @@ -121,7 +121,6 @@
    60.4  /* 'trap_bounce' flags values */
    60.5  #define TBF_EXCEPTION          1
    60.6  #define TBF_EXCEPTION_ERRCODE  2
    60.7 -#define TBF_EXCEPTION_CR2      4
    60.8  #define TBF_INTERRUPT          8
    60.9  #define TBF_FAILSAFE          16
   60.10  
    61.1 --- a/xen/include/asm-x86/vmx_platform.h	Thu Nov 10 15:24:29 2005 -0600
    61.2 +++ b/xen/include/asm-x86/vmx_platform.h	Fri Nov 11 10:47:43 2005 +0100
    61.3 @@ -55,17 +55,18 @@
    61.4  #define REPNZ   0x2
    61.5  #define OVERLAP 0x4
    61.6  
    61.7 -#define INSTR_PIO 1
    61.8 -#define INSTR_OR 2
    61.9 -#define INSTR_AND 3
   61.10 -#define INSTR_XOR 4
   61.11 -#define INSTR_CMP 5
   61.12 -#define INSTR_MOV 6
   61.13 -#define INSTR_MOVS 7
   61.14 -#define INSTR_MOVZ 8
   61.15 -#define INSTR_STOS 9
   61.16 -#define INSTR_TEST 10
   61.17 -#define INSTR_BT 11
   61.18 +#define INSTR_PIO   1
   61.19 +#define INSTR_OR    2
   61.20 +#define INSTR_AND   3
   61.21 +#define INSTR_XOR   4
   61.22 +#define INSTR_CMP   5
   61.23 +#define INSTR_MOV   6
   61.24 +#define INSTR_MOVS  7
   61.25 +#define INSTR_MOVZX 8
   61.26 +#define INSTR_MOVSX 9
   61.27 +#define INSTR_STOS  10
   61.28 +#define INSTR_TEST  11
   61.29 +#define INSTR_BT    12
   61.30  
   61.31  struct instruction {
   61.32      __s8    instr; /* instruction type */
    62.1 --- a/xen/include/asm-x86/vmx_vioapic.h	Thu Nov 10 15:24:29 2005 -0600
    62.2 +++ b/xen/include/asm-x86/vmx_vioapic.h	Fri Nov 11 10:47:43 2005 +0100
    62.3 @@ -92,9 +92,10 @@ typedef union RedirStatus
    62.4  #define MAX_LAPIC_NUM        32
    62.5  
    62.6  typedef struct vmx_vioapic {
    62.7 -    uint32_t ioregsel;
    62.8      uint32_t irr;
    62.9      uint32_t isr;           /* This is used for level trigger */
   62.10 +    uint32_t imr;
   62.11 +    uint32_t ioregsel;
   62.12      uint32_t flags;
   62.13      uint32_t lapic_count;
   62.14      uint32_t id;
    63.1 --- a/xen/include/public/arch-ia64.h	Thu Nov 10 15:24:29 2005 -0600
    63.2 +++ b/xen/include/public/arch-ia64.h	Fri Nov 11 10:47:43 2005 +0100
    63.3 @@ -271,12 +271,10 @@ typedef struct {
    63.4  
    63.5  typedef mapped_regs_t vpd_t;
    63.6  
    63.7 -#define __ARCH_HAS_VCPU_INFO
    63.8 -
    63.9  typedef struct {
   63.10      unsigned int flags;
   63.11      unsigned long start_info_pfn;
   63.12 -} arch_shared_info_t;  // DON'T PACK 
   63.13 +} arch_shared_info_t;
   63.14  
   63.15  typedef struct vcpu_guest_context {
   63.16  #define VGCF_FPU_VALID (1<<0)
    64.1 --- a/xen/include/public/arch-x86_32.h	Thu Nov 10 15:24:29 2005 -0600
    64.2 +++ b/xen/include/public/arch-x86_32.h	Fri Nov 11 10:47:43 2005 +0100
    64.3 @@ -90,7 +90,7 @@ typedef struct cpu_user_regs {
    64.4      uint16_t cs;
    64.5      uint8_t  saved_upcall_mask;
    64.6      uint8_t  _pad0;
    64.7 -    uint32_t eflags;
    64.8 +    uint32_t eflags;        /* eflags.IF == !saved_upcall_mask */
    64.9      uint32_t esp;
   64.10      uint16_t ss, _pad1;
   64.11      uint16_t es, _pad2;
   64.12 @@ -132,6 +132,11 @@ typedef struct arch_shared_info {
   64.13      unsigned long pfn_to_mfn_frame_list_list; 
   64.14  } arch_shared_info_t;
   64.15  
   64.16 +typedef struct {
   64.17 +    unsigned long cr2;
   64.18 +    unsigned long pad; /* sizeof(vcpu_info_t) == 16 */
   64.19 +} arch_vcpu_info_t;
   64.20 +
   64.21  #endif
   64.22  
   64.23  #endif
    65.1 --- a/xen/include/public/arch-x86_64.h	Thu Nov 10 15:24:29 2005 -0600
    65.2 +++ b/xen/include/public/arch-x86_64.h	Fri Nov 11 10:47:43 2005 +0100
    65.3 @@ -154,7 +154,7 @@ typedef struct cpu_user_regs {
    65.4      uint16_t cs, _pad0[1];
    65.5      uint8_t  saved_upcall_mask;
    65.6      uint8_t  _pad1[3];
    65.7 -    __DECL_REG(flags);
    65.8 +    __DECL_REG(flags);      /* rflags.IF == !saved_upcall_mask */
    65.9      __DECL_REG(sp);
   65.10      uint16_t ss, _pad2[3];
   65.11      uint16_t es, _pad3[3];
   65.12 @@ -201,6 +201,11 @@ typedef struct arch_shared_info {
   65.13      unsigned long pfn_to_mfn_frame_list_list; 
   65.14  } arch_shared_info_t;
   65.15  
   65.16 +typedef struct {
   65.17 +    unsigned long cr2;
   65.18 +    unsigned long pad; /* sizeof(vcpu_info_t) == 32 */
   65.19 +} arch_vcpu_info_t;
   65.20 +
   65.21  #endif /* !__ASSEMBLY__ */
   65.22  
   65.23  #endif
    66.1 --- a/xen/include/public/dom0_ops.h	Thu Nov 10 15:24:29 2005 -0600
    66.2 +++ b/xen/include/public/dom0_ops.h	Fri Nov 11 10:47:43 2005 +0100
    66.3 @@ -19,7 +19,7 @@
    66.4   * This makes sure that old versions of dom0 tools will stop working in a
    66.5   * well-defined way (rather than crashing the machine, for instance).
    66.6   */
    66.7 -#define DOM0_INTERFACE_VERSION   0xAAAA1011
    66.8 +#define DOM0_INTERFACE_VERSION   0xAAAA1012
    66.9  
   66.10  /************************************************************************/
   66.11  
    67.1 --- a/xen/include/public/xen.h	Thu Nov 10 15:24:29 2005 -0600
    67.2 +++ b/xen/include/public/xen.h	Fri Nov 11 10:47:43 2005 +0100
    67.3 @@ -299,9 +299,7 @@ typedef struct vcpu_info {
    67.4      uint8_t evtchn_upcall_pending;
    67.5      uint8_t evtchn_upcall_mask;
    67.6      unsigned long evtchn_pending_sel;
    67.7 -#ifdef __ARCH_HAS_VCPU_INFO
    67.8      arch_vcpu_info_t arch;
    67.9 -#endif
   67.10  } vcpu_info_t;
   67.11  
   67.12  typedef struct vcpu_time_info {