ia64/xen-unstable

changeset 14293:50d5bf02e59e

merge with xen-unstable.hg
author awilliam@xenbuild2.aw
date Wed Mar 07 12:38:28 2007 -0700 (2007-03-07)
parents 8a58ea36e420 8117f6684991
children 210858e4f6d5
files linux-2.6-xen-sparse/arch/i386/kernel/alternative-xen.c linux-2.6-xen-sparse/arch/i386/kernel/cpu/intel_cacheinfo-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/x8664_ksyms-xen.c linux-2.6-xen-sparse/mm/Kconfig tools/ptsname/Makefile tools/ptsname/ptsname.c tools/ptsname/setup.py xen/arch/ia64/xen/dom0_ops.c xen/arch/ia64/xen/mm.c xen/include/asm-ia64/mm.h
line diff
     1.1 --- a/Config.mk	Thu Mar 01 15:02:09 2007 -0700
     1.2 +++ b/Config.mk	Wed Mar 07 12:38:28 2007 -0700
     1.3 @@ -73,9 +73,10 @@ ACM_SECURITY ?= n
     1.4  ACM_DEFAULT_SECURITY_POLICY ?= ACM_NULL_POLICY
     1.5  
     1.6  # Optional components
     1.7 -XENSTAT_XENTOP ?= y
     1.8 -VTPM_TOOLS ?= n
     1.9 +XENSTAT_XENTOP     ?= y
    1.10 +VTPM_TOOLS         ?= n
    1.11  LIBXENAPI_BINDINGS ?= n
    1.12 -XENFB_TOOLS ?= n
    1.13 +XENFB_TOOLS        ?= n
    1.14 +PYTHON_TOOLS       ?= y
    1.15  
    1.16  -include $(XEN_ROOT)/.config
     2.1 --- a/README	Thu Mar 01 15:02:09 2007 -0700
     2.2 +++ b/README	Wed Mar 07 12:38:28 2007 -0700
     2.3 @@ -92,6 +92,8 @@ provided by your Linux distributor:
     2.4      * Development install of zlib (e.g., zlib-dev)
     2.5      * Development install of Python v2.3 or later (e.g., python-dev)
     2.6      * Development install of curses (e.g., libncurses-dev)
     2.7 +    * Development install of openssl (e.g., openssl-dev)
     2.8 +    * Development install of x11 (e.g. xorg-x11-dev)
     2.9      * bridge-utils package (/sbin/brctl)
    2.10      * iproute package (/sbin/ip)
    2.11      * hotplug or udev
     3.1 --- a/config/StdGNU.mk	Thu Mar 01 15:02:09 2007 -0700
     3.2 +++ b/config/StdGNU.mk	Wed Mar 07 12:38:28 2007 -0700
     3.3 @@ -12,9 +12,9 @@ OBJDUMP    = $(CROSS_COMPILE)objdump
     3.4  MSGFMT     = msgfmt
     3.5  
     3.6  INSTALL      = install
     3.7 -INSTALL_DIR  = $(INSTALL) -d -m0755
     3.8 -INSTALL_DATA = $(INSTALL) -m0644
     3.9 -INSTALL_PROG = $(INSTALL) -m0755
    3.10 +INSTALL_DIR  = $(INSTALL) -d -m0755 -p
    3.11 +INSTALL_DATA = $(INSTALL) -m0644 -p
    3.12 +INSTALL_PROG = $(INSTALL) -m0755 -p
    3.13  
    3.14  LIB64DIR = lib64
    3.15  
     4.1 --- a/config/SunOS.mk	Thu Mar 01 15:02:09 2007 -0700
     4.2 +++ b/config/SunOS.mk	Wed Mar 07 12:38:28 2007 -0700
     4.3 @@ -14,9 +14,9 @@ MSGFMT     = gmsgfmt
     4.4  SHELL      = bash
     4.5  
     4.6  INSTALL      = ginstall
     4.7 -INSTALL_DIR  = $(INSTALL) -d -m0755
     4.8 -INSTALL_DATA = $(INSTALL) -m0644
     4.9 -INSTALL_PROG = $(INSTALL) -m0755
    4.10 +INSTALL_DIR  = $(INSTALL) -d -m0755 -p
    4.11 +INSTALL_DATA = $(INSTALL) -m0644 -p
    4.12 +INSTALL_PROG = $(INSTALL) -m0755 -p
    4.13  
    4.14  LIB64DIR = lib/amd64
    4.15  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/docs/misc/dump-core-format.txt	Wed Mar 07 12:38:28 2007 -0700
     5.3 @@ -0,0 +1,231 @@
     5.4 +xen dump-core format
     5.5 +               Written by Isaku Yamahata <yamahata at valinux co jp>  Feb. 2007
     5.6 +
     5.7 +
     5.8 +Introduction
     5.9 +------------
    5.10 +With xm dump-core command, the guest domain's core can be created as a file.
    5.11 +Its format was changed to be based on ELF format because elf format is easily
    5.12 +extensible and handy. This document describes the new format.
    5.13 +In this document the new format is called new xen dump-core format,
    5.14 +xen dump-core format or simply dump-core format. The file of xen dump-core
    5.15 +format is called xen dump-core file or dump-core file.
    5.16 +
    5.17 +The usual process core file includes program headers and no section header.
    5.18 +On the other hand the xen dump-core file includes no program headers and
    5.19 +some sections because of its peculiar requirements.
    5.20 +
    5.21 +
    5.22 +Reference
    5.23 +---------
    5.24 +For ELF format itself, see Tool Interface Standard(TIS) Executable and
    5.25 +Linking Format(ELF) Specification version 1.2.
    5.26 +For xen related structure, please see the xen header files.
    5.27 +
    5.28 +
    5.29 +Elf header
    5.30 +----------
    5.31 +The elf header members are set as follows
    5.32 +        e_ident[EI_CLASS] = ELFCLASS64 = 2
    5.33 +        e_ident[EI_OSABI] = ELFOSABI_SYSV = 0
    5.34 +        e_type = ET_CORE = 4
    5.35 +ELFCLASS64 is always used independent of architecture.
    5.36 +e_ident[EI_DATA] and e_flags are set according to the dumping system's
    5.37 +architecture. Other members are set as usual.
    5.38 +
    5.39 +Sections
    5.40 +--------
    5.41 +Currently the following sections are defined. Some sections are optional.
    5.42 +
    5.43 +".note.Xen" section
    5.44 +        name            ".note.Xen"
    5.45 +        type            SHT_NOTE
    5.46 +        description
    5.47 +                This section is used as note section to store xen dump-core
    5.48 +                file specific informations. The each detailed informations are
    5.49 +                described in note section. This section must exist.
    5.50 +
    5.51 +".xen_prstatus" section
    5.52 +        name            ".xen_prstatus"
    5.53 +        type            SHT_PROGBITS
    5.54 +        structure       array of vcpu_guest_context_t
    5.55 +        description
    5.56 +                This section stores the array of vcpu_guest_context_t
    5.57 +                which is obtained by XEN_DOMCTL_getvcpucontext hypercall
    5.58 +                when the xen dump-core file is created.
    5.59 +                The size of array is stored in xch_nr_vcpus member of header
    5.60 +                note descriptor in .note.Xen note section.
    5.61 +                This section must exist.
    5.62 +
    5.63 +".xen_shared_info" section
    5.64 +        name            ".xen_shared_info"
    5.65 +        type            SHT_PROGBITS
    5.66 +        structure       shared_info_t
    5.67 +        description
    5.68 +                This section stores the contents of shared info page
    5.69 +                of a domain. This section is optional. 
    5.70 +
    5.71 +".xen_p2m" section
    5.72 +        name            ".xen_p2m"
    5.73 +        type            SHT_PROGBITS
    5.74 +        structure       array of struct xen_dumpcore_p2m
    5.75 +                        struct xen_dumpcore_p2m {
    5.76 +                            uint64_t    pfn;
    5.77 +                            uint64_t    gmfn;
    5.78 +                        };
    5.79 +        description
    5.80 +                This elements represents the frame number of the page
    5.81 +                in .xen_pages section.
    5.82 +                        pfn:    guest-specific pseudo-physical frame number
    5.83 +                        gmfn:   machine physical frame number
    5.84 +                The size of arrays is stored in xch_nr_pages member of header
    5.85 +                note descriptor in .note.Xen note section.
    5.86 +                There is no rule about the order. Analysis tools must no rely
    5.87 +                on its order.
    5.88 +                This section must exist when the domain is non auto
    5.89 +                translated physmap mode. Currently x86 paravirtualized domain.
    5.90 +
    5.91 +".xen_pfn" section
    5.92 +        name            ".xen_pfn"
    5.93 +        type            SHT_PROGBITS
    5.94 +        structure       array of uint64_t
    5.95 +        description
    5.96 +                This elements represents the frame number of the page
    5.97 +                in .xen_pages section.
    5.98 +                The size of arrays is stored in xch_nr_pages member of header
    5.99 +                note descriptor in .note.Xen note section.
   5.100 +                There is no rule about the order. Analysis tools must no rely
   5.101 +                on its order.
   5.102 +                This section must exist when the domain is auto translated
   5.103 +                physmap mode. Currently x86 full virtualized domain and
   5.104 +                ia64 domain.
   5.105 +
   5.106 +".xen_pages" section
   5.107 +        name            ".xen_pages"
   5.108 +        type            SHT_PROGBITS
   5.109 +        structure       array of page where page is page size byte array
   5.110 +        description
   5.111 +                This section includes the contents of pages.
   5.112 +                The corresponding address is described in .xen_p2m section
   5.113 +                or .xen_pfn section.
   5.114 +                The page size is stored in xch_page_size member of header note
   5.115 +                descriptor in .note.Xen section.
   5.116 +                The array size is stored in xch_nr_pages member of header note
   5.117 +                descriptor in .note.Xen section.
   5.118 +                This section must exist.
   5.119 +
   5.120 +
   5.121 +".xen_ia64_mapped_regs" section
   5.122 +        name            ".xen_ia64_mapped_regs"
   5.123 +        type            SHT_PROGBITS
   5.124 +        structure       array of mapped_regs_t
   5.125 +        description
   5.126 +                This section stores the array of mapped_regs_t.
   5.127 +                The size of array is stored in xch_nr_vcpus member of header
   5.128 +                note descriptor in .note.Xen note section.
   5.129 +                This section is ia64 specific and must exist for ia64 domain.
   5.130 +                This section must not exist for non-ia64 domain.
   5.131 +
   5.132 +
   5.133 +note section
   5.134 +------------
   5.135 +The note types are defined in xen/include/public/elfnote.h.
   5.136 +The note descriptors are defined in tools/libxc/xc_core.h
   5.137 +Currently the following note informations are defined.
   5.138 +
   5.139 +
   5.140 +elf note section
   5.141 +
   5.142 +"Xen" is used as elf note name in elf note info
   5.143 +        namesz  4
   5.144 +        name    "Xen" (null-terminated)
   5.145 +
   5.146 +
   5.147 +Descriptors
   5.148 +
   5.149 +none note descriptor
   5.150 +        type            XEN_ELFNOTE_DUMPCORE_NONE = 0x2000000
   5.151 +        structure       struct xen_dumpcore_elfnote_none_desc {
   5.152 +                               /* nothing is defined */
   5.153 +                        };
   5.154 +        description
   5.155 +                This note descriptor is defined to just indicate that this
   5.156 +                file is xen dump-core format without any specific information.
   5.157 +                This note information must exist.
   5.158 +
   5.159 +header note descriptor
   5.160 +        type            XEN_ELFNOTE_DUMPCORE_HEADER = 0x2000001
   5.161 +        structure       struct xen_dumpcore_elfnote_header_desc {
   5.162 +                                uint64_t    xch_magic;
   5.163 +                                uint64_t    xch_nr_vcpus;
   5.164 +                                uint64_t    xch_nr_pages;
   5.165 +                                uint64_t    xch_page_size;
   5.166 +                        };
   5.167 +        description
   5.168 +                This note descriptor stores basic information of the domain.
   5.169 +                xch_magic       magic number
   5.170 +                    XC_CORE_MAGIC = 0xF00FEBED for paravirtualized domain
   5.171 +                    XC_CORE_MAGIC_HVM = 0xF00FEBEE for full virtualized domain
   5.172 +                xch_nr_vcpus    the number of vcpus
   5.173 +                xch_nr_pages    the number of pages
   5.174 +                xch_page_size   guest OS's page size
   5.175 +                This note information must exist.
   5.176 +
   5.177 +xen_version descriptor
   5.178 +        type            XEN_ELFNOTE_DUMPCORE_XEN_VERSION = 0x2000002
   5.179 +        structure       struct xen_dumpcore_elfnote_xen_version_desc {
   5.180 +                                uint64_t                    major_version;
   5.181 +                                uint64_t                    minor_version;
   5.182 +                                xen_extraversion_t          extra_version;
   5.183 +                                xen_compile_info_t          compile_info;
   5.184 +                                xen_capabilities_info_t     capabilities;
   5.185 +                                xen_changeset_info_t        changeset;
   5.186 +                                xen_platform_parameters_t   platform_parameters;
   5.187 +                                uint64_t                    pagesize;
   5.188 +                        };
   5.189 +        description
   5.190 +                This note descriptor stores basic information about xen
   5.191 +                hypervisor. The each members store the result of
   5.192 +                __HYPERVISOR_xen_version hypercall.
   5.193 +                major_version   16msb bit of the result of XENVER_version
   5.194 +                minor_version   16lsb bit of the result of XENVER_version
   5.195 +                        uint64_t is used to make struct
   5.196 +                        xen_dumpcore_elfnote_xen_version_desc independent
   5.197 +                        on 32bit/64bit instead of uint32_t.
   5.198 +                extra_version   the result of XENVER_extraversion
   5.199 +                compile_info    the result of XENVER_compile_info
   5.200 +                capabilities    the result of XENVER_capabilities
   5.201 +                changeset       the result of XENVER_changeset
   5.202 +                platform_parameters
   5.203 +                                the result of XENVER_platform_parameters
   5.204 +                pagesize        the result of XENVER_pagesize
   5.205 +                This note information must exist.
   5.206 +
   5.207 +format_version descriptor
   5.208 +        type            XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION = 0x2000003
   5.209 +        structure       struct xen_dumpcore_elfnote_format_version_desc {
   5.210 +                                uint64_t    version;
   5.211 +                        };
   5.212 +        description
   5.213 +                This note descriptor stores xen dump-core format version.
   5.214 +                The 32msb bit is major version and the 32lsb bit is minor
   5.215 +                version. 
   5.216 +                The minor version will be incremented when the format
   5.217 +                is changed in compatible way. e.g. new sections, new note
   5.218 +                descriptors are added.
   5.219 +                the major version will be incremented when the format is
   5.220 +                changed in incompatible way.
   5.221 +                This note information must exit. Analysis tools should check
   5.222 +                this format version.
   5.223 +                This note information must exist.
   5.224 +
   5.225 +
   5.226 +Format version history
   5.227 +----------------------
   5.228 +Currently only (major, minor) = (0, 1) is used.
   5.229 +[When the format is changed, it would be described here.]
   5.230 +
   5.231 +(0, 1) update
   5.232 +- EI_CLASS member of elf header was changed to ELFCLASS64 independent of
   5.233 +  architecture. This is mainly for x86_32pae.
   5.234 +  The format version isn't bumped because analysis tools can distinguish it.
     6.1 --- a/docs/xen-api/xenapi-datamodel.tex	Thu Mar 01 15:02:09 2007 -0700
     6.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Wed Mar 07 12:38:28 2007 -0700
     6.3 @@ -26,6 +26,7 @@ Name & Description \\
     6.4  {\tt task} & A long-running asynchronous task \\
     6.5  {\tt VM} & A virtual machine (or 'guest') \\
     6.6  {\tt VM\_metrics} & The metrics associated with a VM \\
     6.7 +{\tt VM\_guest\_metrics} & The metrics reported by the guest (as opposed to inferred from outside) \\
     6.8  {\tt host} & A physical host \\
     6.9  {\tt host\_metrics} & The metrics associated with a host \\
    6.10  {\tt host\_cpu} & A physical CPU \\
    6.11 @@ -61,8 +62,6 @@ VBD.VM & VM.VBDs & one-to-many\\
    6.12  crashdump.VM & VM.crash\_dumps & one-to-many\\
    6.13  VIF.VM & VM.VIFs & one-to-many\\
    6.14  VIF.network & network.VIFs & one-to-many\\
    6.15 -host.metrics & host\_metrics.host & one-to-one\\
    6.16 -PIF.metrics & PIF\_metrics.PIF & one-to-one\\
    6.17  PIF.host & host.PIFs & one-to-many\\
    6.18  PIF.network & network.PIFs & one-to-many\\
    6.19  SR.VDIs & VDI.SR & many-to-one\\
    6.20 @@ -1098,10 +1097,11 @@ Quals & Field & Type & Description \\
    6.21  $\mathit{RW}$ &  {\tt platform/clock\_offset} & bool & timeshift applied to guest's clock \\
    6.22  $\mathit{RW}$ &  {\tt platform/enable\_audio} & bool & emulate audio \\
    6.23  $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for pass-through devices \\
    6.24 -$\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
    6.25  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
    6.26 +$\mathit{RO}_\mathit{run}$ &  {\tt domid} & int & domain ID (if available, -1 otherwise) \\
    6.27  $\mathit{RO}_\mathit{run}$ &  {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
    6.28  $\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
    6.29 +$\mathit{RO}_\mathit{run}$ &  {\tt guest\_metrics} & VM\_guest\_metrics ref & metrics associated with the running guest \\
    6.30  \hline
    6.31  \end{longtable}
    6.32  \subsection{Additional RPCs associated with class: VM}
    6.33 @@ -3800,38 +3800,6 @@ value of the field
    6.34  \vspace{0.3cm}
    6.35  \vspace{0.3cm}
    6.36  \vspace{0.3cm}
    6.37 -\subsubsection{RPC name:~get\_tools\_version}
    6.38 -
    6.39 -{\bf Overview:} 
    6.40 -Get the tools\_version field of the given VM.
    6.41 -
    6.42 - \noindent {\bf Signature:} 
    6.43 -\begin{verbatim} ((string -> string) Map) get_tools_version (session_id s, VM ref self)\end{verbatim}
    6.44 -
    6.45 -
    6.46 -\noindent{\bf Arguments:}
    6.47 -
    6.48 - 
    6.49 -\vspace{0.3cm}
    6.50 -\begin{tabular}{|c|c|p{7cm}|}
    6.51 - \hline
    6.52 -{\bf type} & {\bf name} & {\bf description} \\ \hline
    6.53 -{\tt VM ref } & self & reference to the object \\ \hline 
    6.54 -
    6.55 -\end{tabular}
    6.56 -
    6.57 -\vspace{0.3cm}
    6.58 -
    6.59 - \noindent {\bf Return Type:} 
    6.60 -{\tt 
    6.61 -(string $\rightarrow$ string) Map
    6.62 -}
    6.63 -
    6.64 -
    6.65 -value of the field
    6.66 -\vspace{0.3cm}
    6.67 -\vspace{0.3cm}
    6.68 -\vspace{0.3cm}
    6.69  \subsubsection{RPC name:~get\_other\_config}
    6.70  
    6.71  {\bf Overview:} 
    6.72 @@ -3969,6 +3937,38 @@ void
    6.73  \vspace{0.3cm}
    6.74  \vspace{0.3cm}
    6.75  \vspace{0.3cm}
    6.76 +\subsubsection{RPC name:~get\_domid}
    6.77 +
    6.78 +{\bf Overview:} 
    6.79 +Get the domid field of the given VM.
    6.80 +
    6.81 + \noindent {\bf Signature:} 
    6.82 +\begin{verbatim} int get_domid (session_id s, VM ref self)\end{verbatim}
    6.83 +
    6.84 +
    6.85 +\noindent{\bf Arguments:}
    6.86 +
    6.87 + 
    6.88 +\vspace{0.3cm}
    6.89 +\begin{tabular}{|c|c|p{7cm}|}
    6.90 + \hline
    6.91 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    6.92 +{\tt VM ref } & self & reference to the object \\ \hline 
    6.93 +
    6.94 +\end{tabular}
    6.95 +
    6.96 +\vspace{0.3cm}
    6.97 +
    6.98 + \noindent {\bf Return Type:} 
    6.99 +{\tt 
   6.100 +int
   6.101 +}
   6.102 +
   6.103 +
   6.104 +value of the field
   6.105 +\vspace{0.3cm}
   6.106 +\vspace{0.3cm}
   6.107 +\vspace{0.3cm}
   6.108  \subsubsection{RPC name:~get\_is\_control\_domain}
   6.109  
   6.110  {\bf Overview:} 
   6.111 @@ -4033,6 +4033,38 @@ value of the field
   6.112  \vspace{0.3cm}
   6.113  \vspace{0.3cm}
   6.114  \vspace{0.3cm}
   6.115 +\subsubsection{RPC name:~get\_guest\_metrics}
   6.116 +
   6.117 +{\bf Overview:} 
   6.118 +Get the guest\_metrics field of the given VM.
   6.119 +
   6.120 + \noindent {\bf Signature:} 
   6.121 +\begin{verbatim} (VM_guest_metrics ref) get_guest_metrics (session_id s, VM ref self)\end{verbatim}
   6.122 +
   6.123 +
   6.124 +\noindent{\bf Arguments:}
   6.125 +
   6.126 + 
   6.127 +\vspace{0.3cm}
   6.128 +\begin{tabular}{|c|c|p{7cm}|}
   6.129 + \hline
   6.130 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.131 +{\tt VM ref } & self & reference to the object \\ \hline 
   6.132 +
   6.133 +\end{tabular}
   6.134 +
   6.135 +\vspace{0.3cm}
   6.136 +
   6.137 + \noindent {\bf Return Type:} 
   6.138 +{\tt 
   6.139 +VM\_guest\_metrics ref
   6.140 +}
   6.141 +
   6.142 +
   6.143 +value of the field
   6.144 +\vspace{0.3cm}
   6.145 +\vspace{0.3cm}
   6.146 +\vspace{0.3cm}
   6.147  \subsubsection{RPC name:~create}
   6.148  
   6.149  {\bf Overview:} 
   6.150 @@ -4214,6 +4246,27 @@ Quals & Field & Type & Description \\
   6.151  \hline
   6.152  \end{longtable}
   6.153  \subsection{Additional RPCs associated with class: VM\_metrics}
   6.154 +\subsubsection{RPC name:~get\_all}
   6.155 +
   6.156 +{\bf Overview:} 
   6.157 +Return a list of all the VM\_metrics instances known to the system.
   6.158 +
   6.159 + \noindent {\bf Signature:} 
   6.160 +\begin{verbatim} ((VM_metrics ref) Set) get_all (session_id s)\end{verbatim}
   6.161 +
   6.162 +
   6.163 +\vspace{0.3cm}
   6.164 +
   6.165 + \noindent {\bf Return Type:} 
   6.166 +{\tt 
   6.167 +(VM\_metrics ref) Set
   6.168 +}
   6.169 +
   6.170 +
   6.171 +references to all objects
   6.172 +\vspace{0.3cm}
   6.173 +\vspace{0.3cm}
   6.174 +\vspace{0.3cm}
   6.175  \subsubsection{RPC name:~get\_uuid}
   6.176  
   6.177  {\bf Overview:} 
   6.178 @@ -4409,6 +4462,338 @@ all fields from the object
   6.179  
   6.180  \vspace{1cm}
   6.181  \newpage
   6.182 +\section{Class: VM\_guest\_metrics}
   6.183 +\subsection{Fields for class: VM\_guest\_metrics}
   6.184 +\begin{longtable}{|lllp{0.38\textwidth}|}
   6.185 +\hline
   6.186 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VM\_guest\_metrics} \\
   6.187 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
   6.188 +The metrics reported by the guest (as opposed to inferred from outside).}} \\
   6.189 +\hline
   6.190 +Quals & Field & Type & Description \\
   6.191 +\hline
   6.192 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   6.193 +$\mathit{RO}_\mathit{run}$ &  {\tt os\_version} & (string $\rightarrow$ string) Map & version of the OS \\
   6.194 +$\mathit{RO}_\mathit{run}$ &  {\tt PV\_drivers\_version} & (string $\rightarrow$ string) Map & version of the PV drivers \\
   6.195 +$\mathit{RO}_\mathit{run}$ &  {\tt memory} & (string $\rightarrow$ string) Map & free/used/total memory \\
   6.196 +$\mathit{RO}_\mathit{run}$ &  {\tt disks} & (string $\rightarrow$ string) Map & disk configuration/free space \\
   6.197 +$\mathit{RO}_\mathit{run}$ &  {\tt networks} & (string $\rightarrow$ string) Map & network configuration \\
   6.198 +$\mathit{RO}_\mathit{run}$ &  {\tt other} & (string $\rightarrow$ string) Map & anything else \\
   6.199 +\hline
   6.200 +\end{longtable}
   6.201 +\subsection{Additional RPCs associated with class: VM\_guest\_metrics}
   6.202 +\subsubsection{RPC name:~get\_all}
   6.203 +
   6.204 +{\bf Overview:} 
   6.205 +Return a list of all the VM\_guest\_metrics instances known to the system.
   6.206 +
   6.207 + \noindent {\bf Signature:} 
   6.208 +\begin{verbatim} ((VM_guest_metrics ref) Set) get_all (session_id s)\end{verbatim}
   6.209 +
   6.210 +
   6.211 +\vspace{0.3cm}
   6.212 +
   6.213 + \noindent {\bf Return Type:} 
   6.214 +{\tt 
   6.215 +(VM\_guest\_metrics ref) Set
   6.216 +}
   6.217 +
   6.218 +
   6.219 +references to all objects
   6.220 +\vspace{0.3cm}
   6.221 +\vspace{0.3cm}
   6.222 +\vspace{0.3cm}
   6.223 +\subsubsection{RPC name:~get\_uuid}
   6.224 +
   6.225 +{\bf Overview:} 
   6.226 +Get the uuid field of the given VM\_guest\_metrics.
   6.227 +
   6.228 + \noindent {\bf Signature:} 
   6.229 +\begin{verbatim} string get_uuid (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.230 +
   6.231 +
   6.232 +\noindent{\bf Arguments:}
   6.233 +
   6.234 + 
   6.235 +\vspace{0.3cm}
   6.236 +\begin{tabular}{|c|c|p{7cm}|}
   6.237 + \hline
   6.238 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.239 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.240 +
   6.241 +\end{tabular}
   6.242 +
   6.243 +\vspace{0.3cm}
   6.244 +
   6.245 + \noindent {\bf Return Type:} 
   6.246 +{\tt 
   6.247 +string
   6.248 +}
   6.249 +
   6.250 +
   6.251 +value of the field
   6.252 +\vspace{0.3cm}
   6.253 +\vspace{0.3cm}
   6.254 +\vspace{0.3cm}
   6.255 +\subsubsection{RPC name:~get\_os\_version}
   6.256 +
   6.257 +{\bf Overview:} 
   6.258 +Get the os\_version field of the given VM\_guest\_metrics.
   6.259 +
   6.260 + \noindent {\bf Signature:} 
   6.261 +\begin{verbatim} ((string -> string) Map) get_os_version (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.262 +
   6.263 +
   6.264 +\noindent{\bf Arguments:}
   6.265 +
   6.266 + 
   6.267 +\vspace{0.3cm}
   6.268 +\begin{tabular}{|c|c|p{7cm}|}
   6.269 + \hline
   6.270 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.271 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.272 +
   6.273 +\end{tabular}
   6.274 +
   6.275 +\vspace{0.3cm}
   6.276 +
   6.277 + \noindent {\bf Return Type:} 
   6.278 +{\tt 
   6.279 +(string $\rightarrow$ string) Map
   6.280 +}
   6.281 +
   6.282 +
   6.283 +value of the field
   6.284 +\vspace{0.3cm}
   6.285 +\vspace{0.3cm}
   6.286 +\vspace{0.3cm}
   6.287 +\subsubsection{RPC name:~get\_PV\_drivers\_version}
   6.288 +
   6.289 +{\bf Overview:} 
   6.290 +Get the PV\_drivers\_version field of the given VM\_guest\_metrics.
   6.291 +
   6.292 + \noindent {\bf Signature:} 
   6.293 +\begin{verbatim} ((string -> string) Map) get_PV_drivers_version (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.294 +
   6.295 +
   6.296 +\noindent{\bf Arguments:}
   6.297 +
   6.298 + 
   6.299 +\vspace{0.3cm}
   6.300 +\begin{tabular}{|c|c|p{7cm}|}
   6.301 + \hline
   6.302 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.303 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.304 +
   6.305 +\end{tabular}
   6.306 +
   6.307 +\vspace{0.3cm}
   6.308 +
   6.309 + \noindent {\bf Return Type:} 
   6.310 +{\tt 
   6.311 +(string $\rightarrow$ string) Map
   6.312 +}
   6.313 +
   6.314 +
   6.315 +value of the field
   6.316 +\vspace{0.3cm}
   6.317 +\vspace{0.3cm}
   6.318 +\vspace{0.3cm}
   6.319 +\subsubsection{RPC name:~get\_memory}
   6.320 +
   6.321 +{\bf Overview:} 
   6.322 +Get the memory field of the given VM\_guest\_metrics.
   6.323 +
   6.324 + \noindent {\bf Signature:} 
   6.325 +\begin{verbatim} ((string -> string) Map) get_memory (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.326 +
   6.327 +
   6.328 +\noindent{\bf Arguments:}
   6.329 +
   6.330 + 
   6.331 +\vspace{0.3cm}
   6.332 +\begin{tabular}{|c|c|p{7cm}|}
   6.333 + \hline
   6.334 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.335 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.336 +
   6.337 +\end{tabular}
   6.338 +
   6.339 +\vspace{0.3cm}
   6.340 +
   6.341 + \noindent {\bf Return Type:} 
   6.342 +{\tt 
   6.343 +(string $\rightarrow$ string) Map
   6.344 +}
   6.345 +
   6.346 +
   6.347 +value of the field
   6.348 +\vspace{0.3cm}
   6.349 +\vspace{0.3cm}
   6.350 +\vspace{0.3cm}
   6.351 +\subsubsection{RPC name:~get\_disks}
   6.352 +
   6.353 +{\bf Overview:} 
   6.354 +Get the disks field of the given VM\_guest\_metrics.
   6.355 +
   6.356 + \noindent {\bf Signature:} 
   6.357 +\begin{verbatim} ((string -> string) Map) get_disks (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.358 +
   6.359 +
   6.360 +\noindent{\bf Arguments:}
   6.361 +
   6.362 + 
   6.363 +\vspace{0.3cm}
   6.364 +\begin{tabular}{|c|c|p{7cm}|}
   6.365 + \hline
   6.366 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.367 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.368 +
   6.369 +\end{tabular}
   6.370 +
   6.371 +\vspace{0.3cm}
   6.372 +
   6.373 + \noindent {\bf Return Type:} 
   6.374 +{\tt 
   6.375 +(string $\rightarrow$ string) Map
   6.376 +}
   6.377 +
   6.378 +
   6.379 +value of the field
   6.380 +\vspace{0.3cm}
   6.381 +\vspace{0.3cm}
   6.382 +\vspace{0.3cm}
   6.383 +\subsubsection{RPC name:~get\_networks}
   6.384 +
   6.385 +{\bf Overview:} 
   6.386 +Get the networks field of the given VM\_guest\_metrics.
   6.387 +
   6.388 + \noindent {\bf Signature:} 
   6.389 +\begin{verbatim} ((string -> string) Map) get_networks (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.390 +
   6.391 +
   6.392 +\noindent{\bf Arguments:}
   6.393 +
   6.394 + 
   6.395 +\vspace{0.3cm}
   6.396 +\begin{tabular}{|c|c|p{7cm}|}
   6.397 + \hline
   6.398 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.399 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.400 +
   6.401 +\end{tabular}
   6.402 +
   6.403 +\vspace{0.3cm}
   6.404 +
   6.405 + \noindent {\bf Return Type:} 
   6.406 +{\tt 
   6.407 +(string $\rightarrow$ string) Map
   6.408 +}
   6.409 +
   6.410 +
   6.411 +value of the field
   6.412 +\vspace{0.3cm}
   6.413 +\vspace{0.3cm}
   6.414 +\vspace{0.3cm}
   6.415 +\subsubsection{RPC name:~get\_other}
   6.416 +
   6.417 +{\bf Overview:} 
   6.418 +Get the other field of the given VM\_guest\_metrics.
   6.419 +
   6.420 + \noindent {\bf Signature:} 
   6.421 +\begin{verbatim} ((string -> string) Map) get_other (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.422 +
   6.423 +
   6.424 +\noindent{\bf Arguments:}
   6.425 +
   6.426 + 
   6.427 +\vspace{0.3cm}
   6.428 +\begin{tabular}{|c|c|p{7cm}|}
   6.429 + \hline
   6.430 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.431 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.432 +
   6.433 +\end{tabular}
   6.434 +
   6.435 +\vspace{0.3cm}
   6.436 +
   6.437 + \noindent {\bf Return Type:} 
   6.438 +{\tt 
   6.439 +(string $\rightarrow$ string) Map
   6.440 +}
   6.441 +
   6.442 +
   6.443 +value of the field
   6.444 +\vspace{0.3cm}
   6.445 +\vspace{0.3cm}
   6.446 +\vspace{0.3cm}
   6.447 +\subsubsection{RPC name:~get\_by\_uuid}
   6.448 +
   6.449 +{\bf Overview:} 
   6.450 +Get a reference to the VM\_guest\_metrics instance with the specified UUID.
   6.451 +
   6.452 + \noindent {\bf Signature:} 
   6.453 +\begin{verbatim} (VM_guest_metrics ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
   6.454 +
   6.455 +
   6.456 +\noindent{\bf Arguments:}
   6.457 +
   6.458 + 
   6.459 +\vspace{0.3cm}
   6.460 +\begin{tabular}{|c|c|p{7cm}|}
   6.461 + \hline
   6.462 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.463 +{\tt string } & uuid & UUID of object to return \\ \hline 
   6.464 +
   6.465 +\end{tabular}
   6.466 +
   6.467 +\vspace{0.3cm}
   6.468 +
   6.469 + \noindent {\bf Return Type:} 
   6.470 +{\tt 
   6.471 +VM\_guest\_metrics ref
   6.472 +}
   6.473 +
   6.474 +
   6.475 +reference to the object
   6.476 +\vspace{0.3cm}
   6.477 +\vspace{0.3cm}
   6.478 +\vspace{0.3cm}
   6.479 +\subsubsection{RPC name:~get\_record}
   6.480 +
   6.481 +{\bf Overview:} 
   6.482 +Get a record containing the current state of the given VM\_guest\_metrics.
   6.483 +
   6.484 + \noindent {\bf Signature:} 
   6.485 +\begin{verbatim} (VM_guest_metrics record) get_record (session_id s, VM_guest_metrics ref self)\end{verbatim}
   6.486 +
   6.487 +
   6.488 +\noindent{\bf Arguments:}
   6.489 +
   6.490 + 
   6.491 +\vspace{0.3cm}
   6.492 +\begin{tabular}{|c|c|p{7cm}|}
   6.493 + \hline
   6.494 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.495 +{\tt VM\_guest\_metrics ref } & self & reference to the object \\ \hline 
   6.496 +
   6.497 +\end{tabular}
   6.498 +
   6.499 +\vspace{0.3cm}
   6.500 +
   6.501 + \noindent {\bf Return Type:} 
   6.502 +{\tt 
   6.503 +VM\_guest\_metrics record
   6.504 +}
   6.505 +
   6.506 +
   6.507 +all fields from the object
   6.508 +\vspace{0.3cm}
   6.509 +\vspace{0.3cm}
   6.510 +\vspace{0.3cm}
   6.511 +
   6.512 +\vspace{1cm}
   6.513 +\newpage
   6.514  \section{Class: host}
   6.515  \subsection{Fields for class: host}
   6.516  \begin{longtable}{|lllp{0.38\textwidth}|}
   6.517 @@ -4422,8 +4807,13 @@ Quals & Field & Type & Description \\
   6.518  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   6.519  $\mathit{RW}$ &  {\tt name/label} & string & a human-readable name \\
   6.520  $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg human-readable description \\
   6.521 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/major} & int & major version number \\
   6.522 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/minor} & int & minor version number \\
   6.523 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor} & string & identification of vendor \\
   6.524 +$\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor\_implementation} & (string $\rightarrow$ string) Map & details of vendor implementation \\
   6.525  $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
   6.526  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
   6.527 +$\mathit{RO}_\mathit{run}$ &  {\tt capabilities} & string Set & Xen capabilities \\
   6.528  $\mathit{RO}_\mathit{run}$ &  {\tt supported\_bootloaders} & string Set & a list of the bootloaders installed on the machine \\
   6.529  $\mathit{RO}_\mathit{run}$ &  {\tt resident\_VMs} & (VM ref) Set & list of VMs currently resident on host \\
   6.530  $\mathit{RW}$ &  {\tt logging} & (string $\rightarrow$ string) Map & logging configuration \\
   6.531 @@ -4784,6 +5174,134 @@ void
   6.532  \vspace{0.3cm}
   6.533  \vspace{0.3cm}
   6.534  \vspace{0.3cm}
   6.535 +\subsubsection{RPC name:~get\_API\_version\_major}
   6.536 +
   6.537 +{\bf Overview:} 
   6.538 +Get the API\_version/major field of the given host.
   6.539 +
   6.540 + \noindent {\bf Signature:} 
   6.541 +\begin{verbatim} int get_API_version_major (session_id s, host ref self)\end{verbatim}
   6.542 +
   6.543 +
   6.544 +\noindent{\bf Arguments:}
   6.545 +
   6.546 + 
   6.547 +\vspace{0.3cm}
   6.548 +\begin{tabular}{|c|c|p{7cm}|}
   6.549 + \hline
   6.550 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.551 +{\tt host ref } & self & reference to the object \\ \hline 
   6.552 +
   6.553 +\end{tabular}
   6.554 +
   6.555 +\vspace{0.3cm}
   6.556 +
   6.557 + \noindent {\bf Return Type:} 
   6.558 +{\tt 
   6.559 +int
   6.560 +}
   6.561 +
   6.562 +
   6.563 +value of the field
   6.564 +\vspace{0.3cm}
   6.565 +\vspace{0.3cm}
   6.566 +\vspace{0.3cm}
   6.567 +\subsubsection{RPC name:~get\_API\_version\_minor}
   6.568 +
   6.569 +{\bf Overview:} 
   6.570 +Get the API\_version/minor field of the given host.
   6.571 +
   6.572 + \noindent {\bf Signature:} 
   6.573 +\begin{verbatim} int get_API_version_minor (session_id s, host ref self)\end{verbatim}
   6.574 +
   6.575 +
   6.576 +\noindent{\bf Arguments:}
   6.577 +
   6.578 + 
   6.579 +\vspace{0.3cm}
   6.580 +\begin{tabular}{|c|c|p{7cm}|}
   6.581 + \hline
   6.582 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.583 +{\tt host ref } & self & reference to the object \\ \hline 
   6.584 +
   6.585 +\end{tabular}
   6.586 +
   6.587 +\vspace{0.3cm}
   6.588 +
   6.589 + \noindent {\bf Return Type:} 
   6.590 +{\tt 
   6.591 +int
   6.592 +}
   6.593 +
   6.594 +
   6.595 +value of the field
   6.596 +\vspace{0.3cm}
   6.597 +\vspace{0.3cm}
   6.598 +\vspace{0.3cm}
   6.599 +\subsubsection{RPC name:~get\_API\_version\_vendor}
   6.600 +
   6.601 +{\bf Overview:} 
   6.602 +Get the API\_version/vendor field of the given host.
   6.603 +
   6.604 + \noindent {\bf Signature:} 
   6.605 +\begin{verbatim} string get_API_version_vendor (session_id s, host ref self)\end{verbatim}
   6.606 +
   6.607 +
   6.608 +\noindent{\bf Arguments:}
   6.609 +
   6.610 + 
   6.611 +\vspace{0.3cm}
   6.612 +\begin{tabular}{|c|c|p{7cm}|}
   6.613 + \hline
   6.614 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.615 +{\tt host ref } & self & reference to the object \\ \hline 
   6.616 +
   6.617 +\end{tabular}
   6.618 +
   6.619 +\vspace{0.3cm}
   6.620 +
   6.621 + \noindent {\bf Return Type:} 
   6.622 +{\tt 
   6.623 +string
   6.624 +}
   6.625 +
   6.626 +
   6.627 +value of the field
   6.628 +\vspace{0.3cm}
   6.629 +\vspace{0.3cm}
   6.630 +\vspace{0.3cm}
   6.631 +\subsubsection{RPC name:~get\_API\_version\_vendor\_implementation}
   6.632 +
   6.633 +{\bf Overview:} 
   6.634 +Get the API\_version/vendor\_implementation field of the given host.
   6.635 +
   6.636 + \noindent {\bf Signature:} 
   6.637 +\begin{verbatim} ((string -> string) Map) get_API_version_vendor_implementation (session_id s, host ref self)\end{verbatim}
   6.638 +
   6.639 +
   6.640 +\noindent{\bf Arguments:}
   6.641 +
   6.642 + 
   6.643 +\vspace{0.3cm}
   6.644 +\begin{tabular}{|c|c|p{7cm}|}
   6.645 + \hline
   6.646 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.647 +{\tt host ref } & self & reference to the object \\ \hline 
   6.648 +
   6.649 +\end{tabular}
   6.650 +
   6.651 +\vspace{0.3cm}
   6.652 +
   6.653 + \noindent {\bf Return Type:} 
   6.654 +{\tt 
   6.655 +(string $\rightarrow$ string) Map
   6.656 +}
   6.657 +
   6.658 +
   6.659 +value of the field
   6.660 +\vspace{0.3cm}
   6.661 +\vspace{0.3cm}
   6.662 +\vspace{0.3cm}
   6.663  \subsubsection{RPC name:~get\_software\_version}
   6.664  
   6.665  {\bf Overview:} 
   6.666 @@ -4953,6 +5471,38 @@ void
   6.667  \vspace{0.3cm}
   6.668  \vspace{0.3cm}
   6.669  \vspace{0.3cm}
   6.670 +\subsubsection{RPC name:~get\_capabilities}
   6.671 +
   6.672 +{\bf Overview:} 
   6.673 +Get the capabilities field of the given host.
   6.674 +
   6.675 + \noindent {\bf Signature:} 
   6.676 +\begin{verbatim} (string Set) get_capabilities (session_id s, host ref self)\end{verbatim}
   6.677 +
   6.678 +
   6.679 +\noindent{\bf Arguments:}
   6.680 +
   6.681 + 
   6.682 +\vspace{0.3cm}
   6.683 +\begin{tabular}{|c|c|p{7cm}|}
   6.684 + \hline
   6.685 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.686 +{\tt host ref } & self & reference to the object \\ \hline 
   6.687 +
   6.688 +\end{tabular}
   6.689 +
   6.690 +\vspace{0.3cm}
   6.691 +
   6.692 + \noindent {\bf Return Type:} 
   6.693 +{\tt 
   6.694 +string Set
   6.695 +}
   6.696 +
   6.697 +
   6.698 +value of the field
   6.699 +\vspace{0.3cm}
   6.700 +\vspace{0.3cm}
   6.701 +\vspace{0.3cm}
   6.702  \subsubsection{RPC name:~get\_supported\_bootloaders}
   6.703  
   6.704  {\bf Overview:} 
   6.705 @@ -5524,12 +6074,32 @@ The metrics associated with a host.}} \\
   6.706  Quals & Field & Type & Description \\
   6.707  \hline
   6.708  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   6.709 -$\mathit{RO}_\mathit{ins}$ &  {\tt host} & host ref & Host to which these metrics apply \\
   6.710  $\mathit{RO}_\mathit{run}$ &  {\tt memory/total} & int & Host's total memory (bytes) \\
   6.711  $\mathit{RO}_\mathit{run}$ &  {\tt memory/free} & int & Host's free memory (bytes) \\
   6.712  \hline
   6.713  \end{longtable}
   6.714  \subsection{Additional RPCs associated with class: host\_metrics}
   6.715 +\subsubsection{RPC name:~get\_all}
   6.716 +
   6.717 +{\bf Overview:} 
   6.718 +Return a list of all the host\_metrics instances known to the system.
   6.719 +
   6.720 + \noindent {\bf Signature:} 
   6.721 +\begin{verbatim} ((host_metrics ref) Set) get_all (session_id s)\end{verbatim}
   6.722 +
   6.723 +
   6.724 +\vspace{0.3cm}
   6.725 +
   6.726 + \noindent {\bf Return Type:} 
   6.727 +{\tt 
   6.728 +(host\_metrics ref) Set
   6.729 +}
   6.730 +
   6.731 +
   6.732 +references to all objects
   6.733 +\vspace{0.3cm}
   6.734 +\vspace{0.3cm}
   6.735 +\vspace{0.3cm}
   6.736  \subsubsection{RPC name:~get\_uuid}
   6.737  
   6.738  {\bf Overview:} 
   6.739 @@ -5562,38 +6132,6 @@ value of the field
   6.740  \vspace{0.3cm}
   6.741  \vspace{0.3cm}
   6.742  \vspace{0.3cm}
   6.743 -\subsubsection{RPC name:~get\_host}
   6.744 -
   6.745 -{\bf Overview:} 
   6.746 -Get the host field of the given host\_metrics.
   6.747 -
   6.748 - \noindent {\bf Signature:} 
   6.749 -\begin{verbatim} (host ref) get_host (session_id s, host_metrics ref self)\end{verbatim}
   6.750 -
   6.751 -
   6.752 -\noindent{\bf Arguments:}
   6.753 -
   6.754 - 
   6.755 -\vspace{0.3cm}
   6.756 -\begin{tabular}{|c|c|p{7cm}|}
   6.757 - \hline
   6.758 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.759 -{\tt host\_metrics ref } & self & reference to the object \\ \hline 
   6.760 -
   6.761 -\end{tabular}
   6.762 -
   6.763 -\vspace{0.3cm}
   6.764 -
   6.765 - \noindent {\bf Return Type:} 
   6.766 -{\tt 
   6.767 -host ref
   6.768 -}
   6.769 -
   6.770 -
   6.771 -value of the field
   6.772 -\vspace{0.3cm}
   6.773 -\vspace{0.3cm}
   6.774 -\vspace{0.3cm}
   6.775  \subsubsection{RPC name:~get\_memory\_total}
   6.776  
   6.777  {\bf Overview:} 
   6.778 @@ -5735,15 +6273,38 @@ all fields from the object
   6.779  Quals & Field & Type & Description \\
   6.780  \hline
   6.781  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   6.782 -$\mathit{RO}_\mathit{ins}$ &  {\tt host} & host ref & the host the CPU is in \\
   6.783 -$\mathit{RO}_\mathit{ins}$ &  {\tt number} & int & the number of the physical CPU within the host \\
   6.784 -$\mathit{RO}_\mathit{ins}$ &  {\tt vendor} & string & the vendor of the physical CPU \\
   6.785 -$\mathit{RO}_\mathit{ins}$ &  {\tt speed} & int & the speed of the physical CPU \\
   6.786 -$\mathit{RO}_\mathit{ins}$ &  {\tt modelname} & string & the model name of the physical CPU \\
   6.787 +$\mathit{RO}_\mathit{run}$ &  {\tt host} & host ref & the host the CPU is in \\
   6.788 +$\mathit{RO}_\mathit{run}$ &  {\tt number} & int & the number of the physical CPU within the host \\
   6.789 +$\mathit{RO}_\mathit{run}$ &  {\tt vendor} & string & the vendor of the physical CPU \\
   6.790 +$\mathit{RO}_\mathit{run}$ &  {\tt speed} & int & the speed of the physical CPU \\
   6.791 +$\mathit{RO}_\mathit{run}$ &  {\tt modelname} & string & the model name of the physical CPU \\
   6.792 +$\mathit{RO}_\mathit{run}$ &  {\tt stepping} & string & the stepping of the physical CPU \\
   6.793 +$\mathit{RO}_\mathit{run}$ &  {\tt flags} & string & the flags of the physical CPU \\
   6.794  $\mathit{RO}_\mathit{run}$ &  {\tt utilisation} & float & the current CPU utilisation \\
   6.795  \hline
   6.796  \end{longtable}
   6.797  \subsection{Additional RPCs associated with class: host\_cpu}
   6.798 +\subsubsection{RPC name:~get\_all}
   6.799 +
   6.800 +{\bf Overview:} 
   6.801 +Return a list of all the host\_cpus known to the system.
   6.802 +
   6.803 + \noindent {\bf Signature:} 
   6.804 +\begin{verbatim} ((host_cpu ref) Set) get_all (session_id s)\end{verbatim}
   6.805 +
   6.806 +
   6.807 +\vspace{0.3cm}
   6.808 +
   6.809 + \noindent {\bf Return Type:} 
   6.810 +{\tt 
   6.811 +(host\_cpu ref) Set
   6.812 +}
   6.813 +
   6.814 +
   6.815 +references to all objects
   6.816 +\vspace{0.3cm}
   6.817 +\vspace{0.3cm}
   6.818 +\vspace{0.3cm}
   6.819  \subsubsection{RPC name:~get\_uuid}
   6.820  
   6.821  {\bf Overview:} 
   6.822 @@ -5936,6 +6497,70 @@ value of the field
   6.823  \vspace{0.3cm}
   6.824  \vspace{0.3cm}
   6.825  \vspace{0.3cm}
   6.826 +\subsubsection{RPC name:~get\_stepping}
   6.827 +
   6.828 +{\bf Overview:} 
   6.829 +Get the stepping field of the given host\_cpu.
   6.830 +
   6.831 + \noindent {\bf Signature:} 
   6.832 +\begin{verbatim} string get_stepping (session_id s, host_cpu ref self)\end{verbatim}
   6.833 +
   6.834 +
   6.835 +\noindent{\bf Arguments:}
   6.836 +
   6.837 + 
   6.838 +\vspace{0.3cm}
   6.839 +\begin{tabular}{|c|c|p{7cm}|}
   6.840 + \hline
   6.841 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.842 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
   6.843 +
   6.844 +\end{tabular}
   6.845 +
   6.846 +\vspace{0.3cm}
   6.847 +
   6.848 + \noindent {\bf Return Type:} 
   6.849 +{\tt 
   6.850 +string
   6.851 +}
   6.852 +
   6.853 +
   6.854 +value of the field
   6.855 +\vspace{0.3cm}
   6.856 +\vspace{0.3cm}
   6.857 +\vspace{0.3cm}
   6.858 +\subsubsection{RPC name:~get\_flags}
   6.859 +
   6.860 +{\bf Overview:} 
   6.861 +Get the flags field of the given host\_cpu.
   6.862 +
   6.863 + \noindent {\bf Signature:} 
   6.864 +\begin{verbatim} string get_flags (session_id s, host_cpu ref self)\end{verbatim}
   6.865 +
   6.866 +
   6.867 +\noindent{\bf Arguments:}
   6.868 +
   6.869 + 
   6.870 +\vspace{0.3cm}
   6.871 +\begin{tabular}{|c|c|p{7cm}|}
   6.872 + \hline
   6.873 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.874 +{\tt host\_cpu ref } & self & reference to the object \\ \hline 
   6.875 +
   6.876 +\end{tabular}
   6.877 +
   6.878 +\vspace{0.3cm}
   6.879 +
   6.880 + \noindent {\bf Return Type:} 
   6.881 +{\tt 
   6.882 +string
   6.883 +}
   6.884 +
   6.885 +
   6.886 +value of the field
   6.887 +\vspace{0.3cm}
   6.888 +\vspace{0.3cm}
   6.889 +\vspace{0.3cm}
   6.890  \subsubsection{RPC name:~get\_utilisation}
   6.891  
   6.892  {\bf Overview:} 
   6.893 @@ -5968,70 +6593,6 @@ value of the field
   6.894  \vspace{0.3cm}
   6.895  \vspace{0.3cm}
   6.896  \vspace{0.3cm}
   6.897 -\subsubsection{RPC name:~create}
   6.898 -
   6.899 -{\bf Overview:} 
   6.900 -Create a new host\_cpu instance, and return its handle.
   6.901 -
   6.902 - \noindent {\bf Signature:} 
   6.903 -\begin{verbatim} (host_cpu ref) create (session_id s, host_cpu record args)\end{verbatim}
   6.904 -
   6.905 -
   6.906 -\noindent{\bf Arguments:}
   6.907 -
   6.908 - 
   6.909 -\vspace{0.3cm}
   6.910 -\begin{tabular}{|c|c|p{7cm}|}
   6.911 - \hline
   6.912 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.913 -{\tt host\_cpu record } & args & All constructor arguments \\ \hline 
   6.914 -
   6.915 -\end{tabular}
   6.916 -
   6.917 -\vspace{0.3cm}
   6.918 -
   6.919 - \noindent {\bf Return Type:} 
   6.920 -{\tt 
   6.921 -host\_cpu ref
   6.922 -}
   6.923 -
   6.924 -
   6.925 -reference to the newly created object
   6.926 -\vspace{0.3cm}
   6.927 -\vspace{0.3cm}
   6.928 -\vspace{0.3cm}
   6.929 -\subsubsection{RPC name:~destroy}
   6.930 -
   6.931 -{\bf Overview:} 
   6.932 -Destroy the specified host\_cpu instance.
   6.933 -
   6.934 - \noindent {\bf Signature:} 
   6.935 -\begin{verbatim} void destroy (session_id s, host_cpu ref self)\end{verbatim}
   6.936 -
   6.937 -
   6.938 -\noindent{\bf Arguments:}
   6.939 -
   6.940 - 
   6.941 -\vspace{0.3cm}
   6.942 -\begin{tabular}{|c|c|p{7cm}|}
   6.943 - \hline
   6.944 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.945 -{\tt host\_cpu ref } & self & reference to the object \\ \hline 
   6.946 -
   6.947 -\end{tabular}
   6.948 -
   6.949 -\vspace{0.3cm}
   6.950 -
   6.951 - \noindent {\bf Return Type:} 
   6.952 -{\tt 
   6.953 -void
   6.954 -}
   6.955 -
   6.956 -
   6.957 -
   6.958 -\vspace{0.3cm}
   6.959 -\vspace{0.3cm}
   6.960 -\vspace{0.3cm}
   6.961  \subsubsection{RPC name:~get\_by\_uuid}
   6.962  
   6.963  {\bf Overview:} 
   6.964 @@ -6114,8 +6675,6 @@ Quals & Field & Type & Description \\
   6.965  $\mathit{RW}$ &  {\tt name/description} & string & a notes field containg human-readable description \\
   6.966  $\mathit{RO}_\mathit{run}$ &  {\tt VIFs} & (VIF ref) Set & list of connected vifs \\
   6.967  $\mathit{RO}_\mathit{run}$ &  {\tt PIFs} & (PIF ref) Set & list of connected pifs \\
   6.968 -$\mathit{RW}$ &  {\tt default\_gateway} & string & default gateway IP address. Used for auto-configuring guests with fixed IP setting \\
   6.969 -$\mathit{RW}$ &  {\tt default\_netmask} & string & default netmask. Used for auto-configuring guests with fixed IP setting \\
   6.970  \hline
   6.971  \end{longtable}
   6.972  \subsection{Additional RPCs associated with class: network}
   6.973 @@ -6368,138 +6927,6 @@ value of the field
   6.974  \vspace{0.3cm}
   6.975  \vspace{0.3cm}
   6.976  \vspace{0.3cm}
   6.977 -\subsubsection{RPC name:~get\_default\_gateway}
   6.978 -
   6.979 -{\bf Overview:} 
   6.980 -Get the default\_gateway field of the given network.
   6.981 -
   6.982 - \noindent {\bf Signature:} 
   6.983 -\begin{verbatim} string get_default_gateway (session_id s, network ref self)\end{verbatim}
   6.984 -
   6.985 -
   6.986 -\noindent{\bf Arguments:}
   6.987 -
   6.988 - 
   6.989 -\vspace{0.3cm}
   6.990 -\begin{tabular}{|c|c|p{7cm}|}
   6.991 - \hline
   6.992 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   6.993 -{\tt network ref } & self & reference to the object \\ \hline 
   6.994 -
   6.995 -\end{tabular}
   6.996 -
   6.997 -\vspace{0.3cm}
   6.998 -
   6.999 - \noindent {\bf Return Type:} 
  6.1000 -{\tt 
  6.1001 -string
  6.1002 -}
  6.1003 -
  6.1004 -
  6.1005 -value of the field
  6.1006 -\vspace{0.3cm}
  6.1007 -\vspace{0.3cm}
  6.1008 -\vspace{0.3cm}
  6.1009 -\subsubsection{RPC name:~set\_default\_gateway}
  6.1010 -
  6.1011 -{\bf Overview:} 
  6.1012 -Set the default\_gateway field of the given network.
  6.1013 -
  6.1014 - \noindent {\bf Signature:} 
  6.1015 -\begin{verbatim} void set_default_gateway (session_id s, network ref self, string value)\end{verbatim}
  6.1016 -
  6.1017 -
  6.1018 -\noindent{\bf Arguments:}
  6.1019 -
  6.1020 - 
  6.1021 -\vspace{0.3cm}
  6.1022 -\begin{tabular}{|c|c|p{7cm}|}
  6.1023 - \hline
  6.1024 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1025 -{\tt network ref } & self & reference to the object \\ \hline 
  6.1026 -
  6.1027 -{\tt string } & value & New value to set \\ \hline 
  6.1028 -
  6.1029 -\end{tabular}
  6.1030 -
  6.1031 -\vspace{0.3cm}
  6.1032 -
  6.1033 - \noindent {\bf Return Type:} 
  6.1034 -{\tt 
  6.1035 -void
  6.1036 -}
  6.1037 -
  6.1038 -
  6.1039 -
  6.1040 -\vspace{0.3cm}
  6.1041 -\vspace{0.3cm}
  6.1042 -\vspace{0.3cm}
  6.1043 -\subsubsection{RPC name:~get\_default\_netmask}
  6.1044 -
  6.1045 -{\bf Overview:} 
  6.1046 -Get the default\_netmask field of the given network.
  6.1047 -
  6.1048 - \noindent {\bf Signature:} 
  6.1049 -\begin{verbatim} string get_default_netmask (session_id s, network ref self)\end{verbatim}
  6.1050 -
  6.1051 -
  6.1052 -\noindent{\bf Arguments:}
  6.1053 -
  6.1054 - 
  6.1055 -\vspace{0.3cm}
  6.1056 -\begin{tabular}{|c|c|p{7cm}|}
  6.1057 - \hline
  6.1058 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1059 -{\tt network ref } & self & reference to the object \\ \hline 
  6.1060 -
  6.1061 -\end{tabular}
  6.1062 -
  6.1063 -\vspace{0.3cm}
  6.1064 -
  6.1065 - \noindent {\bf Return Type:} 
  6.1066 -{\tt 
  6.1067 -string
  6.1068 -}
  6.1069 -
  6.1070 -
  6.1071 -value of the field
  6.1072 -\vspace{0.3cm}
  6.1073 -\vspace{0.3cm}
  6.1074 -\vspace{0.3cm}
  6.1075 -\subsubsection{RPC name:~set\_default\_netmask}
  6.1076 -
  6.1077 -{\bf Overview:} 
  6.1078 -Set the default\_netmask field of the given network.
  6.1079 -
  6.1080 - \noindent {\bf Signature:} 
  6.1081 -\begin{verbatim} void set_default_netmask (session_id s, network ref self, string value)\end{verbatim}
  6.1082 -
  6.1083 -
  6.1084 -\noindent{\bf Arguments:}
  6.1085 -
  6.1086 - 
  6.1087 -\vspace{0.3cm}
  6.1088 -\begin{tabular}{|c|c|p{7cm}|}
  6.1089 - \hline
  6.1090 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1091 -{\tt network ref } & self & reference to the object \\ \hline 
  6.1092 -
  6.1093 -{\tt string } & value & New value to set \\ \hline 
  6.1094 -
  6.1095 -\end{tabular}
  6.1096 -
  6.1097 -\vspace{0.3cm}
  6.1098 -
  6.1099 - \noindent {\bf Return Type:} 
  6.1100 -{\tt 
  6.1101 -void
  6.1102 -}
  6.1103 -
  6.1104 -
  6.1105 -
  6.1106 -\vspace{0.3cm}
  6.1107 -\vspace{0.3cm}
  6.1108 -\vspace{0.3cm}
  6.1109  \subsubsection{RPC name:~create}
  6.1110  
  6.1111  {\bf Overview:} 
  6.1112 @@ -6679,12 +7106,37 @@ Quals & Field & Type & Description \\
  6.1113  $\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & virtual machine to which this vif is connected \\
  6.1114  $\mathit{RW}$ &  {\tt MAC} & string & ethernet MAC address of virtual interface, as exposed to guest \\
  6.1115  $\mathit{RW}$ &  {\tt MTU} & int & MTU in octets \\
  6.1116 +$\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device currently attached (erased on reboot) \\
  6.1117 +$\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code associated with last attach-operation (erased on reboot) \\
  6.1118 +$\mathit{RO}_\mathit{run}$ &  {\tt status\_detail} & string & error/success information associated with last attach-operation status (erased on reboot) \\
  6.1119  $\mathit{RW}$ &  {\tt qos/algorithm\_type} & string & QoS algorithm to use \\
  6.1120 -$\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) Map & Paramters for chosen QoS algorithm \\
  6.1121 +$\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) Map & parameters for chosen QoS algorithm \\
  6.1122 +$\mathit{RO}_\mathit{run}$ &  {\tt qos/supported\_algorithms} & string Set & supported QoS algorithms for this VIF \\
  6.1123  $\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VIF\_metrics ref & metrics associated with this VIF. \\
  6.1124  \hline
  6.1125  \end{longtable}
  6.1126  \subsection{Additional RPCs associated with class: VIF}
  6.1127 +\subsubsection{RPC name:~get\_all}
  6.1128 +
  6.1129 +{\bf Overview:} 
  6.1130 +Return a list of all the VIFs known to the system.
  6.1131 +
  6.1132 + \noindent {\bf Signature:} 
  6.1133 +\begin{verbatim} ((VIF ref) Set) get_all (session_id s)\end{verbatim}
  6.1134 +
  6.1135 +
  6.1136 +\vspace{0.3cm}
  6.1137 +
  6.1138 + \noindent {\bf Return Type:} 
  6.1139 +{\tt 
  6.1140 +(VIF ref) Set
  6.1141 +}
  6.1142 +
  6.1143 +
  6.1144 +references to all objects
  6.1145 +\vspace{0.3cm}
  6.1146 +\vspace{0.3cm}
  6.1147 +\vspace{0.3cm}
  6.1148  \subsubsection{RPC name:~get\_uuid}
  6.1149  
  6.1150  {\bf Overview:} 
  6.1151 @@ -6979,6 +7431,102 @@ void
  6.1152  \vspace{0.3cm}
  6.1153  \vspace{0.3cm}
  6.1154  \vspace{0.3cm}
  6.1155 +\subsubsection{RPC name:~get\_currently\_attached}
  6.1156 +
  6.1157 +{\bf Overview:} 
  6.1158 +Get the currently\_attached field of the given VIF.
  6.1159 +
  6.1160 + \noindent {\bf Signature:} 
  6.1161 +\begin{verbatim} bool get_currently_attached (session_id s, VIF ref self)\end{verbatim}
  6.1162 +
  6.1163 +
  6.1164 +\noindent{\bf Arguments:}
  6.1165 +
  6.1166 + 
  6.1167 +\vspace{0.3cm}
  6.1168 +\begin{tabular}{|c|c|p{7cm}|}
  6.1169 + \hline
  6.1170 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1171 +{\tt VIF ref } & self & reference to the object \\ \hline 
  6.1172 +
  6.1173 +\end{tabular}
  6.1174 +
  6.1175 +\vspace{0.3cm}
  6.1176 +
  6.1177 + \noindent {\bf Return Type:} 
  6.1178 +{\tt 
  6.1179 +bool
  6.1180 +}
  6.1181 +
  6.1182 +
  6.1183 +value of the field
  6.1184 +\vspace{0.3cm}
  6.1185 +\vspace{0.3cm}
  6.1186 +\vspace{0.3cm}
  6.1187 +\subsubsection{RPC name:~get\_status\_code}
  6.1188 +
  6.1189 +{\bf Overview:} 
  6.1190 +Get the status\_code field of the given VIF.
  6.1191 +
  6.1192 + \noindent {\bf Signature:} 
  6.1193 +\begin{verbatim} int get_status_code (session_id s, VIF ref self)\end{verbatim}
  6.1194 +
  6.1195 +
  6.1196 +\noindent{\bf Arguments:}
  6.1197 +
  6.1198 + 
  6.1199 +\vspace{0.3cm}
  6.1200 +\begin{tabular}{|c|c|p{7cm}|}
  6.1201 + \hline
  6.1202 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1203 +{\tt VIF ref } & self & reference to the object \\ \hline 
  6.1204 +
  6.1205 +\end{tabular}
  6.1206 +
  6.1207 +\vspace{0.3cm}
  6.1208 +
  6.1209 + \noindent {\bf Return Type:} 
  6.1210 +{\tt 
  6.1211 +int
  6.1212 +}
  6.1213 +
  6.1214 +
  6.1215 +value of the field
  6.1216 +\vspace{0.3cm}
  6.1217 +\vspace{0.3cm}
  6.1218 +\vspace{0.3cm}
  6.1219 +\subsubsection{RPC name:~get\_status\_detail}
  6.1220 +
  6.1221 +{\bf Overview:} 
  6.1222 +Get the status\_detail field of the given VIF.
  6.1223 +
  6.1224 + \noindent {\bf Signature:} 
  6.1225 +\begin{verbatim} string get_status_detail (session_id s, VIF ref self)\end{verbatim}
  6.1226 +
  6.1227 +
  6.1228 +\noindent{\bf Arguments:}
  6.1229 +
  6.1230 + 
  6.1231 +\vspace{0.3cm}
  6.1232 +\begin{tabular}{|c|c|p{7cm}|}
  6.1233 + \hline
  6.1234 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1235 +{\tt VIF ref } & self & reference to the object \\ \hline 
  6.1236 +
  6.1237 +\end{tabular}
  6.1238 +
  6.1239 +\vspace{0.3cm}
  6.1240 +
  6.1241 + \noindent {\bf Return Type:} 
  6.1242 +{\tt 
  6.1243 +string
  6.1244 +}
  6.1245 +
  6.1246 +
  6.1247 +value of the field
  6.1248 +\vspace{0.3cm}
  6.1249 +\vspace{0.3cm}
  6.1250 +\vspace{0.3cm}
  6.1251  \subsubsection{RPC name:~get\_qos\_algorithm\_type}
  6.1252  
  6.1253  {\bf Overview:} 
  6.1254 @@ -7184,6 +7732,38 @@ void
  6.1255  \vspace{0.3cm}
  6.1256  \vspace{0.3cm}
  6.1257  \vspace{0.3cm}
  6.1258 +\subsubsection{RPC name:~get\_qos\_supported\_algorithms}
  6.1259 +
  6.1260 +{\bf Overview:} 
  6.1261 +Get the qos/supported\_algorithms field of the given VIF.
  6.1262 +
  6.1263 + \noindent {\bf Signature:} 
  6.1264 +\begin{verbatim} (string Set) get_qos_supported_algorithms (session_id s, VIF ref self)\end{verbatim}
  6.1265 +
  6.1266 +
  6.1267 +\noindent{\bf Arguments:}
  6.1268 +
  6.1269 + 
  6.1270 +\vspace{0.3cm}
  6.1271 +\begin{tabular}{|c|c|p{7cm}|}
  6.1272 + \hline
  6.1273 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1274 +{\tt VIF ref } & self & reference to the object \\ \hline 
  6.1275 +
  6.1276 +\end{tabular}
  6.1277 +
  6.1278 +\vspace{0.3cm}
  6.1279 +
  6.1280 + \noindent {\bf Return Type:} 
  6.1281 +{\tt 
  6.1282 +string Set
  6.1283 +}
  6.1284 +
  6.1285 +
  6.1286 +value of the field
  6.1287 +\vspace{0.3cm}
  6.1288 +\vspace{0.3cm}
  6.1289 +\vspace{0.3cm}
  6.1290  \subsubsection{RPC name:~get\_metrics}
  6.1291  
  6.1292  {\bf Overview:} 
  6.1293 @@ -7363,6 +7943,27 @@ Quals & Field & Type & Description \\
  6.1294  \hline
  6.1295  \end{longtable}
  6.1296  \subsection{Additional RPCs associated with class: VIF\_metrics}
  6.1297 +\subsubsection{RPC name:~get\_all}
  6.1298 +
  6.1299 +{\bf Overview:} 
  6.1300 +Return a list of all the VIF\_metrics instances known to the system.
  6.1301 +
  6.1302 + \noindent {\bf Signature:} 
  6.1303 +\begin{verbatim} ((VIF_metrics ref) Set) get_all (session_id s)\end{verbatim}
  6.1304 +
  6.1305 +
  6.1306 +\vspace{0.3cm}
  6.1307 +
  6.1308 + \noindent {\bf Return Type:} 
  6.1309 +{\tt 
  6.1310 +(VIF\_metrics ref) Set
  6.1311 +}
  6.1312 +
  6.1313 +
  6.1314 +references to all objects
  6.1315 +\vspace{0.3cm}
  6.1316 +\vspace{0.3cm}
  6.1317 +\vspace{0.3cm}
  6.1318  \subsubsection{RPC name:~get\_uuid}
  6.1319  
  6.1320  {\bf Overview:} 
  6.1321 @@ -7623,6 +8224,27 @@ void
  6.1322  \noindent{\bf Possible Error Codes:} {\tt PIF\_IS\_PHYSICAL}
  6.1323  
  6.1324  \vspace{0.6cm}
  6.1325 +\subsubsection{RPC name:~get\_all}
  6.1326 +
  6.1327 +{\bf Overview:} 
  6.1328 +Return a list of all the PIFs known to the system.
  6.1329 +
  6.1330 + \noindent {\bf Signature:} 
  6.1331 +\begin{verbatim} ((PIF ref) Set) get_all (session_id s)\end{verbatim}
  6.1332 +
  6.1333 +
  6.1334 +\vspace{0.3cm}
  6.1335 +
  6.1336 + \noindent {\bf Return Type:} 
  6.1337 +{\tt 
  6.1338 +(PIF ref) Set
  6.1339 +}
  6.1340 +
  6.1341 +
  6.1342 +references to all objects
  6.1343 +\vspace{0.3cm}
  6.1344 +\vspace{0.3cm}
  6.1345 +\vspace{0.3cm}
  6.1346  \subsubsection{RPC name:~get\_uuid}
  6.1347  
  6.1348  {\bf Overview:} 
  6.1349 @@ -8093,12 +8715,32 @@ The metrics associated with a physical n
  6.1350  Quals & Field & Type & Description \\
  6.1351  \hline
  6.1352  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
  6.1353 -$\mathit{RO}_\mathit{ins}$ &  {\tt PIF} & PIF ref & PIF to which these metrics apply \\
  6.1354  $\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
  6.1355  $\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
  6.1356  \hline
  6.1357  \end{longtable}
  6.1358  \subsection{Additional RPCs associated with class: PIF\_metrics}
  6.1359 +\subsubsection{RPC name:~get\_all}
  6.1360 +
  6.1361 +{\bf Overview:} 
  6.1362 +Return a list of all the PIF\_metrics instances known to the system.
  6.1363 +
  6.1364 + \noindent {\bf Signature:} 
  6.1365 +\begin{verbatim} ((PIF_metrics ref) Set) get_all (session_id s)\end{verbatim}
  6.1366 +
  6.1367 +
  6.1368 +\vspace{0.3cm}
  6.1369 +
  6.1370 + \noindent {\bf Return Type:} 
  6.1371 +{\tt 
  6.1372 +(PIF\_metrics ref) Set
  6.1373 +}
  6.1374 +
  6.1375 +
  6.1376 +references to all objects
  6.1377 +\vspace{0.3cm}
  6.1378 +\vspace{0.3cm}
  6.1379 +\vspace{0.3cm}
  6.1380  \subsubsection{RPC name:~get\_uuid}
  6.1381  
  6.1382  {\bf Overview:} 
  6.1383 @@ -8131,38 +8773,6 @@ value of the field
  6.1384  \vspace{0.3cm}
  6.1385  \vspace{0.3cm}
  6.1386  \vspace{0.3cm}
  6.1387 -\subsubsection{RPC name:~get\_PIF}
  6.1388 -
  6.1389 -{\bf Overview:} 
  6.1390 -Get the PIF field of the given PIF\_metrics.
  6.1391 -
  6.1392 - \noindent {\bf Signature:} 
  6.1393 -\begin{verbatim} (PIF ref) get_PIF (session_id s, PIF_metrics ref self)\end{verbatim}
  6.1394 -
  6.1395 -
  6.1396 -\noindent{\bf Arguments:}
  6.1397 -
  6.1398 - 
  6.1399 -\vspace{0.3cm}
  6.1400 -\begin{tabular}{|c|c|p{7cm}|}
  6.1401 - \hline
  6.1402 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1403 -{\tt PIF\_metrics ref } & self & reference to the object \\ \hline 
  6.1404 -
  6.1405 -\end{tabular}
  6.1406 -
  6.1407 -\vspace{0.3cm}
  6.1408 -
  6.1409 - \noindent {\bf Return Type:} 
  6.1410 -{\tt 
  6.1411 -PIF ref
  6.1412 -}
  6.1413 -
  6.1414 -
  6.1415 -value of the field
  6.1416 -\vspace{0.3cm}
  6.1417 -\vspace{0.3cm}
  6.1418 -\vspace{0.3cm}
  6.1419  \subsubsection{RPC name:~get\_io\_read\_kbs}
  6.1420  
  6.1421  {\bf Overview:} 
  6.1422 @@ -8942,7 +9552,7 @@ Quals & Field & Type & Description \\
  6.1423  $\mathit{RW}$ &  {\tt SR} & SR ref & storage repository in which the VDI resides \\
  6.1424  $\mathit{RO}_\mathit{run}$ &  {\tt VBDs} & (VBD ref) Set & list of vbds that refer to this disk \\
  6.1425  $\mathit{RO}_\mathit{run}$ &  {\tt crash\_dumps} & (crashdump ref) Set & list of crash dumps that refer to this disk \\
  6.1426 -$\mathit{RW}$ &  {\tt virtual\_size} & int & size of disk as presented to the guest (in multiples of sector\_size field) \\
  6.1427 +$\mathit{RW}$ &  {\tt virtual\_size} & int & size of disk as presented to the guest (in bytes). Note that, depending on storage backend type, requested size may not be respected exactly \\
  6.1428  $\mathit{RO}_\mathit{run}$ &  {\tt physical\_utilisation} & int & amount of physical space that the disk image is currently taking up on the storage repository (in bytes) \\
  6.1429  $\mathit{RO}_\mathit{ins}$ &  {\tt sector\_size} & int & sector size of VDI (in bytes) \\
  6.1430  $\mathit{RO}_\mathit{ins}$ &  {\tt type} & vdi\_type & type of the VDI \\
  6.1431 @@ -9018,6 +9628,27 @@ void
  6.1432  \vspace{0.3cm}
  6.1433  \vspace{0.3cm}
  6.1434  \vspace{0.3cm}
  6.1435 +\subsubsection{RPC name:~get\_all}
  6.1436 +
  6.1437 +{\bf Overview:} 
  6.1438 +Return a list of all the VDIs known to the system.
  6.1439 +
  6.1440 + \noindent {\bf Signature:} 
  6.1441 +\begin{verbatim} ((VDI ref) Set) get_all (session_id s)\end{verbatim}
  6.1442 +
  6.1443 +
  6.1444 +\vspace{0.3cm}
  6.1445 +
  6.1446 + \noindent {\bf Return Type:} 
  6.1447 +{\tt 
  6.1448 +(VDI ref) Set
  6.1449 +}
  6.1450 +
  6.1451 +
  6.1452 +references to all objects
  6.1453 +\vspace{0.3cm}
  6.1454 +\vspace{0.3cm}
  6.1455 +\vspace{0.3cm}
  6.1456  \subsubsection{RPC name:~get\_uuid}
  6.1457  
  6.1458  {\bf Overview:} 
  6.1459 @@ -9786,9 +10417,13 @@ Quals & Field & Type & Description \\
  6.1460  $\mathit{RW}$ &  {\tt bootable} & bool & true if this VBD is bootable \\
  6.1461  $\mathit{RW}$ &  {\tt mode} & vbd\_mode & the mode the VBD should be mounted with \\
  6.1462  $\mathit{RW}$ &  {\tt type} & vbd\_type & how the VBD will appear to the guest (e.g. disk or CD) \\
  6.1463 +$\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device currently attached (erased on reboot) \\
  6.1464 +$\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code associated with last attach-operation (erased on reboot) \\
  6.1465 +$\mathit{RO}_\mathit{run}$ &  {\tt status\_detail} & string & error/success information associated with last attach-operation status (erased on reboot) \\
  6.1466  $\mathit{RW}$ &  {\tt qos/algorithm\_type} & string & QoS algorithm to use \\
  6.1467 -$\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) Map & Paramters for chosen QoS algorithm \\
  6.1468 -$\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VBD\_metrics ref & metrics associated with this VBD. \\
  6.1469 +$\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) Map & parameters for chosen QoS algorithm \\
  6.1470 +$\mathit{RO}_\mathit{run}$ &  {\tt qos/supported\_algorithms} & string Set & supported QoS algorithms for this VBD \\
  6.1471 +$\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VBD\_metrics ref & metrics associated with this VBD \\
  6.1472  \hline
  6.1473  \end{longtable}
  6.1474  \subsection{Additional RPCs associated with class: VBD}
  6.1475 @@ -9827,6 +10462,27 @@ void
  6.1476  \vspace{0.3cm}
  6.1477  \vspace{0.3cm}
  6.1478  \vspace{0.3cm}
  6.1479 +\subsubsection{RPC name:~get\_all}
  6.1480 +
  6.1481 +{\bf Overview:} 
  6.1482 +Return a list of all the VBDs known to the system.
  6.1483 +
  6.1484 + \noindent {\bf Signature:} 
  6.1485 +\begin{verbatim} ((VBD ref) Set) get_all (session_id s)\end{verbatim}
  6.1486 +
  6.1487 +
  6.1488 +\vspace{0.3cm}
  6.1489 +
  6.1490 + \noindent {\bf Return Type:} 
  6.1491 +{\tt 
  6.1492 +(VBD ref) Set
  6.1493 +}
  6.1494 +
  6.1495 +
  6.1496 +references to all objects
  6.1497 +\vspace{0.3cm}
  6.1498 +\vspace{0.3cm}
  6.1499 +\vspace{0.3cm}
  6.1500  \subsubsection{RPC name:~get\_uuid}
  6.1501  
  6.1502  {\bf Overview:} 
  6.1503 @@ -10187,6 +10843,102 @@ void
  6.1504  \vspace{0.3cm}
  6.1505  \vspace{0.3cm}
  6.1506  \vspace{0.3cm}
  6.1507 +\subsubsection{RPC name:~get\_currently\_attached}
  6.1508 +
  6.1509 +{\bf Overview:} 
  6.1510 +Get the currently\_attached field of the given VBD.
  6.1511 +
  6.1512 + \noindent {\bf Signature:} 
  6.1513 +\begin{verbatim} bool get_currently_attached (session_id s, VBD ref self)\end{verbatim}
  6.1514 +
  6.1515 +
  6.1516 +\noindent{\bf Arguments:}
  6.1517 +
  6.1518 + 
  6.1519 +\vspace{0.3cm}
  6.1520 +\begin{tabular}{|c|c|p{7cm}|}
  6.1521 + \hline
  6.1522 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1523 +{\tt VBD ref } & self & reference to the object \\ \hline 
  6.1524 +
  6.1525 +\end{tabular}
  6.1526 +
  6.1527 +\vspace{0.3cm}
  6.1528 +
  6.1529 + \noindent {\bf Return Type:} 
  6.1530 +{\tt 
  6.1531 +bool
  6.1532 +}
  6.1533 +
  6.1534 +
  6.1535 +value of the field
  6.1536 +\vspace{0.3cm}
  6.1537 +\vspace{0.3cm}
  6.1538 +\vspace{0.3cm}
  6.1539 +\subsubsection{RPC name:~get\_status\_code}
  6.1540 +
  6.1541 +{\bf Overview:} 
  6.1542 +Get the status\_code field of the given VBD.
  6.1543 +
  6.1544 + \noindent {\bf Signature:} 
  6.1545 +\begin{verbatim} int get_status_code (session_id s, VBD ref self)\end{verbatim}
  6.1546 +
  6.1547 +
  6.1548 +\noindent{\bf Arguments:}
  6.1549 +
  6.1550 + 
  6.1551 +\vspace{0.3cm}
  6.1552 +\begin{tabular}{|c|c|p{7cm}|}
  6.1553 + \hline
  6.1554 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1555 +{\tt VBD ref } & self & reference to the object \\ \hline 
  6.1556 +
  6.1557 +\end{tabular}
  6.1558 +
  6.1559 +\vspace{0.3cm}
  6.1560 +
  6.1561 + \noindent {\bf Return Type:} 
  6.1562 +{\tt 
  6.1563 +int
  6.1564 +}
  6.1565 +
  6.1566 +
  6.1567 +value of the field
  6.1568 +\vspace{0.3cm}
  6.1569 +\vspace{0.3cm}
  6.1570 +\vspace{0.3cm}
  6.1571 +\subsubsection{RPC name:~get\_status\_detail}
  6.1572 +
  6.1573 +{\bf Overview:} 
  6.1574 +Get the status\_detail field of the given VBD.
  6.1575 +
  6.1576 + \noindent {\bf Signature:} 
  6.1577 +\begin{verbatim} string get_status_detail (session_id s, VBD ref self)\end{verbatim}
  6.1578 +
  6.1579 +
  6.1580 +\noindent{\bf Arguments:}
  6.1581 +
  6.1582 + 
  6.1583 +\vspace{0.3cm}
  6.1584 +\begin{tabular}{|c|c|p{7cm}|}
  6.1585 + \hline
  6.1586 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1587 +{\tt VBD ref } & self & reference to the object \\ \hline 
  6.1588 +
  6.1589 +\end{tabular}
  6.1590 +
  6.1591 +\vspace{0.3cm}
  6.1592 +
  6.1593 + \noindent {\bf Return Type:} 
  6.1594 +{\tt 
  6.1595 +string
  6.1596 +}
  6.1597 +
  6.1598 +
  6.1599 +value of the field
  6.1600 +\vspace{0.3cm}
  6.1601 +\vspace{0.3cm}
  6.1602 +\vspace{0.3cm}
  6.1603  \subsubsection{RPC name:~get\_qos\_algorithm\_type}
  6.1604  
  6.1605  {\bf Overview:} 
  6.1606 @@ -10392,6 +11144,38 @@ void
  6.1607  \vspace{0.3cm}
  6.1608  \vspace{0.3cm}
  6.1609  \vspace{0.3cm}
  6.1610 +\subsubsection{RPC name:~get\_qos\_supported\_algorithms}
  6.1611 +
  6.1612 +{\bf Overview:} 
  6.1613 +Get the qos/supported\_algorithms field of the given VBD.
  6.1614 +
  6.1615 + \noindent {\bf Signature:} 
  6.1616 +\begin{verbatim} (string Set) get_qos_supported_algorithms (session_id s, VBD ref self)\end{verbatim}
  6.1617 +
  6.1618 +
  6.1619 +\noindent{\bf Arguments:}
  6.1620 +
  6.1621 + 
  6.1622 +\vspace{0.3cm}
  6.1623 +\begin{tabular}{|c|c|p{7cm}|}
  6.1624 + \hline
  6.1625 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  6.1626 +{\tt VBD ref } & self & reference to the object \\ \hline 
  6.1627 +
  6.1628 +\end{tabular}
  6.1629 +
  6.1630 +\vspace{0.3cm}
  6.1631 +
  6.1632 + \noindent {\bf Return Type:} 
  6.1633 +{\tt 
  6.1634 +string Set
  6.1635 +}
  6.1636 +
  6.1637 +
  6.1638 +value of the field
  6.1639 +\vspace{0.3cm}
  6.1640 +\vspace{0.3cm}
  6.1641 +\vspace{0.3cm}
  6.1642  \subsubsection{RPC name:~get\_metrics}
  6.1643  
  6.1644  {\bf Overview:} 
  6.1645 @@ -10571,6 +11355,27 @@ Quals & Field & Type & Description \\
  6.1646  \hline
  6.1647  \end{longtable}
  6.1648  \subsection{Additional RPCs associated with class: VBD\_metrics}
  6.1649 +\subsubsection{RPC name:~get\_all}
  6.1650 +
  6.1651 +{\bf Overview:} 
  6.1652 +Return a list of all the VBD\_metrics instances known to the system.
  6.1653 +
  6.1654 + \noindent {\bf Signature:} 
  6.1655 +\begin{verbatim} ((VBD_metrics ref) Set) get_all (session_id s)\end{verbatim}
  6.1656 +
  6.1657 +
  6.1658 +\vspace{0.3cm}
  6.1659 +
  6.1660 + \noindent {\bf Return Type:} 
  6.1661 +{\tt 
  6.1662 +(VBD\_metrics ref) Set
  6.1663 +}
  6.1664 +
  6.1665 +
  6.1666 +references to all objects
  6.1667 +\vspace{0.3cm}
  6.1668 +\vspace{0.3cm}
  6.1669 +\vspace{0.3cm}
  6.1670  \subsubsection{RPC name:~get\_uuid}
  6.1671  
  6.1672  {\bf Overview:} 
  6.1673 @@ -10752,6 +11557,27 @@ Quals & Field & Type & Description \\
  6.1674  \hline
  6.1675  \end{longtable}
  6.1676  \subsection{Additional RPCs associated with class: PBD}
  6.1677 +\subsubsection{RPC name:~get\_all}
  6.1678 +
  6.1679 +{\bf Overview:} 
  6.1680 +Return a list of all the PBDs known to the system.
  6.1681 +
  6.1682 + \noindent {\bf Signature:} 
  6.1683 +\begin{verbatim} ((PBD ref) Set) get_all (session_id s)\end{verbatim}
  6.1684 +
  6.1685 +
  6.1686 +\vspace{0.3cm}
  6.1687 +
  6.1688 + \noindent {\bf Return Type:} 
  6.1689 +{\tt 
  6.1690 +(PBD ref) Set
  6.1691 +}
  6.1692 +
  6.1693 +
  6.1694 +references to all objects
  6.1695 +\vspace{0.3cm}
  6.1696 +\vspace{0.3cm}
  6.1697 +\vspace{0.3cm}
  6.1698  \subsubsection{RPC name:~get\_uuid}
  6.1699  
  6.1700  {\bf Overview:} 
  6.1701 @@ -11568,6 +12394,27 @@ Quals & Field & Type & Description \\
  6.1702  \hline
  6.1703  \end{longtable}
  6.1704  \subsection{Additional RPCs associated with class: console}
  6.1705 +\subsubsection{RPC name:~get\_all}
  6.1706 +
  6.1707 +{\bf Overview:} 
  6.1708 +Return a list of all the consoles known to the system.
  6.1709 +
  6.1710 + \noindent {\bf Signature:} 
  6.1711 +\begin{verbatim} ((console ref) Set) get_all (session_id s)\end{verbatim}
  6.1712 +
  6.1713 +
  6.1714 +\vspace{0.3cm}
  6.1715 +
  6.1716 + \noindent {\bf Return Type:} 
  6.1717 +{\tt 
  6.1718 +(console ref) Set
  6.1719 +}
  6.1720 +
  6.1721 +
  6.1722 +references to all objects
  6.1723 +\vspace{0.3cm}
  6.1724 +\vspace{0.3cm}
  6.1725 +\vspace{0.3cm}
  6.1726  \subsubsection{RPC name:~get\_uuid}
  6.1727  
  6.1728  {\bf Overview:} 
     7.1 --- a/extras/mini-os/Makefile	Thu Mar 01 15:02:09 2007 -0700
     7.2 +++ b/extras/mini-os/Makefile	Wed Mar 07 12:38:28 2007 -0700
     7.3 @@ -4,8 +4,6 @@
     7.4  # Makefile and a arch.mk.
     7.5  #
     7.6  
     7.7 -pae ?= n
     7.8 -
     7.9  XEN_ROOT = ../..
    7.10  include $(XEN_ROOT)/Config.mk
    7.11  
    7.12 @@ -35,6 +33,7 @@ TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FA
    7.13  export TARGET_ARCH
    7.14  export TARGET_ARCH_DIR
    7.15  export TARGET_ARCH_FAM
    7.16 +export XEN_TARGET_X86_PAE 
    7.17  
    7.18  # This is used for architecture specific links.
    7.19  # This can be overwritten from arch specific rules.
     8.1 --- a/extras/mini-os/arch/ia64/mm.c	Thu Mar 01 15:02:09 2007 -0700
     8.2 +++ b/extras/mini-os/arch/ia64/mm.c	Wed Mar 07 12:38:28 2007 -0700
     8.3 @@ -130,3 +130,7 @@ map_frames(unsigned long* frames, unsign
     8.4  	return (void*) __va(frames[0] << PAGE_SHIFT);
     8.5  }
     8.6  
     8.7 +void arch_init_p2m(unsigned long max_pfn)
     8.8 +{
     8.9 +    printk("Warn: p2m map not implemented.\n");
    8.10 +}
     9.1 --- a/extras/mini-os/arch/x86/Makefile	Thu Mar 01 15:02:09 2007 -0700
     9.2 +++ b/extras/mini-os/arch/x86/Makefile	Wed Mar 07 12:38:28 2007 -0700
     9.3 @@ -4,6 +4,7 @@
     9.4  #
     9.5  
     9.6  # include arch.mk has to be before mini-os.mk!
     9.7 +
     9.8  include arch.mk
     9.9  include ../../minios.mk
    9.10  
    10.1 --- a/extras/mini-os/arch/x86/arch.mk	Thu Mar 01 15:02:09 2007 -0700
    10.2 +++ b/extras/mini-os/arch/x86/arch.mk	Wed Mar 07 12:38:28 2007 -0700
    10.3 @@ -9,13 +9,11 @@ ARCH_LDFLAGS := -m elf_i386
    10.4  ARCH_ASFLAGS := -m32
    10.5  EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
    10.6  EXTRA_SRC += arch/$(EXTRA_INC)
    10.7 +
    10.8 +ifeq ($(XEN_TARGET_X86_PAE),y)
    10.9 +ARCH_CFLAGS  += -DCONFIG_X86_PAE=1
   10.10 +ARCH_ASFLAGS += -DCONFIG_X86_PAE=1
   10.11  endif
   10.12 -
   10.13 -ifeq ($(TARGET_ARCH)$(pae),x86_32y)
   10.14 -ARCH_CFLAGS  := -DCONFIG_X86_PAE=1
   10.15 -ARCH_ASFLAGS := -DCONFIG_X86_PAE=1
   10.16 -EXTRA_INC += $(TARGET_ARCH_FAM)/$(TARGET_ARCH)
   10.17 -EXTRA_SRC += arch/$(EXTRA_INC)
   10.18  endif
   10.19  
   10.20  ifeq ($(TARGET_ARCH),x86_64)
    11.1 --- a/extras/mini-os/arch/x86/mm.c	Thu Mar 01 15:02:09 2007 -0700
    11.2 +++ b/extras/mini-os/arch/x86/mm.c	Wed Mar 07 12:38:28 2007 -0700
    11.3 @@ -402,6 +402,49 @@ void *map_frames(unsigned long *f, unsig
    11.4      }
    11.5  }
    11.6  
    11.7 +
    11.8 +void arch_init_p2m(unsigned long max_pfn)
    11.9 +{
   11.10 +#define L1_P2M_SHIFT    10
   11.11 +#define L2_P2M_SHIFT    20    
   11.12 +#define L3_P2M_SHIFT    30    
   11.13 +#define L1_P2M_ENTRIES  (1 << L1_P2M_SHIFT)    
   11.14 +#define L2_P2M_ENTRIES  (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT))    
   11.15 +#define L3_P2M_ENTRIES  (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT))    
   11.16 +#define L1_P2M_MASK     (L1_P2M_ENTRIES - 1)    
   11.17 +#define L2_P2M_MASK     (L2_P2M_ENTRIES - 1)    
   11.18 +#define L3_P2M_MASK     (L3_P2M_ENTRIES - 1)    
   11.19 +    
   11.20 +    unsigned long *l1_list, *l2_list, *l3_list;
   11.21 +    unsigned long pfn;
   11.22 +    
   11.23 +    l3_list = (unsigned long *)alloc_page(); 
   11.24 +    for(pfn=0; pfn<max_pfn; pfn++)
   11.25 +    {
   11.26 +        if(!(pfn % (L1_P2M_ENTRIES * L2_P2M_ENTRIES)))
   11.27 +        {
   11.28 +            l2_list = (unsigned long*)alloc_page();
   11.29 +            if((pfn >> L3_P2M_SHIFT) > 0)
   11.30 +            {
   11.31 +                printk("Error: Too many pfns.\n");
   11.32 +                do_exit();
   11.33 +            }
   11.34 +            l3_list[(pfn >> L2_P2M_SHIFT)] = virt_to_mfn(l2_list);  
   11.35 +        }
   11.36 +        if(!(pfn % (L1_P2M_ENTRIES)))
   11.37 +        {
   11.38 +            l1_list = (unsigned long*)alloc_page();
   11.39 +            l2_list[(pfn >> L1_P2M_SHIFT) & L2_P2M_MASK] = 
   11.40 +                virt_to_mfn(l1_list); 
   11.41 +        }
   11.42 +
   11.43 +        l1_list[pfn & L1_P2M_MASK] = pfn_to_mfn(pfn); 
   11.44 +    }
   11.45 +    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = 
   11.46 +        virt_to_mfn(l3_list);
   11.47 +    HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
   11.48 +}
   11.49 +
   11.50  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)
   11.51  {
   11.52  
    12.1 --- a/extras/mini-os/include/mm.h	Thu Mar 01 15:02:09 2007 -0700
    12.2 +++ b/extras/mini-os/include/mm.h	Wed Mar 07 12:38:28 2007 -0700
    12.3 @@ -55,6 +55,7 @@ static __inline__ int get_order(unsigned
    12.4  
    12.5  void arch_init_demand_mapping_area(unsigned long max_pfn);
    12.6  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
    12.7 +void arch_init_p2m(unsigned long max_pfn_p);
    12.8  
    12.9  void *map_frames(unsigned long *f, unsigned long n);
   12.10  
    13.1 --- a/extras/mini-os/mm.c	Thu Mar 01 15:02:09 2007 -0700
    13.2 +++ b/extras/mini-os/mm.c	Wed Mar 07 12:38:28 2007 -0700
    13.3 @@ -379,6 +379,8 @@ void init_mm(void)
    13.4      init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn));
    13.5      printk("MM: done\n");
    13.6  
    13.7 +    arch_init_p2m(max_pfn);
    13.8 +    
    13.9      arch_init_demand_mapping_area(max_pfn);
   13.10  }
   13.11  
    14.1 --- a/linux-2.6-xen-sparse/arch/i386/Kconfig	Thu Mar 01 15:02:09 2007 -0700
    14.2 +++ b/linux-2.6-xen-sparse/arch/i386/Kconfig	Wed Mar 07 12:38:28 2007 -0700
    14.3 @@ -255,7 +255,6 @@ config NR_CPUS
    14.4  config SCHED_SMT
    14.5  	bool "SMT (Hyperthreading) scheduler support"
    14.6  	depends on X86_HT
    14.7 -	depends on !X86_XEN
    14.8  	help
    14.9  	  SMT scheduler support improves the CPU scheduler's decision making
   14.10  	  when dealing with Intel Pentium 4 chips with HyperThreading at a
   14.11 @@ -313,11 +312,6 @@ config X86_VISWS_APIC
   14.12  	depends on X86_VISWS
   14.13  	default y
   14.14  
   14.15 -config X86_TSC
   14.16 -	bool
   14.17 -	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1) && !X86_NUMAQ && !X86_XEN
   14.18 -	default y
   14.19 -
   14.20  config X86_MCE
   14.21  	bool "Machine Check Exception"
   14.22  	depends on !(X86_VOYAGER || X86_XEN)
    15.1 --- a/linux-2.6-xen-sparse/arch/i386/Kconfig.cpu	Thu Mar 01 15:02:09 2007 -0700
    15.2 +++ b/linux-2.6-xen-sparse/arch/i386/Kconfig.cpu	Wed Mar 07 12:38:28 2007 -0700
    15.3 @@ -311,5 +311,5 @@ config X86_OOSTORE
    15.4  
    15.5  config X86_TSC
    15.6  	bool
    15.7 -	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX) && !X86_NUMAQ
    15.8 +	depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX) && !X86_NUMAQ && !X86_XEN
    15.9  	default y
    16.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/alternative-xen.c	Thu Mar 01 15:02:09 2007 -0700
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,389 +0,0 @@
    16.4 -#include <linux/module.h>
    16.5 -#include <linux/spinlock.h>
    16.6 -#include <linux/list.h>
    16.7 -#include <asm/alternative.h>
    16.8 -#include <asm/sections.h>
    16.9 -
   16.10 -static int no_replacement    = 0;
   16.11 -static int smp_alt_once      = 0;
   16.12 -static int debug_alternative = 0;
   16.13 -
   16.14 -static int __init noreplacement_setup(char *s)
   16.15 -{
   16.16 -	no_replacement = 1;
   16.17 -	return 1;
   16.18 -}
   16.19 -static int __init bootonly(char *str)
   16.20 -{
   16.21 -	smp_alt_once = 1;
   16.22 -	return 1;
   16.23 -}
   16.24 -static int __init debug_alt(char *str)
   16.25 -{
   16.26 -	debug_alternative = 1;
   16.27 -	return 1;
   16.28 -}
   16.29 -
   16.30 -__setup("noreplacement", noreplacement_setup);
   16.31 -__setup("smp-alt-boot", bootonly);
   16.32 -__setup("debug-alternative", debug_alt);
   16.33 -
   16.34 -#define DPRINTK(fmt, args...) if (debug_alternative) \
   16.35 -	printk(KERN_DEBUG fmt, args)
   16.36 -
   16.37 -#ifdef GENERIC_NOP1
   16.38 -/* Use inline assembly to define this because the nops are defined
   16.39 -   as inline assembly strings in the include files and we cannot
   16.40 -   get them easily into strings. */
   16.41 -asm("\t.data\nintelnops: "
   16.42 -	GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
   16.43 -	GENERIC_NOP7 GENERIC_NOP8);
   16.44 -extern unsigned char intelnops[];
   16.45 -static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
   16.46 -	NULL,
   16.47 -	intelnops,
   16.48 -	intelnops + 1,
   16.49 -	intelnops + 1 + 2,
   16.50 -	intelnops + 1 + 2 + 3,
   16.51 -	intelnops + 1 + 2 + 3 + 4,
   16.52 -	intelnops + 1 + 2 + 3 + 4 + 5,
   16.53 -	intelnops + 1 + 2 + 3 + 4 + 5 + 6,
   16.54 -	intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
   16.55 -};
   16.56 -#endif
   16.57 -
   16.58 -#ifdef K8_NOP1
   16.59 -asm("\t.data\nk8nops: "
   16.60 -	K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
   16.61 -	K8_NOP7 K8_NOP8);
   16.62 -extern unsigned char k8nops[];
   16.63 -static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
   16.64 -	NULL,
   16.65 -	k8nops,
   16.66 -	k8nops + 1,
   16.67 -	k8nops + 1 + 2,
   16.68 -	k8nops + 1 + 2 + 3,
   16.69 -	k8nops + 1 + 2 + 3 + 4,
   16.70 -	k8nops + 1 + 2 + 3 + 4 + 5,
   16.71 -	k8nops + 1 + 2 + 3 + 4 + 5 + 6,
   16.72 -	k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
   16.73 -};
   16.74 -#endif
   16.75 -
   16.76 -#ifdef K7_NOP1
   16.77 -asm("\t.data\nk7nops: "
   16.78 -	K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
   16.79 -	K7_NOP7 K7_NOP8);
   16.80 -extern unsigned char k7nops[];
   16.81 -static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
   16.82 -	NULL,
   16.83 -	k7nops,
   16.84 -	k7nops + 1,
   16.85 -	k7nops + 1 + 2,
   16.86 -	k7nops + 1 + 2 + 3,
   16.87 -	k7nops + 1 + 2 + 3 + 4,
   16.88 -	k7nops + 1 + 2 + 3 + 4 + 5,
   16.89 -	k7nops + 1 + 2 + 3 + 4 + 5 + 6,
   16.90 -	k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
   16.91 -};
   16.92 -#endif
   16.93 -
   16.94 -#ifdef CONFIG_X86_64
   16.95 -
   16.96 -extern char __vsyscall_0;
   16.97 -static inline unsigned char** find_nop_table(void)
   16.98 -{
   16.99 -	return k8_nops;
  16.100 -}
  16.101 -
  16.102 -#else /* CONFIG_X86_64 */
  16.103 -
  16.104 -static struct nop {
  16.105 -	int cpuid;
  16.106 -	unsigned char **noptable;
  16.107 -} noptypes[] = {
  16.108 -	{ X86_FEATURE_K8, k8_nops },
  16.109 -	{ X86_FEATURE_K7, k7_nops },
  16.110 -	{ -1, NULL }
  16.111 -};
  16.112 -
  16.113 -static unsigned char** find_nop_table(void)
  16.114 -{
  16.115 -	unsigned char **noptable = intel_nops;
  16.116 -	int i;
  16.117 -
  16.118 -	for (i = 0; noptypes[i].cpuid >= 0; i++) {
  16.119 -		if (boot_cpu_has(noptypes[i].cpuid)) {
  16.120 -			noptable = noptypes[i].noptable;
  16.121 -			break;
  16.122 -		}
  16.123 -	}
  16.124 -	return noptable;
  16.125 -}
  16.126 -
  16.127 -#endif /* CONFIG_X86_64 */
  16.128 -
  16.129 -extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
  16.130 -extern struct alt_instr __smp_alt_instructions[], __smp_alt_instructions_end[];
  16.131 -extern u8 *__smp_locks[], *__smp_locks_end[];
  16.132 -
  16.133 -extern u8 __smp_alt_begin[], __smp_alt_end[];
  16.134 -
  16.135 -/* Replace instructions with better alternatives for this CPU type.
  16.136 -   This runs before SMP is initialized to avoid SMP problems with
  16.137 -   self modifying code. This implies that assymetric systems where
  16.138 -   APs have less capabilities than the boot processor are not handled.
  16.139 -   Tough. Make sure you disable such features by hand. */
  16.140 -
  16.141 -void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
  16.142 -{
  16.143 -	unsigned char **noptable = find_nop_table();
  16.144 -	struct alt_instr *a;
  16.145 -	u8 *instr;
  16.146 -	int diff, i, k;
  16.147 -
  16.148 -	DPRINTK("%s: alt table %p -> %p\n", __FUNCTION__, start, end);
  16.149 -	for (a = start; a < end; a++) {
  16.150 -		BUG_ON(a->replacementlen > a->instrlen);
  16.151 -		if (!boot_cpu_has(a->cpuid))
  16.152 -			continue;
  16.153 -		instr = a->instr;
  16.154 -#ifdef CONFIG_X86_64
  16.155 -		/* vsyscall code is not mapped yet. resolve it manually. */
  16.156 -		if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END) {
  16.157 -			instr -= VSYSCALL_START - (unsigned long)&__vsyscall_0;
  16.158 -			DPRINTK("%s: vsyscall fixup: %p => %p\n",
  16.159 -				__FUNCTION__, a->instr, instr);
  16.160 -		}
  16.161 -#endif
  16.162 -		memcpy(instr, a->replacement, a->replacementlen);
  16.163 -		diff = a->instrlen - a->replacementlen;
  16.164 -		/* Pad the rest with nops */
  16.165 -		for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
  16.166 -			k = diff;
  16.167 -			if (k > ASM_NOP_MAX)
  16.168 -				k = ASM_NOP_MAX;
  16.169 -			memcpy(a->instr + i, noptable[k], k);
  16.170 -		}
  16.171 -	}
  16.172 -}
  16.173 -
  16.174 -#ifdef CONFIG_SMP
  16.175 -
  16.176 -static void alternatives_smp_save(struct alt_instr *start, struct alt_instr *end)
  16.177 -{
  16.178 -	struct alt_instr *a;
  16.179 -
  16.180 -	DPRINTK("%s: alt table %p-%p\n", __FUNCTION__, start, end);
  16.181 -	for (a = start; a < end; a++) {
  16.182 -		memcpy(a->replacement + a->replacementlen,
  16.183 -		       a->instr,
  16.184 -		       a->instrlen);
  16.185 -	}
  16.186 -}
  16.187 -
  16.188 -static void alternatives_smp_apply(struct alt_instr *start, struct alt_instr *end)
  16.189 -{
  16.190 -	struct alt_instr *a;
  16.191 -
  16.192 -	for (a = start; a < end; a++) {
  16.193 -		memcpy(a->instr,
  16.194 -		       a->replacement + a->replacementlen,
  16.195 -		       a->instrlen);
  16.196 -	}
  16.197 -}
  16.198 -
  16.199 -static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
  16.200 -{
  16.201 -	u8 **ptr;
  16.202 -
  16.203 -	for (ptr = start; ptr < end; ptr++) {
  16.204 -		if (*ptr < text)
  16.205 -			continue;
  16.206 -		if (*ptr > text_end)
  16.207 -			continue;
  16.208 -		**ptr = 0xf0; /* lock prefix */
  16.209 -	};
  16.210 -}
  16.211 -
  16.212 -static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end)
  16.213 -{
  16.214 -	unsigned char **noptable = find_nop_table();
  16.215 -	u8 **ptr;
  16.216 -
  16.217 -	for (ptr = start; ptr < end; ptr++) {
  16.218 -		if (*ptr < text)
  16.219 -			continue;
  16.220 -		if (*ptr > text_end)
  16.221 -			continue;
  16.222 -		**ptr = noptable[1][0];
  16.223 -	};
  16.224 -}
  16.225 -
  16.226 -struct smp_alt_module {
  16.227 -	/* what is this ??? */
  16.228 -	struct module	*mod;
  16.229 -	char		*name;
  16.230 -
  16.231 -	/* ptrs to lock prefixes */
  16.232 -	u8		**locks;
  16.233 -	u8		**locks_end;
  16.234 -
  16.235 -	/* .text segment, needed to avoid patching init code ;) */
  16.236 -	u8		*text;
  16.237 -	u8		*text_end;
  16.238 -
  16.239 -	struct list_head next;
  16.240 -};
  16.241 -static LIST_HEAD(smp_alt_modules);
  16.242 -static DEFINE_SPINLOCK(smp_alt);
  16.243 -
  16.244 -void alternatives_smp_module_add(struct module *mod, char *name,
  16.245 -				 void *locks, void *locks_end,
  16.246 -				 void *text,  void *text_end)
  16.247 -{
  16.248 -	struct smp_alt_module *smp;
  16.249 -	unsigned long flags;
  16.250 -
  16.251 -	if (no_replacement)
  16.252 -		return;
  16.253 -
  16.254 -	if (smp_alt_once) {
  16.255 -		if (boot_cpu_has(X86_FEATURE_UP))
  16.256 -			alternatives_smp_unlock(locks, locks_end,
  16.257 -						text, text_end);
  16.258 -		return;
  16.259 -	}
  16.260 -
  16.261 -	smp = kzalloc(sizeof(*smp), GFP_KERNEL);
  16.262 -	if (NULL == smp)
  16.263 -		return; /* we'll run the (safe but slow) SMP code then ... */
  16.264 -
  16.265 -	smp->mod	= mod;
  16.266 -	smp->name	= name;
  16.267 -	smp->locks	= locks;
  16.268 -	smp->locks_end	= locks_end;
  16.269 -	smp->text	= text;
  16.270 -	smp->text_end	= text_end;
  16.271 -	DPRINTK("%s: locks %p -> %p, text %p -> %p, name %s\n",
  16.272 -		__FUNCTION__, smp->locks, smp->locks_end,
  16.273 -		smp->text, smp->text_end, smp->name);
  16.274 -
  16.275 -	spin_lock_irqsave(&smp_alt, flags);
  16.276 -	list_add_tail(&smp->next, &smp_alt_modules);
  16.277 -	if (boot_cpu_has(X86_FEATURE_UP))
  16.278 -		alternatives_smp_unlock(smp->locks, smp->locks_end,
  16.279 -					smp->text, smp->text_end);
  16.280 -	spin_unlock_irqrestore(&smp_alt, flags);
  16.281 -}
  16.282 -
  16.283 -void alternatives_smp_module_del(struct module *mod)
  16.284 -{
  16.285 -	struct smp_alt_module *item;
  16.286 -	unsigned long flags;
  16.287 -
  16.288 -	if (no_replacement || smp_alt_once)
  16.289 -		return;
  16.290 -
  16.291 -	spin_lock_irqsave(&smp_alt, flags);
  16.292 -	list_for_each_entry(item, &smp_alt_modules, next) {
  16.293 -		if (mod != item->mod)
  16.294 -			continue;
  16.295 -		list_del(&item->next);
  16.296 -		spin_unlock_irqrestore(&smp_alt, flags);
  16.297 -		DPRINTK("%s: %s\n", __FUNCTION__, item->name);
  16.298 -		kfree(item);
  16.299 -		return;
  16.300 -	}
  16.301 -	spin_unlock_irqrestore(&smp_alt, flags);
  16.302 -}
  16.303 -
  16.304 -void alternatives_smp_switch(int smp)
  16.305 -{
  16.306 -	struct smp_alt_module *mod;
  16.307 -	unsigned long flags;
  16.308 -
  16.309 -#ifdef CONFIG_LOCKDEP
  16.310 -	/*
  16.311 -	 * A not yet fixed binutils section handling bug prevents
  16.312 -	 * alternatives-replacement from working reliably, so turn
  16.313 -	 * it off:
  16.314 -	 */
  16.315 -	printk("lockdep: not fixing up alternatives.\n");
  16.316 -	return;
  16.317 -#endif
  16.318 -
  16.319 -	if (no_replacement || smp_alt_once)
  16.320 -		return;
  16.321 -	BUG_ON(!smp && (num_online_cpus() > 1));
  16.322 -
  16.323 -	spin_lock_irqsave(&smp_alt, flags);
  16.324 -	if (smp) {
  16.325 -		printk(KERN_INFO "SMP alternatives: switching to SMP code\n");
  16.326 -		clear_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
  16.327 -		clear_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
  16.328 -		alternatives_smp_apply(__smp_alt_instructions,
  16.329 -				       __smp_alt_instructions_end);
  16.330 -		list_for_each_entry(mod, &smp_alt_modules, next)
  16.331 -			alternatives_smp_lock(mod->locks, mod->locks_end,
  16.332 -					      mod->text, mod->text_end);
  16.333 -	} else {
  16.334 -		printk(KERN_INFO "SMP alternatives: switching to UP code\n");
  16.335 -		set_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
  16.336 -		set_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
  16.337 -		apply_alternatives(__smp_alt_instructions,
  16.338 -				   __smp_alt_instructions_end);
  16.339 -		list_for_each_entry(mod, &smp_alt_modules, next)
  16.340 -			alternatives_smp_unlock(mod->locks, mod->locks_end,
  16.341 -						mod->text, mod->text_end);
  16.342 -	}
  16.343 -	spin_unlock_irqrestore(&smp_alt, flags);
  16.344 -}
  16.345 -
  16.346 -#endif
  16.347 -
  16.348 -void __init alternative_instructions(void)
  16.349 -{
  16.350 -	if (no_replacement) {
  16.351 -		printk(KERN_INFO "(SMP-)alternatives turned off\n");
  16.352 -		free_init_pages("SMP alternatives",
  16.353 -				(unsigned long)__smp_alt_begin,
  16.354 -				(unsigned long)__smp_alt_end);
  16.355 -		return;
  16.356 -	}
  16.357 -	apply_alternatives(__alt_instructions, __alt_instructions_end);
  16.358 -
  16.359 -	/* switch to patch-once-at-boottime-only mode and free the
  16.360 -	 * tables in case we know the number of CPUs will never ever
  16.361 -	 * change */
  16.362 -#ifdef CONFIG_HOTPLUG_CPU
  16.363 -	if (num_possible_cpus() < 2)
  16.364 -		smp_alt_once = 1;
  16.365 -#else
  16.366 -	smp_alt_once = 1;
  16.367 -#endif
  16.368 -
  16.369 -#ifdef CONFIG_SMP
  16.370 -	if (smp_alt_once) {
  16.371 -		if (1 == num_possible_cpus()) {
  16.372 -			printk(KERN_INFO "SMP alternatives: switching to UP code\n");
  16.373 -			set_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
  16.374 -			set_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
  16.375 -			apply_alternatives(__smp_alt_instructions,
  16.376 -					   __smp_alt_instructions_end);
  16.377 -			alternatives_smp_unlock(__smp_locks, __smp_locks_end,
  16.378 -						_text, _etext);
  16.379 -		}
  16.380 -		free_init_pages("SMP alternatives",
  16.381 -				(unsigned long)__smp_alt_begin,
  16.382 -				(unsigned long)__smp_alt_end);
  16.383 -	} else {
  16.384 -		alternatives_smp_save(__smp_alt_instructions,
  16.385 -				      __smp_alt_instructions_end);
  16.386 -		alternatives_smp_module_add(NULL, "core kernel",
  16.387 -					    __smp_locks, __smp_locks_end,
  16.388 -					    _text, _etext);
  16.389 -		alternatives_smp_switch(0);
  16.390 -	}
  16.391 -#endif
  16.392 -}
    17.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/intel_cacheinfo-xen.c	Thu Mar 01 15:02:09 2007 -0700
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,774 +0,0 @@
    17.4 -/*
    17.5 - *      Routines to indentify caches on Intel CPU.
    17.6 - *
    17.7 - *      Changes:
    17.8 - *      Venkatesh Pallipadi	: Adding cache identification through cpuid(4)
    17.9 - *		Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure.
   17.10 - *	Andi Kleen		: CPUID4 emulation on AMD.
   17.11 - */
   17.12 -
   17.13 -#include <linux/init.h>
   17.14 -#include <linux/slab.h>
   17.15 -#include <linux/device.h>
   17.16 -#include <linux/compiler.h>
   17.17 -#include <linux/cpu.h>
   17.18 -#include <linux/sched.h>
   17.19 -
   17.20 -#include <asm/processor.h>
   17.21 -#include <asm/smp.h>
   17.22 -
   17.23 -#define LVL_1_INST	1
   17.24 -#define LVL_1_DATA	2
   17.25 -#define LVL_2		3
   17.26 -#define LVL_3		4
   17.27 -#define LVL_TRACE	5
   17.28 -
   17.29 -struct _cache_table
   17.30 -{
   17.31 -	unsigned char descriptor;
   17.32 -	char cache_type;
   17.33 -	short size;
   17.34 -};
   17.35 -
   17.36 -/* all the cache descriptor types we care about (no TLB or trace cache entries) */
   17.37 -static struct _cache_table cache_table[] __cpuinitdata =
   17.38 -{
   17.39 -	{ 0x06, LVL_1_INST, 8 },	/* 4-way set assoc, 32 byte line size */
   17.40 -	{ 0x08, LVL_1_INST, 16 },	/* 4-way set assoc, 32 byte line size */
   17.41 -	{ 0x0a, LVL_1_DATA, 8 },	/* 2 way set assoc, 32 byte line size */
   17.42 -	{ 0x0c, LVL_1_DATA, 16 },	/* 4-way set assoc, 32 byte line size */
   17.43 -	{ 0x22, LVL_3,      512 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.44 -	{ 0x23, LVL_3,      1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.45 -	{ 0x25, LVL_3,      2048 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.46 -	{ 0x29, LVL_3,      4096 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.47 -	{ 0x2c, LVL_1_DATA, 32 },	/* 8-way set assoc, 64 byte line size */
   17.48 -	{ 0x30, LVL_1_INST, 32 },	/* 8-way set assoc, 64 byte line size */
   17.49 -	{ 0x39, LVL_2,      128 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.50 -	{ 0x3a, LVL_2,      192 },	/* 6-way set assoc, sectored cache, 64 byte line size */
   17.51 -	{ 0x3b, LVL_2,      128 },	/* 2-way set assoc, sectored cache, 64 byte line size */
   17.52 -	{ 0x3c, LVL_2,      256 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.53 -	{ 0x3d, LVL_2,      384 },	/* 6-way set assoc, sectored cache, 64 byte line size */
   17.54 -	{ 0x3e, LVL_2,      512 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.55 -	{ 0x41, LVL_2,      128 },	/* 4-way set assoc, 32 byte line size */
   17.56 -	{ 0x42, LVL_2,      256 },	/* 4-way set assoc, 32 byte line size */
   17.57 -	{ 0x43, LVL_2,      512 },	/* 4-way set assoc, 32 byte line size */
   17.58 -	{ 0x44, LVL_2,      1024 },	/* 4-way set assoc, 32 byte line size */
   17.59 -	{ 0x45, LVL_2,      2048 },	/* 4-way set assoc, 32 byte line size */
   17.60 -	{ 0x46, LVL_3,      4096 },	/* 4-way set assoc, 64 byte line size */
   17.61 -	{ 0x47, LVL_3,      8192 },	/* 8-way set assoc, 64 byte line size */
   17.62 -	{ 0x49, LVL_3,      4096 },	/* 16-way set assoc, 64 byte line size */
   17.63 -	{ 0x4a, LVL_3,      6144 },	/* 12-way set assoc, 64 byte line size */
   17.64 -	{ 0x4b, LVL_3,      8192 },	/* 16-way set assoc, 64 byte line size */
   17.65 -	{ 0x4c, LVL_3,     12288 },	/* 12-way set assoc, 64 byte line size */
   17.66 -	{ 0x4d, LVL_3,     16384 },	/* 16-way set assoc, 64 byte line size */
   17.67 -	{ 0x60, LVL_1_DATA, 16 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.68 -	{ 0x66, LVL_1_DATA, 8 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.69 -	{ 0x67, LVL_1_DATA, 16 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.70 -	{ 0x68, LVL_1_DATA, 32 },	/* 4-way set assoc, sectored cache, 64 byte line size */
   17.71 -	{ 0x70, LVL_TRACE,  12 },	/* 8-way set assoc */
   17.72 -	{ 0x71, LVL_TRACE,  16 },	/* 8-way set assoc */
   17.73 -	{ 0x72, LVL_TRACE,  32 },	/* 8-way set assoc */
   17.74 -	{ 0x73, LVL_TRACE,  64 },	/* 8-way set assoc */
   17.75 -	{ 0x78, LVL_2,    1024 },	/* 4-way set assoc, 64 byte line size */
   17.76 -	{ 0x79, LVL_2,     128 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.77 -	{ 0x7a, LVL_2,     256 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.78 -	{ 0x7b, LVL_2,     512 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.79 -	{ 0x7c, LVL_2,    1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
   17.80 -	{ 0x7d, LVL_2,    2048 },	/* 8-way set assoc, 64 byte line size */
   17.81 -	{ 0x7f, LVL_2,     512 },	/* 2-way set assoc, 64 byte line size */
   17.82 -	{ 0x82, LVL_2,     256 },	/* 8-way set assoc, 32 byte line size */
   17.83 -	{ 0x83, LVL_2,     512 },	/* 8-way set assoc, 32 byte line size */
   17.84 -	{ 0x84, LVL_2,    1024 },	/* 8-way set assoc, 32 byte line size */
   17.85 -	{ 0x85, LVL_2,    2048 },	/* 8-way set assoc, 32 byte line size */
   17.86 -	{ 0x86, LVL_2,     512 },	/* 4-way set assoc, 64 byte line size */
   17.87 -	{ 0x87, LVL_2,    1024 },	/* 8-way set assoc, 64 byte line size */
   17.88 -	{ 0x00, 0, 0}
   17.89 -};
   17.90 -
   17.91 -
   17.92 -enum _cache_type
   17.93 -{
   17.94 -	CACHE_TYPE_NULL	= 0,
   17.95 -	CACHE_TYPE_DATA = 1,
   17.96 -	CACHE_TYPE_INST = 2,
   17.97 -	CACHE_TYPE_UNIFIED = 3
   17.98 -};
   17.99 -
  17.100 -union _cpuid4_leaf_eax {
  17.101 -	struct {
  17.102 -		enum _cache_type	type:5;
  17.103 -		unsigned int		level:3;
  17.104 -		unsigned int		is_self_initializing:1;
  17.105 -		unsigned int		is_fully_associative:1;
  17.106 -		unsigned int		reserved:4;
  17.107 -		unsigned int		num_threads_sharing:12;
  17.108 -		unsigned int		num_cores_on_die:6;
  17.109 -	} split;
  17.110 -	u32 full;
  17.111 -};
  17.112 -
  17.113 -union _cpuid4_leaf_ebx {
  17.114 -	struct {
  17.115 -		unsigned int		coherency_line_size:12;
  17.116 -		unsigned int		physical_line_partition:10;
  17.117 -		unsigned int		ways_of_associativity:10;
  17.118 -	} split;
  17.119 -	u32 full;
  17.120 -};
  17.121 -
  17.122 -union _cpuid4_leaf_ecx {
  17.123 -	struct {
  17.124 -		unsigned int		number_of_sets:32;
  17.125 -	} split;
  17.126 -	u32 full;
  17.127 -};
  17.128 -
  17.129 -struct _cpuid4_info {
  17.130 -	union _cpuid4_leaf_eax eax;
  17.131 -	union _cpuid4_leaf_ebx ebx;
  17.132 -	union _cpuid4_leaf_ecx ecx;
  17.133 -	unsigned long size;
  17.134 -	cpumask_t shared_cpu_map;
  17.135 -};
  17.136 -
  17.137 -unsigned short			num_cache_leaves;
  17.138 -
  17.139 -/* AMD doesn't have CPUID4. Emulate it here to report the same
  17.140 -   information to the user.  This makes some assumptions about the machine:
  17.141 -   No L3, L2 not shared, no SMT etc. that is currently true on AMD CPUs.
  17.142 -
  17.143 -   In theory the TLBs could be reported as fake type (they are in "dummy").
  17.144 -   Maybe later */
  17.145 -union l1_cache {
  17.146 -	struct {
  17.147 -		unsigned line_size : 8;
  17.148 -		unsigned lines_per_tag : 8;
  17.149 -		unsigned assoc : 8;
  17.150 -		unsigned size_in_kb : 8;
  17.151 -	};
  17.152 -	unsigned val;
  17.153 -};
  17.154 -
  17.155 -union l2_cache {
  17.156 -	struct {
  17.157 -		unsigned line_size : 8;
  17.158 -		unsigned lines_per_tag : 4;
  17.159 -		unsigned assoc : 4;
  17.160 -		unsigned size_in_kb : 16;
  17.161 -	};
  17.162 -	unsigned val;
  17.163 -};
  17.164 -
  17.165 -static const unsigned short assocs[] = {
  17.166 -	[1] = 1, [2] = 2, [4] = 4, [6] = 8,
  17.167 -	[8] = 16,
  17.168 -	[0xf] = 0xffff // ??
  17.169 -	};
  17.170 -static const unsigned char levels[] = { 1, 1, 2 };
  17.171 -static const unsigned char types[] = { 1, 2, 3 };
  17.172 -
  17.173 -static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
  17.174 -		       union _cpuid4_leaf_ebx *ebx,
  17.175 -		       union _cpuid4_leaf_ecx *ecx)
  17.176 -{
  17.177 -	unsigned dummy;
  17.178 -	unsigned line_size, lines_per_tag, assoc, size_in_kb;
  17.179 -	union l1_cache l1i, l1d;
  17.180 -	union l2_cache l2;
  17.181 -
  17.182 -	eax->full = 0;
  17.183 -	ebx->full = 0;
  17.184 -	ecx->full = 0;
  17.185 -
  17.186 -	cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val);
  17.187 -	cpuid(0x80000006, &dummy, &dummy, &l2.val, &dummy);
  17.188 -
  17.189 -	if (leaf > 2 || !l1d.val || !l1i.val || !l2.val)
  17.190 -		return;
  17.191 -
  17.192 -	eax->split.is_self_initializing = 1;
  17.193 -	eax->split.type = types[leaf];
  17.194 -	eax->split.level = levels[leaf];
  17.195 -	eax->split.num_threads_sharing = 0;
  17.196 -	eax->split.num_cores_on_die = current_cpu_data.x86_max_cores - 1;
  17.197 -
  17.198 -	if (leaf <= 1) {
  17.199 -		union l1_cache *l1 = leaf == 0 ? &l1d : &l1i;
  17.200 -		assoc = l1->assoc;
  17.201 -		line_size = l1->line_size;
  17.202 -		lines_per_tag = l1->lines_per_tag;
  17.203 -		size_in_kb = l1->size_in_kb;
  17.204 -	} else {
  17.205 -		assoc = l2.assoc;
  17.206 -		line_size = l2.line_size;
  17.207 -		lines_per_tag = l2.lines_per_tag;
  17.208 -		/* cpu_data has errata corrections for K7 applied */
  17.209 -		size_in_kb = current_cpu_data.x86_cache_size;
  17.210 -	}
  17.211 -
  17.212 -	if (assoc == 0xf)
  17.213 -		eax->split.is_fully_associative = 1;
  17.214 -	ebx->split.coherency_line_size = line_size - 1;
  17.215 -	ebx->split.ways_of_associativity = assocs[assoc] - 1;
  17.216 -	ebx->split.physical_line_partition = lines_per_tag - 1;
  17.217 -	ecx->split.number_of_sets = (size_in_kb * 1024) / line_size /
  17.218 -		(ebx->split.ways_of_associativity + 1) - 1;
  17.219 -}
  17.220 -
  17.221 -static int __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf)
  17.222 -{
  17.223 -	union _cpuid4_leaf_eax 	eax;
  17.224 -	union _cpuid4_leaf_ebx 	ebx;
  17.225 -	union _cpuid4_leaf_ecx 	ecx;
  17.226 -	unsigned		edx;
  17.227 -
  17.228 -	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
  17.229 -		amd_cpuid4(index, &eax, &ebx, &ecx);
  17.230 -	else
  17.231 -		cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full,  &edx);
  17.232 -	if (eax.split.type == CACHE_TYPE_NULL)
  17.233 -		return -EIO; /* better error ? */
  17.234 -
  17.235 -	this_leaf->eax = eax;
  17.236 -	this_leaf->ebx = ebx;
  17.237 -	this_leaf->ecx = ecx;
  17.238 -	this_leaf->size = (ecx.split.number_of_sets + 1) *
  17.239 -		(ebx.split.coherency_line_size + 1) *
  17.240 -		(ebx.split.physical_line_partition + 1) *
  17.241 -		(ebx.split.ways_of_associativity + 1);
  17.242 -	return 0;
  17.243 -}
  17.244 -
  17.245 -/* will only be called once; __init is safe here */
  17.246 -static int __init find_num_cache_leaves(void)
  17.247 -{
  17.248 -	unsigned int		eax, ebx, ecx, edx;
  17.249 -	union _cpuid4_leaf_eax	cache_eax;
  17.250 -	int 			i = -1;
  17.251 -
  17.252 -	do {
  17.253 -		++i;
  17.254 -		/* Do cpuid(4) loop to find out num_cache_leaves */
  17.255 -		cpuid_count(4, i, &eax, &ebx, &ecx, &edx);
  17.256 -		cache_eax.full = eax;
  17.257 -	} while (cache_eax.split.type != CACHE_TYPE_NULL);
  17.258 -	return i;
  17.259 -}
  17.260 -
  17.261 -unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
  17.262 -{
  17.263 -	unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
  17.264 -	unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
  17.265 -	unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
  17.266 -	unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;
  17.267 -#ifdef CONFIG_X86_HT
  17.268 -	unsigned int cpu = (c == &boot_cpu_data) ? 0 : (c - cpu_data);
  17.269 -#endif
  17.270 -
  17.271 -	if (c->cpuid_level > 3) {
  17.272 -		static int is_initialized;
  17.273 -
  17.274 -		if (is_initialized == 0) {
  17.275 -			/* Init num_cache_leaves from boot CPU */
  17.276 -			num_cache_leaves = find_num_cache_leaves();
  17.277 -			is_initialized++;
  17.278 -		}
  17.279 -
  17.280 -		/*
  17.281 -		 * Whenever possible use cpuid(4), deterministic cache
  17.282 -		 * parameters cpuid leaf to find the cache details
  17.283 -		 */
  17.284 -		for (i = 0; i < num_cache_leaves; i++) {
  17.285 -			struct _cpuid4_info this_leaf;
  17.286 -
  17.287 -			int retval;
  17.288 -
  17.289 -			retval = cpuid4_cache_lookup(i, &this_leaf);
  17.290 -			if (retval >= 0) {
  17.291 -				switch(this_leaf.eax.split.level) {
  17.292 -				    case 1:
  17.293 -					if (this_leaf.eax.split.type ==
  17.294 -							CACHE_TYPE_DATA)
  17.295 -						new_l1d = this_leaf.size/1024;
  17.296 -					else if (this_leaf.eax.split.type ==
  17.297 -							CACHE_TYPE_INST)
  17.298 -						new_l1i = this_leaf.size/1024;
  17.299 -					break;
  17.300 -				    case 2:
  17.301 -					new_l2 = this_leaf.size/1024;
  17.302 -					num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;
  17.303 -					index_msb = get_count_order(num_threads_sharing);
  17.304 -					l2_id = c->apicid >> index_msb;
  17.305 -					break;
  17.306 -				    case 3:
  17.307 -					new_l3 = this_leaf.size/1024;
  17.308 -					num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;
  17.309 -					index_msb = get_count_order(num_threads_sharing);
  17.310 -					l3_id = c->apicid >> index_msb;
  17.311 -					break;
  17.312 -				    default:
  17.313 -					break;
  17.314 -				}
  17.315 -			}
  17.316 -		}
  17.317 -	}
  17.318 -	/*
  17.319 -	 * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
  17.320 -	 * trace cache
  17.321 -	 */
  17.322 -	if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
  17.323 -		/* supports eax=2  call */
  17.324 -		int i, j, n;
  17.325 -		int regs[4];
  17.326 -		unsigned char *dp = (unsigned char *)regs;
  17.327 -		int only_trace = 0;
  17.328 -
  17.329 -		if (num_cache_leaves != 0 && c->x86 == 15)
  17.330 -			only_trace = 1;
  17.331 -
  17.332 -		/* Number of times to iterate */
  17.333 -		n = cpuid_eax(2) & 0xFF;
  17.334 -
  17.335 -		for ( i = 0 ; i < n ; i++ ) {
  17.336 -			cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
  17.337 -
  17.338 -			/* If bit 31 is set, this is an unknown format */
  17.339 -			for ( j = 0 ; j < 3 ; j++ ) {
  17.340 -				if ( regs[j] < 0 ) regs[j] = 0;
  17.341 -			}
  17.342 -
  17.343 -			/* Byte 0 is level count, not a descriptor */
  17.344 -			for ( j = 1 ; j < 16 ; j++ ) {
  17.345 -				unsigned char des = dp[j];
  17.346 -				unsigned char k = 0;
  17.347 -
  17.348 -				/* look up this descriptor in the table */
  17.349 -				while (cache_table[k].descriptor != 0)
  17.350 -				{
  17.351 -					if (cache_table[k].descriptor == des) {
  17.352 -						if (only_trace && cache_table[k].cache_type != LVL_TRACE)
  17.353 -							break;
  17.354 -						switch (cache_table[k].cache_type) {
  17.355 -						case LVL_1_INST:
  17.356 -							l1i += cache_table[k].size;
  17.357 -							break;
  17.358 -						case LVL_1_DATA:
  17.359 -							l1d += cache_table[k].size;
  17.360 -							break;
  17.361 -						case LVL_2:
  17.362 -							l2 += cache_table[k].size;
  17.363 -							break;
  17.364 -						case LVL_3:
  17.365 -							l3 += cache_table[k].size;
  17.366 -							break;
  17.367 -						case LVL_TRACE:
  17.368 -							trace += cache_table[k].size;
  17.369 -							break;
  17.370 -						}
  17.371 -
  17.372 -						break;
  17.373 -					}
  17.374 -
  17.375 -					k++;
  17.376 -				}
  17.377 -			}
  17.378 -		}
  17.379 -	}
  17.380 -
  17.381 -	if (new_l1d)
  17.382 -		l1d = new_l1d;
  17.383 -
  17.384 -	if (new_l1i)
  17.385 -		l1i = new_l1i;
  17.386 -
  17.387 -	if (new_l2) {
  17.388 -		l2 = new_l2;
  17.389 -#ifdef CONFIG_X86_HT
  17.390 -		cpu_llc_id[cpu] = l2_id;
  17.391 -#endif
  17.392 -	}
  17.393 -
  17.394 -	if (new_l3) {
  17.395 -		l3 = new_l3;
  17.396 -#ifdef CONFIG_X86_HT
  17.397 -		cpu_llc_id[cpu] = l3_id;
  17.398 -#endif
  17.399 -	}
  17.400 -
  17.401 -	if (trace)
  17.402 -		printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
  17.403 -	else if ( l1i )
  17.404 -		printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
  17.405 -
  17.406 -	if (l1d)
  17.407 -		printk(", L1 D cache: %dK\n", l1d);
  17.408 -	else
  17.409 -		printk("\n");
  17.410 -
  17.411 -	if (l2)
  17.412 -		printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
  17.413 -
  17.414 -	if (l3)
  17.415 -		printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
  17.416 -
  17.417 -	c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));
  17.418 -
  17.419 -	return l2;
  17.420 -}
  17.421 -
  17.422 -/* pointer to _cpuid4_info array (for each cache leaf) */
  17.423 -static struct _cpuid4_info *cpuid4_info[NR_CPUS];
  17.424 -#define CPUID4_INFO_IDX(x,y)    (&((cpuid4_info[x])[y]))
  17.425 -
  17.426 -#ifdef CONFIG_SMP
  17.427 -static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
  17.428 -{
  17.429 -	struct _cpuid4_info	*this_leaf, *sibling_leaf;
  17.430 -	unsigned long num_threads_sharing;
  17.431 -	int index_msb, i;
  17.432 -	struct cpuinfo_x86 *c = cpu_data;
  17.433 -
  17.434 -	this_leaf = CPUID4_INFO_IDX(cpu, index);
  17.435 -	num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing;
  17.436 -
  17.437 -	if (num_threads_sharing == 1)
  17.438 -		cpu_set(cpu, this_leaf->shared_cpu_map);
  17.439 -	else {
  17.440 -		index_msb = get_count_order(num_threads_sharing);
  17.441 -
  17.442 -		for_each_online_cpu(i) {
  17.443 -			if (c[i].apicid >> index_msb ==
  17.444 -			    c[cpu].apicid >> index_msb) {
  17.445 -				cpu_set(i, this_leaf->shared_cpu_map);
  17.446 -				if (i != cpu && cpuid4_info[i])  {
  17.447 -					sibling_leaf = CPUID4_INFO_IDX(i, index);
  17.448 -					cpu_set(cpu, sibling_leaf->shared_cpu_map);
  17.449 -				}
  17.450 -			}
  17.451 -		}
  17.452 -	}
  17.453 -}
  17.454 -static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
  17.455 -{
  17.456 -	struct _cpuid4_info	*this_leaf, *sibling_leaf;
  17.457 -	int sibling;
  17.458 -
  17.459 -	this_leaf = CPUID4_INFO_IDX(cpu, index);
  17.460 -	for_each_cpu_mask(sibling, this_leaf->shared_cpu_map) {
  17.461 -		sibling_leaf = CPUID4_INFO_IDX(sibling, index);	
  17.462 -		cpu_clear(cpu, sibling_leaf->shared_cpu_map);
  17.463 -	}
  17.464 -}
  17.465 -#else
  17.466 -static void __init cache_shared_cpu_map_setup(unsigned int cpu, int index) {}
  17.467 -static void __init cache_remove_shared_cpu_map(unsigned int cpu, int index) {}
  17.468 -#endif
  17.469 -
  17.470 -static void free_cache_attributes(unsigned int cpu)
  17.471 -{
  17.472 -	kfree(cpuid4_info[cpu]);
  17.473 -	cpuid4_info[cpu] = NULL;
  17.474 -}
  17.475 -
  17.476 -static int __cpuinit detect_cache_attributes(unsigned int cpu)
  17.477 -{
  17.478 -	struct _cpuid4_info	*this_leaf;
  17.479 -	unsigned long 		j;
  17.480 -	int 			retval;
  17.481 -	cpumask_t		oldmask;
  17.482 -
  17.483 -	if (num_cache_leaves == 0)
  17.484 -		return -ENOENT;
  17.485 -
  17.486 -	cpuid4_info[cpu] = kmalloc(
  17.487 -	    sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL);
  17.488 -	if (unlikely(cpuid4_info[cpu] == NULL))
  17.489 -		return -ENOMEM;
  17.490 -	memset(cpuid4_info[cpu], 0,
  17.491 -	    sizeof(struct _cpuid4_info) * num_cache_leaves);
  17.492 -
  17.493 -	oldmask = current->cpus_allowed;
  17.494 -	retval = set_cpus_allowed(current, cpumask_of_cpu(cpu));
  17.495 -	if (retval)
  17.496 -		goto out;
  17.497 -
  17.498 -	/* Do cpuid and store the results */
  17.499 -	retval = 0;
  17.500 -	for (j = 0; j < num_cache_leaves; j++) {
  17.501 -		this_leaf = CPUID4_INFO_IDX(cpu, j);
  17.502 -		retval = cpuid4_cache_lookup(j, this_leaf);
  17.503 -		if (unlikely(retval < 0))
  17.504 -			break;
  17.505 -		cache_shared_cpu_map_setup(cpu, j);
  17.506 -	}
  17.507 -	set_cpus_allowed(current, oldmask);
  17.508 -
  17.509 -out:
  17.510 -	if (retval)
  17.511 -		free_cache_attributes(cpu);
  17.512 -	return retval;
  17.513 -}
  17.514 -
  17.515 -#ifdef CONFIG_SYSFS
  17.516 -
  17.517 -#include <linux/kobject.h>
  17.518 -#include <linux/sysfs.h>
  17.519 -
  17.520 -extern struct sysdev_class cpu_sysdev_class; /* from drivers/base/cpu.c */
  17.521 -
  17.522 -/* pointer to kobject for cpuX/cache */
  17.523 -static struct kobject * cache_kobject[NR_CPUS];
  17.524 -
  17.525 -struct _index_kobject {
  17.526 -	struct kobject kobj;
  17.527 -	unsigned int cpu;
  17.528 -	unsigned short index;
  17.529 -};
  17.530 -
  17.531 -/* pointer to array of kobjects for cpuX/cache/indexY */
  17.532 -static struct _index_kobject *index_kobject[NR_CPUS];
  17.533 -#define INDEX_KOBJECT_PTR(x,y)    (&((index_kobject[x])[y]))
  17.534 -
  17.535 -#define show_one_plus(file_name, object, val)				\
  17.536 -static ssize_t show_##file_name						\
  17.537 -			(struct _cpuid4_info *this_leaf, char *buf)	\
  17.538 -{									\
  17.539 -	return sprintf (buf, "%lu\n", (unsigned long)this_leaf->object + val); \
  17.540 -}
  17.541 -
  17.542 -show_one_plus(level, eax.split.level, 0);
  17.543 -show_one_plus(coherency_line_size, ebx.split.coherency_line_size, 1);
  17.544 -show_one_plus(physical_line_partition, ebx.split.physical_line_partition, 1);
  17.545 -show_one_plus(ways_of_associativity, ebx.split.ways_of_associativity, 1);
  17.546 -show_one_plus(number_of_sets, ecx.split.number_of_sets, 1);
  17.547 -
  17.548 -static ssize_t show_size(struct _cpuid4_info *this_leaf, char *buf)
  17.549 -{
  17.550 -	return sprintf (buf, "%luK\n", this_leaf->size / 1024);
  17.551 -}
  17.552 -
  17.553 -static ssize_t show_shared_cpu_map(struct _cpuid4_info *this_leaf, char *buf)
  17.554 -{
  17.555 -	char mask_str[NR_CPUS];
  17.556 -	cpumask_scnprintf(mask_str, NR_CPUS, this_leaf->shared_cpu_map);
  17.557 -	return sprintf(buf, "%s\n", mask_str);
  17.558 -}
  17.559 -
  17.560 -static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf) {
  17.561 -	switch(this_leaf->eax.split.type) {
  17.562 -	    case CACHE_TYPE_DATA:
  17.563 -		return sprintf(buf, "Data\n");
  17.564 -		break;
  17.565 -	    case CACHE_TYPE_INST:
  17.566 -		return sprintf(buf, "Instruction\n");
  17.567 -		break;
  17.568 -	    case CACHE_TYPE_UNIFIED:
  17.569 -		return sprintf(buf, "Unified\n");
  17.570 -		break;
  17.571 -	    default:
  17.572 -		return sprintf(buf, "Unknown\n");
  17.573 -		break;
  17.574 -	}
  17.575 -}
  17.576 -
  17.577 -struct _cache_attr {
  17.578 -	struct attribute attr;
  17.579 -	ssize_t (*show)(struct _cpuid4_info *, char *);
  17.580 -	ssize_t (*store)(struct _cpuid4_info *, const char *, size_t count);
  17.581 -};
  17.582 -
  17.583 -#define define_one_ro(_name) \
  17.584 -static struct _cache_attr _name = \
  17.585 -	__ATTR(_name, 0444, show_##_name, NULL)
  17.586 -
  17.587 -define_one_ro(level);
  17.588 -define_one_ro(type);
  17.589 -define_one_ro(coherency_line_size);
  17.590 -define_one_ro(physical_line_partition);
  17.591 -define_one_ro(ways_of_associativity);
  17.592 -define_one_ro(number_of_sets);
  17.593 -define_one_ro(size);
  17.594 -define_one_ro(shared_cpu_map);
  17.595 -
  17.596 -static struct attribute * default_attrs[] = {
  17.597 -	&type.attr,
  17.598 -	&level.attr,
  17.599 -	&coherency_line_size.attr,
  17.600 -	&physical_line_partition.attr,
  17.601 -	&ways_of_associativity.attr,
  17.602 -	&number_of_sets.attr,
  17.603 -	&size.attr,
  17.604 -	&shared_cpu_map.attr,
  17.605 -	NULL
  17.606 -};
  17.607 -
  17.608 -#define to_object(k) container_of(k, struct _index_kobject, kobj)
  17.609 -#define to_attr(a) container_of(a, struct _cache_attr, attr)
  17.610 -
  17.611 -static ssize_t show(struct kobject * kobj, struct attribute * attr, char * buf)
  17.612 -{
  17.613 -	struct _cache_attr *fattr = to_attr(attr);
  17.614 -	struct _index_kobject *this_leaf = to_object(kobj);
  17.615 -	ssize_t ret;
  17.616 -
  17.617 -	ret = fattr->show ?
  17.618 -		fattr->show(CPUID4_INFO_IDX(this_leaf->cpu, this_leaf->index),
  17.619 -			buf) :
  17.620 -	       	0;
  17.621 -	return ret;
  17.622 -}
  17.623 -
  17.624 -static ssize_t store(struct kobject * kobj, struct attribute * attr,
  17.625 -		     const char * buf, size_t count)
  17.626 -{
  17.627 -	return 0;
  17.628 -}
  17.629 -
  17.630 -static struct sysfs_ops sysfs_ops = {
  17.631 -	.show   = show,
  17.632 -	.store  = store,
  17.633 -};
  17.634 -
  17.635 -static struct kobj_type ktype_cache = {
  17.636 -	.sysfs_ops	= &sysfs_ops,
  17.637 -	.default_attrs	= default_attrs,
  17.638 -};
  17.639 -
  17.640 -static struct kobj_type ktype_percpu_entry = {
  17.641 -	.sysfs_ops	= &sysfs_ops,
  17.642 -};
  17.643 -
  17.644 -static void cpuid4_cache_sysfs_exit(unsigned int cpu)
  17.645 -{
  17.646 -	kfree(cache_kobject[cpu]);
  17.647 -	kfree(index_kobject[cpu]);
  17.648 -	cache_kobject[cpu] = NULL;
  17.649 -	index_kobject[cpu] = NULL;
  17.650 -	free_cache_attributes(cpu);
  17.651 -}
  17.652 -
  17.653 -static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu)
  17.654 -{
  17.655 -
  17.656 -	if (num_cache_leaves == 0)
  17.657 -		return -ENOENT;
  17.658 -
  17.659 -	detect_cache_attributes(cpu);
  17.660 -	if (cpuid4_info[cpu] == NULL)
  17.661 -		return -ENOENT;
  17.662 -
  17.663 -	/* Allocate all required memory */
  17.664 -	cache_kobject[cpu] = kmalloc(sizeof(struct kobject), GFP_KERNEL);
  17.665 -	if (unlikely(cache_kobject[cpu] == NULL))
  17.666 -		goto err_out;
  17.667 -	memset(cache_kobject[cpu], 0, sizeof(struct kobject));
  17.668 -
  17.669 -	index_kobject[cpu] = kmalloc(
  17.670 -	    sizeof(struct _index_kobject ) * num_cache_leaves, GFP_KERNEL);
  17.671 -	if (unlikely(index_kobject[cpu] == NULL))
  17.672 -		goto err_out;
  17.673 -	memset(index_kobject[cpu], 0,
  17.674 -	    sizeof(struct _index_kobject) * num_cache_leaves);
  17.675 -
  17.676 -	return 0;
  17.677 -
  17.678 -err_out:
  17.679 -	cpuid4_cache_sysfs_exit(cpu);
  17.680 -	return -ENOMEM;
  17.681 -}
  17.682 -
  17.683 -/* Add/Remove cache interface for CPU device */
  17.684 -static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
  17.685 -{
  17.686 -	unsigned int cpu = sys_dev->id;
  17.687 -	unsigned long i, j;
  17.688 -	struct _index_kobject *this_object;
  17.689 -	int retval = 0;
  17.690 -
  17.691 -	retval = cpuid4_cache_sysfs_init(cpu);
  17.692 -	if (unlikely(retval < 0))
  17.693 -		return retval;
  17.694 -
  17.695 -	cache_kobject[cpu]->parent = &sys_dev->kobj;
  17.696 -	kobject_set_name(cache_kobject[cpu], "%s", "cache");
  17.697 -	cache_kobject[cpu]->ktype = &ktype_percpu_entry;
  17.698 -	retval = kobject_register(cache_kobject[cpu]);
  17.699 -
  17.700 -	for (i = 0; i < num_cache_leaves; i++) {
  17.701 -		this_object = INDEX_KOBJECT_PTR(cpu,i);
  17.702 -		this_object->cpu = cpu;
  17.703 -		this_object->index = i;
  17.704 -		this_object->kobj.parent = cache_kobject[cpu];
  17.705 -		kobject_set_name(&(this_object->kobj), "index%1lu", i);
  17.706 -		this_object->kobj.ktype = &ktype_cache;
  17.707 -		retval = kobject_register(&(this_object->kobj));
  17.708 -		if (unlikely(retval)) {
  17.709 -			for (j = 0; j < i; j++) {
  17.710 -				kobject_unregister(
  17.711 -					&(INDEX_KOBJECT_PTR(cpu,j)->kobj));
  17.712 -			}
  17.713 -			kobject_unregister(cache_kobject[cpu]);
  17.714 -			cpuid4_cache_sysfs_exit(cpu);
  17.715 -			break;
  17.716 -		}
  17.717 -	}
  17.718 -	return retval;
  17.719 -}
  17.720 -
  17.721 -static void __cpuexit cache_remove_dev(struct sys_device * sys_dev)
  17.722 -{
  17.723 -	unsigned int cpu = sys_dev->id;
  17.724 -	unsigned long i;
  17.725 -
  17.726 -	for (i = 0; i < num_cache_leaves; i++) {
  17.727 -		cache_remove_shared_cpu_map(cpu, i);
  17.728 -		kobject_unregister(&(INDEX_KOBJECT_PTR(cpu,i)->kobj));
  17.729 -	}
  17.730 -	kobject_unregister(cache_kobject[cpu]);
  17.731 -	cpuid4_cache_sysfs_exit(cpu);
  17.732 -	return;
  17.733 -}
  17.734 -
  17.735 -static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
  17.736 -					unsigned long action, void *hcpu)
  17.737 -{
  17.738 -	unsigned int cpu = (unsigned long)hcpu;
  17.739 -	struct sys_device *sys_dev;
  17.740 -
  17.741 -	sys_dev = get_cpu_sysdev(cpu);
  17.742 -	switch (action) {
  17.743 -	case CPU_ONLINE:
  17.744 -		cache_add_dev(sys_dev);
  17.745 -		break;
  17.746 -	case CPU_DEAD:
  17.747 -		cache_remove_dev(sys_dev);
  17.748 -		break;
  17.749 -	}
  17.750 -	return NOTIFY_OK;
  17.751 -}
  17.752 -
  17.753 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier =
  17.754 -{
  17.755 -    .notifier_call = cacheinfo_cpu_callback,
  17.756 -};
  17.757 -
  17.758 -static int __cpuinit cache_sysfs_init(void)
  17.759 -{
  17.760 -	int i;
  17.761 -
  17.762 -	if (num_cache_leaves == 0)
  17.763 -		return 0;
  17.764 -
  17.765 -	register_hotcpu_notifier(&cacheinfo_cpu_notifier);
  17.766 -
  17.767 -	for_each_online_cpu(i) {
  17.768 -		cacheinfo_cpu_callback(&cacheinfo_cpu_notifier, CPU_ONLINE,
  17.769 -			(void *)(long)i);
  17.770 -	}
  17.771 -
  17.772 -	return 0;
  17.773 -}
  17.774 -
  17.775 -device_initcall(cache_sysfs_init);
  17.776 -
  17.777 -#endif
    18.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S	Thu Mar 01 15:02:09 2007 -0700
    18.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S	Wed Mar 07 12:38:28 2007 -0700
    18.3 @@ -368,6 +368,7 @@ sysexit_scrit:	/**** START OF SYSEXIT CR
    18.4  	movl ESI(%esp), %esi
    18.5  	sysexit
    18.6  14:	__DISABLE_INTERRUPTS
    18.7 +	TRACE_IRQS_OFF
    18.8  sysexit_ecrit:	/**** END OF SYSEXIT CRITICAL REGION ****/
    18.9  	push %esp
   18.10  	call evtchn_do_upcall
   18.11 @@ -427,11 +428,13 @@ restore_nocheck:
   18.12  restore_nocheck:
   18.13  	movl EFLAGS(%esp), %eax
   18.14  	testl $(VM_MASK|NMI_MASK), %eax
   18.15 +	CFI_REMEMBER_STATE
   18.16  	jnz hypervisor_iret
   18.17  	shr $9, %eax			# EAX[0] == IRET_EFLAGS.IF
   18.18  	GET_VCPU_INFO
   18.19  	andb evtchn_upcall_mask(%esi),%al
   18.20  	andb $1,%al			# EAX[0] == IRET_EFLAGS.IF & event_mask
   18.21 +	CFI_REMEMBER_STATE
   18.22  	jnz restore_all_enable_events	#        != 0 => enable event delivery
   18.23  #endif
   18.24  	TRACE_IRQS_IRET
   18.25 @@ -455,8 +458,8 @@ iret_exc:
   18.26  	.long 1b,iret_exc
   18.27  .previous
   18.28  
   18.29 +	CFI_RESTORE_STATE
   18.30  #ifndef CONFIG_XEN
   18.31 -	CFI_RESTORE_STATE
   18.32  ldt_ss:
   18.33  	larl OLDSS(%esp), %eax
   18.34  	jnz restore_nocheck
   18.35 @@ -485,14 +488,36 @@ 1:	iret
   18.36  	.align 4
   18.37  	.long 1b,iret_exc
   18.38  .previous
   18.39 -	CFI_ENDPROC
   18.40  #else
   18.41 +        ALIGN
   18.42 +restore_all_enable_events:
   18.43 +	TRACE_IRQS_ON
   18.44 +	__ENABLE_INTERRUPTS
   18.45 +scrit:	/**** START OF CRITICAL REGION ****/
   18.46 +	__TEST_PENDING
   18.47 +	jnz  14f			# process more events if necessary...
   18.48 +	RESTORE_REGS
   18.49 +	addl $4, %esp
   18.50 +	CFI_ADJUST_CFA_OFFSET -4
   18.51 +1:	iret
   18.52 +.section __ex_table,"a"
   18.53 +	.align 4
   18.54 +	.long 1b,iret_exc
   18.55 +.previous
   18.56 +14:	__DISABLE_INTERRUPTS
   18.57 +	TRACE_IRQS_OFF
   18.58 +	jmp  11f
   18.59 +ecrit:  /**** END OF CRITICAL REGION ****/
   18.60 +
   18.61 +	CFI_RESTORE_STATE
   18.62  hypervisor_iret:
   18.63  	andl $~NMI_MASK, EFLAGS(%esp)
   18.64  	RESTORE_REGS
   18.65  	addl $4, %esp
   18.66 +	CFI_ADJUST_CFA_OFFSET -4
   18.67  	jmp  hypercall_page + (__HYPERVISOR_iret * 32)
   18.68  #endif
   18.69 +	CFI_ENDPROC
   18.70  
   18.71  	# perform work that needs to be done immediately before resumption
   18.72  	ALIGN
   18.73 @@ -736,7 +761,9 @@ error_code:
   18.74  # critical region we know that the entire frame is present and correct
   18.75  # so we can simply throw away the new one.
   18.76  ENTRY(hypervisor_callback)
   18.77 +	RING0_INT_FRAME
   18.78  	pushl %eax
   18.79 +	CFI_ADJUST_CFA_OFFSET 4
   18.80  	SAVE_ALL
   18.81  	movl EIP(%esp),%eax
   18.82  	cmpl $scrit,%eax
   18.83 @@ -749,26 +776,13 @@ ENTRY(hypervisor_callback)
   18.84  	ja   11f
   18.85  	addl $OLDESP,%esp		# Remove eflags...ebx from stack frame.
   18.86  11:	push %esp
   18.87 +	CFI_ADJUST_CFA_OFFSET 4
   18.88  	call evtchn_do_upcall
   18.89  	add  $4,%esp
   18.90 +	CFI_ADJUST_CFA_OFFSET -4
   18.91  	jmp  ret_from_intr
   18.92 +	CFI_ENDPROC
   18.93  
   18.94 -        ALIGN
   18.95 -restore_all_enable_events:
   18.96 -	__ENABLE_INTERRUPTS
   18.97 -scrit:	/**** START OF CRITICAL REGION ****/
   18.98 -	__TEST_PENDING
   18.99 -	jnz  14f			# process more events if necessary...
  18.100 -	RESTORE_REGS
  18.101 -	addl $4, %esp
  18.102 -1:	iret
  18.103 -.section __ex_table,"a"
  18.104 -	.align 4
  18.105 -	.long 1b,iret_exc
  18.106 -.previous
  18.107 -14:	__DISABLE_INTERRUPTS
  18.108 -	jmp  11b
  18.109 -ecrit:  /**** END OF CRITICAL REGION ****/
  18.110  # [How we do the fixup]. We want to merge the current stack frame with the
  18.111  # just-interrupted frame. How we do this depends on where in the critical
  18.112  # region the interrupted handler was executing, and so how many saved
  18.113 @@ -835,6 +849,7 @@ 4:	mov 16(%esp),%gs
  18.114  	addl $16,%esp		# EAX != 0 => Category 2 (Bad IRET)
  18.115  	jmp iret_exc
  18.116  5:	addl $16,%esp		# EAX == 0 => Category 1 (Bad segment)
  18.117 +	RING0_INT_FRAME
  18.118  	pushl $0
  18.119  	SAVE_ALL
  18.120  	jmp ret_from_exception
  18.121 @@ -860,6 +875,7 @@ 9:	xorl %eax,%eax;		\
  18.122  	.long 4b,9b;		\
  18.123  .previous
  18.124  #endif
  18.125 +	CFI_ENDPROC
  18.126  
  18.127  ENTRY(coprocessor_error)
  18.128  	RING0_INT_FRAME
  18.129 @@ -1187,8 +1203,11 @@ ENDPROC(arch_unwind_init_running)
  18.130  #endif
  18.131  
  18.132  ENTRY(fixup_4gb_segment)
  18.133 +	RING0_EC_FRAME
  18.134  	pushl $do_fixup_4gb_segment
  18.135 +	CFI_ADJUST_CFA_OFFSET 4
  18.136  	jmp error_code
  18.137 +	CFI_ENDPROC
  18.138  
  18.139  .section .rodata,"a"
  18.140  .align 4
    19.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/fixup.c	Thu Mar 01 15:02:09 2007 -0700
    19.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/fixup.c	Wed Mar 07 12:38:28 2007 -0700
    19.3 @@ -27,7 +27,6 @@
    19.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    19.5   */
    19.6  
    19.7 -#include <linux/config.h>
    19.8  #include <linux/init.h>
    19.9  #include <linux/sched.h>
   19.10  #include <linux/slab.h>
    20.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S	Thu Mar 01 15:02:09 2007 -0700
    20.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S	Wed Mar 07 12:38:28 2007 -0700
    20.3 @@ -9,11 +9,10 @@
    20.4  #include <asm/cache.h>
    20.5  #include <asm/thread_info.h>
    20.6  #include <asm/asm-offsets.h>
    20.7 +#include <asm/dwarf2.h>
    20.8  #include <xen/interface/xen.h>
    20.9  #include <xen/interface/elfnote.h>
   20.10  
   20.11 -#define _PAGE_PRESENT 0x1
   20.12 -
   20.13  /*
   20.14   * References to members of the new_cpu_data structure.
   20.15   */
   20.16 @@ -65,14 +64,13 @@ ENTRY(startup_32)
   20.17  
   20.18  	pushl %eax		# fake return address
   20.19  	jmp start_kernel
   20.20 -L6:
   20.21 -	jmp L6			# main should never return here, but
   20.22 -				# just in case, we know what happens.
   20.23  
   20.24  #define HYPERCALL_PAGE_OFFSET 0x1000
   20.25  .org HYPERCALL_PAGE_OFFSET
   20.26  ENTRY(hypercall_page)
   20.27 +	CFI_STARTPROC
   20.28  .skip 0x1000
   20.29 +	CFI_ENDPROC
   20.30  
   20.31  /*
   20.32   * Real beginning of normal "text" segment
   20.33 @@ -206,3 +204,4 @@ ENTRY(cpu_gdt_table)
   20.34  	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .long,  _PAGE_PRESENT,_PAGE_PRESENT)
   20.35  #endif
   20.36  	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz, "generic")
   20.37 +	ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long,  1)
    21.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Thu Mar 01 15:02:09 2007 -0700
    21.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Wed Mar 07 12:38:28 2007 -0700
    21.3 @@ -60,9 +60,6 @@
    21.4  #include <asm/tlbflush.h>
    21.5  #include <asm/cpu.h>
    21.6  
    21.7 -#include <asm/tlbflush.h>
    21.8 -#include <asm/cpu.h>
    21.9 -
   21.10  asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
   21.11  
   21.12  static int hlt_counter;
   21.13 @@ -104,7 +101,7 @@ EXPORT_SYMBOL(enable_hlt);
   21.14   * to poll the ->work.need_resched flag instead of waiting for the
   21.15   * cross-CPU IPI to arrive. Use this option with caution.
   21.16   */
   21.17 -static void poll_idle(void)
   21.18 +static void poll_idle (void)
   21.19  {
   21.20  	local_irq_enable();
   21.21  
   21.22 @@ -172,10 +169,7 @@ void cpu_idle(void)
   21.23  				__get_cpu_var(cpu_idle_state) = 0;
   21.24  
   21.25  			rmb();
   21.26 -			idle = pm_idle;
   21.27 -
   21.28 -			if (!idle)
   21.29 -				idle = xen_idle;
   21.30 +			idle = xen_idle; /* no alternatives */
   21.31  
   21.32  			if (cpu_is_offline(cpu))
   21.33  				play_dead();
    22.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Thu Mar 01 15:02:09 2007 -0700
    22.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Wed Mar 07 12:38:28 2007 -0700
    22.3 @@ -1847,6 +1847,9 @@ static __init int add_pcspkr(void)
    22.4  	struct platform_device *pd;
    22.5  	int ret;
    22.6  
    22.7 +	if (!is_initial_xendomain())
    22.8 +		return 0;
    22.9 +
   22.10  	pd = platform_device_alloc("pcspkr", -1);
   22.11  	if (!pd)
   22.12  		return -ENOMEM;
    23.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Thu Mar 01 15:02:09 2007 -0700
    23.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Wed Mar 07 12:38:28 2007 -0700
    23.3 @@ -1022,16 +1022,21 @@ void halt(void)
    23.4  }
    23.5  EXPORT_SYMBOL(halt);
    23.6  
    23.7 -/* No locking required. We are only CPU running, and interrupts are off. */
    23.8 +/* No locking required. Interrupts are disabled on all CPUs. */
    23.9  void time_resume(void)
   23.10  {
   23.11 +	unsigned int cpu;
   23.12 +
   23.13  	init_cpu_khz();
   23.14  
   23.15 -	get_time_values_from_xen(0);
   23.16 +	for_each_online_cpu(cpu) {
   23.17 +		get_time_values_from_xen(cpu);
   23.18 +		per_cpu(processed_system_time, cpu) =
   23.19 +			per_cpu(shadow_time, 0).system_timestamp;
   23.20 +		init_missing_ticks_accounting(cpu);
   23.21 +	}
   23.22  
   23.23  	processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
   23.24 -	per_cpu(processed_system_time, 0) = processed_system_time;
   23.25 -	init_missing_ticks_accounting(0);
   23.26  
   23.27  	update_wallclock();
   23.28  }
    24.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Thu Mar 01 15:02:09 2007 -0700
    24.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c	Wed Mar 07 12:38:28 2007 -0700
    24.3 @@ -30,7 +30,6 @@
    24.4   * IN THE SOFTWARE.
    24.5   */
    24.6  
    24.7 -#include <linux/config.h>
    24.8  #include <linux/sched.h>
    24.9  #include <linux/mm.h>
   24.10  #include <linux/vmalloc.h>
    25.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Thu Mar 01 15:02:09 2007 -0700
    25.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c	Wed Mar 07 12:38:28 2007 -0700
    25.3 @@ -374,8 +374,6 @@ void iounmap(volatile void __iomem *addr
    25.4  }
    25.5  EXPORT_SYMBOL(iounmap);
    25.6  
    25.7 -#ifdef __i386__
    25.8 -
    25.9  void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
   25.10  {
   25.11  	unsigned long offset, last_addr;
   25.12 @@ -443,5 +441,3 @@ void __init bt_iounmap(void *addr, unsig
   25.13  		--nrpages;
   25.14  	}
   25.15  }
   25.16 -
   25.17 -#endif /* __i386__ */
    26.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Thu Mar 01 15:02:09 2007 -0700
    26.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/pgtable-xen.c	Wed Mar 07 12:38:28 2007 -0700
    26.3 @@ -573,64 +573,67 @@ void make_pages_writable(void *va, unsig
    26.4  	}
    26.5  }
    26.6  
    26.7 -static inline int pgd_walk_set_prot(struct page *page, pgprot_t flags)
    26.8 +static inline void pgd_walk_set_prot(struct page *page, pgprot_t flags)
    26.9  {
   26.10  	unsigned long pfn = page_to_pfn(page);
   26.11 -
   26.12 -	if (PageHighMem(page))
   26.13 -		return pgprot_val(flags) & _PAGE_RW
   26.14 -		       ? test_and_clear_bit(PG_pinned, &page->flags)
   26.15 -		       : !test_and_set_bit(PG_pinned, &page->flags);
   26.16 +	int rc;
   26.17  
   26.18 -	BUG_ON(HYPERVISOR_update_va_mapping(
   26.19 -		(unsigned long)__va(pfn << PAGE_SHIFT),
   26.20 -		pfn_pte(pfn, flags), 0));
   26.21 -
   26.22 -	return 0;
   26.23 +	if (PageHighMem(page)) {
   26.24 +		if (pgprot_val(flags) & _PAGE_RW)
   26.25 +			clear_bit(PG_pinned, &page->flags);
   26.26 +		else
   26.27 +			set_bit(PG_pinned, &page->flags);
   26.28 +	} else {
   26.29 +		rc = HYPERVISOR_update_va_mapping(
   26.30 +			(unsigned long)__va(pfn << PAGE_SHIFT),
   26.31 +			pfn_pte(pfn, flags), 0);
   26.32 +		if (rc)
   26.33 +			BUG();
   26.34 +	}
   26.35  }
   26.36  
   26.37 -static int pgd_walk(pgd_t *pgd_base, pgprot_t flags)
   26.38 +static void pgd_walk(pgd_t *pgd_base, pgprot_t flags)
   26.39  {
   26.40  	pgd_t *pgd = pgd_base;
   26.41  	pud_t *pud;
   26.42  	pmd_t *pmd;
   26.43 -	int    g, u, m, flush;
   26.44 +	int    g, u, m, rc;
   26.45  
   26.46  	if (xen_feature(XENFEAT_auto_translated_physmap))
   26.47  		return 0;
   26.48  
   26.49 -	for (g = 0, flush = 0; g < USER_PTRS_PER_PGD; g++, pgd++) {
   26.50 +	for (g = 0; g < USER_PTRS_PER_PGD; g++, pgd++) {
   26.51  		if (pgd_none(*pgd))
   26.52  			continue;
   26.53  		pud = pud_offset(pgd, 0);
   26.54  		if (PTRS_PER_PUD > 1) /* not folded */
   26.55 -			flush |= pgd_walk_set_prot(virt_to_page(pud),flags);
   26.56 +			pgd_walk_set_prot(virt_to_page(pud),flags);
   26.57  		for (u = 0; u < PTRS_PER_PUD; u++, pud++) {
   26.58  			if (pud_none(*pud))
   26.59  				continue;
   26.60  			pmd = pmd_offset(pud, 0);
   26.61  			if (PTRS_PER_PMD > 1) /* not folded */
   26.62 -				flush |= pgd_walk_set_prot(virt_to_page(pmd),flags);
   26.63 +				pgd_walk_set_prot(virt_to_page(pmd),flags);
   26.64  			for (m = 0; m < PTRS_PER_PMD; m++, pmd++) {
   26.65  				if (pmd_none(*pmd))
   26.66  					continue;
   26.67 -				flush |= pgd_walk_set_prot(pmd_page(*pmd),flags);
   26.68 +				pgd_walk_set_prot(pmd_page(*pmd),flags);
   26.69  			}
   26.70  		}
   26.71  	}
   26.72  
   26.73 -	BUG_ON(HYPERVISOR_update_va_mapping(
   26.74 +	rc = HYPERVISOR_update_va_mapping(
   26.75  		(unsigned long)pgd_base,
   26.76  		pfn_pte(virt_to_phys(pgd_base)>>PAGE_SHIFT, flags),
   26.77 -		UVMF_TLB_FLUSH));
   26.78 -
   26.79 -	return flush;
   26.80 +		UVMF_TLB_FLUSH);
   26.81 +	if (rc)
   26.82 +		BUG();
   26.83  }
   26.84  
   26.85  static void __pgd_pin(pgd_t *pgd)
   26.86  {
   26.87 -	if (pgd_walk(pgd, PAGE_KERNEL_RO))
   26.88 -		kmap_flush_unused();
   26.89 +	pgd_walk(pgd, PAGE_KERNEL_RO);
   26.90 +	kmap_flush_unused();
   26.91  	xen_pgd_pin(__pa(pgd));
   26.92  	set_bit(PG_pinned, &virt_to_page(pgd)->flags);
   26.93  }
   26.94 @@ -638,8 +641,7 @@ static void __pgd_pin(pgd_t *pgd)
   26.95  static void __pgd_unpin(pgd_t *pgd)
   26.96  {
   26.97  	xen_pgd_unpin(__pa(pgd));
   26.98 -	if (pgd_walk(pgd, PAGE_KERNEL))
   26.99 -		kmap_flush_unused();
  26.100 +	pgd_walk(pgd, PAGE_KERNEL);
  26.101  	clear_bit(PG_pinned, &virt_to_page(pgd)->flags);
  26.102  }
  26.103  
  26.104 @@ -671,9 +673,6 @@ void mm_pin_all(void)
  26.105  {
  26.106  	struct page *page;
  26.107  
  26.108 -	/* Only pgds on the pgd_list please: none hidden in the slab cache. */
  26.109 -	kmem_cache_shrink(pgd_cache);
  26.110 -
  26.111  	if (xen_feature(XENFEAT_writable_page_tables))
  26.112  		return;
  26.113  
    27.1 --- a/linux-2.6-xen-sparse/arch/ia64/oprofile/oprofile_perfmon.h	Thu Mar 01 15:02:09 2007 -0700
    27.2 +++ b/linux-2.6-xen-sparse/arch/ia64/oprofile/oprofile_perfmon.h	Wed Mar 07 12:38:28 2007 -0700
    27.3 @@ -1,8 +1,6 @@
    27.4  #ifndef OPROFILE_PERFMON_H
    27.5  #define OPROFILE_PERFMON_H
    27.6  
    27.7 -#include <linux/config.h>
    27.8 -
    27.9  #ifdef CONFIG_PERFMON
   27.10  int __perfmon_init(void);
   27.11  void __perfmon_exit(void);
    28.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S	Thu Mar 01 15:02:09 2007 -0700
    28.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S	Wed Mar 07 12:38:28 2007 -0700
    28.3 @@ -4,7 +4,6 @@
    28.4   * Copyright (C) 2005 Dan Magenheimer <dan.magenheimer@hp.com>
    28.5   */
    28.6  
    28.7 -#include <linux/config.h>
    28.8  #include <asm/processor.h>
    28.9  #include <asm/asmmacro.h>
   28.10  
    29.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/mem.c	Thu Mar 01 15:02:09 2007 -0700
    29.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/mem.c	Wed Mar 07 12:38:28 2007 -0700
    29.3 @@ -15,7 +15,6 @@
    29.4   *                    VA Linux Systems Japan K.K.
    29.5   */
    29.6  
    29.7 -#include <linux/config.h>
    29.8  #include <linux/mm.h>
    29.9  #include <linux/efi.h>
   29.10  
    30.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Thu Mar 01 15:02:09 2007 -0700
    30.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/util.c	Wed Mar 07 12:38:28 2007 -0700
    30.3 @@ -21,7 +21,6 @@
    30.4   *
    30.5   */
    30.6  
    30.7 -#include <linux/config.h>
    30.8  #include <linux/mm.h>
    30.9  #include <linux/module.h>
   30.10  #include <linux/slab.h>
    31.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xcom_privcmd.c	Thu Mar 01 15:02:09 2007 -0700
    31.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xcom_privcmd.c	Wed Mar 07 12:38:28 2007 -0700
    31.3 @@ -303,6 +303,7 @@ xencomm_privcmd_domctl(privcmd_hypercall
    31.4  	case XEN_DOMCTL_hypercall_init:
    31.5  	case XEN_DOMCTL_arch_setup:
    31.6  	case XEN_DOMCTL_settimeoffset:
    31.7 +	case XEN_DOMCTL_sendtrigger:
    31.8  		break;
    31.9  	default:
   31.10  		printk("%s: unknown domctl cmd %d\n", __func__, kern_op.cmd);
    32.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S	Thu Mar 01 15:02:09 2007 -0700
    32.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S	Wed Mar 07 12:38:28 2007 -0700
    32.3 @@ -8,8 +8,6 @@
    32.4   *	Dan Magenheimer <dan.magenheimer@.hp.com>
    32.5   */
    32.6  
    32.7 -#include <linux/config.h>
    32.8 -
    32.9  #include <asm/asmmacro.h>
   32.10  #include <asm/cache.h>
   32.11  #include <asm/errno.h>
    33.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S	Thu Mar 01 15:02:09 2007 -0700
    33.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S	Wed Mar 07 12:38:28 2007 -0700
    33.3 @@ -29,8 +29,6 @@
    33.4   * Table is based upon EAS2.6 (Oct 1999)
    33.5   */
    33.6  
    33.7 -#include <linux/config.h>
    33.8 -
    33.9  #include <asm/asmmacro.h>
   33.10  #include <asm/break.h>
   33.11  #include <asm/ia32.h>
    34.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xenminstate.h	Thu Mar 01 15:02:09 2007 -0700
    34.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xenminstate.h	Wed Mar 07 12:38:28 2007 -0700
    34.3 @@ -1,5 +1,3 @@
    34.4 -#include <linux/config.h>
    34.5 -
    34.6  #include <asm/cache.h>
    34.7  
    34.8  #ifdef CONFIG_XEN
    35.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Thu Mar 01 15:02:09 2007 -0700
    35.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Wed Mar 07 12:38:28 2007 -0700
    35.3 @@ -4,7 +4,6 @@
    35.4   * Copyright (C) 2005 Dan Magenheimer <dan.magenheimer@hp.com>
    35.5   */
    35.6  
    35.7 -#include <linux/config.h>
    35.8  #include <asm/processor.h>
    35.9  #include <asm/asmmacro.h>
   35.10  
    36.1 --- a/linux-2.6-xen-sparse/arch/x86_64/Kconfig	Thu Mar 01 15:02:09 2007 -0700
    36.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/Kconfig	Wed Mar 07 12:38:28 2007 -0700
    36.3 @@ -450,7 +450,7 @@ config CALGARY_IOMMU
    36.4  	bool "IBM Calgary IOMMU support"
    36.5  	default y
    36.6  	select SWIOTLB
    36.7 -	depends on PCI && EXPERIMENTAL
    36.8 +	depends on PCI && !X86_64_XEN && EXPERIMENTAL
    36.9  	help
   36.10  	  Support for hardware IOMMUs in IBM's xSeries x366 and x460
   36.11  	  systems. Needed to run systems with more than 3GB of memory
    37.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Thu Mar 01 15:02:09 2007 -0700
    37.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Wed Mar 07 12:38:28 2007 -0700
    37.3 @@ -61,9 +61,7 @@ ifdef CONFIG_XEN
    37.4  time-y				+= ../../i386/kernel/time-xen.o
    37.5  pci-dma-y			+= ../../i386/kernel/pci-dma-xen.o
    37.6  microcode-$(subst m,y,$(CONFIG_MICROCODE))  := ../../i386/kernel/microcode-xen.o
    37.7 -intel_cacheinfo-y		:= ../../i386/kernel/cpu/intel_cacheinfo-xen.o
    37.8  quirks-y			:= ../../i386/kernel/quirks-xen.o
    37.9 -alternative-y			:= ../../i386/kernel/alternative-xen.o
   37.10  
   37.11  n-obj-xen := i8259.o reboot.o i8237.o smpboot.o trampoline.o
   37.12  
    38.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/early_printk-xen.c	Thu Mar 01 15:02:09 2007 -0700
    38.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/early_printk-xen.c	Wed Mar 07 12:38:28 2007 -0700
    38.3 @@ -1,4 +1,3 @@
    38.4 -#include <linux/config.h>
    38.5  #include <linux/console.h>
    38.6  #include <linux/kernel.h>
    38.7  #include <linux/init.h>
    39.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Thu Mar 01 15:02:09 2007 -0700
    39.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Wed Mar 07 12:38:28 2007 -0700
    39.3 @@ -116,19 +116,21 @@ NMI_MASK = 0x80000000
    39.4  	CFI_ADJUST_CFA_OFFSET	-(6*8)
    39.5  	.endm
    39.6  
    39.7 -	.macro	CFI_DEFAULT_STACK start=1
    39.8 +	.macro	CFI_DEFAULT_STACK start=1,adj=0
    39.9  	.if \start
   39.10  	CFI_STARTPROC	simple
   39.11 -	CFI_DEF_CFA	rsp,SS+8
   39.12 +	CFI_DEF_CFA	rsp,SS+8-(\adj*ARGOFFSET)
   39.13  	.else
   39.14 -	CFI_DEF_CFA_OFFSET SS+8
   39.15 +	CFI_DEF_CFA_OFFSET SS+8-(\adj*ARGOFFSET)
   39.16  	.endif
   39.17 +	.if \adj == 0
   39.18  	CFI_REL_OFFSET	r15,R15
   39.19  	CFI_REL_OFFSET	r14,R14
   39.20  	CFI_REL_OFFSET	r13,R13
   39.21  	CFI_REL_OFFSET	r12,R12
   39.22  	CFI_REL_OFFSET	rbp,RBP
   39.23  	CFI_REL_OFFSET	rbx,RBX
   39.24 +	.endif
   39.25  	CFI_REL_OFFSET	r11,R11
   39.26  	CFI_REL_OFFSET	r10,R10
   39.27  	CFI_REL_OFFSET	r9,R9
   39.28 @@ -363,8 +365,8 @@ ENTRY(int_ret_from_sys_call)
   39.29  	CFI_REL_OFFSET	r9,R9-ARGOFFSET
   39.30  	CFI_REL_OFFSET	r10,R10-ARGOFFSET
   39.31  	CFI_REL_OFFSET	r11,R11-ARGOFFSET
   39.32 +        XEN_BLOCK_EVENTS(%rsi)
   39.33  	TRACE_IRQS_OFF
   39.34 -        XEN_BLOCK_EVENTS(%rsi)
   39.35  	testb $3,CS-ARGOFFSET(%rsp)
   39.36          jnz 1f
   39.37          /* Need to set the proper %ss (not NULL) for ring 3 iretq */
   39.38 @@ -534,7 +536,7 @@ END(stub_rt_sigreturn)
   39.39   */ 
   39.40  
   39.41  retint_check:
   39.42 -	CFI_DEFAULT_STACK
   39.43 +	CFI_DEFAULT_STACK adj=1
   39.44  	movl threadinfo_flags(%rcx),%edx
   39.45  	andl %edi,%edx
   39.46  	CFI_REMEMBER_STATE
   39.47 @@ -838,6 +840,7 @@ ENTRY(error_entry)
   39.48  	CFI_REL_OFFSET	r15,R15
   39.49  #if 0        
   39.50  	cmpl $__KERNEL_CS,CS(%rsp)
   39.51 +	CFI_REMEMBER_STATE
   39.52  	je  error_kernelspace
   39.53  #endif        
   39.54  error_call_handler:
   39.55 @@ -864,7 +867,7 @@ error_exit:
   39.56  	TRACE_IRQS_IRETQ
   39.57  	jmp   retint_restore_args
   39.58  
   39.59 -error_kernelspace:
   39.60 +#if 0
   39.61           /*
   39.62           * We need to re-write the logic here because we don't do iretq to 
   39.63           * to return to user mode. It's still possible that we get trap/fault
   39.64 @@ -872,7 +875,8 @@ error_kernelspace:
   39.65           * for example).
   39.66           *
   39.67           */           
   39.68 -#if 0
   39.69 +	CFI_RESTORE_STATE
   39.70 +error_kernelspace:
   39.71  	incl %ebx
   39.72         /* There are two places in the kernel that can potentially fault with
   39.73            usergs. Handle them here. The exception handlers after
   39.74 @@ -888,11 +892,13 @@ error_kernelspace:
   39.75  	cmpq $gs_change,RIP(%rsp)
   39.76          je   error_swapgs
   39.77  	jmp  error_sti
   39.78 -#endif        
   39.79 +#endif
   39.80 +	CFI_ENDPROC
   39.81  END(error_entry)
   39.82  	
   39.83  ENTRY(hypervisor_callback)
   39.84  	zeroentry do_hypervisor_callback
   39.85 +END(hypervisor_callback)
   39.86          
   39.87  /*
   39.88   * Copied from arch/xen/i386/kernel/entry.S
   39.89 @@ -909,48 +915,66 @@ ENTRY(hypervisor_callback)
   39.90  # existing activation in its critical region -- if so, we pop the current
   39.91  # activation and restart the handler using the previous one.
   39.92  ENTRY(do_hypervisor_callback)   # do_hypervisor_callback(struct *pt_regs)
   39.93 +	CFI_STARTPROC
   39.94  # Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
   39.95  # see the correct pointer to the pt_regs
   39.96  	movq %rdi, %rsp            # we don't return, adjust the stack frame
   39.97 -11:	movq %gs:pda_irqstackptr,%rax
   39.98 -	incl %gs:pda_irqcount
   39.99 -	cmovzq %rax,%rsp
  39.100 -	pushq %rdi
  39.101 +	CFI_ENDPROC
  39.102 +	CFI_DEFAULT_STACK
  39.103 +11:	incl %gs:pda_irqcount
  39.104 +	movq %rsp,%rbp
  39.105 +	CFI_DEF_CFA_REGISTER rbp
  39.106 +	cmovzq %gs:pda_irqstackptr,%rsp
  39.107 +	pushq %rbp			# backlink for old unwinder
  39.108  	call evtchn_do_upcall
  39.109  	popq %rsp
  39.110 +	CFI_DEF_CFA_REGISTER rsp
  39.111  	decl %gs:pda_irqcount
  39.112  	jmp  error_exit
  39.113 +	CFI_ENDPROC
  39.114 +END(do_hypervisor_callback)
  39.115  
  39.116  #ifdef CONFIG_X86_LOCAL_APIC
  39.117  KPROBE_ENTRY(nmi)
  39.118  	zeroentry do_nmi_callback
  39.119  ENTRY(do_nmi_callback)
  39.120 +	CFI_STARTPROC
  39.121          addq $8, %rsp
  39.122 +	CFI_ENDPROC
  39.123 +	CFI_DEFAULT_STACK
  39.124          call do_nmi
  39.125          orl  $NMI_MASK,EFLAGS(%rsp)
  39.126          RESTORE_REST
  39.127          XEN_BLOCK_EVENTS(%rsi)
  39.128 +	TRACE_IRQS_OFF
  39.129          GET_THREAD_INFO(%rcx)
  39.130          jmp  retint_restore_args
  39.131 +	CFI_ENDPROC
  39.132  	.previous .text
  39.133 +END(nmi)
  39.134  #endif
  39.135  
  39.136          ALIGN
  39.137  restore_all_enable_events:  
  39.138 +	CFI_DEFAULT_STACK adj=1
  39.139 +	TRACE_IRQS_ON
  39.140  	XEN_UNBLOCK_EVENTS(%rsi)        # %rsi is already set up...
  39.141  
  39.142  scrit:	/**** START OF CRITICAL REGION ****/
  39.143  	XEN_TEST_PENDING(%rsi)
  39.144 +	CFI_REMEMBER_STATE
  39.145  	jnz  14f			# process more events if necessary...
  39.146  	XEN_PUT_VCPU_INFO(%rsi)
  39.147          RESTORE_ARGS 0,8,0
  39.148          HYPERVISOR_IRET 0
  39.149          
  39.150 +	CFI_RESTORE_STATE
  39.151  14:	XEN_LOCKED_BLOCK_EVENTS(%rsi)
  39.152  	XEN_PUT_VCPU_INFO(%rsi)
  39.153  	SAVE_REST
  39.154          movq %rsp,%rdi                  # set the argument again
  39.155  	jmp  11b
  39.156 +	CFI_ENDPROC
  39.157  ecrit:  /**** END OF CRITICAL REGION ****/
  39.158  # At this point, unlike on x86-32, we don't do the fixup to simplify the 
  39.159  # code and the stack frame is more complex on x86-64.
  39.160 @@ -970,8 +994,12 @@ ecrit:  /**** END OF CRITICAL REGION ***
  39.161  # We distinguish between categories by comparing each saved segment register
  39.162  # with its current contents: any discrepancy means we in category 1.
  39.163  ENTRY(failsafe_callback)
  39.164 +	_frame (RIP-0x30)
  39.165 +	CFI_REL_OFFSET rcx, 0
  39.166 +	CFI_REL_OFFSET r11, 8
  39.167  	movw %ds,%cx
  39.168  	cmpw %cx,0x10(%rsp)
  39.169 +	CFI_REMEMBER_STATE
  39.170  	jne 1f
  39.171  	movw %es,%cx
  39.172  	cmpw %cx,0x18(%rsp)
  39.173 @@ -984,17 +1012,26 @@ ENTRY(failsafe_callback)
  39.174  	jne 1f
  39.175  	/* All segments match their saved values => Category 2 (Bad IRET). */
  39.176  	movq (%rsp),%rcx
  39.177 +	CFI_RESTORE rcx
  39.178  	movq 8(%rsp),%r11
  39.179 +	CFI_RESTORE r11
  39.180  	addq $0x30,%rsp
  39.181 +	CFI_ADJUST_CFA_OFFSET -0x30
  39.182  	movq $11,%rdi	/* SIGSEGV */
  39.183  	jmp do_exit			
  39.184 +	CFI_RESTORE_STATE
  39.185  1:	/* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */
  39.186  	movq (%rsp),%rcx
  39.187 +	CFI_RESTORE rcx
  39.188  	movq 8(%rsp),%r11
  39.189 +	CFI_RESTORE r11
  39.190  	addq $0x30,%rsp
  39.191 +	CFI_ADJUST_CFA_OFFSET -0x30
  39.192  	pushq $0
  39.193 +	CFI_ADJUST_CFA_OFFSET 8
  39.194  	SAVE_ALL
  39.195  	jmp error_exit
  39.196 +	CFI_ENDPROC
  39.197  #if 0	      
  39.198          .section __ex_table,"a"
  39.199          .align 8
  39.200 @@ -1117,12 +1154,12 @@ END(device_not_available)
  39.201  
  39.202  	/* runs on exception stack */
  39.203  KPROBE_ENTRY(debug)
  39.204 - 	INTR_FRAME
  39.205 -/*	pushq $0
  39.206 +/* 	INTR_FRAME
  39.207 +	pushq $0
  39.208  	CFI_ADJUST_CFA_OFFSET 8	*/
  39.209  	zeroentry do_debug
  39.210 -/*	paranoid_exit */
  39.211 -	CFI_ENDPROC
  39.212 +/*	paranoidexit
  39.213 +	CFI_ENDPROC */
  39.214  END(debug)
  39.215  	.previous .text
  39.216  
  39.217 @@ -1144,12 +1181,12 @@ END(nmi)
  39.218  #endif        
  39.219  
  39.220  KPROBE_ENTRY(int3)
  39.221 - 	INTR_FRAME
  39.222 -/* 	pushq $0
  39.223 +/* 	INTR_FRAME
  39.224 + 	pushq $0
  39.225   	CFI_ADJUST_CFA_OFFSET 8 */
  39.226   	zeroentry do_int3
  39.227 -/* 	jmp paranoid_exit1 */
  39.228 - 	CFI_ENDPROC
  39.229 +/* 	jmp paranoid_exit1
  39.230 + 	CFI_ENDPROC */
  39.231  END(int3)
  39.232  	.previous .text
  39.233  
  39.234 @@ -1193,9 +1230,11 @@ END(segment_not_present)
  39.235  
  39.236  	/* runs on exception stack */
  39.237  ENTRY(stack_segment)
  39.238 -	XCPT_FRAME
  39.239 +/*	XCPT_FRAME
  39.240 +	paranoidentry do_stack_segment */
  39.241  	errorentry do_stack_segment
  39.242 -	CFI_ENDPROC
  39.243 +/*	jmp paranoid_exit1
  39.244 +	CFI_ENDPROC */
  39.245  END(stack_segment)
  39.246  
  39.247  KPROBE_ENTRY(general_protection)
    40.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/genapic_xen.c	Thu Mar 01 15:02:09 2007 -0700
    40.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/genapic_xen.c	Wed Mar 07 12:38:28 2007 -0700
    40.3 @@ -10,7 +10,6 @@
    40.4   *
    40.5   * Hacked to pieces for Xen by Chris Wright.
    40.6   */
    40.7 -#include <linux/config.h>
    40.8  #include <linux/threads.h>
    40.9  #include <linux/cpumask.h>
   40.10  #include <linux/string.h>
    41.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Thu Mar 01 15:02:09 2007 -0700
    41.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Wed Mar 07 12:38:28 2007 -0700
    41.3 @@ -22,11 +22,9 @@
    41.4  #include <asm/page.h>
    41.5  #include <asm/msr.h>
    41.6  #include <asm/cache.h>
    41.7 -
    41.8 +#include <asm/dwarf2.h>
    41.9  #include <xen/interface/elfnote.h>
   41.10  
   41.11 -#define _PAGE_PRESENT 0x1
   41.12 -
   41.13  	.section .bootstrap.text, "ax", @progbits
   41.14  	.code64
   41.15  #define VIRT_ENTRY_OFFSET 0x0
   41.16 @@ -42,6 +40,7 @@ ENTRY(_start)
   41.17  	/* rsi is pointer to startup info structure.
   41.18  	   pass it to C */
   41.19  	movq %rsi,%rdi
   41.20 +	pushq $0		# fake return address
   41.21  	jmp x86_64_start_kernel
   41.22  
   41.23  ENTRY(stext)
   41.24 @@ -82,7 +81,25 @@ NEXT_PAGE(level2_kernel_pgt)
   41.25  	.fill	512,8,0
   41.26  
   41.27  NEXT_PAGE(hypercall_page)
   41.28 -	.fill	512,8,0
   41.29 +	CFI_STARTPROC
   41.30 +	.rept 0x1000 / 0x20
   41.31 +	.skip 1 /* push %rcx */
   41.32 +	CFI_ADJUST_CFA_OFFSET	8
   41.33 +	CFI_REL_OFFSET	rcx,0
   41.34 +	.skip 2 /* push %r11 */
   41.35 +	CFI_ADJUST_CFA_OFFSET	8
   41.36 +	CFI_REL_OFFSET	rcx,0
   41.37 +	.skip 5 /* mov $#,%eax */
   41.38 +	.skip 2 /* syscall */
   41.39 +	.skip 2 /* pop %r11 */
   41.40 +	CFI_ADJUST_CFA_OFFSET -8
   41.41 +	CFI_RESTORE r11
   41.42 +	.skip 1 /* pop %rcx */
   41.43 +	CFI_ADJUST_CFA_OFFSET -8
   41.44 +	CFI_RESTORE rcx
   41.45 +	.align 0x20,0 /* ret */
   41.46 +	.endr
   41.47 +	CFI_ENDPROC
   41.48  
   41.49  #undef NEXT_PAGE
   41.50  
   41.51 @@ -186,3 +203,4 @@ ENTRY(empty_zero_page)
   41.52  	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .quad,  _PAGE_PRESENT,_PAGE_PRESENT)
   41.53  	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
   41.54  	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz, "generic")
   41.55 +	ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long,  1)
    42.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c	Thu Mar 01 15:02:09 2007 -0700
    42.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c	Wed Mar 07 12:38:28 2007 -0700
    42.3 @@ -47,11 +47,11 @@ EXPORT_SYMBOL(init_task);
    42.4   * on exact cacheline boundaries, to eliminate cacheline ping-pong.
    42.5   */ 
    42.6  DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
    42.7 -#endif
    42.8  
    42.9  /* Copies of the original ist values from the tss are only accessed during
   42.10   * debugging, no special alignment required.
   42.11   */
   42.12  DEFINE_PER_CPU(struct orig_ist, orig_ist);
   42.13 +#endif
   42.14  
   42.15  #define ALIGN_TO_4K __attribute__((section(".data.init_task")))
    43.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Thu Mar 01 15:02:09 2007 -0700
    43.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Wed Mar 07 12:38:28 2007 -0700
    43.3 @@ -117,7 +117,7 @@ void exit_idle(void)
    43.4   * to poll the ->need_resched flag instead of waiting for the
    43.5   * cross-CPU IPI to arrive. Use this option with caution.
    43.6   */
    43.7 -static void poll_idle(void)
    43.8 +static void poll_idle (void)
    43.9  {
   43.10  	local_irq_enable();
   43.11  
   43.12 @@ -179,9 +179,7 @@ void cpu_idle (void)
   43.13  			if (__get_cpu_var(cpu_idle_state))
   43.14  				__get_cpu_var(cpu_idle_state) = 0;
   43.15  			rmb();
   43.16 -			idle = pm_idle;
   43.17 -			if (!idle)
   43.18 -				idle = xen_idle;
   43.19 +			idle = xen_idle; /* no alternatives */
   43.20  			if (cpu_is_offline(smp_processor_id()))
   43.21  				play_dead();
   43.22  			enter_idle();
    44.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c	Thu Mar 01 15:02:09 2007 -0700
    44.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/setup-xen.c	Wed Mar 07 12:38:28 2007 -0700
    44.3 @@ -676,7 +676,8 @@ void __init setup_arch(char **cmdline_p)
    44.4  
    44.5  	init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
    44.6  
    44.7 -	/* dmi_scan_machine(); */
    44.8 +	if (is_initial_xendomain())
    44.9 +		dmi_scan_machine();
   44.10  
   44.11  #ifdef CONFIG_ACPI_NUMA
   44.12  	/*
   44.13 @@ -691,6 +692,14 @@ void __init setup_arch(char **cmdline_p)
   44.14  	contig_initmem_init(0, end_pfn);
   44.15  #endif
   44.16  
   44.17 +#ifdef CONFIG_XEN
   44.18 +	/*
   44.19 +	 * Reserve kernel, physmap, start info, initial page tables, and
   44.20 +	 * direct mapping.
   44.21 +	 */
   44.22 +	reserve_bootmem_generic(__pa_symbol(&_text),
   44.23 +	                        (table_end << PAGE_SHIFT) - __pa_symbol(&_text));
   44.24 +#else
   44.25  	/* Reserve direct mapping */
   44.26  	reserve_bootmem_generic(table_start << PAGE_SHIFT, 
   44.27  				(table_end - table_start) << PAGE_SHIFT);
   44.28 @@ -699,12 +708,6 @@ void __init setup_arch(char **cmdline_p)
   44.29  	reserve_bootmem_generic(__pa_symbol(&_text),
   44.30  				__pa_symbol(&_end) - __pa_symbol(&_text));
   44.31  
   44.32 -#ifdef CONFIG_XEN
   44.33 -	/* reserve physmap, start info and initial page tables */
   44.34 -	reserve_bootmem_generic(__pa_symbol(&_end),
   44.35 -				(table_start << PAGE_SHIFT) -
   44.36 -				__pa_symbol(&_end));
   44.37 -#else
   44.38  	/*
   44.39  	 * reserve physical page 0 - it's a special BIOS page on many boxes,
   44.40  	 * enabling clean reboots, SMP operation, laptop functions.
   44.41 @@ -1625,13 +1628,6 @@ struct seq_operations cpuinfo_op = {
   44.42  	.show =	show_cpuinfo,
   44.43  };
   44.44  
   44.45 -static int __init run_dmi_scan(void)
   44.46 -{
   44.47 -	dmi_scan_machine();
   44.48 -	return 0;
   44.49 -}
   44.50 -core_initcall(run_dmi_scan);
   44.51 -
   44.52  #if defined(CONFIG_INPUT_PCSPKR) || defined(CONFIG_INPUT_PCSPKR_MODULE)
   44.53  #include <linux/platform_device.h>
   44.54  static __init int add_pcspkr(void)
   44.55 @@ -1639,6 +1635,9 @@ static __init int add_pcspkr(void)
   44.56  	struct platform_device *pd;
   44.57  	int ret;
   44.58  
   44.59 +	if (!is_initial_xendomain())
   44.60 +		return 0;
   44.61 +
   44.62  	pd = platform_device_alloc("pcspkr", -1);
   44.63  	if (!pd)
   44.64  		return -ENOMEM;
    45.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/x8664_ksyms-xen.c	Thu Mar 01 15:02:09 2007 -0700
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,60 +0,0 @@
    45.4 -/* Exports for assembly files.
    45.5 -   All C exports should go in the respective C files. */
    45.6 -
    45.7 -#include <linux/config.h>
    45.8 -#include <linux/module.h>
    45.9 -#include <linux/smp.h>
   45.10 -
   45.11 -#include <asm/semaphore.h>
   45.12 -#include <asm/processor.h>
   45.13 -#include <asm/uaccess.h>
   45.14 -#include <asm/pgtable.h>
   45.15 -
   45.16 -EXPORT_SYMBOL(kernel_thread);
   45.17 -
   45.18 -EXPORT_SYMBOL(__down_failed);
   45.19 -EXPORT_SYMBOL(__down_failed_interruptible);
   45.20 -EXPORT_SYMBOL(__down_failed_trylock);
   45.21 -EXPORT_SYMBOL(__up_wakeup);
   45.22 -
   45.23 -EXPORT_SYMBOL(__get_user_1);
   45.24 -EXPORT_SYMBOL(__get_user_2);
   45.25 -EXPORT_SYMBOL(__get_user_4);
   45.26 -EXPORT_SYMBOL(__get_user_8);
   45.27 -EXPORT_SYMBOL(__put_user_1);
   45.28 -EXPORT_SYMBOL(__put_user_2);
   45.29 -EXPORT_SYMBOL(__put_user_4);
   45.30 -EXPORT_SYMBOL(__put_user_8);
   45.31 -
   45.32 -EXPORT_SYMBOL(copy_user_generic);
   45.33 -EXPORT_SYMBOL(copy_from_user);
   45.34 -EXPORT_SYMBOL(copy_to_user);
   45.35 -
   45.36 -EXPORT_SYMBOL(copy_page);
   45.37 -EXPORT_SYMBOL(clear_page);
   45.38 -
   45.39 -#ifdef CONFIG_SMP
   45.40 -extern void FASTCALL( __write_lock_failed(rwlock_t *rw));
   45.41 -extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
   45.42 -EXPORT_SYMBOL(__write_lock_failed);
   45.43 -EXPORT_SYMBOL(__read_lock_failed);
   45.44 -#endif
   45.45 -
   45.46 -/* Export string functions. We normally rely on gcc builtin for most of these,
   45.47 -   but gcc sometimes decides not to inline them. */    
   45.48 -#undef memcpy
   45.49 -#undef memset
   45.50 -#undef memmove
   45.51 -
   45.52 -extern void * memset(void *,int,__kernel_size_t);
   45.53 -extern void * memcpy(void *,const void *,__kernel_size_t);
   45.54 -extern void * __memcpy(void *,const void *,__kernel_size_t);
   45.55 -
   45.56 -EXPORT_SYMBOL(memset);
   45.57 -EXPORT_SYMBOL(memcpy);
   45.58 -EXPORT_SYMBOL(__memcpy);
   45.59 -
   45.60 -EXPORT_SYMBOL(empty_zero_page);
   45.61 -
   45.62 -EXPORT_SYMBOL(load_gs_index);
   45.63 -
    46.1 --- a/linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c	Thu Mar 01 15:02:09 2007 -0700
    46.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/mm/init-xen.c	Wed Mar 07 12:38:28 2007 -0700
    46.3 @@ -102,14 +102,11 @@ static void __meminit early_make_page_re
    46.4  		BUG();
    46.5  }
    46.6  
    46.7 -void make_page_readonly(void *va, unsigned int feature)
    46.8 +static void __make_page_readonly(void *va)
    46.9  {
   46.10  	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
   46.11  	unsigned long addr = (unsigned long) va;
   46.12  
   46.13 -	if (xen_feature(feature))
   46.14 -		return;
   46.15 -
   46.16  	pgd = pgd_offset_k(addr);
   46.17  	pud = pud_offset(pgd, addr);
   46.18  	pmd = pmd_offset(pud, addr);
   46.19 @@ -120,17 +117,14 @@ void make_page_readonly(void *va, unsign
   46.20  		xen_l1_entry_update(ptep, pte); /* fallback */
   46.21  
   46.22  	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
   46.23 -		make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT), feature);
   46.24 +		__make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT));
   46.25  }
   46.26  
   46.27 -void make_page_writable(void *va, unsigned int feature)
   46.28 +static void __make_page_writable(void *va)
   46.29  {
   46.30  	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
   46.31  	unsigned long addr = (unsigned long) va;
   46.32  
   46.33 -	if (xen_feature(feature))
   46.34 -		return;
   46.35 -
   46.36  	pgd = pgd_offset_k(addr);
   46.37  	pud = pud_offset(pgd, addr);
   46.38  	pmd = pmd_offset(pud, addr);
   46.39 @@ -141,7 +135,19 @@ void make_page_writable(void *va, unsign
   46.40  		xen_l1_entry_update(ptep, pte); /* fallback */
   46.41  
   46.42  	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
   46.43 -		make_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT), feature);
   46.44 +		__make_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT));
   46.45 +}
   46.46 +
   46.47 +void make_page_readonly(void *va, unsigned int feature)
   46.48 +{
   46.49 +	if (!xen_feature(feature))
   46.50 +		__make_page_readonly(va);
   46.51 +}
   46.52 +
   46.53 +void make_page_writable(void *va, unsigned int feature)
   46.54 +{
   46.55 +	if (!xen_feature(feature))
   46.56 +		__make_page_writable(va);
   46.57  }
   46.58  
   46.59  void make_pages_readonly(void *va, unsigned nr, unsigned int feature)
   46.60 @@ -150,7 +156,7 @@ void make_pages_readonly(void *va, unsig
   46.61  		return;
   46.62  
   46.63  	while (nr-- != 0) {
   46.64 -		make_page_readonly(va, feature);
   46.65 +		__make_page_readonly(va);
   46.66  		va = (void*)((unsigned long)va + PAGE_SIZE);
   46.67  	}
   46.68  }
   46.69 @@ -161,7 +167,7 @@ void make_pages_writable(void *va, unsig
   46.70  		return;
   46.71  
   46.72  	while (nr-- != 0) {
   46.73 -		make_page_writable(va, feature);
   46.74 +		__make_page_writable(va);
   46.75  		va = (void*)((unsigned long)va + PAGE_SIZE);
   46.76  	}
   46.77  }
   46.78 @@ -208,7 +214,11 @@ static __init void *spp_getpage(void)
   46.79  	void *ptr;
   46.80  	if (after_bootmem)
   46.81  		ptr = (void *) get_zeroed_page(GFP_ATOMIC); 
   46.82 -	else
   46.83 +	else if (start_pfn < table_end) {
   46.84 +		ptr = __va(start_pfn << PAGE_SHIFT);
   46.85 +		start_pfn++;
   46.86 +		memset(ptr, 0, PAGE_SIZE);
   46.87 +	} else
   46.88  		ptr = alloc_bootmem_pages(PAGE_SIZE);
   46.89  	if (!ptr || ((unsigned long)ptr & ~PAGE_MASK))
   46.90  		panic("set_pte_phys: cannot allocate page data %s\n", after_bootmem?"after bootmem":"");
   46.91 @@ -299,36 +309,26 @@ static __init void set_pte_phys_ma(unsig
   46.92  
   46.93  		pmd = (pmd_t *) spp_getpage(); 
   46.94  		make_page_readonly(pmd, XENFEAT_writable_page_tables);
   46.95 -
   46.96  		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
   46.97 -
   46.98  		if (pmd != pmd_offset(pud, 0)) {
   46.99  			printk("PAGETABLE BUG #01! %p <-> %p\n", pmd, pmd_offset(pud,0));
  46.100  			return;
  46.101  		}
  46.102  	}
  46.103  	pmd = pmd_offset(pud, vaddr);
  46.104 -
  46.105  	if (pmd_none(*pmd)) {
  46.106  		pte = (pte_t *) spp_getpage();
  46.107  		make_page_readonly(pte, XENFEAT_writable_page_tables);
  46.108 -
  46.109  		set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
  46.110  		if (pte != pte_offset_kernel(pmd, 0)) {
  46.111  			printk("PAGETABLE BUG #02!\n");
  46.112  			return;
  46.113  		}
  46.114  	}
  46.115 -
  46.116  	new_pte = pfn_pte_ma(phys >> PAGE_SHIFT, prot);
  46.117 -	pte = pte_offset_kernel(pmd, vaddr);
  46.118  
  46.119 -	/* 
  46.120 -	 * Note that the pte page is already RO, thus we want to use
  46.121 -	 * xen_l1_entry_update(), not set_pte().
  46.122 -	 */
  46.123 -	xen_l1_entry_update(pte, 
  46.124 -			    pfn_pte_ma(phys >> PAGE_SHIFT, prot));
  46.125 +	pte = pte_offset_kernel(pmd, vaddr);
  46.126 +	set_pte(pte, new_pte);
  46.127  
  46.128  	/*
  46.129  	 * It's enough to flush this one mapping.
  46.130 @@ -404,6 +404,7 @@ static inline void __set_pte(pte_t *dst,
  46.131  
  46.132  static inline int make_readonly(unsigned long paddr)
  46.133  {
  46.134 +	extern char __vsyscall_0;
  46.135  	int readonly = 0;
  46.136  
  46.137  	/* Make new page tables read-only. */
  46.138 @@ -420,25 +421,45 @@ static inline int make_readonly(unsigned
  46.139  	/*
  46.140  	 * No need for writable mapping of kernel image. This also ensures that
  46.141  	 * page and descriptor tables embedded inside don't have writable
  46.142 -	 * mappings. 
  46.143 +	 * mappings. Exclude the vsyscall area here, allowing alternative
  46.144 +	 * instruction patching to work.
  46.145  	 */
  46.146 -	if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end)))
  46.147 +	if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end))
  46.148 +	    && !(paddr >= __pa_symbol(&__vsyscall_0)
  46.149 +	         && paddr < __pa_symbol(&__vsyscall_0) + PAGE_SIZE))
  46.150  		readonly = 1;
  46.151  
  46.152  	return readonly;
  46.153  }
  46.154  
  46.155 +#ifndef CONFIG_XEN
  46.156  /* Must run before zap_low_mappings */
  46.157  __init void *early_ioremap(unsigned long addr, unsigned long size)
  46.158  {
  46.159 -	return ioremap(addr, size);
  46.160 +	unsigned long map = round_down(addr, LARGE_PAGE_SIZE);
  46.161 +
  46.162 +	/* actually usually some more */
  46.163 +	if (size >= LARGE_PAGE_SIZE) {
  46.164 +		printk("SMBIOS area too long %lu\n", size);
  46.165 +		return NULL;
  46.166 +	}
  46.167 +	set_pmd(temp_mappings[0].pmd,  __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
  46.168 +	map += LARGE_PAGE_SIZE;
  46.169 +	set_pmd(temp_mappings[1].pmd,  __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
  46.170 +	__flush_tlb();
  46.171 +	return temp_mappings[0].address + (addr & (LARGE_PAGE_SIZE-1));
  46.172  }
  46.173  
  46.174  /* To avoid virtual aliases later */
  46.175  __init void early_iounmap(void *addr, unsigned long size)
  46.176  {
  46.177 -	iounmap(addr);
  46.178 +	if ((void *)round_down((unsigned long)addr, LARGE_PAGE_SIZE) != temp_mappings[0].address)
  46.179 +		printk("early_iounmap: bad address %p\n", addr);
  46.180 +	set_pmd(temp_mappings[0].pmd, __pmd(0));
  46.181 +	set_pmd(temp_mappings[1].pmd, __pmd(0));
  46.182 +	__flush_tlb();
  46.183  }
  46.184 +#endif
  46.185  
  46.186  static void __meminit
  46.187  phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end)
  46.188 @@ -638,7 +659,7 @@ static void __init extend_init_mapping(u
  46.189  
  46.190  static void __init find_early_table_space(unsigned long end)
  46.191  {
  46.192 -	unsigned long puds, pmds, ptes, tables; 
  46.193 +	unsigned long puds, pmds, ptes, tables;
  46.194  
  46.195  	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
  46.196  	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
  46.197 @@ -658,12 +679,70 @@ static void __init find_early_table_spac
  46.198  		(table_start << PAGE_SHIFT) + tables);
  46.199  }
  46.200  
  46.201 +static void xen_finish_init_mapping(void)
  46.202 +{
  46.203 +	unsigned long i, start, end;
  46.204 +
  46.205 +	/* Re-vector virtual addresses pointing into the initial
  46.206 +	   mapping to the just-established permanent ones. */
  46.207 +	xen_start_info = __va(__pa(xen_start_info));
  46.208 +	xen_start_info->pt_base = (unsigned long)
  46.209 +		__va(__pa(xen_start_info->pt_base));
  46.210 +	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
  46.211 +		phys_to_machine_mapping =
  46.212 +			__va(__pa(xen_start_info->mfn_list));
  46.213 +		xen_start_info->mfn_list = (unsigned long)
  46.214 +			phys_to_machine_mapping;
  46.215 +	}
  46.216 +	if (xen_start_info->mod_start)
  46.217 +		xen_start_info->mod_start = (unsigned long)
  46.218 +			__va(__pa(xen_start_info->mod_start));
  46.219 +
  46.220 +	/* Destroy the Xen-created mappings beyond the kernel image as
  46.221 +	 * well as the temporary mappings created above. Prevents
  46.222 +	 * overlap with modules area (if init mapping is very big).
  46.223 +	 */
  46.224 +	start = PAGE_ALIGN((unsigned long)_end);
  46.225 +	end   = __START_KERNEL_map + (table_end << PAGE_SHIFT);
  46.226 +	for (; start < end; start += PAGE_SIZE)
  46.227 +		WARN_ON(HYPERVISOR_update_va_mapping(
  46.228 +			start, __pte_ma(0), 0));
  46.229 +
  46.230 +	/* Allocate pte's for initial fixmaps from 'start_pfn' allocator. */
  46.231 +	table_end = ~0UL;
  46.232 +
  46.233 +	/*
  46.234 +	 * Prefetch pte's for the bt_ioremap() area. It gets used before the
  46.235 +	 * boot-time allocator is online, so allocate-on-demand would fail.
  46.236 +	 */
  46.237 +	for (i = FIX_BTMAP_END; i <= FIX_BTMAP_BEGIN; i++)
  46.238 +		__set_fixmap(i, 0, __pgprot(0));
  46.239 +
  46.240 +	/* Switch to the real shared_info page, and clear the dummy page. */
  46.241 +	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
  46.242 +	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
  46.243 +	memset(empty_zero_page, 0, sizeof(empty_zero_page));
  46.244 +
  46.245 +	/* Set up mapping of lowest 1MB of physical memory. */
  46.246 +	for (i = 0; i < NR_FIX_ISAMAPS; i++)
  46.247 +		if (is_initial_xendomain())
  46.248 +			set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
  46.249 +		else
  46.250 +			__set_fixmap(FIX_ISAMAP_BEGIN - i,
  46.251 +				     virt_to_mfn(empty_zero_page)
  46.252 +				     << PAGE_SHIFT,
  46.253 +				     PAGE_KERNEL_RO);
  46.254 +
  46.255 +	/* Disable the 'start_pfn' allocator. */
  46.256 +	table_end = start_pfn;
  46.257 +}
  46.258 +
  46.259  /* Setup the direct mapping of the physical memory at PAGE_OFFSET.
  46.260     This runs before bootmem is initialized and gets pages directly from the 
  46.261     physical memory. To access them they are temporarily mapped. */
  46.262  void __meminit init_memory_mapping(unsigned long start, unsigned long end)
  46.263  { 
  46.264 -	unsigned long next; 
  46.265 +	unsigned long next;
  46.266  
  46.267  	Dprintk("init_memory_mapping\n");
  46.268  
  46.269 @@ -702,31 +781,7 @@ void __meminit init_memory_mapping(unsig
  46.270  
  46.271  	if (!after_bootmem) {
  46.272  		BUG_ON(start_pfn != table_end);
  46.273 -
  46.274 -		/* Re-vector virtual addresses pointing into the initial
  46.275 -		   mapping to the just-established permanent ones. */
  46.276 -		xen_start_info = __va(__pa(xen_start_info));
  46.277 -		xen_start_info->pt_base = (unsigned long)
  46.278 -			__va(__pa(xen_start_info->pt_base));
  46.279 -		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
  46.280 -			phys_to_machine_mapping =
  46.281 -				__va(__pa(xen_start_info->mfn_list));
  46.282 -			xen_start_info->mfn_list = (unsigned long)
  46.283 -				phys_to_machine_mapping;
  46.284 -		}
  46.285 -		if (xen_start_info->mod_start)
  46.286 -			xen_start_info->mod_start = (unsigned long)
  46.287 -				__va(__pa(xen_start_info->mod_start));
  46.288 -
  46.289 -		/* Destroy the Xen-created mappings beyond the kernel image as
  46.290 -		 * well as the temporary mappings created above. Prevents
  46.291 -		 * overlap with modules area (if init mapping is very big).
  46.292 -		 */
  46.293 -		start = PAGE_ALIGN((unsigned long)_end);
  46.294 -		end   = __START_KERNEL_map + (table_end << PAGE_SHIFT);
  46.295 -		for (; start < end; start += PAGE_SIZE)
  46.296 -			WARN_ON(HYPERVISOR_update_va_mapping(
  46.297 -				start, __pte_ma(0), 0));
  46.298 +		xen_finish_init_mapping();
  46.299  	}
  46.300  
  46.301  	__flush_tlb_all();
  46.302 @@ -805,7 +860,6 @@ size_zones(unsigned long *z, unsigned lo
  46.303  void __init paging_init(void)
  46.304  {
  46.305  	unsigned long zones[MAX_NR_ZONES], holes[MAX_NR_ZONES];
  46.306 -	int i;
  46.307  
  46.308  	memory_present(0, 0, end_pfn);
  46.309  	sparse_init();
  46.310 @@ -813,22 +867,7 @@ void __init paging_init(void)
  46.311  	free_area_init_node(0, NODE_DATA(0), zones,
  46.312  			    __pa(PAGE_OFFSET) >> PAGE_SHIFT, holes);
  46.313  
  46.314 -	/* Switch to the real shared_info page, and clear the
  46.315 -	 * dummy page. */
  46.316 -	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
  46.317 -	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
  46.318 -	memset(empty_zero_page, 0, sizeof(empty_zero_page));
  46.319 -
  46.320  	init_mm.context.pinned = 1;
  46.321 -
  46.322 -	/* Setup mapping of lower 1st MB */
  46.323 -	for (i = 0; i < NR_FIX_ISAMAPS; i++)
  46.324 -		if (is_initial_xendomain())
  46.325 -			set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
  46.326 -		else
  46.327 -			__set_fixmap(FIX_ISAMAP_BEGIN - i,
  46.328 -				     virt_to_mfn(empty_zero_page) << PAGE_SHIFT,
  46.329 -				     PAGE_KERNEL_RO);
  46.330  }
  46.331  #endif
  46.332  
  46.333 @@ -1028,11 +1067,6 @@ void __init mem_init(void)
  46.334  
  46.335  void free_init_pages(char *what, unsigned long begin, unsigned long end)
  46.336  {
  46.337 -#ifdef __DO_LATER__
  46.338 -	/*
  46.339 -	 * Some pages can be pinned, but some are not. Unpinning such pages 
  46.340 -	 * triggers BUG(). 
  46.341 -	 */
  46.342  	unsigned long addr;
  46.343  
  46.344  	if (begin >= end)
  46.345 @@ -1044,25 +1078,27 @@ void free_init_pages(char *what, unsigne
  46.346  		init_page_count(virt_to_page(addr));
  46.347  		memset((void *)(addr & ~(PAGE_SIZE-1)),
  46.348  		       POISON_FREE_INITMEM, PAGE_SIZE); 
  46.349 -		make_page_writable(
  46.350 -			__va(__pa(addr)), XENFEAT_writable_page_tables);
  46.351 -		/*
  46.352 -		 * Make pages from __PAGE_OFFSET address as well
  46.353 -		 */
  46.354 -		make_page_writable(
  46.355 -			(void *)addr, XENFEAT_writable_page_tables);
  46.356 +		if (addr >= __START_KERNEL_map) {
  46.357 +			/* make_readonly() reports all kernel addresses. */
  46.358 +			__make_page_writable(__va(__pa(addr)));
  46.359 +			if (HYPERVISOR_update_va_mapping(addr, __pte(0), 0)) {
  46.360 +				pgd_t *pgd = pgd_offset_k(addr);
  46.361 +				pud_t *pud = pud_offset(pgd, addr);
  46.362 +				pmd_t *pmd = pmd_offset(pud, addr);
  46.363 +				pte_t *pte = pte_offset_kernel(pmd, addr);
  46.364 +
  46.365 +				xen_l1_entry_update(pte, __pte(0)); /* fallback */
  46.366 +			}
  46.367 +		}
  46.368  		free_page(addr);
  46.369  		totalram_pages++;
  46.370  	}
  46.371 -#endif
  46.372  }
  46.373  
  46.374  void free_initmem(void)
  46.375  {
  46.376 -#ifdef __DO_LATER__
  46.377  	memset(__initdata_begin, POISON_FREE_INITDATA,
  46.378  		__initdata_end - __initdata_begin);
  46.379 -#endif
  46.380  	free_init_pages("unused kernel memory",
  46.381  			(unsigned long)(&__init_begin),
  46.382  			(unsigned long)(&__init_end));
  46.383 @@ -1125,7 +1161,7 @@ int kern_addr_valid(unsigned long addr)
  46.384  	if (pgd_none(*pgd))
  46.385  		return 0;
  46.386  
  46.387 -	pud = pud_offset_k(pgd, addr);
  46.388 +	pud = pud_offset(pgd, addr);
  46.389  	if (pud_none(*pud))
  46.390  		return 0; 
  46.391  
    47.1 --- a/linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c	Thu Mar 01 15:02:09 2007 -0700
    47.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/mm/pageattr-xen.c	Wed Mar 07 12:38:28 2007 -0700
    47.3 @@ -24,10 +24,13 @@ static inline void mm_walk_set_prot(void
    47.4  {
    47.5  	struct page *page = virt_to_page(pt);
    47.6  	unsigned long pfn = page_to_pfn(page);
    47.7 +	int rc;
    47.8  
    47.9 -	BUG_ON(HYPERVISOR_update_va_mapping(
   47.10 -		       (unsigned long)__va(pfn << PAGE_SHIFT),
   47.11 -		       pfn_pte(pfn, flags), 0));
   47.12 +	rc = HYPERVISOR_update_va_mapping(
   47.13 +		(unsigned long)__va(pfn << PAGE_SHIFT),
   47.14 +		pfn_pte(pfn, flags), 0);
   47.15 +	if (rc)
   47.16 +		BUG();
   47.17  }
   47.18  
   47.19  static void mm_walk(struct mm_struct *mm, pgprot_t flags)
    48.1 --- a/linux-2.6-xen-sparse/drivers/char/mem.c	Thu Mar 01 15:02:09 2007 -0700
    48.2 +++ b/linux-2.6-xen-sparse/drivers/char/mem.c	Wed Mar 07 12:38:28 2007 -0700
    48.3 @@ -787,7 +787,7 @@ static const struct file_operations mem_
    48.4  	.open		= open_mem,
    48.5  };
    48.6  #else
    48.7 -extern struct file_operations mem_fops;
    48.8 +extern const struct file_operations mem_fops;
    48.9  #endif
   48.10  
   48.11  static const struct file_operations kmem_fops = {
    49.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Thu Mar 01 15:02:09 2007 -0700
    49.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Wed Mar 07 12:38:28 2007 -0700
    49.3 @@ -113,14 +113,13 @@ void __exit tpmif_exit(void);
    49.4  
    49.5  
    49.6  static inline int
    49.7 -tx_buffer_copy(struct tx_buffer *txb, const u8 * src, int len,
    49.8 +tx_buffer_copy(struct tx_buffer *txb, const u8 *src, int len,
    49.9                 int isuserbuffer)
   49.10  {
   49.11  	int copied = len;
   49.12  
   49.13 -	if (len > txb->size) {
   49.14 +	if (len > txb->size)
   49.15  		copied = txb->size;
   49.16 -	}
   49.17  	if (isuserbuffer) {
   49.18  		if (copy_from_user(txb->data, src, copied))
   49.19  			return -EFAULT;
   49.20 @@ -133,18 +132,20 @@ tx_buffer_copy(struct tx_buffer *txb, co
   49.21  
   49.22  static inline struct tx_buffer *tx_buffer_alloc(void)
   49.23  {
   49.24 -	struct tx_buffer *txb = kzalloc(sizeof (struct tx_buffer),
   49.25 -					GFP_KERNEL);
   49.26 +	struct tx_buffer *txb;
   49.27 +
   49.28 +	txb = kzalloc(sizeof(struct tx_buffer), GFP_KERNEL);
   49.29 +	if (!txb)
   49.30 +		return NULL;
   49.31  
   49.32 -	if (txb) {
   49.33 -		txb->len = 0;
   49.34 -		txb->size = PAGE_SIZE;
   49.35 -		txb->data = (unsigned char *)__get_free_page(GFP_KERNEL);
   49.36 -		if (txb->data == NULL) {
   49.37 -			kfree(txb);
   49.38 -			txb = NULL;
   49.39 -		}
   49.40 +	txb->len = 0;
   49.41 +	txb->size = PAGE_SIZE;
   49.42 +	txb->data = (unsigned char *)__get_free_page(GFP_KERNEL);
   49.43 +	if (txb->data == NULL) {
   49.44 +		kfree(txb);
   49.45 +		txb = NULL;
   49.46  	}
   49.47 +
   49.48  	return txb;
   49.49  }
   49.50  
   49.51 @@ -160,37 +161,41 @@ static inline void tx_buffer_free(struct
   49.52  /**************************************************************
   49.53   Utility function for the tpm_private structure
   49.54  **************************************************************/
   49.55 -static inline void tpm_private_init(struct tpm_private *tp)
   49.56 +static void tpm_private_init(struct tpm_private *tp)
   49.57  {
   49.58  	spin_lock_init(&tp->tx_lock);
   49.59  	init_waitqueue_head(&tp->wait_q);
   49.60  	atomic_set(&tp->refcnt, 1);
   49.61  }
   49.62  
   49.63 -static inline void tpm_private_put(void)
   49.64 +static void tpm_private_put(void)
   49.65  {
   49.66 -	if ( atomic_dec_and_test(&my_priv->refcnt)) {
   49.67 -		tpmif_free_tx_buffers(my_priv);
   49.68 -		kfree(my_priv);
   49.69 -		my_priv = NULL;
   49.70 -	}
   49.71 +	if (!atomic_dec_and_test(&my_priv->refcnt))
   49.72 +		return;
   49.73 +
   49.74 +	tpmif_free_tx_buffers(my_priv);
   49.75 +	kfree(my_priv);
   49.76 +	my_priv = NULL;
   49.77  }
   49.78  
   49.79  static struct tpm_private *tpm_private_get(void)
   49.80  {
   49.81  	int err;
   49.82 -	if (!my_priv) {
   49.83 -		my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL);
   49.84 -		if (my_priv) {
   49.85 -			tpm_private_init(my_priv);
   49.86 -			err = tpmif_allocate_tx_buffers(my_priv);
   49.87 -			if (err < 0) {
   49.88 -				tpm_private_put();
   49.89 -			}
   49.90 -		}
   49.91 -	} else {
   49.92 +
   49.93 +	if (my_priv) {
   49.94  		atomic_inc(&my_priv->refcnt);
   49.95 +		return my_priv;
   49.96  	}
   49.97 +
   49.98 +	my_priv = kzalloc(sizeof(struct tpm_private), GFP_KERNEL);
   49.99 +	if (!my_priv)
  49.100 +		return NULL;
  49.101 +
  49.102 +	tpm_private_init(my_priv);
  49.103 +	err = tpmif_allocate_tx_buffers(my_priv);
  49.104 +	if (err < 0)
  49.105 +		tpm_private_put();
  49.106 +
  49.107  	return my_priv;
  49.108  }
  49.109  
  49.110 @@ -379,10 +384,8 @@ static int tpmfront_probe(struct xenbus_
  49.111  		return -ENOMEM;
  49.112  
  49.113  	tp->chip = init_vtpm(&dev->dev, &tvd, tp);
  49.114 -
  49.115 -	if (IS_ERR(tp->chip)) {
  49.116 +	if (IS_ERR(tp->chip))
  49.117  		return PTR_ERR(tp->chip);
  49.118 -	}
  49.119  
  49.120  	err = xenbus_scanf(XBT_NIL, dev->nodename,
  49.121  	                   "handle", "%i", &handle);
  49.122 @@ -401,6 +404,7 @@ static int tpmfront_probe(struct xenbus_
  49.123  		tpm_private_put();
  49.124  		return err;
  49.125  	}
  49.126 +
  49.127  	return 0;
  49.128  }
  49.129  
  49.130 @@ -417,32 +421,36 @@ static int tpmfront_suspend(struct xenbu
  49.131  {
  49.132  	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
  49.133  	u32 ctr;
  49.134 -	/* lock, so no app can send */
  49.135 +
  49.136 +	/* Take the lock, preventing any application from sending. */
  49.137  	mutex_lock(&suspend_lock);
  49.138  	tp->is_suspended = 1;
  49.139  
  49.140 -	for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 300; ctr++) {
  49.141 +	for (ctr = 0; atomic_read(&tp->tx_busy); ctr++) {
  49.142  		if ((ctr % 10) == 0)
  49.143  			printk("TPM-FE [INFO]: Waiting for outstanding "
  49.144  			       "request.\n");
  49.145 -		/*
  49.146 -		 * Wait for a request to be responded to.
  49.147 -		 */
  49.148 +		/* Wait for a request to be responded to. */
  49.149  		interruptible_sleep_on_timeout(&tp->wait_q, 100);
  49.150  	}
  49.151 -	xenbus_switch_state(dev, XenbusStateClosing);
  49.152 -
  49.153 -	if (atomic_read(&tp->tx_busy)) {
  49.154 -		/*
  49.155 -		 * A temporary work-around.
  49.156 -		 */
  49.157 -		printk("TPM-FE [WARNING]: Resetting busy flag.");
  49.158 -		atomic_set(&tp->tx_busy, 0);
  49.159 -	}
  49.160  
  49.161  	return 0;
  49.162  }
  49.163  
  49.164 +static int tpmfront_suspend_finish(struct tpm_private *tp)
  49.165 +{
  49.166 +	tp->is_suspended = 0;
  49.167 +	/* Allow applications to send again. */
  49.168 +	mutex_unlock(&suspend_lock);
  49.169 +	return 0;
  49.170 +}
  49.171 +
  49.172 +static int tpmfront_suspend_cancel(struct xenbus_device *dev)
  49.173 +{
  49.174 +	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
  49.175 +	return tpmfront_suspend_finish(tp);
  49.176 +}
  49.177 +
  49.178  static int tpmfront_resume(struct xenbus_device *dev)
  49.179  {
  49.180  	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
  49.181 @@ -484,6 +492,7 @@ static struct xenbus_driver tpmfront = {
  49.182  	.resume = tpmfront_resume,
  49.183  	.otherend_changed = backend_changed,
  49.184  	.suspend = tpmfront_suspend,
  49.185 +	.suspend_cancel = tpmfront_suspend_cancel,
  49.186  };
  49.187  
  49.188  static void __init init_tpm_xenbus(void)
  49.189 @@ -514,9 +523,8 @@ static void tpmif_free_tx_buffers(struct
  49.190  {
  49.191  	unsigned int i;
  49.192  
  49.193 -	for (i = 0; i < TPMIF_TX_RING_SIZE; i++) {
  49.194 +	for (i = 0; i < TPMIF_TX_RING_SIZE; i++)
  49.195  		tx_buffer_free(tp->tx_buffers[i]);
  49.196 -	}
  49.197  }
  49.198  
  49.199  static void tpmif_rx_action(unsigned long priv)
  49.200 @@ -536,9 +544,8 @@ static void tpmif_rx_action(unsigned lon
  49.201  	received = tx->size;
  49.202  
  49.203  	buffer = kmalloc(received, GFP_ATOMIC);
  49.204 -	if (NULL == buffer) {
  49.205 +	if (!buffer)
  49.206  		goto exit;
  49.207 -	}
  49.208  
  49.209  	for (i = 0; i < TPMIF_TX_RING_SIZE && offset < received; i++) {
  49.210  		struct tx_buffer *txb = tp->tx_buffers[i];
  49.211 @@ -547,9 +554,8 @@ static void tpmif_rx_action(unsigned lon
  49.212  
  49.213  		tx = &tp->tx->ring[i].req;
  49.214  		tocopy = tx->size;
  49.215 -		if (tocopy > PAGE_SIZE) {
  49.216 +		if (tocopy > PAGE_SIZE)
  49.217  			tocopy = PAGE_SIZE;
  49.218 -		}
  49.219  
  49.220  		memcpy(&buffer[offset], txb->data, tocopy);
  49.221  
  49.222 @@ -607,12 +613,13 @@ static int tpm_xmit(struct tpm_private *
  49.223  		struct tx_buffer *txb = tp->tx_buffers[i];
  49.224  		int copied;
  49.225  
  49.226 -		if (NULL == txb) {
  49.227 +		if (!txb) {
  49.228  			DPRINTK("txb (i=%d) is NULL. buffers initilized?\n"
  49.229  				"Not transmitting anything!\n", i);
  49.230  			spin_unlock_irq(&tp->tx_lock);
  49.231  			return -EFAULT;
  49.232  		}
  49.233 +
  49.234  		copied = tx_buffer_copy(txb, &buf[offset], count,
  49.235  		                        isuserbuffer);
  49.236  		if (copied < 0) {
  49.237 @@ -624,25 +631,26 @@ static int tpm_xmit(struct tpm_private *
  49.238  		offset += copied;
  49.239  
  49.240  		tx = &tp->tx->ring[i].req;
  49.241 -
  49.242  		tx->addr = virt_to_machine(txb->data);
  49.243  		tx->size = txb->len;
  49.244  
  49.245 -		DPRINTK("First 4 characters sent by TPM-FE are 0x%02x 0x%02x 0x%02x 0x%02x\n",
  49.246 +		DPRINTK("First 4 characters sent by TPM-FE are "
  49.247 +			"0x%02x 0x%02x 0x%02x 0x%02x\n",
  49.248  		        txb->data[0],txb->data[1],txb->data[2],txb->data[3]);
  49.249  
  49.250 -		/* get the granttable reference for this page */
  49.251 +		/* Get the granttable reference for this page. */
  49.252  		tx->ref = gnttab_claim_grant_reference(&gref_head);
  49.253 -
  49.254 -		if (-ENOSPC == tx->ref) {
  49.255 +		if (tx->ref == -ENOSPC) {
  49.256  			spin_unlock_irq(&tp->tx_lock);
  49.257 -			DPRINTK(" Grant table claim reference failed in func:%s line:%d file:%s\n", __FUNCTION__, __LINE__, __FILE__);
  49.258 +			DPRINTK("Grant table claim reference failed in "
  49.259 +				"func:%s line:%d file:%s\n",
  49.260 +				__FUNCTION__, __LINE__, __FILE__);
  49.261  			return -ENOSPC;
  49.262  		}
  49.263 -		gnttab_grant_foreign_access_ref( tx->ref,
  49.264 -		                                 tp->backend_id,
  49.265 -		                                 (tx->addr >> PAGE_SHIFT),
  49.266 -		                                 0 /*RW*/);
  49.267 +		gnttab_grant_foreign_access_ref(tx->ref,
  49.268 +						tp->backend_id,
  49.269 +						virt_to_mfn(txb->data),
  49.270 +						0 /*RW*/);
  49.271  		wmb();
  49.272  	}
  49.273  
  49.274 @@ -660,15 +668,10 @@ static int tpm_xmit(struct tpm_private *
  49.275  
  49.276  static void tpmif_notify_upperlayer(struct tpm_private *tp)
  49.277  {
  49.278 -	/*
  49.279 -	 * Notify upper layer about the state of the connection
  49.280 -	 * to the BE.
  49.281 -	 */
  49.282 -	if (tp->is_connected) {
  49.283 -		vtpm_vd_status(tp->chip, TPM_VD_STATUS_CONNECTED);
  49.284 -	} else {
  49.285 -		vtpm_vd_status(tp->chip, TPM_VD_STATUS_DISCONNECTED);
  49.286 -	}
  49.287 +	/* Notify upper layer about the state of the connection to the BE. */
  49.288 +	vtpm_vd_status(tp->chip, (tp->is_connected
  49.289 +				  ? TPM_VD_STATUS_CONNECTED
  49.290 +				  : TPM_VD_STATUS_DISCONNECTED));
  49.291  }
  49.292  
  49.293  
  49.294 @@ -679,20 +682,16 @@ static void tpmif_set_connected_state(st
  49.295  	 * should disconnect - assumption is that we will resume
  49.296  	 * The mutex keeps apps from sending.
  49.297  	 */
  49.298 -	if (is_connected == 0 && tp->is_suspended == 1) {
  49.299 +	if (is_connected == 0 && tp->is_suspended == 1)
  49.300  		return;
  49.301 -	}
  49.302  
  49.303  	/*
  49.304  	 * Unlock the mutex if we are connected again
  49.305  	 * after being suspended - now resuming.
  49.306  	 * This also removes the suspend state.
  49.307  	 */
  49.308 -	if (is_connected == 1 && tp->is_suspended == 1) {
  49.309 -		tp->is_suspended = 0;
  49.310 -		/* unlock, so apps can resume sending */
  49.311 -		mutex_unlock(&suspend_lock);
  49.312 -	}
  49.313 +	if (is_connected == 1 && tp->is_suspended == 1)
  49.314 +		tpmfront_suspend_finish(tp);
  49.315  
  49.316  	if (is_connected != tp->is_connected) {
  49.317  		tp->is_connected = is_connected;
  49.318 @@ -710,33 +709,24 @@ static void tpmif_set_connected_state(st
  49.319  
  49.320  static int __init tpmif_init(void)
  49.321  {
  49.322 -	long rc = 0;
  49.323  	struct tpm_private *tp;
  49.324  
  49.325  	if (is_initial_xendomain())
  49.326  		return -EPERM;
  49.327  
  49.328  	tp = tpm_private_get();
  49.329 -	if (!tp) {
  49.330 -		rc = -ENOMEM;
  49.331 -		goto failexit;
  49.332 -	}
  49.333 +	if (!tp)
  49.334 +		return -ENOMEM;
  49.335  
  49.336  	IPRINTK("Initialising the vTPM driver.\n");
  49.337 -	if ( gnttab_alloc_grant_references ( TPMIF_TX_RING_SIZE,
  49.338 -	                                     &gref_head ) < 0) {
  49.339 -		rc = -EFAULT;
  49.340 -		goto gnttab_alloc_failed;
  49.341 +	if (gnttab_alloc_grant_references(TPMIF_TX_RING_SIZE,
  49.342 +					  &gref_head) < 0) {
  49.343 +		tpm_private_put();
  49.344 +		return -EFAULT;
  49.345  	}
  49.346  
  49.347  	init_tpm_xenbus();
  49.348  	return 0;
  49.349 -
  49.350 -gnttab_alloc_failed:
  49.351 -	tpm_private_put();
  49.352 -failexit:
  49.353 -
  49.354 -	return (int)rc;
  49.355  }
  49.356  
  49.357  
    50.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 01 15:02:09 2007 -0700
    50.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Mar 07 12:38:28 2007 -0700
    50.3 @@ -32,7 +32,6 @@
    50.4   * IN THE SOFTWARE.
    50.5   */
    50.6  
    50.7 -#include <linux/config.h>
    50.8  #include <linux/kernel.h>
    50.9  #include <linux/module.h>
   50.10  #include <linux/sched.h>
    51.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/sysfs.c	Thu Mar 01 15:02:09 2007 -0700
    51.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/sysfs.c	Wed Mar 07 12:38:28 2007 -0700
    51.3 @@ -28,7 +28,6 @@
    51.4   * IN THE SOFTWARE.
    51.5   */
    51.6  
    51.7 -#include <linux/config.h>
    51.8  #include <linux/capability.h>
    51.9  #include <linux/stat.h>
   51.10  #include <linux/sysdev.h>
    52.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Thu Mar 01 15:02:09 2007 -0700
    52.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Mar 07 12:38:28 2007 -0700
    52.3 @@ -27,7 +27,6 @@
    52.4  #ifndef __BLKIF__BACKEND__COMMON_H__
    52.5  #define __BLKIF__BACKEND__COMMON_H__
    52.6  
    52.7 -#include <linux/config.h>
    52.8  #include <linux/version.h>
    52.9  #include <linux/module.h>
   52.10  #include <linux/interrupt.h>
    53.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Thu Mar 01 15:02:09 2007 -0700
    53.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Wed Mar 07 12:38:28 2007 -0700
    53.3 @@ -35,7 +35,6 @@
    53.4  #ifndef __XEN_DRIVERS_BLOCK_H__
    53.5  #define __XEN_DRIVERS_BLOCK_H__
    53.6  
    53.7 -#include <linux/config.h>
    53.8  #include <linux/version.h>
    53.9  #include <linux/module.h>
   53.10  #include <linux/kernel.h>
    54.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Mar 01 15:02:09 2007 -0700
    54.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Wed Mar 07 12:38:28 2007 -0700
    54.3 @@ -335,7 +335,7 @@ static int blktap_ioctl(struct inode *in
    54.4                          unsigned int cmd, unsigned long arg);
    54.5  static unsigned int blktap_poll(struct file *file, poll_table *wait);
    54.6  
    54.7 -static struct file_operations blktap_fops = {
    54.8 +static const struct file_operations blktap_fops = {
    54.9  	.owner   = THIS_MODULE,
   54.10  	.poll    = blktap_poll,
   54.11  	.ioctl   = blktap_ioctl,
    55.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	Thu Mar 01 15:02:09 2007 -0700
    55.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	Wed Mar 07 12:38:28 2007 -0700
    55.3 @@ -27,7 +27,6 @@
    55.4  #ifndef __BLKIF__BACKEND__COMMON_H__
    55.5  #define __BLKIF__BACKEND__COMMON_H__
    55.6  
    55.7 -#include <linux/config.h>
    55.8  #include <linux/version.h>
    55.9  #include <linux/module.h>
   55.10  #include <linux/interrupt.h>
    56.1 --- a/linux-2.6-xen-sparse/drivers/xen/char/mem.c	Thu Mar 01 15:02:09 2007 -0700
    56.2 +++ b/linux-2.6-xen-sparse/drivers/xen/char/mem.c	Wed Mar 07 12:38:28 2007 -0700
    56.3 @@ -8,7 +8,6 @@
    56.4   *  Shared /dev/zero mmaping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com>
    56.5   */
    56.6  
    56.7 -#include <linux/config.h>
    56.8  #include <linux/mm.h>
    56.9  #include <linux/miscdevice.h>
   56.10  #include <linux/slab.h>
   56.11 @@ -195,7 +194,7 @@ static int open_mem(struct inode * inode
   56.12  	return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
   56.13  }
   56.14  
   56.15 -struct file_operations mem_fops = {
   56.16 +const struct file_operations mem_fops = {
   56.17  	.llseek		= memory_lseek,
   56.18  	.read		= read_mem,
   56.19  	.write		= write_mem,
    57.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Thu Mar 01 15:02:09 2007 -0700
    57.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Wed Mar 07 12:38:28 2007 -0700
    57.3 @@ -30,7 +30,6 @@
    57.4   * IN THE SOFTWARE.
    57.5   */
    57.6  
    57.7 -#include <linux/config.h>
    57.8  #include <linux/version.h>
    57.9  #include <linux/module.h>
   57.10  #include <linux/errno.h>
    58.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Thu Mar 01 15:02:09 2007 -0700
    58.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/cpu_hotplug.c	Wed Mar 07 12:38:28 2007 -0700
    58.3 @@ -1,4 +1,3 @@
    58.4 -#include <linux/config.h>
    58.5  #include <linux/init.h>
    58.6  #include <linux/kernel.h>
    58.7  #include <linux/sched.h>
    58.8 @@ -122,29 +121,19 @@ arch_initcall(setup_vcpu_hotplug_event);
    58.9  
   58.10  int smp_suspend(void)
   58.11  {
   58.12 -	int i, err;
   58.13 -
   58.14 -	lock_cpu_hotplug();
   58.15 +	int cpu, err;
   58.16  
   58.17 -	/*
   58.18 -	 * Take all other CPUs offline. We hold the hotplug mutex to
   58.19 -	 * avoid other processes bringing up CPUs under our feet.
   58.20 -	 */
   58.21 -	while (num_online_cpus() > 1) {
   58.22 -		unlock_cpu_hotplug();
   58.23 -		for_each_online_cpu(i) {
   58.24 -			if (i == 0)
   58.25 -				continue;
   58.26 -			err = cpu_down(i);
   58.27 -			if (err) {
   58.28 -				printk(KERN_CRIT "Failed to take all CPUs "
   58.29 -				       "down: %d.\n", err);
   58.30 -				for_each_possible_cpu(i)
   58.31 -					vcpu_hotplug(i);
   58.32 -				return err;
   58.33 -			}
   58.34 +	for_each_online_cpu(cpu) {
   58.35 +		if (cpu == 0)
   58.36 +			continue;
   58.37 +		err = cpu_down(cpu);
   58.38 +		if (err) {
   58.39 +			printk(KERN_CRIT "Failed to take all CPUs "
   58.40 +			       "down: %d.\n", err);
   58.41 +			for_each_possible_cpu(cpu)
   58.42 +				vcpu_hotplug(cpu);
   58.43 +			return err;
   58.44  		}
   58.45 -		lock_cpu_hotplug();
   58.46  	}
   58.47  
   58.48  	return 0;
   58.49 @@ -155,11 +144,6 @@ void smp_resume(void)
   58.50  	int cpu;
   58.51  
   58.52  	for_each_possible_cpu(cpu)
   58.53 -		cpu_initialize_context(cpu);
   58.54 -
   58.55 -	unlock_cpu_hotplug();
   58.56 -
   58.57 -	for_each_possible_cpu(cpu)
   58.58  		vcpu_hotplug(cpu);
   58.59  }
   58.60  
    59.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Thu Mar 01 15:02:09 2007 -0700
    59.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Mar 07 12:38:28 2007 -0700
    59.3 @@ -30,7 +30,6 @@
    59.4   * IN THE SOFTWARE.
    59.5   */
    59.6  
    59.7 -#include <linux/config.h>
    59.8  #include <linux/module.h>
    59.9  #include <linux/irq.h>
   59.10  #include <linux/interrupt.h>
   59.11 @@ -889,11 +888,67 @@ void unmask_evtchn(int port)
   59.12  }
   59.13  EXPORT_SYMBOL_GPL(unmask_evtchn);
   59.14  
   59.15 -void irq_resume(void)
   59.16 +static void restore_cpu_virqs(int cpu)
   59.17  {
   59.18  	struct evtchn_bind_virq bind_virq;
   59.19 -	struct evtchn_bind_ipi  bind_ipi;
   59.20 -	int cpu, pirq, virq, ipi, irq, evtchn;
   59.21 +	int virq, irq, evtchn;
   59.22 +
   59.23 +	for (virq = 0; virq < NR_VIRQS; virq++) {
   59.24 +		if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1)
   59.25 +			continue;
   59.26 +
   59.27 +		BUG_ON(irq_info[irq] != mk_irq_info(IRQT_VIRQ, virq, 0));
   59.28 +
   59.29 +		/* Get a new binding from Xen. */
   59.30 +		bind_virq.virq = virq;
   59.31 +		bind_virq.vcpu = cpu;
   59.32 +		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
   59.33 +						&bind_virq) != 0)
   59.34 +			BUG();
   59.35 +		evtchn = bind_virq.port;
   59.36 +
   59.37 +		/* Record the new mapping. */
   59.38 +		evtchn_to_irq[evtchn] = irq;
   59.39 +		irq_info[irq] = mk_irq_info(IRQT_VIRQ, virq, evtchn);
   59.40 +		bind_evtchn_to_cpu(evtchn, cpu);
   59.41 +
   59.42 +		/* Ready for use. */
   59.43 +		unmask_evtchn(evtchn);
   59.44 +	}
   59.45 +}
   59.46 +
   59.47 +static void restore_cpu_ipis(int cpu)
   59.48 +{
   59.49 +	struct evtchn_bind_ipi bind_ipi;
   59.50 +	int ipi, irq, evtchn;
   59.51 +
   59.52 +	for (ipi = 0; ipi < NR_IPIS; ipi++) {
   59.53 +		if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1)
   59.54 +			continue;
   59.55 +
   59.56 +		BUG_ON(irq_info[irq] != mk_irq_info(IRQT_IPI, ipi, 0));
   59.57 +
   59.58 +		/* Get a new binding from Xen. */
   59.59 +		bind_ipi.vcpu = cpu;
   59.60 +		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
   59.61 +						&bind_ipi) != 0)
   59.62 +			BUG();
   59.63 +		evtchn = bind_ipi.port;
   59.64 +
   59.65 +		/* Record the new mapping. */
   59.66 +		evtchn_to_irq[evtchn] = irq;
   59.67 +		irq_info[irq] = mk_irq_info(IRQT_IPI, ipi, evtchn);
   59.68 +		bind_evtchn_to_cpu(evtchn, cpu);
   59.69 +
   59.70 +		/* Ready for use. */
   59.71 +		unmask_evtchn(evtchn);
   59.72 +
   59.73 +	}
   59.74 +}
   59.75 +
   59.76 +void irq_resume(void)
   59.77 +{
   59.78 +	int cpu, pirq, irq, evtchn;
   59.79  
   59.80  	init_evtchn_cpu_bindings();
   59.81  
   59.82 @@ -905,66 +960,17 @@ void irq_resume(void)
   59.83  	for (pirq = 0; pirq < NR_PIRQS; pirq++)
   59.84  		BUG_ON(irq_info[pirq_to_irq(pirq)] != IRQ_UNBOUND);
   59.85  
   59.86 -	/* Secondary CPUs must have no VIRQ or IPI bindings. */
   59.87 -	for_each_possible_cpu(cpu) {
   59.88 -		if (cpu == 0)
   59.89 -			continue;
   59.90 -		for (virq = 0; virq < NR_VIRQS; virq++)
   59.91 -			BUG_ON(per_cpu(virq_to_irq, cpu)[virq] != -1);
   59.92 -		for (ipi = 0; ipi < NR_IPIS; ipi++)
   59.93 -			BUG_ON(per_cpu(ipi_to_irq, cpu)[ipi] != -1);
   59.94 -	}
   59.95 -
   59.96  	/* No IRQ <-> event-channel mappings. */
   59.97  	for (irq = 0; irq < NR_IRQS; irq++)
   59.98  		irq_info[irq] &= ~0xFFFF; /* zap event-channel binding */
   59.99  	for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++)
  59.100  		evtchn_to_irq[evtchn] = -1;
  59.101  
  59.102 -	/* Primary CPU: rebind VIRQs automatically. */
  59.103 -	for (virq = 0; virq < NR_VIRQS; virq++) {
  59.104 -		if ((irq = per_cpu(virq_to_irq, 0)[virq]) == -1)
  59.105 -			continue;
  59.106 -
  59.107 -		BUG_ON(irq_info[irq] != mk_irq_info(IRQT_VIRQ, virq, 0));
  59.108 -
  59.109 -		/* Get a new binding from Xen. */
  59.110 -		bind_virq.virq = virq;
  59.111 -		bind_virq.vcpu = 0;
  59.112 -		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq,
  59.113 -						&bind_virq) != 0)
  59.114 -			BUG();
  59.115 -		evtchn = bind_virq.port;
  59.116 -
  59.117 -		/* Record the new mapping. */
  59.118 -		evtchn_to_irq[evtchn] = irq;
  59.119 -		irq_info[irq] = mk_irq_info(IRQT_VIRQ, virq, evtchn);
  59.120 -
  59.121 -		/* Ready for use. */
  59.122 -		unmask_evtchn(evtchn);
  59.123 +	for_each_possible_cpu(cpu) {
  59.124 +		restore_cpu_virqs(cpu);
  59.125 +		restore_cpu_ipis(cpu);
  59.126  	}
  59.127  
  59.128 -	/* Primary CPU: rebind IPIs automatically. */
  59.129 -	for (ipi = 0; ipi < NR_IPIS; ipi++) {
  59.130 -		if ((irq = per_cpu(ipi_to_irq, 0)[ipi]) == -1)
  59.131 -			continue;
  59.132 -
  59.133 -		BUG_ON(irq_info[irq] != mk_irq_info(IRQT_IPI, ipi, 0));
  59.134 -
  59.135 -		/* Get a new binding from Xen. */
  59.136 -		bind_ipi.vcpu = 0;
  59.137 -		if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi,
  59.138 -						&bind_ipi) != 0)
  59.139 -			BUG();
  59.140 -		evtchn = bind_ipi.port;
  59.141 -
  59.142 -		/* Record the new mapping. */
  59.143 -		evtchn_to_irq[evtchn] = irq;
  59.144 -		irq_info[irq] = mk_irq_info(IRQT_IPI, ipi, evtchn);
  59.145 -
  59.146 -		/* Ready for use. */
  59.147 -		unmask_evtchn(evtchn);
  59.148 -	}
  59.149  }
  59.150  
  59.151  void __init xen_init_IRQ(void)
    60.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Thu Mar 01 15:02:09 2007 -0700
    60.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Mar 07 12:38:28 2007 -0700
    60.3 @@ -31,7 +31,6 @@
    60.4   * IN THE SOFTWARE.
    60.5   */
    60.6  
    60.7 -#include <linux/config.h>
    60.8  #include <linux/module.h>
    60.9  #include <linux/sched.h>
   60.10  #include <linux/mm.h>
   60.11 @@ -518,25 +517,26 @@ int gnttab_suspend(void)
   60.12  static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
   60.13  {
   60.14  	struct xen_add_to_physmap xatp;
   60.15 -	unsigned int i;
   60.16 +	unsigned int i = end_idx;
   60.17  
   60.18  	/* Loop backwards, so that the first hypercall has the largest index,
   60.19  	 * ensuring that the table will grow only once.
   60.20  	 */
   60.21 -	for (i = end_idx; i >= start_idx; i--) {
   60.22 +	do {
   60.23  		xatp.domid = DOMID_SELF;
   60.24  		xatp.idx = i;
   60.25  		xatp.space = XENMAPSPACE_grant_table;
   60.26  		xatp.gpfn = (resume_frames >> PAGE_SHIFT) + i;
   60.27  		if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
   60.28  			BUG();
   60.29 -	}
   60.30 +	} while (i-- > start_idx);
   60.31 +
   60.32 +	return 0;
   60.33  }
   60.34  
   60.35  int gnttab_resume(void)
   60.36  {
   60.37 -	struct xen_add_to_physmap xatp;
   60.38 -	unsigned int i, max_nr_gframes, nr_gframes;
   60.39 +	unsigned int max_nr_gframes, nr_gframes;
   60.40  
   60.41  	nr_gframes = nr_grant_frames;
   60.42  	max_nr_gframes = max_nr_grant_frames();
    61.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c	Thu Mar 01 15:02:09 2007 -0700
    61.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c	Wed Mar 07 12:38:28 2007 -0700
    61.3 @@ -7,7 +7,6 @@
    61.4   *  published by the Free Software Foundation.
    61.5   */
    61.6  
    61.7 -#include <linux/config.h>
    61.8  #include <linux/kernel.h>
    61.9  #include <linux/module.h>
   61.10  #include <linux/kobject.h>
    62.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Thu Mar 01 15:02:09 2007 -0700
    62.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Wed Mar 07 12:38:28 2007 -0700
    62.3 @@ -1,4 +1,3 @@
    62.4 -#define __KERNEL_SYSCALLS__
    62.5  #include <linux/version.h>
    62.6  #include <linux/kernel.h>
    62.7  #include <linux/mm.h>
    62.8 @@ -7,6 +6,7 @@
    62.9  #include <linux/reboot.h>
   62.10  #include <linux/sysrq.h>
   62.11  #include <linux/stringify.h>
   62.12 +#include <linux/stop_machine.h>
   62.13  #include <asm/irq.h>
   62.14  #include <asm/mmu_context.h>
   62.15  #include <xen/evtchn.h>
   62.16 @@ -18,6 +18,7 @@
   62.17  #include <xen/gnttab.h>
   62.18  #include <xen/xencons.h>
   62.19  #include <xen/cpu_hotplug.h>
   62.20 +#include <xen/interface/vcpu.h>
   62.21  
   62.22  #if defined(__i386__) || defined(__x86_64__)
   62.23  
   62.24 @@ -58,27 +59,11 @@ EXPORT_SYMBOL(machine_restart);
   62.25  EXPORT_SYMBOL(machine_halt);
   62.26  EXPORT_SYMBOL(machine_power_off);
   62.27  
   62.28 -/* Ensure we run on the idle task page tables so that we will
   62.29 -   switch page tables before running user space. This is needed
   62.30 -   on architectures with separate kernel and user page tables
   62.31 -   because the user page table pointer is not saved/restored. */
   62.32 -static void switch_idle_mm(void)
   62.33 -{
   62.34 -	struct mm_struct *mm = current->active_mm;
   62.35 -
   62.36 -	if (mm == &init_mm)
   62.37 -		return;
   62.38 -
   62.39 -	atomic_inc(&init_mm.mm_count);
   62.40 -	switch_mm(mm, &init_mm, current);
   62.41 -	current->active_mm = &init_mm;
   62.42 -	mmdrop(mm);
   62.43 -}
   62.44 -
   62.45  static void pre_suspend(void)
   62.46  {
   62.47  	HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
   62.48 -	clear_fixmap(FIX_SHARED_INFO);
   62.49 +	HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO),
   62.50 +				     __pte_ma(0), 0);
   62.51  
   62.52  	xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
   62.53  	xen_start_info->console.domU.mfn =
   62.54 @@ -88,6 +73,7 @@ static void pre_suspend(void)
   62.55  static void post_suspend(int suspend_cancelled)
   62.56  {
   62.57  	int i, j, k, fpp;
   62.58 +	unsigned long shinfo_mfn;
   62.59  	extern unsigned long max_pfn;
   62.60  	extern unsigned long *pfn_to_mfn_frame_list_list;
   62.61  	extern unsigned long *pfn_to_mfn_frame_list[];
   62.62 @@ -97,10 +83,15 @@ static void post_suspend(int suspend_can
   62.63  			pfn_to_mfn(xen_start_info->store_mfn);
   62.64  		xen_start_info->console.domU.mfn =
   62.65  			pfn_to_mfn(xen_start_info->console.domU.mfn);
   62.66 +	} else {
   62.67 +#ifdef CONFIG_SMP
   62.68 +		cpu_initialized_map = cpumask_of_cpu(0);
   62.69 +#endif
   62.70  	}
   62.71 -	
   62.72 -	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
   62.73  
   62.74 +	shinfo_mfn = xen_start_info->shared_info >> PAGE_SHIFT;
   62.75 +	HYPERVISOR_update_va_mapping(fix_to_virt(FIX_SHARED_INFO),
   62.76 +				     pfn_pte_ma(shinfo_mfn, PAGE_KERNEL), 0);
   62.77  	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   62.78  
   62.79  	memset(empty_zero_page, 0, PAGE_SIZE);
   62.80 @@ -130,12 +121,87 @@ static void post_suspend(int suspend_can
   62.81  
   62.82  #endif
   62.83  
   62.84 -int __xen_suspend(void)
   62.85 +static int take_machine_down(void *p_fast_suspend)
   62.86 +{
   62.87 +	int fast_suspend = *(int *)p_fast_suspend;
   62.88 +	int suspend_cancelled, err, cpu;
   62.89 +	extern void time_resume(void);
   62.90 +
   62.91 +	if (fast_suspend) {
   62.92 +		preempt_disable();
   62.93 +	} else {
   62.94 +		for (;;) {
   62.95 +			err = smp_suspend();
   62.96 +			if (err)
   62.97 +				return err;
   62.98 +
   62.99 +			xenbus_suspend();
  62.100 +			preempt_disable();
  62.101 +
  62.102 +			if (num_online_cpus() == 1)
  62.103 +				break;
  62.104 +
  62.105 +			preempt_enable();
  62.106 +			xenbus_suspend_cancel();
  62.107 +		}
  62.108 +	}
  62.109 +
  62.110 +	mm_pin_all();
  62.111 +	local_irq_disable();
  62.112 +	preempt_enable();
  62.113 +	gnttab_suspend();
  62.114 +	pre_suspend();
  62.115 +
  62.116 +	/*
  62.117 +	 * This hypercall returns 1 if suspend was cancelled or the domain was
  62.118 +	 * merely checkpointed, and 0 if it is resuming in a new domain.
  62.119 +	 */
  62.120 +	suspend_cancelled = HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
  62.121 +
  62.122 +	post_suspend(suspend_cancelled);
  62.123 +	gnttab_resume();
  62.124 +	if (!suspend_cancelled) {
  62.125 +		irq_resume();
  62.126 +#ifdef __x86_64__
  62.127 +		/*
  62.128 +		 * Older versions of Xen do not save/restore the user %cr3.
  62.129 +		 * We do it here just in case, but there's no need if we are
  62.130 +		 * in fast-suspend mode as that implies a new enough Xen.
  62.131 +		 */
  62.132 +		if (!fast_suspend) {
  62.133 +			struct mmuext_op op;
  62.134 +			op.cmd = MMUEXT_NEW_USER_BASEPTR;
  62.135 +			op.arg1.mfn = pfn_to_mfn(__pa(__user_pgd(
  62.136 +				current->active_mm->pgd)) >> PAGE_SHIFT);
  62.137 +			if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
  62.138 +				BUG();
  62.139 +		}
  62.140 +#endif
  62.141 +	}
  62.142 +	time_resume();
  62.143 +	local_irq_enable();
  62.144 +
  62.145 +	if (fast_suspend && !suspend_cancelled) {
  62.146 +		/*
  62.147 +		 * In fast-suspend mode the APs may not be brought back online
  62.148 +		 * when we resume. In that case we do it here.
  62.149 +		 */
  62.150 +		for_each_online_cpu(cpu) {
  62.151 +			if (cpu == 0)
  62.152 +				continue;
  62.153 +			cpu_set_initialized(cpu);
  62.154 +			err = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL);
  62.155 +			BUG_ON(err);
  62.156 +		}
  62.157 +	}
  62.158 +
  62.159 +	return suspend_cancelled;
  62.160 +}
  62.161 +
  62.162 +int __xen_suspend(int fast_suspend)
  62.163  {
  62.164  	int err, suspend_cancelled;
  62.165  
  62.166 -	extern void time_resume(void);
  62.167 -
  62.168  	BUG_ON(smp_processor_id() != 0);
  62.169  	BUG_ON(in_interrupt());
  62.170  
  62.171 @@ -147,41 +213,21 @@ int __xen_suspend(void)
  62.172  	}
  62.173  #endif
  62.174  
  62.175 -	err = smp_suspend();
  62.176 -	if (err)
  62.177 +	/* If we are definitely UP then 'slow mode' is actually faster. */
  62.178 +	if (num_possible_cpus() == 1)
  62.179 +		fast_suspend = 0;
  62.180 +
  62.181 +	if (fast_suspend) {
  62.182 +		xenbus_suspend();
  62.183 +		err = stop_machine_run(take_machine_down, &fast_suspend, 0);
  62.184 +	} else {
  62.185 +		err = take_machine_down(&fast_suspend);
  62.186 +	}
  62.187 +
  62.188 +	if (err < 0)
  62.189  		return err;
  62.190  
  62.191 -	xenbus_suspend();
  62.192 -
  62.193 -	preempt_disable();
  62.194 -
  62.195 -	mm_pin_all();
  62.196 -	local_irq_disable();
  62.197 -	preempt_enable();
  62.198 -
  62.199 -	gnttab_suspend();
  62.200 -
  62.201 -	pre_suspend();
  62.202 -
  62.203 -	/*
  62.204 -	 * This hypercall returns 1 if suspend was cancelled or the domain was
  62.205 -	 * merely checkpointed, and 0 if it is resuming in a new domain.
  62.206 -	 */
  62.207 -	suspend_cancelled = HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
  62.208 -
  62.209 -	post_suspend(suspend_cancelled);
  62.210 -
  62.211 -	gnttab_resume();
  62.212 -
  62.213 -	if (!suspend_cancelled)
  62.214 -		irq_resume();
  62.215 -
  62.216 -	time_resume();
  62.217 -
  62.218 -	switch_idle_mm();
  62.219 -
  62.220 -	local_irq_enable();
  62.221 -
  62.222 +	suspend_cancelled = err;
  62.223  	if (!suspend_cancelled) {
  62.224  		xencons_resume();
  62.225  		xenbus_resume();
  62.226 @@ -189,7 +235,8 @@ int __xen_suspend(void)
  62.227  		xenbus_suspend_cancel();
  62.228  	}
  62.229  
  62.230 -	smp_resume();
  62.231 +	if (!fast_suspend)
  62.232 +		smp_resume();
  62.233  
  62.234 -	return err;
  62.235 +	return 0;
  62.236  }
    63.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Thu Mar 01 15:02:09 2007 -0700
    63.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Mar 07 12:38:28 2007 -0700
    63.3 @@ -24,13 +24,16 @@ MODULE_LICENSE("Dual BSD/GPL");
    63.4  /* Ignore multiple shutdown requests. */
    63.5  static int shutting_down = SHUTDOWN_INVALID;
    63.6  
    63.7 +/* Can we leave APs online when we suspend? */
    63.8 +static int fast_suspend;
    63.9 +
   63.10  static void __shutdown_handler(void *unused);
   63.11  static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
   63.12  
   63.13  #ifdef CONFIG_XEN
   63.14 -int __xen_suspend(void);
   63.15 +int __xen_suspend(int fast_suspend);
   63.16  #else
   63.17 -#define __xen_suspend() (void)0
   63.18 +#define __xen_suspend(fast_suspend) 0
   63.19  #endif
   63.20  
   63.21  static int shutdown_process(void *__unused)
   63.22 @@ -44,7 +47,8 @@ static int shutdown_process(void *__unus
   63.23  
   63.24  	if ((shutting_down == SHUTDOWN_POWEROFF) ||
   63.25  	    (shutting_down == SHUTDOWN_HALT)) {
   63.26 -		if (call_usermodehelper("/sbin/poweroff", poweroff_argv, envp, 0) < 0) {
   63.27 +		if (call_usermodehelper("/sbin/poweroff", poweroff_argv,
   63.28 +					envp, 0) < 0) {
   63.29  #ifdef CONFIG_XEN
   63.30  			sys_reboot(LINUX_REBOOT_MAGIC1,
   63.31  				   LINUX_REBOOT_MAGIC2,
   63.32 @@ -61,7 +65,9 @@ static int shutdown_process(void *__unus
   63.33  
   63.34  static int xen_suspend(void *__unused)
   63.35  {
   63.36 -	__xen_suspend();
   63.37 +	int err = __xen_suspend(fast_suspend);
   63.38 +	if (err)
   63.39 +		printk(KERN_ERR "Xen suspend failed (%d)\n", err);
   63.40  	shutting_down = SHUTDOWN_INVALID;
   63.41  	return 0;
   63.42  }
   63.43 @@ -193,6 +199,10 @@ static int setup_shutdown_watcher(struct
   63.44  {
   63.45  	int err;
   63.46  
   63.47 +	xenbus_scanf(XBT_NIL, "control",
   63.48 +		     "platform-feature-multiprocessor-suspend",
   63.49 +		     "%d", &fast_suspend);
   63.50 +
   63.51  	err = register_xenbus_watch(&shutdown_watch);
   63.52  	if (err)
   63.53  		printk(KERN_ERR "Failed to set shutdown watcher\n");
    64.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Thu Mar 01 15:02:09 2007 -0700
    64.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Wed Mar 07 12:38:28 2007 -0700
    64.3 @@ -6,7 +6,6 @@
    64.4   */
    64.5  
    64.6  #include <linux/module.h>
    64.7 -#include <linux/config.h>
    64.8  #include <linux/init.h>
    64.9  #include <linux/kernel.h>
   64.10  #include <linux/mm.h>
   64.11 @@ -48,7 +47,7 @@ cpumask_t cpu_online_map;
   64.12  EXPORT_SYMBOL(cpu_online_map);
   64.13  cpumask_t cpu_possible_map;
   64.14  EXPORT_SYMBOL(cpu_possible_map);
   64.15 -static cpumask_t cpu_initialized_map;
   64.16 +cpumask_t cpu_initialized_map;
   64.17  
   64.18  struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
   64.19  EXPORT_SYMBOL(cpu_data);
   64.20 @@ -186,7 +185,7 @@ static void cpu_bringup_and_idle(void)
   64.21  	cpu_idle();
   64.22  }
   64.23  
   64.24 -void cpu_initialize_context(unsigned int cpu)
   64.25 +static void cpu_initialize_context(unsigned int cpu)
   64.26  {
   64.27  	vcpu_guest_context_t ctxt;
   64.28  	struct task_struct *idle = idle_task(cpu);
   64.29 @@ -196,7 +195,7 @@ void cpu_initialize_context(unsigned int
   64.30  	struct Xgt_desc_struct *gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
   64.31  #endif
   64.32  
   64.33 -	if (cpu == 0)
   64.34 +	if (cpu_test_and_set(cpu, cpu_initialized_map))
   64.35  		return;
   64.36  
   64.37  	memset(&ctxt, 0, sizeof(ctxt));
   64.38 @@ -418,10 +417,7 @@ int __devinit __cpu_up(unsigned int cpu)
   64.39  	if (rc)
   64.40  		return rc;
   64.41  
   64.42 -	if (!cpu_isset(cpu, cpu_initialized_map)) {
   64.43 -		cpu_set(cpu, cpu_initialized_map);
   64.44 -		cpu_initialize_context(cpu);
   64.45 -	}
   64.46 +	cpu_initialize_context(cpu);
   64.47  
   64.48  	if (num_online_cpus() == 1)
   64.49  		alternatives_smp_switch(1);
    65.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c	Thu Mar 01 15:02:09 2007 -0700
    65.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_proc.c	Wed Mar 07 12:38:28 2007 -0700
    65.3 @@ -1,5 +1,4 @@
    65.4  
    65.5 -#include <linux/config.h>
    65.6  #include <linux/proc_fs.h>
    65.7  #include <xen/xen_proc.h>
    65.8  
    66.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Thu Mar 01 15:02:09 2007 -0700
    66.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c	Wed Mar 07 12:38:28 2007 -0700
    66.3 @@ -7,7 +7,6 @@
    66.4   *  published by the Free Software Foundation.
    66.5   */
    66.6  
    66.7 -#include <linux/config.h>
    66.8  #include <linux/err.h>
    66.9  #include <linux/kernel.h>
   66.10  #include <linux/module.h>
    67.1 --- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Thu Mar 01 15:02:09 2007 -0700
    67.2 +++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Wed Mar 07 12:38:28 2007 -0700
    67.3 @@ -31,7 +31,6 @@
    67.4   * IN THE SOFTWARE.
    67.5   */
    67.6  
    67.7 -#include <linux/config.h>
    67.8  #include <linux/module.h>
    67.9  #include <linux/kernel.h>
   67.10  #include <linux/sched.h>
   67.11 @@ -407,7 +406,7 @@ static int evtchn_release(struct inode *
   67.12  	return 0;
   67.13  }
   67.14  
   67.15 -static struct file_operations evtchn_fops = {
   67.16 +static const struct file_operations evtchn_fops = {
   67.17  	.owner   = THIS_MODULE,
   67.18  	.read    = evtchn_read,
   67.19  	.write   = evtchn_write,
    68.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Thu Mar 01 15:02:09 2007 -0700
    68.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Wed Mar 07 12:38:28 2007 -0700
    68.3 @@ -29,7 +29,6 @@
    68.4  #ifndef __NETIF__BACKEND__COMMON_H__
    68.5  #define __NETIF__BACKEND__COMMON_H__
    68.6  
    68.7 -#include <linux/config.h>
    68.8  #include <linux/version.h>
    68.9  #include <linux/module.h>
   68.10  #include <linux/interrupt.h>
   68.11 @@ -100,9 +99,21 @@ typedef struct netif_st {
   68.12  	struct net_device *dev;
   68.13  	struct net_device_stats stats;
   68.14  
   68.15 +	unsigned int carrier;
   68.16 +
   68.17  	wait_queue_head_t waiting_to_free;
   68.18  } netif_t;
   68.19  
   68.20 +/*
   68.21 + * Implement our own carrier flag: the network stack's version causes delays
   68.22 + * when the carrier is re-enabled (in particular, dev_activate() may not
   68.23 + * immediately be called, which can cause packet loss; also the etherbridge
   68.24 + * can be rather lazy in activating its port).
   68.25 + */
   68.26 +#define netback_carrier_on(netif)	((netif)->carrier = 1)
   68.27 +#define netback_carrier_off(netif)	((netif)->carrier = 0)
   68.28 +#define netback_carrier_ok(netif)	((netif)->carrier)
   68.29 +
   68.30  #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
   68.31  #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
   68.32  
   68.33 @@ -121,7 +132,8 @@ int netif_map(netif_t *netif, unsigned l
   68.34  
   68.35  void netif_xenbus_init(void);
   68.36  
   68.37 -#define netif_schedulable(dev) (netif_running(dev) && netif_carrier_ok(dev))
   68.38 +#define netif_schedulable(netif)				\
   68.39 +	(netif_running((netif)->dev) && netback_carrier_ok(netif))
   68.40  
   68.41  void netif_schedule_work(netif_t *netif);
   68.42  void netif_deschedule_work(netif_t *netif);
    69.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Mar 01 15:02:09 2007 -0700
    69.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Wed Mar 07 12:38:28 2007 -0700
    69.3 @@ -66,16 +66,19 @@ static void __netif_down(netif_t *netif)
    69.4  static int net_open(struct net_device *dev)
    69.5  {
    69.6  	netif_t *netif = netdev_priv(dev);
    69.7 -	if (netif_carrier_ok(dev))
    69.8 +	if (netback_carrier_ok(netif)) {
    69.9  		__netif_up(netif);
   69.10 +		netif_start_queue(dev);
   69.11 +	}
   69.12  	return 0;
   69.13  }
   69.14  
   69.15  static int net_close(struct net_device *dev)
   69.16  {
   69.17  	netif_t *netif = netdev_priv(dev);
   69.18 -	if (netif_carrier_ok(dev))
   69.19 +	if (netback_carrier_ok(netif))
   69.20  		__netif_down(netif);
   69.21 +	netif_stop_queue(dev);
   69.22  	return 0;
   69.23  }
   69.24  
   69.25 @@ -138,8 +141,6 @@ netif_t *netif_alloc(domid_t domid, unsi
   69.26  		return ERR_PTR(-ENOMEM);
   69.27  	}
   69.28  
   69.29 -	netif_carrier_off(dev);
   69.30 -
   69.31  	netif = netdev_priv(dev);
   69.32  	memset(netif, 0, sizeof(*netif));
   69.33  	netif->domid  = domid;
   69.34 @@ -148,6 +149,8 @@ netif_t *netif_alloc(domid_t domid, unsi
   69.35  	init_waitqueue_head(&netif->waiting_to_free);
   69.36  	netif->dev = dev;
   69.37  
   69.38 +	netback_carrier_off(netif);
   69.39 +
   69.40  	netif->credit_bytes = netif->remaining_credit = ~0UL;
   69.41  	netif->credit_usec  = 0UL;
   69.42  	init_timer(&netif->credit_timeout);
   69.43 @@ -285,7 +288,7 @@ int netif_map(netif_t *netif, unsigned l
   69.44  	netif_get(netif);
   69.45  
   69.46  	rtnl_lock();
   69.47 -	netif_carrier_on(netif->dev);
   69.48 +	netback_carrier_on(netif);
   69.49  	if (netif_running(netif->dev))
   69.50  		__netif_up(netif);
   69.51  	rtnl_unlock();
   69.52 @@ -302,9 +305,10 @@ err_rx:
   69.53  
   69.54  void netif_disconnect(netif_t *netif)
   69.55  {
   69.56 -	if (netif_carrier_ok(netif->dev)) {
   69.57 +	if (netback_carrier_ok(netif)) {
   69.58  		rtnl_lock();
   69.59 -		netif_carrier_off(netif->dev);
   69.60 +		netback_carrier_off(netif);
   69.61 +		netif_carrier_off(netif->dev); /* discard queued packets */
   69.62  		if (netif_running(netif->dev))
   69.63  			__netif_down(netif);
   69.64  		rtnl_unlock();
    70.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Thu Mar 01 15:02:09 2007 -0700
    70.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Wed Mar 07 12:38:28 2007 -0700
    70.3 @@ -45,7 +45,6 @@
    70.4   * IN THE SOFTWARE.
    70.5   */
    70.6  
    70.7 -#include <linux/config.h>
    70.8  #include <linux/module.h>
    70.9  #include <linux/netdevice.h>
   70.10  #include <linux/inetdevice.h>
    71.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Mar 01 15:02:09 2007 -0700
    71.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Mar 07 12:38:28 2007 -0700
    71.3 @@ -38,7 +38,10 @@
    71.4  #include <xen/balloon.h>
    71.5  #include <xen/interface/memory.h>
    71.6  
    71.7 -/*#define NETBE_DEBUG_INTERRUPT*/
    71.8 +/*define NETBE_DEBUG_INTERRUPT*/
    71.9 +
   71.10 +/* extra field used in struct page */
   71.11 +#define netif_page_index(pg) (*(long *)&(pg)->mapping)
   71.12  
   71.13  struct netbk_rx_meta {
   71.14  	skb_frag_t frag;
   71.15 @@ -231,7 +234,7 @@ static inline int netbk_queue_full(netif
   71.16  static void tx_queue_callback(unsigned long data)
   71.17  {
   71.18  	netif_t *netif = (netif_t *)data;
   71.19 -	if (netif_schedulable(netif->dev))
   71.20 +	if (netif_schedulable(netif))
   71.21  		netif_wake_queue(netif->dev);
   71.22  }
   71.23  
   71.24 @@ -242,7 +245,7 @@ int netif_be_start_xmit(struct sk_buff *
   71.25  	BUG_ON(skb->dev != dev);
   71.26  
   71.27  	/* Drop the packet if the target domain has no receive buffers. */
   71.28 -	if (unlikely(!netif_schedulable(dev) || netbk_queue_full(netif)))
   71.29 +	if (unlikely(!netif_schedulable(netif) || netbk_queue_full(netif)))
   71.30  		goto drop;
   71.31  
   71.32  	/*
   71.33 @@ -352,7 +355,7 @@ static u16 netbk_gop_frag(netif_t *netif
   71.34  		copy_gop->flags = GNTCOPY_dest_gref;
   71.35  		if (PageForeign(page)) {
   71.36  			struct pending_tx_info *src_pend =
   71.37 -				&pending_tx_info[page->index];
   71.38 +				&pending_tx_info[netif_page_index(page)];
   71.39  			copy_gop->source.domid = src_pend->netif->domid;
   71.40  			copy_gop->source.u.ref = src_pend->req.gref;
   71.41  			copy_gop->flags |= GNTCOPY_source_gref;
   71.42 @@ -681,7 +684,7 @@ static void net_rx_action(unsigned long 
   71.43  		}
   71.44  
   71.45  		if (netif_queue_stopped(netif->dev) &&
   71.46 -		    netif_schedulable(netif->dev) &&
   71.47 +		    netif_schedulable(netif) &&
   71.48  		    !netbk_queue_full(netif))
   71.49  			netif_wake_queue(netif->dev);
   71.50  
   71.51 @@ -739,7 +742,7 @@ static void add_to_net_schedule_list_tai
   71.52  
   71.53  	spin_lock_irq(&net_schedule_list_lock);
   71.54  	if (!__on_net_schedule_list(netif) &&
   71.55 -	    likely(netif_schedulable(netif->dev))) {
   71.56 +	    likely(netif_schedulable(netif))) {
   71.57  		list_add_tail(&netif->list, &net_schedule_list);
   71.58  		netif_get(netif);
   71.59  	}
   71.60 @@ -1327,7 +1330,7 @@ static void netif_page_release(struct pa
   71.61  	/* Ready for next use. */
   71.62  	init_page_count(page);
   71.63  
   71.64 -	netif_idx_release(page->index);
   71.65 +	netif_idx_release(netif_page_index(page));
   71.66  }
   71.67  
   71.68  irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs)
   71.69 @@ -1337,7 +1340,7 @@ irqreturn_t netif_be_int(int irq, void *
   71.70  	add_to_net_schedule_list_tail(netif);
   71.71  	maybe_schedule_tx_action();
   71.72  
   71.73 -	if (netif_schedulable(netif->dev) && !netbk_queue_full(netif))
   71.74 +	if (netif_schedulable(netif) && !netbk_queue_full(netif))
   71.75  		netif_wake_queue(netif->dev);
   71.76  
   71.77  	return IRQ_HANDLED;
   71.78 @@ -1457,7 +1460,7 @@ static int __init netback_init(void)
   71.79  	for (i = 0; i < MAX_PENDING_REQS; i++) {
   71.80  		page = mmap_pages[i];
   71.81  		SetPageForeign(page, netif_page_release);
   71.82 -		page->index = i;
   71.83 +		netif_page_index(page) = i;
   71.84  	}
   71.85  
   71.86  	pending_cons = 0;
    72.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Thu Mar 01 15:02:09 2007 -0700
    72.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Wed Mar 07 12:38:28 2007 -0700
    72.3 @@ -338,9 +338,7 @@ static void connect(struct backend_info 
    72.4  
    72.5  	xenbus_switch_state(dev, XenbusStateConnected);
    72.6  
    72.7 -	/* May not get a kick from the frontend, so start the tx_queue now. */
    72.8 -	if (!netbk_can_queue(be->netif->dev))
    72.9 -		netif_wake_queue(be->netif->dev);
   72.10 +	netif_wake_queue(be->netif->dev);
   72.11  }
   72.12  
   72.13  
    73.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu Mar 01 15:02:09 2007 -0700
    73.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Mar 07 12:38:28 2007 -0700
    73.3 @@ -29,7 +29,6 @@
    73.4   * IN THE SOFTWARE.
    73.5   */
    73.6  
    73.7 -#include <linux/config.h>
    73.8  #include <linux/module.h>
    73.9  #include <linux/version.h>
   73.10  #include <linux/kernel.h>
   73.11 @@ -155,6 +154,7 @@ struct netfront_info {
   73.12  
   73.13  	unsigned int irq;
   73.14  	unsigned int copying_receiver;
   73.15 +	unsigned int carrier;
   73.16  
   73.17  	/* Receive-ring batched refills. */
   73.18  #define RX_MIN_TARGET 8
   73.19 @@ -194,6 +194,15 @@ struct netfront_rx_info {
   73.20  };
   73.21  
   73.22  /*
   73.23 + * Implement our own carrier flag: the network stack's version causes delays
   73.24 + * when the carrier is re-enabled (in particular, dev_activate() may not
   73.25 + * immediately be called, which can cause packet loss).
   73.26 + */
   73.27 +#define netfront_carrier_on(netif)	((netif)->carrier = 1)
   73.28 +#define netfront_carrier_off(netif)	((netif)->carrier = 0)
   73.29 +#define netfront_carrier_ok(netif)	((netif)->carrier)
   73.30 +
   73.31 +/*
   73.32   * Access macros for acquiring freeing slots in tx_skbs[].
   73.33   */
   73.34  
   73.35 @@ -591,26 +600,6 @@ static int send_fake_arp(struct net_devi
   73.36  	return dev_queue_xmit(skb);
   73.37  }
   73.38  
   73.39 -static int network_open(struct net_device *dev)
   73.40 -{
   73.41 -	struct netfront_info *np = netdev_priv(dev);
   73.42 -
   73.43 -	memset(&np->stats, 0, sizeof(np->stats));
   73.44 -
   73.45 -	spin_lock(&np->rx_lock);
   73.46 -	if (netif_carrier_ok(dev)) {
   73.47 -		network_alloc_rx_buffers(dev);
   73.48 -		np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
   73.49 -		if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
   73.50 -			netif_rx_schedule(dev);
   73.51 -	}
   73.52 -	spin_unlock(&np->rx_lock);
   73.53 -
   73.54 -	netif_start_queue(dev);
   73.55 -
   73.56 -	return 0;
   73.57 -}
   73.58 -
   73.59  static inline int netfront_tx_slot_available(struct netfront_info *np)
   73.60  {
   73.61  	return ((np->tx.req_prod_pvt - np->tx.rsp_cons) <
   73.62 @@ -627,6 +616,26 @@ static inline void network_maybe_wake_tx
   73.63  		netif_wake_queue(dev);
   73.64  }
   73.65  
   73.66 +static int network_open(struct net_device *dev)
   73.67 +{
   73.68 +	struct netfront_info *np = netdev_priv(dev);
   73.69 +
   73.70 +	memset(&np->stats, 0, sizeof(np->stats));
   73.71 +
   73.72 +	spin_lock(&np->rx_lock);
   73.73 +	if (netfront_carrier_ok(np)) {
   73.74 +		network_alloc_rx_buffers(dev);
   73.75 +		np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
   73.76 +		if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
   73.77 +			netif_rx_schedule(dev);
   73.78 +	}
   73.79 +	spin_unlock(&np->rx_lock);
   73.80 +
   73.81 +	network_maybe_wake_tx(dev);
   73.82 +
   73.83 +	return 0;
   73.84 +}
   73.85 +
   73.86  static void network_tx_buf_gc(struct net_device *dev)
   73.87  {
   73.88  	RING_IDX cons, prod;
   73.89 @@ -634,7 +643,7 @@ static void network_tx_buf_gc(struct net
   73.90  	struct netfront_info *np = netdev_priv(dev);
   73.91  	struct sk_buff *skb;
   73.92  
   73.93 -	BUG_ON(!netif_carrier_ok(dev));
   73.94 +	BUG_ON(!netfront_carrier_ok(np));
   73.95  
   73.96  	do {
   73.97  		prod = np->tx.sring->rsp_prod;
   73.98 @@ -704,7 +713,7 @@ static void network_alloc_rx_buffers(str
   73.99  	int nr_flips;
  73.100  	netif_rx_request_t *req;
  73.101  
  73.102 -	if (unlikely(!netif_carrier_ok(dev)))
  73.103 +	if (unlikely(!netfront_carrier_ok(np)))
  73.104  		return;
  73.105  
  73.106  	/*
  73.107 @@ -935,7 +944,7 @@ static int network_start_xmit(struct sk_
  73.108  
  73.109  	spin_lock_irq(&np->tx_lock);
  73.110  
  73.111 -	if (unlikely(!netif_carrier_ok(dev) ||
  73.112 +	if (unlikely(!netfront_carrier_ok(np) ||
  73.113  		     (frags > 1 && !xennet_can_sg(dev)) ||
  73.114  		     netif_needs_gso(dev, skb))) {
  73.115  		spin_unlock_irq(&np->tx_lock);
  73.116 @@ -1025,7 +1034,7 @@ static irqreturn_t netif_int(int irq, vo
  73.117  
  73.118  	spin_lock_irqsave(&np->tx_lock, flags);
  73.119  
  73.120 -	if (likely(netif_carrier_ok(dev))) {
  73.121 +	if (likely(netfront_carrier_ok(np))) {
  73.122  		network_tx_buf_gc(dev);
  73.123  		/* Under tx_lock: protects access to rx shared-ring indexes. */
  73.124  		if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
  73.125 @@ -1300,7 +1309,7 @@ static int netif_poll(struct net_device 
  73.126  
  73.127  	spin_lock(&np->rx_lock);
  73.128  
  73.129 -	if (unlikely(!netif_carrier_ok(dev))) {
  73.130 +	if (unlikely(!netfront_carrier_ok(np))) {
  73.131  		spin_unlock(&np->rx_lock);
  73.132  		return 0;
  73.133  	}
  73.134 @@ -1318,7 +1327,7 @@ static int netif_poll(struct net_device 
  73.135  	work_done = 0;
  73.136  	while ((i != rp) && (work_done < budget)) {
  73.137  		memcpy(rx, RING_GET_RESPONSE(&np->rx, i), sizeof(*rx));
  73.138 -		memset(extras, 0, sizeof(extras));
  73.139 +		memset(extras, 0, sizeof(rinfo.extras));
  73.140  
  73.141  		err = xennet_get_responses(np, &rinfo, rp, &tmpq,
  73.142  					   &pages_flipped);
  73.143 @@ -1745,7 +1754,7 @@ static int network_connect(struct net_de
  73.144  	 * domain a kick because we've probably just requeued some
  73.145  	 * packets.
  73.146  	 */
  73.147 -	netif_carrier_on(dev);
  73.148 +	netfront_carrier_on(np);
  73.149  	notify_remote_via_irq(np->irq);
  73.150  	network_tx_buf_gc(dev);
  73.151  	network_alloc_rx_buffers(dev);
  73.152 @@ -1990,7 +1999,7 @@ static struct net_device * __devinit cre
  73.153  
  73.154  	np->netdev = netdev;
  73.155  
  73.156 -	netif_carrier_off(netdev);
  73.157 +	netfront_carrier_off(np);
  73.158  
  73.159  	return netdev;
  73.160  
  73.161 @@ -2024,7 +2033,7 @@ static void netif_disconnect_backend(str
  73.162  	/* Stop old i/f to prevent errors whilst we rebuild the state. */
  73.163  	spin_lock_irq(&info->tx_lock);
  73.164  	spin_lock(&info->rx_lock);
  73.165 -	netif_carrier_off(info->netdev);
  73.166 +	netfront_carrier_off(info);
  73.167  	spin_unlock(&info->rx_lock);
  73.168  	spin_unlock_irq(&info->tx_lock);
  73.169  
    74.1 --- a/linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c	Thu Mar 01 15:02:09 2007 -0700
    74.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pcifront/pci_op.c	Wed Mar 07 12:38:28 2007 -0700
    74.3 @@ -239,17 +239,12 @@ static void free_root_bus_devs(struct pc
    74.4  {
    74.5  	struct pci_dev *dev;
    74.6  
    74.7 -	down_write(&pci_bus_sem);
    74.8  	while (!list_empty(&bus->devices)) {
    74.9 -		dev = container_of(bus->devices.next, struct pci_dev, bus_list);
   74.10 -		up_write(&pci_bus_sem);
   74.11 -
   74.12 +		dev = container_of(bus->devices.next, struct pci_dev,
   74.13 +				   bus_list);
   74.14  		dev_dbg(&dev->dev, "removing device\n");
   74.15  		pci_remove_bus_device(dev);
   74.16 -
   74.17 -		down_write(&pci_bus_sem);
   74.18  	}
   74.19 -	up_write(&pci_bus_sem);
   74.20  }
   74.21  
   74.22  void pcifront_free_roots(struct pcifront_device *pdev)
    75.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Mar 01 15:02:09 2007 -0700
    75.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Mar 07 12:38:28 2007 -0700
    75.3 @@ -6,7 +6,6 @@
    75.4   * Copyright (c) 2002-2004, K A Fraser, B Dragovic
    75.5   */
    75.6  
    75.7 -#include <linux/config.h>
    75.8  #include <linux/kernel.h>
    75.9  #include <linux/sched.h>
   75.10  #include <linux/slab.h>
   75.11 @@ -249,7 +248,7 @@ static int privcmd_enforce_singleshot_ma
   75.12  }
   75.13  #endif
   75.14  
   75.15 -static struct file_operations privcmd_file_ops = {
   75.16 +static const struct file_operations privcmd_file_ops = {
   75.17  	.ioctl = privcmd_ioctl,
   75.18  	.mmap  = privcmd_mmap,
   75.19  };
    76.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h	Thu Mar 01 15:02:09 2007 -0700
    76.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h	Wed Mar 07 12:38:28 2007 -0700
    76.3 @@ -2,10 +2,9 @@
    76.4   * drivers/xen/tpmback/common.h
    76.5   */
    76.6  
    76.7 -#ifndef __NETIF__BACKEND__COMMON_H__
    76.8 -#define __NETIF__BACKEND__COMMON_H__
    76.9 +#ifndef __TPM__BACKEND__COMMON_H__
   76.10 +#define __TPM__BACKEND__COMMON_H__
   76.11  
   76.12 -#include <linux/config.h>
   76.13  #include <linux/version.h>
   76.14  #include <linux/module.h>
   76.15  #include <linux/interrupt.h>
    77.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Thu Mar 01 15:02:09 2007 -0700
    77.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Wed Mar 07 12:38:28 2007 -0700
    77.3 @@ -629,7 +629,7 @@ static unsigned int vtpm_op_poll(struct 
    77.4  	return flags;
    77.5  }
    77.6  
    77.7 -static struct file_operations vtpm_ops = {
    77.8 +static const struct file_operations vtpm_ops = {
    77.9  	.owner = THIS_MODULE,
   77.10  	.llseek = no_llseek,
   77.11  	.open = vtpm_op_open,
    78.1 --- a/linux-2.6-xen-sparse/drivers/xen/util.c	Thu Mar 01 15:02:09 2007 -0700
    78.2 +++ b/linux-2.6-xen-sparse/drivers/xen/util.c	Wed Mar 07 12:38:28 2007 -0700
    78.3 @@ -1,4 +1,3 @@
    78.4 -#include <linux/config.h>
    78.5  #include <linux/mm.h>
    78.6  #include <linux/module.h>
    78.7  #include <linux/slab.h>
    79.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Thu Mar 01 15:02:09 2007 -0700
    79.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Mar 07 12:38:28 2007 -0700
    79.3 @@ -137,6 +137,17 @@ int xb_write(const void *data, unsigned 
    79.4  	return 0;
    79.5  }
    79.6  
    79.7 +int xb_data_to_read(void)
    79.8 +{
    79.9 +	struct xenstore_domain_interface *intf = xen_store_interface;
   79.10 +	return (intf->rsp_cons != intf->rsp_prod);
   79.11 +}
   79.12 +
   79.13 +int xb_wait_for_data_to_read(void)
   79.14 +{
   79.15 +	return wait_event_interruptible(xb_waitq, xb_data_to_read());
   79.16 +}
   79.17 +
   79.18  int xb_read(void *data, unsigned len)
   79.19  {
   79.20  	struct xenstore_domain_interface *intf = xen_store_interface;
   79.21 @@ -147,9 +158,7 @@ int xb_read(void *data, unsigned len)
   79.22  		unsigned int avail;
   79.23  		const char *src;
   79.24  
   79.25 -		rc = wait_event_interruptible(
   79.26 -			xb_waitq,
   79.27 -			intf->rsp_cons != intf->rsp_prod);
   79.28 +		rc = xb_wait_for_data_to_read();
   79.29  		if (rc < 0)
   79.30  			return rc;
   79.31  
   79.32 @@ -191,8 +200,20 @@ int xb_read(void *data, unsigned len)
   79.33  /* Set up interrupt handler off store event channel. */
   79.34  int xb_init_comms(void)
   79.35  {
   79.36 +	struct xenstore_domain_interface *intf = xen_store_interface;
   79.37  	int err;
   79.38  
   79.39 +	if (intf->req_prod != intf->req_cons)
   79.40 +		printk(KERN_ERR "XENBUS request ring is not quiescent "
   79.41 +		       "(%08x:%08x)!\n", intf->req_cons, intf->req_prod);
   79.42 +
   79.43 +	if (intf->rsp_prod != intf->rsp_cons) {
   79.44 +		printk(KERN_WARNING "XENBUS response ring is not quiescent "
   79.45 +		       "(%08x:%08x): fixing up\n",
   79.46 +		       intf->rsp_cons, intf->rsp_prod);
   79.47 +		intf->rsp_cons = intf->rsp_prod;
   79.48 +	}
   79.49 +
   79.50  	if (xenbus_irq)
   79.51  		unbind_from_irqhandler(xenbus_irq, &xb_waitq);
   79.52  
    80.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h	Thu Mar 01 15:02:09 2007 -0700
    80.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h	Wed Mar 07 12:38:28 2007 -0700
    80.3 @@ -37,6 +37,8 @@ int xb_init_comms(void);
    80.4  /* Low level routines. */
    80.5  int xb_write(const void *data, unsigned len);
    80.6  int xb_read(void *data, unsigned len);
    80.7 +int xb_data_to_read(void);
    80.8 +int xb_wait_for_data_to_read(void);
    80.9  int xs_input_avail(void);
   80.10  extern struct xenstore_domain_interface *xen_store_interface;
   80.11  extern int xen_store_evtchn;
    81.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Thu Mar 01 15:02:09 2007 -0700
    81.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c	Wed Mar 07 12:38:28 2007 -0700
    81.3 @@ -32,7 +32,6 @@
    81.4   * IN THE SOFTWARE.
    81.5   */
    81.6  
    81.7 -#include <linux/config.h>
    81.8  #include <linux/kernel.h>
    81.9  #include <linux/errno.h>
   81.10  #include <linux/uio.h>
   81.11 @@ -174,17 +173,22 @@ static ssize_t xenbus_dev_write(struct f
   81.12  	void *reply;
   81.13  	char *path, *token;
   81.14  	struct watch_adapter *watch, *tmp_watch;
   81.15 -	int err;
   81.16 +	int err, rc = len;
   81.17  
   81.18 -	if ((len + u->len) > sizeof(u->u.buffer))
   81.19 -		return -EINVAL;
   81.20 +	if ((len + u->len) > sizeof(u->u.buffer)) {
   81.21 +		rc = -EINVAL;
   81.22 +		goto out;
   81.23 +	}
   81.24  
   81.25 -	if (copy_from_user(u->u.buffer + u->len, ubuf, len) != 0)
   81.26 -		return -EFAULT;
   81.27 +	if (copy_from_user(u->u.buffer + u->len, ubuf, len) != 0) {
   81.28 +		rc = -EFAULT;
   81.29 +		goto out;
   81.30 +	}
   81.31  
   81.32  	u->len += len;
   81.33 -	if (u->len < (sizeof(u->u.msg) + u->u.msg.len))
   81.34 -		return len;
   81.35 +	if ((u->len < sizeof(u->u.msg)) ||
   81.36 +	    (u->len < (sizeof(u->u.msg) + u->u.msg.len)))
   81.37 +		return rc;
   81.38  
   81.39  	msg_type = u->u.msg.type;
   81.40  
   81.41 @@ -202,14 +206,17 @@ static ssize_t xenbus_dev_write(struct f
   81.42  	case XS_SET_PERMS:
   81.43  		if (msg_type == XS_TRANSACTION_START) {
   81.44  			trans = kmalloc(sizeof(*trans), GFP_KERNEL);
   81.45 -			if (!trans)
   81.46 -				return -ENOMEM;
   81.47 +			if (!trans) {
   81.48 +				rc = -ENOMEM;
   81.49 +				goto out;
   81.50 +			}
   81.51  		}
   81.52  
   81.53  		reply = xenbus_dev_request_and_reply(&u->u.msg);
   81.54  		if (IS_ERR(reply)) {
   81.55  			kfree(trans);
   81.56 -			return PTR_ERR(reply);
   81.57 +			rc = PTR_ERR(reply);
   81.58 +			goto out;
   81.59  		}
   81.60  
   81.61  		if (msg_type == XS_TRANSACTION_START) {
   81.62 @@ -232,8 +239,10 @@ static ssize_t xenbus_dev_write(struct f
   81.63  	case XS_UNWATCH:
   81.64  		path = u->u.buffer + sizeof(u->u.msg);
   81.65  		token = memchr(path, 0, u->u.msg.len);
   81.66 -		if (token == NULL)
   81.67 -			return -EILSEQ;
   81.68 +		if (token == NULL) {
   81.69 +			rc = -EILSEQ;
   81.70 +			goto out;
   81.71 +		}
   81.72  		token++;
   81.73  
   81.74  		if (msg_type == XS_WATCH) {
   81.75 @@ -252,7 +261,8 @@ static ssize_t xenbus_dev_write(struct f
   81.76  			err = register_xenbus_watch(&watch->watch);
   81.77  			if (err) {
   81.78  				free_watch_adapter(watch);
   81.79 -				return err;
   81.80 +				rc = err;
   81.81 +				goto out;
   81.82  			}
   81.83  			
   81.84  			list_add(&watch->list, &u->watches);
   81.85 @@ -266,7 +276,6 @@ static ssize_t xenbus_dev_write(struct f
   81.86                                                   &u->watches, list) {
   81.87  				if (!strcmp(watch->token, token) &&
   81.88  				    !strcmp(watch->watch.node, path))
   81.89 -					break;
   81.90  				{
   81.91  					unregister_xenbus_watch(&watch->watch);
   81.92  					list_del(&watch->list);
   81.93 @@ -279,11 +288,13 @@ static ssize_t xenbus_dev_write(struct f
   81.94  		break;
   81.95  
   81.96  	default:
   81.97 -		return -EINVAL;
   81.98 +		rc = -EINVAL;
   81.99 +		break;
  81.100  	}
  81.101  
  81.102 + out:
  81.103  	u->len = 0;
  81.104 -	return len;
  81.105 +	return rc;
  81.106  }
  81.107  
  81.108  static int xenbus_dev_open(struct inode *inode, struct file *filp)
  81.109 @@ -343,7 +354,7 @@ static unsigned int xenbus_dev_poll(stru
  81.110  	return 0;
  81.111  }
  81.112  
  81.113 -static struct file_operations xenbus_dev_file_ops = {
  81.114 +static const struct file_operations xenbus_dev_file_ops = {
  81.115  	.read = xenbus_dev_read,
  81.116  	.write = xenbus_dev_write,
  81.117  	.open = xenbus_dev_open,
    82.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Thu Mar 01 15:02:09 2007 -0700
    82.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Wed Mar 07 12:38:28 2007 -0700
    82.3 @@ -77,11 +77,22 @@ struct xs_handle {
    82.4  	spinlock_t reply_lock;
    82.5  	wait_queue_head_t reply_waitq;
    82.6  
    82.7 +	/*
    82.8 +	 * Mutex ordering: transaction_mutex -> watch_mutex -> request_mutex.
    82.9 +	 * response_mutex is never taken simultaneously with the other three.
   82.10 +	 */
   82.11 +
   82.12  	/* One request at a time. */
   82.13  	struct mutex request_mutex;
   82.14  
   82.15 +	/* Protect xenbus reader thread against save/restore. */
   82.16 +	struct mutex response_mutex;
   82.17 +
   82.18  	/* Protect transactions against save/restore. */
   82.19 -	struct rw_semaphore suspend_mutex;
   82.20 +	struct rw_semaphore transaction_mutex;
   82.21 +
   82.22 +	/* Protect watch (de)register against save/restore. */
   82.23 +	struct rw_semaphore watch_mutex;
   82.24  };
   82.25  
   82.26  static struct xs_handle xs_state;
   82.27 @@ -150,22 +161,6 @@ static void *read_reply(enum xsd_sockmsg
   82.28  	return body;
   82.29  }
   82.30  
   82.31 -/* Emergency write. */
   82.32 -void xenbus_debug_write(const char *str, unsigned int count)
   82.33 -{
   82.34 -	struct xsd_sockmsg msg = { 0 };
   82.35 -
   82.36 -	msg.type = XS_DEBUG;
   82.37 -	msg.len = sizeof("print") + count + 1;
   82.38 -
   82.39 -	mutex_lock(&xs_state.request_mutex);
   82.40 -	xb_write(&msg, sizeof(msg));
   82.41 -	xb_write("print", sizeof("print"));
   82.42 -	xb_write(str, count);
   82.43 -	xb_write("", 1);
   82.44 -	mutex_unlock(&xs_state.request_mutex);
   82.45 -}
   82.46 -
   82.47  void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
   82.48  {
   82.49  	void *ret;
   82.50 @@ -173,7 +168,7 @@ void *xenbus_dev_request_and_reply(struc
   82.51  	int err;
   82.52  
   82.53  	if (req_msg.type == XS_TRANSACTION_START)
   82.54 -		down_read(&xs_state.suspend_mutex);
   82.55 +		down_read(&xs_state.transaction_mutex);
   82.56  
   82.57  	mutex_lock(&xs_state.request_mutex);
   82.58  
   82.59 @@ -189,7 +184,7 @@ void *xenbus_dev_request_and_reply(struc
   82.60  	if ((req_msg.type == XS_TRANSACTION_END) ||
   82.61  	    ((req_msg.type == XS_TRANSACTION_START) &&
   82.62  	     (msg->type == XS_ERROR)))
   82.63 -		up_read(&xs_state.suspend_mutex);
   82.64 +		up_read(&xs_state.transaction_mutex);
   82.65  
   82.66  	return ret;
   82.67  }
   82.68 @@ -440,11 +435,11 @@ int xenbus_transaction_start(struct xenb
   82.69  {
   82.70  	char *id_str;
   82.71  
   82.72 -	down_read(&xs_state.suspend_mutex);
   82.73 +	down_read(&xs_state.transaction_mutex);
   82.74  
   82.75  	id_str = xs_single(XBT_NIL, XS_TRANSACTION_START, "", NULL);
   82.76  	if (IS_ERR(id_str)) {
   82.77 -		up_read(&xs_state.suspend_mutex);
   82.78 +		up_read(&xs_state.transaction_mutex);
   82.79  		return PTR_ERR(id_str);
   82.80  	}
   82.81  
   82.82 @@ -469,7 +464,7 @@ int xenbus_transaction_end(struct xenbus
   82.83  
   82.84  	err = xs_error(xs_single(t, XS_TRANSACTION_END, abortstr, NULL));
   82.85  
   82.86 -	up_read(&xs_state.suspend_mutex);
   82.87 +	up_read(&xs_state.transaction_mutex);
   82.88  
   82.89  	return err;
   82.90  }
   82.91 @@ -602,7 +597,7 @@ int register_xenbus_watch(struct xenbus_
   82.92  
   82.93  	sprintf(token, "%lX", (long)watch);
   82.94  
   82.95 -	down_read(&xs_state.suspend_mutex);
   82.96 +	down_read(&xs_state.watch_mutex);
   82.97  
   82.98  	spin_lock(&watches_lock);
   82.99  	BUG_ON(find_watch(token));
  82.100 @@ -618,7 +613,7 @@ int register_xenbus_watch(struct xenbus_
  82.101  		spin_unlock(&watches_lock);
  82.102  	}
  82.103  
  82.104 -	up_read(&xs_state.suspend_mutex);
  82.105 +	up_read(&xs_state.watch_mutex);
  82.106  
  82.107  	return err;
  82.108  }
  82.109 @@ -632,7 +627,7 @@ void unregister_xenbus_watch(struct xenb
  82.110  
  82.111  	sprintf(token, "%lX", (long)watch);
  82.112  
  82.113 -	down_read(&xs_state.suspend_mutex);
  82.114 +	down_read(&xs_state.watch_mutex);
  82.115  
  82.116  	spin_lock(&watches_lock);
  82.117  	BUG_ON(!find_watch(token));
  82.118 @@ -645,7 +640,7 @@ void unregister_xenbus_watch(struct xenb
  82.119  		       "XENBUS Failed to release watch %s: %i\n",
  82.120  		       watch->node, err);
  82.121  
  82.122 -	up_read(&xs_state.suspend_mutex);
  82.123 +	up_read(&xs_state.watch_mutex);
  82.124  
  82.125  	/* Cancel pending watch events. */
  82.126  	spin_lock(&watch_events_lock);
  82.127 @@ -668,8 +663,10 @@ EXPORT_SYMBOL_GPL(unregister_xenbus_watc
  82.128  
  82.129  void xs_suspend(void)
  82.130  {
  82.131 -	down_write(&xs_state.suspend_mutex);
  82.132 +	down_write(&xs_state.transaction_mutex);
  82.133 +	down_write(&xs_state.watch_mutex);
  82.134  	mutex_lock(&xs_state.request_mutex);
  82.135 +	mutex_lock(&xs_state.response_mutex);
  82.136  }
  82.137  
  82.138  void xs_resume(void)
  82.139 @@ -677,21 +674,25 @@ void xs_resume(void)
  82.140  	struct xenbus_watch *watch;
  82.141  	char token[sizeof(watch) * 2 + 1];
  82.142  
  82.143 +	mutex_unlock(&xs_state.response_mutex);
  82.144  	mutex_unlock(&xs_state.request_mutex);
  82.145 +	up_write(&xs_state.transaction_mutex);
  82.146  
  82.147 -	/* No need for watches_lock: the suspend_mutex is sufficient. */
  82.148 +	/* No need for watches_lock: the watch_mutex is sufficient. */
  82.149  	list_for_each_entry(watch, &watches, list) {
  82.150  		sprintf(token, "%lX", (long)watch);
  82.151  		xs_watch(watch->node, token);
  82.152  	}
  82.153  
  82.154 -	up_write(&xs_state.suspend_mutex);
  82.155 +	up_write(&xs_state.watch_mutex);
  82.156  }
  82.157  
  82.158  void xs_suspend_cancel(void)
  82.159  {
  82.160 +	mutex_unlock(&xs_state.response_mutex);
  82.161  	mutex_unlock(&xs_state.request_mutex);
  82.162 -	up_write(&xs_state.suspend_mutex);
  82.163 +	up_write(&xs_state.watch_mutex);
  82.164 +	up_write(&xs_state.transaction_mutex);
  82.165  }
  82.166  
  82.167  static int xenwatch_handle_callback(void *data)
  82.168 @@ -753,27 +754,46 @@ static int process_msg(void)
  82.169  	char *body;
  82.170  	int err;
  82.171  
  82.172 +	/*
  82.173 +	 * We must disallow save/restore while reading a xenstore message.
  82.174 +	 * A partial read across s/r leaves us out of sync with xenstored.
  82.175 +	 */
  82.176 +	for (;;) {
  82.177 +		err = xb_wait_for_data_to_read();
  82.178 +		if (err)
  82.179 +			return err;
  82.180 +		mutex_lock(&xs_state.response_mutex);
  82.181 +		if (xb_data_to_read())
  82.182 +			break;
  82.183 +		/* We raced with save/restore: pending data 'disappeared'. */
  82.184 +		mutex_unlock(&xs_state.response_mutex);
  82.185 +	}
  82.186 +
  82.187 +
  82.188  	msg = kmalloc(sizeof(*msg), GFP_KERNEL);
  82.189 -	if (msg == NULL)
  82.190 -		return -ENOMEM;
  82.191 +	if (msg == NULL) {
  82.192 +		err = -ENOMEM;
  82.193 +		goto out;
  82.194 +	}
  82.195  
  82.196  	err = xb_read(&msg->hdr, sizeof(msg->hdr));
  82.197  	if (err) {
  82.198  		kfree(msg);
  82.199 -		return err;
  82.200 +		goto out;
  82.201  	}
  82.202  
  82.203  	body = kmalloc(msg->hdr.len + 1, GFP_KERNEL);
  82.204  	if (body == NULL) {
  82.205  		kfree(msg);
  82.206 -		return -ENOMEM;
  82.207 +		err = -ENOMEM;
  82.208 +		goto out;
  82.209  	}
  82.210  
  82.211  	err = xb_read(body, msg->hdr.len);
  82.212  	if (err) {
  82.213  		kfree(body);
  82.214  		kfree(msg);
  82.215 -		return err;
  82.216 +		goto out;
  82.217  	}
  82.218  	body[msg->hdr.len] = '\0';
  82.219  
  82.220 @@ -782,7 +802,8 @@ static int process_msg(void)
  82.221  					 &msg->u.watch.vec_size);
  82.222  		if (IS_ERR(msg->u.watch.vec)) {
  82.223  			kfree(msg);
  82.224 -			return PTR_ERR(msg->u.watch.vec);
  82.225 +			err = PTR_ERR(msg->u.watch.vec);
  82.226 +			goto out;
  82.227  		}
  82.228  
  82.229  		spin_lock(&watches_lock);
  82.230 @@ -806,7 +827,9 @@ static int process_msg(void)
  82.231  		wake_up(&xs_state.reply_waitq);
  82.232  	}
  82.233  
  82.234 -	return 0;
  82.235 + out:
  82.236 +	mutex_unlock(&xs_state.response_mutex);
  82.237 +	return err;
  82.238  }
  82.239  
  82.240  static int xenbus_thread(void *unused)
  82.241 @@ -835,7 +858,9 @@ int xs_init(void)
  82.242  	init_waitqueue_head(&xs_state.reply_waitq);
  82.243  
  82.244  	mutex_init(&xs_state.request_mutex);
  82.245 -	init_rwsem(&xs_state.suspend_mutex);
  82.246 +	mutex_init(&xs_state.response_mutex);
  82.247 +	init_rwsem(&xs_state.transaction_mutex);
  82.248 +	init_rwsem(&xs_state.watch_mutex);
  82.249  
  82.250  	/* Initialize the shared memory rings to talk to xenstored */
  82.251  	err = xb_init_comms();
    83.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h	Thu Mar 01 15:02:09 2007 -0700
    83.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/dma-mapping.h	Wed Mar 07 12:38:28 2007 -0700
    83.3 @@ -6,7 +6,6 @@
    83.4   * documentation.
    83.5   */
    83.6  
    83.7 -#include <linux/config.h>
    83.8  #include <linux/mm.h>
    83.9  #include <asm/cache.h>
   83.10  #include <asm/io.h>
    84.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Thu Mar 01 15:02:09 2007 -0700
    84.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Mar 07 12:38:28 2007 -0700
    84.3 @@ -33,7 +33,6 @@
    84.4  #ifndef __HYPERVISOR_H__
    84.5  #define __HYPERVISOR_H__
    84.6  
    84.7 -#include <linux/config.h>
    84.8  #include <linux/types.h>
    84.9  #include <linux/kernel.h>
   84.10  #include <linux/version.h>
   84.11 @@ -57,7 +56,11 @@
   84.12  extern shared_info_t *HYPERVISOR_shared_info;
   84.13  
   84.14  #define vcpu_info(cpu) (HYPERVISOR_shared_info->vcpu_info + (cpu))
   84.15 +#ifdef CONFIG_SMP
   84.16  #define current_vcpu_info() vcpu_info(smp_processor_id())
   84.17 +#else
   84.18 +#define current_vcpu_info() vcpu_info(0)
   84.19 +#endif
   84.20  
   84.21  #ifdef CONFIG_X86_32
   84.22  extern unsigned long hypervisor_virt_start;
    85.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Thu Mar 01 15:02:09 2007 -0700
    85.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Wed Mar 07 12:38:28 2007 -0700
    85.3 @@ -20,6 +20,14 @@
    85.4  #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
    85.5  
    85.6  #ifdef __KERNEL__
    85.7 +
    85.8 +/*
    85.9 + * Need to repeat this here in order to not include pgtable.h (which in turn
   85.10 + * depends on definitions made here), but to be able to use the symbolic
   85.11 + * below. The preprocessor will warn if the two definitions aren't identical.
   85.12 + */
   85.13 +#define _PAGE_PRESENT	0x001
   85.14 +
   85.15  #ifndef __ASSEMBLY__
   85.16  
   85.17  #include <linux/string.h>
   85.18 @@ -29,13 +37,6 @@
   85.19  #include <xen/interface/xen.h>
   85.20  #include <xen/features.h>
   85.21  
   85.22 -/*
   85.23 - * Need to repeat this here in order to not include pgtable.h (which in turn
   85.24 - * depends on definitions made here), but to be able to use the symbolic
   85.25 - * below. The preprocessor will warn if the two definitions aren't identical.
   85.26 - */
   85.27 -#define _PAGE_PRESENT	0x001
   85.28 -
   85.29  #define arch_free_page(_page,_order)		\
   85.30  ({	int foreign = PageForeign(_page);	\
   85.31  	if (foreign)				\
   85.32 @@ -139,7 +140,11 @@ typedef struct { unsigned long pgprot; }
   85.33  static inline unsigned long pgd_val(pgd_t x)
   85.34  {
   85.35  	unsigned long ret = x.pgd;
   85.36 +#ifdef CONFIG_XEN_COMPAT_030002
   85.37 +	if (ret) ret = machine_to_phys(ret) | _PAGE_PRESENT;
   85.38 +#else
   85.39  	if (ret & _PAGE_PRESENT) ret = machine_to_phys(ret);
   85.40 +#endif
   85.41  	return ret;
   85.42  }
   85.43  #define HPAGE_SHIFT	22
   85.44 @@ -221,8 +226,6 @@ extern int page_is_ram(unsigned long pag
   85.45  	((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
   85.46  		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
   85.47  
   85.48 -#define __HAVE_ARCH_GATE_AREA 1
   85.49 -
   85.50  #include <asm-generic/memory_model.h>
   85.51  #include <asm-generic/page.h>
   85.52  
    86.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h	Thu Mar 01 15:02:09 2007 -0700
    86.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h	Wed Mar 07 12:38:28 2007 -0700
    86.3 @@ -1,8 +1,6 @@
    86.4  #ifndef _ASM_SWIOTLB_H
    86.5  #define _ASM_SWIOTLB_H 1
    86.6  
    86.7 -#include <linux/config.h>
    86.8 -
    86.9  /* SWIOTLB interface */
   86.10  
   86.11  extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
    87.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Thu Mar 01 15:02:09 2007 -0700
    87.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/synch_bitops.h	Wed Mar 07 12:38:28 2007 -0700
    87.3 @@ -7,8 +7,6 @@
    87.4   * when communicating with Xen or other guest OSes running on other CPUs.
    87.5   */
    87.6  
    87.7 -#include <linux/config.h>
    87.8 -
    87.9  #ifdef HAVE_XEN_PLATFORM_COMPAT_H
   87.10  #include <xen/platform-compat.h>
   87.11  #endif
    88.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h	Thu Mar 01 15:02:09 2007 -0700
    88.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/system.h	Wed Mar 07 12:38:28 2007 -0700
    88.3 @@ -137,7 +137,7 @@ extern struct task_struct * FASTCALL(__s
    88.4  })
    88.5  
    88.6  #define write_cr4(x) \
    88.7 -	__asm__ __volatile__("movl %0,%%cr4": :"r" (x));
    88.8 +	__asm__ __volatile__("movl %0,%%cr4": :"r" (x))
    88.9  
   88.10  /*
   88.11   * Clear and set 'TS' bit respectively
    89.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Thu Mar 01 15:02:09 2007 -0700
    89.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Wed Mar 07 12:38:28 2007 -0700
    89.3 @@ -46,7 +46,6 @@ extern int running_on_xen;
    89.4  #endif /* CONFIG_XEN */
    89.5  
    89.6  #if defined(CONFIG_XEN) || defined(CONFIG_VMX_GUEST)
    89.7 -#include <linux/config.h>
    89.8  #include <linux/types.h>
    89.9  #include <linux/kernel.h>
   89.10  #include <linux/version.h>
    90.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/swiotlb.h	Thu Mar 01 15:02:09 2007 -0700
    90.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/swiotlb.h	Wed Mar 07 12:38:28 2007 -0700
    90.3 @@ -1,8 +1,6 @@
    90.4  #ifndef _ASM_SWIOTLB_H
    90.5  #define _ASM_SWIOTLB_H 1
    90.6  
    90.7 -#include <linux/config.h>
    90.8 -
    90.9  /* SWIOTLB interface */
   90.10  
   90.11  extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
    91.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/synch_bitops.h	Thu Mar 01 15:02:09 2007 -0700
    91.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/synch_bitops.h	Wed Mar 07 12:38:28 2007 -0700
    91.3 @@ -7,8 +7,6 @@
    91.4   * when communicating with Xen or other guest OSes running on other CPUs.
    91.5   */
    91.6  
    91.7 -#include <linux/config.h>
    91.8 -
    91.9  #define ADDR (*(volatile long *) addr)
   91.10  
   91.11  static __inline__ void synch_set_bit(int nr, volatile void * addr)
    92.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/fixmap.h	Thu Mar 01 15:02:09 2007 -0700
    92.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/fixmap.h	Wed Mar 07 12:38:28 2007 -0700
    92.3 @@ -53,6 +53,11 @@ enum fixed_addresses {
    92.4  #define NR_FIX_ISAMAPS	256
    92.5  	FIX_ISAMAP_END,
    92.6  	FIX_ISAMAP_BEGIN = FIX_ISAMAP_END + NR_FIX_ISAMAPS - 1,
    92.7 +	__end_of_permanent_fixed_addresses,
    92.8 +	/* temporary boot-time mappings, used before ioremap() is functional */
    92.9 +#define NR_FIX_BTMAPS	16
   92.10 +	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
   92.11 +	FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
   92.12  	__end_of_fixed_addresses
   92.13  };
   92.14  
    93.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/io.h	Thu Mar 01 15:02:09 2007 -0700
    93.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/io.h	Wed Mar 07 12:38:28 2007 -0700
    93.3 @@ -150,8 +150,10 @@ static inline void __iomem * ioremap (un
    93.4  	return __ioremap(offset, size, 0);
    93.5  }
    93.6  
    93.7 -extern void *early_ioremap(unsigned long addr, unsigned long size);
    93.8 -extern void early_iounmap(void *addr, unsigned long size);
    93.9 +extern void *bt_ioremap(unsigned long addr, unsigned long size);
   93.10 +extern void bt_iounmap(void *addr, unsigned long size);
   93.11 +#define early_ioremap bt_ioremap
   93.12 +#define early_iounmap bt_iounmap
   93.13  
   93.14  /*
   93.15   * This one maps high address device memory and turns off caching for that area.
    94.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/irq.h	Thu Mar 01 15:02:09 2007 -0700
    94.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/irq.h	Wed Mar 07 12:38:28 2007 -0700
    94.3 @@ -10,7 +10,6 @@
    94.4   *	<tomsoft@informatik.tu-chemnitz.de>
    94.5   */
    94.6  
    94.7 -#include <linux/config.h>
    94.8  #include <linux/sched.h>
    94.9  /* include comes from machine specific directory */
   94.10  #include "irq_vectors.h"
    95.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h	Thu Mar 01 15:02:09 2007 -0700
    95.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/pgtable.h	Wed Mar 07 12:38:28 2007 -0700
    95.3 @@ -403,19 +403,6 @@ static inline int pmd_large(pmd_t pte) {
    95.4  /* to find an entry in a page-table-directory. */
    95.5  #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
    95.6  #define pud_offset(pgd, address) ((pud_t *) pgd_page(*(pgd)) + pud_index(address))
    95.7 -static inline pud_t *__pud_offset_k(pud_t *pud, unsigned long address)
    95.8 -{ 
    95.9 -	return pud + pud_index(address);
   95.10 -} 
   95.11 -
   95.12 -/* Find correct pud via the hidden fourth level page level: */
   95.13 -
   95.14 -/* This accesses the reference page table of the boot cpu. 
   95.15 -   Other CPUs get synced lazily via the page fault handler. */
   95.16 -static inline pud_t *pud_offset_k(pgd_t *pgd, unsigned long address)
   95.17 -{
   95.18 -	return pud_offset(pgd_offset_k(address), address);
   95.19 -}
   95.20  
   95.21  /* PMD  - Level 2 access */
   95.22  #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PTE_MASK))
    96.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h	Thu Mar 01 15:02:09 2007 -0700
    96.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h	Wed Mar 07 12:38:28 2007 -0700
    96.3 @@ -246,11 +246,13 @@ DECLARE_PER_CPU(struct tss_struct,init_t
    96.4  
    96.5  
    96.6  extern struct cpuinfo_x86 boot_cpu_data;
    96.7 +#ifndef CONFIG_X86_NO_TSS
    96.8  /* Save the original ist values for checking stack pointers during debugging */
    96.9  struct orig_ist {
   96.10  	unsigned long ist[7];
   96.11  };
   96.12  DECLARE_PER_CPU(struct orig_ist, orig_ist);
   96.13 +#endif
   96.14  
   96.15  #ifdef CONFIG_X86_VSMP
   96.16  #define ARCH_MIN_TASKALIGN	(1 << INTERNODE_CACHE_SHIFT)
    97.1 --- a/linux-2.6-xen-sparse/include/linux/page-flags.h	Thu Mar 01 15:02:09 2007 -0700
    97.2 +++ b/linux-2.6-xen-sparse/include/linux/page-flags.h	Wed Mar 07 12:38:28 2007 -0700
    97.3 @@ -252,14 +252,14 @@
    97.4  #define PageForeign(page)	test_bit(PG_foreign, &(page)->flags)
    97.5  #define SetPageForeign(page, dtor) do {		\
    97.6  	set_bit(PG_foreign, &(page)->flags);	\
    97.7 -	(page)->mapping = (void *)dtor;		\
    97.8 +	(page)->index = (long)(dtor);		\
    97.9  } while (0)
   97.10  #define ClearPageForeign(page) do {		\
   97.11  	clear_bit(PG_foreign, &(page)->flags);	\
   97.12 -	(page)->mapping = NULL;			\
   97.13 +	(page)->index = 0;			\
   97.14  } while (0)
   97.15  #define PageForeignDestructor(page)		\
   97.16 -	( (void (*) (struct page *)) (page)->mapping )(page)
   97.17 +	( (void (*) (struct page *)) (page)->index )(page)
   97.18  
   97.19  struct page;	/* forward declaration */
   97.20  
    98.1 --- a/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Thu Mar 01 15:02:09 2007 -0700
    98.2 +++ b/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Wed Mar 07 12:38:28 2007 -0700
    98.3 @@ -1,17 +1,17 @@
    98.4  #ifndef __XEN_CPU_HOTPLUG_H__
    98.5  #define __XEN_CPU_HOTPLUG_H__
    98.6  
    98.7 -#include <linux/config.h>
    98.8  #include <linux/kernel.h>
    98.9  #include <linux/cpumask.h>
   98.10  
   98.11 -#if defined(CONFIG_HOTPLUG_CPU)
   98.12 +#if defined(CONFIG_X86) && defined(CONFIG_SMP)
   98.13 +extern cpumask_t cpu_initialized_map;
   98.14 +#define cpu_set_initialized(cpu) cpu_set(cpu, cpu_initialized_map)
   98.15 +#else
   98.16 +#define cpu_set_initialized(cpu) ((void)0)
   98.17 +#endif
   98.18  
   98.19 -#if defined(CONFIG_X86)
   98.20 -void cpu_initialize_context(unsigned int cpu);
   98.21 -#else
   98.22 -#define cpu_initialize_context(cpu)	((void)0)
   98.23 -#endif
   98.24 +#if defined(CONFIG_HOTPLUG_CPU)
   98.25  
   98.26  int cpu_up_check(unsigned int cpu);
   98.27  void init_xenbus_allowed_cpumask(void);
    99.1 --- a/linux-2.6-xen-sparse/include/xen/driver_util.h	Thu Mar 01 15:02:09 2007 -0700
    99.2 +++ b/linux-2.6-xen-sparse/include/xen/driver_util.h	Wed Mar 07 12:38:28 2007 -0700
    99.3 @@ -2,7 +2,6 @@
    99.4  #ifndef __ASM_XEN_DRIVER_UTIL_H__
    99.5  #define __ASM_XEN_DRIVER_UTIL_H__
    99.6  
    99.7 -#include <linux/config.h>
    99.8  #include <linux/vmalloc.h>
    99.9  
   99.10  /* Allocate/destroy a 'vmalloc' VM area. */
   100.1 --- a/linux-2.6-xen-sparse/include/xen/evtchn.h	Thu Mar 01 15:02:09 2007 -0700
   100.2 +++ b/linux-2.6-xen-sparse/include/xen/evtchn.h	Wed Mar 07 12:38:28 2007 -0700
   100.3 @@ -34,7 +34,6 @@
   100.4  #ifndef __ASM_EVTCHN_H__
   100.5  #define __ASM_EVTCHN_H__
   100.6  
   100.7 -#include <linux/config.h>
   100.8  #include <linux/interrupt.h>
   100.9  #include <asm/hypervisor.h>
  100.10  #include <asm/ptrace.h>
   101.1 --- a/linux-2.6-xen-sparse/include/xen/gnttab.h	Thu Mar 01 15:02:09 2007 -0700
   101.2 +++ b/linux-2.6-xen-sparse/include/xen/gnttab.h	Wed Mar 07 12:38:28 2007 -0700
   101.3 @@ -37,7 +37,6 @@
   101.4  #ifndef __ASM_GNTTAB_H__
   101.5  #define __ASM_GNTTAB_H__
   101.6  
   101.7 -#include <linux/config.h>
   101.8  #include <asm/hypervisor.h>
   101.9  #include <asm/maddr.h> /* maddr_t */
  101.10  #include <xen/interface/grant_table.h>
   102.1 --- a/linux-2.6-xen-sparse/include/xen/pcifront.h	Thu Mar 01 15:02:09 2007 -0700
   102.2 +++ b/linux-2.6-xen-sparse/include/xen/pcifront.h	Wed Mar 07 12:38:28 2007 -0700
   102.3 @@ -6,7 +6,6 @@
   102.4  #ifndef __XEN_ASM_PCIFRONT_H__
   102.5  #define __XEN_ASM_PCIFRONT_H__
   102.6  
   102.7 -#include <linux/config.h>
   102.8  #include <linux/spinlock.h>
   102.9  
  102.10  #ifdef __KERNEL__
   103.1 --- a/linux-2.6-xen-sparse/include/xen/xen_proc.h	Thu Mar 01 15:02:09 2007 -0700
   103.2 +++ b/linux-2.6-xen-sparse/include/xen/xen_proc.h	Wed Mar 07 12:38:28 2007 -0700
   103.3 @@ -2,7 +2,6 @@
   103.4  #ifndef __ASM_XEN_PROC_H__
   103.5  #define __ASM_XEN_PROC_H__
   103.6  
   103.7 -#include <linux/config.h>
   103.8  #include <linux/proc_fs.h>
   103.9  
  103.10  extern struct proc_dir_entry *create_xen_proc_entry(
   104.1 --- a/linux-2.6-xen-sparse/mm/Kconfig	Thu Mar 01 15:02:09 2007 -0700
   104.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.3 @@ -1,157 +0,0 @@
   104.4 -config SELECT_MEMORY_MODEL
   104.5 -	def_bool y
   104.6 -	depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL
   104.7 -
   104.8 -choice
   104.9 -	prompt "Memory model"
  104.10 -	depends on SELECT_MEMORY_MODEL
  104.11 -	default DISCONTIGMEM_MANUAL if ARCH_DISCONTIGMEM_DEFAULT
  104.12 -	default SPARSEMEM_MANUAL if ARCH_SPARSEMEM_DEFAULT
  104.13 -	default FLATMEM_MANUAL
  104.14 -
  104.15 -config FLATMEM_MANUAL
  104.16 -	bool "Flat Memory"
  104.17 -	depends on !(ARCH_DISCONTIGMEM_ENABLE || ARCH_SPARSEMEM_ENABLE) || ARCH_FLATMEM_ENABLE
  104.18 -	help
  104.19 -	  This option allows you to change some of the ways that
  104.20 -	  Linux manages its memory internally.  Most users will
  104.21 -	  only have one option here: FLATMEM.  This is normal
  104.22 -	  and a correct option.
  104.23 -
  104.24 -	  Some users of more advanced features like NUMA and
  104.25 -	  memory hotplug may have different options here.
  104.26 -	  DISCONTIGMEM is an more mature, better tested system,
  104.27 -	  but is incompatible with memory hotplug and may suffer
  104.28 -	  decreased performance over SPARSEMEM.  If unsure between
  104.29 -	  "Sparse Memory" and "Discontiguous Memory", choose
  104.30 -	  "Discontiguous Memory".
  104.31 -
  104.32 -	  If unsure, choose this option (Flat Memory) over any other.
  104.33 -
  104.34 -config DISCONTIGMEM_MANUAL
  104.35 -	bool "Discontiguous Memory"
  104.36 -	depends on ARCH_DISCONTIGMEM_ENABLE
  104.37 -	help
  104.38 -	  This option provides enhanced support for discontiguous
  104.39 -	  memory systems, over FLATMEM.  These systems have holes
  104.40 -	  in their physical address spaces, and this option provides
  104.41 -	  more efficient handling of these holes.  However, the vast
  104.42 -	  majority of hardware has quite flat address spaces, and
  104.43 -	  can have degraded performance from extra overhead that
  104.44 -	  this option imposes.
  104.45 -
  104.46 -	  Many NUMA configurations will have this as the only option.
  104.47 -
  104.48 -	  If unsure, choose "Flat Memory" over this option.
  104.49 -
  104.50 -config SPARSEMEM_MANUAL
  104.51 -	bool "Sparse Memory"
  104.52 -	depends on ARCH_SPARSEMEM_ENABLE
  104.53 -	help
  104.54 -	  This will be the only option for some systems, including
  104.55 -	  memory hotplug systems.  This is normal.
  104.56 -
  104.57 -	  For many other systems, this will be an alternative to
  104.58 -	  "Discontiguous Memory".  This option provides some potential
  104.59 -	  performance benefits, along with decreased code complexity,
  104.60 -	  but it is newer, and more experimental.
  104.61 -
  104.62 -	  If unsure, choose "Discontiguous Memory" or "Flat Memory"
  104.63 -	  over this option.
  104.64 -
  104.65 -endchoice
  104.66 -
  104.67 -config DISCONTIGMEM
  104.68 -	def_bool y
  104.69 -	depends on (!SELECT_MEMORY_MODEL && ARCH_DISCONTIGMEM_ENABLE) || DISCONTIGMEM_MANUAL
  104.70 -
  104.71 -config SPARSEMEM
  104.72 -	def_bool y
  104.73 -	depends on SPARSEMEM_MANUAL
  104.74 -
  104.75 -config FLATMEM
  104.76 -	def_bool y
  104.77 -	depends on (!DISCONTIGMEM && !SPARSEMEM) || FLATMEM_MANUAL
  104.78 -
  104.79 -config FLAT_NODE_MEM_MAP
  104.80 -	def_bool y
  104.81 -	depends on !SPARSEMEM
  104.82 -
  104.83 -#
  104.84 -# Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's
  104.85 -# to represent different areas of memory.  This variable allows
  104.86 -# those dependencies to exist individually.
  104.87 -#
  104.88 -config NEED_MULTIPLE_NODES
  104.89 -	def_bool y
  104.90 -	depends on DISCONTIGMEM || NUMA
  104.91 -
  104.92 -config HAVE_MEMORY_PRESENT
  104.93 -	def_bool y
  104.94 -	depends on ARCH_HAVE_MEMORY_PRESENT || SPARSEMEM
  104.95 -
  104.96 -#
  104.97 -# SPARSEMEM_EXTREME (which is the default) does some bootmem
  104.98 -# allocations when memory_present() is called.  If this can not
  104.99 -# be done on your architecture, select this option.  However,
 104.100 -# statically allocating the mem_section[] array can potentially
 104.101 -# consume vast quantities of .bss, so be careful.
 104.102 -#
 104.103 -# This option will also potentially produce smaller runtime code
 104.104 -# with gcc 3.4 and later.
 104.105 -#
 104.106 -config SPARSEMEM_STATIC
 104.107 -	def_bool n
 104.108 -
 104.109 -#
 104.110 -# Architectecture platforms which require a two level mem_section in SPARSEMEM
 104.111 -# must select this option. This is usually for architecture platforms with
 104.112 -# an extremely sparse physical address space.
 104.113 -#
 104.114 -config SPARSEMEM_EXTREME
 104.115 -	def_bool y
 104.116 -	depends on SPARSEMEM && !SPARSEMEM_STATIC
 104.117 -
 104.118 -# eventually, we can have this option just 'select SPARSEMEM'
 104.119 -config MEMORY_HOTPLUG
 104.120 -	bool "Allow for memory hot-add"
 104.121 -	depends on SPARSEMEM && HOTPLUG && !SOFTWARE_SUSPEND && ARCH_ENABLE_MEMORY_HOTPLUG
 104.122 -	depends on (IA64 || X86 || PPC64)
 104.123 -
 104.124 -comment "Memory hotplug is currently incompatible with Software Suspend"
 104.125 -	depends on SPARSEMEM && HOTPLUG && SOFTWARE_SUSPEND
 104.126 -
 104.127 -# Heavily threaded applications may benefit from splitting the mm-wide
 104.128 -# page_table_lock, so that faults on different parts of the user address
 104.129 -# space can be handled with less contention: split it at this NR_CPUS.
 104.130 -# Default to 4 for wider testing, though 8 might be more appropriate.
 104.131 -# ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock.
 104.132 -# PA-RISC 7xxx's spinlock_t would enlarge struct page from 32 to 44 bytes.
 104.133 -# XEN on x86 architecture uses the mapping field on pagetable pages to store a
 104.134 -# pointer to the destructor. This conflicts with pte_lock_deinit().
 104.135 -#
 104.136 -config SPLIT_PTLOCK_CPUS
 104.137 -	int
 104.138 -	default "4096" if ARM && !CPU_CACHE_VIPT
 104.139 -	default "4096" if PARISC && !PA20
 104.140 -	default "4096" if X86_XEN || X86_64_XEN
 104.141 -	default "4"
 104.142 -
 104.143 -#
 104.144 -# support for page migration
 104.145 -#
 104.146 -config MIGRATION
 104.147 -	bool "Page migration"
 104.148 -	def_bool y
 104.149 -	depends on NUMA
 104.150 -	help
 104.151 -	  Allows the migration of the physical location of pages of processes
 104.152 -	  while the virtual addresses are not changed. This is useful for
 104.153 -	  example on NUMA systems to put pages nearer to the processors accessing
 104.154 -	  the page.
 104.155 -
 104.156 -config RESOURCES_64BIT
 104.157 -	bool "64 bit Memory and IO resources (EXPERIMENTAL)" if (!64BIT && EXPERIMENTAL)
 104.158 -	default 64BIT
 104.159 -	help
 104.160 -	  This option allows memory and IO resources to be 64 bit.
   105.1 --- a/patches/linux-2.6.18/blktap-aio-16_03_06.patch	Thu Mar 01 15:02:09 2007 -0700
   105.2 +++ b/patches/linux-2.6.18/blktap-aio-16_03_06.patch	Wed Mar 07 12:38:28 2007 -0700
   105.3 @@ -106,7 +106,7 @@ diff -pruN ../orig-linux-2.6.18/fs/aio.c
   105.4  +	return pollflags;
   105.5  +}
   105.6  +
   105.7 -+static struct file_operations aioq_fops = {
   105.8 ++static const struct file_operations aioq_fops = {
   105.9  +	.release	= aio_queue_fd_close,
  105.10  +	.poll		= aio_queue_fd_poll
  105.11  +};
  105.12 @@ -201,7 +201,7 @@ diff -pruN ../orig-linux-2.6.18/fs/event
  105.13   		   int maxevents, long timeout);
  105.14   static int eventpollfs_delete_dentry(struct dentry *dentry);
  105.15  -static struct inode *ep_eventpoll_inode(void);
  105.16 -+static struct inode *ep_eventpoll_inode(struct file_operations *fops);
  105.17 ++static struct inode *ep_eventpoll_inode(const struct file_operations *fops);
  105.18   static int eventpollfs_get_sb(struct file_system_type *fs_type,
  105.19   			      int flags, const char *dev_name,
  105.20   			      void *data, struct vfsmount *mnt);
  105.21 @@ -221,7 +221,7 @@ diff -pruN ../orig-linux-2.6.18/fs/event
  105.22  -static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
  105.23  -		    struct eventpoll *ep)
  105.24  +int ep_getfd(int *efd, struct inode **einode, struct file **efile,
  105.25 -+		    struct eventpoll *ep, struct file_operations *fops)
  105.26 ++		    struct eventpoll *ep, const struct file_operations *fops)
  105.27   {
  105.28   	struct qstr this;
  105.29   	char name[32];
  105.30 @@ -248,7 +248,7 @@ diff -pruN ../orig-linux-2.6.18/fs/event
  105.31   
  105.32   
  105.33  -static struct inode *ep_eventpoll_inode(void)
  105.34 -+static struct inode *ep_eventpoll_inode(struct file_operations *fops)
  105.35 ++static struct inode *ep_eventpoll_inode(const struct file_operations *fops)
  105.36   {
  105.37   	int error = -ENOMEM;
  105.38   	struct inode *inode = new_inode(eventpoll_mnt->mnt_sb);
  105.39 @@ -288,7 +288,7 @@ diff -pruN ../orig-linux-2.6.18/include/
  105.40  + */
  105.41  +struct eventpoll;
  105.42  +int ep_getfd(int *efd, struct inode **einode, struct file **efile,
  105.43 -+             struct eventpoll *ep, struct file_operations *fops);
  105.44 ++             struct eventpoll *ep, const struct file_operations *fops);
  105.45   #else
  105.46   
  105.47   static inline void eventpoll_init_file(struct file *file) {}
   106.1 --- a/tools/Makefile	Thu Mar 01 15:02:09 2007 -0700
   106.2 +++ b/tools/Makefile	Wed Mar 07 12:38:28 2007 -0700
   106.3 @@ -24,9 +24,8 @@ SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen
   106.4  
   106.5  # These don't cross-compile
   106.6  ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
   106.7 -SUBDIRS-y += python
   106.8 -SUBDIRS-y += pygrub
   106.9 -SUBDIRS-y += ptsname
  106.10 +SUBDIRS-$(PYTHON_TOOLS) += python
  106.11 +SUBDIRS-$(PYTHON_TOOLS) += pygrub
  106.12  endif
  106.13  
  106.14  .PHONY: all
  106.15 @@ -42,8 +41,8 @@ install: check
  106.16  		$(MAKE) -C $$subdir $@; \
  106.17  	done
  106.18  	$(MAKE) ioemuinstall
  106.19 -	$(INSTALL_DIR) -p $(DESTDIR)/var/xen/dump
  106.20 -	$(INSTALL_DIR) -p $(DESTDIR)/var/log/xen
  106.21 +	$(INSTALL_DIR) $(DESTDIR)/var/xen/dump
  106.22 +	$(INSTALL_DIR) $(DESTDIR)/var/log/xen
  106.23  
  106.24  .PHONY: clean
  106.25  clean: check_clean
   107.1 --- a/tools/blktap/drivers/blktapctrl.c	Thu Mar 01 15:02:09 2007 -0700
   107.2 +++ b/tools/blktap/drivers/blktapctrl.c	Wed Mar 07 12:38:28 2007 -0700
   107.3 @@ -303,6 +303,7 @@ static int write_msg(int fd, int msgtype
   107.4  		msg->type = CTLMSG_PARAMS;
   107.5  		msg->len = msglen;
   107.6  		msg->drivertype = blkif->drivertype;
   107.7 +		msg->readonly = blkif->readonly;
   107.8  
   107.9  		gettimeofday(&timeout, NULL);
  107.10  		msg->cookie = blkif->cookie;
  107.11 @@ -410,7 +411,6 @@ static int read_msg(int fd, int msgtype,
  107.12  	if (select(fd+1, &readfds,  (fd_set *) 0,
  107.13  		  (fd_set *) 0, &timeout) > 0) {
  107.14  		ret = read(fd, buf, msglen);
  107.15 -		
  107.16  	}			
  107.17  	if (ret > 0) {
  107.18  		msg = (msg_hdr_t *)buf;
   108.1 --- a/tools/blktap/drivers/block-aio.c	Thu Mar 01 15:02:09 2007 -0700
   108.2 +++ b/tools/blktap/drivers/block-aio.c	Wed Mar 07 12:38:28 2007 -0700
   108.3 @@ -152,9 +152,9 @@ static inline void init_fds(struct disk_
   108.4  }
   108.5  
   108.6  /* Open the disk file and initialize aio state. */
   108.7 -int tdaio_open (struct disk_driver *dd, const char *name)
   108.8 +int tdaio_open (struct disk_driver *dd, const char *name, td_flag_t flags)
   108.9  {
  108.10 -	int i, fd, ret = 0;
  108.11 +	int i, fd, ret = 0, o_flags;
  108.12  	struct td_state    *s   = dd->td_state;
  108.13  	struct tdaio_state *prv = (struct tdaio_state *)dd->private;
  108.14  
  108.15 @@ -187,12 +187,15 @@ int tdaio_open (struct disk_driver *dd, 
  108.16  		prv->iocb_free[i] = &prv->iocb_list[i];
  108.17  
  108.18  	/* Open the file */
  108.19 -        fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
  108.20 +	o_flags = O_DIRECT | O_LARGEFILE | 
  108.21 +		((flags == TD_RDONLY) ? O_RDONLY : O_RDWR);
  108.22 +        fd = open(name, o_flags);
  108.23  
  108.24          if ( (fd == -1) && (errno == EINVAL) ) {
  108.25  
  108.26                  /* Maybe O_DIRECT isn't supported. */
  108.27 -                fd = open(name, O_RDWR | O_LARGEFILE);
  108.28 +		o_flags &= ~O_DIRECT;
  108.29 +                fd = open(name, o_flags);
  108.30                  if (fd != -1) DPRINTF("WARNING: Accessing image without"
  108.31                                       "O_DIRECT! (%s)\n", name);
  108.32  
  108.33 @@ -280,6 +283,9 @@ int tdaio_submit(struct disk_driver *dd)
  108.34  	int ret;
  108.35  	struct tdaio_state *prv = (struct tdaio_state *)dd->private;
  108.36  
  108.37 +	if (!prv->iocb_queued)
  108.38 +		return 0;
  108.39 +
  108.40  	ret = io_submit(prv->aio_ctx, prv->iocb_queued, prv->iocb_queue);
  108.41  	
  108.42  	/* XXX: TODO: Handle error conditions here. */
  108.43 @@ -324,12 +330,13 @@ int tdaio_do_callbacks(struct disk_drive
  108.44  	return rsp;
  108.45  }
  108.46  
  108.47 -int tdaio_has_parent(struct disk_driver *dd)
  108.48 +int tdaio_get_parent_id(struct disk_driver *dd, struct disk_id *id)
  108.49  {
  108.50 -	return 0;
  108.51 +	return TD_NO_PARENT;
  108.52  }
  108.53  
  108.54 -int tdaio_get_parent(struct disk_driver *dd, struct disk_driver *parent)
  108.55 +int tdaio_validate_parent(struct disk_driver *dd, 
  108.56 +			  struct disk_driver *parent, td_flag_t flags)
  108.57  {
  108.58  	return -EINVAL;
  108.59  }
  108.60 @@ -341,8 +348,8 @@ struct tap_disk tapdisk_aio = {
  108.61  	.td_queue_read      = tdaio_queue_read,
  108.62  	.td_queue_write     = tdaio_queue_write,
  108.63  	.td_submit          = tdaio_submit,
  108.64 -	.td_has_parent      = tdaio_has_parent,
  108.65 -	.td_get_parent      = tdaio_get_parent,
  108.66  	.td_close           = tdaio_close,
  108.67  	.td_do_callbacks    = tdaio_do_callbacks,
  108.68 +	.td_get_parent_id   = tdaio_get_parent_id,
  108.69 +	.td_validate_parent = tdaio_validate_parent
  108.70  };
   109.1 --- a/tools/blktap/drivers/block-qcow.c	Thu Mar 01 15:02:09 2007 -0700
   109.2 +++ b/tools/blktap/drivers/block-qcow.c	Wed Mar 07 12:38:28 2007 -0700
   109.3 @@ -209,23 +209,6 @@ static int init_aio_state(struct disk_dr
   109.4  	return -1;
   109.5  }
   109.6  
   109.7 -/*
   109.8 - *Test if block is zero. 
   109.9 - * Return: 
  109.10 - *       1 for TRUE
  109.11 - *       0 for FALSE
  109.12 - */
  109.13 -static inline int IS_ZERO(char *buf, int len)
  109.14 -{
  109.15 -	int i;
  109.16 -
  109.17 -	for (i = 0; i < len; i++) {
  109.18 -		/*if not zero, return false*/
  109.19 -		if (ZERO_TEST(*(buf + i))) return 0; 
  109.20 -	}
  109.21 -	return 1;
  109.22 -}
  109.23 -
  109.24  static uint32_t gen_cksum(char *ptr, int len)
  109.25  {
  109.26  	unsigned char *md;
  109.27 @@ -439,7 +422,7 @@ static int qtruncate(int fd, off_t lengt
  109.28  		return -1;
  109.29  	if (S_ISBLK(st.st_mode))
  109.30  		return 0;
  109.31 -	
  109.32 +
  109.33  	sectors = (length + DEFAULT_SECTOR_SIZE - 1)/DEFAULT_SECTOR_SIZE;
  109.34  	current = (st.st_size + DEFAULT_SECTOR_SIZE - 1)/DEFAULT_SECTOR_SIZE;
  109.35  	rem     = st.st_size % DEFAULT_SECTOR_SIZE;
  109.36 @@ -825,9 +808,9 @@ static inline void init_fds(struct disk_
  109.37  }
  109.38  
  109.39  /* Open the disk file and initialize qcow state. */
  109.40 -int tdqcow_open (struct disk_driver *dd, const char *name)
  109.41 +int tdqcow_open (struct disk_driver *dd, const char *name, td_flag_t flags)
  109.42  {
  109.43 -	int fd, len, i, shift, ret, size, l1_table_size;
  109.44 +	int fd, len, i, shift, ret, size, l1_table_size, o_flags;
  109.45  	struct td_state     *bs = dd->td_state;
  109.46  	struct tdqcow_state *s  = (struct tdqcow_state *)dd->private;
  109.47  	char *buf;
  109.48 @@ -838,7 +821,9 @@ int tdqcow_open (struct disk_driver *dd,
  109.49  
  109.50   	DPRINTF("QCOW: Opening %s\n",name);
  109.51  
  109.52 -	fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
  109.53 +	o_flags = O_DIRECT | O_LARGEFILE | 
  109.54 +		((flags == TD_RDONLY) ? O_RDONLY : O_RDWR);
  109.55 +	fd = open(name, o_flags);
  109.56  	if (fd < 0) {
  109.57  		DPRINTF("Unable to open %s (%d)\n",name,0 - errno);
  109.58  		return -1;
  109.59 @@ -1016,7 +1001,8 @@ int tdqcow_queue_read(struct disk_driver
  109.60  				 * as busy and try again later */
  109.61  				return cb(dd, -EBUSY, sector + n,
  109.62  					  nb_sectors - n, id, private);
  109.63 -			} else rsp += ret;
  109.64 +			} else
  109.65 +				rsp += ret;
  109.66  		} else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
  109.67  			aio_unlock(s, sector);
  109.68  			if (decompress_cluster(s, cluster_offset) < 0) {
  109.69 @@ -1403,21 +1389,15 @@ int qcow_compress_cluster(struct tdqcow_
  109.70  	return 0;
  109.71  }
  109.72  
  109.73 -int tdqcow_has_parent(struct disk_driver *dd)
  109.74 -{
  109.75 -	struct tdqcow_state *s = (struct tdqcow_state *)dd->private;
  109.76 -	return (s->backing_file_offset ? 1 : 0);
  109.77 -}
  109.78 -
  109.79 -int tdqcow_get_parent(struct disk_driver *cdd, struct disk_driver *pdd)
  109.80 +int tdqcow_get_parent_id(struct disk_driver *dd, struct disk_id *id)
  109.81  {
  109.82  	off_t off;
  109.83  	char *buf, *filename;
  109.84 -	int len, secs, ret = -1;
  109.85 -	struct tdqcow_state *child  = (struct tdqcow_state *)cdd->private;
  109.86 +	int len, secs, err = -EINVAL;
  109.87 +	struct tdqcow_state *child  = (struct tdqcow_state *)dd->private;
  109.88  
  109.89  	if (!child->backing_file_offset)
  109.90 -		return -1;
  109.91 +		return TD_NO_PARENT;
  109.92  
  109.93  	/* read the backing file name */
  109.94  	len  = child->backing_file_size;
  109.95 @@ -1432,14 +1412,39 @@ int tdqcow_get_parent(struct disk_driver
  109.96  
  109.97  	if (read(child->fd, buf, secs << 9) != secs << 9)
  109.98  		goto out;
  109.99 -	filename      = buf + (child->backing_file_offset - off);
 109.100 -	filename[len] = '\0';
 109.101 +	filename       = buf + (child->backing_file_offset - off);
 109.102 +	filename[len]  = '\0';
 109.103  
 109.104 -	/*Open backing file*/
 109.105 -	ret = tdqcow_open(pdd, filename);
 109.106 +	id->name       = strdup(filename);
 109.107 +	id->drivertype = DISK_TYPE_QCOW;
 109.108 +	err            = 0;
 109.109   out:
 109.110  	free(buf);
 109.111 -	return ret;
 109.112 +	return err;
 109.113 +}
 109.114 +
 109.115 +int tdqcow_validate_parent(struct disk_driver *child,
 109.116 +			   struct disk_driver *parent, td_flag_t flags)
 109.117 +{
 109.118 +	struct stat stats;
 109.119 +	uint64_t psize, csize;
 109.120 +	struct tdqcow_state *c = (struct tdqcow_state *)child->private;
 109.121 +	struct tdqcow_state *p = (struct tdqcow_state *)parent->private;
 109.122 +	
 109.123 +	if (stat(p->name, &stats))
 109.124 +		return -EINVAL;
 109.125 +	if (get_filesize(p->name, &psize, &stats))
 109.126 +		return -EINVAL;
 109.127 +
 109.128 +	if (stat(c->name, &stats))
 109.129 +		return -EINVAL;
 109.130 +	if (get_filesize(c->name, &csize, &stats))
 109.131 +		return -EINVAL;
 109.132 +
 109.133 +	if (csize != psize)
 109.134 +		return -EINVAL;
 109.135 +
 109.136 +	return 0;
 109.137  }
 109.138  
 109.139  struct tap_disk tapdisk_qcow = {
 109.140 @@ -1449,8 +1454,8 @@ struct tap_disk tapdisk_qcow = {
 109.141  	.td_queue_read       = tdqcow_queue_read,
 109.142  	.td_queue_write      = tdqcow_queue_write,
 109.143  	.td_submit           = tdqcow_submit,
 109.144 -	.td_has_parent       = tdqcow_has_parent,
 109.145 -	.td_get_parent       = tdqcow_get_parent,
 109.146  	.td_close            = tdqcow_close,
 109.147  	.td_do_callbacks     = tdqcow_do_callbacks,
 109.148 +	.td_get_parent_id    = tdqcow_get_parent_id,
 109.149 +	.td_validate_parent  = tdqcow_validate_parent
 109.150  };
   110.1 --- a/tools/blktap/drivers/block-ram.c	Thu Mar 01 15:02:09 2007 -0700
   110.2 +++ b/tools/blktap/drivers/block-ram.c	Wed Mar 07 12:38:28 2007 -0700
   110.3 @@ -135,11 +135,11 @@ static inline void init_fds(struct disk_
   110.4  }
   110.5  
   110.6  /* Open the disk file and initialize ram state. */
   110.7 -int tdram_open (struct disk_driver *dd, const char *name)
   110.8 +int tdram_open (struct disk_driver *dd, const char *name, td_flag_t flags)
   110.9  {
  110.10  	char *p;
  110.11  	uint64_t size;
  110.12 -	int i, fd, ret = 0, count = 0;
  110.13 +	int i, fd, ret = 0, count = 0, o_flags;
  110.14  	struct td_state    *s     = dd->td_state;
  110.15  	struct tdram_state *prv   = (struct tdram_state *)dd->private;
  110.16  
  110.17 @@ -167,12 +167,15 @@ int tdram_open (struct disk_driver *dd, 
  110.18  	}
  110.19  
  110.20  	/* Open the file */
  110.21 -        fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
  110.22 +	o_flags = O_DIRECT | O_LARGEFILE | 
  110.23 +		((flags == TD_RDONLY) ? O_RDONLY : O_RDWR);
  110.24 +        fd = open(name, o_flags);
  110.25  
  110.26          if ((fd == -1) && (errno == EINVAL)) {
  110.27  
  110.28                  /* Maybe O_DIRECT isn't supported. */
  110.29 -                fd = open(name, O_RDWR | O_LARGEFILE);
  110.30 +		o_flags &= ~O_DIRECT;
  110.31 +                fd = open(name, o_flags);
  110.32                  if (fd != -1) DPRINTF("WARNING: Accessing image without"
  110.33                                       "O_DIRECT! (%s)\n", name);
  110.34  
  110.35 @@ -275,12 +278,13 @@ int tdram_do_callbacks(struct disk_drive
  110.36  	return 1;
  110.37  }
  110.38  
  110.39 -int tdram_has_parent(struct disk_driver *dd)
  110.40 +int tdram_get_parent_id(struct disk_driver *dd, struct disk_id *id)
  110.41  {
  110.42 -	return 0;
  110.43 +	return TD_NO_PARENT;
  110.44  }
  110.45  
  110.46 -int tdram_get_parent(struct disk_driver *dd, struct disk_driver *parent)
  110.47 +int tdram_validate_parent(struct disk_driver *dd, 
  110.48 +			  struct disk_driver *parent, td_flag_t flags)
  110.49  {
  110.50  	return -EINVAL;
  110.51  }
  110.52 @@ -292,8 +296,8 @@ struct tap_disk tapdisk_ram = {
  110.53  	.td_queue_read      = tdram_queue_read,
  110.54  	.td_queue_write     = tdram_queue_write,
  110.55  	.td_submit          = tdram_submit,
  110.56 -	.td_has_parent      = tdram_has_parent,
  110.57 -	.td_get_parent      = tdram_get_parent,
  110.58  	.td_close           = tdram_close,
  110.59  	.td_do_callbacks    = tdram_do_callbacks,
  110.60 +	.td_get_parent_id   = tdram_get_parent_id,
  110.61 +	.td_validate_parent = tdram_validate_parent
  110.62  };
   111.1 --- a/tools/blktap/drivers/block-sync.c	Thu Mar 01 15:02:09 2007 -0700
   111.2 +++ b/tools/blktap/drivers/block-sync.c	Wed Mar 07 12:38:28 2007 -0700
   111.3 @@ -118,9 +118,9 @@ static inline void init_fds(struct disk_
   111.4  }
   111.5  
   111.6  /* Open the disk file and initialize aio state. */
   111.7 -int tdsync_open (struct disk_driver *dd, const char *name)
   111.8 +int tdsync_open (struct disk_driver *dd, const char *name, td_flag_t flags)
   111.9  {
  111.10 -	int i, fd, ret = 0;
  111.11 +	int i, fd, ret = 0, o_flags;
  111.12  	struct td_state     *s   = dd->td_state;
  111.13  	struct tdsync_state *prv = (struct tdsync_state *)dd->private;
  111.14  	
  111.15 @@ -130,11 +130,14 @@ int tdsync_open (struct disk_driver *dd,
  111.16  		return (0 - errno);
  111.17  	
  111.18  	/* Open the file */
  111.19 -        fd = open(name, O_RDWR | O_DIRECT | O_LARGEFILE);
  111.20 +	o_flags = O_DIRECT | O_LARGEFILE | 
  111.21 +		((flags == TD_RDONLY) ? O_RDONLY : O_RDWR);
  111.22 +        fd = open(name, o_flags);
  111.23  
  111.24          if ( (fd == -1) && (errno == EINVAL) ) {
  111.25  
  111.26                  /* Maybe O_DIRECT isn't supported. */
  111.27 +		o_flags &= ~O_DIRECT;
  111.28                  fd = open(name, O_RDWR | O_LARGEFILE);
  111.29                  if (fd != -1) DPRINTF("WARNING: Accessing image without"
  111.30                                       "O_DIRECT! (%s)\n", name);
  111.31 @@ -223,12 +226,13 @@ int tdsync_do_callbacks(struct disk_driv
  111.32  	return 1;
  111.33  }
  111.34  
  111.35 -int tdsync_has_parent(struct disk_driver *dd)
  111.36 +int tdsync_get_parent_id(struct disk_driver *dd, struct disk_id *id)
  111.37  {
  111.38 -	return 0;
  111.39 +	return TD_NO_PARENT;
  111.40  }
  111.41  
  111.42 -int tdsync_get_parent(struct disk_driver *dd, struct disk_driver *parent)
  111.43 +int tdsync_validate_parent(struct disk_driver *dd, 
  111.44 +			   struct disk_driver *parent, td_flag_t flags)
  111.45  {
  111.46  	return -EINVAL;
  111.47  }
  111.48 @@ -240,8 +244,8 @@ struct tap_disk tapdisk_sync = {
  111.49  	.td_queue_read       = tdsync_queue_read,
  111.50  	.td_queue_write      = tdsync_queue_write,
  111.51  	.td_submit           = tdsync_submit,
  111.52 -	.td_has_parent       = tdsync_has_parent,
  111.53 -	.td_get_parent       = tdsync_get_parent,
  111.54  	.td_close            = tdsync_close,
  111.55  	.td_do_callbacks     = tdsync_do_callbacks,
  111.56 +	.td_get_parent_id    = tdsync_get_parent_id,
  111.57 +	.td_validate_parent  = tdsync_validate_parent
  111.58  };
   112.1 --- a/tools/blktap/drivers/block-vmdk.c	Thu Mar 01 15:02:09 2007 -0700
   112.2 +++ b/tools/blktap/drivers/block-vmdk.c	Wed Mar 07 12:38:28 2007 -0700
   112.3 @@ -119,10 +119,11 @@ static inline void init_fds(struct disk_
   112.4  }
   112.5  
   112.6  /* Open the disk file and initialize aio state. */
   112.7 -static int tdvmdk_open (struct disk_driver *dd, const char *name)
   112.8 +static int tdvmdk_open (struct disk_driver *dd, 
   112.9 +			const char *name, td_flag_t flags)
  112.10  {
  112.11  	int ret, fd;
  112.12 -    	int l1_size, i;
  112.13 +    	int l1_size, i, o_flags;
  112.14      	uint32_t magic;
  112.15  	struct td_state     *s   = dd->td_state;
  112.16  	struct tdvmdk_state *prv = (struct tdvmdk_state *)dd->private;
  112.17 @@ -133,12 +134,15 @@ static int tdvmdk_open (struct disk_driv
  112.18  		return -1;
  112.19  	
  112.20  	/* Open the file */
  112.21 -        fd = open(name, O_RDWR | O_LARGEFILE); 
  112.22 +	o_flags = O_DIRECT | O_LARGEFILE | 
  112.23 +		((flags == TD_RDONLY) ? O_RDONLY : O_RDWR);
  112.24 +        fd = open(name, o_flags); 
  112.25  
  112.26          if ( (fd == -1) && (errno == EINVAL) ) {
  112.27  
  112.28                  /* Maybe O_DIRECT isn't supported. */
  112.29 -                fd = open(name, O_RDWR | O_LARGEFILE);
  112.30 +		o_flags &= ~O_DIRECT;
  112.31 +                fd = open(name, o_flags);
  112.32                  if (fd != -1) DPRINTF("WARNING: Accessing image without"
  112.33                                       "O_DIRECT! (%s)\n", name);
  112.34  
  112.35 @@ -394,12 +398,13 @@ static int tdvmdk_do_callbacks(struct di
  112.36  	return 1;
  112.37  }
  112.38  
  112.39 -static int tdvmdk_has_parent(struct disk_driver *dd)
  112.40 +static int tdvmdk_get_parent_id(struct disk_driver *dd, struct disk_id *id)
  112.41  {
  112.42 -	return 0;
  112.43 +	return TD_NO_PARENT;
  112.44  }
  112.45  
  112.46 -static int tdvmdk_get_parent(struct disk_driver *dd, struct disk_driver *parent)
  112.47 +static int tdvmdk_validate_parent(struct disk_driver *dd, 
  112.48 +				  struct disk_driver *parent, td_flag_t flags)
  112.49  {
  112.50  	return -EINVAL;
  112.51  }
  112.52 @@ -411,8 +416,8 @@ struct tap_disk tapdisk_vmdk = {
  112.53  	.td_queue_read       = tdvmdk_queue_read,
  112.54  	.td_queue_write      = tdvmdk_queue_write,
  112.55  	.td_submit           = tdvmdk_submit,
  112.56 -	.td_has_parent       = tdvmdk_has_parent,
  112.57 -	.td_get_parent       = tdvmdk_get_parent,
  112.58  	.td_close            = tdvmdk_close,
  112.59  	.td_do_callbacks     = tdvmdk_do_callbacks,
  112.60 +	.td_get_parent_id    = tdvmdk_get_parent_id,
  112.61 +	.td_validate_parent  = tdvmdk_validate_parent
  112.62  };
   113.1 --- a/tools/blktap/drivers/img2qcow.c	Thu Mar 01 15:02:09 2007 -0700
   113.2 +++ b/tools/blktap/drivers/img2qcow.c	Wed Mar 07 12:38:28 2007 -0700
   113.3 @@ -201,7 +201,7 @@ int main(int argc, char *argv[])
   113.4  	dd.private  = malloc(dd.drv->private_data_size);
   113.5  
   113.6          /*Open qcow file*/
   113.7 -        if (dd.drv->td_open(&dd, argv[1])!=0) {
   113.8 +        if (dd.drv->td_open(&dd, argv[1], 0)!=0) {
   113.9  		DFPRINTF("Unable to open Qcow file [%s]\n",argv[1]);
  113.10  		exit(-1);
  113.11  	}
   114.1 --- a/tools/blktap/drivers/qcow2raw.c	Thu Mar 01 15:02:09 2007 -0700
   114.2 +++ b/tools/blktap/drivers/qcow2raw.c	Wed Mar 07 12:38:28 2007 -0700
   114.3 @@ -169,7 +169,7 @@ int main(int argc, char *argv[])
   114.4  	ddqcow.drv = &tapdisk_qcow;
   114.5  	ddqcow.private = malloc(ddqcow.drv->private_data_size);
   114.6  
   114.7 -        if (ddqcow.drv->td_open(&ddqcow, argv[2])!=0) {
   114.8 +        if (ddqcow.drv->td_open(&ddqcow, argv[2], TD_RDONLY)!=0) {
   114.9  		DFPRINTF("Unable to open Qcow file [%s]\n",argv[2]);
  114.10  		exit(-1);
  114.11  	} else DFPRINTF("QCOW file opened, size %llu\n",
  114.12 @@ -270,7 +270,7 @@ int main(int argc, char *argv[])
  114.13  	ddaio.drv = &tapdisk_aio;
  114.14  	ddaio.private = malloc(ddaio.drv->private_data_size);
  114.15  
  114.16 -        if (ddaio.drv->td_open(&ddaio, argv[1])!=0) {
  114.17 +        if (ddaio.drv->td_open(&ddaio, argv[1], 0)!=0) {
  114.18  		DFPRINTF("Unable to open Qcow file [%s]\n", argv[1]);
  114.19  		exit(-1);
  114.20  	}
   115.1 --- a/tools/blktap/drivers/tapdisk.c	Thu Mar 01 15:02:09 2007 -0700
   115.2 +++ b/tools/blktap/drivers/tapdisk.c	Wed Mar 07 12:38:28 2007 -0700
   115.3 @@ -81,6 +81,15 @@ void daemonize(void)
   115.4  	return;
   115.5  }
   115.6  
   115.7 +static void free_driver(struct disk_driver *d)
   115.8 +{
   115.9 +	if (d->name)
  115.10 +		free(d->name);
  115.11 +	if (d->private)
  115.12 +		free(d->private);
  115.13 +	free(d);
  115.14 +}
  115.15 +
  115.16  static void unmap_disk(struct td_state *s)
  115.17  {
  115.18  	tapdev_info_t *info = s->ring_info;
  115.19 @@ -91,8 +100,7 @@ static void unmap_disk(struct td_state *
  115.20  	while (dd) {
  115.21  		tmp = dd->next;
  115.22  		dd->drv->td_close(dd);
  115.23 -		free(dd->private);
  115.24 -		free(dd);
  115.25 +		free_driver(dd);
  115.26  		dd = tmp;
  115.27  	}
  115.28  
  115.29 @@ -112,7 +120,6 @@ static void unmap_disk(struct td_state *
  115.30  	free(s);
  115.31  
  115.32  	return;
  115.33 -
  115.34  }
  115.35  
  115.36  void sig_handler(int sig)
  115.37 @@ -205,26 +212,6 @@ static struct td_state *state_init(void)
  115.38  	return s;
  115.39  }
  115.40  
  115.41 -static struct disk_driver *disk_init(struct td_state *s, struct tap_disk *drv)
  115.42 -{
  115.43 -	struct disk_driver *dd;
  115.44 -
  115.45 -	dd = calloc(1, sizeof(struct disk_driver));
  115.46 -	if (!dd)
  115.47 -		return NULL;
  115.48 -	
  115.49 -	dd->private = malloc(drv->private_data_size);
  115.50 -	if (!dd->private) {
  115.51 -		free(dd);
  115.52 -		return NULL;
  115.53 -	}
  115.54 -
  115.55 -	dd->drv      = drv;
  115.56 -	dd->td_state = s;
  115.57 -
  115.58 -	return dd;
  115.59 -}
  115.60 -
  115.61  static int map_new_dev(struct td_state *s, int minor)
  115.62  {
  115.63  	int tap_fd;
  115.64 @@ -280,49 +267,104 @@ static int map_new_dev(struct td_state *
  115.65  	return -1;
  115.66  }
  115.67  
  115.68 -static int open_disk(struct td_state *s, struct disk_driver *dd, char *path)
  115.69 +static struct disk_driver *disk_init(struct td_state *s, 
  115.70 +				     struct tap_disk *drv, 
  115.71 +				     char *name, td_flag_t flags)
  115.72 +{
  115.73 +	struct disk_driver *dd;
  115.74 +
  115.75 +	dd = calloc(1, sizeof(struct disk_driver));
  115.76 +	if (!dd)
  115.77 +		return NULL;
  115.78 +	
  115.79 +	dd->private = malloc(drv->private_data_size);
  115.80 +	if (!dd->private) {
  115.81 +		free(dd);
  115.82 +		return NULL;
  115.83 +	}
  115.84 +
  115.85 +	dd->drv      = drv;
  115.86 +	dd->td_state = s;
  115.87 +	dd->name     = name;
  115.88 +	dd->flags    = flags;
  115.89 +
  115.90 +	return dd;
  115.91 +}
  115.92 +
  115.93 +static int open_disk(struct td_state *s, 
  115.94 +		     struct tap_disk *drv, char *path, td_flag_t flags)
  115.95  {
  115.96  	int err;
  115.97 -	struct disk_driver *d = dd;
  115.98 +	char *dup;
  115.99 +	td_flag_t pflags;
 115.100 +	struct disk_id id;
 115.101 +	struct disk_driver *d;
 115.102 +
 115.103 +	dup = strdup(path);
 115.104 +	if (!dup)
 115.105 +		return -ENOMEM;
 115.106  
 115.107 -	err = dd->drv->td_open(dd, path);
 115.108 -	if (err)
 115.109 -		return err;
 115.110 +	memset(&id, 0, sizeof(struct disk_id));
 115.111 +	s->disks = d = disk_init(s, drv, dup, flags);
 115.112 +	if (!d)
 115.113 +		return -ENOMEM;
 115.114 +
 115.115 +	err = drv->td_open(d, path, flags);
 115.116 +	if (err) {
 115.117 +		free_driver(d);
 115.118 +		s->disks = NULL;
 115.119 +		return -ENOMEM;
 115.120 +	}
 115.121 +	pflags = flags | TD_RDONLY;
 115.122  
 115.123  	/* load backing files as necessary */
 115.124 -	while (d->drv->td_has_parent(d)) {
 115.125 +	while ((err = d->drv->td_get_parent_id(d, &id)) == 0) {
 115.126  		struct disk_driver *new;
 115.127  		
 115.128 -		new = calloc(1, sizeof(struct disk_driver));
 115.129 +		if (id.drivertype > MAX_DISK_TYPES || 
 115.130 +		    !get_driver(id.drivertype) || !id.name)
 115.131 +			goto fail;
 115.132 +
 115.133 +		dup = strdup(id.name);
 115.134 +		if (!dup)
 115.135 +			goto fail;
 115.136 +
 115.137 +		new = disk_init(s, get_driver(id.drivertype), dup, pflags);
 115.138  		if (!new)
 115.139  			goto fail;
 115.140 -		new->drv      = d->drv;
 115.141 -		new->td_state = s;
 115.142 -		new->private  = malloc(new->drv->private_data_size);
 115.143 -		if (!new->private) {
 115.144 -			free(new);
 115.145 -			goto fail;
 115.146 -		}
 115.147 -		
 115.148 -		err = d->drv->td_get_parent(d, new);
 115.149 +
 115.150 +		err = new->drv->td_open(new, new->name, pflags);
 115.151  		if (err)
 115.152  			goto fail;
 115.153  
 115.154 +		err = d->drv->td_validate_parent(d, new, 0);
 115.155 +		if (err) {
 115.156 +			d->next = new;
 115.157 +			goto fail;
 115.158 +		}
 115.159 +
 115.160  		d = d->next = new;
 115.161 +		free(id.name);
 115.162  	}
 115.163  
 115.164 -	return 0;
 115.165 +	s->info |= ((flags & TD_RDONLY) ? VDISK_READONLY : 0);
 115.166 +
 115.167 +	if (err >= 0)
 115.168 +		return 0;
 115.169  
 115.170   fail:
 115.171  	DPRINTF("failed opening disk\n");
 115.172 -	while (dd) {
 115.173 -		d = dd->next;
 115.174 -		dd->drv->td_close(dd);
 115.175 -		free(dd->private);
 115.176 -		free(dd);
 115.177 -		dd = d;
 115.178 +	if (id.name)
 115.179 +		free(id.name);
 115.180 +	d = s->disks;
 115.181 +	while (d) {
 115.182 +		struct disk_driver *tmp = d->next;
 115.183 +		d->drv->td_close(d);
 115.184 +		free_driver(d);
 115.185 +		d = tmp;
 115.186  	}
 115.187 -	return err;
 115.188 +	s->disks = NULL;
 115.189 +	return -1;
 115.190  }
 115.191  
 115.192  static int read_msg(char *buf)
 115.193 @@ -334,7 +376,6 @@ static int read_msg(char *buf)
 115.194  	msg_newdev_t *msg_dev;
 115.195  	msg_pid_t *msg_pid;
 115.196  	struct tap_disk *drv;
 115.197 -	struct disk_driver *dd;
 115.198  	int ret = -1;
 115.199  	struct td_state *s = NULL;
 115.200  	fd_list_entry_t *entry;
 115.201 @@ -369,14 +410,9 @@ static int read_msg(char *buf)
 115.202  			if (s == NULL)
 115.203  				goto params_done;
 115.204  
 115.205 -			s->disks = dd = disk_init(s, drv);
 115.206 -			if (!dd) {
 115.207 -				free(s);
 115.208 -				goto params_done;
 115.209 -			}
 115.210 -
 115.211  			/*Open file*/
 115.212 -			ret = open_disk(s, dd, path);
 115.213 +			ret = open_disk(s, drv, path, 
 115.214 +					((msg->readonly) ? TD_RDONLY : 0));
 115.215  			if (ret)
 115.216  				goto params_done;
 115.217  
 115.218 @@ -482,7 +518,8 @@ void io_done(struct disk_driver *dd, int
 115.219  
 115.220  	if (!run) return; /*We have received signal to close*/
 115.221  
 115.222 -	if (drv->td_do_callbacks(dd, sid) > 0) kick_responses(dd->td_state);
 115.223 +	if (sid > MAX_IOFD || drv->td_do_callbacks(dd, sid) > 0)
 115.224 +		kick_responses(dd->td_state);
 115.225  
 115.226  	return;
 115.227  }
 115.228 @@ -633,6 +670,12 @@ static void get_io_request(struct td_sta
 115.229  			sector_nr = req->sector_number;
 115.230  		}
 115.231  
 115.232 +		if ((dd->flags & TD_RDONLY) && 
 115.233 +		    (req->operation == BLKIF_OP_WRITE)) {
 115.234 +			blkif->pending_list[idx].status = BLKIF_RSP_ERROR;
 115.235 +			goto send_response;
 115.236 +		}
 115.237 +
 115.238  		for (i = start_seg; i < req->nr_segments; i++) {
 115.239  			nsects = req->seg[i].last_sect - 
 115.240  				 req->seg[i].first_sect + 1;
 115.241 @@ -698,10 +741,12 @@ static void get_io_request(struct td_sta
 115.242  			}
 115.243  			sector_nr += nsects;
 115.244  		}
 115.245 +	send_response:
 115.246  		blkif->pending_list[idx].submitting = 0;
 115.247  		/* force write_rsp_to_ring for synchronous case */
 115.248  		if (blkif->pending_list[idx].secs_pending == 0)
 115.249 -			dd->early += send_responses(dd, 0, 0, 0, idx, (void *)0);
 115.250 +			dd->early += send_responses(dd, 0, 0, 0, idx, 
 115.251 +						    (void *)(long)0);
 115.252  	}
 115.253  
 115.254   out:
 115.255 @@ -709,7 +754,7 @@ static void get_io_request(struct td_sta
 115.256  	td_for_each_disk(s, dd) {
 115.257  		dd->early += dd->drv->td_submit(dd);
 115.258  		if (dd->early > 0) {
 115.259 -			io_done(dd, 10);
 115.260 +			io_done(dd, MAX_IOFD + 1);
 115.261  			dd->early = 0;
 115.262  		}
 115.263  	}
 115.264 @@ -785,6 +830,20 @@ int main(int argc, char *argv[])
 115.265  					}
 115.266  				}
 115.267  
 115.268 +				/* completed io from above may have 
 115.269 +				 * queued new requests on chained disks */
 115.270 +				if (progress_made) {
 115.271 +					td_for_each_disk(ptr->s, dd) {
 115.272 +						dd->early += 
 115.273 +							dd->drv->td_submit(dd);
 115.274 +						if (dd->early > 0) {
 115.275 +							io_done(dd, 
 115.276 +								MAX_IOFD + 1);
 115.277 +							dd->early = 0;
 115.278 +						}
 115.279 +					}
 115.280 +				}
 115.281 +
 115.282  				if (FD_ISSET(ptr->tap_fd, &readfds) ||
 115.283  				    (info->busy.req && progress_made))
 115.284  					get_io_request(ptr->s);
   116.1 --- a/tools/blktap/drivers/tapdisk.h	Thu Mar 01 15:02:09 2007 -0700
   116.2 +++ b/tools/blktap/drivers/tapdisk.h	Wed Mar 07 12:38:28 2007 -0700
   116.3 @@ -42,10 +42,15 @@
   116.4   * 
   116.5   *   - The fd used for poll is an otherwise unused pipe, which allows poll to 
   116.6   *     be safely called without ever returning anything.
   116.7 - * 
   116.8 + *
   116.9   * NOTE: tapdisk uses the number of sectors submitted per request as a 
  116.10   * ref count.  Plugins must use the callback function to communicate the
  116.11   * completion--or error--of every sector submitted to them.
  116.12 + *
  116.13 + * td_get_parent_id returns:
  116.14 + *     0 if parent id successfully retrieved
  116.15 + *     TD_NO_PARENT if no parent exists
  116.16 + *     -errno on error
  116.17   */
  116.18  
  116.19  #ifndef TAPDISK_H_
  116.20 @@ -71,13 +76,25 @@
  116.21  #define MAX_IOFD                 2
  116.22  
  116.23  #define BLK_NOT_ALLOCATED       99
  116.24 +#define TD_NO_PARENT             1
  116.25 +
  116.26 +typedef uint32_t td_flag_t;
  116.27 +
  116.28 +#define TD_RDONLY                1
  116.29  
  116.30  struct td_state;
  116.31  struct tap_disk;
  116.32  
  116.33 +struct disk_id {
  116.34 +	char *name;
  116.35 +	int drivertype;
  116.36 +};
  116.37 +
  116.38  struct disk_driver {
  116.39  	int early;
  116.40 +	char *name;
  116.41  	void *private;
  116.42 +	td_flag_t flags;
  116.43  	int io_fd[MAX_IOFD];
  116.44  	struct tap_disk *drv;
  116.45  	struct td_state *td_state;
  116.46 @@ -105,18 +122,20 @@ typedef int (*td_callback_t)(struct disk
  116.47  struct tap_disk {
  116.48  	const char *disk_type;
  116.49  	int private_data_size;
  116.50 -	int (*td_open)        (struct disk_driver *dd, const char *name);
  116.51 -	int (*td_queue_read)  (struct disk_driver *dd, uint64_t sector,
  116.52 -			       int nb_sectors, char *buf, td_callback_t cb, 
  116.53 -			       int id, void *prv);
  116.54 -	int (*td_queue_write) (struct disk_driver *dd, uint64_t sector,
  116.55 -			       int nb_sectors, char *buf, td_callback_t cb, 
  116.56 -			       int id, void *prv);
  116.57 -	int (*td_submit)      (struct disk_driver *dd);
  116.58 -	int (*td_has_parent)  (struct disk_driver *dd);
  116.59 -	int (*td_get_parent)  (struct disk_driver *dd, struct disk_driver *p);
  116.60 -	int (*td_close)       (struct disk_driver *dd);
  116.61 -	int (*td_do_callbacks)(struct disk_driver *dd, int sid);
  116.62 +	int (*td_open)           (struct disk_driver *dd, 
  116.63 +				  const char *name, td_flag_t flags);
  116.64 +	int (*td_queue_read)     (struct disk_driver *dd, uint64_t sector,
  116.65 +				  int nb_sectors, char *buf, td_callback_t cb,
  116.66 +				  int id, void *prv);
  116.67 +	int (*td_queue_write)    (struct disk_driver *dd, uint64_t sector,
  116.68 +				  int nb_sectors, char *buf, td_callback_t cb, 
  116.69 +				  int id, void *prv);
  116.70 +	int (*td_submit)         (struct disk_driver *dd);
  116.71 +	int (*td_close)          (struct disk_driver *dd);
  116.72 +	int (*td_do_callbacks)   (struct disk_driver *dd, int sid);
  116.73 +	int (*td_get_parent_id)  (struct disk_driver *dd, struct disk_id *id);
  116.74 +	int (*td_validate_parent)(struct disk_driver *dd, 
  116.75 +				  struct disk_driver *p, td_flag_t flags);
  116.76  };
  116.77  
  116.78  typedef struct disk_info {
   117.1 --- a/tools/blktap/lib/Makefile	Thu Mar 01 15:02:09 2007 -0700
   117.2 +++ b/tools/blktap/lib/Makefile	Wed Mar 07 12:38:28 2007 -0700
   117.3 @@ -40,8 +40,8 @@ build: libblktap.a
   117.4  libblktap: libblktap.a
   117.5  
   117.6  install: all
   117.7 -	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
   117.8 -	$(INSTALL_DIR) -p $(DESTDIR)/usr/include
   117.9 +	$(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
  117.10 +	$(INSTALL_DIR) $(DESTDIR)/usr/include
  117.11  	$(INSTALL_PROG) $(LIB) $(DESTDIR)/usr/$(LIBDIR)
  117.12  	ln -sf libblktap.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libblktap.so.$(MAJOR)
  117.13  	ln -sf libblktap.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libblktap.so
   118.1 --- a/tools/blktap/lib/blktaplib.h	Thu Mar 01 15:02:09 2007 -0700
   118.2 +++ b/tools/blktap/lib/blktaplib.h	Wed Mar 07 12:38:28 2007 -0700
   118.3 @@ -173,6 +173,7 @@ typedef struct msg_hdr {
   118.4  	uint16_t   len;
   118.5  	uint16_t   drivertype;
   118.6  	uint16_t   cookie;
   118.7 +	uint8_t    readonly;
   118.8  } msg_hdr_t;
   118.9  
  118.10  typedef struct msg_newdev {
   119.1 --- a/tools/blktap/lib/xenbus.c	Thu Mar 01 15:02:09 2007 -0700
   119.2 +++ b/tools/blktap/lib/xenbus.c	Wed Mar 07 12:38:28 2007 -0700
   119.3 @@ -177,8 +177,11 @@ static void ueblktap_setup(struct xs_han
   119.4  	}
   119.5  
   119.6  	/* Check to see if device is to be opened read-only. */
   119.7 -	asprintf(&path, "%s/%s", bepath, "read-only");
   119.8 -	if (xs_exists(h, path))
   119.9 +	deverr = xs_gather(h, bepath, "mode", NULL, &path, NULL);
  119.10 +	if (deverr) {
  119.11 +		DPRINTF("ERROR: could not find read/write mode\n");
  119.12 +		goto fail;
  119.13 +	} else if (path[0] == 'r')
  119.14  		be->readonly = 1;
  119.15  
  119.16  	if (be->blkif == NULL) {
   120.1 --- a/tools/console/Makefile	Thu Mar 01 15:02:09 2007 -0700
   120.2 +++ b/tools/console/Makefile	Wed Mar 07 12:38:28 2007 -0700
   120.3 @@ -30,7 +30,7 @@ xenconsole: $(patsubst %.c,%.o,$(wildcar
   120.4  
   120.5  .PHONY: install
   120.6  install: $(BIN)
   120.7 -	$(INSTALL_DIR) -p $(DESTDIR)/$(DAEMON_INSTALL_DIR)
   120.8 +	$(INSTALL_DIR) $(DESTDIR)/$(DAEMON_INSTALL_DIR)
   120.9  	$(INSTALL_PROG) xenconsoled $(DESTDIR)/$(DAEMON_INSTALL_DIR)
  120.10 -	$(INSTALL_DIR) -p $(DESTDIR)/$(CLIENT_INSTALL_DIR)
  120.11 +	$(INSTALL_DIR) $(DESTDIR)/$(CLIENT_INSTALL_DIR)
  120.12  	$(INSTALL_PROG) xenconsole $(DESTDIR)/$(CLIENT_INSTALL_DIR)
   121.1 --- a/tools/examples/init.d/xendomains	Thu Mar 01 15:02:09 2007 -0700
   121.2 +++ b/tools/examples/init.d/xendomains	Wed Mar 07 12:38:28 2007 -0700
   121.3 @@ -58,18 +58,7 @@ else
   121.4  	_SMSG=(done failed failed missed failed skipped unused failed failed)
   121.5  	_RC_UNUSED=6
   121.6      fi
   121.7 -    if test -e /lib/lsb/init-functions; then
   121.8 -	# LSB    
   121.9 -    	. /lib/lsb/init-functions
  121.10 -	echo_rc()
  121.11 -	{
  121.12 -	    if test ${_RC_RV} = 0; then
  121.13 -		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
  121.14 -	    else
  121.15 -		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
  121.16 -	    fi
  121.17 -	}
  121.18 -    elif test -e /etc/init.d/functions; then
  121.19 +    if test -e /etc/init.d/functions; then
  121.20  	# REDHAT
  121.21  	. /etc/init.d/functions
  121.22  	echo_rc()
  121.23 @@ -81,6 +70,24 @@ else
  121.24  		failure "  [${_SMSG[${_RC_RV}]}] "
  121.25  	    fi
  121.26  	}
  121.27 +    elif test -e /lib/lsb/init-functions; then
  121.28 +	# LSB    
  121.29 +    	. /lib/lsb/init-functions
  121.30 +        if alias log_success_msg >/dev/null 2>/dev/null; then
  121.31 +	  echo_rc()
  121.32 +	  {
  121.33 +	       echo "  [${_SMSG[${_RC_RV}]}] "
  121.34 +	  }
  121.35 +        else
  121.36 +	  echo_rc()
  121.37 +	  {
  121.38 +	    if test ${_RC_RV} = 0; then
  121.39 +		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
  121.40 +	    else
  121.41 +		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
  121.42 +	    fi
  121.43 +	  }
  121.44 +        fi
  121.45      else    
  121.46  	# emulate it
  121.47  	echo_rc()
   122.1 --- a/tools/firmware/hvmloader/acpi/dsdt.asl	Thu Mar 01 15:02:09 2007 -0700
   122.2 +++ b/tools/firmware/hvmloader/acpi/dsdt.asl	Wed Mar 07 12:38:28 2007 -0700
   122.3 @@ -123,7 +123,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
   122.4              }
   122.5  
   122.6              Name(BUFA, ResourceTemplate() {
   122.7 -                IRQ(Level, ActiveLow, Shared) { 5, 6, 10, 11 }
   122.8 +                IRQ(Level, ActiveLow, Shared) { 5, 7, 10, 11 }
   122.9              })
  122.10  
  122.11              Name(BUFB, Buffer() {
  122.12 @@ -643,22 +643,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
  122.13                          IRQNoFlags () {4}
  122.14                      })
  122.15                  }
  122.16 -
  122.17 -                Device (LTP1)
  122.18 -                {
  122.19 -                    Name (_HID, EisaId ("PNP0400"))
  122.20 -                    Name (_UID, 0x02)
  122.21 -                    Method (_STA, 0, NotSerialized)
  122.22 -                    {
  122.23 -                        Return (0x0F)
  122.24 -                    }
  122.25 -
  122.26 -                    Name (_CRS, ResourceTemplate()
  122.27 -                    {
  122.28 -                        IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
  122.29 -                        IRQNoFlags () {7}
  122.30 -                    })
  122.31 -                } 
  122.32              }
  122.33          }
  122.34      }
   123.1 --- a/tools/firmware/hvmloader/acpi/dsdt.c	Thu Mar 01 15:02:09 2007 -0700
   123.2 +++ b/tools/firmware/hvmloader/acpi/dsdt.c	Wed Mar 07 12:38:28 2007 -0700
   123.3 @@ -5,15 +5,15 @@
   123.4   * Copyright (C) 2000 - 2006 Intel Corporation
   123.5   * Supports ACPI Specification Revision 3.0a
   123.6   * 
   123.7 - * Compilation of "dsdt.asl" - Fri Feb 16 15:14:37 2007
   123.8 + * Compilation of "dsdt.asl" - Mon Feb 26 11:09:49 2007
   123.9   * 
  123.10   * C source code output
  123.11   *
  123.12   */
  123.13  unsigned char AmlCode[] =
  123.14  {
  123.15 -    0x44,0x53,0x44,0x54,0x9F,0x0D,0x00,0x00,  /* 00000000    "DSDT...." */
  123.16 -    0x02,0xEE,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    "..Xen..." */
  123.17 +    0x44,0x53,0x44,0x54,0x67,0x0D,0x00,0x00,  /* 00000000    "DSDTg..." */
  123.18 +    0x02,0xE0,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    "..Xen..." */
  123.19      0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "HVM....." */
  123.20      0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
  123.21      0x07,0x07,0x06,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
  123.22 @@ -27,7 +27,7 @@ unsigned char AmlCode[] =
  123.23      0x04,0x0A,0x07,0x0A,0x07,0x00,0x00,0x08,  /* 00000060    "........" */
  123.24      0x50,0x49,0x43,0x44,0x00,0x14,0x0C,0x5F,  /* 00000068    "PICD..._" */
  123.25      0x50,0x49,0x43,0x01,0x70,0x68,0x50,0x49,  /* 00000070    "PIC.phPI" */
  123.26 -    0x43,0x44,0x10,0x44,0xD2,0x5F,0x53,0x42,  /* 00000078    "CD.D._SB" */
  123.27 +    0x43,0x44,0x10,0x4C,0xCE,0x5F,0x53,0x42,  /* 00000078    "CD.L._SB" */
  123.28      0x5F,0x5B,0x82,0x49,0x04,0x4D,0x45,0x4D,  /* 00000080    "_[.I.MEM" */
  123.29      0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000088    "0._HID.A" */
  123.30      0xD0,0x0C,0x02,0x08,0x5F,0x43,0x52,0x53,  /* 00000090    "...._CRS" */
  123.31 @@ -37,7 +37,7 @@ unsigned char AmlCode[] =
  123.32      0x00,0x00,0xFF,0xFF,0x09,0x00,0x00,0x00,  /* 000000B0    "........" */
  123.33      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000B8    "........" */
  123.34      0x00,0x00,0x00,0x00,0x0A,0x00,0x00,0x00,  /* 000000C0    "........" */
  123.35 -    0x00,0x00,0x79,0x00,0x5B,0x82,0x41,0xCD,  /* 000000C8    "..y.[.A." */
  123.36 +    0x00,0x00,0x79,0x00,0x5B,0x82,0x49,0xC9,  /* 000000C8    "..y.[.I." */
  123.37      0x50,0x43,0x49,0x30,0x08,0x5F,0x48,0x49,  /* 000000D0    "PCI0._HI" */
  123.38      0x44,0x0C,0x41,0xD0,0x0A,0x03,0x08,0x5F,  /* 000000D8    "D.A...._" */
  123.39      0x55,0x49,0x44,0x00,0x08,0x5F,0x41,0x44,  /* 000000E0    "UID.._AD" */
  123.40 @@ -59,7 +59,7 @@ unsigned char AmlCode[] =
  123.41      0x00,0xF0,0xFF,0xFF,0xFF,0xF4,0x00,0x00,  /* 00000160    "........" */
  123.42      0x00,0x00,0x00,0x00,0x00,0x05,0x79,0x00,  /* 00000168    "......y." */
  123.43      0xA4,0x50,0x52,0x54,0x30,0x08,0x42,0x55,  /* 00000170    ".PRT0.BU" */
  123.44 -    0x46,0x41,0x11,0x09,0x0A,0x06,0x23,0x60,  /* 00000178    "FA....#`" */
  123.45 +    0x46,0x41,0x11,0x09,0x0A,0x06,0x23,0xA0,  /* 00000178    "FA....#." */
  123.46      0x0C,0x18,0x79,0x00,0x08,0x42,0x55,0x46,  /* 00000180    "..y..BUF" */
  123.47      0x42,0x11,0x09,0x0A,0x06,0x23,0x00,0x00,  /* 00000188    "B....#.." */
  123.48      0x18,0x79,0x00,0x8B,0x42,0x55,0x46,0x42,  /* 00000190    ".y..BUFB" */
  123.49 @@ -348,7 +348,7 @@ unsigned char AmlCode[] =
  123.50      0x0C,0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A,  /* 00000A68    "........" */
  123.51      0x02,0x00,0x0A,0x2F,0x12,0x0C,0x04,0x0C,  /* 00000A70    ".../...." */
  123.52      0xFF,0xFF,0x0F,0x00,0x0A,0x03,0x00,0x0A,  /* 00000A78    "........" */
  123.53 -    0x10,0x5B,0x82,0x4C,0x31,0x49,0x53,0x41,  /* 00000A80    ".[.L1ISA" */
  123.54 +    0x10,0x5B,0x82,0x44,0x2E,0x49,0x53,0x41,  /* 00000A80    ".[.D.ISA" */
  123.55      0x5F,0x08,0x5F,0x41,0x44,0x52,0x0C,0x00,  /* 00000A88    "_._ADR.." */
  123.56      0x00,0x01,0x00,0x5B,0x80,0x50,0x49,0x52,  /* 00000A90    "...[.PIR" */
  123.57      0x51,0x02,0x0A,0x60,0x0A,0x04,0x10,0x2E,  /* 00000A98    "Q..`...." */
  123.58 @@ -440,13 +440,6 @@ unsigned char AmlCode[] =
  123.59      0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000D48    "._STA..." */
  123.60      0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000D50    ".._CRS.." */
  123.61      0x0A,0x0D,0x47,0x01,0xF8,0x03,0xF8,0x03,  /* 00000D58    "..G....." */
  123.62 -    0x01,0x08,0x22,0x10,0x00,0x79,0x00,0x5B,  /* 00000D60    ".."..y.[" */
  123.63 -    0x82,0x36,0x4C,0x54,0x50,0x31,0x08,0x5F,  /* 00000D68    ".6LTP1._" */
  123.64 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x04,0x00,  /* 00000D70    "HID.A..." */
  123.65 -    0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,0x14,  /* 00000D78    "._UID..." */
  123.66 -    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000D80    "._STA..." */
  123.67 -    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000D88    ".._CRS.." */
  123.68 -    0x0A,0x0D,0x47,0x01,0x78,0x03,0x78,0x03,  /* 00000D90    "..G.x.x." */
  123.69 -    0x08,0x08,0x22,0x80,0x00,0x79,0x00,
  123.70 +    0x01,0x08,0x22,0x10,0x00,0x79,0x00,
  123.71  };
  123.72  int DsdtLen=sizeof(AmlCode);
   124.1 --- a/tools/firmware/hvmloader/config.h	Thu Mar 01 15:02:09 2007 -0700
   124.2 +++ b/tools/firmware/hvmloader/config.h	Wed Mar 07 12:38:28 2007 -0700
   124.3 @@ -9,7 +9,7 @@
   124.4  #define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
   124.5  
   124.6  #define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
   124.7 -#define PCI_ISA_IRQ_MASK    0x0c60U /* ISA IRQs 5,6,10,11 are PCI connected */
   124.8 +#define PCI_ISA_IRQ_MASK    0x0ca0U /* ISA IRQs 5,7,10,11 are PCI connected */
   124.9  
  124.10  #define ROMBIOS_SEG            0xF000
  124.11  #define ROMBIOS_BEGIN          0x000F0000
   125.1 --- a/tools/firmware/rombios/rombios.c	Thu Mar 01 15:02:09 2007 -0700
   125.2 +++ b/tools/firmware/rombios/rombios.c	Wed Mar 07 12:38:28 2007 -0700
   125.3 @@ -890,7 +890,7 @@ static void           int14_function();
   125.4  static void           int15_function();
   125.5  static void           int16_function();
   125.6  static void           int17_function();
   125.7 -static void           int19_function();
   125.8 +static void           int18_function();
   125.9  static void           int1a_function();
  125.10  static void           int70_function();
  125.11  static void           int74_function();
  125.12 @@ -1837,6 +1837,38 @@ keyboard_panic(status)
  125.13  }
  125.14  
  125.15  //--------------------------------------------------------------------------
  125.16 +// machine_reset
  125.17 +//--------------------------------------------------------------------------
  125.18 +  void
  125.19 +machine_reset()
  125.20 +{
  125.21 +  /* Frob the keyboard reset line to reset the processor */
  125.22 +  outb(0x64, 0x60); /* Map the flags register at data port (0x60) */
  125.23 +  outb(0x60, 0x14); /* Set the flags to system|disable */
  125.24 +  outb(0x64, 0xfe); /* Pulse output 0 (system reset) low */
  125.25 +  BX_PANIC("Couldn't reset the machine\n");
  125.26 +}
  125.27 +
  125.28 +//--------------------------------------------------------------------------
  125.29 +// clobber_entry_point
  125.30 +//    Because PV drivers in HVM guests detach some of the emulated devices, 
  125.31 +//    it is not safe to do a soft reboot by just dropping to real mode and
  125.32 +//    jumping at ffff:0000. -- the boot drives might have disappeared!
  125.33 +//    This rather foul function overwrites(!) the BIOS entry point 
  125.34 +//    to point at machine-reset, which will cause the Xen tools to
  125.35 +//    rebuild the whole machine from scratch.
  125.36 +//--------------------------------------------------------------------------
  125.37 +  void 
  125.38 +clobber_entry_point() 
  125.39 +{
  125.40 +    /* The instruction at the entry point is one byte (0xea) for the
  125.41 +     * jump opcode, then two bytes of address, then two of segment. 
  125.42 +     * Overwrite the address bytes.*/
  125.43 +    write_word(0xffff, 0x0001, machine_reset); 
  125.44 +}
  125.45 +
  125.46 +
  125.47 +//--------------------------------------------------------------------------
  125.48  // shutdown_status_panic
  125.49  //   called when the shutdown statsu is not implemented, displays the status
  125.50  //--------------------------------------------------------------------------
  125.51 @@ -7626,7 +7658,7 @@ int17_function(regs, ds, iret_addr)
  125.52  }
  125.53  
  125.54  void
  125.55 -int19_function(seq_nr)
  125.56 +int18_function(seq_nr)
  125.57  Bit16u seq_nr;
  125.58  {
  125.59    Bit16u ebda_seg=read_word(0x0040,0x000E);
  125.60 @@ -7702,8 +7734,8 @@ ASM_START
  125.61      push cx
  125.62      push dx
  125.63  
  125.64 -    mov  dl, _int19_function.bootdrv + 2[bp]
  125.65 -    mov  ax, _int19_function.bootseg + 2[bp]
  125.66 +    mov  dl, _int18_function.bootdrv + 2[bp]
  125.67 +    mov  ax, _int18_function.bootseg + 2[bp]
  125.68      mov  es, ax         ;; segment
  125.69      mov  bx, #0x0000    ;; offset
  125.70      mov  ah, #0x02      ;; function 2, read diskette sector
  125.71 @@ -7714,7 +7746,7 @@ ASM_START
  125.72      int  #0x13          ;; read sector
  125.73      jnc  int19_load_done
  125.74      mov  ax, #0x0001
  125.75 -    mov  _int19_function.status + 2[bp], ax
  125.76 +    mov  _int18_function.status + 2[bp], ax
  125.77  
  125.78  int19_load_done:
  125.79      pop  dx
  125.80 @@ -7789,13 +7821,13 @@ ASM_START
  125.81      ;; Build an iret stack frame that will take us to the boot vector.
  125.82      ;; iret pops ip, then cs, then flags, so push them in the opposite order.
  125.83      pushf
  125.84 -    mov  ax, _int19_function.bootseg + 0[bp] 
  125.85 +    mov  ax, _int18_function.bootseg + 0[bp] 
  125.86      push ax
  125.87 -    mov  ax, _int19_function.bootip + 0[bp] 
  125.88 +    mov  ax, _int18_function.bootip + 0[bp] 
  125.89      push ax
  125.90      ;; Set the magic number in ax and the boot drive in dl.
  125.91      mov  ax, #0xaa55
  125.92 -    mov  dl, _int19_function.bootdrv + 0[bp]
  125.93 +    mov  dl, _int18_function.bootdrv + 0[bp]
  125.94      ;; Zero some of the other registers.
  125.95      xor  bx, bx
  125.96      mov  ds, bx
  125.97 @@ -8272,6 +8304,8 @@ int18_handler: ;; Boot Failure recovery:
  125.98    mov  ss, ax
  125.99  
 125.100    ;; Get the boot sequence number out of the IPL memory
 125.101 +  ;; The first time we do this it will have been set to -1 so 
 125.102 +  ;; we will start from device 0.
 125.103    mov  bx, #IPL_SEG 
 125.104    mov  ds, bx                     ;; Set segment
 125.105    mov  bx, IPL_SEQUENCE_OFFSET    ;; BX is now the sequence number
 125.106 @@ -8279,43 +8313,33 @@ int18_handler: ;; Boot Failure recovery:
 125.107    mov  IPL_SEQUENCE_OFFSET, bx    ;; Write it back
 125.108    mov  ds, ax                     ;; and reset the segment to zero. 
 125.109  
 125.110 -  ;; Carry on in the INT 19h handler, using the new sequence number
 125.111 +  ;; Call the C code for the next boot device
 125.112    push bx
 125.113 -
 125.114 -  jmp  int19_next_boot
 125.115 +  call _int18_function
 125.116 +
 125.117 +  ;; Boot failed: invoke the boot recovery function...
 125.118 +  int  #0x18
 125.119  
 125.120  ;----------
 125.121  ;- INT19h -
 125.122  ;----------
 125.123  int19_relocated: ;; Boot function, relocated
 125.124 -
 125.125 -  ;; int19 was beginning to be really complex, so now it
 125.126 -  ;; just calls a C function that does the work
 125.127 -
 125.128 -  push bp
 125.129 -  mov  bp, sp
 125.130 -  
 125.131 -  ;; Reset SS and SP
 125.132 +  ;;
 125.133 +  ;; *** Warning: INT 19h resets the whole machine *** 
 125.134 +  ;;
 125.135 +  ;; Because PV drivers in HVM guests detach some of the emulated devices, 
 125.136 +  ;; it is not safe to do a soft reboot by just dropping to real mode and
 125.137 +  ;; invoking INT 19h -- the boot drives might have disappeared!
 125.138 +  ;; If the user asks for a soft reboot, the only thing we can do is 
 125.139 +  ;; reset the whole machine.  When it comes back up, the normal BIOS 
 125.140 +  ;; boot sequence will start, which is more or less the required behaviour.
 125.141 +  ;; 
 125.142 +  ;; Reset SP and SS
 125.143    mov  ax, #0xfffe
 125.144    mov  sp, ax
 125.145    xor  ax, ax
 125.146    mov  ss, ax
 125.147 -
 125.148 -  ;; Start from the first boot device (0, in AX)
 125.149 -  mov  bx, #IPL_SEG 
 125.150 -  mov  ds, bx                     ;; Set segment to write to the IPL memory
 125.151 -  mov  IPL_SEQUENCE_OFFSET, ax    ;; Save the sequence number 
 125.152 -  mov  ds, ax                     ;; and reset the segment.
 125.153 -
 125.154 -  push ax
 125.155 -
 125.156 -int19_next_boot:
 125.157 -
 125.158 -  ;; Call the C code for the next boot device
 125.159 -  call _int19_function
 125.160 -
 125.161 -  ;; Boot failed: invoke the boot recovery function
 125.162 -  int  #0x18
 125.163 +  call _machine_reset
 125.164  
 125.165  ;----------
 125.166  ;- INT1Ch -
 125.167 @@ -9214,218 +9238,80 @@ pci_routing_table_structure:
 125.168    db 0 ;; pci bus number
 125.169    db 0x08 ;; pci device number (bit 7-3)
 125.170    db 0x61 ;; link value INTA#: pointer into PCI2ISA config space
 125.171 -  dw 0x0c60 ;; IRQ bitmap INTA# 
 125.172 +  dw 0x0ca0 ;; IRQ bitmap INTA# 
 125.173    db 0x62 ;; link value INTB#
 125.174 -  dw 0x0c60 ;; IRQ bitmap INTB# 
 125.175 +  dw 0x0ca0 ;; IRQ bitmap INTB# 
 125.176    db 0x63 ;; link value INTC#
 125.177 -  dw 0x0c60 ;; IRQ bitmap INTC# 
 125.178 +  dw 0x0ca0 ;; IRQ bitmap INTC# 
 125.179    db 0x60 ;; link value INTD#
 125.180 -  dw 0x0c60 ;; IRQ bitmap INTD#
 125.181 +  dw 0x0ca0 ;; IRQ bitmap INTD#
 125.182    db 0 ;; physical slot (0 = embedded)
 125.183    db 0 ;; reserved
 125.184    ;; second slot entry: 1st PCI slot
 125.185    db 0 ;; pci bus number
 125.186    db 0x10 ;; pci device number (bit 7-3)
 125.187    db 0x62 ;; link value INTA#
 125.188 -  dw 0x0c60 ;; IRQ bitmap INTA# 
 125.189 +  dw 0x0ca0 ;; IRQ bitmap INTA# 
 125.190    db 0x63 ;; link value INTB#
 125.191 -  dw 0x0c60 ;; IRQ bitmap INTB# 
 125.192 +  dw 0x0ca0 ;; IRQ bitmap INTB# 
 125.193    db 0x60 ;; link value INTC#
 125.194 -  dw 0x0c60 ;; IRQ bitmap INTC# 
 125.195 +  dw 0x0ca0 ;; IRQ bitmap INTC# 
 125.196    db 0x61 ;; link value INTD#
 125.197 -  dw 0x0c60 ;; IRQ bitmap INTD#
 125.198 +  dw 0x0ca0 ;; IRQ bitmap INTD#
 125.199    db 1 ;; physical slot (0 = embedded)
 125.200    db 0 ;; reserved
 125.201    ;; third slot entry: 2nd PCI slot
 125.202    db 0 ;; pci bus number
 125.203    db 0x18 ;; pci device number (bit 7-3)
 125.204    db 0x63 ;; link value INTA#
 125.205 -  dw 0x0c60 ;; IRQ bitmap INTA# 
 125.206 +  dw 0x0ca0 ;; IRQ bitmap INTA# 
 125.207    db 0x60 ;; link value INTB#
 125.208 -  dw 0x0c60 ;; IRQ bitmap INTB# 
 125.209 +  dw 0x0ca0 ;; IRQ bitmap INTB# 
 125.210    db 0x61 ;; link value INTC#
 125.211 -  dw 0x0c60 ;; IRQ bitmap INTC# 
 125.212 +  dw 0x0ca0 ;; IRQ bitmap INTC# 
 125.213    db 0x62 ;; link value INTD#
 125.214 -  dw 0x0c60 ;; IRQ bitmap INTD#
 125.215 +  dw 0x0ca0 ;; IRQ bitmap INTD#
 125.216    db 2 ;; physical slot (0 = embedded)
 125.217    db 0 ;; reserved
 125.218    ;; 4th slot entry: 3rd PCI slot
 125.219    db 0 ;; pci bus number
 125.220    db 0x20 ;; pci device number (bit 7-3)
 125.221    db 0x60 ;; link value INTA#
 125.222 -  dw 0x0c60 ;; IRQ bitmap INTA# 
 125.223 +  dw 0x0ca0 ;; IRQ bitmap INTA# 
 125.224    db 0x61 ;; link value INTB#
 125.225 -  dw 0x0c60 ;; IRQ bitmap INTB# 
 125.226 +  dw 0x0ca0 ;; IRQ bitmap INTB# 
 125.227    db 0x62 ;; link value INTC#
 125.228 -  dw 0x0c60 ;; IRQ bitmap INTC# 
 125.229 +  dw 0x0ca0 ;; IRQ bitmap INTC# 
 125.230    db 0x63 ;; link value INTD#
 125.231 -  dw 0x0c60 ;; IRQ bitmap INTD#
 125.232 +  dw 0x0ca0 ;; IRQ bitmap INTD#
 125.233    db 3 ;; physical slot (0 = embedded)
 125.234    db 0 ;; reserved
 125.235    ;; 5th slot entry: 4rd PCI slot
 125.236    db 0 ;; pci bus number
 125.237    db 0x28 ;; pci device number (bit 7-3)
 125.238    db 0x61 ;; link value INTA#
 125.239 -  dw 0x0c60 ;; IRQ bitmap INTA# 
 125.240 +  dw 0x0ca0 ;; IRQ bitmap INTA# 
 125.241    db 0x62 ;; link value INTB#
 125.242 -  dw 0x0c60 ;; IRQ bitmap INTB# 
 125.243 +  dw 0x0ca0 ;; IRQ bitmap INTB# 
 125.244    db 0x63 ;; link value INTC#
 125.245 -  dw 0x0c60 ;; IRQ bitmap INTC# 
 125.246 +  dw 0x0ca0 ;; IRQ bitmap INTC# 
 125.247    db 0x60 ;; link value INTD#
 125.248 -  dw 0x0c60 ;; IRQ bitmap INTD#
 125.249 +  dw 0x0ca0 ;; IRQ bitmap INTD#
 125.250    db 4 ;; physical slot (0 = embedded)
 125.251    db 0 ;; reserved
 125.252    ;; 6th slot entry: 5rd PCI slot
 125.253    db 0 ;; pci bus number
 125.254    db 0x30 ;; pci device number (bit 7-3)
 125.255    db 0x62 ;; link value INTA#
 125.256 -  dw 0x0c60 ;; IRQ bitmap INTA# 
 125.257 +  dw 0x0ca0 ;; IRQ bitmap INTA# 
 125.258    db 0x63 ;; link value INTB#
 125.259 -  dw 0x0c60 ;; IRQ bitmap INTB# 
 125.260 +  dw 0x0ca0 ;; IRQ bitmap INTB# 
 125.261    db 0x60 ;; link value INTC#
 125.262 -  dw 0x0c60 ;; IRQ bitmap INTC# 
 125.263 +  dw 0x0ca0 ;; IRQ bitmap INTC# 
 125.264    db 0x61 ;; link value INTD#
 125.265 -  dw 0x0c60 ;; IRQ bitmap INTD#
 125.266 +  dw 0x0ca0 ;; IRQ bitmap INTD#
 125.267    db 5 ;; physical slot (0 = embedded)
 125.268    db 0 ;; reserved
 125.269 -
 125.270 -pci_irq_list:
 125.271 -  db 11, 10, 9, 5;
 125.272 -
 125.273 -pcibios_init_sel_reg:
 125.274 -  push eax
 125.275 -  mov eax, #0x800000
 125.276 -  mov ax,  bx
 125.277 -  shl eax, #8
 125.278 -  and dl,  #0xfc
 125.279 -  or  al,  dl
 125.280 -  mov dx,  #0x0cf8
 125.281 -  out dx,  eax
 125.282 -  pop eax
 125.283 -  ret
 125.284 -  
 125.285 -pcibios_init_set_elcr:
 125.286 -  push ax
 125.287 -  push cx
 125.288 -  mov  dx, #0x04d0
 125.289 -  test al, #0x08
 125.290 -  jz   is_master_pic
 125.291 -  inc  dx
 125.292 -  and  al, #0x07
 125.293 -is_master_pic:
 125.294 -  mov  cl, al
 125.295 -  mov  bl, #0x01
 125.296 -  shl  bl, cl
 125.297 -  in   al, dx
 125.298 -  or   al, bl
 125.299 -  out  dx, al
 125.300 -  pop  cx
 125.301 -  pop  ax
 125.302 -  ret
 125.303 -
 125.304 -pcibios_init:
 125.305 -  push ds
 125.306 -  push bp
 125.307 -  mov  ax, #0xf000
 125.308 -  mov  ds, ax
 125.309 -  mov  dx, #0x04d0 ;; reset ELCR1 + ELCR2
 125.310 -  mov  al, #0x00
 125.311 -  out  dx, al
 125.312 -  inc  dx
 125.313 -  out  dx, al
 125.314 -  mov  si, #pci_routing_table_structure
 125.315 -  mov  bh, [si+8]
 125.316 -  mov  bl, [si+9]
 125.317 -  mov  dl, #0x00
 125.318 -  call pcibios_init_sel_reg
 125.319 -  mov  dx, #0x0cfc
 125.320 -  in   eax, dx
 125.321 -  cmp  eax, [si+12] ;; check irq router
 125.322 -  jne  pci_init_end
 125.323 -  mov  dl, [si+34]
 125.324 -  call pcibios_init_sel_reg
 125.325 -  push bx ;; save irq router bus + devfunc
 125.326 -  mov  dx, #0x0cfc
 125.327 -  mov  ax, #0x8080
 125.328 -  out  dx, ax ;; reset PIRQ route control
 125.329 -  inc  dx
 125.330 -  inc  dx
 125.331 -  out  dx, ax
 125.332 -  mov  ax, [si+6]
 125.333 -  sub  ax, #0x20
 125.334 -  shr  ax, #4
 125.335 -  mov  cx, ax
 125.336 -  add  si, #0x20 ;; set pointer to 1st entry
 125.337 -  mov  bp, sp
 125.338 -  mov  ax, #pci_irq_list
 125.339 -  push ax
 125.340 -  xor  ax, ax
 125.341 -  push ax
 125.342 -pci_init_loop1:
 125.343 -  mov  bh, [si]
 125.344 -  mov  bl, [si+1]
 125.345 -pci_init_loop2:
 125.346 -  mov  dl, #0x00
 125.347 -  call pcibios_init_sel_reg
 125.348 -  mov  dx, #0x0cfc
 125.349 -  in   ax, dx
 125.350 -  cmp  ax, #0xffff
 125.351 -  jnz  pci_test_int_pin
 125.352 -  test bl, #0x07
 125.353 -  jz   next_pir_entry
 125.354 -  jmp  next_pci_func
 125.355 -pci_test_int_pin:
 125.356 -  mov  dl, #0x3c
 125.357 -  call pcibios_init_sel_reg
 125.358 -  mov  dx, #0x0cfd
 125.359 -  in   al, dx
 125.360 -  and  al, #0x07
 125.361 -  jz   next_pci_func
 125.362 -  dec  al ;; determine pirq reg
 125.363 -  mov  dl, #0x03
 125.364 -  mul  al, dl
 125.365 -  add  al, #0x02
 125.366 -  xor  ah, ah
 125.367 -  mov  bx, ax
 125.368 -  mov  al, [si+bx]
 125.369 -  mov  dl, al
 125.370 -  mov  bx, [bp]
 125.371 -  call pcibios_init_sel_reg
 125.372 -  mov  dx, #0x0cfc
 125.373 -  and  al, #0x03
 125.374 -  add  dl, al
 125.375 -  in   al, dx
 125.376 -  cmp  al, #0x80
 125.377 -  jb   pirq_found
 125.378 -  mov  bx, [bp-2] ;; pci irq list pointer
 125.379 -  mov  al, [bx]
 125.380 -  out  dx, al
 125.381 -  inc  bx
 125.382 -  mov  [bp-2], bx
 125.383 -  call pcibios_init_set_elcr
 125.384 -pirq_found:
 125.385 -  mov  bh, [si]
 125.386 -  mov  bl, [si+1]
 125.387 -  add  bl, [bp-3] ;; pci function number
 125.388 -  mov  dl, #0x3c
 125.389 -  call pcibios_init_sel_reg
 125.390 -  mov  dx, #0x0cfc
 125.391 -  out  dx, al
 125.392 -next_pci_func:
 125.393 -  inc  byte ptr[bp-3]
 125.394 -  inc  bl
 125.395 -  test bl, #0x07
 125.396 -  jnz  pci_init_loop2
 125.397 -next_pir_entry:
 125.398 -  add  si, #0x10
 125.399 -  mov  byte ptr[bp-3], #0x00
 125.400 -  loop pci_init_loop1
 125.401 -  mov  sp, bp
 125.402 -  pop  bx
 125.403 -pci_init_end:
 125.404 -  pop  bp
 125.405 -  pop  ds
 125.406 -  ret
 125.407  #endif // BX_PCIBIOS
 125.408  
 125.409  ; parallel port detection: base address in DX, index in BX, timeout in CL
 125.410 @@ -9747,6 +9633,8 @@ normal_post:
 125.411  
 125.412    call _log_bios_start
 125.413  
 125.414 +  call _clobber_entry_point
 125.415 +
 125.416    ;; set all interrupts to default handler
 125.417    mov  bx, #0x0000    ;; offset index
 125.418    mov  cx, #0x0100    ;; counter (256 interrupts)
 125.419 @@ -9995,8 +9883,10 @@ post_default_ints:
 125.420    call _tcpa_calling_int19h          /* specs: 8.2.3 step 1 */
 125.421    call _tcpa_add_event_separators    /* specs: 8.2.3 step 2 */
 125.422  #endif
 125.423 -  int  #0x19
 125.424 -  //JMP_EP(0x0064) ; INT 19h location
 125.425 +
 125.426 +  ;; Start the boot sequence.   See the comments in int19_relocated 
 125.427 +  ;; for why we use INT 18h instead of INT 19h here.
 125.428 +  int  #0x18
 125.429  
 125.430  #if BX_TCGBIOS
 125.431    call _tcpa_returned_int19h         /* specs: 8.2.3 step 3/7 */
   126.1 --- a/tools/guest-headers/Makefile	Thu Mar 01 15:02:09 2007 -0700
   126.2 +++ b/tools/guest-headers/Makefile	Wed Mar 07 12:38:28 2007 -0700
   126.3 @@ -13,7 +13,7 @@ check:
   126.4  
   126.5  install-Linux:
   126.6  	mkdir -p $(DESTDIR)/usr/include/xen/linux
   126.7 -	install -m0644 $(linuxsparsetree)/include/xen/public/*.h $(DESTDIR)/usr/include/xen/linux
   126.8 +	$(INSTALL_DATA) $(linuxsparsetree)/include/xen/public/*.h $(DESTDIR)/usr/include/xen/linux
   126.9  
  126.10  install-SunOS:
  126.11  
   127.1 --- a/tools/ioemu/Makefile	Thu Mar 01 15:02:09 2007 -0700
   127.2 +++ b/tools/ioemu/Makefile	Wed Mar 07 12:38:28 2007 -0700
   127.3 @@ -65,10 +65,10 @@ common  de-ch  es     fo  fr-ca  hu     
   127.4  
   127.5  install-doc: $(DOCS)
   127.6  	mkdir -p "$(DESTDIR)$(docdir)"
   127.7 -	$(INSTALL) -m 644 qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
   127.8 +	$(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
   127.9  ifndef CONFIG_WIN32
  127.10  	mkdir -p "$(DESTDIR)$(mandir)/man1"
  127.11 -	$(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
  127.12 +	$(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
  127.13  endif
  127.14  
  127.15  install: all $(if $(BUILD_DOCS),install-doc)
  127.16 @@ -77,12 +77,12 @@ install: all $(if $(BUILD_DOCS),install-
  127.17  #	mkdir -p "$(DESTDIR)$(datadir)"
  127.18  #	for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
  127.19  #			video.x openbios-sparc32 linux_boot.bin; do \
  127.20 -#		$(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
  127.21 +#		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
  127.22  #	done
  127.23  ifndef CONFIG_WIN32
  127.24  	mkdir -p "$(DESTDIR)$(datadir)/keymaps"
  127.25  	for x in $(KEYMAPS); do \
  127.26 -		$(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
  127.27 +		$(INSTALL_DATA) $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
  127.28  	done
  127.29  endif
  127.30  	for d in $(TARGET_DIRS); do \
   128.1 --- a/tools/ioemu/hw/ide.c	Thu Mar 01 15:02:09 2007 -0700
   128.2 +++ b/tools/ioemu/hw/ide.c	Wed Mar 07 12:38:28 2007 -0700
   128.3 @@ -434,6 +434,121 @@ static void dma_create_thread(void)
   128.4  }
   128.5  #endif /* DMA_MULTI_THREAD */
   128.6  
   128.7 +#if defined(__ia64__)
   128.8 +#include <xen/hvm/ioreq.h>
   128.9 +
  128.10 +struct buffered_piopage *buffered_pio_page;
  128.11 +
  128.12 +static inline struct pio_buffer *
  128.13 +piobuf_by_addr(uint32_t addr)
  128.14 +{
  128.15 +    if (addr == 0x1F0)
  128.16 +        return &buffered_pio_page->pio[PIO_BUFFER_IDE_PRIMARY];
  128.17 +    if (addr == 0x170)
  128.18 +        return &buffered_pio_page->pio[PIO_BUFFER_IDE_SECONDARY];
  128.19 +    return NULL;
  128.20 +}
  128.21 +
  128.22 +static void
  128.23 +buffered_pio_init(void)
  128.24 +{
  128.25 +    struct pio_buffer *p1, *p2;
  128.26 +    uint32_t off1, off2;
  128.27 +
  128.28 +    if (!buffered_pio_page)
  128.29 +        return;
  128.30 +
  128.31 +    p1 = &buffered_pio_page->pio[PIO_BUFFER_IDE_PRIMARY];
  128.32 +    p2 = &buffered_pio_page->pio[PIO_BUFFER_IDE_SECONDARY];
  128.33 +    off1 = offsetof(struct buffered_piopage, buffer);
  128.34 +    off2 = (off1 + TARGET_PAGE_SIZE)/2;
  128.35 +
  128.36 +    p1->buf_size = off2 - off1;
  128.37 +    p1->page_offset = off1;
  128.38 +
  128.39 +    p2->buf_size = TARGET_PAGE_SIZE - off2;
  128.40 +    p2->page_offset = off2;
  128.41 +}
  128.42 +
  128.43 +static inline void
  128.44 +buffered_pio_flush(struct pio_buffer *piobuf)
  128.45 +{
  128.46 +    IDEState *s = piobuf->opaque;
  128.47 +    uint32_t pointer = piobuf->pointer;
  128.48 +
  128.49 +    if (s != NULL && pointer > 0) {
  128.50 +        uint8_t *buf = (uint8_t *)buffered_pio_page + piobuf->page_offset;
  128.51 +        memcpy(s->data_ptr, buf, pointer);
  128.52 +        s->data_ptr += pointer;
  128.53 +    }
  128.54 +}
  128.55 +
  128.56 +static inline void
  128.57 +buffered_pio_reset(IDEState *s)
  128.58 +{
  128.59 +    struct pio_buffer *piobuf;
  128.60 +
  128.61 +    if ((unsigned)s->drive_serial - 1 < 2)      /* 1,2 */
  128.62 +        piobuf = &buffered_pio_page->pio[PIO_BUFFER_IDE_PRIMARY];
  128.63 +    else if ((unsigned)s->drive_serial - 3 < 2) /* 3,4 */
  128.64 +        piobuf = &buffered_pio_page->pio[PIO_BUFFER_IDE_SECONDARY];
  128.65 +    else
  128.66 +        return;
  128.67 +    buffered_pio_flush(piobuf);
  128.68 +    piobuf->pointer = 0;
  128.69 +    piobuf->data_end = 0;
  128.70 +    piobuf->opaque = NULL;
  128.71 +}
  128.72 +
  128.73 +static inline void
  128.74 +buffered_pio_write(IDEState *s, uint32_t addr, int size)
  128.75 +{
  128.76 +    struct pio_buffer *piobuf = piobuf_by_addr(addr);
  128.77 +    int data_end;
  128.78 +
  128.79 +    if (!piobuf)
  128.80 +        return;
  128.81 +    buffered_pio_flush(piobuf);
  128.82 +    data_end = s->data_end - s->data_ptr - size;
  128.83 +    if (data_end <= 0)
  128.84 +        data_end = 0;
  128.85 +    else if (data_end > piobuf->buf_size)
  128.86 +        data_end = piobuf->buf_size;
  128.87 +    piobuf->pointer = 0;
  128.88 +    piobuf->data_end = data_end;
  128.89 +    piobuf->opaque = s;
  128.90 +}
  128.91 +
  128.92 +static inline void
  128.93 +buffered_pio_read(IDEState *s, uint32_t addr, int size)
  128.94 +{
  128.95 +    struct pio_buffer *piobuf = piobuf_by_addr(addr);
  128.96 +    int data_end;
  128.97 +
  128.98 +    if (!piobuf)
  128.99 +        return;
 128.100 +    s->data_ptr += piobuf->pointer;
 128.101 +    data_end = s->data_end - s->data_ptr - size;
 128.102 +    if (data_end <= 0) {
 128.103 +        data_end = 0;
 128.104 +    } else {
 128.105 +	uint8_t *buf = (uint8_t *)buffered_pio_page + piobuf->page_offset;
 128.106 +        if (data_end > piobuf->buf_size)
 128.107 +            data_end = piobuf->buf_size;
 128.108 +        memcpy(buf, s->data_ptr + size, data_end);
 128.109 +    }
 128.110 +    piobuf->pointer = 0;
 128.111 +    piobuf->data_end = data_end;
 128.112 +    piobuf->opaque = NULL;
 128.113 +}
 128.114 +
 128.115 +#else /* !__ia64__ */
 128.116 +#define buffered_pio_init()         do {} while (0)
 128.117 +#define buffered_pio_reset(I)       do {} while (0)
 128.118 +#define buffered_pio_write(I,A,S)   do {} while (0)
 128.119 +#define buffered_pio_read(I,A,S)    do {} while (0)
 128.120 +#endif
 128.121 +
 128.122  static void ide_dma_start(IDEState *s, IDEDMAFunc *dma_cb);
 128.123  
 128.124  static void padstr(char *str, const char *src, int len)
 128.125 @@ -618,6 +733,7 @@ static void ide_transfer_start(IDEState 
 128.126      s->data_ptr = buf;
 128.127      s->data_end = buf + size;
 128.128      s->status |= DRQ_STAT;
 128.129 +    buffered_pio_reset(s);
 128.130  }
 128.131  
 128.132  static void ide_transfer_stop(IDEState *s)
 128.133 @@ -626,6 +742,7 @@ static void ide_transfer_stop(IDEState *
 128.134      s->data_ptr = s->io_buffer;
 128.135      s->data_end = s->io_buffer;
 128.136      s->status &= ~DRQ_STAT;
 128.137 +    buffered_pio_reset(s);
 128.138  }
 128.139  
 128.140  static int64_t ide_get_sector(IDEState *s)
 128.141 @@ -1562,6 +1679,7 @@ static void ide_ioport_write(void *opaqu
 128.142          ide_if[0].select = (val & ~0x10) | 0xa0;
 128.143          ide_if[1].select = (val | 0x10) | 0xa0;
 128.144          /* select drive */
 128.145 +        buffered_pio_reset(ide_if->cur_drive);
 128.146          unit = (val >> 4) & 1;
 128.147          s = ide_if + unit;
 128.148          ide_if->cur_drive = s;
 128.149 @@ -1928,6 +2046,7 @@ static void ide_data_writew(void *opaque
 128.150      IDEState *s = ((IDEState *)opaque)->cur_drive;
 128.151      uint8_t *p;
 128.152  
 128.153 +    buffered_pio_write(s, addr, 2);
 128.154      p = s->data_ptr;
 128.155      *(uint16_t *)p = le16_to_cpu(val);
 128.156      p += 2;
 128.157 @@ -1941,6 +2060,8 @@ static uint32_t ide_data_readw(void *opa
 128.158      IDEState *s = ((IDEState *)opaque)->cur_drive;
 128.159      uint8_t *p;
 128.160      int ret;
 128.161 +    
 128.162 +    buffered_pio_read(s, addr, 2);
 128.163      p = s->data_ptr;
 128.164      ret = cpu_to_le16(*(uint16_t *)p);
 128.165      p += 2;
 128.166 @@ -1955,6 +2076,7 @@ static void ide_data_writel(void *opaque
 128.167      IDEState *s = ((IDEState *)opaque)->cur_drive;
 128.168      uint8_t *p;
 128.169  
 128.170 +    buffered_pio_write(s, addr, 4);
 128.171      p = s->data_ptr;
 128.172      *(uint32_t *)p = le32_to_cpu(val);
 128.173      p += 4;
 128.174 @@ -1969,6 +2091,7 @@ static uint32_t ide_data_readl(void *opa
 128.175      uint8_t *p;
 128.176      int ret;
 128.177      
 128.178 +    buffered_pio_read(s, addr, 4);
 128.179      p = s->data_ptr;
 128.180      ret = cpu_to_le32(*(uint32_t *)p);
 128.181      p += 4;
 128.182 @@ -2517,6 +2640,8 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
 128.183      ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
 128.184      ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
 128.185  
 128.186 +    buffered_pio_init();
 128.187 +
 128.188      register_savevm("ide_pci", 0, 1, generic_pci_save, generic_pci_load, d);
 128.189  
 128.190  #ifdef DMA_MULTI_THREAD    
   129.1 --- a/tools/ioemu/target-i386-dm/qemu-ifup	Thu Mar 01 15:02:09 2007 -0700
   129.2 +++ b/tools/ioemu/target-i386-dm/qemu-ifup	Wed Mar 07 12:38:28 2007 -0700
   129.3 @@ -3,8 +3,7 @@
   129.4  #. /etc/rc.d/init.d/functions
   129.5  #ulimit -c unlimited
   129.6  
   129.7 -echo -c 'config qemu network with xen bridge for '
   129.8 -echo $*
   129.9 +echo 'config qemu network with xen bridge for ' $*
  129.10  
  129.11  ifconfig $1 0.0.0.0 up
  129.12  brctl addif $2 $1
   130.1 --- a/tools/ioemu/vl.c	Thu Mar 01 15:02:09 2007 -0700
   130.2 +++ b/tools/ioemu/vl.c	Wed Mar 07 12:38:28 2007 -0700
   130.3 @@ -1565,12 +1565,51 @@ CharDriverState *qemu_chr_open_stdio(voi
   130.4      return chr;
   130.5  }
   130.6  
   130.7 -int store_console_dev(int domid, char *pts)
   130.8 +/*
   130.9 + * Create a store entry for a device (e.g., monitor, serial/parallel lines).
  130.10 + * The entry is <domain-path><storeString>/tty and the value is the name
  130.11 + * of the pty associated with the device.
  130.12 + */
  130.13 +static int store_dev_info(char *devName, int domid,
  130.14 +                          CharDriverState *cState, char *storeString)
  130.15  {
  130.16      int xc_handle;
  130.17      struct xs_handle *xs;
  130.18      char *path;
  130.19 -
  130.20 +    char *newpath;
  130.21 +    FDCharDriver *s;
  130.22 +    char *pts;
  130.23 +
  130.24 +    /* Check for valid arguments (at least, prevent segfaults). */
  130.25 +    if ((devName == NULL) || (cState == NULL) || (storeString == NULL)) {
  130.26 +        fprintf(logfile, "%s - invalid arguments\n", __FUNCTION__);
  130.27 +        return EINVAL;
  130.28 +    }
  130.29 +
  130.30 +    /*
  130.31 +     * Only continue if we're talking to a pty
  130.32 +     * Actually, the following code works for any CharDriverState using
  130.33 +     * FDCharDriver, but we really only care about pty's here
  130.34 +     */
  130.35 +    if (strcmp(devName, "pty"))
  130.36 +        return 0;
  130.37 +
  130.38 +    s = cState->opaque;
  130.39 +    if (s == NULL) {
  130.40 +        fprintf(logfile, "%s - unable to retrieve fd for '%s'/'%s'\n",
  130.41 +                __FUNCTION__, storeString, devName);
  130.42 +        return EBADF;
  130.43 +    }
  130.44 +
  130.45 +    pts = ptsname(s->fd_in);
  130.46 +    if (pts == NULL) {
  130.47 +        fprintf(logfile, "%s - unable to determine ptsname '%s'/'%s', "
  130.48 +                "error %d (%s)\n",
  130.49 +                __FUNCTION__, storeString, devName, errno, strerror(errno));
  130.50 +        return errno;
  130.51 +    }
  130.52 +
  130.53 +    /* We now have everything we need to set the xenstore entry. */
  130.54      xs = xs_daemon_open();
  130.55      if (xs == NULL) {
  130.56          fprintf(logfile, "Could not contact XenStore\n");
  130.57 @@ -1588,14 +1627,19 @@ int store_console_dev(int domid, char *p
  130.58          fprintf(logfile, "xs_get_domain_path() error\n");
  130.59          return -1;
  130.60      }
  130.61 -    path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
  130.62 -    if (path == NULL) {
  130.63 +    newpath = realloc(path, (strlen(path) + strlen(storeString) +
  130.64 +                             strlen("/tty") + 1));
  130.65 +    if (newpath == NULL) {
  130.66 +        free(path); /* realloc errors leave old block */
  130.67          fprintf(logfile, "realloc error\n");
  130.68          return -1;
  130.69      }
  130.70 -    strcat(path, "/console/tty");
  130.71 +    path = newpath;
  130.72 +
  130.73 +    strcat(path, storeString);
  130.74 +    strcat(path, "/tty");
  130.75      if (!xs_write(xs, XBT_NULL, path, pts, strlen(pts))) {
  130.76 -        fprintf(logfile, "xs_write for console fail");
  130.77 +        fprintf(logfile, "xs_write for '%s' fail", storeString);
  130.78          return -1;
  130.79      }
  130.80  
  130.81 @@ -1622,7 +1666,6 @@ CharDriverState *qemu_chr_open_pty(void)
  130.82      tcsetattr(slave_fd, TCSAFLUSH, &tty);
  130.83      
  130.84      fprintf(stderr, "char device redirected to %s\n", ptsname(master_fd));
  130.85 -    store_console_dev(domid, ptsname(master_fd));
  130.86  
  130.87      return qemu_chr_open_fd(master_fd, master_fd);
  130.88  }
  130.89 @@ -3207,6 +3250,14 @@ static int net_tap_init(VLANState *vlan,
  130.90          pid = fork();
  130.91          if (pid >= 0) {
  130.92              if (pid == 0) {
  130.93 +                int open_max = sysconf(_SC_OPEN_MAX), i;
  130.94 +                for (i = 0; i < open_max; i++)
  130.95 +                    if (i != STDIN_FILENO &&
  130.96 +                        i != STDOUT_FILENO &&
  130.97 +                        i != STDERR_FILENO &&
  130.98 +                        i != fd)
  130.99 +                        close(i);
 130.100 +
 130.101                  parg = args;
 130.102                  *parg++ = (char *)setup_script;
 130.103                  *parg++ = ifname;
 130.104 @@ -5768,17 +5819,17 @@ int unset_mm_mapping(int xc_handle, uint
 130.105      int err = 0;
 130.106      xc_dominfo_t info;
 130.107  
 130.108 +    xc_domain_getinfo(xc_handle, domid, 1, &info);
 130.109 +    if ((info.nr_pages - nr_pages) <= 0) {
 130.110 +        fprintf(stderr, "unset_mm_mapping: error nr_pages\n");
 130.111 +        err = -1;
 130.112 +    }
 130.113 +
 130.114      err = xc_domain_memory_decrease_reservation(xc_handle, domid,
 130.115                                                  nr_pages, 0, extent_start);
 130.116      if (err)
 130.117          fprintf(stderr, "Failed to decrease physmap\n");
 130.118  
 130.119 -    xc_domain_getinfo(xc_handle, domid, 1, &info);
 130.120 -
 130.121 -    if ((info.nr_pages - nr_pages) <= 0) {
 130.122 -        fprintf(stderr, "unset_mm_mapping: error nr_pages\n");
 130.123 -        err = -1;
 130.124 -    }
 130.125  
 130.126      if (xc_domain_setmaxmem(xc_handle, domid, (info.nr_pages - nr_pages) *
 130.127                              PAGE_SIZE/1024) != 0) {
 130.128 @@ -5972,6 +6023,7 @@ int main(int argc, char **argv)
 130.129      xen_pfn_t *page_array;
 130.130      extern void *shared_page;
 130.131      extern void *buffered_io_page;
 130.132 +    extern void *buffered_pio_page;
 130.133  
 130.134      char qemu_dm_logfilename[64];
 130.135  
 130.136 @@ -6044,9 +6096,14 @@ int main(int argc, char **argv)
 130.137      for(i = 1; i < MAX_SERIAL_PORTS; i++)
 130.138          serial_devices[i][0] = '\0';
 130.139      serial_device_index = 0;
 130.140 -    
 130.141 +
 130.142 +#ifndef CONFIG_DM
 130.143      pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "vc");
 130.144      for(i = 1; i < MAX_PARALLEL_PORTS; i++)
 130.145 +#else
 130.146 +    /* Xen steals IRQ7 for PCI. Disable LPT1 by default. */
 130.147 +    for(i = 0; i < MAX_PARALLEL_PORTS; i++)
 130.148 +#endif
 130.149          parallel_devices[i][0] = '\0';
 130.150      parallel_device_index = 0;
 130.151      
 130.152 @@ -6571,6 +6628,10 @@ int main(int argc, char **argv)
 130.153                                         PROT_READ|PROT_WRITE,
 130.154                                         BUFFER_IO_PAGE_START >> PAGE_SHIFT);
 130.155  
 130.156 +    buffered_pio_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
 130.157 +                                       PROT_READ|PROT_WRITE,
 130.158 +                                       BUFFER_PIO_PAGE_START >> PAGE_SHIFT);
 130.159 +
 130.160      for (i = 0; i < tmp_nr_pages; i++)
 130.161          page_array[i] = i;
 130.162  	
 130.163 @@ -6684,16 +6745,23 @@ int main(int argc, char **argv)
 130.164          fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device);
 130.165          exit(1);
 130.166      }
 130.167 +    store_dev_info(monitor_device, domid, monitor_hd, "/monitor");
 130.168      monitor_init(monitor_hd, !nographic);
 130.169  
 130.170      for(i = 0; i < MAX_SERIAL_PORTS; i++) {
 130.171          if (serial_devices[i][0] != '\0') {
 130.172 +            char buf[16];
 130.173              serial_hds[i] = qemu_chr_open(serial_devices[i]);
 130.174              if (!serial_hds[i]) {
 130.175                  fprintf(stderr, "qemu: could not open serial device '%s'\n", 
 130.176                          serial_devices[i]);
 130.177                  exit(1);
 130.178              }
 130.179 +            snprintf(buf, sizeof(buf), "/serial/%d", i);
 130.180 +            store_dev_info(serial_devices[i], domid, serial_hds[i], buf);
 130.181 +            if (i == 0) /* serial 0 is also called the console */
 130.182 +                store_dev_info(serial_devices[i], domid,
 130.183 +                               serial_hds[i], "/console");
 130.184              if (!strcmp(serial_devices[i], "vc"))
 130.185                  qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i);
 130.186          }
 130.187 @@ -6701,12 +6769,15 @@ int main(int argc, char **argv)
 130.188  
 130.189      for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
 130.190          if (parallel_devices[i][0] != '\0') {
 130.191 +            char buf[16];
 130.192              parallel_hds[i] = qemu_chr_open(parallel_devices[i]);
 130.193              if (!parallel_hds[i]) {
 130.194                  fprintf(stderr, "qemu: could not open parallel device '%s'\n", 
 130.195                          parallel_devices[i]);
 130.196                  exit(1);
 130.197              }
 130.198 +            snprintf(buf, sizeof(buf), "/parallel/%d", i);
 130.199 +            store_dev_info(parallel_devices[i], domid, parallel_hds[i], buf);
 130.200              if (!strcmp(parallel_devices[i], "vc"))
 130.201                  qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i);
 130.202          }
   131.1 --- a/tools/ioemu/vnc.c	Thu Mar 01 15:02:09 2007 -0700
   131.2 +++ b/tools/ioemu/vnc.c	Wed Mar 07 12:38:28 2007 -0700
   131.3 @@ -1445,7 +1445,7 @@ int vnc_display_init(DisplayState *ds, i
   131.4  
   131.5  int vnc_start_viewer(int port)
   131.6  {
   131.7 -    int pid;
   131.8 +    int pid, i, open_max;
   131.9      char s[16];
  131.10  
  131.11      sprintf(s, ":%d", port);
  131.12 @@ -1456,6 +1456,12 @@ int vnc_start_viewer(int port)
  131.13  	exit(1);
  131.14  
  131.15      case 0:	/* child */
  131.16 +	open_max = sysconf(_SC_OPEN_MAX);
  131.17 +	for (i = 0; i < open_max; i++)
  131.18 +	    if (i != STDIN_FILENO &&
  131.19 +		i != STDOUT_FILENO &&
  131.20 +		i != STDERR_FILENO)
  131.21 +		close(i);
  131.22  	execlp("vncviewer", "vncviewer", s, NULL);
  131.23  	fprintf(stderr, "vncviewer execlp failed\n");
  131.24  	exit(1);
   132.1 --- a/tools/ioemu/xenstore.c	Thu Mar 01 15:02:09 2007 -0700
   132.2 +++ b/tools/ioemu/xenstore.c	Wed Mar 07 12:38:28 2007 -0700
   132.3 @@ -16,6 +16,9 @@ static struct xs_handle *xsh = NULL;
   132.4  static char *hd_filename[MAX_DISKS];
   132.5  static QEMUTimer *insert_timer = NULL;
   132.6  
   132.7 +#define UWAIT_MAX (30*1000000) /* thirty seconds */
   132.8 +#define UWAIT     (100000)     /* 1/10th second  */
   132.9 +
  132.10  static int pasprintf(char **buf, const char *fmt, ...)
  132.11  {
  132.12      va_list ap;
  132.13 @@ -53,32 +56,20 @@ void xenstore_check_new_media_present(in
  132.14      qemu_mod_timer(insert_timer, qemu_get_clock(rt_clock) + timeout);
  132.15  }
  132.16  
  132.17 -static int waitForDevice(char *path, char *field, char *desired)
  132.18 +static void waitForDevice(char *fn)
  132.19  { 
  132.20 -    char *buf = NULL, *stat = NULL;
  132.21 -    unsigned int len;
  132.22 -    int val = 1;
  132.23 +    struct stat sbuf;
  132.24 +    int status;
  132.25 +    int uwait = UWAIT_MAX;
  132.26  
  132.27 -    /* loop until we find a value in xenstore, return 
  132.28 -     * if it was what we wanted, or not
  132.29 -     */
  132.30 -    while (1) {
  132.31 -        if (pasprintf(&buf, "%s/%s", path, field) == -1)
  132.32 -            goto done;
  132.33 -        free(stat);
  132.34 -        stat = xs_read(xsh, XBT_NULL, buf, &len);
  132.35 -        if (stat == NULL) {
  132.36 -            usleep(100000); /* 1/10th second, no path found */
  132.37 -        } else {
  132.38 -            val = strcmp(stat, desired);
  132.39 -            goto done;
  132.40 -        }
  132.41 -    }
  132.42 +    do {
  132.43 +        status = stat(fn, &sbuf);
  132.44 +        if (!status) break;
  132.45 +        usleep(UWAIT);
  132.46 +        uwait -= UWAIT;
  132.47 +    } while (uwait > 0);
  132.48  
  132.49 -done:
  132.50 -    free(stat);
  132.51 -    free(buf);
  132.52 -    return val;
  132.53 +    return;
  132.54  }
  132.55  
  132.56  void xenstore_parse_domain_config(int domid)
  132.57 @@ -161,11 +152,6 @@ void xenstore_parse_domain_config(int do
  132.58  	free(fpath);
  132.59          fpath = xs_read(xsh, XBT_NULL, buf, &len);
  132.60  	if (fpath != NULL) {
  132.61 -
  132.62 -            if (waitForDevice(fpath, "hotplug-status", "connected")) {
  132.63 -               continue;
  132.64 -            }
  132.65 -
  132.66  	    if (pasprintf(&buf, "%s/dev", fpath) == -1)
  132.67  	        continue;
  132.68              params = xs_read(xsh, XBT_NULL, buf , &len);
  132.69 @@ -173,6 +159,11 @@ void xenstore_parse_domain_config(int do
  132.70                  free(hd_filename[hd_index]);
  132.71                  hd_filename[hd_index] = params;
  132.72                  params = NULL;              /* don't free params on re-use */
  132.73 +                /* 
  132.74 +                 * wait for device, on timeout silently fail because we will 
  132.75 +                 * fail to open below
  132.76 +                 */
  132.77 +                waitForDevice(hd_filename[hd_index]);
  132.78              }
  132.79          }
  132.80  	bs_table[hd_index] = bdrv_new(dev);
   133.1 --- a/tools/libxc/Makefile	Thu Mar 01 15:02:09 2007 -0700
   133.2 +++ b/tools/libxc/Makefile	Wed Mar 07 12:38:28 2007 -0700
   133.3 @@ -6,6 +6,8 @@ MINOR    = 0
   133.4  
   133.5  CTRL_SRCS-y       :=
   133.6  CTRL_SRCS-y       += xc_core.c
   133.7 +CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c
   133.8 +CTRL_SRCS-$(CONFIG_IA64) += xc_core_ia64.c
   133.9  CTRL_SRCS-y       += xc_domain.c
  133.10  CTRL_SRCS-y       += xc_evtchn.c
  133.11  CTRL_SRCS-y       += xc_misc.c
  133.12 @@ -57,6 +59,9 @@ CFLAGS   += -Werror -Wmissing-prototypes
  133.13  CFLAGS   += -fno-strict-aliasing
  133.14  CFLAGS   += $(INCLUDES) -I.
  133.15  
  133.16 +# Needed for posix_fadvise64() in xc_linux.c
  133.17 +CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
  133.18 +
  133.19  # Define this to make it possible to run valgrind on code linked with these
  133.20  # libraries.
  133.21  #CFLAGS   += -DVALGRIND -O0 -ggdb3
   134.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c	Thu Mar 01 15:02:09 2007 -0700
   134.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Wed Mar 07 12:38:28 2007 -0700
   134.3 @@ -569,6 +569,7 @@ setup_guest(int xc_handle, uint32_t dom,
   134.4      xen_pfn_t *pfn_list;
   134.5      shared_iopage_t *sp;
   134.6      void *ioreq_buffer_page;
   134.7 +    void *pio_buffer_page;
   134.8      unsigned long dom_memsize = memsize << 20;
   134.9      unsigned long nr_pages = memsize << (20 - PAGE_SHIFT);
  134.10      unsigned long vcpus;
  134.11 @@ -628,9 +629,10 @@ setup_guest(int xc_handle, uint32_t dom,
  134.12  
  134.13      pfn_list[0] = IO_PAGE_START >> PAGE_SHIFT;
  134.14      pfn_list[1] = STORE_PAGE_START >> PAGE_SHIFT;
  134.15 -    pfn_list[2] = BUFFER_IO_PAGE_START >> PAGE_SHIFT; 
  134.16 +    pfn_list[2] = BUFFER_IO_PAGE_START >> PAGE_SHIFT;
  134.17 +    pfn_list[3] = BUFFER_PIO_PAGE_START >> PAGE_SHIFT;
  134.18  
  134.19 -    rc = xc_domain_memory_populate_physmap(xc_handle, dom, 3,
  134.20 +    rc = xc_domain_memory_populate_physmap(xc_handle, dom, 4,
  134.21                                             0, 0, &pfn_list[0]);
  134.22      if (rc != 0) {
  134.23          PERROR("Could not allocate IO page or store page or buffer io page.\n");
  134.24 @@ -684,6 +686,12 @@ setup_guest(int xc_handle, uint32_t dom,
  134.25                                               pfn_list[2]); 
  134.26      memset(ioreq_buffer_page,0,PAGE_SIZE);
  134.27      munmap(ioreq_buffer_page, PAGE_SIZE);
  134.28 +
  134.29 +    pio_buffer_page = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
  134.30 +                                           PROT_READ | PROT_WRITE,
  134.31 +                                           pfn_list[3]);
  134.32 +    memset(pio_buffer_page,0,PAGE_SIZE);
  134.33 +    munmap(pio_buffer_page, PAGE_SIZE);
  134.34      free(pfn_list);
  134.35      return 0;
  134.36  
   135.1 --- a/tools/libxc/powerpc64/mk_flatdevtree.c	Thu Mar 01 15:02:09 2007 -0700
   135.2 +++ b/tools/libxc/powerpc64/mk_flatdevtree.c	Wed Mar 07 12:38:28 2007 -0700
   135.3 @@ -618,7 +618,7 @@ int make_devtree(struct ft_cxt *root,
   135.4      }
   135.5  
   135.6      /* write a copy of the tree to a file */
   135.7 -    if ((dtb_fd = open(DTB_FILE , O_RDWR)) == -1) {
   135.8 +    if ((dtb_fd = creat(DTB_FILE, S_IRUSR | S_IWUSR)) == -1) {
   135.9          PERROR("%s: failed to open file %s", __func__, DTB_FILE);
  135.10          goto error;
  135.11      }
   136.1 --- a/tools/libxc/powerpc64/xc_linux_build.c	Thu Mar 01 15:02:09 2007 -0700
   136.2 +++ b/tools/libxc/powerpc64/xc_linux_build.c	Wed Mar 07 12:38:28 2007 -0700
   136.3 @@ -33,13 +33,16 @@
   136.4  #include <xc_private.h>
   136.5  #include <xg_private.h>
   136.6  #include <xenctrl.h>
   136.7 -#include <xen/arch-powerpc.h>
   136.8  
   136.9  #include "flatdevtree_env.h"
  136.10  #include "flatdevtree.h"
  136.11  #include "utils.h"
  136.12  #include "mk_flatdevtree.h"
  136.13  
  136.14 +/* Use 16MB extents to match PowerPC's large page size. */
  136.15 +#define EXTENT_SHIFT 24
  136.16 +#define EXTENT_ORDER (EXTENT_SHIFT - PAGE_SHIFT)
  136.17 +
  136.18  #define INITRD_ADDR (24UL << 20)
  136.19  #define DEVTREE_ADDR (16UL << 20)
  136.20  
  136.21 @@ -151,6 +154,50 @@ static int check_memory_config(int rma_l
  136.22      return 1;
  136.23  }
  136.24  
  136.25 +static int alloc_memory(int xc_handle, domid_t domid, ulong nr_pages,
  136.26 +                        ulong rma_pages)
  136.27 +{
  136.28 +    xen_pfn_t *extent_pfn_arry;
  136.29 +    ulong nr_extents;
  136.30 +    ulong start_pfn = rma_pages;
  136.31 +    int i;
  136.32 +    int j;
  136.33 +    int rc = 0;
  136.34 +
  136.35 +    nr_extents = (nr_pages - rma_pages) >> EXTENT_ORDER;
  136.36 +    DPRINTF("allocating memory in %lu chunks of %luMB\n", nr_extents,
  136.37 +            1UL >> (20 - EXTENT_ORDER));
  136.38 +
  136.39 +    /* populate_physmap requires an array of PFNs that determine where the
  136.40 +     * guest mapping of the new MFNs. */
  136.41 +    extent_pfn_arry = malloc((1<<EXTENT_ORDER) * sizeof(xen_pfn_t));
  136.42 +    if (extent_pfn_arry == NULL) {
  136.43 +        PERROR("Couldn't allocate extent PFN array.\n");
  136.44 +        return -ENOMEM;
  136.45 +    }
  136.46 +
  136.47 +    /* Now allocate the remaining memory as large-order extents. */
  136.48 +    for (i = 0; i < nr_extents; i++) {
  136.49 +        /* Initialize the extent PFN array. */
  136.50 +        for (j = 0; j < (1 << EXTENT_ORDER); j++)
  136.51 +            extent_pfn_arry[j] = start_pfn++;
  136.52 +
  136.53 +        DPRINTF("populate_physmap(Dom%u, order %u, starting_pfn %llx)\n",
  136.54 +                domid, EXTENT_ORDER, extent_pfn_arry[0]);
  136.55 +
  136.56 +        if (xc_domain_memory_populate_physmap(xc_handle, domid, 1, EXTENT_ORDER,
  136.57 +                                               0, extent_pfn_arry))
  136.58 +        {
  136.59 +            PERROR("Could not allocate extents\n");
  136.60 +            rc = -1;
  136.61 +            break;
  136.62 +        }
  136.63 +    }
  136.64 +
  136.65 +    free(extent_pfn_arry);
  136.66 +    return rc;
  136.67 +}
  136.68 +
  136.69  int xc_linux_build(int xc_handle,
  136.70                     uint32_t domid,
  136.71                     unsigned int mem_mb,
  136.72 @@ -176,9 +223,6 @@ int xc_linux_build(int xc_handle,
  136.73      u64 shared_info_paddr;
  136.74      u64 store_paddr;
  136.75      u64 console_paddr;
  136.76 -    u32 remaining_kb;
  136.77 -    u32 extent_order;
  136.78 -    u64 nr_extents;
  136.79      int rma_log = 26;  /* 64MB RMA */
  136.80      int rc = 0;
  136.81      int op;
  136.82 @@ -201,36 +245,26 @@ int xc_linux_build(int xc_handle,
  136.83          goto out;
  136.84      }
  136.85      
  136.86 -    /* alloc RMA */
  136.87 +    /* Allocate the RMA. */
  136.88 +    DPRINTF("RMA: 0x%lx pages\n", rma_pages);
  136.89      if (xc_alloc_real_mode_area(xc_handle, domid, rma_log)) {
  136.90          rc = -1;
  136.91          goto out;
  136.92      }
  136.93  
  136.94 -    /* subtract already allocated RMA to determine remaining KB to alloc */
  136.95 -    remaining_kb = (nr_pages - rma_pages) * (PAGE_SIZE / 1024);
  136.96 -    DPRINTF("totalmem - RMA = %dKB\n", remaining_kb);
  136.97 -
  136.98 -    /* to allocate in 16MB chunks, we need to determine the order of 
  136.99 -     * the number of PAGE_SIZE pages contained in 16MB. */
 136.100 -    extent_order = 24 - 12; /* extent_order = log2((1 << 24) - (1 << 12)) */
 136.101 -    nr_extents = (remaining_kb / (PAGE_SIZE/1024)) >> extent_order;
 136.102 -    DPRINTF("allocating memory in %llu chunks of %luMB\n", nr_extents,
 136.103 -            (((1 << extent_order) >> 10) * PAGE_SIZE) >> 10);
 136.104 -
 136.105 -    /* now allocate the remaining memory as large-order allocations */
 136.106 -    DPRINTF("increase_reservation(%u, %llu, %u)\n", domid, nr_extents, extent_order);
 136.107 -    if (xc_domain_memory_increase_reservation(xc_handle, domid, nr_extents, 
 136.108 -                                              extent_order, 0, NULL)) {
 136.109 -        rc = -1;
 136.110 -        goto out;
 136.111 -    }
 136.112 -
 136.113 +    /* Get the MFN mapping (for RMA only -- we only load data into the RMA). */
 136.114      if (get_rma_page_array(xc_handle, domid, &page_array, rma_pages)) {
 136.115          rc = -1;
 136.116          goto out;
 136.117      }
 136.118  
 136.119 +    /* Allocate the non-RMA memory. */
 136.120 +    rc = alloc_memory(xc_handle, domid, nr_pages, rma_pages);
 136.121 +    if (rc) {
 136.122 +        goto out;
 136.123 +    }
 136.124 +
 136.125 +    /* Load kernel. */
 136.126      DPRINTF("loading image '%s'\n", image_name);
 136.127      if (load_elf_kernel(xc_handle, domid, image_name, &dsi, page_array)) {
 136.128          rc = -1;
 136.129 @@ -238,6 +272,7 @@ int xc_linux_build(int xc_handle,
 136.130      }
 136.131      kern_addr = 0;
 136.132  
 136.133 +    /* Load initrd. */
 136.134      if (initrd_name && initrd_name[0] != '\0') {
 136.135          DPRINTF("loading initrd '%s'\n", initrd_name);
 136.136          if (load_initrd(xc_handle, domid, page_array, initrd_name,
 136.137 @@ -250,16 +285,15 @@ int xc_linux_build(int xc_handle,
 136.138      /* fetch the current shadow_memory value for this domain */
 136.139      op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
 136.140      if (xc_shadow_control(xc_handle, domid, op, NULL, 0, 
 136.141 -                          &shadow_mb, 0, NULL) < 0 ) {
 136.142 +                          &shadow_mb, 0, NULL) < 0) {
 136.143          rc = -1;
 136.144          goto out;
 136.145      }
 136.146  
 136.147      /* determine shared_info, console, and store paddr */
 136.148 -    shared_info_paddr = (rma_pages << PAGE_SHIFT) -
 136.149 -                        (RMA_SHARED_INFO * PAGE_SIZE);
 136.150 -    console_paddr = (rma_pages << PAGE_SHIFT) - (RMA_CONSOLE * PAGE_SIZE);
 136.151 -    store_paddr = (rma_pages << PAGE_SHIFT) - (RMA_STORE * PAGE_SIZE);
 136.152 +    shared_info_paddr = (rma_pages << PAGE_SHIFT) - PAGE_SIZE;
 136.153 +    console_paddr = shared_info_paddr - PAGE_SIZE;
 136.154 +    store_paddr = console_paddr - PAGE_SIZE;
 136.155  
 136.156      /* map paddrs to mfns */
 136.157      *store_mfn = page_array[(xen_pfn_t)(store_paddr >> PAGE_SHIFT)];
 136.158 @@ -286,16 +320,17 @@ int xc_linux_build(int xc_handle,
 136.159                        devtree_addr, devtree.bph->totalsize)) {
 136.160          DPRINTF("couldn't load flattened device tree.\n");
 136.161          rc = -1;
 136.162 -        goto out;
 136.163 +        goto out2;
 136.164      }
 136.165  
 136.166      if (init_boot_vcpu(xc_handle, domid, &dsi, devtree_addr, kern_addr)) {
 136.167          rc = -1;
 136.168 -        goto out;
 136.169 +        goto out2;
 136.170      }
 136.171  
 136.172 +out2:
 136.173 +    free_devtree(&devtree);
 136.174  out:
 136.175 -    free_devtree(&devtree);
 136.176      free_page_array(page_array);
 136.177      return rc;
 136.178  }
   137.1 --- a/tools/libxc/xc_core.c	Thu Mar 01 15:02:09 2007 -0700
   137.2 +++ b/tools/libxc/xc_core.c	Wed Mar 07 12:38:28 2007 -0700
   137.3 @@ -1,10 +1,62 @@
   137.4 +/*
   137.5 + * Elf format, (pfn, gmfn) table, IA64 support.
   137.6 + * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
   137.7 + *                    VA Linux Systems Japan K.K.
   137.8 + *
   137.9 + * xen dump-core file format follows ELF format specification.
  137.10 + * Analisys tools shouldn't depends on the order of sections.
  137.11 + * They should follow elf header and check section names.
  137.12 + *
  137.13 + *  +--------------------------------------------------------+
  137.14 + *  |ELF header                                              |
  137.15 + *  +--------------------------------------------------------+
  137.16 + *  |section headers                                         |
  137.17 + *  |    null section header                                 |
  137.18 + *  |    .shstrtab                                           |
  137.19 + *  |    .note.Xen                                           |
  137.20 + *  |    .xen_prstatus                                       |
  137.21 + *  |    .xen_ia64_mmapped_regs if ia64                      |
  137.22 + *  |    .xen_shared_info if present                         |
  137.23 + *  |    .xen_p2m or .xen_pfn                                |
  137.24 + *  |    .xen_pages                                          |
  137.25 + *  +--------------------------------------------------------+
  137.26 + *  |.note.Xen:note section                                  |
  137.27 + *  |    "Xen" is used as note name,                         |
  137.28 + *  |    types are defined in xen/include/public/elfnote.h   |
  137.29 + *  |    and descriptors are defined in xc_core.h.           |
  137.30 + *  |    dumpcore none                                       |
  137.31 + *  |    dumpcore header                                     |
  137.32 + *  |    dumpcore xen version                                |
  137.33 + *  |    dumpcore format version                             |
  137.34 + *  +--------------------------------------------------------+
  137.35 + *  |.xen_prstatus                                           |
  137.36 + *  |       vcpu_guest_context_t[nr_vcpus]                   |
  137.37 + *  +--------------------------------------------------------+
  137.38 + *  |.xen_ia64_mmapped_regs if ia64                          |
  137.39 + *  |       mmapped_regs_t[nr_vcpus]                         |
  137.40 + *  +--------------------------------------------------------+
  137.41 + *  |.xen_shared_info if possible                            |
  137.42 + *  +--------------------------------------------------------+
  137.43 + *  |.xen_p2m or .xen_pfn                                    |
  137.44 + *  |    .xen_p2m: struct xen_dumpcore_p2m[nr_pages]         |
  137.45 + *  |    .xen_pfn: uint64_t[nr_pages]                        |
  137.46 + *  +--------------------------------------------------------+
  137.47 + *  |.xen_pages                                              |
  137.48 + *  |    page * nr_pages                                     |
  137.49 + *  +--------------------------------------------------------+
  137.50 + *  |.shstrtab: section header string table                  |
  137.51 + *  +--------------------------------------------------------+
  137.52 + *
  137.53 + */
  137.54 +
  137.55  #include "xg_private.h"
  137.56 +#include "xc_core.h"
  137.57 +#include "xc_dom.h"
  137.58  #include <stdlib.h>
  137.59  #include <unistd.h>
  137.60  
  137.61  /* number of pages to write at a time */
  137.62  #define DUMP_INCREMENT (4 * 1024)
  137.63 -#define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
  137.64  
  137.65  static int
  137.66  copy_from_domain_page(int xc_handle,
  137.67 @@ -21,107 +73,712 @@ copy_from_domain_page(int xc_handle,
  137.68      return 0;
  137.69  }
  137.70  
  137.71 +/* string table */
  137.72 +struct xc_core_strtab {
  137.73 +    char       *strings;
  137.74 +    uint16_t    current;
  137.75 +    uint16_t    max;
  137.76 +};
  137.77 +
  137.78 +static struct xc_core_strtab*
  137.79 +xc_core_strtab_init(void)
  137.80 +{
  137.81 +    struct xc_core_strtab *strtab;
  137.82 +    char *strings;
  137.83 +    strtab = malloc(sizeof(*strtab));
  137.84 +    if ( strtab == NULL )
  137.85 +        return NULL;
  137.86 +
  137.87 +    strings = malloc(PAGE_SIZE);
  137.88 +    if ( strings == NULL )
  137.89 +    {
  137.90 +        PERROR("Could not allocate string table init");
  137.91 +        free(strtab);
  137.92 +        return NULL;
  137.93 +    }
  137.94 +    strtab->strings = strings;
  137.95 +    strtab->max = PAGE_SIZE;
  137.96 +
  137.97 +    /* index 0 represents none */
  137.98 +    strtab->strings[0] = '\0';
  137.99 +    strtab->current = 1;
 137.100 +
 137.101 +    return strtab;
 137.102 +}
 137.103 +
 137.104 +static void
 137.105 +xc_core_strtab_free(struct xc_core_strtab *strtab)
 137.106 +{
 137.107 +    free(strtab->strings);
 137.108 +    free(strtab);
 137.109 +}
 137.110 +
 137.111 +static uint16_t
 137.112 +xc_core_strtab_get(struct xc_core_strtab *strtab, const char *name)
 137.113 +{
 137.114 +    uint16_t ret = 0;
 137.115 +    uint16_t len = strlen(name) + 1;
 137.116 +
 137.117 +    if ( strtab->current + len > strtab->max )
 137.118 +    {
 137.119 +        char *tmp;
 137.120 +        if ( strtab->max * 2 < strtab->max )
 137.121 +        {
 137.122 +            PERROR("too long string table");
 137.123 +            errno = ENOMEM;
 137.124 +            return ret;
 137.125 +        }
 137.126 +
 137.127 +
 137.128 +        tmp = realloc(strtab->strings, strtab->max * 2);
 137.129 +        if ( tmp == NULL )
 137.130 +        {
 137.131 +            PERROR("Could not allocate string table");
 137.132 +            return ret;
 137.133 +        }
 137.134 +
 137.135 +        strtab->strings = tmp;
 137.136 +        strtab->max *= 2;
 137.137 +    }
 137.138 +
 137.139 +    ret = strtab->current;
 137.140 +    strcpy(strtab->strings + strtab->current, name);
 137.141 +    strtab->current += len;
 137.142 +    return ret;
 137.143 +}
 137.144 +
 137.145 +
 137.146 +/* section headers */
 137.147 +struct xc_core_section_headers {
 137.148 +    uint16_t    num;
 137.149 +    uint16_t    num_max;
 137.150 +
 137.151 +    Elf64_Shdr  *shdrs;
 137.152 +};
 137.153 +#define SHDR_INIT       16
 137.154 +#define SHDR_INC        4
 137.155 +
 137.156 +static struct xc_core_section_headers*
 137.157 +xc_core_shdr_init(void)
 137.158 +{
 137.159 +    struct xc_core_section_headers *sheaders;
 137.160 +    sheaders = malloc(sizeof(*sheaders));
 137.161 +    if ( sheaders == NULL )
 137.162 +        return NULL;
 137.163 +
 137.164 +    sheaders->num = 0;
 137.165 +    sheaders->num_max = SHDR_INIT;
 137.166 +    sheaders->shdrs = malloc(sizeof(sheaders->shdrs[0]) * sheaders->num_max);
 137.167 +    if ( sheaders->shdrs == NULL )
 137.168 +    {
 137.169 +        free(sheaders);
 137.170 +        return NULL;
 137.171 +    }
 137.172 +    return sheaders;
 137.173 +}
 137.174 +
 137.175 +static void
 137.176 +xc_core_shdr_free(struct xc_core_section_headers *sheaders)
 137.177 +{
 137.178 +    free(sheaders->shdrs);
 137.179 +    free(sheaders);
 137.180 +}
 137.181 +
 137.182 +Elf64_Shdr*
 137.183 +xc_core_shdr_get(struct xc_core_section_headers *sheaders)
 137.184 +{
 137.185 +    Elf64_Shdr *shdr;
 137.186 +
 137.187 +    if ( sheaders->num == sheaders->num_max )
 137.188 +    {
 137.189 +        Elf64_Shdr *shdrs;
 137.190 +        if ( sheaders->num_max + SHDR_INC < sheaders->num_max )
 137.191 +        {
 137.192 +            errno = E2BIG;
 137.193 +            return NULL;
 137.194 +        }
 137.195 +        sheaders->num_max += SHDR_INC;
 137.196 +        shdrs = realloc(sheaders->shdrs,
 137.197 +                        sizeof(sheaders->shdrs[0]) * sheaders->num_max);
 137.198 +        if ( shdrs == NULL )
 137.199 +            return NULL;
 137.200 +        sheaders->shdrs = shdrs;
 137.201 +    }
 137.202 +
 137.203 +    shdr = &sheaders->shdrs[sheaders->num];
 137.204 +    sheaders->num++;
 137.205 +    memset(shdr, 0, sizeof(*shdr));
 137.206 +    return shdr;
 137.207 +}
 137.208 +
 137.209 +int
 137.210 +xc_core_shdr_set(Elf64_Shdr *shdr,
 137.211 +                 struct xc_core_strtab *strtab,
 137.212 +                 const char *name, uint32_t type,
 137.213 +                 uint64_t offset, uint64_t size,
 137.214 +                 uint64_t addralign, uint64_t entsize)
 137.215 +{
 137.216 +    uint64_t name_idx = xc_core_strtab_get(strtab, name);
 137.217 +    if ( name_idx == 0 )
 137.218 +        return -1;
 137.219 +
 137.220 +    shdr->sh_name = name_idx;
 137.221 +    shdr->sh_type = type;
 137.222 +    shdr->sh_offset = offset;
 137.223 +    shdr->sh_size = size;
 137.224 +    shdr->sh_addralign = addralign;
 137.225 +    shdr->sh_entsize = entsize;
 137.226 +    return 0;
 137.227 +}
 137.228 +
 137.229 +static int
 137.230 +elfnote_fill_xen_version(int xc_handle,
 137.231 +                         struct xen_dumpcore_elfnote_xen_version_desc
 137.232 +                         *xen_version)
 137.233 +{
 137.234 +    int rc;
 137.235 +    memset(xen_version, 0, sizeof(*xen_version));
 137.236 +
 137.237 +    rc = xc_version(xc_handle, XENVER_version, NULL);
 137.238 +    if ( rc < 0 )
 137.239 +        return rc;
 137.240 +    xen_version->major_version = rc >> 16;
 137.241 +    xen_version->minor_version = rc & ((1 << 16) - 1);
 137.242 +
 137.243 +    rc = xc_version(xc_handle, XENVER_extraversion,
 137.244 +                    &xen_version->extra_version);
 137.245 +    if ( rc < 0 )
 137.246 +        return rc;
 137.247 +
 137.248 +    rc = xc_version(xc_handle, XENVER_compile_info,
 137.249 +                    &xen_version->compile_info);
 137.250 +    if ( rc < 0 )
 137.251 +        return rc;
 137.252 +
 137.253 +    rc = xc_version(xc_handle,
 137.254 +                    XENVER_capabilities, &xen_version->capabilities);
 137.255 +    if ( rc < 0 )
 137.256 +        return rc;
 137.257 +
 137.258 +    rc = xc_version(xc_handle, XENVER_changeset, &xen_version->changeset);
 137.259 +    if ( rc < 0 )
 137.260 +        return rc;
 137.261 +
 137.262 +    rc = xc_version(xc_handle, XENVER_platform_parameters,
 137.263 +                    &xen_version->platform_parameters);
 137.264 +    if ( rc < 0 )
 137.265 +        return rc;
 137.266 +
 137.267 +    rc = xc_version(xc_handle, XENVER_pagesize, NULL);
 137.268 +    if ( rc < 0 )
 137.269 +        return rc;
 137.270 +    xen_version->pagesize = rc;
 137.271 +
 137.272 +    return 0;
 137.273 +}
 137.274 +
 137.275 +static int
 137.276 +elfnote_fill_format_version(struct xen_dumpcore_elfnote_format_version_desc
 137.277 +                            *format_version)
 137.278 +{
 137.279 +    format_version->version = XEN_DUMPCORE_FORMAT_VERSION_CURRENT;
 137.280 +    return 0;
 137.281 +}
 137.282 +
 137.283  int
 137.284  xc_domain_dumpcore_via_callback(int xc_handle,
 137.285                                  uint32_t domid,
 137.286                                  void *args,
 137.287                                  dumpcore_rtn_t dump_rtn)
 137.288  {
 137.289 -    unsigned long nr_pages;
 137.290 -    uint64_t *page_array = NULL;
 137.291      xc_dominfo_t info;
 137.292 -    int i, nr_vcpus = 0;
 137.293 +    shared_info_t *live_shinfo = NULL;
 137.294 +
 137.295 +    int nr_vcpus = 0;
 137.296      char *dump_mem, *dump_mem_start = NULL;
 137.297 -    struct xc_core_header header;
 137.298      vcpu_guest_context_t  ctxt[MAX_VIRT_CPUS];
 137.299 +    struct xc_core_arch_context arch_ctxt;
 137.300      char dummy[PAGE_SIZE];
 137.301      int dummy_len;
 137.302 -    int sts;
 137.303 +    int sts = -1;
 137.304 +
 137.305 +    unsigned long i;
 137.306 +    unsigned long j;
 137.307 +    unsigned long nr_pages;
 137.308 +
 137.309 +    xc_core_memory_map_t *memory_map = NULL;
 137.310 +    unsigned int nr_memory_map;
 137.311 +    unsigned int map_idx;
 137.312 +
 137.313 +    int auto_translated_physmap;
 137.314 +    xen_pfn_t *p2m = NULL;
 137.315 +    unsigned long max_pfn = 0;
 137.316 +    struct xen_dumpcore_p2m *p2m_array = NULL;
 137.317 +
 137.318 +    uint64_t *pfn_array = NULL;
 137.319  
 137.320 +    Elf64_Ehdr ehdr;
 137.321 +    uint64_t filesz;
 137.322 +    uint64_t offset;
 137.323 +    uint64_t fixup;
 137.324 +
 137.325 +    struct xc_core_strtab *strtab = NULL;
 137.326 +    uint16_t strtab_idx;
 137.327 +    struct xc_core_section_headers *sheaders = NULL;
 137.328 +    Elf64_Shdr *shdr;
 137.329 +
 137.330 +    /* elf notes */
 137.331 +    struct elfnote elfnote;
 137.332 +    struct xen_dumpcore_elfnote_none_desc none;
 137.333 +    struct xen_dumpcore_elfnote_header_desc header;
 137.334 +    struct xen_dumpcore_elfnote_xen_version_desc xen_version;
 137.335 +    struct xen_dumpcore_elfnote_format_version_desc format_version;
 137.336 +
 137.337 +    xc_core_arch_context_init(&arch_ctxt);
 137.338      if ( (dump_mem_start = malloc(DUMP_INCREMENT*PAGE_SIZE)) == NULL )
 137.339      {
 137.340          PERROR("Could not allocate dump_mem");
 137.341 -        goto error_out;
 137.342 +        goto out;
 137.343      }
 137.344  
 137.345      if ( xc_domain_getinfo(xc_handle, domid, 1, &info) != 1 )
 137.346      {
 137.347          PERROR("Could not get info for domain");
 137.348 -        goto error_out;
 137.349 +        goto out;
 137.350      }
 137.351 +    /* Map the shared info frame */
 137.352 +    live_shinfo = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
 137.353 +                                       PROT_READ, info.shared_info_frame);
 137.354 +    if ( !live_shinfo 
 137.355 +#ifdef __ia64__
 137.356 +         && !info.hvm
 137.357 +#endif
 137.358 +        )
 137.359 +    {
 137.360 +        PERROR("Couldn't map live_shinfo");
 137.361 +        goto out;
 137.362 +    }
 137.363 +    auto_translated_physmap = xc_core_arch_auto_translated_physmap(&info);
 137.364  
 137.365      if ( domid != info.domid )
 137.366      {
 137.367          PERROR("Domain %d does not exist", domid);
 137.368 -        goto error_out;
 137.369 +        goto out;
 137.370      }
 137.371  
 137.372      for ( i = 0; i <= info.max_vcpu_id; i++ )
 137.373 -        if ( xc_vcpu_getcontext(xc_handle, domid, i, &ctxt[nr_vcpus]) == 0)
 137.374 +    {
 137.375 +        if ( xc_vcpu_getcontext(xc_handle, domid, i, &ctxt[nr_vcpus]) == 0 )
 137.376 +        {
 137.377 +            if ( xc_core_arch_context_get(&arch_ctxt, &ctxt[nr_vcpus],
 137.378 +                                          xc_handle, domid) )
 137.379 +                continue;
 137.380              nr_vcpus++;
 137.381 +        }
 137.382 +    }
 137.383 +    if ( nr_vcpus == 0 )
 137.384 +    {
 137.385 +        PERROR("No VCPU context could be grabbed");
 137.386 +        goto out;
 137.387 +    }
 137.388 +
 137.389 +    /* obtain memory map */
 137.390 +    sts = xc_core_arch_memory_map_get(xc_handle, &info, live_shinfo,
 137.391 +                                      &memory_map, &nr_memory_map);
 137.392 +    if ( sts != 0 )
 137.393 +        goto out;
 137.394  
 137.395      nr_pages = info.nr_pages;
 137.396 +    if ( !auto_translated_physmap )
 137.397 +    {
 137.398 +        /* obtain p2m table */
 137.399 +        p2m_array = malloc(nr_pages * sizeof(p2m_array[0]));
 137.400 +        if ( p2m_array == NULL )
 137.401 +        {
 137.402 +            PERROR("Could not allocate p2m array");
 137.403 +            goto out;
 137.404 +        }
 137.405  
 137.406 +        sts = xc_core_arch_map_p2m(xc_handle, &info, live_shinfo,
 137.407 +                                   &p2m, &max_pfn);
 137.408 +        if ( sts != 0 )
 137.409 +            goto out;
 137.410 +    }
 137.411 +    else
 137.412 +    {
 137.413 +        pfn_array = malloc(nr_pages * sizeof(pfn_array[0]));
 137.414 +        if ( pfn_array == NULL )
 137.415 +        {
 137.416 +            PERROR("Could not allocate pfn array");
 137.417 +            goto out;
 137.418 +        }
 137.419 +    }
 137.420 +
 137.421 +    /* create .xen_p2m or .xen_pfn */
 137.422 +    j = 0;
 137.423 +    for ( map_idx = 0; map_idx < nr_memory_map; map_idx++ )
 137.424 +    {
 137.425 +        uint64_t pfn_start;
 137.426 +        uint64_t pfn_end;
 137.427 +
 137.428 +        pfn_start = memory_map[map_idx].addr >> PAGE_SHIFT;
 137.429 +        pfn_end = pfn_start + (memory_map[map_idx].size >> PAGE_SHIFT);
 137.430 +        for ( i = pfn_start; i < pfn_end; i++ )
 137.431 +        {
 137.432 +            if ( !auto_translated_physmap )
 137.433 +            {
 137.434 +                if ( p2m[i] == INVALID_P2M_ENTRY )
 137.435 +                    continue;
 137.436 +                p2m_array[j].pfn = i;
 137.437 +                p2m_array[j].gmfn = p2m[i];
 137.438 +            }
 137.439 +            else
 137.440 +            {
 137.441 +                /* try to map page to determin wheter it has underlying page */
 137.442 +                void *vaddr = xc_map_foreign_range(xc_handle, domid,
 137.443 +                                                   PAGE_SIZE, PROT_READ, i);
 137.444 +                if ( vaddr == NULL )
 137.445 +                    continue;
 137.446 +                munmap(vaddr, PAGE_SIZE);
 137.447 +                pfn_array[j] = i;
 137.448 +            }
 137.449 +
 137.450 +            j++;
 137.451 +        }
 137.452 +    }
 137.453 +    if ( j != nr_pages )
 137.454 +    {
 137.455 +        PERROR("j (%ld) != nr_pages (%ld)", j , nr_pages);
 137.456 +        /* When live dump-mode (-L option) is specified,
 137.457 +         * guest domain may change its mapping.
 137.458 +         */
 137.459 +        nr_pages = j;
 137.460 +    }
 137.461 +
 137.462 +    memset(&ehdr, 0, sizeof(ehdr));
 137.463 +    ehdr.e_ident[EI_MAG0] = ELFMAG0;
 137.464 +    ehdr.e_ident[EI_MAG1] = ELFMAG1;
 137.465 +    ehdr.e_ident[EI_MAG2] = ELFMAG2;
 137.466 +    ehdr.e_ident[EI_MAG3] = ELFMAG3;
 137.467 +    ehdr.e_ident[EI_CLASS] = ELFCLASS64;
 137.468 +    ehdr.e_ident[EI_DATA] = ELF_ARCH_DATA;
 137.469 +    ehdr.e_ident[EI_VERSION] = EV_CURRENT;
 137.470 +    ehdr.e_ident[EI_OSABI] = ELFOSABI_SYSV;
 137.471 +    ehdr.e_ident[EI_ABIVERSION] = EV_CURRENT;
 137.472 +
 137.473 +    ehdr.e_type = ET_CORE;
 137.474 +    ehdr.e_machine = ELF_ARCH_MACHINE;
 137.475 +    ehdr.e_version = EV_CURRENT;
 137.476 +    ehdr.e_entry = 0;
 137.477 +    ehdr.e_phoff = 0;
 137.478 +    ehdr.e_shoff = sizeof(ehdr);
 137.479 +    ehdr.e_flags = ELF_CORE_EFLAGS;
 137.480 +    ehdr.e_ehsize = sizeof(ehdr);
 137.481 +    ehdr.e_phentsize = sizeof(Elf64_Phdr);
 137.482 +    ehdr.e_phnum = 0;
 137.483 +    ehdr.e_shentsize = sizeof(Elf64_Shdr);
 137.484 +    /* ehdr.e_shnum and ehdr.e_shstrndx aren't known here yet. fill it later*/
 137.485 +
 137.486 +    /* create section header */
 137.487 +    strtab = xc_core_strtab_init();
 137.488 +    if ( strtab == NULL )
 137.489 +    {
 137.490 +        PERROR("Could not allocate string table");
 137.491 +        goto out;
 137.492 +    }
 137.493 +    sheaders = xc_core_shdr_init();
 137.494 +    if ( sheaders == NULL )
 137.495 +    {
 137.496 +        PERROR("Could not allocate section headers");
 137.497 +        goto out;
 137.498 +    }
 137.499 +    /* null section */
 137.500 +    shdr = xc_core_shdr_get(sheaders);
 137.501 +    if ( shdr == NULL )
 137.502 +    {
 137.503 +        PERROR("Could not get section header for null section");
 137.504 +        goto out;
 137.505 +    }
 137.506 +
 137.507 +    /* .shstrtab */
 137.508 +    shdr = xc_core_shdr_get(sheaders);
 137.509 +    if ( shdr == NULL )
 137.510 +    {
 137.511 +        PERROR("Could not get section header for shstrtab");
 137.512 +        goto out;
 137.513 +    }
 137.514 +    strtab_idx = shdr - sheaders->shdrs;
 137.515 +    /* strtab_shdr.sh_offset, strtab_shdr.sh_size aren't unknown.
 137.516 +     * fill it later
 137.517 +     */
 137.518 +    sts = xc_core_shdr_set(shdr, strtab, ELF_SHSTRTAB, SHT_STRTAB, 0, 0, 0, 0);
 137.519 +    if ( sts != 0 )
 137.520 +        goto out;
 137.521 +
 137.522 +    /* elf note section */
 137.523 +    /* here the number of section header is unknown. fix up offset later. */
 137.524 +    offset = sizeof(ehdr);
 137.525 +    filesz =
 137.526 +        sizeof(struct xen_dumpcore_elfnote_none) +         /* none */
 137.527 +        sizeof(struct xen_dumpcore_elfnote_header) +       /* core header */
 137.528 +        sizeof(struct xen_dumpcore_elfnote_xen_version) +  /* xen version */
 137.529 +        sizeof(struct xen_dumpcore_elfnote_format_version);/* format version */
 137.530 +    shdr = xc_core_shdr_get(sheaders);
 137.531 +    if ( shdr == NULL )
 137.532 +    {
 137.533 +        PERROR("Could not get section header for note section");
 137.534 +        goto out;
 137.535 +    }
 137.536 +    sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_NOTE, SHT_NOTE,
 137.537 +                           offset, filesz, 0, 0);
 137.538 +    if ( sts != 0 )
 137.539 +        goto out;
 137.540 +    offset += filesz;
 137.541 +
 137.542 +    /* prstatus */
 137.543 +    shdr = xc_core_shdr_get(sheaders);
 137.544 +    if ( shdr == NULL )
 137.545 +    {
 137.546 +        PERROR("Could not get section header for .xen_prstatus");
 137.547 +        goto out;
 137.548 +    }
 137.549 +    filesz = sizeof(ctxt[0]) * nr_vcpus;
 137.550 +    sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_PRSTATUS,
 137.551 +                           SHT_PROGBITS, offset, filesz,
 137.552 +                           __alignof__(ctxt[0]), sizeof(ctxt[0]));
 137.553 +    if ( sts != 0 )
 137.554 +        goto out;
 137.555 +    offset += filesz;
 137.556 +
 137.557 +    /* arch context */
 137.558 +    sts = xc_core_arch_context_get_shdr(&arch_ctxt, sheaders, strtab,
 137.559 +                                        &filesz, offset);
 137.560 +    if ( sts != 0)
 137.561 +        goto out;
 137.562 +    offset += filesz;
 137.563 +
 137.564 +    /* shared_info */
 137.565 +    if ( live_shinfo != NULL )
 137.566 +    {
 137.567 +        shdr = xc_core_shdr_get(sheaders);
 137.568 +        if ( shdr == NULL )
 137.569 +        {
 137.570 +            PERROR("Could not get section header for .xen_shared_info");
 137.571 +            goto out;
 137.572 +        }
 137.573 +        filesz = PAGE_SIZE;
 137.574 +        sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_SHARED_INFO,
 137.575 +                               SHT_PROGBITS, offset, filesz,
 137.576 +                               __alignof__(*live_shinfo), PAGE_SIZE);
 137.577 +        if ( sts != 0 )
 137.578 +            goto out;
 137.579 +        offset += filesz;
 137.580 +    }
 137.581 +
 137.582 +    /* p2m/pfn table */
 137.583 +    shdr = xc_core_shdr_get(sheaders);
 137.584 +    if ( shdr == NULL )
 137.585 +    {
 137.586 +        PERROR("Could not get section header for .xen_{p2m, pfn} table");
 137.587 +        goto out;
 137.588 +    }
 137.589 +    if ( !auto_translated_physmap )
 137.590 +    {
 137.591 +        filesz = nr_pages * sizeof(p2m_array[0]);
 137.592 +        sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_P2M,
 137.593 +                               SHT_PROGBITS,
 137.594 +                               offset, filesz, __alignof__(p2m_array[0]),
 137.595 +                               sizeof(p2m_array[0]));
 137.596 +        if ( sts != 0 )
 137.597 +            goto out;
 137.598 +    }
 137.599 +    else
 137.600 +    {
 137.601 +        filesz = nr_pages * sizeof(pfn_array[0]);
 137.602 +        sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_PFN,
 137.603 +                               SHT_PROGBITS,
 137.604 +                               offset, filesz, __alignof__(pfn_array[0]),
 137.605 +                               sizeof(pfn_array[0]));
 137.606 +        if ( sts != 0 )
 137.607 +            goto out;
 137.608 +    }
 137.609 +    offset += filesz;
 137.610 +
 137.611 +    /* pages */
 137.612 +    shdr = xc_core_shdr_get(sheaders);
 137.613 +    if ( shdr == NULL )
 137.614 +    {
 137.615 +        PERROR("could not get section headers for .xen_pages");
 137.616 +        goto out;
 137.617 +    }
 137.618 +
 137.619 +    /*
 137.620 +     * pages are the last section to allocate section headers
 137.621 +     * so that we know the number of section headers here.
 137.622 +     */
 137.623 +    fixup = sheaders->num * sizeof(*shdr);
 137.624 +    /* zeroth section should have zero offset */
 137.625 +    for ( i = 1; i < sheaders->num; i++ )
 137.626 +        sheaders->shdrs[i].sh_offset += fixup;
 137.627 +    offset += fixup;
 137.628 +    dummy_len = ROUNDUP(offset, PAGE_SHIFT) - offset; /* padding length */
 137.629 +    offset += dummy_len;
 137.630 +
 137.631 +    filesz = nr_pages * PAGE_SIZE;
 137.632 +    sts = xc_core_shdr_set(shdr, strtab, XEN_DUMPCORE_SEC_PAGES, SHT_PROGBITS,
 137.633 +                           offset, filesz, PAGE_SIZE, PAGE_SIZE);
 137.634 +    if ( sts != 0 )
 137.635 +        goto out;
 137.636 +    offset += filesz;
 137.637 +
 137.638 +    /* fixing up section header string table section header */
 137.639 +    filesz = strtab->current;
 137.640 +    sheaders->shdrs[strtab_idx].sh_offset = offset;
 137.641 +    sheaders->shdrs[strtab_idx].sh_size = filesz;
 137.642 +
 137.643 +    /* write out elf header */
 137.644 +    ehdr.e_shnum = sheaders->num;
 137.645 +    ehdr.e_shstrndx = strtab_idx;
 137.646 +    sts = dump_rtn(args, (char*)&ehdr, sizeof(ehdr));
 137.647 +    if ( sts != 0 )
 137.648 +        goto out;
 137.649 +
 137.650 +    /* section headers */
 137.651 +    sts = dump_rtn(args, (char*)sheaders->shdrs,
 137.652 +                   sheaders->num * sizeof(sheaders->shdrs[0]));
 137.653 +    if ( sts != 0 )
 137.654 +        goto out;
 137.655 +
 137.656 +    /* elf note section */
 137.657 +    memset(&elfnote, 0, sizeof(elfnote));
 137.658 +    elfnote.namesz = strlen(XEN_DUMPCORE_ELFNOTE_NAME) + 1;
 137.659 +    strncpy(elfnote.name, XEN_DUMPCORE_ELFNOTE_NAME, sizeof(elfnote.name));
 137.660 +
 137.661 +    /* elf note section:xen core header */
 137.662 +    elfnote.descsz = sizeof(none);
 137.663 +    elfnote.type = XEN_ELFNOTE_DUMPCORE_NONE;
 137.664 +    sts = dump_rtn(args, (char*)&elfnote, sizeof(elfnote));
 137.665 +    if ( sts != 0 )
 137.666 +        goto out;
 137.667 +    sts = dump_rtn(args, (char*)&none, sizeof(none));
 137.668 +    if ( sts != 0 )
 137.669 +        goto out;
 137.670 +
 137.671 +    /* elf note section:xen core header */
 137.672 +    elfnote.descsz = sizeof(header);
 137.673 +    elfnote.type = XEN_ELFNOTE_DUMPCORE_HEADER;
 137.674      header.xch_magic = info.hvm ? XC_CORE_MAGIC_HVM : XC_CORE_MAGIC;
 137.675      header.xch_nr_vcpus = nr_vcpus;
 137.676      header.xch_nr_pages = nr_pages;
 137.677 -    header.xch_ctxt_offset = sizeof(struct xc_core_header);
 137.678 -    header.xch_index_offset = sizeof(struct xc_core_header) +
 137.679 -        sizeof(vcpu_guest_context_t)*nr_vcpus;
 137.680 -    dummy_len = (sizeof(struct xc_core_header) +
 137.681 -                 (sizeof(vcpu_guest_context_t) * nr_vcpus) +
 137.682 -                 (nr_pages * sizeof(*page_array)));
 137.683 -    header.xch_pages_offset = round_pgup(dummy_len);
 137.684 +    header.xch_page_size = PAGE_SIZE;
 137.685 +    sts = dump_rtn(args, (char*)&elfnote, sizeof(elfnote));
 137.686 +    if ( sts != 0 )
 137.687 +        goto out;
 137.688 +    sts = dump_rtn(args, (char*)&header, sizeof(header));
 137.689 +    if ( sts != 0 )
 137.690 +        goto out;
 137.691  
 137.692 -    sts = dump_rtn(args, (char *)&header, sizeof(struct xc_core_header));
 137.693 +    /* elf note section: xen version */
 137.694 +    elfnote.descsz = sizeof(xen_version);
 137.695 +    elfnote.type = XEN_ELFNOTE_DUMPCORE_XEN_VERSION;
 137.696 +    elfnote_fill_xen_version(xc_handle, &xen_version);
 137.697 +    sts = dump_rtn(args, (char*)&elfnote, sizeof(elfnote));
 137.698 +    if ( sts != 0 )
 137.699 +        goto out;
 137.700 +    sts = dump_rtn(args, (char*)&xen_version, sizeof(xen_version));
 137.701      if ( sts != 0 )
 137.702 -        goto error_out;
 137.703 +        goto out;
 137.704  
 137.705 +    /* elf note section: format version */
 137.706 +    elfnote.descsz = sizeof(format_version);
 137.707 +    elfnote.type = XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION;
 137.708 +    elfnote_fill_format_version(&format_version);
 137.709 +    sts = dump_rtn(args, (char*)&elfnote, sizeof(elfnote));
 137.710 +    if ( sts != 0 )
 137.711 +        goto out;
 137.712 +    sts = dump_rtn(args, (char*)&format_version, sizeof(format_version));
 137.713 +    if ( sts != 0 )
 137.714 +        goto out;
 137.715 +
 137.716 +    /* prstatus: .xen_prstatus */
 137.717      sts = dump_rtn(args, (char *)&ctxt, sizeof(ctxt[0]) * nr_vcpus);
 137.718      if ( sts != 0 )
 137.719 -        goto error_out;
 137.720 +        goto out;
 137.721  
 137.722 -    if ( (page_array = malloc(nr_pages * sizeof(*page_array))) == NULL )
 137.723 +    if ( live_shinfo != NULL )
 137.724      {
 137.725 -        IPRINTF("Could not allocate memory\n");
 137.726 -        goto error_out;
 137.727 +        /* shared_info: .xen_shared_info */
 137.728 +        sts = dump_rtn(args, (char*)live_shinfo, PAGE_SIZE);
 137.729 +        if ( sts != 0 )
 137.730 +            goto out;
 137.731      }
 137.732 -    if ( xc_get_pfn_list(xc_handle, domid, page_array, nr_pages) != nr_pages )
 137.733 -    {
 137.734 -        IPRINTF("Could not get the page frame list\n");
 137.735 -        goto error_out;
 137.736 -    }
 137.737 -    sts = dump_rtn(args, (char *)page_array, nr_pages * sizeof(*page_array));
 137.738 +
 137.739 +    /* arch specific context */
 137.740 +    sts = xc_core_arch_context_dump(&arch_ctxt, args, dump_rtn);
 137.741      if ( sts != 0 )
 137.742 -        goto error_out;
 137.743 +        goto out;
 137.744 +
 137.745 +    /* p2m/pfn table: .xen_p2m/.xen_pfn */
 137.746 +    if ( !auto_translated_physmap )
 137.747 +        sts = dump_rtn(args, (char *)p2m_array,
 137.748 +                       sizeof(p2m_array[0]) * nr_pages);
 137.749 +    else
 137.750 +        sts = dump_rtn(args, (char *)pfn_array,
 137.751 +                       sizeof(pfn_array[0]) * nr_pages);
 137.752 +    if ( sts != 0 )
 137.753 +        goto out;
 137.754  
 137.755      /* Pad the output data to page alignment. */
 137.756      memset(dummy, 0, PAGE_SIZE);
 137.757 -    sts = dump_rtn(args, dummy, header.xch_pages_offset - dummy_len);
 137.758 +    sts = dump_rtn(args, dummy, dummy_len);
 137.759      if ( sts != 0 )
 137.760 -        goto error_out;
 137.761 +        goto out;
 137.762  
 137.763 +    /* dump pages: .xen_pages */
 137.764      for ( dump_mem = dump_mem_start, i = 0; i < nr_pages; i++ )
 137.765      {
 137.766 -        copy_from_domain_page(xc_handle, domid, page_array[i], dump_mem);
 137.767 +        uint64_t gmfn;
 137.768 +        if ( !auto_translated_physmap )
 137.769 +            gmfn = p2m_array[i].gmfn;
 137.770 +        else
 137.771 +            gmfn = pfn_array[i];
 137.772 +
 137.773 +        copy_from_domain_page(xc_handle, domid, gmfn, dump_mem);
 137.774          dump_mem += PAGE_SIZE;
 137.775          if ( ((i + 1) % DUMP_INCREMENT == 0) || ((i + 1) == nr_pages) )
 137.776          {
 137.777              sts = dump_rtn(args, dump_mem_start, dump_mem - dump_mem_start);
 137.778              if ( sts != 0 )
 137.779 -                goto error_out;
 137.780 +                goto out;
 137.781              dump_mem = dump_mem_start;
 137.782          }
 137.783      }
 137.784  
 137.785 -    free(dump_mem_start);
 137.786 -    free(page_array);
 137.787 -    return 0;
 137.788 +    /* elf section header string table: .shstrtab */
 137.789 +    sts = dump_rtn(args, strtab->strings, strtab->current);
 137.790 +    if ( sts != 0 )
 137.791 +        goto out;
 137.792 +
 137.793 +    sts = 0;
 137.794  
 137.795 - error_out:
 137.796 -    free(dump_mem_start);
 137.797 -    free(page_array);
 137.798 -    return -1;
 137.799 +out:
 137.800 +    if ( p2m != NULL )
 137.801 +        munmap(p2m, PAGE_SIZE * P2M_FL_ENTRIES);
 137.802 +    if ( p2m_array != NULL )
 137.803 +        free(p2m_array);
 137.804 +    if ( pfn_array != NULL )
 137.805 +        free(pfn_array);
 137.806 +    if ( sheaders != NULL )
 137.807 +        xc_core_shdr_free(sheaders);
 137.808 +    if ( strtab != NULL )
 137.809 +        xc_core_strtab_free(strtab);
 137.810 +    if ( dump_mem_start != NULL )
 137.811 +        free(dump_mem_start);
 137.812 +    if ( live_shinfo != NULL )
 137.813 +        munmap(live_shinfo, PAGE_SIZE);
 137.814 +    xc_core_arch_context_free(&arch_ctxt);
 137.815 +
 137.816 +    return sts;
 137.817  }
 137.818  
 137.819  /* Callback args for writing to a local dump file. */
 137.820 @@ -145,6 +802,12 @@ static int local_file_dump(void *args, c
 137.821          }
 137.822      }
 137.823  
 137.824 +    if (length >= DUMP_INCREMENT*PAGE_SIZE) {
 137.825 +        // Now dumping pages -- make sure we discard clean pages from
 137.826 +        // the cache after each write
 137.827 +        discard_file_cache(da->fd, 0 /* no flush */);
 137.828 +    }
 137.829 +
 137.830      return 0;
 137.831  }
 137.832  
 137.833 @@ -165,6 +828,9 @@ xc_domain_dumpcore(int xc_handle,
 137.834      sts = xc_domain_dumpcore_via_callback(
 137.835          xc_handle, domid, &da, &local_file_dump);
 137.836  
 137.837 +    /* flush and discard any remaining portion of the file from cache */
 137.838 +    discard_file_cache(da.fd, 1/* flush first*/);
 137.839 +
 137.840      close(da.fd);
 137.841  
 137.842      return sts;
   138.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   138.2 +++ b/tools/libxc/xc_core.h	Wed Mar 07 12:38:28 2007 -0700
   138.3 @@ -0,0 +1,165 @@
   138.4 +/*
   138.5 + * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
   138.6 + *                    VA Linux Systems Japan K.K.
   138.7 + *
   138.8 + * This program is free software; you can redistribute it and/or modify
   138.9 + * it under the terms of the GNU General Public License as published by
  138.10 + * the Free Software Foundation; either version 2 of the License, or
  138.11 + * (at your option) any later version.
  138.12 + *
  138.13 + * This program is distributed in the hope that it will be useful,
  138.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  138.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  138.16 + * GNU General Public License for more details.
  138.17 + *
  138.18 + * You should have received a copy of the GNU General Public License
  138.19 + * along with this program; if not, write to the Free Software
  138.20 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  138.21 + *
  138.22 + */
  138.23 +
  138.24 +#ifndef XC_CORE_H
  138.25 +#define XC_CORE_H
  138.26 +
  138.27 +#include "xen/version.h"
  138.28 +#include "xg_private.h"
  138.29 +#include "xen/elfstructs.h"
  138.30 +
  138.31 +/* section names */
  138.32 +#define XEN_DUMPCORE_SEC_NOTE                   ".note.Xen"
  138.33 +#define XEN_DUMPCORE_SEC_PRSTATUS               ".xen_prstatus"
  138.34 +#define XEN_DUMPCORE_SEC_SHARED_INFO            ".xen_shared_info"
  138.35 +#define XEN_DUMPCORE_SEC_P2M                    ".xen_p2m"
  138.36 +#define XEN_DUMPCORE_SEC_PFN                    ".xen_pfn"
  138.37 +#define XEN_DUMPCORE_SEC_PAGES                  ".xen_pages"
  138.38 +
  138.39 +#define XEN_DUMPCORE_SEC_IA64_MAPPED_REGS       ".xen_ia64_mapped_regs"
  138.40 +
  138.41 +/* elf note name */
  138.42 +#define XEN_DUMPCORE_ELFNOTE_NAME               "Xen"
  138.43 +/* note numbers are defined in xen/elfnote.h */
  138.44 +
  138.45 +struct elfnote {
  138.46 +    uint32_t    namesz; /* Elf_Note note; */
  138.47 +    uint32_t    descsz;
  138.48 +    uint32_t    type;
  138.49 +    char        name[4]; /* sizeof("Xen") = 4
  138.50 +                          * Fotunately this is 64bit aligned so that
  138.51 +                          * we can use same structore for both 32/64bit
  138.52 +                          */
  138.53 +};
  138.54 +
  138.55 +struct xen_dumpcore_elfnote_none_desc {
  138.56 +    /* nothing */
  138.57 +};
  138.58 +
  138.59 +struct xen_dumpcore_elfnote_header_desc {
  138.60 +    uint64_t    xch_magic;
  138.61 +    uint64_t    xch_nr_vcpus;
  138.62 +    uint64_t    xch_nr_pages;
  138.63 +    uint64_t    xch_page_size;
  138.64 +};
  138.65 +
  138.66 +struct xen_dumpcore_elfnote_xen_version_desc {
  138.67 +    uint64_t                    major_version;
  138.68 +    uint64_t                    minor_version;
  138.69 +    xen_extraversion_t          extra_version;
  138.70 +    xen_compile_info_t          compile_info;
  138.71 +    xen_capabilities_info_t     capabilities;
  138.72 +    xen_changeset_info_t        changeset;
  138.73 +    xen_platform_parameters_t   platform_parameters;
  138.74 +    uint64_t                    pagesize;
  138.75 +};
  138.76 +
  138.77 +#define XEN_DUMPCORE_FORMAT_VERSION(major, minor)  \
  138.78 +    ((major) << 32) | ((minor) & 0xffffffff)
  138.79 +#define XEN_DUMPCORE_FORMAT_MAJOR(version)      ((major) >> 32)
  138.80 +#define XEN_DUMPCORE_FORMAT_MINOR(version)      ((minor) & 0xffffffff)
  138.81 +
  138.82 +#define XEN_DUMPCORE_FORMAT_MAJOR_CURRENT       ((uint64_t)0)
  138.83 +#define XEN_DUMPCORE_FORMAT_MINOR_CURRENT       ((uint64_t)1)
  138.84 +#define XEN_DUMPCORE_FORMAT_VERSION_CURRENT                         \
  138.85 +    XEN_DUMPCORE_FORMAT_VERSION(XEN_DUMPCORE_FORMAT_MAJOR_CURRENT,  \
  138.86 +                                XEN_DUMPCORE_FORMAT_MINOR_CURRENT)
  138.87 +
  138.88 +struct xen_dumpcore_elfnote_format_version_desc {
  138.89 +    uint64_t    version;
  138.90 +};
  138.91 +
  138.92 +
  138.93 +struct xen_dumpcore_elfnote_none {
  138.94 +    struct elfnote                              elfnote;
  138.95 +    struct xen_dumpcore_elfnote_none_desc       none;
  138.96 +};
  138.97 +
  138.98 +struct xen_dumpcore_elfnote_header {
  138.99 +    struct elfnote                              elfnote;
 138.100 +    struct xen_dumpcore_elfnote_header_desc     header;
 138.101 +};
 138.102 +
 138.103 +struct xen_dumpcore_elfnote_xen_version {
 138.104 +    struct elfnote                                     elfnote;
 138.105 +    struct xen_dumpcore_elfnote_xen_version_desc        xen_version;
 138.106 +};
 138.107 +
 138.108 +struct xen_dumpcore_elfnote_format_version {
 138.109 +    struct elfnote                                      elfnote;
 138.110 +    struct xen_dumpcore_elfnote_format_version_desc     format_version;
 138.111 +};
 138.112 +
 138.113 +struct xen_dumpcore_p2m {
 138.114 +    uint64_t    pfn;
 138.115 +    uint64_t    gmfn;
 138.116 +};
 138.117 +
 138.118 +
 138.119 +struct xc_core_strtab;
 138.120 +struct xc_core_section_headers;
 138.121 +
 138.122 +Elf64_Shdr*
 138.123 +xc_core_shdr_get(struct xc_core_section_headers *sheaders);
 138.124 +int
 138.125 +xc_core_shdr_set(Elf64_Shdr *shdr,
 138.126 +                 struct xc_core_strtab *strtab,
 138.127 +                 const char *name, uint32_t type,
 138.128 +                 uint64_t offset, uint64_t size,
 138.129 +                 uint64_t addralign, uint64_t entsize);
 138.130 +
 138.131 +struct xc_core_memory_map {
 138.132 +    uint64_t    addr;
 138.133 +    uint64_t    size;
 138.134 +};
 138.135 +typedef struct xc_core_memory_map xc_core_memory_map_t;
 138.136 +int xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info);
 138.137 +int xc_core_arch_memory_map_get(int xc_handle, xc_dominfo_t *info,
 138.138 +                                shared_info_t *live_shinfo,
 138.139 +                                xc_core_memory_map_t **mapp,
 138.140 +                                unsigned int *nr_entries);
 138.141 +int xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
 138.142 +                         shared_info_t *live_shinfo, xen_pfn_t **live_p2m,
 138.143 +                         unsigned long *pfnp);
 138.144 +
 138.145 +
 138.146 +#if defined (__i386__) || defined (__x86_64__)
 138.147 +# include "xc_core_x86.h"
 138.148 +#elif defined (__ia64__)
 138.149 +# include "xc_core_ia64.h"
 138.150 +#else
 138.151 +# error "unsupported architecture"
 138.152 +#endif
 138.153 +
 138.154 +#ifndef ELF_CORE_EFLAGS
 138.155 +# define ELF_CORE_EFLAGS 0
 138.156 +#endif
 138.157 +
 138.158 +#endif /* XC_CORE_H */
 138.159 +
 138.160 +/*
 138.161 + * Local variables:
 138.162 + * mode: C
 138.163 + * c-set-style: "BSD"
 138.164 + * c-basic-offset: 4
 138.165 + * tab-width: 4
 138.166 + * indent-tabs-mode: nil
 138.167 + * End:
 138.168 + */
   139.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   139.2 +++ b/tools/libxc/xc_core_ia64.c	Wed Mar 07 12:38:28 2007 -0700
   139.3 @@ -0,0 +1,315 @@
   139.4 +/*
   139.5 + * This program is free software; you can redistribute it and/or modify
   139.6 + * it under the terms of the GNU General Public License as published by
   139.7 + * the Free Software Foundation; either version 2 of the License, or
   139.8 + * (at your option) any later version.
   139.9 + *
  139.10 + * This program is distributed in the hope that it will be useful,
  139.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  139.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  139.13 + * GNU General Public License for more details.
  139.14 + *
  139.15 + * You should have received a copy of the GNU General Public License
  139.16 + * along with this program; if not, write to the Free Software
  139.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  139.18 + *
  139.19 + * Copyright (c) 2007 Isaku Yamahata <yamahata at valinux co jp>
  139.20 + *                    VA Linux Systems Japan K.K.
  139.21 + *
  139.22 + */
  139.23 +
  139.24 +#include "xg_private.h"
  139.25 +#include "xc_core.h"
  139.26 +#include "xc_efi.h"
  139.27 +#include "xc_dom.h"
  139.28 +
  139.29 +int
  139.30 +xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info)
  139.31 +{
  139.32 +    /*
  139.33 +     * on ia64, both paravirtualize domain and hvm domain are
  139.34 +     * auto_translated_physmap mode
  139.35 +     */
  139.36 +    return 1;
  139.37 +}
  139.38 +
  139.39 +/* see setup_guest() @ xc_linux_build.c */
  139.40 +static int
  139.41 +memory_map_get_old_domu(int xc_handle, xc_dominfo_t *info,
  139.42 +                        shared_info_t *live_shinfo,
  139.43 +                        xc_core_memory_map_t **mapp, unsigned int *nr_entries)
  139.44 +{
  139.45 +    xc_core_memory_map_t *map = NULL;
  139.46 +
  139.47 +    map = malloc(sizeof(*map));
  139.48 +    if ( map == NULL )
  139.49 +    {
  139.50 +        PERROR("Could not allocate memory");
  139.51 +        goto out;
  139.52 +    }
  139.53 +
  139.54 +    map->addr = 0;
  139.55 +    map->size = info->max_memkb * 1024;
  139.56 +
  139.57 +    *mapp = map;
  139.58 +    *nr_entries = 1;
  139.59 +    return 0;
  139.60 +
  139.61 +out:
  139.62 +    if ( map != NULL )
  139.63 +        free(map);
  139.64 +    return -1;
  139.65 +}
  139.66 +
  139.67 +/* see setup_guest() @ xc_ia64_hvm_build.c */
  139.68 +static int
  139.69 +memory_map_get_old_hvm(int xc_handle, xc_dominfo_t *info, 
  139.70 +                       shared_info_t *live_shinfo,
  139.71 +                       xc_core_memory_map_t **mapp, unsigned int *nr_entries)
  139.72 +{
  139.73 +    const xc_core_memory_map_t gfw_map[] = {
  139.74 +        {IO_PAGE_START, IO_PAGE_SIZE},
  139.75 +        {STORE_PAGE_START, STORE_PAGE_SIZE},
  139.76 +        {BUFFER_IO_PAGE_START, BUFFER_IO_PAGE_SIZE},
  139.77 +        {GFW_START, GFW_SIZE},
  139.78 +    };
  139.79 +    const unsigned int nr_gfw_map = sizeof(gfw_map)/sizeof(gfw_map[0]);
  139.80 +    xc_core_memory_map_t *map = NULL;
  139.81 +    unsigned int i;
  139.82 +    
  139.83 +#define VGA_IO_END      (VGA_IO_START + VGA_IO_SIZE)
  139.84 +    /* [0, VGA_IO_START) [VGA_IO_END, 3GB), [4GB, ...) + gfw_map */
  139.85 +    map = malloc((3 + nr_gfw_map) * sizeof(*map));
  139.86 +    if ( map == NULL )
  139.87 +    {
  139.88 +        PERROR("Could not allocate memory");
  139.89 +        goto out;
  139.90 +    }
  139.91 +
  139.92 +    for ( i = 0; i < nr_gfw_map; i++ )
  139.93 +        map[i] = gfw_map[i];
  139.94 +    map[i].addr = 0;
  139.95 +    map[i].size = info->max_memkb * 1024;
  139.96 +    i++;
  139.97 +    if ( map[i - 1].size < VGA_IO_END )
  139.98 +    {
  139.99 +        map[i - 1].size = VGA_IO_START;
 139.100 +    }
 139.101 +    else
 139.102 +    {
 139.103 +        map[i].addr = VGA_IO_END;
 139.104 +        map[i].size = map[i - 1].size - VGA_IO_END;
 139.105 +        map[i - 1].size = VGA_IO_START;
 139.106 +        i++;
 139.107 +        if ( map[i - 1].addr + map[i - 1].size > MMIO_START )
 139.108 +        {
 139.109 +            map[i].addr = MMIO_START + 1 * MEM_G;
 139.110 +            map[i].size = map[i - 1].addr + map[i - 1].size - MMIO_START;
 139.111 +            map[i - 1].size = MMIO_START - map[i - 1].addr;
 139.112 +            i++;
 139.113 +        }
 139.114 +    }
 139.115 +    *mapp = map;
 139.116 +    *nr_entries = i;
 139.117 +    return 0;
 139.118 +
 139.119 +out:
 139.120 +    if ( map != NULL )
 139.121 +        free(map);
 139.122 +    return -1;
 139.123 +}
 139.124 +
 139.125 +static int
 139.126 +memory_map_get_old(int xc_handle, xc_dominfo_t *info, 
 139.127 +                   shared_info_t *live_shinfo,
 139.128 +                   xc_core_memory_map_t **mapp, unsigned int *nr_entries)
 139.129 +{
 139.130 +    if ( info->hvm )
 139.131 +        return memory_map_get_old_hvm(xc_handle, info, live_shinfo,
 139.132 +                                      mapp, nr_entries);
 139.133 +    if ( live_shinfo == NULL )
 139.134 +        return -1;
 139.135 +    return memory_map_get_old_domu(xc_handle, info, live_shinfo,
 139.136 +                                   mapp, nr_entries);
 139.137 +}
 139.138 +
 139.139 +int
 139.140 +xc_core_arch_memory_map_get(int xc_handle, xc_dominfo_t *info,
 139.141 +                            shared_info_t *live_shinfo,
 139.142 +                            xc_core_memory_map_t **mapp,
 139.143 +                            unsigned int *nr_entries)
 139.144 +{