[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] merge with xen-unstable.hg



# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID c4ea8d4d2ae1913fb66dc61a5ec78e6dcd101262
# Parent  3e0685ecfe644253d64ab12e83acd81845c4b37d
# Parent  5b9ff5e8653aa37d812a26526440fc4976e10b7a
merge with xen-unstable.hg
---
 tools/debugger/libxendebug/Makefile                                   |   74 -
 tools/debugger/libxendebug/list.h                                     |  186 --
 tools/debugger/libxendebug/xendebug.c                                 |  599 
--------
 tools/debugger/libxendebug/xendebug.h                                 |   78 -
 tools/libxc/xc_bvtsched.c                                             |   92 -
 tools/misc/cpuperf/Makefile                                           |   51 
 tools/misc/cpuperf/README.txt                                         |  371 
-----
 tools/misc/cpuperf/cpuperf.c                                          |  296 
----
 tools/misc/cpuperf/cpuperf_perfcntr.h                                 |   41 
 tools/misc/cpuperf/cpuperf_xeno.h                                     |   38 
 tools/misc/cpuperf/module/Makefile                                    |   16 
 tools/misc/cpuperf/module/perfcntr.c                                  |  730 
---------
 tools/misc/cpuperf/p4perf.h                                           |  382 
-----
 xen/arch/x86/dom0_ops.c                                               |  486 
------
 xen/common/dom0_ops.c                                                 |  739 
----------
 xen/common/sched_bvt.c                                                |  588 
-------
 xen/include/public/sched_ctl.h                                        |   69 
 .hgignore                                                             |    1 
 docs/man/xm.pod.1                                                     |   55 
 docs/misc/xend.tex                                                    |    8 
 docs/src/interface.tex                                                |    4 
 docs/src/user.tex                                                     |    5 
 linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S                      |   28 
 linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S                    |   23 
 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c                    |   23 
 patches/linux-2.6.16.13/series                                        |    1 
 patches/linux-2.6.16.13/x86-elfnote-as-preprocessor-macro.patch       |   26 
 tools/blktap/lib/xs_api.c                                             |    6 
 tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c |    9 
 tools/examples/xen-backend.rules                                      |    1 
 tools/firmware/acpi/acpi_dsdt.asl                                     |   45 
 tools/firmware/acpi/acpi_dsdt.c                                       |  480 
+++---
 tools/libxc/Makefile                                                  |    1 
 tools/libxc/ia64/xc_ia64_hvm_build.c                                  |   41 
 tools/libxc/ia64/xc_ia64_linux_restore.c                              |   46 
 tools/libxc/ia64/xc_ia64_linux_save.c                                 |   24 
 tools/libxc/ia64/xc_ia64_stubs.c                                      |   24 
 tools/libxc/powerpc64/xc_linux_build.c                                |    1 
 tools/libxc/xc_csched.c                                               |   32 
 tools/libxc/xc_domain.c                                               |  364 
++--
 tools/libxc/xc_hvm_build.c                                            |   36 
 tools/libxc/xc_linux_build.c                                          |   90 -
 tools/libxc/xc_linux_restore.c                                        |  122 -
 tools/libxc/xc_linux_save.c                                           |   77 -
 tools/libxc/xc_load_bin.c                                             |    2 
 tools/libxc/xc_load_elf.c                                             |  339 
+++-
 tools/libxc/xc_misc.c                                                 |   82 -
 tools/libxc/xc_private.c                                              |   75 -
 tools/libxc/xc_private.h                                              |   53 
 tools/libxc/xc_ptrace.c                                               |   85 -
 tools/libxc/xc_sedf.c                                                 |   47 
 tools/libxc/xc_tbuf.c                                                 |   88 -
 tools/libxc/xenctrl.h                                                 |   59 
 tools/libxc/xg_private.h                                              |   37 
 tools/misc/Makefile                                                   |    3 
 tools/misc/xenperf.c                                                  |    6 
 tools/python/xen/lowlevel/xc/xc.c                                     |  134 -
 tools/python/xen/xend/XendDomain.py                                   |   28 
 tools/python/xen/xend/XendNode.py                                     |    6 
 tools/python/xen/xend/server/SrvDomain.py                             |   12 
 tools/python/xen/xend/server/SrvNode.py                               |    6 
 tools/python/xen/xend/server/XMLRPCServer.py                          |    2 
 tools/python/xen/xm/main.py                                           |   20 
 tools/tests/test_x86_emulator.c                                       |   14 
 tools/xcutils/Makefile                                                |    2 
 tools/xcutils/readnotes.c                                             |  326 
++++
 tools/xenmon/setmask.c                                                |   35 
 tools/xenstat/libxenstat/src/xenstat.c                                |    6 
 xen/acm/acm_simple_type_enforcement_hooks.c                           |    2 
 xen/arch/ia64/tools/xelilo/elilo.README                               |    2 
 xen/arch/ia64/xen/dom0_ops.c                                          |  239 
+--
 xen/arch/ia64/xen/domain.c                                            |   14 
 xen/arch/ia64/xen/hypercall.c                                         |    9 
 xen/arch/powerpc/dom0_ops.c                                           |   44 
 xen/arch/powerpc/domain_build.c                                       |    4 
 xen/arch/powerpc/powerpc64/hypercall_table.S                          |   45 
 xen/arch/x86/Makefile                                                 |    4 
 xen/arch/x86/domain_build.c                                           |   42 
 xen/arch/x86/domctl.c                                                 |  326 
++++
 xen/arch/x86/mm.c                                                     |    1 
 xen/arch/x86/platform_hypercall.c                                     |  159 ++
 xen/arch/x86/setup.c                                                  |   11 
 xen/arch/x86/shadow2-common.c                                         |   39 
 xen/arch/x86/shadow2.c                                                |   10 
 xen/arch/x86/sysctl.c                                                 |   77 +
 xen/arch/x86/traps.c                                                  |   16 
 xen/arch/x86/x86_32/entry.S                                           |   12 
 xen/arch/x86/x86_64/entry.S                                           |    8 
 xen/arch/x86/x86_emulate.c                                            |   30 
 xen/common/Makefile                                                   |    4 
 xen/common/acm_ops.c                                                  |    1 
 xen/common/domain.c                                                   |    8 
 xen/common/domctl.c                                                   |  681 
+++++++++
 xen/common/elf.c                                                      |  365 
++++
 xen/common/multicall.c                                                |    1 
 xen/common/perfc.c                                                    |   10 
 xen/common/sched_credit.c                                             |   30 
 xen/common/sched_sedf.c                                               |   69 
 xen/common/schedule.c                                                 |   33 
 xen/common/sysctl.c                                                   |  152 ++
 xen/common/trace.c                                                    |   41 
 xen/include/acm/acm_hooks.h                                           |   38 
 xen/include/asm-ia64/domain.h                                         |    2 
 xen/include/asm-x86/perfc_defn.h                                      |  118 -
 xen/include/asm-x86/processor.h                                       |   10 
 xen/include/asm-x86/shadow2-types.h                                   |   13 
 xen/include/asm-x86/shadow2.h                                         |   16 
 xen/include/public/acm.h                                              |    1 
 xen/include/public/acm_ops.h                                          |    1 
 xen/include/public/arch-ia64.h                                        |    3 
 xen/include/public/arch-powerpc.h                                     |    3 
 xen/include/public/arch-x86_32.h                                      |   18 
 xen/include/public/arch-x86_64.h                                      |    3 
 xen/include/public/dom0_ops.h                                         |  612 
--------
 xen/include/public/domctl.h                                           |  393 
+++++
 xen/include/public/elfnote.h                                          |  133 +
 xen/include/public/platform.h                                         |  125 +
 xen/include/public/sysctl.h                                           |  155 ++
 xen/include/public/xen-compat.h                                       |    2 
 xen/include/public/xen.h                                              |   16 
 xen/include/xen/cpumask.h                                             |    7 
 xen/include/xen/elf.h                                                 |    4 
 xen/include/xen/hypercall.h                                           |   16 
 xen/include/xen/perfc_defn.h                                          |    1 
 xen/include/xen/sched-if.h                                            |    5 
 xen/include/xen/sched.h                                               |   22 
 xen/include/xen/trace.h                                               |    6 
 127 files changed, 4703 insertions(+), 7385 deletions(-)

diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 .hgignore
--- a/.hgignore Fri Aug 25 16:21:39 2006 -0600
+++ b/.hgignore Sun Aug 27 10:24:41 2006 -0600
@@ -151,6 +151,7 @@
 ^tools/vtpm_manager/manager/vtpm_managerd$
 ^tools/xcutils/xc_restore$
 ^tools/xcutils/xc_save$
+^tools/xcutils/readnotes$
 ^tools/xenmon/xentrace_setmask$
 ^tools/xenmon/xenbaked$
 ^tools/xenstat/xentop/xentop$
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 docs/man/xm.pod.1
--- a/docs/man/xm.pod.1 Fri Aug 25 16:21:39 2006 -0600
+++ b/docs/man/xm.pod.1 Sun Aug 27 10:24:41 2006 -0600
@@ -511,55 +511,6 @@ FIXME: we really need a scheduler expert
 
 =over 4
 
-=item B<sched-bvt> I<mcuadv> I<warpback> I<warpvalue> I<warpl> I<warpu>
-
-Performs runtime adjustments to the default parameters for the
-Borrowed Virtual Time (BVT) scheduler.  For full information on the
-BVT concept, please consult the base paper listed in the B<SEE ALSO>
-section.
-
-Set Borrowed Virtual Time (BVT) scheduler parameters. There are five
-required parameters, which are given in order below.
-
-FIXME: what units are all the BVT params in?
-
-B<PARAMETERS>
-
-=over 4
-
-=item I<mcuadv>
-
-The MCU (Minimum Charging Unit) advance determines the proportional
-share of the CPU that a domain receives. It is set inversely
-proportionally to a domain's sharing weight.
-
-=item I<warpback>
-
-The amount of `virtual time' the domain is allowed to warp backwards.
-
-=item I<warpvalue>
-
-Warp value (FIXME: what does this really mean?)
-
-=item I<warpl>
-
-The warp limit is the maximum time a domain can run warped for.
-
-=item I<warpu>
-
-The unwarp requirement is the minimum time a domain must run unwarped
-for before it can warp again.
-
-=back 
-
-=item B<sched-bvt-ctxallow> I<allow>
-
-Sets the BVT scheduler's context switch allowance. 
-
-The context switch allowance is similar to the ``quantum'' in
-traditional schedulers. It is the minimum time that a scheduled domain
-will be allowed to run before being preempted.
-
 =item B<sched-sedf> I<period> I<slice> I<latency-hint> I<extratime> I<weight>
 
 Set Simple EDF (Earliest Deadline First) scheduler parameters.  This
@@ -1126,12 +1077,6 @@ their binary identifiers (ssidrefs) used
 
 B<xmdomain.cfg>(5), B<xentop>(1)
 
-BVT scheduling paper: K.J. Duda and D.R. Cheriton. Borrowed Virtual
-Time (BVT) scheduling: supporting latency-sensitive threads in a
-general purpose scheduler. In proceedings of the 17th ACM SIGOPS
-Symposium on Operating Systems principles, volume 33(5) of ACM
-Operating Systems Review, pages 261-267
-
 =head1 AUTHOR
 
   Sean Dague <sean at dague dot net>
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 docs/misc/xend.tex
--- a/docs/misc/xend.tex        Fri Aug 25 16:21:39 2006 -0600
+++ b/docs/misc/xend.tex        Sun Aug 27 10:24:41 2006 -0600
@@ -337,14 +337,6 @@ Python client interface in {\tt xen.xend
   {\tt xend\_domain\_pincpu(self, id, cpu)}\\:
   Pin a domain to a cpu.
 
-\item {\tt POST /domain/[dom] bvt\_set(mcuadv, warp, warpl, warpu)},\\
-  {\tt xend\_domain\_cpu\_bvt\_set(dom, mcuadv, warp, warpl, warpu)}:\\
-  Set BVT scheduler parameters.
-
-\item {\tt POST /domain/[dom] atropos\_set(period, slice, latency, 
xtratime)},\\
-  {\tt xend\_domain\_cpu\_atropos\_set(dom, period, slice, latency, 
xtratime)}:\\
-  Set atropos scheduler parameters.
-
 \item {\tt POST /domain/[dom] maxmem\_set(memory)},\\
   {\tt xend\_domain\_maxmem\_set(dom, memory)}:\\
   Set domain maximum memory limit.
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 docs/src/interface.tex
--- a/docs/src/interface.tex    Fri Aug 25 16:21:39 2006 -0600
+++ b/docs/src/interface.tex    Sun Aug 27 10:24:41 2006 -0600
@@ -209,8 +209,8 @@ implement timeout values when they block
 
 Xen offers a uniform API for CPU schedulers.  It is possible to choose
 from a number of schedulers at boot and it should be easy to add more.
-The SEDF, BVT, and Credit schedulers are part of the normal Xen
-distribution.  BVT and SEDF will be going away and their use should be
+The SEDF and Credit schedulers are part of the normal Xen
+distribution.  SEDF will be going away and its use should be
 avoided once the credit scheduler has stabilized and become the default.
 The Credit scheduler provides proportional fair shares of the
 host's CPUs to the running domains. It does this while transparently
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 docs/src/user.tex
--- a/docs/src/user.tex Fri Aug 25 16:21:39 2006 -0600
+++ b/docs/src/user.tex Sun Aug 27 10:24:41 2006 -0600
@@ -3179,7 +3179,7 @@ editing \path{grub.conf}.
 \item [ tbuf\_size=xxx ] Set the size of the per-cpu trace buffers, in
   pages (default 0).  
 \item [ sched=xxx ] Select the CPU scheduler Xen should use.  The
-  current possibilities are `credit' (default), `sedf', and `bvt'.
+  current possibilities are `credit' (default), and `sedf'.
 \item [ apic\_verbosity=debug,verbose ] Print more detailed
   information about local APIC and IOAPIC configuration.
 \item [ lapic ] Force use of local APIC even when left disabled by
@@ -4135,9 +4135,6 @@ as it will forward multicasts received f
 
 \begin{description}
 
-\item[BVT] The BVT scheduler is used to give proportional fair shares
-  of the CPU to domains.
-
 \item[Domain] A domain is the execution context that contains a
   running {\bf virtual machine}.  The relationship between virtual
   machines and domains on Xen is similar to that between programs and
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S  Fri Aug 25 16:21:39 
2006 -0600
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S  Sun Aug 27 10:24:41 
2006 -0600
@@ -2,6 +2,7 @@
 
 .text
 #include <linux/config.h>
+#include <linux/elfnote.h>
 #include <linux/threads.h>
 #include <linux/linkage.h>
 #include <asm/segment.h>
@@ -9,6 +10,7 @@
 #include <asm/thread_info.h>
 #include <asm/asm-offsets.h>
 #include <xen/interface/arch-x86_32.h>
+#include <xen/interface/elfnote.h>
 
 /*
  * References to members of the new_cpu_data structure.
@@ -138,6 +140,7 @@ ENTRY(cpu_gdt_table)
        .quad 0x0000000000000000        /* 0xf0 - unused */
        .quad 0x0000000000000000        /* 0xf8 - GDT entry 31: double-fault 
TSS */
 
+#ifdef CONFIG_XEN_COMPAT_030002
 /*
  * __xen_guest information
  */
@@ -157,12 +160,8 @@ ENTRY(cpu_gdt_table)
        .ascii  ",XEN_VER=xen-3.0"
        .ascii  ",VIRT_BASE=0x"
                utoa __PAGE_OFFSET
-#ifdef CONFIG_XEN_COMPAT_030002
        .ascii  ",ELF_PADDR_OFFSET=0x"
                utoa __PAGE_OFFSET
-#else
-       .ascii  ",ELF_PADDR_OFFSET=0x0"
-#endif /* !CONFIG_XEN_COMPAT_030002 */
        .ascii  ",VIRT_ENTRY=0x"
                utoa (__PAGE_OFFSET + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
        .ascii  ",HYPERCALL_PAGE=0x"
@@ -179,3 +178,24 @@ ENTRY(cpu_gdt_table)
 #endif
        .ascii  ",LOADER=generic"
        .byte   0
+#endif /* CONFIG_XEN_COMPAT_030002 */
+
+
+       ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz, "linux")       
+       ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz, "2.6")
+       ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz, "xen-3.0")
+       ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .long,  __PAGE_OFFSET)
+#ifdef CONFIG_XEN_COMPAT_030002
+       ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .long,  __PAGE_OFFSET)
+#else
+       ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .long,  0)
+#endif /* !CONFIG_XEN_COMPAT_030002 */
+       ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .long,  startup_32)
+       ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long,  hypercall_page)
+       ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, 
"writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
+#ifdef CONFIG_X86_PAE
+       ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz, "yes")
+#else
+       ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz, "no")
+#endif
+       ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz, "generic")
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S        Fri Aug 25 
16:21:39 2006 -0600
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S        Sun Aug 27 
10:24:41 2006 -0600
@@ -16,11 +16,14 @@
 #include <linux/linkage.h>
 #include <linux/threads.h>
 #include <linux/init.h>
+#include <linux/elfnote.h>
 #include <asm/desc.h>
 #include <asm/segment.h>
 #include <asm/page.h>
 #include <asm/msr.h>
 #include <asm/cache.h>
+
+#include <xen/interface/elfnote.h>
 
        .text
        .code64
@@ -131,6 +134,7 @@ gdt_end:
        /* zero the remaining page */
        .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
 
+#ifdef CONFIG_XEN_COMPAT_030002
 /*
  * __xen_guest information
  */
@@ -150,12 +154,8 @@ gdt_end:
        .ascii  ",XEN_VER=xen-3.0"
        .ascii  ",VIRT_BASE=0x"
                utoh __START_KERNEL_map
-#ifdef CONFIG_XEN_COMPAT_030002
        .ascii  ",ELF_PADDR_OFFSET=0x"
                utoh __START_KERNEL_map
-#else
-       .ascii  ",ELF_PADDR_OFFSET=0x0"
-#endif /* !CONFIG_XEN_COMPAT_030002 */
        .ascii  ",VIRT_ENTRY=0x"
                utoh (__START_KERNEL_map + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
        .ascii  ",HYPERCALL_PAGE=0x"
@@ -166,3 +166,18 @@ gdt_end:
        .ascii           "|supervisor_mode_kernel"
        .ascii  ",LOADER=generic"
        .byte   0
+#endif /* CONFIG_XEN_COMPAT_030002 */
+       
+       ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz, "linux")
+       ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz, "2.6")
+       ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz, "xen-3.0")
+       ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .quad,  __START_KERNEL_map)
+#ifdef CONFIG_XEN_COMPAT_030002
+       ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .quad,  __START_KERNEL_map)
+#else
+       ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .quad,  0)
+#endif /* !CONFIG_XEN_COMPAT_030002 */
+       ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad,  startup_64)
+       ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad,  hypercall_page)
+       ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, 
"writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
+       ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz, "generic")
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c        Fri Aug 25 
16:21:39 2006 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c        Sun Aug 27 
10:24:41 2006 -0600
@@ -35,9 +35,6 @@ static struct proc_dir_entry *privcmd_in
 static struct proc_dir_entry *privcmd_intf;
 static struct proc_dir_entry *capabilities_intf;
 
-#define NR_HYPERCALLS 64
-static DECLARE_BITMAP(hypercall_permission_map, NR_HYPERCALLS);
-
 static int privcmd_ioctl(struct inode *inode, struct file *file,
                         unsigned int cmd, unsigned long data)
 {
@@ -50,12 +47,6 @@ static int privcmd_ioctl(struct inode *i
   
                if (copy_from_user(&hypercall, udata, sizeof(hypercall)))
                        return -EFAULT;
-
-               /* Check hypercall number for validity. */
-               if (hypercall.op >= NR_HYPERCALLS)
-                       return -EINVAL;
-               if (!test_bit(hypercall.op, hypercall_permission_map))
-                       return -EINVAL;
 
 #if defined(__i386__)
                __asm__ __volatile__ (
@@ -262,20 +253,6 @@ static int __init privcmd_init(void)
        if (!is_running_on_xen())
                return -ENODEV;
 
-       /* Set of hypercalls that privileged applications may execute. */
-       set_bit(__HYPERVISOR_acm_op,           hypercall_permission_map);
-       set_bit(__HYPERVISOR_dom0_op,          hypercall_permission_map);
-       set_bit(__HYPERVISOR_event_channel_op, hypercall_permission_map);
-       set_bit(__HYPERVISOR_memory_op,        hypercall_permission_map);
-       set_bit(__HYPERVISOR_mmu_update,       hypercall_permission_map);
-       set_bit(__HYPERVISOR_mmuext_op,        hypercall_permission_map);
-       set_bit(__HYPERVISOR_xen_version,      hypercall_permission_map);
-       set_bit(__HYPERVISOR_sched_op,         hypercall_permission_map);
-       set_bit(__HYPERVISOR_sched_op_compat,  hypercall_permission_map);
-       set_bit(__HYPERVISOR_event_channel_op_compat,
-               hypercall_permission_map);
-       set_bit(__HYPERVISOR_hvm_op,           hypercall_permission_map);
-
        privcmd_intf = create_xen_proc_entry("privcmd", 0400);
        if (privcmd_intf != NULL)
                privcmd_intf->proc_fops = &privcmd_file_ops;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 patches/linux-2.6.16.13/series
--- a/patches/linux-2.6.16.13/series    Fri Aug 25 16:21:39 2006 -0600
+++ b/patches/linux-2.6.16.13/series    Sun Aug 27 10:24:41 2006 -0600
@@ -20,3 +20,4 @@ xenoprof-generic.patch
 xenoprof-generic.patch
 x86-put-note-sections-into-a-pt_note-segment-in-vmlinux.patch
 x86_64-put-note-sections-into-a-pt_note-segment-in-vmlinux.patch
+x86-elfnote-as-preprocessor-macro.patch
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/blktap/lib/xs_api.c
--- a/tools/blktap/lib/xs_api.c Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/blktap/lib/xs_api.c Sun Aug 27 10:24:41 2006 -0600
@@ -180,8 +180,7 @@ char *get_dom_domid(struct xs_handle *h,
        
        e = xs_directory(h, xth, "/local/domain", &num);
        
-       i = 0;
-       while (i < num) {
+       for (i = 0; (i < num) && (domid == NULL); i++) {
                asprintf(&path, "/local/domain/%s/name", e[i]);
                val = xs_read(h, xth, path, &len);
                free(path);
@@ -192,12 +191,9 @@ char *get_dom_domid(struct xs_handle *h,
                        /* match! */
                        asprintf(&path, "/local/domain/%s/domid", e[i]);
                        domid = xs_read(h, xth, path, &len);
-                       free(val);
                        free(path);
-                       break;
                }
                free(val);
-               i++;
        }
        xs_transaction_end(h, xth, 0);
        
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
--- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c     
Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c     
Sun Aug 27 10:24:41 2006 -0600
@@ -53,15 +53,6 @@ curvcpuid()
   return (process->thread_known ? process->tid : 0);
 
 }
-
-
-#define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
-#define DOMFLAGS_SHUTDOWN  (1<<2) /* The guest OS has shut down.             */
-#define DOMFLAGS_PAUSED    (1<<3) /* Currently paused by control software.   */
-#define DOMFLAGS_BLOCKED   (1<<4) /* Currently blocked pending an event.     */
-#define DOMFLAGS_RUNNING   (1<<5) /* Domain is currently running.            */
-
-
 
 struct inferior_list all_processes;
 static int current_domid;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/examples/xen-backend.rules
--- a/tools/examples/xen-backend.rules  Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/examples/xen-backend.rules  Sun Aug 27 10:24:41 2006 -0600
@@ -4,3 +4,4 @@ SUBSYSTEM=="xen-backend", KERNEL=="vif*"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} 
online"
 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", 
RUN+="$env{script} offline"
 SUBSYSTEM=="xen-backend", ACTION=="remove", 
RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
+KERNEL=="evtchn", NAME="xen/%k"
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/firmware/acpi/acpi_dsdt.asl
--- a/tools/firmware/acpi/acpi_dsdt.asl Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/firmware/acpi/acpi_dsdt.asl Sun Aug 27 10:24:41 2006 -0600
@@ -111,31 +111,9 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
                     WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, 
EntireRange,
                         0x0000,
                         0x0D00,
-                        0x0FFF,
-                        0x0000,
-                        0x0300)
-
-                 /* reserve what device model consumed for IDE and acpi pci 
device            */
-                     WordIO (ResourceConsumer, MinFixed, MaxFixed, PosDecode, 
EntireRange,
-                        0x0000,
-                        0xc000,
-                        0xc01f,
-                        0x0000,
-                        0x0020)
-                 /* reserve what device model consumed for Ethernet controller 
pci device        */
-                     WordIO (ResourceConsumer, MinFixed, MaxFixed, PosDecode, 
EntireRange,
-                        0x0000,
-                        0xc020,
-                        0xc03f,
-                        0x0000,
-                        0x0010)
-
-                    DWordMemory (ResourceProducer, PosDecode, MinFixed, 
MaxFixed, Cacheable, ReadOnly,
-                        0x00000000,
-                        0x000c0000,
-                        0x000FFFFF,
-                        0x00000000,
-                        0x00030000)
+                        0xFFFF,
+                        0x0000,
+                        0xF300)
 
                 /* reserve what device model consumed for PCI VGA device       
 */
 
@@ -151,13 +129,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
                         0xF2000FFF,
                         0x00000000,
                         0x00001000)
-                 /* reserve what device model consumed for Ethernet controller 
pci device        */
-                      DWordMemory (ResourceConsumer, PosDecode, MinFixed, 
MaxFixed, Cacheable, ReadWrite,
-                        0x00000000,
-                        0xF2001000,
-                        0xF200101F,
-                        0x00000000,
-                        0x00000020) 
                 })
                 Return (PRT0)
             }
@@ -528,9 +499,9 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
                     })
                 }
 
-                Device (UAR2)
-                {
-                    Name (_HID, EisaId ("PNP0501"))
+                Device (LTP1)
+                {
+                    Name (_HID, EisaId ("PNP0400"))
                     Name (_UID, 0x02)
                     Method (_STA, 0, NotSerialized)
                     {
@@ -539,8 +510,8 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
 
                     Name (_CRS, ResourceTemplate()
                     {
-                        IO (Decode16, 0x02F8, 0x02F8, 0x01, 0x08)
-                        IRQNoFlags () {3}
+                        IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
+                        IRQNoFlags () {7}
                     })
                 } 
             }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/firmware/acpi/acpi_dsdt.c
--- a/tools/firmware/acpi/acpi_dsdt.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/firmware/acpi/acpi_dsdt.c   Sun Aug 27 10:24:41 2006 -0600
@@ -5,15 +5,15 @@
  * Copyright (C) 2000 - 2005 Intel Corporation
  * Supports ACPI Specification Revision 3.0
  * 
- * Compilation of "acpi_dsdt.asl" - Thu Aug  3 11:05:15 2006
+ * Compilation of "acpi_dsdt.asl" - Mon Aug 14 18:15:09 2006
  * 
  * C source code output
  *
  */
 unsigned char AmlCode[] = 
 {
-    0x44,0x53,0x44,0x54,0x0E,0x09,0x00,0x00,  /* 00000000    "DSDT...." */
-    0x01,0x03,0x49,0x4E,0x54,0x45,0x4C,0x00,  /* 00000008    "..INTEL." */
+    0x44,0x53,0x44,0x54,0xBA,0x08,0x00,0x00,  /* 00000000    "DSDT...." */
+    0x01,0x1D,0x49,0x4E,0x54,0x45,0x4C,0x00,  /* 00000008    "..INTEL." */
     0x69,0x6E,0x74,0x2D,0x78,0x65,0x6E,0x00,  /* 00000010    "int-xen." */
     0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
     0x13,0x05,0x05,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
@@ -34,7 +34,7 @@ unsigned char AmlCode[] =
     0x12,0x08,0x04,0x0A,0x07,0x0A,0x07,0x00,  /* 00000098    "........" */
     0x00,0x08,0x50,0x49,0x43,0x44,0x00,0x14,  /* 000000A0    "..PICD.." */
     0x0C,0x5F,0x50,0x49,0x43,0x01,0x70,0x68,  /* 000000A8    "._PIC.ph" */
-    0x50,0x49,0x43,0x44,0x10,0x49,0x85,0x5F,  /* 000000B0    "PICD.I._" */
+    0x50,0x49,0x43,0x44,0x10,0x45,0x80,0x5F,  /* 000000B0    "PICD.E._" */
     0x53,0x42,0x5F,0x5B,0x82,0x49,0x04,0x4D,  /* 000000B8    "SB_[.I.M" */
     0x45,0x4D,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 000000C0    "EM0._HID" */
     0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x43,  /* 000000C8    ".A...._C" */
@@ -45,7 +45,7 @@ unsigned char AmlCode[] =
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000F0    "........" */
     0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,  /* 000000F8    "........" */
     0x00,0x00,0x00,0x00,0x79,0x00,0x5B,0x82,  /* 00000100    "....y.[." */
-    0x46,0x80,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "F.PCI0._" */
+    0x42,0x7B,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "B{PCI0._" */
     0x48,0x49,0x44,0x0C,0x41,0xD0,0x0A,0x03,  /* 00000110    "HID.A..." */
     0x08,0x5F,0x55,0x49,0x44,0x00,0x08,0x5F,  /* 00000118    "._UID.._" */
     0x41,0x44,0x52,0x00,0x08,0x5F,0x42,0x42,  /* 00000120    "ADR.._BB" */
@@ -55,252 +55,242 @@ unsigned char AmlCode[] =
     0x33,0x03,0x49,0x52,0x51,0x35,0x05,0x49,  /* 00000140    "3.IRQ5.I" */
     0x52,0x51,0x37,0x07,0x49,0x52,0x51,0x39,  /* 00000148    "RQ7.IRQ9" */
     0x09,0x49,0x52,0x51,0x41,0x0A,0x49,0x52,  /* 00000150    ".IRQA.IR" */
-    0x51,0x42,0x0B,0x14,0x48,0x0D,0x5F,0x43,  /* 00000158    "QB..H._C" */
+    0x51,0x42,0x0B,0x14,0x44,0x08,0x5F,0x43,  /* 00000158    "QB..D._C" */
     0x52,0x53,0x00,0x08,0x50,0x52,0x54,0x30,  /* 00000160    "RS..PRT0" */
-    0x11,0x46,0x0C,0x0A,0xC2,0x88,0x0D,0x00,  /* 00000168    ".F......" */
+    0x11,0x42,0x07,0x0A,0x6E,0x88,0x0D,0x00,  /* 00000168    ".B..n..." */
     0x02,0x0F,0x00,0x00,0x00,0x00,0x00,0xFF,  /* 00000170    "........" */
     0x00,0x00,0x00,0x00,0x01,0x47,0x01,0xF8,  /* 00000178    ".....G.." */
     0x0C,0xF8,0x0C,0x01,0x08,0x88,0x0D,0x00,  /* 00000180    "........" */
     0x01,0x0C,0x03,0x00,0x00,0x00,0x00,0xF7,  /* 00000188    "........" */
     0x0C,0x00,0x00,0xF8,0x0C,0x88,0x0D,0x00,  /* 00000190    "........" */
     0x01,0x0C,0x03,0x00,0x00,0x00,0x0D,0xFF,  /* 00000198    "........" */
-    0x0F,0x00,0x00,0x00,0x03,0x88,0x0D,0x00,  /* 000001A0    "........" */
-    0x01,0x0D,0x03,0x00,0x00,0x00,0xC0,0x1F,  /* 000001A8    "........" */
-    0xC0,0x00,0x00,0x20,0x00,0x88,0x0D,0x00,  /* 000001B0    "... ...." */
-    0x01,0x0D,0x03,0x00,0x00,0x20,0xC0,0x3F,  /* 000001B8    "..... .?" */
-    0xC0,0x00,0x00,0x10,0x00,0x87,0x17,0x00,  /* 000001C0    "........" */
-    0x00,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,  /* 000001C8    "........" */
-    0x00,0x0C,0x00,0xFF,0xFF,0x0F,0x00,0x00,  /* 000001D0    "........" */
-    0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x87,  /* 000001D8    "........" */
-    0x17,0x00,0x00,0x0D,0x03,0x00,0x00,0x00,  /* 000001E0    "........" */
-    0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0xFF,  /* 000001E8    "........" */
-    0xF1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000001F0    "........" */
-    0x02,0x87,0x17,0x00,0x00,0x0D,0x03,0x00,  /* 000001F8    "........" */
-    0x00,0x00,0x00,0x00,0x00,0x00,0xF2,0xFF,  /* 00000200    "........" */
-    0x0F,0x00,0xF2,0x00,0x00,0x00,0x00,0x00,  /* 00000208    "........" */
-    0x10,0x00,0x00,0x87,0x17,0x00,0x00,0x0D,  /* 00000210    "........" */
-    0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,  /* 00000218    "........" */
-    0xF2,0x1F,0x10,0x00,0xF2,0x00,0x00,0x00,  /* 00000220    "........" */
-    0x00,0x20,0x00,0x00,0x00,0x79,0x00,0xA4,  /* 00000228    ". ...y.." */
-    0x50,0x52,0x54,0x30,0x08,0x42,0x55,0x46,  /* 00000230    "PRT0.BUF" */
-    0x41,0x11,0x09,0x0A,0x06,0x23,0xF8,0xDC,  /* 00000238    "A....#.." */
-    0x18,0x79,0x00,0x08,0x42,0x55,0x46,0x42,  /* 00000240    ".y..BUFB" */
-    0x11,0x09,0x0A,0x06,0x23,0x00,0x00,0x18,  /* 00000248    "....#..." */
-    0x79,0x00,0x8B,0x42,0x55,0x46,0x42,0x01,  /* 00000250    "y..BUFB." */
-    0x49,0x52,0x51,0x56,0x08,0x42,0x55,0x46,  /* 00000258    "IRQV.BUF" */
-    0x43,0x11,0x07,0x0A,0x04,0x05,0x07,0x0A,  /* 00000260    "C......." */
-    0x0B,0x8C,0x42,0x55,0x46,0x43,0x01,0x50,  /* 00000268    "..BUFC.P" */
-    0x49,0x51,0x41,0x8C,0x42,0x55,0x46,0x43,  /* 00000270    "IQA.BUFC" */
-    0x01,0x50,0x49,0x51,0x42,0x8C,0x42,0x55,  /* 00000278    ".PIQB.BU" */
-    0x46,0x43,0x01,0x50,0x49,0x51,0x43,0x8C,  /* 00000280    "FC.PIQC." */
-    0x42,0x55,0x46,0x43,0x01,0x50,0x49,0x51,  /* 00000288    "BUFC.PIQ" */
-    0x44,0x5B,0x82,0x48,0x08,0x4C,0x4E,0x4B,  /* 00000290    "D[.H.LNK" */
-    0x41,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000298    "A._HID.A" */
-    0xD0,0x0C,0x0F,0x08,0x5F,0x55,0x49,0x44,  /* 000002A0    "...._UID" */
-    0x01,0x14,0x1C,0x5F,0x53,0x54,0x41,0x00,  /* 000002A8    "..._STA." */
-    0x7B,0x50,0x49,0x52,0x41,0x0A,0x80,0x60,  /* 000002B0    "{PIRA..`" */
-    0xA0,0x08,0x93,0x60,0x0A,0x80,0xA4,0x0A,  /* 000002B8    "...`...." */
-    0x09,0xA1,0x04,0xA4,0x0A,0x0B,0x14,0x0B,  /* 000002C0    "........" */
-    0x5F,0x50,0x52,0x53,0x00,0xA4,0x42,0x55,  /* 000002C8    "_PRS..BU" */
-    0x46,0x41,0x14,0x11,0x5F,0x44,0x49,0x53,  /* 000002D0    "FA.._DIS" */
-    0x00,0x7D,0x50,0x49,0x52,0x41,0x0A,0x80,  /* 000002D8    ".}PIRA.." */
-    0x50,0x49,0x52,0x41,0x14,0x1A,0x5F,0x43,  /* 000002E0    "PIRA.._C" */
-    0x52,0x53,0x00,0x7B,0x50,0x49,0x52,0x42,  /* 000002E8    "RS.{PIRB" */
-    0x0A,0x0F,0x60,0x79,0x01,0x60,0x49,0x52,  /* 000002F0    "..`y.`IR" */
-    0x51,0x56,0xA4,0x42,0x55,0x46,0x42,0x14,  /* 000002F8    "QV.BUFB." */
-    0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,  /* 00000300    "._SRS..h" */
-    0x01,0x49,0x52,0x51,0x31,0x82,0x49,0x52,  /* 00000308    ".IRQ1.IR" */
-    0x51,0x31,0x60,0x76,0x60,0x70,0x60,0x50,  /* 00000310    "Q1`v`p`P" */
-    0x49,0x52,0x41,0x5B,0x82,0x49,0x08,0x4C,  /* 00000318    "IRA[.I.L" */
-    0x4E,0x4B,0x42,0x08,0x5F,0x48,0x49,0x44,  /* 00000320    "NKB._HID" */
-    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 00000328    ".A...._U" */
-    0x49,0x44,0x0A,0x02,0x14,0x1C,0x5F,0x53,  /* 00000330    "ID...._S" */
-    0x54,0x41,0x00,0x7B,0x50,0x49,0x52,0x42,  /* 00000338    "TA.{PIRB" */
-    0x0A,0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,  /* 00000340    "..`...`." */
-    0x80,0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,  /* 00000348    "........" */
-    0x0B,0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,  /* 00000350    "..._PRS." */
-    0xA4,0x42,0x55,0x46,0x41,0x14,0x11,0x5F,  /* 00000358    ".BUFA.._" */
-    0x44,0x49,0x53,0x00,0x7D,0x50,0x49,0x52,  /* 00000360    "DIS.}PIR" */
-    0x42,0x0A,0x80,0x50,0x49,0x52,0x42,0x14,  /* 00000368    "B..PIRB." */
-    0x1A,0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,  /* 00000370    "._CRS.{P" */
-    0x49,0x52,0x42,0x0A,0x0F,0x60,0x79,0x01,  /* 00000378    "IRB..`y." */
-    0x60,0x49,0x52,0x51,0x56,0xA4,0x42,0x55,  /* 00000380    "`IRQV.BU" */
-    0x46,0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,  /* 00000388    "FB.._SRS" */
-    0x01,0x8B,0x68,0x01,0x49,0x52,0x51,0x31,  /* 00000390    "..h.IRQ1" */
-    0x82,0x49,0x52,0x51,0x31,0x60,0x76,0x60,  /* 00000398    ".IRQ1`v`" */
-    0x70,0x60,0x50,0x49,0x52,0x42,0x5B,0x82,  /* 000003A0    "p`PIRB[." */
-    0x49,0x08,0x4C,0x4E,0x4B,0x43,0x08,0x5F,  /* 000003A8    "I.LNKC._" */
-    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,  /* 000003B0    "HID.A..." */
-    0x08,0x5F,0x55,0x49,0x44,0x0A,0x03,0x14,  /* 000003B8    "._UID..." */
-    0x1C,0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,  /* 000003C0    "._STA.{P" */
-    0x49,0x52,0x43,0x0A,0x80,0x60,0xA0,0x08,  /* 000003C8    "IRC..`.." */
-    0x93,0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,  /* 000003D0    ".`......" */
-    0x04,0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,  /* 000003D8    "......_P" */
-    0x52,0x53,0x00,0xA4,0x42,0x55,0x46,0x41,  /* 000003E0    "RS..BUFA" */
-    0x14,0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,  /* 000003E8    ".._DIS.}" */
-    0x50,0x49,0x52,0x43,0x0A,0x80,0x50,0x49,  /* 000003F0    "PIRC..PI" */
-    0x52,0x43,0x14,0x1A,0x5F,0x43,0x52,0x53,  /* 000003F8    "RC.._CRS" */
-    0x00,0x7B,0x50,0x49,0x52,0x43,0x0A,0x0F,  /* 00000400    ".{PIRC.." */
-    0x60,0x79,0x01,0x60,0x49,0x52,0x51,0x56,  /* 00000408    "`y.`IRQV" */
-    0xA4,0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,  /* 00000410    ".BUFB.._" */
-    0x53,0x52,0x53,0x01,0x8B,0x68,0x01,0x49,  /* 00000418    "SRS..h.I" */
-    0x52,0x51,0x31,0x82,0x49,0x52,0x51,0x31,  /* 00000420    "RQ1.IRQ1" */
-    0x60,0x76,0x60,0x70,0x60,0x50,0x49,0x52,  /* 00000428    "`v`p`PIR" */
-    0x43,0x5B,0x82,0x49,0x08,0x4C,0x4E,0x4B,  /* 00000430    "C[.I.LNK" */
-    0x44,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000438    "D._HID.A" */
-    0xD0,0x0C,0x0F,0x08,0x5F,0x55,0x49,0x44,  /* 00000440    "...._UID" */
-    0x0A,0x04,0x14,0x1C,0x5F,0x53,0x54,0x41,  /* 00000448    "...._STA" */
-    0x00,0x7B,0x50,0x49,0x52,0x44,0x0A,0x80,  /* 00000450    ".{PIRD.." */
-    0x60,0xA0,0x08,0x93,0x60,0x0A,0x80,0xA4,  /* 00000458    "`...`..." */
-    0x0A,0x09,0xA1,0x04,0xA4,0x0A,0x0B,0x14,  /* 00000460    "........" */
-    0x0B,0x5F,0x50,0x52,0x53,0x00,0xA4,0x42,  /* 00000468    "._PRS..B" */
-    0x55,0x46,0x41,0x14,0x11,0x5F,0x44,0x49,  /* 00000470    "UFA.._DI" */
-    0x53,0x00,0x7D,0x50,0x49,0x52,0x44,0x0A,  /* 00000478    "S.}PIRD." */
-    0x80,0x50,0x49,0x52,0x44,0x14,0x1A,0x5F,  /* 00000480    ".PIRD.._" */
-    0x43,0x52,0x53,0x00,0x7B,0x50,0x49,0x52,  /* 00000488    "CRS.{PIR" */
-    0x44,0x0A,0x0F,0x60,0x79,0x01,0x60,0x49,  /* 00000490    "D..`y.`I" */
-    0x52,0x51,0x56,0xA4,0x42,0x55,0x46,0x42,  /* 00000498    "RQV.BUFB" */
-    0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,  /* 000004A0    ".._SRS.." */
-    0x68,0x01,0x49,0x52,0x51,0x31,0x82,0x49,  /* 000004A8    "h.IRQ1.I" */
-    0x52,0x51,0x31,0x60,0x76,0x60,0x70,0x60,  /* 000004B0    "RQ1`v`p`" */
-    0x50,0x49,0x52,0x44,0x14,0x16,0x5F,0x50,  /* 000004B8    "PIRD.._P" */
-    0x52,0x54,0x00,0xA0,0x0A,0x50,0x49,0x43,  /* 000004C0    "RT...PIC" */
-    0x44,0xA4,0x50,0x52,0x54,0x41,0xA4,0x50,  /* 000004C8    "D.PRTA.P" */
-    0x52,0x54,0x50,0x08,0x50,0x52,0x54,0x50,  /* 000004D0    "RTP.PRTP" */
-    0x12,0x43,0x0E,0x10,0x12,0x0B,0x04,0x0B,  /* 000004D8    ".C......" */
-    0xFF,0xFF,0x00,0x4C,0x4E,0x4B,0x41,0x00,  /* 000004E0    "...LNKA." */
-    0x12,0x0B,0x04,0x0B,0xFF,0xFF,0x01,0x4C,  /* 000004E8    ".......L" */
-    0x4E,0x4B,0x42,0x00,0x12,0x0C,0x04,0x0B,  /* 000004F0    "NKB....." */
-    0xFF,0xFF,0x0A,0x02,0x4C,0x4E,0x4B,0x43,  /* 000004F8    "....LNKC" */
-    0x00,0x12,0x0C,0x04,0x0B,0xFF,0xFF,0x0A,  /* 00000500    "........" */
-    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000508    ".LNKD..." */
-    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x00,0x4C,  /* 00000510    ".......L" */
-    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000518    "NKB....." */
-    0xFF,0xFF,0x01,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000520    ".....LNK" */
-    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000528    "C......." */
-    0x01,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000530    "....LNKD" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000538    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000540    "...LNKA." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000548    "........" */
-    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000550    ".LNKC..." */
-    0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,0x4C,  /* 00000558    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000560    "NKD....." */
-    0xFF,0xFF,0x02,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000568    "......LN" */
-    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000570    "KA......" */
-    0xFF,0x02,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000578    ".....LNK" */
-    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000580    "B......." */
-    0x03,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000588    "...LNKD." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 00000590    "........" */
-    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 00000598    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,  /* 000005A0    "........" */
-    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000005A8    "LNKB...." */
-    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x03,0x4C,  /* 000005B0    ".......L" */
-    0x4E,0x4B,0x43,0x00,0x08,0x50,0x52,0x54,  /* 000005B8    "NKC..PRT" */
-    0x41,0x12,0x32,0x04,0x12,0x0B,0x04,0x0C,  /* 000005C0    "A.2....." */
-    0xFF,0xFF,0x01,0x00,0x00,0x00,0x0A,0x05,  /* 000005C8    "........" */
-    0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 000005D0    "........" */
-    0x00,0x00,0x0A,0x07,0x12,0x0B,0x04,0x0C,  /* 000005D8    "........" */
-    0xFF,0xFF,0x03,0x00,0x00,0x00,0x0A,0x0A,  /* 000005E0    "........" */
-    0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 000005E8    "........" */
-    0x00,0x00,0x0A,0x0B,0x5B,0x82,0x48,0x31,  /* 000005F0    "....[.H1" */
-    0x49,0x53,0x41,0x5F,0x08,0x5F,0x41,0x44,  /* 000005F8    "ISA_._AD" */
-    0x52,0x00,0x5B,0x80,0x50,0x49,0x52,0x51,  /* 00000600    "R.[.PIRQ" */
-    0x02,0x0A,0x60,0x0A,0x04,0x10,0x2E,0x5C,  /* 00000608    "..`....\" */
-    0x00,0x5B,0x81,0x29,0x5C,0x2F,0x04,0x5F,  /* 00000610    ".[.)\/._" */
-    0x53,0x42,0x5F,0x50,0x43,0x49,0x30,0x49,  /* 00000618    "SB_PCI0I" */
-    0x53,0x41,0x5F,0x50,0x49,0x52,0x51,0x01,  /* 00000620    "SA_PIRQ." */
-    0x50,0x49,0x52,0x41,0x08,0x50,0x49,0x52,  /* 00000628    "PIRA.PIR" */
-    0x42,0x08,0x50,0x49,0x52,0x43,0x08,0x50,  /* 00000630    "B.PIRC.P" */
-    0x49,0x52,0x44,0x08,0x5B,0x82,0x46,0x0B,  /* 00000638    "IRD.[.F." */
-    0x53,0x59,0x53,0x52,0x08,0x5F,0x48,0x49,  /* 00000640    "SYSR._HI" */
-    0x44,0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,  /* 00000648    "D.A...._" */
-    0x55,0x49,0x44,0x01,0x08,0x43,0x52,0x53,  /* 00000650    "UID..CRS" */
-    0x5F,0x11,0x4E,0x08,0x0A,0x8A,0x47,0x01,  /* 00000658    "_.N...G." */
-    0x10,0x00,0x10,0x00,0x00,0x10,0x47,0x01,  /* 00000660    "......G." */
-    0x22,0x00,0x22,0x00,0x00,0x0C,0x47,0x01,  /* 00000668    ""."...G." */
-    0x30,0x00,0x30,0x00,0x00,0x10,0x47,0x01,  /* 00000670    "0.0...G." */
-    0x44,0x00,0x44,0x00,0x00,0x1C,0x47,0x01,  /* 00000678    "D.D...G." */
-    0x62,0x00,0x62,0x00,0x00,0x02,0x47,0x01,  /* 00000680    "b.b...G." */
-    0x65,0x00,0x65,0x00,0x00,0x0B,0x47,0x01,  /* 00000688    "e.e...G." */
-    0x72,0x00,0x72,0x00,0x00,0x0E,0x47,0x01,  /* 00000690    "r.r...G." */
-    0x80,0x00,0x80,0x00,0x00,0x01,0x47,0x01,  /* 00000698    "......G." */
-    0x84,0x00,0x84,0x00,0x00,0x03,0x47,0x01,  /* 000006A0    "......G." */
-    0x88,0x00,0x88,0x00,0x00,0x01,0x47,0x01,  /* 000006A8    "......G." */
-    0x8C,0x00,0x8C,0x00,0x00,0x03,0x47,0x01,  /* 000006B0    "......G." */
-    0x90,0x00,0x90,0x00,0x00,0x10,0x47,0x01,  /* 000006B8    "......G." */
-    0xA2,0x00,0xA2,0x00,0x00,0x1C,0x47,0x01,  /* 000006C0    "......G." */
-    0xE0,0x00,0xE0,0x00,0x00,0x10,0x47,0x01,  /* 000006C8    "......G." */
-    0xA0,0x08,0xA0,0x08,0x00,0x04,0x47,0x01,  /* 000006D0    "......G." */
-    0xC0,0x0C,0xC0,0x0C,0x00,0x10,0x47,0x01,  /* 000006D8    "......G." */
-    0xD0,0x04,0xD0,0x04,0x00,0x02,0x79,0x00,  /* 000006E0    "......y." */
-    0x14,0x0B,0x5F,0x43,0x52,0x53,0x00,0xA4,  /* 000006E8    ".._CRS.." */
-    0x43,0x52,0x53,0x5F,0x5B,0x82,0x2B,0x50,  /* 000006F0    "CRS_[.+P" */
-    0x49,0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 000006F8    "IC_._HID" */
-    0x0B,0x41,0xD0,0x08,0x5F,0x43,0x52,0x53,  /* 00000700    ".A.._CRS" */
-    0x11,0x18,0x0A,0x15,0x47,0x01,0x20,0x00,  /* 00000708    "....G. ." */
-    0x20,0x00,0x01,0x02,0x47,0x01,0xA0,0x00,  /* 00000710    " ...G..." */
-    0xA0,0x00,0x01,0x02,0x22,0x04,0x00,0x79,  /* 00000718    "...."..y" */
-    0x00,0x5B,0x82,0x47,0x05,0x44,0x4D,0x41,  /* 00000720    ".[.G.DMA" */
-    0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000728    "0._HID.A" */
-    0xD0,0x02,0x00,0x08,0x5F,0x43,0x52,0x53,  /* 00000730    "...._CRS" */
-    0x11,0x41,0x04,0x0A,0x3D,0x2A,0x10,0x04,  /* 00000738    ".A..=*.." */
-    0x47,0x01,0x00,0x00,0x00,0x00,0x00,0x10,  /* 00000740    "G......." */
-    0x47,0x01,0x81,0x00,0x81,0x00,0x00,0x03,  /* 00000748    "G......." */
-    0x47,0x01,0x87,0x00,0x87,0x00,0x00,0x01,  /* 00000750    "G......." */
-    0x47,0x01,0x89,0x00,0x89,0x00,0x00,0x03,  /* 00000758    "G......." */
-    0x47,0x01,0x8F,0x00,0x8F,0x00,0x00,0x01,  /* 00000760    "G......." */
-    0x47,0x01,0xC0,0x00,0xC0,0x00,0x00,0x20,  /* 00000768    "G...... " */
-    0x47,0x01,0x80,0x04,0x80,0x04,0x00,0x10,  /* 00000770    "G......." */
-    0x79,0x00,0x5B,0x82,0x25,0x54,0x4D,0x52,  /* 00000778    "y.[.%TMR" */
-    0x5F,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000780    "_._HID.A" */
-    0xD0,0x01,0x00,0x08,0x5F,0x43,0x52,0x53,  /* 00000788    "...._CRS" */
-    0x11,0x10,0x0A,0x0D,0x47,0x01,0x40,0x00,  /* 00000790    "....G.@." */
-    0x40,0x00,0x00,0x04,0x22,0x01,0x00,0x79,  /* 00000798    "@..."..y" */
-    0x00,0x5B,0x82,0x25,0x52,0x54,0x43,0x5F,  /* 000007A0    ".[.%RTC_" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 000007A8    "._HID.A." */
-    0x0B,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 000007B0    "..._CRS." */
-    0x10,0x0A,0x0D,0x47,0x01,0x70,0x00,0x70,  /* 000007B8    "...G.p.p" */
-    0x00,0x00,0x02,0x22,0x00,0x01,0x79,0x00,  /* 000007C0    "..."..y." */
-    0x5B,0x82,0x22,0x53,0x50,0x4B,0x52,0x08,  /* 000007C8    "[."SPKR." */
-    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x08,  /* 000007D0    "_HID.A.." */
-    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x0D,  /* 000007D8    ".._CRS.." */
-    0x0A,0x0A,0x47,0x01,0x61,0x00,0x61,0x00,  /* 000007E0    "..G.a.a." */
-    0x00,0x01,0x79,0x00,0x5B,0x82,0x31,0x50,  /* 000007E8    "..y.[.1P" */
-    0x53,0x32,0x4D,0x08,0x5F,0x48,0x49,0x44,  /* 000007F0    "S2M._HID" */
-    0x0C,0x41,0xD0,0x0F,0x13,0x08,0x5F,0x43,  /* 000007F8    ".A...._C" */
-    0x49,0x44,0x0C,0x41,0xD0,0x0F,0x13,0x14,  /* 00000800    "ID.A...." */
-    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000808    "._STA..." */
-    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x08,  /* 00000810    ".._CRS.." */
-    0x0A,0x05,0x22,0x00,0x10,0x79,0x00,0x5B,  /* 00000818    ".."..y.[" */
-    0x82,0x42,0x04,0x50,0x53,0x32,0x4B,0x08,  /* 00000820    ".B.PS2K." */
-    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x03,  /* 00000828    "_HID.A.." */
-    0x03,0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,  /* 00000830    ".._CID.A" */
-    0xD0,0x03,0x0B,0x14,0x09,0x5F,0x53,0x54,  /* 00000838    "....._ST" */
-    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 00000840    "A....._C" */
-    0x52,0x53,0x11,0x18,0x0A,0x15,0x47,0x01,  /* 00000848    "RS....G." */
-    0x60,0x00,0x60,0x00,0x00,0x01,0x47,0x01,  /* 00000850    "`.`...G." */
-    0x64,0x00,0x64,0x00,0x00,0x01,0x22,0x02,  /* 00000858    "d.d..."." */
-    0x00,0x79,0x00,0x5B,0x82,0x3A,0x46,0x44,  /* 00000860    ".y.[.:FD" */
-    0x43,0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000868    "C0._HID." */
-    0x41,0xD0,0x07,0x00,0x14,0x09,0x5F,0x53,  /* 00000870    "A....._S" */
-    0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,  /* 00000878    "TA....._" */
-    0x43,0x52,0x53,0x11,0x1B,0x0A,0x18,0x47,  /* 00000880    "CRS....G" */
-    0x01,0xF0,0x03,0xF0,0x03,0x01,0x06,0x47,  /* 00000888    ".......G" */
-    0x01,0xF7,0x03,0xF7,0x03,0x01,0x01,0x22,  /* 00000890    "......."" */
-    0x40,0x00,0x2A,0x04,0x00,0x79,0x00,0x5B,  /* 00000898    "@.*..y.[" */
-    0x82,0x35,0x55,0x41,0x52,0x31,0x08,0x5F,  /* 000008A0    ".5UAR1._" */
-    0x48,0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,  /* 000008A8    "HID.A..." */
-    0x08,0x5F,0x55,0x49,0x44,0x01,0x14,0x09,  /* 000008B0    "._UID..." */
-    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 000008B8    "_STA...." */
-    0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,  /* 000008C0    "._CRS..." */
-    0x0D,0x47,0x01,0xF8,0x03,0xF8,0x03,0x01,  /* 000008C8    ".G......" */
-    0x08,0x22,0x10,0x00,0x79,0x00,0x5B,0x82,  /* 000008D0    "."..y.[." */
-    0x36,0x55,0x41,0x52,0x32,0x08,0x5F,0x48,  /* 000008D8    "6UAR2._H" */
-    0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,0x08,  /* 000008E0    "ID.A...." */
-    0x5F,0x55,0x49,0x44,0x0A,0x02,0x14,0x09,  /* 000008E8    "_UID...." */
-    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 000008F0    "_STA...." */
-    0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,  /* 000008F8    "._CRS..." */
-    0x0D,0x47,0x01,0xF8,0x02,0xF8,0x02,0x01,  /* 00000900    ".G......" */
-    0x08,0x22,0x08,0x00,0x79,0x00,
+    0xFF,0x00,0x00,0x00,0xF3,0x87,0x17,0x00,  /* 000001A0    "........" */
+    0x00,0x0D,0x03,0x00,0x00,0x00,0x00,0x00,  /* 000001A8    "........" */
+    0x00,0x00,0xF0,0xFF,0xFF,0xFF,0xF1,0x00,  /* 000001B0    "........" */
+    0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x87,  /* 000001B8    "........" */
+    0x17,0x00,0x00,0x0D,0x03,0x00,0x00,0x00,  /* 000001C0    "........" */
+    0x00,0x00,0x00,0x00,0xF2,0xFF,0x0F,0x00,  /* 000001C8    "........" */
+    0xF2,0x00,0x00,0x00,0x00,0x00,0x10,0x00,  /* 000001D0    "........" */
+    0x00,0x79,0x00,0xA4,0x50,0x52,0x54,0x30,  /* 000001D8    ".y..PRT0" */
+    0x08,0x42,0x55,0x46,0x41,0x11,0x09,0x0A,  /* 000001E0    ".BUFA..." */
+    0x06,0x23,0xF8,0xDC,0x18,0x79,0x00,0x08,  /* 000001E8    ".#...y.." */
+    0x42,0x55,0x46,0x42,0x11,0x09,0x0A,0x06,  /* 000001F0    "BUFB...." */
+    0x23,0x00,0x00,0x18,0x79,0x00,0x8B,0x42,  /* 000001F8    "#...y..B" */
+    0x55,0x46,0x42,0x01,0x49,0x52,0x51,0x56,  /* 00000200    "UFB.IRQV" */
+    0x08,0x42,0x55,0x46,0x43,0x11,0x07,0x0A,  /* 00000208    ".BUFC..." */
+    0x04,0x05,0x07,0x0A,0x0B,0x8C,0x42,0x55,  /* 00000210    "......BU" */
+    0x46,0x43,0x01,0x50,0x49,0x51,0x41,0x8C,  /* 00000218    "FC.PIQA." */
+    0x42,0x55,0x46,0x43,0x01,0x50,0x49,0x51,  /* 00000220    "BUFC.PIQ" */
+    0x42,0x8C,0x42,0x55,0x46,0x43,0x01,0x50,  /* 00000228    "B.BUFC.P" */
+    0x49,0x51,0x43,0x8C,0x42,0x55,0x46,0x43,  /* 00000230    "IQC.BUFC" */
+    0x01,0x50,0x49,0x51,0x44,0x5B,0x82,0x48,  /* 00000238    ".PIQD[.H" */
+    0x08,0x4C,0x4E,0x4B,0x41,0x08,0x5F,0x48,  /* 00000240    ".LNKA._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,  /* 00000248    "ID.A...." */
+    0x5F,0x55,0x49,0x44,0x01,0x14,0x1C,0x5F,  /* 00000250    "_UID..._" */
+    0x53,0x54,0x41,0x00,0x7B,0x50,0x49,0x52,  /* 00000258    "STA.{PIR" */
+    0x41,0x0A,0x80,0x60,0xA0,0x08,0x93,0x60,  /* 00000260    "A..`...`" */
+    0x0A,0x80,0xA4,0x0A,0x09,0xA1,0x04,0xA4,  /* 00000268    "........" */
+    0x0A,0x0B,0x14,0x0B,0x5F,0x50,0x52,0x53,  /* 00000270    "...._PRS" */
+    0x00,0xA4,0x42,0x55,0x46,0x41,0x14,0x11,  /* 00000278    "..BUFA.." */
+    0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,0x49,  /* 00000280    "_DIS.}PI" */
+    0x52,0x41,0x0A,0x80,0x50,0x49,0x52,0x41,  /* 00000288    "RA..PIRA" */
+    0x14,0x1A,0x5F,0x43,0x52,0x53,0x00,0x7B,  /* 00000290    ".._CRS.{" */
+    0x50,0x49,0x52,0x42,0x0A,0x0F,0x60,0x79,  /* 00000298    "PIRB..`y" */
+    0x01,0x60,0x49,0x52,0x51,0x56,0xA4,0x42,  /* 000002A0    ".`IRQV.B" */
+    0x55,0x46,0x42,0x14,0x1B,0x5F,0x53,0x52,  /* 000002A8    "UFB.._SR" */
+    0x53,0x01,0x8B,0x68,0x01,0x49,0x52,0x51,  /* 000002B0    "S..h.IRQ" */
+    0x31,0x82,0x49,0x52,0x51,0x31,0x60,0x76,  /* 000002B8    "1.IRQ1`v" */
+    0x60,0x70,0x60,0x50,0x49,0x52,0x41,0x5B,  /* 000002C0    "`p`PIRA[" */
+    0x82,0x49,0x08,0x4C,0x4E,0x4B,0x42,0x08,  /* 000002C8    ".I.LNKB." */
+    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,  /* 000002D0    "_HID.A.." */
+    0x0F,0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,  /* 000002D8    ".._UID.." */
+    0x14,0x1C,0x5F,0x53,0x54,0x41,0x00,0x7B,  /* 000002E0    ".._STA.{" */
+    0x50,0x49,0x52,0x42,0x0A,0x80,0x60,0xA0,  /* 000002E8    "PIRB..`." */
+    0x08,0x93,0x60,0x0A,0x80,0xA4,0x0A,0x09,  /* 000002F0    "..`....." */
+    0xA1,0x04,0xA4,0x0A,0x0B,0x14,0x0B,0x5F,  /* 000002F8    "......._" */
+    0x50,0x52,0x53,0x00,0xA4,0x42,0x55,0x46,  /* 00000300    "PRS..BUF" */
+    0x41,0x14,0x11,0x5F,0x44,0x49,0x53,0x00,  /* 00000308    "A.._DIS." */
+    0x7D,0x50,0x49,0x52,0x42,0x0A,0x80,0x50,  /* 00000310    "}PIRB..P" */
+    0x49,0x52,0x42,0x14,0x1A,0x5F,0x43,0x52,  /* 00000318    "IRB.._CR" */
+    0x53,0x00,0x7B,0x50,0x49,0x52,0x42,0x0A,  /* 00000320    "S.{PIRB." */
+    0x0F,0x60,0x79,0x01,0x60,0x49,0x52,0x51,  /* 00000328    ".`y.`IRQ" */
+    0x56,0xA4,0x42,0x55,0x46,0x42,0x14,0x1B,  /* 00000330    "V.BUFB.." */
+    0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,0x01,  /* 00000338    "_SRS..h." */
+    0x49,0x52,0x51,0x31,0x82,0x49,0x52,0x51,  /* 00000340    "IRQ1.IRQ" */
+    0x31,0x60,0x76,0x60,0x70,0x60,0x50,0x49,  /* 00000348    "1`v`p`PI" */
+    0x52,0x42,0x5B,0x82,0x49,0x08,0x4C,0x4E,  /* 00000350    "RB[.I.LN" */
+    0x4B,0x43,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000358    "KC._HID." */
+    0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,0x49,  /* 00000360    "A...._UI" */
+    0x44,0x0A,0x03,0x14,0x1C,0x5F,0x53,0x54,  /* 00000368    "D...._ST" */
+    0x41,0x00,0x7B,0x50,0x49,0x52,0x43,0x0A,  /* 00000370    "A.{PIRC." */
+    0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,0x80,  /* 00000378    ".`...`.." */
+    0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,0x0B,  /* 00000380    "........" */
+    0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,0xA4,  /* 00000388    ".._PRS.." */
+    0x42,0x55,0x46,0x41,0x14,0x11,0x5F,0x44,  /* 00000390    "BUFA.._D" */
+    0x49,0x53,0x00,0x7D,0x50,0x49,0x52,0x43,  /* 00000398    "IS.}PIRC" */
+    0x0A,0x80,0x50,0x49,0x52,0x43,0x14,0x1A,  /* 000003A0    "..PIRC.." */
+    0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,0x49,  /* 000003A8    "_CRS.{PI" */
+    0x52,0x43,0x0A,0x0F,0x60,0x79,0x01,0x60,  /* 000003B0    "RC..`y.`" */
+    0x49,0x52,0x51,0x56,0xA4,0x42,0x55,0x46,  /* 000003B8    "IRQV.BUF" */
+    0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,  /* 000003C0    "B.._SRS." */
+    0x8B,0x68,0x01,0x49,0x52,0x51,0x31,0x82,  /* 000003C8    ".h.IRQ1." */
+    0x49,0x52,0x51,0x31,0x60,0x76,0x60,0x70,  /* 000003D0    "IRQ1`v`p" */
+    0x60,0x50,0x49,0x52,0x43,0x5B,0x82,0x49,  /* 000003D8    "`PIRC[.I" */
+    0x08,0x4C,0x4E,0x4B,0x44,0x08,0x5F,0x48,  /* 000003E0    ".LNKD._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,  /* 000003E8    "ID.A...." */
+    0x5F,0x55,0x49,0x44,0x0A,0x04,0x14,0x1C,  /* 000003F0    "_UID...." */
+    0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,0x49,  /* 000003F8    "_STA.{PI" */
+    0x52,0x44,0x0A,0x80,0x60,0xA0,0x08,0x93,  /* 00000400    "RD..`..." */
+    0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,0x04,  /* 00000408    "`......." */
+    0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,0x52,  /* 00000410    "....._PR" */
+    0x53,0x00,0xA4,0x42,0x55,0x46,0x41,0x14,  /* 00000418    "S..BUFA." */
+    0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,  /* 00000420    "._DIS.}P" */
+    0x49,0x52,0x44,0x0A,0x80,0x50,0x49,0x52,  /* 00000428    "IRD..PIR" */
+    0x44,0x14,0x1A,0x5F,0x43,0x52,0x53,0x00,  /* 00000430    "D.._CRS." */
+    0x7B,0x50,0x49,0x52,0x44,0x0A,0x0F,0x60,  /* 00000438    "{PIRD..`" */
+    0x79,0x01,0x60,0x49,0x52,0x51,0x56,0xA4,  /* 00000440    "y.`IRQV." */
+    0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,0x53,  /* 00000448    "BUFB.._S" */
+    0x52,0x53,0x01,0x8B,0x68,0x01,0x49,0x52,  /* 00000450    "RS..h.IR" */
+    0x51,0x31,0x82,0x49,0x52,0x51,0x31,0x60,  /* 00000458    "Q1.IRQ1`" */
+    0x76,0x60,0x70,0x60,0x50,0x49,0x52,0x44,  /* 00000460    "v`p`PIRD" */
+    0x14,0x16,0x5F,0x50,0x52,0x54,0x00,0xA0,  /* 00000468    ".._PRT.." */
+    0x0A,0x50,0x49,0x43,0x44,0xA4,0x50,0x52,  /* 00000470    ".PICD.PR" */
+    0x54,0x41,0xA4,0x50,0x52,0x54,0x50,0x08,  /* 00000478    "TA.PRTP." */
+    0x50,0x52,0x54,0x50,0x12,0x43,0x0E,0x10,  /* 00000480    "PRTP.C.." */
+    0x12,0x0B,0x04,0x0B,0xFF,0xFF,0x00,0x4C,  /* 00000488    ".......L" */
+    0x4E,0x4B,0x41,0x00,0x12,0x0B,0x04,0x0B,  /* 00000490    "NKA....." */
+    0xFF,0xFF,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000498    "...LNKB." */
+    0x12,0x0C,0x04,0x0B,0xFF,0xFF,0x0A,0x02,  /* 000004A0    "........" */
+    0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0C,0x04,  /* 000004A8    "LNKC...." */
+    0x0B,0xFF,0xFF,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000004B0    ".....LNK" */
+    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000004B8    "D......." */
+    0x01,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 000004C0    "...LNKB." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 000004C8    "........" */
+    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 000004D0    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x02,  /* 000004D8    "........" */
+    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 000004E0    "LNKD...." */
+    0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,0x4C,  /* 000004E8    ".......L" */
+    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 000004F0    "NKA....." */
+    0xFF,0xFF,0x02,0x00,0x00,0x4C,0x4E,0x4B,  /* 000004F8    ".....LNK" */
+    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000500    "C......." */
+    0x02,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000508    "...LNKD." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000510    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000518    "..LNKA.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x0A,  /* 00000520    "........" */
+    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000528    ".LNKB..." */
+    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x00,0x4C,  /* 00000530    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000538    "NKD....." */
+    0xFF,0xFF,0x03,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000540    ".....LNK" */
+    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000548    "A......." */
+    0x03,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000550    "....LNKB" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000558    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000560    "...LNKC." */
+    0x08,0x50,0x52,0x54,0x41,0x12,0x32,0x04,  /* 00000568    ".PRTA.2." */
+    0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 00000570    "........" */
+    0x00,0x00,0x0A,0x05,0x12,0x0B,0x04,0x0C,  /* 00000578    "........" */
+    0xFF,0xFF,0x02,0x00,0x00,0x00,0x0A,0x07,  /* 00000580    "........" */
+    0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 00000588    "........" */
+    0x00,0x00,0x0A,0x0A,0x12,0x0B,0x04,0x0C,  /* 00000590    "........" */
+    0xFF,0xFF,0x04,0x00,0x00,0x00,0x0A,0x0B,  /* 00000598    "........" */
+    0x5B,0x82,0x48,0x31,0x49,0x53,0x41,0x5F,  /* 000005A0    "[.H1ISA_" */
+    0x08,0x5F,0x41,0x44,0x52,0x00,0x5B,0x80,  /* 000005A8    "._ADR.[." */
+    0x50,0x49,0x52,0x51,0x02,0x0A,0x60,0x0A,  /* 000005B0    "PIRQ..`." */
+    0x04,0x10,0x2E,0x5C,0x00,0x5B,0x81,0x29,  /* 000005B8    "...\.[.)" */
+    0x5C,0x2F,0x04,0x5F,0x53,0x42,0x5F,0x50,  /* 000005C0    "\/._SB_P" */
+    0x43,0x49,0x30,0x49,0x53,0x41,0x5F,0x50,  /* 000005C8    "CI0ISA_P" */
+    0x49,0x52,0x51,0x01,0x50,0x49,0x52,0x41,  /* 000005D0    "IRQ.PIRA" */
+    0x08,0x50,0x49,0x52,0x42,0x08,0x50,0x49,  /* 000005D8    ".PIRB.PI" */
+    0x52,0x43,0x08,0x50,0x49,0x52,0x44,0x08,  /* 000005E0    "RC.PIRD." */
+    0x5B,0x82,0x46,0x0B,0x53,0x59,0x53,0x52,  /* 000005E8    "[.F.SYSR" */
+    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 000005F0    "._HID.A." */
+    0x0C,0x02,0x08,0x5F,0x55,0x49,0x44,0x01,  /* 000005F8    "..._UID." */
+    0x08,0x43,0x52,0x53,0x5F,0x11,0x4E,0x08,  /* 00000600    ".CRS_.N." */
+    0x0A,0x8A,0x47,0x01,0x10,0x00,0x10,0x00,  /* 00000608    "..G....." */
+    0x00,0x10,0x47,0x01,0x22,0x00,0x22,0x00,  /* 00000610    "..G."."." */
+    0x00,0x0C,0x47,0x01,0x30,0x00,0x30,0x00,  /* 00000618    "..G.0.0." */
+    0x00,0x10,0x47,0x01,0x44,0x00,0x44,0x00,  /* 00000620    "..G.D.D." */
+    0x00,0x1C,0x47,0x01,0x62,0x00,0x62,0x00,  /* 00000628    "..G.b.b." */
+    0x00,0x02,0x47,0x01,0x65,0x00,0x65,0x00,  /* 00000630    "..G.e.e." */
+    0x00,0x0B,0x47,0x01,0x72,0x00,0x72,0x00,  /* 00000638    "..G.r.r." */
+    0x00,0x0E,0x47,0x01,0x80,0x00,0x80,0x00,  /* 00000640    "..G....." */
+    0x00,0x01,0x47,0x01,0x84,0x00,0x84,0x00,  /* 00000648    "..G....." */
+    0x00,0x03,0x47,0x01,0x88,0x00,0x88,0x00,  /* 00000650    "..G....." */
+    0x00,0x01,0x47,0x01,0x8C,0x00,0x8C,0x00,  /* 00000658    "..G....." */
+    0x00,0x03,0x47,0x01,0x90,0x00,0x90,0x00,  /* 00000660    "..G....." */
+    0x00,0x10,0x47,0x01,0xA2,0x00,0xA2,0x00,  /* 00000668    "..G....." */
+    0x00,0x1C,0x47,0x01,0xE0,0x00,0xE0,0x00,  /* 00000670    "..G....." */
+    0x00,0x10,0x47,0x01,0xA0,0x08,0xA0,0x08,  /* 00000678    "..G....." */
+    0x00,0x04,0x47,0x01,0xC0,0x0C,0xC0,0x0C,  /* 00000680    "..G....." */
+    0x00,0x10,0x47,0x01,0xD0,0x04,0xD0,0x04,  /* 00000688    "..G....." */
+    0x00,0x02,0x79,0x00,0x14,0x0B,0x5F,0x43,  /* 00000690    "..y..._C" */
+    0x52,0x53,0x00,0xA4,0x43,0x52,0x53,0x5F,  /* 00000698    "RS..CRS_" */
+    0x5B,0x82,0x2B,0x50,0x49,0x43,0x5F,0x08,  /* 000006A0    "[.+PIC_." */
+    0x5F,0x48,0x49,0x44,0x0B,0x41,0xD0,0x08,  /* 000006A8    "_HID.A.." */
+    0x5F,0x43,0x52,0x53,0x11,0x18,0x0A,0x15,  /* 000006B0    "_CRS...." */
+    0x47,0x01,0x20,0x00,0x20,0x00,0x01,0x02,  /* 000006B8    "G. . ..." */
+    0x47,0x01,0xA0,0x00,0xA0,0x00,0x01,0x02,  /* 000006C0    "G......." */
+    0x22,0x04,0x00,0x79,0x00,0x5B,0x82,0x47,  /* 000006C8    ""..y.[.G" */
+    0x05,0x44,0x4D,0x41,0x30,0x08,0x5F,0x48,  /* 000006D0    ".DMA0._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x02,0x00,0x08,  /* 000006D8    "ID.A...." */
+    0x5F,0x43,0x52,0x53,0x11,0x41,0x04,0x0A,  /* 000006E0    "_CRS.A.." */
+    0x3D,0x2A,0x10,0x04,0x47,0x01,0x00,0x00,  /* 000006E8    "=*..G..." */
+    0x00,0x00,0x00,0x10,0x47,0x01,0x81,0x00,  /* 000006F0    "....G..." */
+    0x81,0x00,0x00,0x03,0x47,0x01,0x87,0x00,  /* 000006F8    "....G..." */
+    0x87,0x00,0x00,0x01,0x47,0x01,0x89,0x00,  /* 00000700    "....G..." */
+    0x89,0x00,0x00,0x03,0x47,0x01,0x8F,0x00,  /* 00000708    "....G..." */
+    0x8F,0x00,0x00,0x01,0x47,0x01,0xC0,0x00,  /* 00000710    "....G..." */
+    0xC0,0x00,0x00,0x20,0x47,0x01,0x80,0x04,  /* 00000718    "... G..." */
+    0x80,0x04,0x00,0x10,0x79,0x00,0x5B,0x82,  /* 00000720    "....y.[." */
+    0x25,0x54,0x4D,0x52,0x5F,0x08,0x5F,0x48,  /* 00000728    "%TMR_._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x01,0x00,0x08,  /* 00000730    "ID.A...." */
+    0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,  /* 00000738    "_CRS...." */
+    0x47,0x01,0x40,0x00,0x40,0x00,0x00,0x04,  /* 00000740    "G.@.@..." */
+    0x22,0x01,0x00,0x79,0x00,0x5B,0x82,0x25,  /* 00000748    ""..y.[.%" */
+    0x52,0x54,0x43,0x5F,0x08,0x5F,0x48,0x49,  /* 00000750    "RTC_._HI" */
+    0x44,0x0C,0x41,0xD0,0x0B,0x00,0x08,0x5F,  /* 00000758    "D.A...._" */
+    0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,  /* 00000760    "CRS....G" */
+    0x01,0x70,0x00,0x70,0x00,0x00,0x02,0x22,  /* 00000768    ".p.p..."" */
+    0x00,0x01,0x79,0x00,0x5B,0x82,0x22,0x53,  /* 00000770    "..y.[."S" */
+    0x50,0x4B,0x52,0x08,0x5F,0x48,0x49,0x44,  /* 00000778    "PKR._HID" */
+    0x0C,0x41,0xD0,0x08,0x00,0x08,0x5F,0x43,  /* 00000780    ".A...._C" */
+    0x52,0x53,0x11,0x0D,0x0A,0x0A,0x47,0x01,  /* 00000788    "RS....G." */
+    0x61,0x00,0x61,0x00,0x00,0x01,0x79,0x00,  /* 00000790    "a.a...y." */
+    0x5B,0x82,0x31,0x50,0x53,0x32,0x4D,0x08,  /* 00000798    "[.1PS2M." */
+    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0F,  /* 000007A0    "_HID.A.." */
+    0x13,0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,  /* 000007A8    ".._CID.A" */
+    0xD0,0x0F,0x13,0x14,0x09,0x5F,0x53,0x54,  /* 000007B0    "....._ST" */
+    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 000007B8    "A....._C" */
+    0x52,0x53,0x11,0x08,0x0A,0x05,0x22,0x00,  /* 000007C0    "RS...."." */
+    0x10,0x79,0x00,0x5B,0x82,0x42,0x04,0x50,  /* 000007C8    ".y.[.B.P" */
+    0x53,0x32,0x4B,0x08,0x5F,0x48,0x49,0x44,  /* 000007D0    "S2K._HID" */
+    0x0C,0x41,0xD0,0x03,0x03,0x08,0x5F,0x43,  /* 000007D8    ".A...._C" */
+    0x49,0x44,0x0C,0x41,0xD0,0x03,0x0B,0x14,  /* 000007E0    "ID.A...." */
+    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 000007E8    "._STA..." */
+    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x18,  /* 000007F0    ".._CRS.." */
+    0x0A,0x15,0x47,0x01,0x60,0x00,0x60,0x00,  /* 000007F8    "..G.`.`." */
+    0x00,0x01,0x47,0x01,0x64,0x00,0x64,0x00,  /* 00000800    "..G.d.d." */
+    0x00,0x01,0x22,0x02,0x00,0x79,0x00,0x5B,  /* 00000808    ".."..y.[" */
+    0x82,0x3A,0x46,0x44,0x43,0x30,0x08,0x5F,  /* 00000810    ".:FDC0._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x07,0x00,  /* 00000818    "HID.A..." */
+    0x14,0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,  /* 00000820    ".._STA.." */
+    0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000828    "..._CRS." */
+    0x1B,0x0A,0x18,0x47,0x01,0xF0,0x03,0xF0,  /* 00000830    "...G...." */
+    0x03,0x01,0x06,0x47,0x01,0xF7,0x03,0xF7,  /* 00000838    "...G...." */
+    0x03,0x01,0x01,0x22,0x40,0x00,0x2A,0x04,  /* 00000840    "..."@.*." */
+    0x00,0x79,0x00,0x5B,0x82,0x35,0x55,0x41,  /* 00000848    ".y.[.5UA" */
+    0x52,0x31,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000850    "R1._HID." */
+    0x41,0xD0,0x05,0x01,0x08,0x5F,0x55,0x49,  /* 00000858    "A...._UI" */
+    0x44,0x01,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000860    "D..._STA" */
+    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 00000868    "....._CR" */
+    0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,0xF8,  /* 00000870    "S....G.." */
+    0x03,0xF8,0x03,0x01,0x08,0x22,0x10,0x00,  /* 00000878    ".....".." */
+    0x79,0x00,0x5B,0x82,0x36,0x4C,0x54,0x50,  /* 00000880    "y.[.6LTP" */
+    0x31,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000888    "1._HID.A" */
+    0xD0,0x04,0x00,0x08,0x5F,0x55,0x49,0x44,  /* 00000890    "...._UID" */
+    0x0A,0x02,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000898    "...._STA" */
+    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 000008A0    "....._CR" */
+    0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,0x78,  /* 000008A8    "S....G.x" */
+    0x03,0x78,0x03,0x08,0x08,0x22,0x80,0x00,  /* 000008B0    ".x...".." */
+    0x79,0x00,
 };
 int DsdtLen=sizeof(AmlCode);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/Makefile
--- a/tools/libxc/Makefile      Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/Makefile      Sun Aug 27 10:24:41 2006 -0600
@@ -11,7 +11,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 include $(XEN_ROOT)/tools/Rules.mk
 
 CTRL_SRCS-y       :=
-CTRL_SRCS-y       += xc_bvtsched.c
 CTRL_SRCS-y       += xc_core.c
 CTRL_SRCS-y       += xc_domain.c
 CTRL_SRCS-y       += xc_evtchn.c
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/ia64/xc_ia64_hvm_build.c
--- a/tools/libxc/ia64/xc_ia64_hvm_build.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c      Sun Aug 27 10:24:41 2006 -0600
@@ -554,7 +554,7 @@ setup_guest(int xc_handle, uint32_t dom,
     unsigned long page_array[2];
     shared_iopage_t *sp;
     unsigned long dom_memsize = (memsize << 20);
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
 
     if ((image_size > 12 * MEM_M) || (image_size & (PAGE_SIZE - 1))) {
         PERROR("Guest firmware size is incorrect [%ld]?", image_size);
@@ -562,13 +562,12 @@ setup_guest(int xc_handle, uint32_t dom,
     }
 
     /* This will creates the physmap.  */
-    op.u.domain_setup.flags = XEN_DOMAINSETUP_hvm_guest;
-    op.u.domain_setup.domain = (domid_t)dom;
-    op.u.domain_setup.bp = 0;
-    op.u.domain_setup.maxmem = 0;
-    
-    op.cmd = DOM0_DOMAIN_SETUP;
-    if (xc_dom0_op(xc_handle, &op))
+    domctl.u.arch_setup.flags = XEN_DOMAINSETUP_hvm_guest;
+    domctl.u.arch_setup.bp = 0;
+    domctl.u.arch_setup.maxmem = 0;
+    domctl.cmd = XEN_DOMCTL_arch_setup;
+    domctl.domain = (domid_t)dom;
+    if (xc_domctl(xc_handle, &domctl))
         goto error_out;
 
     /* Load guest firmware */
@@ -618,7 +617,7 @@ xc_hvm_build(int xc_handle, uint32_t dom
              unsigned int acpi, unsigned int apic, unsigned int store_evtchn,
              unsigned long *store_mfn)
 {
-    dom0_op_t launch_op, op;
+    struct xen_domctl launch_domctl, domctl;
     int rc;
     vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
     char *image = NULL;
@@ -644,10 +643,10 @@ xc_hvm_build(int xc_handle, uint32_t dom
         return 1;
     }
 
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)domid;
-    if (do_dom0_op(xc_handle, &op) < 0 ||
-        (uint16_t)op.u.getdomaininfo.domain != domid) {
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)domid;
+    if (do_domctl(xc_handle, &domctl) < 0 ||
+        (uint16_t)domctl.domain != domid) {
         PERROR("Could not get info on domain");
         goto error_out;
     }
@@ -664,14 +663,14 @@ xc_hvm_build(int xc_handle, uint32_t dom
 
     ctxt->user_regs.cr_iip = 0x80000000ffffffb0UL;
 
-    memset(&launch_op, 0, sizeof(launch_op));
-
-    launch_op.u.setvcpucontext.domain = (domid_t)domid;
-    launch_op.u.setvcpucontext.vcpu = 0;
-    set_xen_guest_handle(launch_op.u.setvcpucontext.ctxt, ctxt);
-
-    launch_op.cmd = DOM0_SETVCPUCONTEXT;
-    rc = do_dom0_op(xc_handle, &launch_op);
+    memset(&launch_domctl, 0, sizeof(launch_domctl));
+
+    launch_domctl.domain = (domid_t)domid;
+    launch_domctl.u.vcpucontext.vcpu = 0;
+    set_xen_guest_handle(launch_domctl.u.vcpucontext.ctxt, ctxt);
+
+    launch_domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    rc = do_domctl(xc_handle, &launch_domctl);
     return rc;
 
 error_out:
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/ia64/xc_ia64_linux_restore.c
--- a/tools/libxc/ia64/xc_ia64_linux_restore.c  Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/ia64/xc_ia64_linux_restore.c  Sun Aug 27 10:24:41 2006 -0600
@@ -61,7 +61,7 @@ xc_linux_restore(int xc_handle, int io_f
                  unsigned long *store_mfn, unsigned int console_evtchn,
                  unsigned long *console_mfn)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int rc = 1, i;
     unsigned long mfn, pfn;
     unsigned long ver;
@@ -94,19 +94,19 @@ xc_linux_restore(int xc_handle, int io_f
     }
 
     if (mlock(&ctxt, sizeof(ctxt))) {
-        /* needed for build dom0 op, but might as well do early */
+        /* needed for build domctl, but might as well do early */
         ERR("Unable to mlock ctxt");
         return 1;
     }
 
     /* Get the domain's shared-info frame. */
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)dom;
-    if (xc_dom0_op(xc_handle, &op) < 0) {
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)dom;
+    if (xc_domctl(xc_handle, &domctl) < 0) {
         ERR("Could not get information on new domain");
         goto out;
     }
-    shared_info_frame = op.u.getdomaininfo.shared_info_frame;
+    shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
 
     if (xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) {
         errno = ENOMEM;
@@ -122,20 +122,20 @@ xc_linux_restore(int xc_handle, int io_f
 
     DPRINTF("Increased domain reservation by %ld KB\n", PFN_TO_KB(max_pfn));
 
-    if (!read_exact(io_fd, &op.u.domain_setup, sizeof(op.u.domain_setup))) {
+    if (!read_exact(io_fd, &domctl.u.arch_setup, sizeof(domctl.u.arch_setup))) 
{
         ERR("read: domain setup");
         goto out;
     }
 
     /* Build firmware (will be overwritten).  */
-    op.u.domain_setup.domain = (domid_t)dom;
-    op.u.domain_setup.flags &= ~XEN_DOMAINSETUP_query;
-    op.u.domain_setup.bp = ((nr_pfns - 3) << PAGE_SHIFT)
+    domctl.domain = (domid_t)dom;
+    domctl.u.arch_setup.flags &= ~XEN_DOMAINSETUP_query;
+    domctl.u.arch_setup.bp = ((nr_pfns - 3) << PAGE_SHIFT)
                            + sizeof (start_info_t);
-    op.u.domain_setup.maxmem = (nr_pfns - 3) << PAGE_SHIFT;
+    domctl.u.arch_setup.maxmem = (nr_pfns - 3) << PAGE_SHIFT;
     
-    op.cmd = DOM0_DOMAIN_SETUP;
-    if (xc_dom0_op(xc_handle, &op))
+    domctl.cmd = XEN_DOMCTL_arch_setup;
+    if (xc_domctl(xc_handle, &domctl))
         goto out;
 
     /* Get pages.  */
@@ -226,22 +226,22 @@ xc_linux_restore(int xc_handle, int io_f
     }
 
     /* First to initialize.  */
-    op.cmd = DOM0_SETVCPUCONTEXT;
-    op.u.setvcpucontext.domain = (domid_t)dom;
-    op.u.setvcpucontext.vcpu   = 0;
-    set_xen_guest_handle(op.u.setvcpucontext.ctxt, &ctxt);
-    if (xc_dom0_op(xc_handle, &op) != 0) {
+    domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    domctl.domain = (domid_t)dom;
+    domctl.u.vcpucontext.vcpu   = 0;
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt);
+    if (xc_domctl(xc_handle, &domctl) != 0) {
            ERR("Couldn't set vcpu context");
            goto out;
     }
 
     /* Second to set registers...  */
     ctxt.flags = VGCF_EXTRA_REGS;
-    op.cmd = DOM0_SETVCPUCONTEXT;
-    op.u.setvcpucontext.domain = (domid_t)dom;
-    op.u.setvcpucontext.vcpu   = 0;
-    set_xen_guest_handle(op.u.setvcpucontext.ctxt, &ctxt);
-    if (xc_dom0_op(xc_handle, &op) != 0) {
+    domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    domctl.domain = (domid_t)dom;
+    domctl.u.vcpucontext.vcpu   = 0;
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt);
+    if (xc_domctl(xc_handle, &domctl) != 0) {
            ERR("Couldn't set vcpu context");
            goto out;
     }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/ia64/xc_ia64_linux_save.c
--- a/tools/libxc/ia64/xc_ia64_linux_save.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/ia64/xc_ia64_linux_save.c     Sun Aug 27 10:24:41 2006 -0600
@@ -60,7 +60,7 @@ static int xc_ia64_shadow_control(int xc
                                   unsigned int sop,
                                   unsigned long *dirty_bitmap,
                                   unsigned long pages,
-                                  xc_shadow_control_stats_t *stats)
+                                  xc_shadow_op_stats_t *stats)
 {
     if (dirty_bitmap != NULL && pages > 0) {
         int i;
@@ -137,7 +137,7 @@ xc_linux_save(int xc_handle, int io_fd, 
 xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
               uint32_t max_factor, uint32_t flags, int (*suspend)(int))
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     xc_dominfo_t info;
 
     int rc = 1;
@@ -242,15 +242,15 @@ xc_linux_save(int xc_handle, int io_fd, 
         }
     }
 
-    op.cmd = DOM0_DOMAIN_SETUP;
-    op.u.domain_setup.domain = (domid_t)dom;
-    op.u.domain_setup.flags = XEN_DOMAINSETUP_query;
-    if (xc_dom0_op(xc_handle, &op) < 0) {
+    domctl.cmd = XEN_DOMCTL_arch_setup;
+    domctl.domain = (domid_t)dom;
+    domctl.u.arch_setup.flags = XEN_DOMAINSETUP_query;
+    if (xc_domctl(xc_handle, &domctl) < 0) {
         ERR("Could not get domain setup");
         goto out;
     }
-    op.u.domain_setup.domain = 0;
-    if (!write_exact(io_fd, &op.u.domain_setup, sizeof(op.u.domain_setup))) {
+    if (!write_exact(io_fd, &domctl.u.arch_setup,
+                     sizeof(domctl.u.arch_setup))) {
         ERR("write: domain setup");
         goto out;
     }
@@ -259,7 +259,7 @@ xc_linux_save(int xc_handle, int io_fd, 
     if (live) {
 
         if (xc_ia64_shadow_control(xc_handle, dom,
-                                   DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY,
+                                   XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY,
                                    NULL, 0, NULL ) < 0) {
             ERR("Couldn't enable shadow mode");
             goto out;
@@ -324,7 +324,7 @@ xc_linux_save(int xc_handle, int io_fd, 
            but this is fast enough for the moment. */
         if (!last_iter) {
             if (xc_ia64_shadow_control(xc_handle, dom,
-                                       DOM0_SHADOW_CONTROL_OP_PEEK,
+                                       XEN_DOMCTL_SHADOW_OP_PEEK,
                                        to_skip, max_pfn, NULL) != max_pfn) {
                 ERR("Error peeking shadow bitmap");
                 goto out;
@@ -392,7 +392,7 @@ xc_linux_save(int xc_handle, int io_fd, 
 
             /* Pages to be sent are pages which were dirty.  */
             if (xc_ia64_shadow_control(xc_handle, dom,
-                                       DOM0_SHADOW_CONTROL_OP_CLEAN,
+                                       XEN_DOMCTL_SHADOW_OP_CLEAN,
                                        to_send, max_pfn, NULL ) != max_pfn) {
                 ERR("Error flushing shadow PT");
                 goto out;
@@ -481,7 +481,7 @@ xc_linux_save(int xc_handle, int io_fd, 
  out:
 
     if (live) {
-        if (xc_ia64_shadow_control(xc_handle, dom, DOM0_SHADOW_CONTROL_OP_OFF,
+        if (xc_ia64_shadow_control(xc_handle, dom, XEN_DOMCTL_SHADOW_OP_OFF,
                                    NULL, 0, NULL ) < 0) {
             DPRINTF("Warning - couldn't disable shadow mode");
         }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/ia64/xc_ia64_stubs.c
--- a/tools/libxc/ia64/xc_ia64_stubs.c  Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/ia64/xc_ia64_stubs.c  Sun Aug 27 10:24:41 2006 -0600
@@ -33,7 +33,7 @@ xc_ia64_get_pfn_list(int xc_handle, uint
 xc_ia64_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
                      unsigned int start_page, unsigned int nr_pages)
 {
-    dom0_op_t op;
+    struct xen_domctl domctl;
     int num_pfns,ret;
     unsigned int __start_page, __nr_pages;
     unsigned long max_pfns;
@@ -45,11 +45,11 @@ xc_ia64_get_pfn_list(int xc_handle, uint
   
     while (__nr_pages) {
         max_pfns = ((unsigned long)__start_page << 32) | __nr_pages;
-        op.cmd = DOM0_GETMEMLIST;
-        op.u.getmemlist.domain   = (domid_t)domid;
-        op.u.getmemlist.max_pfns = max_pfns;
-        op.u.getmemlist.num_pfns = 0;
-        set_xen_guest_handle(op.u.getmemlist.buffer, __pfn_buf);
+        domctl.cmd = XEN_DOMCTL_getmemlist;
+        domctl.domain   = (domid_t)domid;
+        domctl.u.getmemlist.max_pfns = max_pfns;
+        domctl.u.getmemlist.num_pfns = 0;
+        set_xen_guest_handle(domctl.u.getmemlist.buffer, __pfn_buf);
 
         if ((max_pfns != -1UL)
             && mlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t)) != 0) {
@@ -57,7 +57,7 @@ xc_ia64_get_pfn_list(int xc_handle, uint
             return -1;
         }
 
-        ret = do_dom0_op(xc_handle, &op);
+        ret = do_domctl(xc_handle, &domctl);
 
         if (max_pfns != -1UL)
             (void)munlock(__pfn_buf, __nr_pages * sizeof(xen_pfn_t));
@@ -65,7 +65,7 @@ xc_ia64_get_pfn_list(int xc_handle, uint
         if (max_pfns == -1UL)
             return 0;
         
-        num_pfns = op.u.getmemlist.num_pfns;
+        num_pfns = domctl.u.getmemlist.num_pfns;
         __start_page += num_pfns;
         __nr_pages -= num_pfns;
         __pfn_buf += num_pfns;
@@ -89,10 +89,10 @@ long
 long
 xc_get_max_pages(int xc_handle, uint32_t domid)
 {
-    dom0_op_t op;
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)domid;
-    return (do_dom0_op(xc_handle, &op) < 0) ? -1 : 
op.u.getdomaininfo.max_pages;
+    struct xen_domctl domctl;
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)domid;
+    return (do_domctl(xc_handle, &domctl) < 0) ? -1 : 
domctl.u.getdomaininfo.max_pages;
 }
 
 /*
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c    Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/powerpc64/xc_linux_build.c    Sun Aug 27 10:24:41 2006 -0600
@@ -27,7 +27,6 @@
 #include <sys/types.h>
 #include <inttypes.h>
 
-#include <xen/dom0_ops.h>
 #include <xen/memory.h>
 #include <xc_private.h>
 #include <xg_private.h>
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_csched.c
--- a/tools/libxc/xc_csched.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_csched.c   Sun Aug 27 10:24:41 2006 -0600
@@ -15,36 +15,36 @@ xc_sched_credit_domain_set(
 xc_sched_credit_domain_set(
     int xc_handle,
     uint32_t domid,
-    struct sched_credit_adjdom *sdom)
+    struct xen_domctl_sched_credit *sdom)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
 
-    op.cmd = DOM0_ADJUSTDOM;    
-    op.u.adjustdom.domain = (domid_t) domid;
-    op.u.adjustdom.sched_id = SCHED_CREDIT;
-    op.u.adjustdom.direction = SCHED_INFO_PUT;
-    op.u.adjustdom.u.credit = *sdom;
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.domain = (domid_t) domid;
+    domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo;
+    domctl.u.scheduler_op.u.credit = *sdom;
 
-    return do_dom0_op(xc_handle, &op);
+    return do_domctl(xc_handle, &domctl);
 }
 
 int
 xc_sched_credit_domain_get(
     int xc_handle,
     uint32_t domid,
-    struct sched_credit_adjdom *sdom)
+    struct xen_domctl_sched_credit *sdom)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int err;
 
-    op.cmd = DOM0_ADJUSTDOM;    
-    op.u.adjustdom.domain = (domid_t) domid;
-    op.u.adjustdom.sched_id = SCHED_CREDIT;
-    op.u.adjustdom.direction = SCHED_INFO_GET;
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.domain = (domid_t) domid;
+    domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_CREDIT;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
 
-    err = do_dom0_op(xc_handle, &op);
+    err = do_domctl(xc_handle, &domctl);
     if ( err == 0 )
-        *sdom = op.u.adjustdom.u.credit;
+        *sdom = domctl.u.scheduler_op.u.credit;
 
     return err;
 }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_domain.c   Sun Aug 27 10:24:41 2006 -0600
@@ -15,16 +15,16 @@ int xc_domain_create(int xc_handle,
                      uint32_t *pdomid)
 {
     int err;
-    DECLARE_DOM0_OP;
-
-    op.cmd = DOM0_CREATEDOMAIN;
-    op.u.createdomain.domain = (domid_t)*pdomid;
-    op.u.createdomain.ssidref = ssidref;
-    memcpy(op.u.createdomain.handle, handle, sizeof(xen_domain_handle_t));
-    if ( (err = do_dom0_op(xc_handle, &op)) != 0 )
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_createdomain;
+    domctl.domain = (domid_t)*pdomid;
+    domctl.u.createdomain.ssidref = ssidref;
+    memcpy(domctl.u.createdomain.handle, handle, sizeof(xen_domain_handle_t));
+    if ( (err = do_domctl(xc_handle, &domctl)) != 0 )
         return err;
 
-    *pdomid = (uint16_t)op.u.createdomain.domain;
+    *pdomid = (uint16_t)domctl.domain;
     return 0;
 }
 
@@ -32,30 +32,30 @@ int xc_domain_pause(int xc_handle,
 int xc_domain_pause(int xc_handle,
                     uint32_t domid)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_PAUSEDOMAIN;
-    op.u.pausedomain.domain = (domid_t)domid;
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_pausedomain;
+    domctl.domain = (domid_t)domid;
+    return do_domctl(xc_handle, &domctl);
 }
 
 
 int xc_domain_unpause(int xc_handle,
                       uint32_t domid)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_UNPAUSEDOMAIN;
-    op.u.unpausedomain.domain = (domid_t)domid;
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_unpausedomain;
+    domctl.domain = (domid_t)domid;
+    return do_domctl(xc_handle, &domctl);
 }
 
 
 int xc_domain_destroy(int xc_handle,
                       uint32_t domid)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_DESTROYDOMAIN;
-    op.u.destroydomain.domain = (domid_t)domid;
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_destroydomain;
+    domctl.domain = (domid_t)domid;
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_domain_shutdown(int xc_handle,
@@ -90,14 +90,62 @@ int xc_vcpu_setaffinity(int xc_handle,
 int xc_vcpu_setaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        cpumap_t cpumap)
-{
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_SETVCPUAFFINITY;
-    op.u.setvcpuaffinity.domain  = (domid_t)domid;
-    op.u.setvcpuaffinity.vcpu    = vcpu;
-    op.u.setvcpuaffinity.cpumap  = cpumap;
-    return do_dom0_op(xc_handle, &op);
+                        uint64_t cpumap)
+{
+    DECLARE_DOMCTL;
+    int ret = -1;
+
+    domctl.cmd = XEN_DOMCTL_setvcpuaffinity;
+    domctl.domain = (domid_t)domid;
+    domctl.u.vcpuaffinity.vcpu    = vcpu;
+
+    set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap,
+                         (uint8_t *)&cpumap);
+    domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(cpumap) * 8;
+    
+    if ( mlock(&cpumap, sizeof(cpumap)) != 0 )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        goto out;
+    }
+
+    ret = do_domctl(xc_handle, &domctl);
+
+    safe_munlock(&cpumap, sizeof(cpumap));
+
+ out:
+    return ret;
+}
+
+
+int xc_vcpu_getaffinity(int xc_handle,
+                        uint32_t domid,
+                        int vcpu,
+                        uint64_t *cpumap)
+{
+    DECLARE_DOMCTL;
+    int ret = -1;
+
+    domctl.cmd = XEN_DOMCTL_getvcpuaffinity;
+    domctl.domain = (domid_t)domid;
+    domctl.u.vcpuaffinity.vcpu = vcpu;
+
+    set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap,
+                         (uint8_t *)cpumap);
+    domctl.u.vcpuaffinity.cpumap.nr_cpus = sizeof(*cpumap) * 8;
+    
+    if ( mlock(cpumap, sizeof(*cpumap)) != 0 )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        goto out;
+    }
+
+    ret = do_domctl(xc_handle, &domctl);
+
+    safe_munlock(cpumap, sizeof(*cpumap));
+
+ out:
+    return ret;
 }
 
 
@@ -108,27 +156,27 @@ int xc_domain_getinfo(int xc_handle,
 {
     unsigned int nr_doms;
     uint32_t next_domid = first_domid;
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int rc = 0;
 
     memset(info, 0, max_doms*sizeof(xc_dominfo_t));
 
     for ( nr_doms = 0; nr_doms < max_doms; nr_doms++ )
     {
-        op.cmd = DOM0_GETDOMAININFO;
-        op.u.getdomaininfo.domain = (domid_t)next_domid;
-        if ( (rc = do_dom0_op(xc_handle, &op)) < 0 )
+        domctl.cmd = XEN_DOMCTL_getdomaininfo;
+        domctl.domain = (domid_t)next_domid;
+        if ( (rc = do_domctl(xc_handle, &domctl)) < 0 )
             break;
-        info->domid      = (uint16_t)op.u.getdomaininfo.domain;
-
-        info->dying    = !!(op.u.getdomaininfo.flags & DOMFLAGS_DYING);
-        info->shutdown = !!(op.u.getdomaininfo.flags & DOMFLAGS_SHUTDOWN);
-        info->paused   = !!(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED);
-        info->blocked  = !!(op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
-        info->running  = !!(op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
+        info->domid      = (uint16_t)domctl.domain;
+
+        info->dying    = !!(domctl.u.getdomaininfo.flags & DOMFLAGS_DYING);
+        info->shutdown = !!(domctl.u.getdomaininfo.flags & DOMFLAGS_SHUTDOWN);
+        info->paused   = !!(domctl.u.getdomaininfo.flags & DOMFLAGS_PAUSED);
+        info->blocked  = !!(domctl.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
+        info->running  = !!(domctl.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
 
         info->shutdown_reason =
-            (op.u.getdomaininfo.flags>>DOMFLAGS_SHUTDOWNSHIFT) &
+            (domctl.u.getdomaininfo.flags>>DOMFLAGS_SHUTDOWNSHIFT) &
             DOMFLAGS_SHUTDOWNMASK;
 
         if ( info->shutdown && (info->shutdown_reason == SHUTDOWN_crash) )
@@ -137,18 +185,18 @@ int xc_domain_getinfo(int xc_handle,
             info->crashed  = 1;
         }
 
-        info->ssidref  = op.u.getdomaininfo.ssidref;
-        info->nr_pages = op.u.getdomaininfo.tot_pages;
-        info->max_memkb = op.u.getdomaininfo.max_pages << (PAGE_SHIFT - 10);
-        info->shared_info_frame = op.u.getdomaininfo.shared_info_frame;
-        info->cpu_time = op.u.getdomaininfo.cpu_time;
-        info->nr_online_vcpus = op.u.getdomaininfo.nr_online_vcpus;
-        info->max_vcpu_id = op.u.getdomaininfo.max_vcpu_id;
-
-        memcpy(info->handle, op.u.getdomaininfo.handle,
+        info->ssidref  = domctl.u.getdomaininfo.ssidref;
+        info->nr_pages = domctl.u.getdomaininfo.tot_pages;
+        info->max_memkb = domctl.u.getdomaininfo.max_pages << (PAGE_SHIFT-10);
+        info->shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
+        info->cpu_time = domctl.u.getdomaininfo.cpu_time;
+        info->nr_online_vcpus = domctl.u.getdomaininfo.nr_online_vcpus;
+        info->max_vcpu_id = domctl.u.getdomaininfo.max_vcpu_id;
+
+        memcpy(info->handle, domctl.u.getdomaininfo.handle,
                sizeof(xen_domain_handle_t));
 
-        next_domid = (uint16_t)op.u.getdomaininfo.domain + 1;
+        next_domid = (uint16_t)domctl.domain + 1;
         info++;
     }
 
@@ -163,20 +211,20 @@ int xc_domain_getinfolist(int xc_handle,
                           xc_domaininfo_t *info)
 {
     int ret = 0;
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
     if ( mlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0 )
         return -1;
 
-    op.cmd = DOM0_GETDOMAININFOLIST;
-    op.u.getdomaininfolist.first_domain = first_domain;
-    op.u.getdomaininfolist.max_domains  = max_domains;
-    set_xen_guest_handle(op.u.getdomaininfolist.buffer, info);
-
-    if ( xc_dom0_op(xc_handle, &op) < 0 )
+    sysctl.cmd = XEN_SYSCTL_getdomaininfolist;
+    sysctl.u.getdomaininfolist.first_domain = first_domain;
+    sysctl.u.getdomaininfolist.max_domains  = max_domains;
+    set_xen_guest_handle(sysctl.u.getdomaininfolist.buffer, info);
+
+    if ( xc_sysctl(xc_handle, &sysctl) < 0 )
         ret = -1;
     else
-        ret = op.u.getdomaininfolist.num_domains;
+        ret = sysctl.u.getdomaininfolist.num_domains;
 
     if ( munlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0 )
         ret = -1;
@@ -190,17 +238,17 @@ int xc_vcpu_getcontext(int xc_handle,
                                vcpu_guest_context_t *ctxt)
 {
     int rc;
-    DECLARE_DOM0_OP;
-
-    op.cmd = DOM0_GETVCPUCONTEXT;
-    op.u.getvcpucontext.domain = (domid_t)domid;
-    op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    set_xen_guest_handle(op.u.getvcpucontext.ctxt, ctxt);
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_getvcpucontext;
+    domctl.domain = (domid_t)domid;
+    domctl.u.vcpucontext.vcpu   = (uint16_t)vcpu;
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
 
-    rc = do_dom0_op(xc_handle, &op);
+    rc = do_domctl(xc_handle, &domctl);
 
     safe_munlock(ctxt, sizeof(*ctxt));
 
@@ -215,28 +263,28 @@ int xc_shadow_control(int xc_handle,
                       unsigned long pages,
                       unsigned long *mb,
                       uint32_t mode,
-                      xc_shadow_control_stats_t *stats)
+                      xc_shadow_op_stats_t *stats)
 {
     int rc;
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_SHADOW_CONTROL;
-    op.u.shadow_control.domain = (domid_t)domid;
-    op.u.shadow_control.op     = sop;
-    op.u.shadow_control.pages  = pages;
-    op.u.shadow_control.mb     = mb ? *mb : 0;
-    op.u.shadow_control.mode   = mode;
-    set_xen_guest_handle(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
-
-    rc = do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_shadow_op;
+    domctl.domain = (domid_t)domid;
+    domctl.u.shadow_op.op     = sop;
+    domctl.u.shadow_op.pages  = pages;
+    domctl.u.shadow_op.mb     = mb ? *mb : 0;
+    domctl.u.shadow_op.mode   = mode;
+    set_xen_guest_handle(domctl.u.shadow_op.dirty_bitmap, dirty_bitmap);
+
+    rc = do_domctl(xc_handle, &domctl);
 
     if ( stats )
-        memcpy(stats, &op.u.shadow_control.stats,
-               sizeof(xc_shadow_control_stats_t));
+        memcpy(stats, &domctl.u.shadow_op.stats,
+               sizeof(xc_shadow_op_stats_t));
     
     if ( mb ) 
-        *mb = op.u.shadow_control.mb;
-
-    return (rc == 0) ? op.u.shadow_control.pages : rc;
+        *mb = domctl.u.shadow_op.mb;
+
+    return (rc == 0) ? domctl.u.shadow_op.pages : rc;
 }
 
 int xc_domain_setcpuweight(int xc_handle,
@@ -250,58 +298,30 @@ int xc_domain_setcpuweight(int xc_handle
     if ( (ret = xc_sched_id(xc_handle, &sched_id)) != 0 )
         return ret;
 
-    switch ( sched_id )
-    {
-        case SCHED_BVT:
-        {
-            uint32_t mcuadv;
-            int warpback;
-            int32_t warpvalue;
-            long long warpl;
-            long long warpu;
-
-            /* Preserve all the scheduling parameters apart
-               of MCU advance. */
-            if ( (ret = xc_bvtsched_domain_get(
-                xc_handle, domid, &mcuadv,
-                &warpback, &warpvalue, &warpl, &warpu)) != 0 )
-                return ret;
-
-            /* The MCU advance is inverse of the weight.
-               Default value of the weight is 1, default mcuadv 10.
-               The scaling factor is therefore 10. */
-            if ( weight > 0 )
-                mcuadv = 10 / weight;
-
-            ret = xc_bvtsched_domain_set(xc_handle, domid, mcuadv,
-                                         warpback, warpvalue, warpl, warpu);
-            break;
-        }
-    }
-
-    return ret;
+    /* No-op. */
+    return 0;
 }
 
 int xc_domain_setmaxmem(int xc_handle,
                         uint32_t domid,
                         unsigned int max_memkb)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_SETDOMAINMAXMEM;
-    op.u.setdomainmaxmem.domain = (domid_t)domid;
-    op.u.setdomainmaxmem.max_memkb = max_memkb;
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_max_mem;
+    domctl.domain = (domid_t)domid;
+    domctl.u.max_mem.max_memkb = max_memkb;
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_domain_set_time_offset(int xc_handle,
                               uint32_t domid,
                               int32_t time_offset_seconds)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_SETTIMEOFFSET;
-    op.u.settimeoffset.domain = (domid_t)domid;
-    op.u.settimeoffset.time_offset_seconds = time_offset_seconds;
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_settimeoffset;
+    domctl.domain = (domid_t)domid;
+    domctl.u.settimeoffset.time_offset_seconds = time_offset_seconds;
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_domain_memory_increase_reservation(int xc_handle,
@@ -425,21 +445,22 @@ int xc_domain_translate_gpfn_list(int xc
 
 int xc_domain_max_vcpus(int xc_handle, uint32_t domid, unsigned int max)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_MAX_VCPUS;
-    op.u.max_vcpus.domain = (domid_t)domid;
-    op.u.max_vcpus.max    = max;
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_max_vcpus;
+    domctl.domain = (domid_t)domid;
+    domctl.u.max_vcpus.max    = max;
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_domain_sethandle(int xc_handle, uint32_t domid,
                         xen_domain_handle_t handle)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_SETDOMAINHANDLE;
-    op.u.setdomainhandle.domain = (domid_t)domid;
-    memcpy(op.u.setdomainhandle.handle, handle, sizeof(xen_domain_handle_t));
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_setdomainhandle;
+    domctl.domain = (domid_t)domid;
+    memcpy(domctl.u.setdomainhandle.handle, handle,
+           sizeof(xen_domain_handle_t));
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_vcpu_getinfo(int xc_handle,
@@ -448,14 +469,15 @@ int xc_vcpu_getinfo(int xc_handle,
                     xc_vcpuinfo_t *info)
 {
     int rc;
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_GETVCPUINFO;
-    op.u.getvcpuinfo.domain = (domid_t)domid;
-    op.u.getvcpuinfo.vcpu   = (uint16_t)vcpu;
-
-    rc = do_dom0_op(xc_handle, &op);
-
-    memcpy(info, &op.u.getvcpuinfo, sizeof(*info));
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_getvcpuinfo;
+    domctl.domain = (domid_t)domid;
+    domctl.u.getvcpuinfo.vcpu   = (uint16_t)vcpu;
+
+    rc = do_domctl(xc_handle, &domctl);
+
+    memcpy(info, &domctl.u.getvcpuinfo, sizeof(*info));
 
     return rc;
 }
@@ -466,15 +488,15 @@ int xc_domain_ioport_permission(int xc_h
                                 uint32_t nr_ports,
                                 uint32_t allow_access)
 {
-    DECLARE_DOM0_OP;
-
-    op.cmd = DOM0_IOPORT_PERMISSION;
-    op.u.ioport_permission.domain = (domid_t)domid;
-    op.u.ioport_permission.first_port = first_port;
-    op.u.ioport_permission.nr_ports = nr_ports;
-    op.u.ioport_permission.allow_access = allow_access;
-
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_ioport_permission;
+    domctl.domain = (domid_t)domid;
+    domctl.u.ioport_permission.first_port = first_port;
+    domctl.u.ioport_permission.nr_ports = nr_ports;
+    domctl.u.ioport_permission.allow_access = allow_access;
+
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_vcpu_setcontext(int xc_handle,
@@ -482,18 +504,18 @@ int xc_vcpu_setcontext(int xc_handle,
                        uint32_t vcpu,
                        vcpu_guest_context_t *ctxt)
 {
-    dom0_op_t op;
+    DECLARE_DOMCTL;
     int rc;
 
-    op.cmd = DOM0_SETVCPUCONTEXT;
-    op.u.setvcpucontext.domain = domid;
-    op.u.setvcpucontext.vcpu = vcpu;
-    set_xen_guest_handle(op.u.setvcpucontext.ctxt, ctxt);
+    domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    domctl.domain = domid;
+    domctl.u.vcpucontext.vcpu = vcpu;
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
 
-    rc = do_dom0_op(xc_handle, &op);
+    rc = do_domctl(xc_handle, &domctl);
 
     safe_munlock(ctxt, sizeof(*ctxt));
 
@@ -506,14 +528,14 @@ int xc_domain_irq_permission(int xc_hand
                              uint8_t pirq,
                              uint8_t allow_access)
 {
-    dom0_op_t op;
-
-    op.cmd = DOM0_IRQ_PERMISSION;
-    op.u.irq_permission.domain = domid;
-    op.u.irq_permission.pirq = pirq;
-    op.u.irq_permission.allow_access = allow_access;
-
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_irq_permission;
+    domctl.domain = domid;
+    domctl.u.irq_permission.pirq = pirq;
+    domctl.u.irq_permission.allow_access = allow_access;
+
+    return do_domctl(xc_handle, &domctl);
 }
 
 int xc_domain_iomem_permission(int xc_handle,
@@ -522,15 +544,15 @@ int xc_domain_iomem_permission(int xc_ha
                                unsigned long nr_mfns,
                                uint8_t allow_access)
 {
-    dom0_op_t op;
-
-    op.cmd = DOM0_IOMEM_PERMISSION;
-    op.u.iomem_permission.domain = domid;
-    op.u.iomem_permission.first_mfn = first_mfn;
-    op.u.iomem_permission.nr_mfns = nr_mfns;
-    op.u.iomem_permission.allow_access = allow_access;
-
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_iomem_permission;
+    domctl.domain = domid;
+    domctl.u.iomem_permission.first_mfn = first_mfn;
+    domctl.u.iomem_permission.nr_mfns = nr_mfns;
+    domctl.u.iomem_permission.allow_access = allow_access;
+
+    return do_domctl(xc_handle, &domctl);
 }
 
 /*
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_hvm_build.c        Sun Aug 27 10:24:41 2006 -0600
@@ -395,7 +395,7 @@ static int xc_hvm_build_internal(int xc_
                                  unsigned int store_evtchn,
                                  unsigned long *store_mfn)
 {
-    dom0_op_t launch_op, op;
+    struct xen_domctl launch_domctl, domctl;
     int rc, i;
     vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
     unsigned long nr_pages;
@@ -432,21 +432,21 @@ static int xc_hvm_build_internal(int xc_
         return 1;
     }
 
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)domid;
-    if ( (xc_dom0_op(xc_handle, &op) < 0) ||
-         ((uint16_t)op.u.getdomaininfo.domain != domid) )
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)domid;
+    if ( (xc_domctl(xc_handle, &domctl) < 0) ||
+         ((uint16_t)domctl.domain != domid) )
     {
         PERROR("Could not get info on domain");
         goto error_out;
     }
 
     /* HVM domains must be put into shadow2 mode at the start of day */
-    if ( xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_ENABLE,
+    if ( xc_shadow_control(xc_handle, domid, XEN_DOMCTL_SHADOW_OP_ENABLE,
                            NULL, 0, NULL, 
-                           DOM0_SHADOW_ENABLE_REFCOUNT  |
-                           DOM0_SHADOW_ENABLE_TRANSLATE |
-                           DOM0_SHADOW_ENABLE_EXTERNAL, 
+                           XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  |
+                           XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE |
+                           XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL, 
                            NULL) )
     {
         PERROR("Could not enable shadow paging for domain.\n");
@@ -457,7 +457,7 @@ static int xc_hvm_build_internal(int xc_
 
     ctxt->flags = VGCF_HVM_GUEST;
     if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
-                     ctxt, op.u.getdomaininfo.shared_info_frame,
+                     ctxt, domctl.u.getdomaininfo.shared_info_frame,
                      vcpus, pae, acpi, apic, store_evtchn, store_mfn) < 0)
     {
         ERROR("Error constructing guest OS");
@@ -495,14 +495,14 @@ static int xc_hvm_build_internal(int xc_
     ctxt->syscall_callback_eip  = 0;
 #endif
 
-    memset( &launch_op, 0, sizeof(launch_op) );
-
-    launch_op.u.setvcpucontext.domain = (domid_t)domid;
-    launch_op.u.setvcpucontext.vcpu   = 0;
-    set_xen_guest_handle(launch_op.u.setvcpucontext.ctxt, ctxt);
-
-    launch_op.cmd = DOM0_SETVCPUCONTEXT;
-    rc = xc_dom0_op(xc_handle, &launch_op);
+    memset(&launch_domctl, 0, sizeof(launch_domctl));
+
+    launch_domctl.domain = (domid_t)domid;
+    launch_domctl.u.vcpucontext.vcpu   = 0;
+    set_xen_guest_handle(launch_domctl.u.vcpucontext.ctxt, ctxt);
+
+    launch_domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    rc = xc_domctl(xc_handle, &launch_domctl);
 
     return rc;
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_linux_build.c      Sun Aug 27 10:24:41 2006 -0600
@@ -474,7 +474,7 @@ static int setup_guest(int xc_handle,
     struct xen_ia64_boot_param *bp;
     shared_info_t *shared_info;
     int i;
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int rc;
 
     rc = probeimageformat(image, image_size, &load_funcs);
@@ -494,14 +494,13 @@ static int setup_guest(int xc_handle,
     start_info_mpa = (nr_pages - 3) << PAGE_SHIFT;
 
     /* Build firmware.  */
-    memset(&op.u.domain_setup, 0, sizeof(op.u.domain_setup));
-    op.u.domain_setup.flags = 0;
-    op.u.domain_setup.domain = (domid_t)dom;
-    op.u.domain_setup.bp = start_info_mpa + sizeof (start_info_t);
-    op.u.domain_setup.maxmem = (nr_pages - 3) << PAGE_SHIFT;
-    
-    op.cmd = DOM0_DOMAIN_SETUP;
-    if ( xc_dom0_op(xc_handle, &op) )
+    memset(&domctl.u.arch_setup, 0, sizeof(domctl.u.arch_setup));
+    domctl.u.arch_setup.flags = 0;
+    domctl.u.arch_setup.bp = start_info_mpa + sizeof (start_info_t);
+    domctl.u.arch_setup.maxmem = (nr_pages - 3) << PAGE_SHIFT;
+    domctl.cmd = XEN_DOMCTL_arch_setup;
+    domctl.domain = (domid_t)dom;
+    if ( xc_domctl(xc_handle, &domctl) )
         goto error_out;
 
     start_page = dsi.v_start >> PAGE_SHIFT;
@@ -655,12 +654,14 @@ static int setup_guest(int xc_handle,
                        uint32_t required_features[XENFEAT_NR_SUBMAPS])
 {
     xen_pfn_t *page_array = NULL;
-    unsigned long count, i, hypercall_pfn;
+    unsigned long count, i;
+    unsigned long long hypercall_page;
+    int hypercall_page_defined;
     start_info_t *start_info;
     shared_info_t *shared_info;
     xc_mmu_t *mmu = NULL;
-    char *p;
-    DECLARE_DOM0_OP;
+    const char *p;
+    DECLARE_DOMCTL;
     int rc;
 
     unsigned long nr_pt_pages;
@@ -704,12 +705,9 @@ static int setup_guest(int xc_handle,
         goto error_out;
 
     /* Parse and validate kernel features. */
-    p = strstr(dsi.xen_guest_string, "FEATURES=");
-    if ( p != NULL )
-    {
-        if ( !parse_features(p + strlen("FEATURES="),
-                             supported_features,
-                             required_features) )
+    if ( (p = xen_elfnote_string(&dsi, XEN_ELFNOTE_FEATURES)) != NULL )
+    {
+        if ( !parse_features(p, supported_features, required_features) )
         {
             ERROR("Failed to parse guest kernel features.");
             goto error_out;
@@ -967,7 +965,7 @@ static int setup_guest(int xc_handle,
 
         /* Enable shadow translate mode */
         if ( xc_shadow_control(xc_handle, dom,
-                               DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE,
+                               XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE,
                                NULL, 0, NULL, 0, NULL) < 0 )
         {
             PERROR("Could not enable translation mode");
@@ -1071,18 +1069,18 @@ static int setup_guest(int xc_handle,
     if ( xc_finish_mmu_updates(xc_handle, mmu) )
         goto error_out;
 
-    p = strstr(dsi.xen_guest_string, "HYPERCALL_PAGE=");
-    if ( p != NULL )
-    {
-        p += strlen("HYPERCALL_PAGE=");
-        hypercall_pfn = strtoul(p, NULL, 16);
-        if ( hypercall_pfn >= nr_pages )
-            goto error_out;
-        op.u.hypercall_init.domain = (domid_t)dom;
-        op.u.hypercall_init.gmfn   = shadow_mode_enabled ?
-            hypercall_pfn : page_array[hypercall_pfn];
-        op.cmd = DOM0_HYPERCALL_INIT;
-        if ( xc_dom0_op(xc_handle, &op) )
+    hypercall_page = xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE,
+                                         &hypercall_page_defined);
+    if ( hypercall_page_defined )
+    {
+        unsigned long long pfn = (hypercall_page - dsi.v_start) >> PAGE_SHIFT;
+        if ( pfn >= nr_pages )
+            goto error_out;
+        domctl.domain = (domid_t)dom;
+        domctl.u.hypercall_init.gmfn   = shadow_mode_enabled ?
+            pfn : page_array[pfn];
+        domctl.cmd = XEN_DOMCTL_hypercall_init;
+        if ( xc_domctl(xc_handle, &domctl) )
             goto error_out;
     }
 
@@ -1115,8 +1113,8 @@ static int xc_linux_build_internal(int x
                                    unsigned int console_evtchn,
                                    unsigned long *console_mfn)
 {
-    dom0_op_t launch_op;
-    DECLARE_DOM0_OP;
+    struct xen_domctl launch_domctl;
+    DECLARE_DOMCTL;
     int rc, i;
     vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
     unsigned long nr_pages;
@@ -1148,10 +1146,10 @@ static int xc_linux_build_internal(int x
         return 1;
     }
 
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)domid;
-    if ( (xc_dom0_op(xc_handle, &op) < 0) ||
-         ((uint16_t)op.u.getdomaininfo.domain != domid) )
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)domid;
+    if ( (xc_domctl(xc_handle, &domctl) < 0) ||
+         ((uint16_t)domctl.domain != domid) )
     {
         PERROR("Could not get info on domain");
         goto error_out;
@@ -1164,7 +1162,7 @@ static int xc_linux_build_internal(int x
                      nr_pages,
                      &vstartinfo_start, &vkern_entry,
                      &vstack_start, ctxt, cmdline,
-                     op.u.getdomaininfo.shared_info_frame,
+                     domctl.u.getdomaininfo.shared_info_frame,
                      flags, store_evtchn, store_mfn,
                      console_evtchn, console_mfn,
                      features_bitmap) < 0 )
@@ -1240,14 +1238,14 @@ static int xc_linux_build_internal(int x
 #endif
 #endif /* x86 */
 
-    memset( &launch_op, 0, sizeof(launch_op) );
-
-    launch_op.u.setvcpucontext.domain = (domid_t)domid;
-    launch_op.u.setvcpucontext.vcpu   = 0;
-    set_xen_guest_handle(launch_op.u.setvcpucontext.ctxt, ctxt);
-
-    launch_op.cmd = DOM0_SETVCPUCONTEXT;
-    rc = xc_dom0_op(xc_handle, &launch_op);
+    memset( &launch_domctl, 0, sizeof(launch_domctl) );
+
+    launch_domctl.domain = (domid_t)domid;
+    launch_domctl.u.vcpucontext.vcpu   = 0;
+    set_xen_guest_handle(launch_domctl.u.vcpucontext.ctxt, ctxt);
+
+    launch_domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    rc = xc_domctl(xc_handle, &launch_domctl);
 
     return rc;
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_linux_restore.c    Sun Aug 27 10:24:41 2006 -0600
@@ -107,7 +107,7 @@ int xc_linux_restore(int xc_handle, int 
                      unsigned int store_evtchn, unsigned long *store_mfn,
                      unsigned int console_evtchn, unsigned long *console_mfn)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int rc = 1, i, n, pae_extended_cr3 = 0;
     unsigned long mfn, pfn;
     unsigned int prev_pc, this_pc;
@@ -163,7 +163,7 @@ int xc_linux_restore(int xc_handle, int 
     }
 
     if (mlock(&ctxt, sizeof(ctxt))) {
-        /* needed for build dom0 op, but might as well do early */
+        /* needed for build domctl, but might as well do early */
         ERR("Unable to mlock ctxt");
         return 1;
     }
@@ -257,13 +257,13 @@ int xc_linux_restore(int xc_handle, int 
     }
 
     /* Get the domain's shared-info frame. */
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)dom;
-    if (xc_dom0_op(xc_handle, &op) < 0) {
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)dom;
+    if (xc_domctl(xc_handle, &domctl) < 0) {
         ERR("Could not get information on new domain");
         goto out;
     }
-    shared_info_frame = op.u.getdomaininfo.shared_info_frame;
+    shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
 
     if(xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) {
         errno = ENOMEM;
@@ -337,17 +337,22 @@ int xc_linux_restore(int xc_handle, int 
             goto out;
         }
 
-        for (i = 0; i < j; i++) {
-
-            if ((region_pfn_type[i] & LTAB_MASK) == XTAB)
+        for ( i = 0; i < j; i++ )
+        {
+            unsigned long pfn, pagetype;
+            pfn      = region_pfn_type[i] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+            pagetype = region_pfn_type[i] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
+
+            if ( pagetype == XEN_DOMCTL_PFINFO_XTAB)
                 region_mfn[i] = 0; /* we know map will fail, but don't care */
             else
-                region_mfn[i] = p2m[region_pfn_type[i] & ~LTAB_MASK];
-
-        }
-
-        if (!(region_base = xc_map_foreign_batch(
-                  xc_handle, dom, PROT_WRITE, region_mfn, j))) {
+                region_mfn[i] = p2m[pfn];
+        }
+
+        region_base = xc_map_foreign_batch(
+            xc_handle, dom, PROT_WRITE, region_mfn, j);
+        if ( region_base == NULL )
+        {
             ERR("map batch failed");
             goto out;
         }
@@ -357,14 +362,15 @@ int xc_linux_restore(int xc_handle, int 
             void *page;
             unsigned long pagetype;
 
-            pfn      = region_pfn_type[i] & ~LTAB_MASK;
-            pagetype = region_pfn_type[i] & LTAB_MASK;
-
-            if (pagetype == XTAB)
+            pfn      = region_pfn_type[i] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+            pagetype = region_pfn_type[i] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
+
+            if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
                 /* a bogus/unmapped page: skip it */
                 continue;
 
-            if (pfn > max_pfn) {
+            if ( pfn > max_pfn )
+            {
                 ERR("pfn out of range");
                 goto out;
             }
@@ -381,10 +387,11 @@ int xc_linux_restore(int xc_handle, int 
                 goto out;
             }
 
-            pagetype &= LTABTYPE_MASK;
-
-            if(pagetype >= L1TAB && pagetype <= L4TAB) {
-
+            pagetype &= XEN_DOMCTL_PFINFO_LTABTYPE_MASK;
+
+            if ( (pagetype >= XEN_DOMCTL_PFINFO_L1TAB) && 
+                 (pagetype <= XEN_DOMCTL_PFINFO_L4TAB) )
+            {
                 /*
                 ** A page table page - need to 'uncanonicalize' it, i.e.
                 ** replace all the references to pfns with the corresponding
@@ -396,7 +403,7 @@ int xc_linux_restore(int xc_handle, int 
                 */
                 if ((pt_levels != 3) ||
                     pae_extended_cr3 ||
-                    (pagetype != L1TAB)) {
+                    (pagetype != XEN_DOMCTL_PFINFO_L1TAB)) {
 
                     if (!uncanonicalize_pagetable(pagetype, page)) {
                         /*
@@ -412,8 +419,9 @@ int xc_linux_restore(int xc_handle, int 
 
                 }
 
-            } else if(pagetype != NOTAB) {
-
+            }
+            else if ( pagetype != XEN_DOMCTL_PFINFO_NOTAB )
+            {
                 ERR("Bogus page type %lx page table is out of range: "
                     "i=%d max_pfn=%lu", pagetype, i, max_pfn);
                 goto out;
@@ -484,10 +492,12 @@ int xc_linux_restore(int xc_handle, int 
         int j, k;
 
         /* First pass: find all L3TABs current in > 4G mfns and get new mfns */
-        for (i = 0; i < max_pfn; i++) {
-
-            if (((pfn_type[i] & LTABTYPE_MASK)==L3TAB) && (p2m[i]>0xfffffUL)) {
-
+        for ( i = 0; i < max_pfn; i++ )
+        {
+            if ( ((pfn_type[i] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) ==
+                  XEN_DOMCTL_PFINFO_L3TAB) &&
+                 (p2m[i] > 0xfffffUL) )
+            {
                 unsigned long new_mfn;
                 uint64_t l3ptes[4];
                 uint64_t *l3tab;
@@ -530,9 +540,11 @@ int xc_linux_restore(int xc_handle, int 
         /* Second pass: find all L1TABs and uncanonicalize them */
         j = 0;
 
-        for(i = 0; i < max_pfn; i++) {
-
-            if (((pfn_type[i] & LTABTYPE_MASK)==L1TAB)) {
+        for ( i = 0; i < max_pfn; i++ )
+        {
+            if ( ((pfn_type[i] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) ==
+                  XEN_DOMCTL_PFINFO_L1TAB) )
+            {
                 region_mfn[j] = p2m[i];
                 j++;
             }
@@ -547,7 +559,7 @@ int xc_linux_restore(int xc_handle, int 
                 }
 
                 for(k = 0; k < j; k++) {
-                    if(!uncanonicalize_pagetable(L1TAB,
+                    if(!uncanonicalize_pagetable(XEN_DOMCTL_PFINFO_L1TAB,
                                                  region_base + k*PAGE_SIZE)) {
                         ERR("failed uncanonicalize pt!");
                         goto out;
@@ -570,26 +582,26 @@ int xc_linux_restore(int xc_handle, int 
      * will barf when doing the type-checking.
      */
     nr_pins = 0;
-    for (i = 0; i < max_pfn; i++) {
-
-        if ( (pfn_type[i] & LPINTAB) == 0 )
+    for ( i = 0; i < max_pfn; i++ )
+    {
+        if ( (pfn_type[i] & XEN_DOMCTL_PFINFO_LPINTAB) == 0 )
             continue;
 
-        switch (pfn_type[i]) {
-
-        case (L1TAB|LPINTAB):
+        switch ( pfn_type[i] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK )
+        {
+        case XEN_DOMCTL_PFINFO_L1TAB:
             pin[nr_pins].cmd = MMUEXT_PIN_L1_TABLE;
             break;
 
-        case (L2TAB|LPINTAB):
+        case XEN_DOMCTL_PFINFO_L2TAB:
             pin[nr_pins].cmd = MMUEXT_PIN_L2_TABLE;
             break;
 
-        case (L3TAB|LPINTAB):
+        case XEN_DOMCTL_PFINFO_L3TAB:
             pin[nr_pins].cmd = MMUEXT_PIN_L3_TABLE;
             break;
 
-        case (L4TAB|LPINTAB):
+        case XEN_DOMCTL_PFINFO_L4TAB:
             pin[nr_pins].cmd = MMUEXT_PIN_L4_TABLE;
             break;
 
@@ -678,7 +690,7 @@ int xc_linux_restore(int xc_handle, int 
 
     /* Uncanonicalise the suspend-record frame number and poke resume rec. */
     pfn = ctxt.user_regs.edx;
-    if ((pfn >= max_pfn) || (pfn_type[pfn] != NOTAB)) {
+    if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
         ERR("Suspend record frame number is bad");
         goto out;
     }
@@ -703,7 +715,7 @@ int xc_linux_restore(int xc_handle, int 
 
     for (i = 0; i < ctxt.gdt_ents; i += 512) {
         pfn = ctxt.gdt_frames[i];
-        if ((pfn >= max_pfn) || (pfn_type[pfn] != NOTAB)) {
+        if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
             ERR("GDT frame number is bad");
             goto out;
         }
@@ -719,11 +731,11 @@ int xc_linux_restore(int xc_handle, int 
         goto out;
     }
 
-    if ( (pfn_type[pfn] & LTABTYPE_MASK) !=
-         ((unsigned long)pt_levels<<LTAB_SHIFT) ) {
+    if ( (pfn_type[pfn] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) !=
+         ((unsigned long)pt_levels<<XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) {
         ERR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx",
             pfn, max_pfn, pfn_type[pfn],
-            (unsigned long)pt_levels<<LTAB_SHIFT);
+            (unsigned long)pt_levels<<XEN_DOMCTL_PFINFO_LTAB_SHIFT);
         goto out;
     }
 
@@ -744,7 +756,7 @@ int xc_linux_restore(int xc_handle, int 
     /* Uncanonicalise the pfn-to-mfn table frame-number list. */
     for (i = 0; i < P2M_FL_ENTRIES; i++) {
         pfn = p2m_frame_list[i];
-        if ((pfn >= max_pfn) || (pfn_type[pfn] != NOTAB)) {
+        if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
             ERR("PFN-to-MFN frame number is bad");
             goto out;
         }
@@ -797,11 +809,11 @@ int xc_linux_restore(int xc_handle, int 
 
     DPRINTF("Domain ready to be built.\n");
 
-    op.cmd = DOM0_SETVCPUCONTEXT;
-    op.u.setvcpucontext.domain = (domid_t)dom;
-    op.u.setvcpucontext.vcpu   = 0;
-    set_xen_guest_handle(op.u.setvcpucontext.ctxt, &ctxt);
-    rc = xc_dom0_op(xc_handle, &op);
+    domctl.cmd = XEN_DOMCTL_setvcpucontext;
+    domctl.domain = (domid_t)dom;
+    domctl.u.vcpucontext.vcpu   = 0;
+    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt);
+    rc = xc_domctl(xc_handle, &domctl);
 
     if (rc != 0) {
         ERR("Couldn't build the domain");
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c       Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_linux_save.c       Sun Aug 27 10:24:41 2006 -0600
@@ -271,7 +271,7 @@ static inline ssize_t write_exact(int fd
 
 
 static int print_stats(int xc_handle, uint32_t domid, int pages_sent,
-                       xc_shadow_control_stats_t *stats, int print)
+                       xc_shadow_op_stats_t *stats, int print)
 {
     static struct timeval wall_last;
     static long long      d0_cpu_last;
@@ -329,7 +329,7 @@ static int analysis_phase(int xc_handle,
                           unsigned long *arr, int runs)
 {
     long long start, now;
-    xc_shadow_control_stats_t stats;
+    xc_shadow_op_stats_t stats;
     int j;
 
     start = llgettimeofday();
@@ -337,13 +337,13 @@ static int analysis_phase(int xc_handle,
     for (j = 0; j < runs; j++) {
         int i;
 
-        xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_CLEAN,
+        xc_shadow_control(xc_handle, domid, XEN_DOMCTL_SHADOW_OP_CLEAN,
                           arr, max_pfn, NULL, 0, NULL);
         DPRINTF("#Flush\n");
         for ( i = 0; i < 40; i++ ) {
             usleep(50000);
             now = llgettimeofday();
-            xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_PEEK,
+            xc_shadow_control(xc_handle, domid, XEN_DOMCTL_SHADOW_OP_PEEK,
                               NULL, 0, NULL, 0, &stats);
 
             DPRINTF("now= %lld faults= %"PRId32" dirty= %"PRId32"\n",
@@ -427,10 +427,10 @@ int canonicalize_pagetable(unsigned long
     */
     xen_start = xen_end = pte_last = PAGE_SIZE / ((pt_levels == 2)? 4 : 8);
 
-    if (pt_levels == 2 && type == L2TAB)
+    if (pt_levels == 2 && type == XEN_DOMCTL_PFINFO_L2TAB)
         xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT);
 
-    if (pt_levels == 3 && type == L3TAB)
+    if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L3TAB)
         xen_start = L3_PAGETABLE_ENTRIES_PAE;
 
     /*
@@ -439,7 +439,7 @@ int canonicalize_pagetable(unsigned long
     ** Xen always ensures is present in that L2. Guests must ensure
     ** that this check will fail for other L2s.
     */
-    if (pt_levels == 3 && type == L2TAB) {
+    if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L2TAB) {
 
 /* XXX index of the L2 entry in PAE mode which holds the guest LPT */
 #define PAE_GLPT_L2ENTRY (495)
@@ -449,7 +449,7 @@ int canonicalize_pagetable(unsigned long
             xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
     }
 
-    if (pt_levels == 4 && type == L4TAB) {
+    if (pt_levels == 4 && type == XEN_DOMCTL_PFINFO_L4TAB) {
         /*
         ** XXX SMH: should compute these from hvirt_start (which we have)
         ** and hvirt_end (which we don't)
@@ -603,7 +603,7 @@ int xc_linux_save(int xc_handle, int io_
        - to fixup by sending at the end if not already resent; */
     unsigned long *to_send = NULL, *to_skip = NULL, *to_fix = NULL;
 
-    xc_shadow_control_stats_t stats;
+    xc_shadow_op_stats_t stats;
 
     unsigned long needed_to_fix = 0;
     unsigned long total_sent    = 0;
@@ -724,7 +724,7 @@ int xc_linux_save(int xc_handle, int io_
     if (live) {
 
         if (xc_shadow_control(xc_handle, dom,
-                              DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY,
+                              XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY,
                               NULL, 0, NULL, 0, NULL) < 0) {
             ERR("Couldn't enable shadow mode");
             goto out;
@@ -781,8 +781,8 @@ int xc_linux_save(int xc_handle, int io_
     analysis_phase(xc_handle, dom, max_pfn, to_skip, 0);
 
     /* We want zeroed memory so use calloc rather than malloc. */
-    pfn_type  = calloc(MAX_BATCH_SIZE, sizeof(unsigned long));
-    pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(unsigned long));
+    pfn_type  = calloc(MAX_BATCH_SIZE, sizeof(*pfn_type));
+    pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(*pfn_batch));
 
     if ((pfn_type == NULL) || (pfn_batch == NULL)) {
         ERR("failed to alloc memory for pfn_type and/or pfn_batch arrays");
@@ -790,11 +790,10 @@ int xc_linux_save(int xc_handle, int io_
         goto out;
     }
 
-    if (mlock(pfn_type, MAX_BATCH_SIZE * sizeof(unsigned long))) {
+    if (mlock(pfn_type, MAX_BATCH_SIZE * sizeof(*pfn_type))) {
         ERR("Unable to mlock");
         goto out;
     }
-
 
     /*
      * Quick belt and braces sanity check.
@@ -876,7 +875,7 @@ int xc_linux_save(int xc_handle, int io_
             /* slightly wasteful to peek the whole array evey time,
                but this is fast enough for the moment. */
             if (!last_iter && xc_shadow_control(
-                    xc_handle, dom, DOM0_SHADOW_CONTROL_OP_PEEK,
+                    xc_handle, dom, XEN_DOMCTL_SHADOW_OP_PEEK,
                     to_skip, max_pfn, NULL, 0, NULL) != max_pfn) {
                 ERR("Error peeking shadow bitmap");
                 goto out;
@@ -930,7 +929,7 @@ int xc_linux_save(int xc_handle, int io_
                 if(last_iter && test_bit(n, to_fix) && !test_bit(n, to_send)) {
                     needed_to_fix++;
                     DPRINTF("Fix! iter %d, pfn %x. mfn %lx\n",
-                            iter,n,pfn_type[batch]);
+                            iter, n, pfn_type[batch]);
                 }
 
                 clear_bit(n, to_fix);
@@ -952,9 +951,12 @@ int xc_linux_save(int xc_handle, int io_
                 goto out;
             }
 
-            for (j = 0; j < batch; j++) {
-
-                if ((pfn_type[j] & LTAB_MASK) == XTAB) {
+            for ( j = 0; j < batch; j++ )
+            {
+
+                if ( (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) ==
+                     XEN_DOMCTL_PFINFO_XTAB )
+                {
                     DPRINTF("type fail: page %i mfn %08lx\n", j, pfn_type[j]);
                     continue;
                 }
@@ -963,13 +965,16 @@ int xc_linux_save(int xc_handle, int io_
                     DPRINTF("%d pfn= %08lx mfn= %08lx [mfn]= %08lx"
                             " sum= %08lx\n",
                             iter,
-                            (pfn_type[j] & LTAB_MASK) | pfn_batch[j],
+                            (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) |
+                            pfn_batch[j],
                             pfn_type[j],
-                            mfn_to_pfn(pfn_type[j]&(~LTAB_MASK)),
+                            mfn_to_pfn(pfn_type[j] &
+                                       ~XEN_DOMCTL_PFINFO_LTAB_MASK),
                             csum_page(region_base + (PAGE_SIZE*j)));
 
                 /* canonicalise mfn->pfn */
-                pfn_type[j] = (pfn_type[j] & LTAB_MASK) | pfn_batch[j];
+                pfn_type[j] = (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) |
+                    pfn_batch[j];
             }
 
             if(!write_exact(io_fd, &batch, sizeof(unsigned int))) {
@@ -983,21 +988,23 @@ int xc_linux_save(int xc_handle, int io_
             }
 
             /* entering this loop, pfn_type is now in pfns (Not mfns) */
-            for (j = 0; j < batch; j++) {
-
-                unsigned long pfn      = pfn_type[j] & ~LTAB_MASK;
-                unsigned long pagetype = pfn_type[j] & LTAB_MASK;
-                void *spage            = (void *) region_base + (PAGE_SIZE*j);
-
+            for ( j = 0; j < batch; j++ )
+            {
+                unsigned long pfn, pagetype;
+                void *spage = (char *)region_base + (PAGE_SIZE*j);
+
+                pfn      = pfn_type[j] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
+                pagetype = pfn_type[j] &  XEN_DOMCTL_PFINFO_LTAB_MASK;
 
                 /* write out pages in batch */
-                if (pagetype == XTAB)
+                if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
                     continue;
 
-                pagetype &= LTABTYPE_MASK;
-
-                if (pagetype >= L1TAB && pagetype <= L4TAB) {
-
+                pagetype &= XEN_DOMCTL_PFINFO_LTABTYPE_MASK;
+
+                if ( (pagetype >= XEN_DOMCTL_PFINFO_L1TAB) &&
+                     (pagetype <= XEN_DOMCTL_PFINFO_L4TAB) )
+                {
                     /* We have a pagetable page: need to rewrite it. */
                     race = 
                         canonicalize_pagetable(pagetype, pfn, spage, page); 
@@ -1083,7 +1090,7 @@ int xc_linux_save(int xc_handle, int io_
             }
 
             if (xc_shadow_control(xc_handle, dom, 
-                                  DOM0_SHADOW_CONTROL_OP_CLEAN, to_send, 
+                                  XEN_DOMCTL_SHADOW_OP_CLEAN, to_send, 
                                   max_pfn, NULL, 0, &stats) != max_pfn) {
                 ERR("Error flushing shadow PT");
                 goto out;
@@ -1174,7 +1181,7 @@ int xc_linux_save(int xc_handle, int io_
 
     if (live) {
         if(xc_shadow_control(xc_handle, dom, 
-                             DOM0_SHADOW_CONTROL_OP_OFF,
+                             XEN_DOMCTL_SHADOW_OP_OFF,
                              NULL, 0, NULL, 0, NULL) < 0) {
             DPRINTF("Warning - couldn't disable shadow mode");
         }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_load_bin.c
--- a/tools/libxc/xc_load_bin.c Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_load_bin.c Sun Aug 27 10:24:41 2006 -0600
@@ -227,7 +227,7 @@ static int parsebinimage(const char *ima
     dsi->v_kernstart = dsi->v_start;
     dsi->v_kernend = dsi->v_end;
     dsi->v_kernentry = image_info->entry_addr;
-    dsi->xen_guest_string = "";
+    dsi->__xen_guest_string = NULL;
 
     return 0;
 }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_load_elf.c Sun Aug 27 10:24:41 2006 -0600
@@ -5,6 +5,7 @@
 #include "xg_private.h"
 #include "xc_elf.h"
 #include <stdlib.h>
+#include <inttypes.h>
 
 #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
 #define round_pgdown(_p)  ((_p)&PAGE_MASK)
@@ -65,17 +66,187 @@ static inline int is_loadable_phdr(Elf_P
             ((phdr->p_flags & (PF_W|PF_X)) != 0));
 }
 
+/*
+ * Fallback for kernels containing only the legacy __xen_guest string
+ * and no ELF notes.
+ */
+static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab)
+{
+    return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0;
+}
+
+static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type)
+{
+    const char *xenguest_fallbacks[] = {
+        [XEN_ELFNOTE_ENTRY] = "VIRT_ENTRY=",
+        [XEN_ELFNOTE_HYPERCALL_PAGE] = "HYPERCALL_PAGE=",
+        [XEN_ELFNOTE_VIRT_BASE] = "VIRT_BASE=",
+        [XEN_ELFNOTE_PADDR_OFFSET] = "ELF_PADDR_OFFSET=",
+        [XEN_ELFNOTE_XEN_VERSION] = "XEN_VER=",
+        [XEN_ELFNOTE_GUEST_OS] = "GUEST_OS=",
+        [XEN_ELFNOTE_GUEST_VERSION] = "GUEST_VER=",
+        [XEN_ELFNOTE_LOADER] = "LOADER=",
+        [XEN_ELFNOTE_PAE_MODE] = "PAE=",
+        [XEN_ELFNOTE_FEATURES] = "FEATURES=",
+        [XEN_ELFNOTE_BSD_SYMTAB] = "BSD_SYMTAB=",
+    };
+    const char *fallback;
+    const char *p;
+
+    if ( !dsi->__xen_guest_string )
+        return NULL;
+
+    if ( type > sizeof(xenguest_fallbacks) )
+        return NULL;
+
+    if ( (fallback = xenguest_fallbacks[type]) == NULL )
+        return NULL;
+
+    if ( (p = strstr(dsi->__xen_guest_string,fallback)) == NULL )
+        return NULL;
+
+    return p + strlen(fallback);
+}
+
+static const char *xen_guest_string(struct domain_setup_info *dsi, int type)
+{
+    const char *p = xen_guest_lookup(dsi, type);
+
+    /*
+     * We special case this since the __xen_guest_section treats the
+     * mere precense of the BSD_SYMTAB string as true or false.
+     */
+    if ( type == XEN_ELFNOTE_BSD_SYMTAB )
+        return p ? "yes" : "no";
+
+    return p;
+}
+
+static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
+                                                   int type, int *defined)
+{
+    const char *p = xen_guest_lookup(dsi, type);
+    unsigned long long value;
+
+    if ( p == NULL )
+        return 0;
+
+    errno = 0;
+    value = strtoull(p, NULL, 0);
+    if ( errno < 0 )
+        return 0;
+
+    /* We special case this since __xen_guest_section contains a PFN
+     * for this field not a virtual address.
+     */
+    if (type == XEN_ELFNOTE_HYPERCALL_PAGE)
+        value = dsi->v_start + (value<<PAGE_SHIFT);
+
+    *defined = 1;
+    return value;
+}
+
+/*
+ * Interface to the Xen ELF notes.
+ */
+#define ELFNOTE_NAME(_n_)   ((void*)(_n_) + sizeof(*(_n_)))
+#define ELFNOTE_DESC(_n_)   (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
+#define ELFNOTE_NEXT(_n_)   (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
+
+static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
+{
+    Elf_Note *note;
+
+    if ( shdr->sh_type != SHT_NOTE )
+        return 0;
+
+    for ( note = (Elf_Note *)(image + shdr->sh_offset);
+          note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
+          note = ELFNOTE_NEXT(note) )
+    {
+        if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) )
+            return 1;
+    }
+
+    return 0;
+}
+
+static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
+{
+    Elf_Note *note;
+
+    if ( !dsi->__elfnote_section )
+        return NULL;
+
+    for ( note = (Elf_Note *)dsi->__elfnote_section;
+          note < (Elf_Note *)dsi->__elfnote_section_end;
+          note = ELFNOTE_NEXT(note) )
+    {
+        if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) )
+            continue;
+
+        if ( note->type == type )
+            return note;
+    }
+
+    return NULL;
+}
+
+const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
+{
+    Elf_Note *note;
+
+    if ( !dsi->__elfnote_section )
+        return xen_guest_string(dsi, type);
+
+    note = xen_elfnote_lookup(dsi, type);
+    if ( note == NULL )
+        return NULL;
+
+    return (const char *)ELFNOTE_DESC(note);
+}
+
+unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
+                                       int type, int *defined)
+{
+    Elf_Note *note;
+
+    *defined = 0;
+
+    if ( !dsi->__elfnote_section )
+        return xen_guest_numeric(dsi, type, defined);
+
+    note = xen_elfnote_lookup(dsi, type);
+    if ( note == NULL )
+    {
+        return 0;
+    }
+
+    switch ( note->descsz )
+    {
+    case 4:
+        *defined = 1;
+        return *(uint32_t*)ELFNOTE_DESC(note);
+    case 8:
+        *defined = 1;
+        return *(uint64_t*)ELFNOTE_DESC(note);
+    default:
+        ERROR("elfnotes: unknown data size %#x for numeric type note %#x\n",
+              note->descsz, type);
+        return 0;
+    }
+}
+
 static int parseelfimage(const char *image,
-                         unsigned long elfsize,
+                         unsigned long image_len,
                          struct domain_setup_info *dsi)
 {
     Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
     Elf_Phdr *phdr;
     Elf_Shdr *shdr;
-    Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_base, elf_pa_off;
-    const char *shstrtab;
-    char *guestinfo=NULL, *p;
-    int h, virt_base_defined, elf_pa_off_defined;
+    Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry;
+    const char *shstrtab, *p;
+    int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined;
 
     if ( !IS_ELF(*ehdr) )
     {
@@ -92,13 +263,13 @@ static int parseelfimage(const char *ima
         return -EINVAL;
     }
 
-    if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize )
+    if ( (ehdr->e_phoff + (ehdr->e_phnum*ehdr->e_phentsize)) > image_len )
     {
         ERROR("ELF program headers extend beyond end of image.");
         return -EINVAL;
     }
 
-    if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize )
+    if ( (ehdr->e_shoff + (ehdr->e_shnum*ehdr->e_shentsize)) > image_len )
     {
         ERROR("ELF section headers extend beyond end of image.");
         return -EINVAL;
@@ -114,69 +285,119 @@ static int parseelfimage(const char *ima
                         (ehdr->e_shstrndx*ehdr->e_shentsize));
     shstrtab = image + shdr->sh_offset;
 
-    /* Find the special '__xen_guest' section and check its contents. */
+    dsi->__elfnote_section = NULL;
+    dsi->__xen_guest_string = NULL;
+
+    /* Look for .notes segment containing at least one Xen note */
     for ( h = 0; h < ehdr->e_shnum; h++ )
     {
         shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
-        if ( strcmp(&shstrtab[shdr->sh_name], "__xen_guest") != 0 )
+        if ( !is_xen_elfnote_section(image, shdr) )
             continue;
-
-        guestinfo = (char *)image + shdr->sh_offset;
-
-        if ( (strstr(guestinfo, "LOADER=generic") == NULL) &&
-             (strstr(guestinfo, "GUEST_OS=linux") == NULL) )
+        dsi->__elfnote_section = (void *)image + shdr->sh_offset;
+        dsi->__elfnote_section_end =
+            (void *)image + shdr->sh_offset + shdr->sh_size;
+        break;
+    }
+
+    /* Fall back to looking for the special '__xen_guest' section. */
+    if ( dsi->__elfnote_section == NULL )
+    {
+        for ( h = 0; h < ehdr->e_shnum; h++ )
+        {
+            shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
+            if ( is_xen_guest_section(shdr, shstrtab) )
+            {
+                dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
+                break;
+            }
+        }
+    }
+
+    /* Check the contents of the Xen notes or guest string. */
+    if ( dsi->__elfnote_section || dsi->__xen_guest_string )
+    {
+        const char *loader = xen_elfnote_string(dsi, XEN_ELFNOTE_LOADER);
+        const char *guest_os = xen_elfnote_string(dsi, XEN_ELFNOTE_GUEST_OS);
+        const char *xen_version =
+            xen_elfnote_string(dsi, XEN_ELFNOTE_XEN_VERSION);
+
+        if ( ( loader == NULL || strncmp(loader, "generic", 7) ) &&
+             ( guest_os == NULL || strncmp(guest_os, "linux", 5) ) )
         {
             ERROR("Will only load images built for the generic loader "
                   "or Linux images");
-            ERROR("Actually saw: '%s'", guestinfo);
             return -EINVAL;
         }
 
-        if ( (strstr(guestinfo, "XEN_VER=xen-3.0") == NULL) )
+        if ( xen_version == NULL || strncmp(xen_version, "xen-3.0", 7) )
         {
             ERROR("Will only load images built for Xen v3.0");
-            ERROR("Actually saw: '%s'", guestinfo);
             return -EINVAL;
         }
-
-        dsi->pae_kernel = PAEKERN_no;
-        p = strstr(guestinfo, "PAE=yes");
-        if ( p != NULL )
+    }
+    else
+    {
+#if defined(__x86_64__) || defined(__i386__)
+        ERROR("Not a Xen-ELF image: "
+              "No ELF notes or '__xen_guest' section found.");
+        return -EINVAL;
+#endif
+    }
+
+    /*
+     * If we have ELF notes then PAE=yes implies that we must support
+     * the extended cr3 syntax. Otherwise we need to find the
+     * [extended-cr3] syntax in the __xen_guest string.
+     */
+    dsi->pae_kernel = PAEKERN_no;
+    if ( dsi->__elfnote_section )
+    {
+        p = xen_elfnote_string(dsi, XEN_ELFNOTE_PAE_MODE);
+        if ( p != NULL && strncmp(p, "yes", 3) == 0 )
+            dsi->pae_kernel = PAEKERN_extended_cr3;
+
+    }
+    else
+    {
+        p = xen_guest_lookup(dsi, XEN_ELFNOTE_PAE_MODE);
+        if ( p != NULL && strncmp(p, "yes", 3) == 0 )
         {
             dsi->pae_kernel = PAEKERN_yes;
-            if ( !strncmp(p+7, "[extended-cr3]", 14) )
+            if ( !strncmp(p+4, "[extended-cr3]", 14) )
                 dsi->pae_kernel = PAEKERN_extended_cr3;
         }
-
-        break;
-    }
-
-    if ( guestinfo == NULL )
-    {
-#ifdef __ia64__
-        guestinfo = "";
-#else
-        ERROR("Not a Xen-ELF image: '__xen_guest' section not found.");
-        return -EINVAL;
-#endif
-    }
-
-    dsi->xen_guest_string = guestinfo;
-
-    /* Initial guess for virt_base is 0 if it is not explicitly defined. */
-    p = strstr(guestinfo, "VIRT_BASE=");
-    virt_base_defined = (p != NULL);
-    virt_base = virt_base_defined ? strtoull(p+10, &p, 0) : 0;
-
-    /* Initial guess for elf_pa_off is virt_base if not explicitly defined. */
-    p = strstr(guestinfo, "ELF_PADDR_OFFSET=");
-    elf_pa_off_defined = (p != NULL);
-    elf_pa_off = elf_pa_off_defined ? strtoull(p+17, &p, 0) : virt_base;
+    }
+
+    /* Initial guess for v_start is 0 if it is not explicitly defined. */
+    dsi->v_start =
+        xen_elfnote_numeric(dsi, XEN_ELFNOTE_VIRT_BASE, &virt_base_defined);
+    if ( !virt_base_defined )
+        dsi->v_start = 0;
+
+    /*
+     * If we are using the legacy __xen_guest section then elf_pa_off
+     * defaults to v_start in order to maintain compatibility with
+     * older hypervisors which set padd in the ELF header to
+     * virt_base.
+     *
+     * If we are using the modern ELF notes interface then the default
+     * is 0.
+     */
+    dsi->elf_paddr_offset =
+        xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET, 
&elf_pa_off_defined);
+    if ( !elf_pa_off_defined )
+    {
+        if ( dsi->__elfnote_section )
+            dsi->elf_paddr_offset = 0;
+        else
+            dsi->elf_paddr_offset = dsi->v_start;
+    }
 
     if ( elf_pa_off_defined && !virt_base_defined )
     {
-        ERROR("Neither ELF_PADDR_OFFSET nor VIRT_BASE found in __xen_guest"
-              " section.");
+        ERROR("Neither ELF_PADDR_OFFSET nor VIRT_BASE found in ELF "
+              " notes or __xen_guest section.");
         return -EINVAL;
     }
 
@@ -185,7 +406,7 @@ static int parseelfimage(const char *ima
         phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
         if ( !is_loadable_phdr(phdr) )
             continue;
-        vaddr = phdr->p_paddr - elf_pa_off + virt_base;
+        vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
         if ( (vaddr + phdr->p_memsz) < vaddr )
         {
             ERROR("ELF program header %d is too large.", h);
@@ -198,17 +419,12 @@ static int parseelfimage(const char *ima
             kernend = vaddr + phdr->p_memsz;
     }
 
-    /*
-     * Legacy compatibility and images with no __xen_guest section: assume
-     * header addresses are virtual addresses, and that guest memory should be
-     * mapped starting at kernel load address.
-     */
-    dsi->v_start          = virt_base_defined  ? virt_base  : kernstart;
-    dsi->elf_paddr_offset = elf_pa_off_defined ? elf_pa_off : dsi->v_start;
-
     dsi->v_kernentry = ehdr->e_entry;
-    if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
-        dsi->v_kernentry = strtoull(p+11, &p, 0);
+
+    virt_entry =
+        xen_elfnote_numeric(dsi, XEN_ELFNOTE_ENTRY, &virt_entry_defined);
+    if ( virt_entry_defined )
+        dsi->v_kernentry = virt_entry;
 
     if ( (kernstart > kernend) ||
          (dsi->v_kernentry < kernstart) ||
@@ -219,7 +435,8 @@ static int parseelfimage(const char *ima
         return -EINVAL;
     }
 
-    if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
+    p = xen_elfnote_string(dsi, XEN_ELFNOTE_BSD_SYMTAB);
+    if ( p != NULL && strncmp(p, "yes", 3) == 0 )
         dsi->load_symtab = 1;
 
     dsi->v_kernstart = kernstart;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_misc.c     Sun Aug 27 10:24:41 2006 -0600
@@ -12,20 +12,20 @@ int xc_readconsolering(int xc_handle,
                        int clear)
 {
     int ret;
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
     char *buffer = *pbuffer;
     unsigned int nr_chars = *pnr_chars;
 
-    op.cmd = DOM0_READCONSOLE;
-    set_xen_guest_handle(op.u.readconsole.buffer, buffer);
-    op.u.readconsole.count  = nr_chars;
-    op.u.readconsole.clear  = clear;
+    sysctl.cmd = XEN_SYSCTL_readconsole;
+    set_xen_guest_handle(sysctl.u.readconsole.buffer, buffer);
+    sysctl.u.readconsole.count  = nr_chars;
+    sysctl.u.readconsole.clear  = clear;
 
     if ( (ret = mlock(buffer, nr_chars)) != 0 )
         return ret;
 
-    if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
-        *pnr_chars = op.u.readconsole.count;
+    if ( (ret = do_sysctl(xc_handle, &sysctl)) == 0 )
+        *pnr_chars = sysctl.u.readconsole.count;
 
     safe_munlock(buffer, nr_chars);
 
@@ -36,15 +36,14 @@ int xc_physinfo(int xc_handle,
                 xc_physinfo_t *put_info)
 {
     int ret;
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_PHYSINFO;
-    op.interface_version = DOM0_INTERFACE_VERSION;
+    sysctl.cmd = XEN_SYSCTL_physinfo;
 
-    if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
+    if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
         return ret;
 
-    memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
+    memcpy(put_info, &sysctl.u.physinfo, sizeof(*put_info));
 
     return 0;
 }
@@ -53,15 +52,14 @@ int xc_sched_id(int xc_handle,
                 int *sched_id)
 {
     int ret;
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_SCHED_ID;
-    op.interface_version = DOM0_INTERFACE_VERSION;
+    sysctl.cmd = XEN_SYSCTL_sched_id;
 
-    if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
+    if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
         return ret;
 
-    *sched_id = op.u.sched_id.sched_id;
+    *sched_id = sysctl.u.sched_id.sched_id;
 
     return 0;
 }
@@ -74,56 +72,22 @@ int xc_perfc_control(int xc_handle,
                      int *nbr_val)
 {
     int rc;
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_PERFCCONTROL;
-    op.u.perfccontrol.op   = opcode;
-    set_xen_guest_handle(op.u.perfccontrol.desc, desc);
-    set_xen_guest_handle(op.u.perfccontrol.val, val);
+    sysctl.cmd = XEN_SYSCTL_perfc_op;
+    sysctl.u.perfc_op.cmd = opcode;
+    set_xen_guest_handle(sysctl.u.perfc_op.desc, desc);
+    set_xen_guest_handle(sysctl.u.perfc_op.val, val);
 
-    rc = do_dom0_op(xc_handle, &op);
+    rc = do_sysctl(xc_handle, &sysctl);
 
     if (nbr_desc)
-        *nbr_desc = op.u.perfccontrol.nr_counters;
+        *nbr_desc = sysctl.u.perfc_op.nr_counters;
     if (nbr_val)
-        *nbr_val = op.u.perfccontrol.nr_vals;
+        *nbr_val = sysctl.u.perfc_op.nr_vals;
 
     return rc;
 }
-
-long long xc_msr_read(int xc_handle, int cpu_mask, int msr)
-{
-    int rc;
-    DECLARE_DOM0_OP;
-
-    op.cmd = DOM0_MSR;
-    op.u.msr.write = 0;
-    op.u.msr.msr = msr;
-    op.u.msr.cpu_mask = cpu_mask;
-
-    rc = do_dom0_op(xc_handle, &op);
-
-    return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
-}
-
-int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
-                  unsigned int high)
-{
-    int rc;
-    DECLARE_DOM0_OP;
-
-    op.cmd = DOM0_MSR;
-    op.u.msr.write = 1;
-    op.u.msr.msr = msr;
-    op.u.msr.cpu_mask = cpu_mask;
-    op.u.msr.in1 = low;
-    op.u.msr.in2 = high;
-
-    rc = do_dom0_op(xc_handle, &op);
-
-    return rc;
-}
-
 
 /*
  * Local variables:
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_private.c  Sun Aug 27 10:24:41 2006 -0600
@@ -11,12 +11,12 @@ int xc_get_pfn_type_batch(int xc_handle,
 int xc_get_pfn_type_batch(int xc_handle,
                           uint32_t dom, int num, unsigned long *arr)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_GETPAGEFRAMEINFO2;
-    op.u.getpageframeinfo2.domain = (domid_t)dom;
-    op.u.getpageframeinfo2.num    = num;
-    set_xen_guest_handle(op.u.getpageframeinfo2.array, arr);
-    return do_dom0_op(xc_handle, &op);
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_getpageframeinfo2;
+    domctl.domain = (domid_t)dom;
+    domctl.u.getpageframeinfo2.num    = num;
+    set_xen_guest_handle(domctl.u.getpageframeinfo2.array, arr);
+    return do_domctl(xc_handle, &domctl);
 }
 
 #define GETPFN_ERR (~0U)
@@ -24,16 +24,16 @@ unsigned int get_pfn_type(int xc_handle,
                           unsigned long mfn,
                           uint32_t dom)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_GETPAGEFRAMEINFO;
-    op.u.getpageframeinfo.gmfn   = mfn;
-    op.u.getpageframeinfo.domain = (domid_t)dom;
-    if ( do_dom0_op(xc_handle, &op) < 0 )
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_getpageframeinfo;
+    domctl.u.getpageframeinfo.gmfn   = mfn;
+    domctl.domain = (domid_t)dom;
+    if ( do_domctl(xc_handle, &domctl) < 0 )
     {
         PERROR("Unexpected failure when getting page frame info!");
         return GETPFN_ERR;
     }
-    return op.u.getpageframeinfo.type;
+    return domctl.u.getpageframeinfo.type;
 }
 
 int xc_mmuext_op(
@@ -248,17 +248,17 @@ int xc_memory_op(int xc_handle,
 
 long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid, int vcpu )
 {
-    DECLARE_DOM0_OP;
-
-    op.cmd = DOM0_GETVCPUINFO;
-    op.u.getvcpuinfo.domain = (domid_t)domid;
-    op.u.getvcpuinfo.vcpu   = (uint16_t)vcpu;
-    if ( (do_dom0_op(xc_handle, &op) < 0) )
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_getvcpuinfo;
+    domctl.domain = (domid_t)domid;
+    domctl.u.getvcpuinfo.vcpu   = (uint16_t)vcpu;
+    if ( (do_domctl(xc_handle, &domctl) < 0) )
     {
         PERROR("Could not get info on domain");
         return -1;
     }
-    return op.u.getvcpuinfo.cpu_time;
+    return domctl.u.getvcpuinfo.cpu_time;
 }
 
 
@@ -268,12 +268,12 @@ int xc_get_pfn_list(int xc_handle,
                     xen_pfn_t *pfn_buf,
                     unsigned long max_pfns)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int ret;
-    op.cmd = DOM0_GETMEMLIST;
-    op.u.getmemlist.domain   = (domid_t)domid;
-    op.u.getmemlist.max_pfns = max_pfns;
-    set_xen_guest_handle(op.u.getmemlist.buffer, pfn_buf);
+    domctl.cmd = XEN_DOMCTL_getmemlist;
+    domctl.domain   = (domid_t)domid;
+    domctl.u.getmemlist.max_pfns = max_pfns;
+    set_xen_guest_handle(domctl.u.getmemlist.buffer, pfn_buf);
 
 #ifdef VALGRIND
     memset(pfn_buf, 0, max_pfns * sizeof(xen_pfn_t));
@@ -285,7 +285,7 @@ int xc_get_pfn_list(int xc_handle,
         return -1;
     }
 
-    ret = do_dom0_op(xc_handle, &op);
+    ret = do_domctl(xc_handle, &domctl);
 
     safe_munlock(pfn_buf, max_pfns * sizeof(xen_pfn_t));
 
@@ -294,7 +294,7 @@ int xc_get_pfn_list(int xc_handle,
     DPRINTF(("Ret for xc_get_pfn_list is %d\n", ret));
     if (ret >= 0) {
         int i, j;
-        for (i = 0; i < op.u.getmemlist.num_pfns; i += 16) {
+        for (i = 0; i < domctl.u.getmemlist.num_pfns; i += 16) {
             DPRINTF("0x%x: ", i);
             for (j = 0; j < 16; j++)
                 DPRINTF("0x%lx ", pfn_buf[i + j]);
@@ -304,17 +304,17 @@ int xc_get_pfn_list(int xc_handle,
 #endif
 #endif
 
-    return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
+    return (ret < 0) ? -1 : domctl.u.getmemlist.num_pfns;
 }
 #endif
 
 long xc_get_tot_pages(int xc_handle, uint32_t domid)
 {
-    DECLARE_DOM0_OP;
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = (domid_t)domid;
-    return (do_dom0_op(xc_handle, &op) < 0) ?
-        -1 : op.u.getdomaininfo.tot_pages;
+    DECLARE_DOMCTL;
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)domid;
+    return (do_domctl(xc_handle, &domctl) < 0) ?
+        -1 : domctl.u.getdomaininfo.tot_pages;
 }
 
 int xc_copy_to_domain_page(int xc_handle,
@@ -386,9 +386,14 @@ void xc_map_memcpy(unsigned long dst, co
     }
 }
 
-int xc_dom0_op(int xc_handle, dom0_op_t *op)
-{
-    return do_dom0_op(xc_handle, op);
+int xc_domctl(int xc_handle, struct xen_domctl *domctl)
+{
+    return do_domctl(xc_handle, domctl);
+}
+
+int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl)
+{
+    return do_sysctl(xc_handle, sysctl);
 }
 
 int xc_version(int xc_handle, int cmd, void *arg)
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_private.h  Sun Aug 27 10:24:41 2006 -0600
@@ -18,14 +18,16 @@
 #include <xen/sys/privcmd.h>
 
 /* valgrind cannot see when a hypercall has filled in some values.  For this
-   reason, we must zero the privcmd_hypercall_t or dom0_op_t instance before a
-   call, if using valgrind.  */
+   reason, we must zero the privcmd_hypercall_t or domctl/sysctl instance
+   before a call, if using valgrind.  */
 #ifdef VALGRIND
 #define DECLARE_HYPERCALL privcmd_hypercall_t hypercall = { 0 }
-#define DECLARE_DOM0_OP dom0_op_t op = { 0 }
+#define DECLARE_DOMCTL struct xen_domctl domctl = { 0 }
+#define DECLARE_SYSCTL struct xen_sysctl sysctl = { 0 }
 #else
 #define DECLARE_HYPERCALL privcmd_hypercall_t hypercall
-#define DECLARE_DOM0_OP dom0_op_t op
+#define DECLARE_DOMCTL struct xen_domctl domctl
+#define DECLARE_SYSCTL struct xen_sysctl sysctl
 #endif
 
 #define PAGE_SHIFT              XC_PAGE_SHIFT
@@ -94,17 +96,17 @@ static inline int do_xen_version(int xc_
     return do_xen_hypercall(xc_handle, &hypercall);
 }
 
-static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
+static inline int do_domctl(int xc_handle, struct xen_domctl *domctl)
 {
     int ret = -1;
     DECLARE_HYPERCALL;
 
-    op->interface_version = DOM0_INTERFACE_VERSION;
+    domctl->interface_version = XEN_DOMCTL_INTERFACE_VERSION;
 
-    hypercall.op     = __HYPERVISOR_dom0_op;
-    hypercall.arg[0] = (unsigned long)op;
+    hypercall.op     = __HYPERVISOR_domctl;
+    hypercall.arg[0] = (unsigned long)domctl;
 
-    if ( mlock(op, sizeof(*op)) != 0 )
+    if ( mlock(domctl, sizeof(*domctl)) != 0 )
     {
         PERROR("Could not lock memory for Xen hypercall");
         goto out1;
@@ -113,11 +115,40 @@ static inline int do_dom0_op(int xc_hand
     if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
     {
         if ( errno == EACCES )
-            DPRINTF("Dom0 operation failed -- need to"
+            DPRINTF("domctl operation failed -- need to"
                     " rebuild the user-space tool set?\n");
     }
 
-    safe_munlock(op, sizeof(*op));
+    safe_munlock(domctl, sizeof(*domctl));
+
+ out1:
+    return ret;
+}
+
+static inline int do_sysctl(int xc_handle, struct xen_sysctl *sysctl)
+{
+    int ret = -1;
+    DECLARE_HYPERCALL;
+
+    sysctl->interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+
+    hypercall.op     = __HYPERVISOR_sysctl;
+    hypercall.arg[0] = (unsigned long)sysctl;
+
+    if ( mlock(sysctl, sizeof(*sysctl)) != 0 )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        goto out1;
+    }
+
+    if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
+    {
+        if ( errno == EACCES )
+            DPRINTF("sysctl operation failed -- need to"
+                    " rebuild the user-space tool set?\n");
+    }
+
+    safe_munlock(sysctl, sizeof(*sysctl));
 
  out1:
     return ret;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_ptrace.c   Sun Aug 27 10:24:41 2006 -0600
@@ -41,8 +41,8 @@ static int                      current_
 static int                      current_domid = -1;
 static int                      current_isfile;
 
-static cpumap_t                 online_cpumap;
-static cpumap_t                 regs_valid;
+static uint64_t                 online_cpumap;
+static uint64_t                 regs_valid;
 static vcpu_guest_context_t     ctxt[MAX_VIRT_CPUS];
 
 extern int ffsll(long long int);
@@ -111,7 +111,8 @@ paging_enabled(vcpu_guest_context_t *v)
  */
 
 static int
-get_online_cpumap(int xc_handle, dom0_getdomaininfo_t *d, cpumap_t *cpumap)
+get_online_cpumap(int xc_handle, struct xen_domctl_getdomaininfo *d,
+                  uint64_t *cpumap)
 {
     int i, online, retval;
 
@@ -133,9 +134,9 @@ get_online_cpumap(int xc_handle, dom0_ge
  */
 
 static void
-online_vcpus_changed(cpumap_t cpumap)
-{
-    cpumap_t changed_cpumap = cpumap ^ online_cpumap;
+online_vcpus_changed(uint64_t cpumap)
+{
+    uint64_t changed_cpumap = cpumap ^ online_cpumap;
     int index;
 
     while ( (index = ffsll(changed_cpumap)) ) {
@@ -418,25 +419,25 @@ __xc_waitdomain(
     int *status,
     int options)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int retval;
     struct timespec ts;
-    cpumap_t cpumap;
+    uint64_t cpumap;
 
     ts.tv_sec = 0;
     ts.tv_nsec = 10*1000*1000;
 
-    op.cmd = DOM0_GETDOMAININFO;
-    op.u.getdomaininfo.domain = domain;
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = domain;
 
  retry:
-    retval = do_dom0_op(xc_handle, &op);
-    if ( retval || (op.u.getdomaininfo.domain != domain) )
+    retval = do_domctl(xc_handle, &domctl);
+    if ( retval || (domctl.domain != domain) )
     {
         IPRINTF("getdomaininfo failed\n");
         goto done;
     }
-    *status = op.u.getdomaininfo.flags;
+    *status = domctl.u.getdomaininfo.flags;
 
     if ( options & WNOHANG )
         goto done;
@@ -447,13 +448,13 @@ __xc_waitdomain(
         goto done;
     }
 
-    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) )
+    if ( !(domctl.u.getdomaininfo.flags & DOMFLAGS_PAUSED) )
     {
         nanosleep(&ts,NULL);
         goto retry;
     }
  done:
-    if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
+    if (get_online_cpumap(xc_handle, &domctl.u.getdomaininfo, &cpumap))
         IPRINTF("get_online_cpumap failed\n");
     if (online_cpumap != cpumap)
         online_vcpus_changed(cpumap);
@@ -470,11 +471,11 @@ xc_ptrace(
     long eaddr,
     long edata)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     struct gdb_regs pt;
     long            retval = 0;
     unsigned long  *guest_va;
-    cpumap_t        cpumap;
+    uint64_t        cpumap;
     int             cpu, index;
     void           *addr = (char *)eaddr;
     void           *data = (char *)edata;
@@ -535,7 +536,7 @@ xc_ptrace(
         SET_XC_REGS(((struct gdb_regs *)data), ctxt[cpu].user_regs);
         if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
                                 &ctxt[cpu])))
-            goto out_error_dom0;
+            goto out_error_domctl;
         break;
 
     case PTRACE_SINGLESTEP:
@@ -547,7 +548,7 @@ xc_ptrace(
         ctxt[cpu].user_regs.eflags |= PSL_T;
         if ((retval = xc_vcpu_setcontext(xc_handle, current_domid, cpu,
                                 &ctxt[cpu])))
-            goto out_error_dom0;
+            goto out_error_domctl;
         /* FALLTHROUGH */
 
     case PTRACE_CONT:
@@ -566,22 +567,22 @@ xc_ptrace(
                     ctxt[cpu].user_regs.eflags &= ~PSL_T;
                     if ((retval = xc_vcpu_setcontext(xc_handle, current_domid,
                                                 cpu, &ctxt[cpu])))
-                        goto out_error_dom0;
+                        goto out_error_domctl;
                 }
             }
         }
         if ( request == PTRACE_DETACH )
         {
-            op.cmd = DOM0_SETDEBUGGING;
-            op.u.setdebugging.domain = current_domid;
-            op.u.setdebugging.enable = 0;
-            if ((retval = do_dom0_op(xc_handle, &op)))
-                goto out_error_dom0;
+            domctl.cmd = XEN_DOMCTL_setdebugging;
+            domctl.domain = current_domid;
+            domctl.u.setdebugging.enable = 0;
+            if ((retval = do_domctl(xc_handle, &domctl)))
+                goto out_error_domctl;
         }
         regs_valid = 0;
         if ((retval = xc_domain_unpause(xc_handle, current_domid > 0 ?
                                 current_domid : -current_domid)))
-            goto out_error_dom0;
+            goto out_error_domctl;
         break;
 
     case PTRACE_ATTACH:
@@ -589,22 +590,22 @@ xc_ptrace(
         current_isfile = (int)edata;
         if (current_isfile)
             break;
-        op.cmd = DOM0_GETDOMAININFO;
-        op.u.getdomaininfo.domain = current_domid;
-        retval = do_dom0_op(xc_handle, &op);
-        if ( retval || (op.u.getdomaininfo.domain != current_domid) )
-            goto out_error_dom0;
-        if ( op.u.getdomaininfo.flags & DOMFLAGS_PAUSED )
+        domctl.cmd = XEN_DOMCTL_getdomaininfo;
+        domctl.domain = current_domid;
+        retval = do_domctl(xc_handle, &domctl);
+        if ( retval || (domctl.domain != current_domid) )
+            goto out_error_domctl;
+        if ( domctl.u.getdomaininfo.flags & DOMFLAGS_PAUSED )
             IPRINTF("domain currently paused\n");
         else if ((retval = xc_domain_pause(xc_handle, current_domid)))
-            goto out_error_dom0;
-        op.cmd = DOM0_SETDEBUGGING;
-        op.u.setdebugging.domain = current_domid;
-        op.u.setdebugging.enable = 1;
-        if ((retval = do_dom0_op(xc_handle, &op)))
-            goto out_error_dom0;
-
-        if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
+            goto out_error_domctl;
+        domctl.cmd = XEN_DOMCTL_setdebugging;
+        domctl.domain = current_domid;
+        domctl.u.setdebugging.enable = 1;
+        if ((retval = do_domctl(xc_handle, &domctl)))
+            goto out_error_domctl;
+
+        if (get_online_cpumap(xc_handle, &domctl.u.getdomaininfo, &cpumap))
             IPRINTF("get_online_cpumap failed\n");
         if (online_cpumap != cpumap)
             online_vcpus_changed(cpumap);
@@ -625,8 +626,8 @@ xc_ptrace(
 
     return retval;
 
- out_error_dom0:
-    perror("dom0 op failed");
+ out_error_domctl:
+    perror("domctl failed");
  out_error:
     errno = EINVAL;
     return retval;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_sedf.c
--- a/tools/libxc/xc_sedf.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_sedf.c     Sun Aug 27 10:24:41 2006 -0600
@@ -10,37 +10,50 @@
 
 #include "xc_private.h"
 
-int xc_sedf_domain_set(int xc_handle,
-                          uint32_t domid, uint64_t period, uint64_t 
slice,uint64_t latency, uint16_t extratime,uint16_t weight)
+int xc_sedf_domain_set(
+    int xc_handle,
+    uint32_t domid,
+    uint64_t period,
+    uint64_t slice,
+    uint64_t latency,
+    uint16_t extratime,
+    uint16_t weight)
 {
-    DECLARE_DOM0_OP;
-    struct sedf_adjdom *p = &op.u.adjustdom.u.sedf;
+    DECLARE_DOMCTL;
+    struct xen_domctl_sched_sedf *p = &domctl.u.scheduler_op.u.sedf;
 
-    op.cmd = DOM0_ADJUSTDOM;
-    op.u.adjustdom.domain  = (domid_t)domid;
-    op.u.adjustdom.sched_id = SCHED_SEDF;
-    op.u.adjustdom.direction = SCHED_INFO_PUT;
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.domain  = (domid_t)domid;
+    domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_SEDF;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo;
 
     p->period    = period;
     p->slice     = slice;
     p->latency   = latency;
     p->extratime = extratime;
     p->weight    = weight;
-    return do_dom0_op(xc_handle, &op);
+    return do_domctl(xc_handle, &domctl);
 }
 
-int xc_sedf_domain_get(int xc_handle, uint32_t domid, uint64_t *period, 
uint64_t *slice, uint64_t* latency, uint16_t* extratime, uint16_t* weight)
+int xc_sedf_domain_get(
+    int xc_handle,
+    uint32_t domid,
+    uint64_t *period,
+    uint64_t *slice,
+    uint64_t *latency,
+    uint16_t *extratime,
+    uint16_t *weight)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_DOMCTL;
     int ret;
-    struct sedf_adjdom *p = &op.u.adjustdom.u.sedf;
+    struct xen_domctl_sched_sedf *p = &domctl.u.scheduler_op.u.sedf;
 
-    op.cmd = DOM0_ADJUSTDOM;
-    op.u.adjustdom.domain = (domid_t)domid;
-    op.u.adjustdom.sched_id = SCHED_SEDF;
-    op.u.adjustdom.direction = SCHED_INFO_GET;
+    domctl.cmd = XEN_DOMCTL_scheduler_op;
+    domctl.domain = (domid_t)domid;
+    domctl.u.scheduler_op.sched_id = XEN_SCHEDULER_SEDF;
+    domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo;
 
-    ret = do_dom0_op(xc_handle, &op);
+    ret = do_domctl(xc_handle, &domctl);
 
     *period    = p->period;
     *slice     = p->slice;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xc_tbuf.c
--- a/tools/libxc/xc_tbuf.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xc_tbuf.c     Sun Aug 27 10:24:41 2006 -0600
@@ -18,49 +18,49 @@
 
 static int tbuf_enable(int xc_handle, int enable)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
     if (enable)
-        op.u.tbufcontrol.op  = DOM0_TBUF_ENABLE;
+        sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_enable;
     else
-        op.u.tbufcontrol.op  = DOM0_TBUF_DISABLE;
+        sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_disable;
 
-    return xc_dom0_op(xc_handle, &op);
+    return xc_sysctl(xc_handle, &sysctl);
 }
 
 int xc_tbuf_set_size(int xc_handle, unsigned long size)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_SET_SIZE;
-    op.u.tbufcontrol.size = size;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_size;
+    sysctl.u.tbuf_op.size = size;
 
-    return xc_dom0_op(xc_handle, &op);
+    return xc_sysctl(xc_handle, &sysctl);
 }
 
 int xc_tbuf_get_size(int xc_handle, unsigned long *size)
 {
     int rc;
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
 
-    rc = xc_dom0_op(xc_handle, &op);
+    rc = xc_sysctl(xc_handle, &sysctl);
     if (rc == 0)
-        *size = op.u.tbufcontrol.size;
+        *size = sysctl.u.tbuf_op.size;
     return rc;
 }
 
 int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
                    unsigned long *size)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
     int rc;
 
     /*
@@ -73,15 +73,15 @@ int xc_tbuf_enable(int xc_handle, size_t
     if ( tbuf_enable(xc_handle, 1) != 0 )
         return -1;
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
 
-    rc = xc_dom0_op(xc_handle, &op);
+    rc = xc_sysctl(xc_handle, &sysctl);
     if ( rc == 0 )
     {
-        *size = op.u.tbufcontrol.size;
-        *mfn = op.u.tbufcontrol.buffer_mfn;
+        *size = sysctl.u.tbuf_op.size;
+        *mfn = sysctl.u.tbuf_op.buffer_mfn;
     }
 
     return 0;
@@ -94,25 +94,39 @@ int xc_tbuf_disable(int xc_handle)
 
 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
+    int ret = -1;
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_SET_CPU_MASK;
-    op.u.tbufcontrol.cpu_mask = mask;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_cpu_mask;
 
-    return do_dom0_op(xc_handle, &op);
+    set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, (uint8_t *)&mask);
+    sysctl.u.tbuf_op.cpu_mask.nr_cpus = sizeof(mask) * 8;
+
+    if ( mlock(&mask, sizeof(mask)) != 0 )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        goto out;
+    }
+
+    ret = do_sysctl(xc_handle, &sysctl);
+
+    safe_munlock(&mask, sizeof(mask));
+
+ out:
+    return ret;
 }
 
 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask)
 {
-    DECLARE_DOM0_OP;
+    DECLARE_SYSCTL;
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_SET_EVT_MASK;
-    op.u.tbufcontrol.evt_mask = mask;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_evt_mask;
+    sysctl.u.tbuf_op.evt_mask = mask;
 
-    return do_dom0_op(xc_handle, &op);
+    return do_sysctl(xc_handle, &sysctl);
 }
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xenctrl.h     Sun Aug 27 10:24:41 2006 -0600
@@ -13,11 +13,11 @@
 #include <stdint.h>
 #include <sys/ptrace.h>
 #include <xen/xen.h>
-#include <xen/dom0_ops.h>
+#include <xen/domctl.h>
+#include <xen/sysctl.h>
 #include <xen/version.h>
 #include <xen/event_channel.h>
 #include <xen/sched.h>
-#include <xen/sched_ctl.h>
 #include <xen/memory.h>
 #include <xen/acm.h>
 #include <xen/acm_ops.h>
@@ -139,7 +139,7 @@ typedef struct {
     xen_domain_handle_t handle;
 } xc_dominfo_t;
 
-typedef dom0_getdomaininfo_t xc_domaininfo_t;
+typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
 int xc_domain_create(int xc_handle,
                      uint32_t ssidref,
                      xen_domain_handle_t handle,
@@ -231,7 +231,11 @@ int xc_vcpu_setaffinity(int xc_handle,
 int xc_vcpu_setaffinity(int xc_handle,
                         uint32_t domid,
                         int vcpu,
-                        cpumap_t cpumap);
+                        uint64_t cpumap);
+int xc_vcpu_getaffinity(int xc_handle,
+                        uint32_t domid,
+                        int vcpu,
+                        uint64_t *cpumap);
 
 /**
  * This function will return information about one or more domains. It is
@@ -301,7 +305,7 @@ int xc_vcpu_getcontext(int xc_handle,
                                uint32_t vcpu,
                                vcpu_guest_context_t *ctxt);
 
-typedef dom0_getvcpuinfo_t xc_vcpuinfo_t;
+typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
 int xc_vcpu_getinfo(int xc_handle,
                     uint32_t domid,
                     uint32_t vcpu,
@@ -317,7 +321,7 @@ int xc_domain_sethandle(int xc_handle, u
 int xc_domain_sethandle(int xc_handle, uint32_t domid,
                         xen_domain_handle_t handle);
 
-typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
+typedef xen_domctl_shadow_op_stats_t xc_shadow_op_stats_t;
 int xc_shadow_control(int xc_handle,
                       uint32_t domid,
                       unsigned int sop,
@@ -325,29 +329,7 @@ int xc_shadow_control(int xc_handle,
                       unsigned long pages,
                       unsigned long *mb,
                       uint32_t mode,
-                      xc_shadow_control_stats_t *stats);
-
-int xc_bvtsched_global_set(int xc_handle,
-                           unsigned long ctx_allow);
-
-int xc_bvtsched_domain_set(int xc_handle,
-                           uint32_t domid,
-                           uint32_t mcuadv,
-                           int warpback,
-                           int32_t warpvalue,
-                           long long warpl,
-                           long long warpu);
-
-int xc_bvtsched_global_get(int xc_handle,
-                           unsigned long *ctx_allow);
-
-int xc_bvtsched_domain_get(int xc_handle,
-                           uint32_t domid,
-                           uint32_t *mcuadv,
-                           int *warpback,
-                           int32_t *warpvalue,
-                           long long *warpl,
-                           long long *warpu);
+                      xc_shadow_op_stats_t *stats);
 
 int xc_sedf_domain_set(int xc_handle,
                        uint32_t domid,
@@ -363,11 +345,11 @@ int xc_sedf_domain_get(int xc_handle,
 
 int xc_sched_credit_domain_set(int xc_handle,
                                uint32_t domid,
-                               struct sched_credit_adjdom *sdom);
+                               struct xen_domctl_sched_credit *sdom);
 
 int xc_sched_credit_domain_get(int xc_handle,
                                uint32_t domid,
-                               struct sched_credit_adjdom *sdom);
+                               struct xen_domctl_sched_credit *sdom);
 
 /*
  * EVENT CHANNEL FUNCTIONS
@@ -399,7 +381,7 @@ int xc_readconsolering(int xc_handle,
                        unsigned int *pnr_chars,
                        int clear);
 
-typedef dom0_physinfo_t xc_physinfo_t;
+typedef xen_sysctl_physinfo_t xc_physinfo_t;
 int xc_physinfo(int xc_handle,
                 xc_physinfo_t *info);
 
@@ -460,8 +442,8 @@ unsigned long xc_make_page_below_4G(int 
 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
                                     unsigned long mfn);
 
-typedef dom0_perfc_desc_t xc_perfc_desc_t;
-typedef dom0_perfc_val_t xc_perfc_val_t;
+typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t;
+typedef xen_sysctl_perfc_val_t xc_perfc_val_t;
 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val
    arrays. */
 int xc_perfc_control(int xc_handle,
@@ -471,11 +453,6 @@ int xc_perfc_control(int xc_handle,
                      int *nbr_desc,
                      int *nbr_val);
 
-/* read/write msr */
-long long xc_msr_read(int xc_handle, int cpu_mask, int msr);
-int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
-                  unsigned int high);
-
 /**
  * Memory maps a range within one domain to a local address range.  Mappings
  * should be unmapped with munmap and should follow the same rules as mmap
@@ -588,8 +565,8 @@ int xc_tbuf_set_cpu_mask(int xc_handle, 
 
 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask);
 
-/* Execute a privileged dom0 operation. */
-int xc_dom0_op(int xc_handle, dom0_op_t *op);
+int xc_domctl(int xc_handle, struct xen_domctl *domctl);
+int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl);
 
 int xc_version(int xc_handle, int cmd, void *arg);
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/libxc/xg_private.h
--- a/tools/libxc/xg_private.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/libxc/xg_private.h  Sun Aug 27 10:24:41 2006 -0600
@@ -5,6 +5,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -16,15 +17,7 @@
 
 #include <xen/sys/privcmd.h>
 #include <xen/memory.h>
-
-/* valgrind cannot see when a hypercall has filled in some values.  For this
-   reason, we must zero the dom0_op_t instance before a call, if using
-   valgrind.  */
-#ifdef VALGRIND
-#define DECLARE_DOM0_OP dom0_op_t op = { 0 }
-#else
-#define DECLARE_DOM0_OP dom0_op_t op
-#endif
+#include <xen/elfnote.h>
 
 #ifndef ELFSIZE
 #include <limits.h>
@@ -149,8 +142,15 @@ struct domain_setup_info
     unsigned long symtab_addr;
     unsigned long symtab_len;
 
-    /* __xen_guest info string for convenient loader parsing. */
-    char *xen_guest_string;
+    /*
+     * Only one of __elfnote_* or __xen_guest_string will be
+     * non-NULL.
+     *
+     * You should use the xen_elfnote_* accessors below in order to
+     * pickup the correct one and retain backwards compatibility.
+     */
+    void *__elfnote_section, *__elfnote_section_end;
+    const char *__xen_guest_string;
 };
 
 typedef int (*parseimagefunc)(const char *image, unsigned long image_size,
@@ -159,6 +159,21 @@ typedef int (*loadimagefunc)(const char 
                              int xch,
                              uint32_t dom, xen_pfn_t *parray,
                              struct domain_setup_info *dsi);
+
+/*
+ * If an ELF note of the given type is found then the value contained
+ * in the note is returned and *defined is set to non-zero. If no such
+ * note is found then *defined is set to 0 and 0 is returned.
+ */
+extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
+                                             int type, int *defined);
+
+/*
+ * If an ELF note of the given type is found then the string contained
+ * in the value is returned, otherwise NULL is returned.
+ */
+extern const char * xen_elfnote_string(struct domain_setup_info *dsi,
+                                      int type);
 
 struct load_funcs
 {
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/misc/Makefile
--- a/tools/misc/Makefile       Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/misc/Makefile       Sun Aug 27 10:24:41 2006 -0600
@@ -24,7 +24,6 @@ all: build
 .PHONY: build
 build: $(TARGETS)
        $(MAKE) -C miniterm
-       $(MAKE) -C cpuperf
 ifeq ($(CONFIG_MBOOTPACK),y)
        $(MAKE) -C mbootpack
 endif
@@ -36,7 +35,6 @@ install: build
        [ -d $(DESTDIR)/usr/sbin ] || $(INSTALL_DIR) $(DESTDIR)/usr/sbin
        $(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin
        $(INSTALL_PROG) $(INSTALL_SBIN) $(DESTDIR)/usr/sbin
-       $(MAKE) -C cpuperf install
        $(MAKE) -C lomount install
 #       No sense in installing miniterm on the Xen box.
 #      $(MAKE) -C miniterm install
@@ -47,7 +45,6 @@ clean:
 clean:
        $(RM) *.o $(TARGETS) *~
        $(MAKE) -C miniterm clean
-       $(MAKE) -C cpuperf clean
        $(MAKE) -C mbootpack clean
        $(MAKE) -C lomount clean
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/misc/xenperf.c
--- a/tools/misc/xenperf.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/misc/xenperf.c      Sun Aug 27 10:24:41 2006 -0600
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
     
     if ( reset )
     {
-        if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_RESET,
+        if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_reset,
                               NULL, NULL, NULL, NULL) != 0 )
         {
             fprintf(stderr, "Error reseting performance counters: %d (%s)\n",
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
         return 0;
     }
 
-       if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_QUERY,
+       if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
                                                  NULL, NULL, &num_desc, 
&num_val) != 0 )
         {
             fprintf(stderr, "Error getting number of perf counters: %d (%s)\n",
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
         exit(-1);
     }
 
-    if ( xc_perfc_control(xc_handle, DOM0_PERFCCONTROL_OP_QUERY,
+    if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query,
                                                  pcd, pcv, NULL, NULL) != 0 )
     {
         fprintf(stderr, "Error getting perf counter: %d (%s)\n",
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/python/xen/lowlevel/xc/xc.c Sun Aug 27 10:24:41 2006 -0600
@@ -141,7 +141,7 @@ static PyObject *pyxc_vcpu_setaffinity(X
 {
     uint32_t dom;
     int vcpu = 0, i;
-    cpumap_t cpumap = ~0ULL;
+    uint64_t  cpumap = ~0ULL;
     PyObject *cpulist = NULL;
 
     static char *kwd_list[] = { "dom", "vcpu", "cpumap", NULL };
@@ -154,7 +154,7 @@ static PyObject *pyxc_vcpu_setaffinity(X
     {
         cpumap = 0ULL;
         for ( i = 0; i < PyList_Size(cpulist); i++ ) 
-            cpumap |= (cpumap_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i));
+            cpumap |= (uint64_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i));
     }
   
     if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap) != 0 )
@@ -289,7 +289,7 @@ static PyObject *pyxc_vcpu_getinfo(XcObj
     uint32_t dom, vcpu = 0;
     xc_vcpuinfo_t info;
     int rc, i;
-    cpumap_t cpumap;
+    uint64_t cpumap;
 
     static char *kwd_list[] = { "dom", "vcpu", NULL };
     
@@ -298,6 +298,9 @@ static PyObject *pyxc_vcpu_getinfo(XcObj
         return NULL;
 
     rc = xc_vcpu_getinfo(self->xc_handle, dom, vcpu, &info);
+    if ( rc < 0 )
+        return PyErr_SetFromErrno(xc_error);
+    rc = xc_vcpu_getaffinity(self->xc_handle, dom, vcpu, &cpumap);
     if ( rc < 0 )
         return PyErr_SetFromErrno(xc_error);
 
@@ -308,7 +311,6 @@ static PyObject *pyxc_vcpu_getinfo(XcObj
                               "cpu_time", info.cpu_time,
                               "cpu",      info.cpu);
 
-    cpumap = info.cpumap;
     cpulist = PyList_New(0);
     for ( i = 0; cpumap != 0; i++ )
     {
@@ -386,83 +388,6 @@ static PyObject *pyxc_hvm_build(XcObject
         return PyErr_SetFromErrno(xc_error);
 
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
-}
-
-static PyObject *pyxc_bvtsched_global_set(XcObject *self, PyObject *args)
-{
-    unsigned long ctx_allow;
-
-    if (!PyArg_ParseTuple(args, "l", &ctx_allow))
-        return NULL;
-
-    if (xc_bvtsched_global_set(self->xc_handle, ctx_allow) != 0)
-        return PyErr_SetFromErrno(xc_error);
-    
-    Py_INCREF(zero);
-    return zero;
-}
-
-static PyObject *pyxc_bvtsched_global_get(XcObject *self)
-{
-    unsigned long ctx_allow;
-    
-    if (xc_bvtsched_global_get(self->xc_handle, &ctx_allow) != 0)
-        return PyErr_SetFromErrno(xc_error);
-    
-    return Py_BuildValue("s:l", "ctx_allow", ctx_allow);
-}
-
-static PyObject *pyxc_bvtsched_domain_set(XcObject *self,
-                                          PyObject *args,
-                                          PyObject *kwds)
-{
-    uint32_t dom;
-    uint32_t mcuadv;
-    int warpback; 
-    int32_t warpvalue;
-    long long warpl;
-    long long warpu;
-
-    static char *kwd_list[] = { "dom", "mcuadv", "warpback", "warpvalue",
-                                "warpl", "warpu", NULL };
-
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiiLL", kwd_list,
-                                      &dom, &mcuadv, &warpback, &warpvalue, 
-                                      &warpl, &warpu) )
-        return NULL;
-
-    if ( xc_bvtsched_domain_set(self->xc_handle, dom, mcuadv, 
-                                warpback, warpvalue, warpl, warpu) != 0 )
-        return PyErr_SetFromErrno(xc_error);
-    
-    Py_INCREF(zero);
-    return zero;
-}
-
-static PyObject *pyxc_bvtsched_domain_get(XcObject *self,
-                                          PyObject *args)
-{
-    uint32_t dom;
-    uint32_t mcuadv;
-    int warpback; 
-    int32_t warpvalue;
-    long long warpl;
-    long long warpu;
-    
-    if (!PyArg_ParseTuple(args, "i", &dom))
-        return NULL;
-    
-    if (xc_bvtsched_domain_get(self->xc_handle, dom, &mcuadv, &warpback,
-                               &warpvalue, &warpl, &warpu) != 0)
-        return PyErr_SetFromErrno(xc_error);
-
-    return Py_BuildValue("{s:i,s:l,s:l,s:l,s:l}",
-                         "domain", dom,
-                         "mcuadv", mcuadv,
-                         "warpback", warpback,
-                         "warpvalue", warpvalue,
-                         "warpl", warpl,
-                         "warpu", warpu);
 }
 
 static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self,
@@ -709,11 +634,11 @@ static PyObject *pyxc_shadow_mem_control
         return NULL;
     
     if ( mbarg < 0 ) 
-        op = DOM0_SHADOW_CONTROL_OP_GET_ALLOCATION;
+        op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
     else 
     {
         mb = mbarg;
-        op = DOM0_SHADOW_CONTROL_OP_SET_ALLOCATION;
+        op = XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION;
     }
     if ( xc_shadow_control(xc->xc_handle, dom, op, NULL, 0, &mb, 0, NULL) < 0 )
         return PyErr_SetFromErrno(xc_error);
@@ -731,7 +656,7 @@ static PyObject *pyxc_sched_credit_domai
     uint16_t cap;
     static char *kwd_list[] = { "dom", "weight", "cap", NULL };
     static char kwd_type[] = "I|HH";
-    struct sched_credit_adjdom sdom;
+    struct xen_domctl_sched_credit sdom;
     
     weight = 0;
     cap = (uint16_t)~0U;
@@ -752,7 +677,7 @@ static PyObject *pyxc_sched_credit_domai
 static PyObject *pyxc_sched_credit_domain_get(XcObject *self, PyObject *args)
 {
     uint32_t domid;
-    struct sched_credit_adjdom sdom;
+    struct xen_domctl_sched_credit sdom;
     
     if( !PyArg_ParseTuple(args, "I", &domid) )
         return NULL;
@@ -1051,45 +976,6 @@ static PyMethodDef pyxc_methods[] = {
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
-    { "bvtsched_global_set",
-      (PyCFunction)pyxc_bvtsched_global_set,
-      METH_VARARGS | METH_KEYWORDS, "\n"
-      "Set global tuning parameters for Borrowed Virtual Time scheduler.\n"
-      " ctx_allow [int]: Minimal guaranteed quantum.\n\n"
-      "Returns: [int] 0 on success; -1 on error.\n" },
-
-    { "bvtsched_global_get",
-      (PyCFunction)pyxc_bvtsched_global_get,
-      METH_NOARGS, "\n"
-      "Get global tuning parameters for BVT scheduler.\n"
-      "Returns: [dict]:\n"
-      " ctx_allow [int]: context switch allowance\n" },
-
-    { "bvtsched_domain_set",
-      (PyCFunction)pyxc_bvtsched_domain_set,
-      METH_VARARGS | METH_KEYWORDS, "\n"
-      "Set per-domain tuning parameters for Borrowed Virtual Time scheduler.\n"
-      " dom       [int]: Identifier of domain to be tuned.\n"
-      " mcuadv    [int]: Proportional to the inverse of the domain's weight.\n"
-      " warpback  [int]: Warp ? \n"
-      " warpvalue [int]: How far to warp domain's EVT on unblock.\n"
-      " warpl     [int]: How long the domain can run warped.\n"
-      " warpu     [int]: How long before the domain can warp again.\n\n"
-      "Returns:   [int] 0 on success; -1 on error.\n" },
-
-    { "bvtsched_domain_get",
-      (PyCFunction)pyxc_bvtsched_domain_get,
-      METH_VARARGS, "\n"
-      "Get per-domain tuning parameters under the BVT scheduler.\n"
-      " dom [int]: Identifier of domain to be queried.\n"
-      "Returns [dict]:\n"
-      " domain [int]:  Domain ID.\n"
-      " mcuadv [long]: MCU Advance.\n"
-      " warp   [long]: Warp.\n"
-      " warpu  [long]: Unwarp requirement.\n"
-      " warpl  [long]: Warp limit,\n"
-    },
-    
     { "sedf_domain_set",
       (PyCFunction)pyxc_sedf_domain_set,
       METH_KEYWORDS, "\n"
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/python/xen/xend/XendDomain.py       Sun Aug 27 10:24:41 2006 -0600
@@ -471,34 +471,6 @@ class XendDomain:
         except Exception, ex:
             raise XendError(str(ex))
 
-    def domain_cpu_bvt_set(self, domid, mcuadv, warpback, warpvalue, warpl,
-                           warpu):
-        """Set BVT (Borrowed Virtual Time) scheduler parameters for a domain.
-        """
-        dominfo = self.domain_lookup_by_name_or_id_nr(domid)
-        if not dominfo:
-            raise XendInvalidDomain(str(domid))
-        try:
-            return xc.bvtsched_domain_set(dom=dominfo.getDomid(),
-                                          mcuadv=mcuadv,
-                                          warpback=warpback,
-                                          warpvalue=warpvalue, 
-                                          warpl=warpl, warpu=warpu)
-        except Exception, ex:
-            raise XendError(str(ex))
-
-    def domain_cpu_bvt_get(self, domid):
-        """Get BVT (Borrowed Virtual Time) scheduler parameters for a domain.
-        """
-        dominfo = self.domain_lookup_by_name_or_id_nr(domid)
-        if not dominfo:
-            raise XendInvalidDomain(str(domid))
-        try:
-            return xc.bvtsched_domain_get(dominfo.getDomid())
-        except Exception, ex:
-            raise XendError(str(ex))
-    
-    
     def domain_cpu_sedf_set(self, domid, period, slice_, latency, extratime,
                             weight):
         """Set Simple EDF scheduler parameters for a domain.
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/python/xen/xend/XendNode.py Sun Aug 27 10:24:41 2006 -0600
@@ -39,12 +39,6 @@ class XendNode:
     def notify(self, _):
         return 0
     
-    def cpu_bvt_slice_set(self, ctx_allow):
-        return self.xc.bvtsched_global_set(ctx_allow)
-
-    def cpu_bvt_slice_get(self):
-        return self.xc.bvtsched_global_get()
-    
     def info(self):
         return (self.nodeinfo() + self.physinfo() + self.xeninfo() +
                 self.xendinfo())
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/python/xen/xend/server/SrvDomain.py Sun Aug 27 10:24:41 2006 -0600
@@ -102,18 +102,6 @@ class SrvDomain(SrvDir):
         val = fn(req.args, {'dom': self.dom.domid})
         return val
 
-    def op_cpu_bvt_set(self, _, req):
-        fn = FormFn(self.xd.domain_cpu_bvt_set,
-                    [['dom',       'int'],
-                     ['mcuadv',    'int'],
-                     ['warpback',  'int'],
-                     ['warpvalue', 'int'],
-                     ['warpl',     'long'],
-                     ['warpu',     'long']])
-        val = fn(req.args, {'dom': self.dom.domid})
-        return val
-    
-    
     def op_cpu_sedf_get(self, _, req):
         fn = FormFn(self.xd.domain_cpu_sedf_get,
                     [['dom', 'int']])
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/python/xen/xend/server/SrvNode.py
--- a/tools/python/xen/xend/server/SrvNode.py   Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/python/xen/xend/server/SrvNode.py   Sun Aug 27 10:24:41 2006 -0600
@@ -39,12 +39,6 @@ class SrvNode(SrvDir):
         val = self.xn.reboot()
         return val
 
-    def op_cpu_bvt_slice_set(self, _, req):
-        fn = FormFn(self.xn.cpu_bvt_slice_set,
-                    [['ctx_allow', 'int']])
-        val = fn(req.args, {})
-        return val
-    
     def render_POST(self, req):
         return self.perform(req)
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py      Fri Aug 25 16:21:39 
2006 -0600
+++ b/tools/python/xen/xend/server/XMLRPCServer.py      Sun Aug 27 10:24:41 
2006 -0600
@@ -109,7 +109,7 @@ class XMLRPCServer:
                     self.server.register_function(fn, "xend.domain.%s" % 
name[7:])
 
         # Functions in XendNode and XendDmesg
-        for type, lst, n in [(XendNode, ['info', 'cpu_bvt_slice_set'], 'node'),
+        for type, lst, n in [(XendNode, ['info'], 'node'),
                              (XendDmesg, ['info', 'clear'], 'node.dmesg')]:
             inst = type.instance()
             for name in lst:
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/python/xen/xm/main.py       Sun Aug 27 10:24:41 2006 -0600
@@ -89,10 +89,6 @@ info_help =    "info                    
 info_help =    "info                             Get information about the xen 
host"
 rename_help =  "rename <DomId> <New Name>        Rename a domain"
 log_help =     "log                              Print the xend log"
-sched_bvt_help = """sched-bvt <Parameters>           Set Borrowed Virtual Time 
scheduler
-                                    parameters"""
-sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow>       Set the BVT 
scheduler context switch
-                                    allowance"""
 sched_sedf_help = "sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF 
parameters\n" + \
 "              -p, --period          Relative deadline(ms).\n\
               -s, --slice           Worst-case execution time(ms)\n\
@@ -192,8 +188,6 @@ host_commands = [
 
 scheduler_commands = [
     "sched-credit",
-    "sched-bvt",
-    "sched-bvt-ctxallow",
     "sched-sedf",
     ]
 
@@ -671,18 +665,6 @@ def xm_domname(args):
 
     dom = server.xend.domain(name)
     print sxp.child_value(dom, 'name')
-
-def xm_sched_bvt(args):
-    arg_check(args, "sched-bvt", 6)
-    dom = args[0]
-    v = map(long, args[1:6])
-    server.xend.domain.cpu_bvt_set(dom, *v)
-
-def xm_sched_bvt_ctxallow(args):
-    arg_check(args, "sched-bvt-ctxallow", 1)
-
-    slice = int(args[0])
-    server.xend.node.cpu_bvt_slice_set(slice)
 
 def xm_sched_sedf(args):
     def ns_to_ms(val):
@@ -1209,8 +1191,6 @@ commands = {
     "log": xm_log,
     "serve": xm_serve,
     # scheduler
-    "sched-bvt": xm_sched_bvt,
-    "sched-bvt-ctxallow": xm_sched_bvt_ctxallow,
     "sched-sedf": xm_sched_sedf,
     "sched-credit": xm_sched_credit,
     # block
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/tests/test_x86_emulator.c
--- a/tools/tests/test_x86_emulator.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/tests/test_x86_emulator.c   Sun Aug 27 10:24:41 2006 -0600
@@ -15,6 +15,8 @@ typedef int64_t            s64;
 #include <asm-x86/x86_emulate.h>
 #include <sys/mman.h>
 
+#define PFEC_write_access (1U<<1)
+
 static int read_any(
     unsigned long addr,
     unsigned long *val,
@@ -105,6 +107,7 @@ int main(int argc, char **argv)
     regs.eflags = 0x200;
     regs.eip    = (unsigned long)&instr[0];
     regs.ecx    = 0x12345678;
+    regs.error_code = PFEC_write_access;
     ctxt.cr2    = (unsigned long)res;
     *res        = 0x7FFFFFFF;
     rc = x86_emulate_memop(&ctxt, &emulops);
@@ -125,6 +128,7 @@ int main(int argc, char **argv)
     regs.ecx    = 0x12345678UL;
 #endif
     ctxt.cr2    = (unsigned long)res;
+    regs.error_code = 0;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0x92345677) || 
@@ -139,6 +143,7 @@ int main(int argc, char **argv)
     regs.eip    = (unsigned long)&instr[0];
     regs.ecx    = ~0UL;
     ctxt.cr2    = (unsigned long)res;
+    regs.error_code = 0;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0x92345677) || 
@@ -154,6 +159,7 @@ int main(int argc, char **argv)
     regs.eax    = 0x92345677UL;
     regs.ecx    = 0xAA;
     ctxt.cr2    = (unsigned long)res;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0x923456AA) || 
@@ -170,6 +176,7 @@ int main(int argc, char **argv)
     regs.eax    = 0xAABBCC77UL;
     regs.ecx    = 0xFF;
     ctxt.cr2    = (unsigned long)res;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0x923456AA) || 
@@ -186,6 +193,7 @@ int main(int argc, char **argv)
     regs.eip    = (unsigned long)&instr[0];
     regs.ecx    = 0x12345678;
     ctxt.cr2    = (unsigned long)res;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0x12345678) || 
@@ -203,6 +211,7 @@ int main(int argc, char **argv)
     regs.eax    = 0x923456AAUL;
     regs.ecx    = 0xDDEEFF00L;
     ctxt.cr2    = (unsigned long)res;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0xDDEEFF00) || 
@@ -240,6 +249,7 @@ int main(int argc, char **argv)
     regs.eip    = (unsigned long)&instr[0];
     regs.edi    = (unsigned long)res;
     ctxt.cr2    = regs.edi;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (*res != 0x2233445D) ||
@@ -261,6 +271,7 @@ int main(int argc, char **argv)
     regs.eip    = (unsigned long)&instr[0];
     regs.edi    = (unsigned long)res;
     ctxt.cr2    = regs.edi;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (res[0] != 0x9999AAAA) ||
@@ -275,6 +286,7 @@ int main(int argc, char **argv)
     regs.eip    = (unsigned long)&instr[0];
     regs.edi    = (unsigned long)res;
     ctxt.cr2    = regs.edi;
+    regs.error_code = PFEC_write_access;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) || 
          (res[0] != 0x9999AAAA) ||
@@ -292,6 +304,7 @@ int main(int argc, char **argv)
     regs.ecx    = 0x12345678;
     ctxt.cr2    = (unsigned long)res;
     *res        = 0x82;
+    regs.error_code = 0;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) ||
          (*res != 0x82) ||
@@ -307,6 +320,7 @@ int main(int argc, char **argv)
     regs.ecx    = 0x12345678;
     ctxt.cr2    = (unsigned long)res;
     *res        = 0x1234aa82;
+    regs.error_code = 0;
     rc = x86_emulate_memop(&ctxt, &emulops);
     if ( (rc != 0) ||
          (*res != 0x1234aa82) ||
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/xcutils/Makefile
--- a/tools/xcutils/Makefile    Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/xcutils/Makefile    Sun Aug 27 10:24:41 2006 -0600
@@ -26,7 +26,7 @@ CFLAGS += -Wp,-MD,.$(@F).d
 CFLAGS += -Wp,-MD,.$(@F).d
 PROG_DEP = .*.d
 
-PROGRAMS               = xc_restore xc_save
+PROGRAMS               = xc_restore xc_save readnotes
 
 LDLIBS                 = -L$(XEN_LIBXC) -lxenguest -lxenctrl
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/xenmon/setmask.c
--- a/tools/xenmon/setmask.c    Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/xenmon/setmask.c    Sun Aug 27 10:24:41 2006 -0600
@@ -40,15 +40,14 @@ typedef struct { int counter; } atomic_t
 
 int main(int argc, char * argv[])
 {
-
-    dom0_op_t op; 
+    struct xen_sysctl sysctl;
     int ret;
 
     int xc_handle = xc_interface_open();
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
-    ret = xc_dom0_op(xc_handle, &op);
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
+    ret = xc_sysctl(xc_handle, &sysctl);
     if ( ret != 0 )
     {
         perror("Failure to get event mask from Xen");
@@ -56,26 +55,26 @@ int main(int argc, char * argv[])
     }
     else
     {
-        printf("Current event mask: 0x%.8x\n", op.u.tbufcontrol.evt_mask);
+        printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
     }
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_SET_EVT_MASK;
-    op.u.tbufcontrol.evt_mask = XENMON;
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_evt_mask;
+    sysctl.u.tbuf_op.evt_mask = XENMON;
 
-    ret = xc_dom0_op(xc_handle, &op);
-    printf("Setting mask to 0x%.8x\n", op.u.tbufcontrol.evt_mask);
+    ret = xc_sysctl(xc_handle, &sysctl);
+    printf("Setting mask to 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
     if ( ret != 0 )
     {
         perror("Failure to get scheduler ID from Xen");
         exit(1);
     }
 
-    op.cmd = DOM0_TBUFCONTROL;
-    op.interface_version = DOM0_INTERFACE_VERSION;
-    op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
-    ret = xc_dom0_op(xc_handle, &op);
+    sysctl.cmd = XEN_SYSCTL_tbuf_op;
+    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
+    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
+    ret = xc_sysctl(xc_handle, &sysctl);
     if ( ret != 0 )
     {
         perror("Failure to get event mask from Xen");
@@ -83,7 +82,7 @@ int main(int argc, char * argv[])
     }
     else
     {
-        printf("Current event mask: 0x%.8x\n", op.u.tbufcontrol.evt_mask);
+        printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
     }
     xc_interface_close(xc_handle);
     return 0;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c    Fri Aug 25 16:21:39 2006 -0600
+++ b/tools/xenstat/libxenstat/src/xenstat.c    Sun Aug 27 10:24:41 2006 -0600
@@ -210,8 +210,8 @@ xenstat_node *xenstat_get_node(xenstat_h
 {
 #define DOMAIN_CHUNK_SIZE 256
        xenstat_node *node;
-       dom0_physinfo_t physinfo;
-       dom0_getdomaininfo_t domaininfo[DOMAIN_CHUNK_SIZE];
+       xc_physinfo_t physinfo;
+       xc_domaininfo_t domaininfo[DOMAIN_CHUNK_SIZE];
        unsigned int new_domains;
        unsigned int i;
 
@@ -530,7 +530,7 @@ static int xenstat_collect_vcpus(xenstat
        
                for (vcpu = 0; vcpu < node->domains[i].num_vcpus; vcpu++) {
                        /* FIXME: need to be using a more efficient mechanism*/
-                       dom0_getvcpuinfo_t info;
+                       xc_vcpuinfo_t info;
 
                        if (xc_vcpu_getinfo(node->handle->xc_handle,
                                            node->domains[i].id, vcpu, &info) 
!= 0) {
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/acm/acm_simple_type_enforcement_hooks.c
--- a/xen/acm/acm_simple_type_enforcement_hooks.c       Fri Aug 25 16:21:39 
2006 -0600
+++ b/xen/acm/acm_simple_type_enforcement_hooks.c       Sun Aug 27 10:24:41 
2006 -0600
@@ -353,7 +353,7 @@ ste_dump_stats(u8 *buf, u16 buf_len)
     stats.ec_cachehit_count = 
htonl(atomic_read(&ste_bin_pol.ec_cachehit_count));
     stats.gt_cachehit_count = 
htonl(atomic_read(&ste_bin_pol.gt_cachehit_count));
 
-    if (buf_len < sizeof(struct acm_ste_stats_buffer)
+    if (buf_len < sizeof(struct acm_ste_stats_buffer))
         return -ENOMEM;
 
     memcpy(buf, &stats, sizeof(struct acm_ste_stats_buffer));
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/ia64/tools/xelilo/elilo.README
--- a/xen/arch/ia64/tools/xelilo/elilo.README   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/ia64/tools/xelilo/elilo.README   Sun Aug 27 10:24:41 2006 -0600
@@ -17,4 +17,4 @@ 2. How to run with the new elilo.efi?
                        vmm=xen.gz
                        initrd=initrd-2.6.9-5.7.EL.img
                        read-only
-                       append="com2=57600,8n1 console=com2 sched=bvt -- nomca 
console=ttyS1,57600 console=tty0 root=/dev/sda3"
+                       append="com2=57600,8n1 console=com2 -- nomca 
console=ttyS1,57600 console=tty0 root=/dev/sda3"
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/ia64/xen/dom0_ops.c
--- a/xen/arch/ia64/xen/dom0_ops.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/ia64/xen/dom0_ops.c      Sun Aug 27 10:24:41 2006 -0600
@@ -10,14 +10,14 @@
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
-#include <public/dom0_ops.h>
+#include <public/domctl.h>
+#include <public/sysctl.h>
 #include <xen/sched.h>
 #include <xen/event.h>
 #include <asm/pdb.h>
 #include <xen/trace.h>
 #include <xen/console.h>
 #include <xen/guest_access.h>
-#include <public/sched_ctl.h>
 #include <asm/vmx.h>
 #include <asm/dom_fw.h>
 #include <xen/iocap.h>
@@ -26,7 +26,8 @@ void build_physmap_table(struct domain *
 void build_physmap_table(struct domain *d);
 
 extern unsigned long total_pages;
-long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
+
+long arch_do_domctl(xen_domctl_t *op, XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
 {
     long ret = 0;
 
@@ -35,10 +36,10 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_
 
     switch ( op->cmd )
     {
-    case DOM0_GETMEMLIST:
+    case XEN_DOMCTL_getmemlist:
     {
         unsigned long i;
-        struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
+        struct domain *d = find_domain_by_id(op->domain);
         unsigned long start_page = op->u.getmemlist.max_pfns >> 32;
         unsigned long nr_pages = op->u.getmemlist.max_pfns & 0xffffffff;
         unsigned long mfn;
@@ -64,16 +65,132 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_
         }
 
         op->u.getmemlist.num_pfns = i;
-        if (copy_to_guest(u_dom0_op, op, 1))
+        if (copy_to_guest(u_domctl, op, 1))
             ret = -EFAULT;
 
         put_domain(d);
     }
     break;
 
-    case DOM0_PHYSINFO:
-    {
-        dom0_physinfo_t *pi = &op->u.physinfo;
+    case XEN_DOMCTL_arch_setup:
+    {
+        xen_domctl_arch_setup_t *ds = &op->u.arch_setup;
+        struct domain *d = find_domain_by_id(op->domain);
+
+        if ( d == NULL) {
+            ret = -EINVAL;
+            break;
+        }
+
+        if (ds->flags & XEN_DOMAINSETUP_query) {
+            /* Set flags.  */
+            if (d->arch.is_vti)
+                ds->flags |= XEN_DOMAINSETUP_hvm_guest;
+            /* Set params.  */
+            ds->bp = 0;                /* unknown.  */
+            ds->maxmem = 0; /* unknown.  */
+            ds->xsi_va = d->arch.shared_info_va;
+            ds->hypercall_imm = d->arch.breakimm;
+            /* Copy back.  */
+            if ( copy_to_guest(u_domctl, op, 1) )
+                ret = -EFAULT;
+        }
+        else {
+            if (ds->flags & XEN_DOMAINSETUP_hvm_guest) {
+                if (!vmx_enabled) {
+                    printk("No VMX hardware feature for vmx domain.\n");
+                    ret = -EINVAL;
+                    break;
+                }
+                if (!d->arch.is_vti) {
+                    struct vcpu *v;
+                    for_each_vcpu(d, v) {
+                        BUG_ON(v->arch.privregs == NULL);
+                        free_domheap_pages(virt_to_page(v->arch.privregs),
+                                      get_order_from_shift(XMAPPEDREGS_SHIFT));
+                        relinquish_vcpu_resources(v);
+                    }
+                }
+                d->arch.is_vti = 1;
+                vmx_setup_platform(d);
+            }
+            else {
+                build_physmap_table(d);
+                dom_fw_setup(d, ds->bp, ds->maxmem);
+                if (ds->xsi_va)
+                    d->arch.shared_info_va = ds->xsi_va;
+                if (ds->hypercall_imm) {
+                    struct vcpu *v;
+                    d->arch.breakimm = ds->hypercall_imm;
+                    for_each_vcpu (d, v)
+                        v->arch.breakimm = d->arch.breakimm;
+                }
+            }
+        }
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_shadow_op:
+    {
+        struct domain *d; 
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d != NULL )
+        {
+            ret = shadow_mode_control(d, &op->u.shadow_op);
+            put_domain(d);
+            copy_to_guest(u_domctl, op, 1);
+        } 
+    }
+    break;
+
+    case XEN_DOMCTL_ioport_permission:
+    {
+        struct domain *d;
+        unsigned int fp = op->u.ioport_permission.first_port;
+        unsigned int np = op->u.ioport_permission.nr_ports;
+        unsigned int lp = fp + np - 1;
+
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if (unlikely(d == NULL))
+            break;
+
+        if (np == 0)
+            ret = 0;
+        else {
+            if (op->u.ioport_permission.allow_access)
+                ret = ioports_permit_access(d, fp, lp);
+            else
+                ret = ioports_deny_access(d, fp, lp);
+        }
+
+        put_domain(d);
+    }
+    break;
+    default:
+        printf("arch_do_domctl: unrecognized domctl: %d!!!\n",op->cmd);
+        ret = -ENOSYS;
+
+    }
+
+    return ret;
+}
+
+long arch_do_sysctl(xen_sysctl_t *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
+{
+    long ret = 0;
+
+    if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+
+    switch ( op->cmd )
+    {
+    case XEN_SYSCTL_physinfo:
+    {
+        xen_sysctl_physinfo_t *pi = &op->u.physinfo;
 
         pi->threads_per_core =
             cpus_weight(cpu_sibling_map[0]);
@@ -88,111 +205,13 @@ long arch_do_dom0_op(dom0_op_t *op, XEN_
         memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
         //memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
         ret = 0;
-        if ( copy_to_guest(u_dom0_op, op, 1) )
+        if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
     }
     break;
 
-    case DOM0_DOMAIN_SETUP:
-    {
-        dom0_domain_setup_t *ds = &op->u.domain_setup;
-        struct domain *d = find_domain_by_id(ds->domain);
-
-        if ( d == NULL) {
-            ret = -EINVAL;
-            break;
-        }
-
-        if (ds->flags & XEN_DOMAINSETUP_query) {
-            /* Set flags.  */
-            if (d->arch.is_vti)
-                ds->flags |= XEN_DOMAINSETUP_hvm_guest;
-            /* Set params.  */
-            ds->bp = 0;                /* unknown.  */
-            ds->maxmem = 0; /* unknown.  */
-            ds->xsi_va = d->arch.shared_info_va;
-            ds->hypercall_imm = d->arch.breakimm;
-            /* Copy back.  */
-            if ( copy_to_guest(u_dom0_op, op, 1) )
-                ret = -EFAULT;
-        }
-        else {
-            if (ds->flags & XEN_DOMAINSETUP_hvm_guest) {
-                if (!vmx_enabled) {
-                    printk("No VMX hardware feature for vmx domain.\n");
-                    ret = -EINVAL;
-                    break;
-                }
-                if (!d->arch.is_vti) {
-                    struct vcpu *v;
-                    for_each_vcpu(d, v) {
-                        BUG_ON(v->arch.privregs == NULL);
-                        free_domheap_pages(virt_to_page(v->arch.privregs),
-                                      get_order_from_shift(XMAPPEDREGS_SHIFT));
-                        relinquish_vcpu_resources(v);
-                    }
-                }
-                d->arch.is_vti = 1;
-                vmx_setup_platform(d);
-            }
-            else {
-                build_physmap_table(d);
-                dom_fw_setup(d, ds->bp, ds->maxmem);
-                if (ds->xsi_va)
-                    d->arch.shared_info_va = ds->xsi_va;
-                if (ds->hypercall_imm) {
-                    struct vcpu *v;
-                    d->arch.breakimm = ds->hypercall_imm;
-                    for_each_vcpu (d, v)
-                        v->arch.breakimm = d->arch.breakimm;
-                }
-            }
-        }
-
-        put_domain(d);
-    }
-    break;
-
-    case DOM0_SHADOW_CONTROL:
-    {
-        struct domain *d; 
-        ret = -ESRCH;
-        d = find_domain_by_id(op->u.shadow_control.domain);
-        if ( d != NULL )
-        {
-            ret = shadow_mode_control(d, &op->u.shadow_control);
-            put_domain(d);
-            copy_to_guest(u_dom0_op, op, 1);
-        } 
-    }
-    break;
-
-    case DOM0_IOPORT_PERMISSION:
-    {
-        struct domain *d;
-        unsigned int fp = op->u.ioport_permission.first_port;
-        unsigned int np = op->u.ioport_permission.nr_ports;
-        unsigned int lp = fp + np - 1;
-
-        ret = -ESRCH;
-        d = find_domain_by_id(op->u.ioport_permission.domain);
-        if (unlikely(d == NULL))
-            break;
-
-        if (np == 0)
-            ret = 0;
-        else {
-            if (op->u.ioport_permission.allow_access)
-                ret = ioports_permit_access(d, fp, lp);
-            else
-                ret = ioports_deny_access(d, fp, lp);
-        }
-
-        put_domain(d);
-    }
-    break;
-    default:
-        printf("arch_do_dom0_op: unrecognized dom0 op: %d!!!\n",op->cmd);
+    default:
+        printf("arch_do_sysctl: unrecognized sysctl: %d!!!\n",op->cmd);
         ret = -ENOSYS;
 
     }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/ia64/xen/domain.c        Sun Aug 27 10:24:41 2006 -0600
@@ -615,7 +615,7 @@ domain_set_shared_info_va (unsigned long
 /* Transfer and clear the shadow bitmap in 1kB chunks for L1 cache. */
 #define SHADOW_COPY_CHUNK (1024 / sizeof (unsigned long))
 
-int shadow_mode_control(struct domain *d, dom0_shadow_control_t *sc)
+int shadow_mode_control(struct domain *d, xen_domctl_shadow_ops_t *sc)
 {
        unsigned int op = sc->op;
        int          rc = 0;
@@ -631,7 +631,7 @@ int shadow_mode_control(struct domain *d
 
        switch (op)
        {
-       case DOM0_SHADOW_CONTROL_OP_OFF:
+       case XEN_DOMCTL_SHADOW_OP_OFF:
                if (shadow_mode_enabled (d)) {
                        u64 *bm = d->arch.shadow_bitmap;
 
@@ -645,12 +645,12 @@ int shadow_mode_control(struct domain *d
                }
                break;
 
-       case DOM0_SHADOW_CONTROL_OP_ENABLE_TEST:
-       case DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE:
+       case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST:
+       case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE:
                rc = -EINVAL;
                break;
 
-       case DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY:
+       case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY:
                if (shadow_mode_enabled(d)) {
                        rc = -EINVAL;
                        break;
@@ -677,7 +677,7 @@ int shadow_mode_control(struct domain *d
                }
                break;
 
-       case DOM0_SHADOW_CONTROL_OP_CLEAN:
+       case XEN_DOMCTL_SHADOW_OP_CLEAN:
          {
                int nbr_longs;
 
@@ -716,7 +716,7 @@ int shadow_mode_control(struct domain *d
                break;
          }
 
-       case DOM0_SHADOW_CONTROL_OP_PEEK:
+       case XEN_DOMCTL_SHADOW_OP_PEEK:
        {
                unsigned long size;
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/ia64/xen/hypercall.c
--- a/xen/arch/ia64/xen/hypercall.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/ia64/xen/hypercall.c     Sun Aug 27 10:24:41 2006 -0600
@@ -19,7 +19,8 @@
 
 #include <asm/vcpu.h>
 #include <asm/dom_fw.h>
-#include <public/dom0_ops.h>
+#include <public/domctl.h>
+#include <public/sysctl.h>
 #include <public/event_channel.h>
 #include <public/memory.h>
 #include <public/sched.h>
@@ -44,7 +45,7 @@ const hypercall_t ia64_hypercall_table[N
        (hypercall_t)do_ni_hypercall,           /* do_set_callbacks */
        (hypercall_t)do_ni_hypercall,           /* do_fpu_taskswitch *//*  5 */
        (hypercall_t)do_sched_op_compat,
-       (hypercall_t)do_dom0_op,
+       (hypercall_t)do_ni_hypercall,
        (hypercall_t)do_ni_hypercall,           /* do_set_debugreg */
        (hypercall_t)do_ni_hypercall,           /* do_get_debugreg */
        (hypercall_t)do_ni_hypercall,           /* do_update_descriptor * 10 */
@@ -72,8 +73,8 @@ const hypercall_t ia64_hypercall_table[N
        (hypercall_t)do_event_channel_op,
        (hypercall_t)do_physdev_op,
        (hypercall_t)do_hvm_op,                 /*  */
-       (hypercall_t)do_ni_hypercall,           /*  */                 /* 35 */
-       (hypercall_t)do_ni_hypercall,           /*  */
+       (hypercall_t)do_sysctl,                 /*  */                  /* 35 */
+       (hypercall_t)do_domctl,                 /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
        (hypercall_t)do_ni_hypercall,           /*  */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/powerpc/dom0_ops.c
--- a/xen/arch/powerpc/dom0_ops.c       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/powerpc/dom0_ops.c       Sun Aug 27 10:24:41 2006 -0600
@@ -24,10 +24,8 @@
 #include <xen/sched.h>
 #include <xen/guest_access.h>
 #include <public/xen.h>
-#include <public/dom0_ops.h>
-
-extern void arch_getdomaininfo_ctxt(struct vcpu *v, vcpu_guest_context_t *c);
-extern long arch_do_dom0_op(struct dom0_op *op, XEN_GUEST_HANDLE(dom0_op_t) 
u_dom0_op);
+#include <public/domctl.h>
+#include <public/sysctl.h>
 
 void arch_getdomaininfo_ctxt(struct vcpu *v, vcpu_guest_context_t *c)
 { 
@@ -35,16 +33,17 @@ void arch_getdomaininfo_ctxt(struct vcpu
     /* XXX fill in rest of vcpu_guest_context_t */
 }
 
-long arch_do_dom0_op(struct dom0_op *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long arch_do_domctl(struct xen_domctl *domctl,
+                    XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
 {
     long ret = 0;
 
-    switch (op->cmd) {
-    case DOM0_GETMEMLIST:
+    switch (domctl->cmd) {
+    case XEN_DOMCTL_getmemlist:
     {
         int i;
-        struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
-        unsigned long max_pfns = op->u.getmemlist.max_pfns;
+        struct domain *d = find_domain_by_id(domctl->domain);
+        unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
         xen_pfn_t mfn;
         struct list_head *list_ent;
 
@@ -59,7 +58,7 @@ long arch_do_dom0_op(struct dom0_op *op,
             {
                 mfn = page_to_mfn(list_entry(
                     list_ent, struct page_info, list));
-                if ( copy_to_guest_offset(op->u.getmemlist.buffer,
+                if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
                                           i, &mfn, 1) )
                 {
                     ret = -EFAULT;
@@ -69,17 +68,31 @@ long arch_do_dom0_op(struct dom0_op *op,
             }
             spin_unlock(&d->page_alloc_lock);
 
-            op->u.getmemlist.num_pfns = i;
-            copy_to_guest(u_dom0_op, op, 1);
+            domctl->u.getmemlist.num_pfns = i;
+            copy_to_guest(u_domctl, domctl, 1);
             
             put_domain(d);
         }
     }
     break;
 
-    case DOM0_PHYSINFO:
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    return ret;
+}
+
+long arch_do_sysctl(struct xen_sysctl *sysctl,
+                    XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
+{
+    long ret = 0;
+
+    switch (sysctl->cmd) {
+    case XEN_SYSCTL_physinfo:
     {
-        dom0_physinfo_t *pi = &op->u.physinfo;
+        xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
 
         pi->threads_per_core = 1;
         pi->cores_per_socket = 1;
@@ -90,7 +103,7 @@ long arch_do_dom0_op(struct dom0_op *op,
         pi->cpu_khz          = cpu_khz;
         memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
         ret = 0;
-        if ( copy_to_guest(u_dom0_op, op, 1) )
+        if ( copy_to_guest(u_sysctl, sysctl, 1) )
             ret = -EFAULT;
     }
     break;
@@ -102,3 +115,4 @@ long arch_do_dom0_op(struct dom0_op *op,
 
     return ret;
 }
+
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/powerpc/domain_build.c
--- a/xen/arch/powerpc/domain_build.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/powerpc/domain_build.c   Sun Aug 27 10:24:41 2006 -0600
@@ -137,10 +137,6 @@ int construct_dom0(struct domain *d,
     dsi.v_kernend = RM_MASK(dsi.v_kernend, 42);
     dsi.v_kernentry = RM_MASK(dsi.v_kernentry, 42);
 
-    if (dsi.xen_section_string == NULL) {
-        printk("Not a Xen-ELF image: '__xen_guest' section not found.\n");
-        return -EINVAL;
-    }
     printk("*** LOADING DOMAIN 0 ***\n");
 
     /* By default DOM0 is allocated all available memory. */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
xen/arch/powerpc/powerpc64/hypercall_table.S
--- a/xen/arch/powerpc/powerpc64/hypercall_table.S      Fri Aug 25 16:21:39 
2006 -0600
+++ b/xen/arch/powerpc/powerpc64/hypercall_table.S      Sun Aug 27 10:24:41 
2006 -0600
@@ -11,7 +11,7 @@ __hypercall_table:
         .quad 0 /* do_set_callbacks */
         .quad 0 /* do_fpu_taskswitch */     /*  5 */
         .quad do_sched_op
-        .quad do_dom0_op
+        .quad 0 /* do_platform_op */
         .quad 0 /* do_set_debugreg */
         .quad 0 /* do_get_debugreg */
         .quad 0 /* do_update_descriptor */  /* 10 */
@@ -38,46 +38,9 @@ __hypercall_table:
         .quad 0 /* do_xenoprof_op */
         .quad do_event_channel_op
         .quad do_physdev_op
+        .quad 0 /* do_hvm_op */
+        .quad do_sysctl             /* 35 */
+        .quad do_domctl
         .rept NR_hypercalls-((.-__hypercall_table)/8)
         .quad do_ni_hypercall
         .endr
-
-        .globl hypercall_args_table
-hypercall_args_table:  
-        .byte 1 /* do_set_trap_table    */  /*  0 */
-        .byte 4 /* do_mmu_update        */
-        .byte 2 /* do_set_gdt           */
-        .byte 2 /* do_stack_switch      */
-        .byte 4 /* do_set_callbacks     */
-        .byte 1 /* do_fpu_taskswitch    */  /*  5 */
-        .byte 2 /* do_arch_sched_op     */
-        .byte 1 /* do_dom0_op           */
-        .byte 2 /* do_set_debugreg      */
-        .byte 1 /* do_get_debugreg      */
-        .byte 4 /* do_update_descriptor */  /* 10 */
-        .byte 0 /* do_ni_hypercall      */
-        .byte 2 /* do_memory_op         */
-        .byte 2 /* do_multicall         */
-        .byte 4 /* do_update_va_mapping */
-        .byte 2 /* do_set_timer_op      */  /* 15 */
-        .byte 1 /* do_event_channel_op  */
-        .byte 2 /* do_xen_version       */
-        .byte 3 /* do_console_io        */
-        .byte 1 /* do_physdev_op        */
-        .byte 3 /* do_grant_table_op    */  /* 20 */
-        .byte 2 /* do_vm_assist         */
-        .byte 5 /* do_update_va_mapping_otherdomain */
-        .byte 0 /* do_switch_vm86       */
-        .byte 2 /* do_boot_vcpu         */
-        .byte 0 /* do_ni_hypercall      */  /* 25 */
-        .byte 4 /* do_mmuext_op         */
-        .byte 1 /* do_acm_op            */
-        .byte 2 /* do_nmi_op            */
-        .byte 2 /* do_arch_sched_op     */
-        .byte 2 /* do_callback_op       */  /* 30 */
-        .byte 2 /* do_xenoprof_op       */
-        .byte 2 /* do_event_channel_op  */
-        .byte 2 /* do_physdev_op        */
-        .rept NR_hypercalls-(.-hypercall_args_table)
-        .byte 0 /* do_ni_hypercall      */
-        .endr
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/Makefile
--- a/xen/arch/x86/Makefile     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/Makefile     Sun Aug 27 10:24:41 2006 -0600
@@ -12,12 +12,13 @@ obj-y += compat.o
 obj-y += compat.o
 obj-y += delay.o
 obj-y += dmi_scan.o
-obj-y += dom0_ops.o
+obj-y += domctl.o
 obj-y += domain.o
 obj-y += domain_build.o
 obj-y += e820.o
 obj-y += extable.o
 obj-y += flushtlb.o
+obj-y += platform_hypercall.o
 obj-y += i387.o
 obj-y += i8259.o
 obj-y += io_apic.o
@@ -33,6 +34,7 @@ obj-y += smp.o
 obj-y += smp.o
 obj-y += smpboot.o
 obj-y += string.o
+obj-y += sysctl.o
 obj-y += time.o
 obj-y += trampoline.o
 obj-y += traps.o
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/domain_build.c       Sun Aug 27 10:24:41 2006 -0600
@@ -28,6 +28,7 @@
 #include <asm/shadow.h>
 
 #include <public/version.h>
+#include <public/elfnote.h>
 
 extern unsigned long initial_images_nrpages(void);
 extern void discard_initial_images(void);
@@ -210,8 +211,9 @@ int construct_dom0(struct domain *d,
     struct page_info *page = NULL;
     start_info_t *si;
     struct vcpu *v = d->vcpu[0];
-    char *p;
+    const char *p;
     unsigned long hypercall_page;
+    int hypercall_page_defined;
 #if defined(__i386__)
     char *image_start  = (char *)_image_start;  /* use lowmem mappings */
     char *initrd_start = (char *)_initrd_start; /* use lowmem mappings */
@@ -288,13 +290,7 @@ int construct_dom0(struct domain *d,
     if ( (rc = parseelfimage(&dsi)) != 0 )
         return rc;
 
-    if ( dsi.xen_section_string == NULL )
-    {
-        printk("Not a Xen-ELF image: '__xen_guest' section not found.\n");
-        return -EINVAL;
-    }
-
-    dom0_pae = !!strstr(dsi.xen_section_string, "PAE=yes");
+    dom0_pae = (dsi.pae_kernel != PAEKERN_no);
     xen_pae  = (CONFIG_PAGING_LEVELS == 3);
     if ( dom0_pae != xen_pae )
     {
@@ -303,15 +299,14 @@ int construct_dom0(struct domain *d,
         return -EINVAL;
     }
 
-    if ( xen_pae && !!strstr(dsi.xen_section_string, "PAE=yes[extended-cr3]") )
-        set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist);
-
-    if ( (p = strstr(dsi.xen_section_string, "FEATURES=")) != NULL )
-    {
-        parse_features(
-            p + strlen("FEATURES="),
-            dom0_features_supported,
-            dom0_features_required);
+    if ( xen_pae && dsi.pae_kernel == PAEKERN_extended_cr3 )
+            set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist);
+
+    if ( (p = xen_elfnote_string(&dsi, XEN_ELFNOTE_FEATURES)) != NULL )
+    {
+        parse_features(p,
+                       dom0_features_supported,
+                       dom0_features_required);
         printk("Domain 0 kernel supports features = { %08x }.\n",
                dom0_features_supported[0]);
         printk("Domain 0 kernel requires features = { %08x }.\n",
@@ -696,20 +691,17 @@ int construct_dom0(struct domain *d,
     /* Copy the OS image and free temporary buffer. */
     (void)loadelfimage(&dsi);
 
-    p = strstr(dsi.xen_section_string, "HYPERCALL_PAGE=");
-    if ( p != NULL )
-    {
-        p += strlen("HYPERCALL_PAGE=");
-        hypercall_page = simple_strtoul(p, NULL, 16);
-        hypercall_page = dsi.v_start + (hypercall_page << PAGE_SHIFT);
+    hypercall_page =
+        xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, 
&hypercall_page_defined);
+    if ( hypercall_page_defined )
+    {
         if ( (hypercall_page < dsi.v_start) || (hypercall_page >= v_end) )
         {
             write_ptbase(current);
             local_irq_enable();
-            printk("Invalid HYPERCALL_PAGE field in guest header.\n");
+            printk("Invalid HYPERCALL_PAGE field in ELF notes.\n");
             return -1;
         }
-
         hypercall_page_initialise(d, (void *)hypercall_page);
     }
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/mm.c Sun Aug 27 10:24:41 2006 -0600
@@ -2264,7 +2264,6 @@ int do_mmu_update(
 
     perfc_incrc(calls_to_mmu_update);
     perfc_addc(num_page_updates, count);
-    perfc_incr_histo(bpt_updates, count, PT_UPDATES);
 
     if ( unlikely(!guest_handle_okay(ureqs, count)) )
     {
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/setup.c      Sun Aug 27 10:24:41 2006 -0600
@@ -15,6 +15,7 @@
 #include <xen/version.h>
 #include <xen/gdbstub.h>
 #include <xen/percpu.h>
+#include <xen/hypercall.h>
 #include <public/version.h>
 #include <asm/bitops.h>
 #include <asm/smp.h>
@@ -416,9 +417,13 @@ void __init __start_xen(multiboot_info_t
            nr_pages << (PAGE_SHIFT - 10));
     total_pages = nr_pages;
 
-    /* Sanity check for unwanted bloat of dom0_op structure. */
-    BUILD_BUG_ON(sizeof(((struct dom0_op *)0)->u) !=
-                 sizeof(((struct dom0_op *)0)->u.pad));
+    /* Sanity check for unwanted bloat of certain hypercall structures. */
+    BUILD_BUG_ON(sizeof(((struct xen_platform_op *)0)->u) !=
+                 sizeof(((struct xen_platform_op *)0)->u.pad));
+    BUILD_BUG_ON(sizeof(((struct xen_domctl *)0)->u) !=
+                 sizeof(((struct xen_domctl *)0)->u.pad));
+    BUILD_BUG_ON(sizeof(((struct xen_sysctl *)0)->u) !=
+                 sizeof(((struct xen_sysctl *)0)->u.pad));
 
     BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
     BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/shadow2-common.c
--- a/xen/arch/x86/shadow2-common.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/shadow2-common.c     Sun Aug 27 10:24:41 2006 -0600
@@ -2951,14 +2951,15 @@ void shadow2_convert_to_log_dirty(struct
 
 /* Read a domain's log-dirty bitmap and stats.  
  * If the operation is a CLEAN, clear the bitmap and stats as well. */
-static int shadow2_log_dirty_op(struct domain *d, dom0_shadow_control_t *sc)
-{    
+static int shadow2_log_dirty_op(
+    struct domain *d, struct xen_domctl_shadow_op *sc)
+{
     int i, rv = 0, clean = 0;
 
     domain_pause(d);
     shadow2_lock(d);
 
-    clean = (sc->op == DOM0_SHADOW_CONTROL_OP_CLEAN);
+    clean = (sc->op == XEN_DOMCTL_SHADOW_OP_CLEAN);
 
     SHADOW2_DEBUG(LOGDIRTY, "log-dirty %s: dom %u faults=%u dirty=%u\n", 
                   (clean) ? "clean" : "peek",
@@ -3081,11 +3082,11 @@ void sh2_do_mark_dirty(struct domain *d,
 
 
 /**************************************************************************/
-/* Shadow-control DOM0_OP dispatcher */
-
-int shadow2_control_op(struct domain *d, 
-                       dom0_shadow_control_t *sc,
-                       XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
+/* Shadow-control XEN_DOMCTL dispatcher */
+
+int shadow2_domctl(struct domain *d, 
+                   xen_domctl_shadow_op_t *sc,
+                   XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
 {
     int rc, preempted = 0;
 
@@ -3097,7 +3098,7 @@ int shadow2_control_op(struct domain *d,
 
     switch ( sc->op )
     {
-    case DOM0_SHADOW_CONTROL_OP_OFF:
+    case XEN_DOMCTL_SHADOW_OP_OFF:
         if ( shadow2_mode_log_dirty(d) )
             if ( (rc = shadow2_log_dirty_disable(d)) != 0 ) 
                 return rc;
@@ -3106,34 +3107,34 @@ int shadow2_control_op(struct domain *d,
                 return rc;
         return 0;
 
-    case DOM0_SHADOW_CONTROL_OP_ENABLE_TEST:
+    case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST:
         return shadow2_test_enable(d);
 
-    case DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY:
+    case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY:
         return shadow2_log_dirty_enable(d);
 
-    case DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE:
+    case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE:
         return shadow2_enable(d, SHM2_refcounts|SHM2_translate);
 
-    case DOM0_SHADOW_CONTROL_OP_CLEAN:
-    case DOM0_SHADOW_CONTROL_OP_PEEK:
+    case XEN_DOMCTL_SHADOW_OP_CLEAN:
+    case XEN_DOMCTL_SHADOW_OP_PEEK:
         return shadow2_log_dirty_op(d, sc);
 
-    case DOM0_SHADOW_CONTROL_OP_ENABLE:
-        if ( sc->mode & DOM0_SHADOW_ENABLE_LOG_DIRTY )
+    case XEN_DOMCTL_SHADOW_OP_ENABLE:
+        if ( sc->mode & XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY )
             return shadow2_log_dirty_enable(d);
         return shadow2_enable(d, sc->mode << SHM2_shift);
 
-    case DOM0_SHADOW_CONTROL_OP_GET_ALLOCATION:
+    case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION:
         sc->mb = shadow2_get_allocation(d);
         return 0;
 
-    case DOM0_SHADOW_CONTROL_OP_SET_ALLOCATION:
+    case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION:
         rc = shadow2_set_allocation(d, sc->mb, &preempted);
         if ( preempted )
             /* Not finished.  Set up to re-run the call. */
             rc = hypercall_create_continuation(
-                __HYPERVISOR_dom0_op, "h", u_dom0_op);
+                __HYPERVISOR_domctl, "h", u_domctl);
         else 
             /* Finished.  Return the new allocation */
             sc->mb = shadow2_get_allocation(d);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/shadow2.c
--- a/xen/arch/x86/shadow2.c    Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/shadow2.c    Sun Aug 27 10:24:41 2006 -0600
@@ -2893,7 +2893,7 @@ static int sh2_page_fault(struct vcpu *v
     // i.e. ring 3.  Such errors are not caused or dealt with by the shadow
     // code.
     //
-    if ( (regs->error_code & X86_PFEC_SUPERVISOR_FAULT) &&
+    if ( (regs->error_code & PFEC_user_mode) &&
          !(accumulated_gflags & _PAGE_USER) )
     {
         /* illegal user-mode access to supervisor-only page */
@@ -2903,7 +2903,7 @@ static int sh2_page_fault(struct vcpu *v
 
     // Was it a write fault?
     //
-    if ( regs->error_code & X86_PFEC_WRITE_FAULT )
+    if ( regs->error_code & PFEC_write_access )
     {
         if ( unlikely(!(accumulated_gflags & _PAGE_RW)) )
         {
@@ -2917,7 +2917,7 @@ static int sh2_page_fault(struct vcpu *v
         // marked "do not execute".  Such errors are not caused or dealt with
         // by the shadow code.
         //
-        if ( regs->error_code & X86_PFEC_INSN_FETCH_FAULT )
+        if ( regs->error_code & PFEC_insn_fetch )
         {
             if ( accumulated_gflags & _PAGE_NX_BIT )
             {
@@ -2960,8 +2960,8 @@ static int sh2_page_fault(struct vcpu *v
      * for the shadow entry, since we might promote a page here. */
     // XXX -- this code will need to change somewhat if/when the shadow code
     // can directly map superpages...
-    ft = ((regs->error_code & X86_PFEC_WRITE_FAULT) 
-          ? ft_demand_write : ft_demand_read);
+    ft = ((regs->error_code & PFEC_write_access) ?
+          ft_demand_write : ft_demand_read);
     ptr_sl1e = shadow_get_and_create_l1e(v, &gw, &sl1mfn, ft);
     ASSERT(ptr_sl1e);
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/traps.c      Sun Aug 27 10:24:41 2006 -0600
@@ -686,9 +686,9 @@ void propagate_page_fault(unsigned long 
     v->vcpu_info->arch.cr2           = addr;
 
     /* Re-set error_code.user flag appropriately for the guest. */
-    error_code &= ~PGERR_user_mode;
+    error_code &= ~PFEC_user_mode;
     if ( !guest_kernel_mode(v, guest_cpu_user_regs()) )
-        error_code |= PGERR_user_mode;
+        error_code |= PFEC_user_mode;
 
     ti = &v->arch.guest_context.trap_ctxt[TRAP_page_fault];
     tb->flags = TBF_EXCEPTION | TBF_EXCEPTION_ERRCODE;
@@ -768,17 +768,17 @@ static int __spurious_page_fault(
     unsigned int required_flags, disallowed_flags;
 
     /* Reserved bit violations are never spurious faults. */
-    if ( regs->error_code & PGERR_reserved_bit )
+    if ( regs->error_code & PFEC_reserved_bit )
         return 0;
 
     required_flags  = _PAGE_PRESENT;
-    if ( regs->error_code & PGERR_write_access )
+    if ( regs->error_code & PFEC_write_access )
         required_flags |= _PAGE_RW;
-    if ( regs->error_code & PGERR_user_mode )
+    if ( regs->error_code & PFEC_user_mode )
         required_flags |= _PAGE_USER;
 
     disallowed_flags = 0;
-    if ( regs->error_code & PGERR_instr_fetch )
+    if ( regs->error_code & PFEC_insn_fetch )
         disallowed_flags |= _PAGE_NX;
 
     mfn = cr3 >> PAGE_SHIFT;
@@ -886,7 +886,7 @@ static int fixup_page_fault(unsigned lon
          guest_kernel_mode(v, regs) &&
          /* Do not check if access-protection fault since the page may 
             legitimately be not present in shadow page tables */
-         ((regs->error_code & PGERR_write_access) == PGERR_write_access) &&
+         ((regs->error_code & PFEC_write_access) == PFEC_write_access) &&
          ptwr_do_page_fault(d, addr, regs) )
         return EXCRET_fault_fixed;
 
@@ -1100,7 +1100,7 @@ static int emulate_privileged_op(struct 
             if ( (rc = copy_to_user((void *)regs->edi, &data, op_bytes)) != 0 )
             {
                 propagate_page_fault(regs->edi + op_bytes - rc,
-                                     PGERR_write_access);
+                                     PFEC_write_access);
                 return EXCRET_fault_fixed;
             }
             regs->edi += (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/x86_32/entry.S
--- a/xen/arch/x86/x86_32/entry.S       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/x86_32/entry.S       Sun Aug 27 10:24:41 2006 -0600
@@ -630,7 +630,7 @@ ENTRY(hypercall_table)
         .long do_set_callbacks
         .long do_fpu_taskswitch     /*  5 */
         .long do_arch_sched_op_compat
-        .long do_dom0_op
+        .long do_platform_op
         .long do_set_debugreg
         .long do_get_debugreg
         .long do_update_descriptor  /* 10 */
@@ -657,7 +657,9 @@ ENTRY(hypercall_table)
         .long do_xenoprof_op
         .long do_event_channel_op
         .long do_physdev_op
-        .long do_hvm_op             /* 34 */
+        .long do_hvm_op
+        .long do_sysctl             /* 35 */
+        .long do_domctl
         .rept NR_hypercalls-((.-hypercall_table)/4)
         .long do_ni_hypercall
         .endr
@@ -670,7 +672,7 @@ ENTRY(hypercall_args_table)
         .byte 4 /* do_set_callbacks     */
         .byte 1 /* do_fpu_taskswitch    */  /*  5 */
         .byte 2 /* do_arch_sched_op_compat */
-        .byte 1 /* do_dom0_op           */
+        .byte 1 /* do_platform_op       */
         .byte 2 /* do_set_debugreg      */
         .byte 1 /* do_get_debugreg      */
         .byte 4 /* do_update_descriptor */  /* 10 */
@@ -697,7 +699,9 @@ ENTRY(hypercall_args_table)
         .byte 2 /* do_xenoprof_op       */
         .byte 2 /* do_event_channel_op  */
         .byte 2 /* do_physdev_op        */
-        .byte 2 /* do_hvm_op            */  /* 34 */
+        .byte 2 /* do_hvm_op            */
+        .byte 1 /* do_sysctl            */  /* 35 */
+        .byte 1 /* do_domctl            */
         .rept NR_hypercalls-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/x86_64/entry.S       Sun Aug 27 10:24:41 2006 -0600
@@ -543,7 +543,7 @@ ENTRY(hypercall_table)
         .quad do_set_callbacks
         .quad do_fpu_taskswitch     /*  5 */
         .quad do_arch_sched_op_compat
-        .quad do_dom0_op
+        .quad do_platform_op
         .quad do_set_debugreg
         .quad do_get_debugreg
         .quad do_update_descriptor  /* 10 */
@@ -571,6 +571,8 @@ ENTRY(hypercall_table)
         .quad do_event_channel_op
         .quad do_physdev_op
         .quad do_hvm_op
+        .quad do_sysctl             /* 35 */
+        .quad do_domctl
         .rept NR_hypercalls-((.-hypercall_table)/8)
         .quad do_ni_hypercall
         .endr
@@ -583,7 +585,7 @@ ENTRY(hypercall_args_table)
         .byte 3 /* do_set_callbacks     */
         .byte 1 /* do_fpu_taskswitch    */  /*  5 */
         .byte 2 /* do_arch_sched_op_compat */
-        .byte 1 /* do_dom0_op           */
+        .byte 1 /* do_platform_op           */
         .byte 2 /* do_set_debugreg      */
         .byte 1 /* do_get_debugreg      */
         .byte 2 /* do_update_descriptor */  /* 10 */
@@ -611,6 +613,8 @@ ENTRY(hypercall_args_table)
         .byte 2 /* do_event_channel_op  */
         .byte 2 /* do_physdev_op        */
         .byte 2 /* do_hvm_op            */
+        .byte 1 /* do_sysctl            */  /* 35 */
+        .byte 1 /* do_domctl            */
         .rept NR_hypercalls-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/x86_emulate.c
--- a/xen/arch/x86/x86_emulate.c        Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/arch/x86/x86_emulate.c        Sun Aug 27 10:24:41 2006 -0600
@@ -20,6 +20,11 @@
 #define DPRINTF DPRINTK
 #endif
 #include <asm-x86/x86_emulate.h>
+
+#ifndef PFEC_write_access
+#define PFEC_write_access (1U<<1)
+#define PFEC_insn_fetch   (1U<<4)
+#endif
 
 /*
  * Opcode effective-address decode tables.
@@ -444,6 +449,13 @@ x86_emulate_memop(
     /* Shadow copy of register state. Committed on successful emulation. */
     struct cpu_user_regs _regs = *ctxt->regs;
 
+    /*
+     * We do not emulate faults on instruction fetch. We assume that the
+     * guest never executes out of a special memory area.
+     */
+    if ( _regs.error_code & PFEC_insn_fetch )
+        return -1;
+
     switch ( mode )
     {
     case X86EMUL_MODE_REAL:
@@ -769,6 +781,13 @@ x86_emulate_memop(
         dst.val = src.val;
         break;
     case 0x8f: /* pop (sole member of Grp1a) */
+        /*
+         * If the faulting access was a read it means that the fault occurred
+         * when accessing the implicit stack operand. We assume the guest never
+         * uses special memory areas as stack space.
+         */
+        if ( !(_regs.error_code & PFEC_write_access) )
+            goto cannot_emulate; /* fault on stack access: bail */
         /* 64-bit mode: POP always pops a 64-bit operand. */
         if ( mode == X86EMUL_MODE_PROT64 )
             dst.bytes = 8;
@@ -846,6 +865,13 @@ x86_emulate_memop(
             emulate_1op("dec", dst, _regs.eflags);
             break;
         case 6: /* push */
+            /*
+             * If the faulting access was a write it means that the fault
+             * occurred when accessing the implicit stack operand. We assume
+             * the guest never uses special memory areas as stack space.
+             */
+            if ( _regs.error_code & PFEC_write_access )
+                goto cannot_emulate; /* fault on stack access: bail */
             /* 64-bit mode: PUSH always pushes a 64-bit operand. */
             if ( mode == X86EMUL_MODE_PROT64 )
             {
@@ -920,7 +946,7 @@ x86_emulate_memop(
     case 0xa4 ... 0xa5: /* movs */
         dst.type  = OP_MEM;
         dst.bytes = (d & ByteOp) ? 1 : op_bytes;
-        if ( _regs.error_code & 2 )
+        if ( _regs.error_code & PFEC_write_access )
         {
             /* Write fault: destination is special memory. */
             dst.ptr = (unsigned long *)cr2;
@@ -1162,7 +1188,7 @@ x86_emulate_write_std(
 
     if ( (rc = copy_to_user((void *)addr, (void *)&val, bytes)) != 0 )
     {
-        propagate_page_fault(addr + bytes - rc, PGERR_write_access);
+        propagate_page_fault(addr + bytes - rc, PFEC_write_access);
         return X86EMUL_PROPAGATE_FAULT;
     }
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/Makefile
--- a/xen/common/Makefile       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/Makefile       Sun Aug 27 10:24:41 2006 -0600
@@ -1,6 +1,6 @@ obj-y += acm_ops.o
 obj-y += acm_ops.o
 obj-y += bitmap.o
-obj-y += dom0_ops.o
+obj-y += domctl.o
 obj-y += domain.o
 obj-y += elf.o
 obj-y += event_channel.o
@@ -12,7 +12,6 @@ obj-y += multicall.o
 obj-y += multicall.o
 obj-y += page_alloc.o
 obj-y += rangeset.o
-obj-y += sched_bvt.o
 obj-y += sched_credit.o
 obj-y += sched_sedf.o
 obj-y += schedule.o
@@ -20,6 +19,7 @@ obj-y += softirq.o
 obj-y += softirq.o
 obj-y += string.o
 obj-y += symbols.o
+obj-y += sysctl.o
 obj-y += trace.o
 obj-y += timer.o
 obj-y += version.o
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/acm_ops.c
--- a/xen/common/acm_ops.c      Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/acm_ops.c      Sun Aug 27 10:24:41 2006 -0600
@@ -26,7 +26,6 @@
 #include <xen/trace.h>
 #include <xen/console.h>
 #include <xen/guest_access.h>
-#include <public/sched_ctl.h>
 #include <acm/acm_hooks.h>
 
 #ifndef ACM_SECURITY
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/domain.c
--- a/xen/common/domain.c       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/domain.c       Sun Aug 27 10:24:41 2006 -0600
@@ -23,7 +23,6 @@
 #include <xen/shutdown.h>
 #include <xen/percpu.h>
 #include <asm/debugger.h>
-#include <public/dom0_ops.h>
 #include <public/sched.h>
 #include <public/vcpu.h>
 
@@ -454,11 +453,12 @@ void domain_unpause_by_systemcontroller(
  * of domains other than domain 0. ie. the domains that are being built by 
  * the userspace dom0 domain builder.
  */
-int set_info_guest(struct domain *d, dom0_setvcpucontext_t *setvcpucontext)
+int set_info_guest(struct domain *d,
+                   xen_domctl_vcpucontext_t *vcpucontext)
 {
     int rc = 0;
     struct vcpu_guest_context *c = NULL;
-    unsigned long vcpu = setvcpucontext->vcpu;
+    unsigned long vcpu = vcpucontext->vcpu;
     struct vcpu *v;
 
     if ( (vcpu >= MAX_VIRT_CPUS) || ((v = d->vcpu[vcpu]) == NULL) )
@@ -470,7 +470,7 @@ int set_info_guest(struct domain *d, dom
     domain_pause(d);
 
     rc = -EFAULT;
-    if ( copy_from_guest(c, setvcpucontext->ctxt, 1) == 0 )
+    if ( copy_from_guest(c, vcpucontext->ctxt, 1) == 0 )
         rc = arch_set_info_guest(v, c);
 
     domain_unpause(d);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/elf.c
--- a/xen/common/elf.c  Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/elf.c  Sun Aug 27 10:24:41 2006 -0600
@@ -11,12 +11,183 @@
 #include <xen/elf.h>
 #include <xen/sched.h>
 #include <xen/errno.h>
+#include <xen/inttypes.h>
+
+#include <public/elfnote.h>
 
 static void loadelfsymtab(struct domain_setup_info *dsi, int doload);
 static inline int is_loadable_phdr(Elf_Phdr *phdr)
 {
     return ((phdr->p_type == PT_LOAD) &&
             ((phdr->p_flags & (PF_W|PF_X)) != 0));
+}
+
+/*
+ * Fallback for kernels containing only the legacy __xen_guest string
+ * and no ELF notes.
+ */
+static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab)
+{
+    return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0;
+}
+
+static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type)
+{
+    const char *xenguest_fallbacks[] = {
+        [XEN_ELFNOTE_ENTRY] = "VIRT_ENTRY=",
+        [XEN_ELFNOTE_HYPERCALL_PAGE] = "HYPERCALL_PAGE=",
+        [XEN_ELFNOTE_VIRT_BASE] = "VIRT_BASE=",
+        [XEN_ELFNOTE_PADDR_OFFSET] = "ELF_PADDR_OFFSET=",
+        [XEN_ELFNOTE_XEN_VERSION] = "XEN_VER=",
+        [XEN_ELFNOTE_GUEST_OS] = "GUEST_OS=",
+        [XEN_ELFNOTE_GUEST_VERSION] = "GUEST_VER=",
+        [XEN_ELFNOTE_LOADER] = "LOADER=",
+        [XEN_ELFNOTE_PAE_MODE] = "PAE=",
+        [XEN_ELFNOTE_FEATURES] = "FEATURES=",
+        [XEN_ELFNOTE_BSD_SYMTAB] = "BSD_SYMTAB=",
+    };
+    const char *fallback;
+    const char *p;
+
+    if ( !dsi->__xen_guest_string )
+        return NULL;
+
+    if ( type > sizeof(xenguest_fallbacks) )
+        return NULL;
+
+    if ( (fallback = xenguest_fallbacks[type]) == NULL )
+        return NULL;
+
+    if ( (p = strstr(dsi->__xen_guest_string,fallback)) == NULL )
+        return NULL;
+
+    return p + strlen(fallback);
+}
+
+static const char *xen_guest_string(struct domain_setup_info *dsi, int type)
+{
+    const char *p = xen_guest_lookup(dsi, type);
+
+    /*
+     * We special case this since the __xen_guest_section treats the
+     * mere precense of the BSD_SYMTAB string as true or false.
+     */
+    if ( type == XEN_ELFNOTE_BSD_SYMTAB )
+        return p ? "yes" : "no";
+
+    return p;
+}
+
+static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
+                                                   int type, int *defined)
+{
+    const char *p = xen_guest_lookup(dsi, type);
+    unsigned long long value;
+
+    if ( p == NULL )
+        return 0;
+
+    value = simple_strtoull(p, NULL, 0);
+
+    /* We special case this since __xen_guest_section contains a PFN
+     * for this field not a virtual address.
+     */
+    if (type == XEN_ELFNOTE_HYPERCALL_PAGE)
+        value = dsi->v_start + (value<<PAGE_SHIFT);
+
+    *defined = 1;
+    return value;
+}
+
+/*
+ * Interface to the Xen ELF notes.
+ */
+#define ELFNOTE_NAME(_n_)   ((void*)(_n_) + sizeof(*(_n_)))
+#define ELFNOTE_DESC(_n_)   (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
+#define ELFNOTE_NEXT(_n_)   (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
+
+static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
+{
+    Elf_Note *note;
+
+    if ( shdr->sh_type != SHT_NOTE )
+        return 0;
+
+    for ( note = (Elf_Note *)(image + shdr->sh_offset);
+          note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
+          note = ELFNOTE_NEXT(note) )
+    {
+        if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) )
+            return 1;
+    }
+
+    return 0;
+}
+
+static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
+{
+    Elf_Note *note;
+
+    if ( !dsi->__elfnote_section )
+        return NULL;
+
+    for ( note = (Elf_Note *)dsi->__elfnote_section;
+          note < (Elf_Note *)dsi->__elfnote_section_end;
+          note = ELFNOTE_NEXT(note) )
+    {
+        if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) )
+            continue;
+
+        if ( note->type == type )
+            return note;
+    }
+
+    return NULL;
+}
+
+const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
+{
+    Elf_Note *note;
+
+    if ( !dsi->__elfnote_section )
+        return xen_guest_string(dsi, type);
+
+    note = xen_elfnote_lookup(dsi, type);
+    if ( note == NULL )
+        return NULL;
+
+    return (const char *)ELFNOTE_DESC(note);
+}
+
+unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
+                                       int type, int *defined)
+{
+    Elf_Note *note;
+
+    *defined = 0;
+
+    if ( !dsi->__elfnote_section )
+        return xen_guest_numeric(dsi, type, defined);
+
+    note = xen_elfnote_lookup(dsi, type);
+    if ( note == NULL )
+    {
+        return 0;
+    }
+
+    switch ( note->descsz )
+    {
+    case 4:
+        *defined = 1;
+        return *(uint32_t*)ELFNOTE_DESC(note);
+    case 8:
+        *defined = 1;
+        return *(uint64_t*)ELFNOTE_DESC(note);
+    default:
+        printk("ERROR: unknown data size %#x for numeric type note %#x\n",
+               note->descsz, type);
+        return 0;
+    }
 }
 
 int parseelfimage(struct domain_setup_info *dsi)
@@ -24,21 +195,22 @@ int parseelfimage(struct domain_setup_in
     Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
     Elf_Phdr *phdr;
     Elf_Shdr *shdr;
-    Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_base, elf_pa_off;
-    char *shstrtab, *guestinfo=NULL, *p;
-    char *elfbase = (char *)dsi->image_addr;
-    int h, virt_base_defined, elf_pa_off_defined;
+    Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry;
+    const char *shstrtab, *p;
+    const char *image = (char *)dsi->image_addr;
+    const unsigned long image_len = dsi->image_len;
+    int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined;
 
     if ( !elf_sanity_check(ehdr) )
         return -EINVAL;
 
-    if ( (ehdr->e_phoff + (ehdr->e_phnum*ehdr->e_phentsize)) > dsi->image_len )
+    if ( (ehdr->e_phoff + (ehdr->e_phnum*ehdr->e_phentsize)) > image_len )
     {
         printk("ELF program headers extend beyond end of image.\n");
         return -EINVAL;
     }
 
-    if ( (ehdr->e_shoff + (ehdr->e_shnum*ehdr->e_shentsize)) > dsi->image_len )
+    if ( (ehdr->e_shoff + (ehdr->e_shnum*ehdr->e_shentsize)) > image_len )
     {
         printk("ELF section headers extend beyond end of image.\n");
         return -EINVAL;
@@ -50,64 +222,131 @@ int parseelfimage(struct domain_setup_in
         printk("ELF image has no section-header strings table (shstrtab).\n");
         return -EINVAL;
     }
-    shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff + 
+    shdr = (Elf_Shdr *)(image + ehdr->e_shoff +
                         (ehdr->e_shstrndx*ehdr->e_shentsize));
-    shstrtab = elfbase + shdr->sh_offset;
-    
-    /* Find the special '__xen_guest' section and check its contents. */
+    shstrtab = image + shdr->sh_offset;
+
+    dsi->__elfnote_section = NULL;
+    dsi->__xen_guest_string = NULL;
+
+    /* Look for .notes segment containing at least one Xen note */
     for ( h = 0; h < ehdr->e_shnum; h++ )
     {
-        shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff + (h*ehdr->e_shentsize));
-        if ( strcmp(&shstrtab[shdr->sh_name], "__xen_guest") != 0 )
+        shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
+        if ( !is_xen_elfnote_section(image, shdr) )
             continue;
-
-        guestinfo = elfbase + shdr->sh_offset;
-
-        if ( (strstr(guestinfo, "LOADER=generic") == NULL) &&
-             (strstr(guestinfo, "GUEST_OS=linux") == NULL) )
-        {
-            printk("ERROR: Xen will only load images built for the generic "
-                   "loader or Linux images\n");
+        dsi->__elfnote_section = (void *)image + shdr->sh_offset;
+        dsi->__elfnote_section_end =
+            (void *)image + shdr->sh_offset + shdr->sh_size;
+        break;
+    }
+
+    /* Fall back to looking for the special '__xen_guest' section. */
+    if ( dsi->__elfnote_section == NULL )
+    {
+        for ( h = 0; h < ehdr->e_shnum; h++ )
+        {
+            shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
+            if ( is_xen_guest_section(shdr, shstrtab) )
+            {
+                dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
+                break;
+            }
+        }
+    }
+
+    /* Check the contents of the Xen notes or guest string. */
+    if ( dsi->__elfnote_section || dsi->__xen_guest_string )
+    {
+        const char *loader = xen_elfnote_string(dsi, XEN_ELFNOTE_LOADER);
+        const char *guest_os = xen_elfnote_string(dsi, XEN_ELFNOTE_GUEST_OS);
+        const char *xen_version =
+            xen_elfnote_string(dsi, XEN_ELFNOTE_XEN_VERSION);
+
+        if ( ( loader == NULL || strncmp(loader, "generic", 7) ) &&
+             ( guest_os == NULL || strncmp(guest_os, "linux", 5) ) )
+        {
+            printk("ERROR: Will only load images built for the generic "
+                   "loader or Linux images");
             return -EINVAL;
         }
 
-        if ( (strstr(guestinfo, "XEN_VER=xen-3.0") == NULL) )
+        if ( xen_version == NULL || strncmp(xen_version, "xen-3.0", 7) )
         {
             printk("ERROR: Xen will only load images built for Xen v3.0\n");
-            return -EINVAL;
-        }
-
-        break;
-    }
-
-    dsi->xen_section_string = guestinfo;
-
-    if ( guestinfo == NULL )
-        guestinfo = "";
-
-    /* Initial guess for virt_base is 0 if it is not explicitly defined. */
-    p = strstr(guestinfo, "VIRT_BASE=");
-    virt_base_defined = (p != NULL);
-    virt_base = virt_base_defined ? simple_strtoul(p+10, &p, 0) : 0;
-
-    /* Initial guess for elf_pa_off is virt_base if not explicitly defined. */
-    p = strstr(guestinfo, "ELF_PADDR_OFFSET=");
-    elf_pa_off_defined = (p != NULL);
-    elf_pa_off = elf_pa_off_defined ? simple_strtoul(p+17, &p, 0) : virt_base;
+        }
+    }
+    else
+    {
+#if defined(__x86_64__) || defined(__i386__)
+        printk("ERROR: Not a Xen-ELF image: "
+               "No ELF notes or '__xen_guest' section found.\n");
+        return -EINVAL;
+#endif
+    }
+
+    /*
+     * If we have ELF notes then PAE=yes implies that we must support
+     * the extended cr3 syntax. Otherwise we need to find the
+     * [extended-cr3] syntax in the __xen_guest string.
+     */
+    dsi->pae_kernel = PAEKERN_no;
+    if ( dsi->__elfnote_section )
+    {
+        p = xen_elfnote_string(dsi, XEN_ELFNOTE_PAE_MODE);
+        if ( p != NULL && strncmp(p, "yes", 3) == 0 )
+            dsi->pae_kernel = PAEKERN_extended_cr3;
+
+    }
+    else
+    {
+        p = xen_guest_lookup(dsi, XEN_ELFNOTE_PAE_MODE);
+        if ( p != NULL && strncmp(p, "yes", 3) == 0 )
+        {
+            dsi->pae_kernel = PAEKERN_yes;
+            if ( !strncmp(p+4, "[extended-cr3]", 14) )
+                dsi->pae_kernel = PAEKERN_extended_cr3;
+        }
+    }
+
+    /* Initial guess for v_start is 0 if it is not explicitly defined. */
+    dsi->v_start =
+        xen_elfnote_numeric(dsi, XEN_ELFNOTE_VIRT_BASE, &virt_base_defined);
+    if ( !virt_base_defined )
+        dsi->v_start = 0;
+
+    /*
+     * If we are using the legacy __xen_guest section then elf_pa_off
+     * defaults to v_start in order to maintain compatibility with
+     * older hypervisors which set padd in the ELF header to
+     * virt_base.
+     *
+     * If we are using the modern ELF notes interface then the default
+     * is 0.
+     */
+    dsi->elf_paddr_offset =
+        xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET, 
&elf_pa_off_defined);
+    if ( !elf_pa_off_defined )
+    {
+        if ( dsi->__elfnote_section )
+            dsi->elf_paddr_offset = 0;
+        else
+            dsi->elf_paddr_offset = dsi->v_start;
+    }
 
     if ( elf_pa_off_defined && !virt_base_defined )
     {
         printk("ERROR: Neither ELF_PADDR_OFFSET nor VIRT_BASE found in"
-               " __xen_guest section.\n");
+               " Xen ELF notes.\n");
         return -EINVAL;
     }
 
     for ( h = 0; h < ehdr->e_phnum; h++ )
     {
-        phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
+        phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
         if ( !is_loadable_phdr(phdr) )
             continue;
-        vaddr = phdr->p_paddr - elf_pa_off + virt_base;
+        vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
         if ( (vaddr + phdr->p_memsz) < vaddr )
         {
             printk("ERROR: ELF program header %d is too large.\n", h);
@@ -120,19 +359,14 @@ int parseelfimage(struct domain_setup_in
             kernend = vaddr + phdr->p_memsz;
     }
 
-    /*
-     * Legacy compatibility and images with no __xen_guest section: assume
-     * header addresses are virtual addresses, and that guest memory should be
-     * mapped starting at kernel load address.
-     */
-    dsi->v_start          = virt_base_defined  ? virt_base  : kernstart;
-    dsi->elf_paddr_offset = elf_pa_off_defined ? elf_pa_off : dsi->v_start;
-
     dsi->v_kernentry = ehdr->e_entry;
-    if ( (p = strstr(guestinfo, "VIRT_ENTRY=")) != NULL )
-        dsi->v_kernentry = simple_strtoul(p+11, &p, 0);
-
-    if ( (kernstart > kernend) || 
+
+    virt_entry =
+        xen_elfnote_numeric(dsi, XEN_ELFNOTE_ENTRY, &virt_entry_defined);
+    if ( virt_entry_defined )
+        dsi->v_kernentry = virt_entry;
+
+    if ( (kernstart > kernend) ||
          (dsi->v_kernentry < kernstart) ||
          (dsi->v_kernentry > kernend) ||
          (dsi->v_start > kernstart) )
@@ -141,8 +375,9 @@ int parseelfimage(struct domain_setup_in
         return -EINVAL;
     }
 
-    if ( (p = strstr(guestinfo, "BSD_SYMTAB")) != NULL )
-            dsi->load_symtab = 1;
+    p = xen_elfnote_string(dsi, XEN_ELFNOTE_BSD_SYMTAB);
+    if ( p != NULL && strncmp(p, "yes", 3) == 0 )
+        dsi->load_symtab = 1;
 
     dsi->v_kernstart = kernstart;
     dsi->v_kernend   = kernend;
@@ -155,7 +390,7 @@ int parseelfimage(struct domain_setup_in
 
 int loadelfimage(struct domain_setup_info *dsi)
 {
-    char *elfbase = (char *)dsi->image_addr;
+    char *image = (char *)dsi->image_addr;
     Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr;
     Elf_Phdr *phdr;
     unsigned long vaddr;
@@ -163,12 +398,12 @@ int loadelfimage(struct domain_setup_inf
   
     for ( h = 0; h < ehdr->e_phnum; h++ )
     {
-        phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
+        phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
         if ( !is_loadable_phdr(phdr) )
             continue;
         vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
         if ( phdr->p_filesz != 0 )
-            memcpy((char *)vaddr, elfbase + phdr->p_offset, phdr->p_filesz);
+            memcpy((char *)vaddr, image + phdr->p_offset, phdr->p_filesz);
         if ( phdr->p_memsz > phdr->p_filesz )
             memset((char *)vaddr + phdr->p_filesz, 0,
                    phdr->p_memsz - phdr->p_filesz);
@@ -186,7 +421,7 @@ static void loadelfsymtab(struct domain_
     Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr, *sym_ehdr;
     Elf_Shdr *shdr;
     unsigned long maxva, symva;
-    char *p, *elfbase = (char *)dsi->image_addr;
+    char *p, *image = (char *)dsi->image_addr;
     int h, i;
 
     if ( !dsi->load_symtab )
@@ -203,12 +438,12 @@ static void loadelfsymtab(struct domain_
     {
         p = (void *)symva;
         shdr = (Elf_Shdr *)(p + sizeof(int) + sizeof(Elf_Ehdr));
-        memcpy(shdr, elfbase + ehdr->e_shoff, ehdr->e_shnum*sizeof(Elf_Shdr));
+        memcpy(shdr, image + ehdr->e_shoff, ehdr->e_shnum*sizeof(Elf_Shdr));
     } 
     else
     {
         p = NULL;
-        shdr = (Elf_Shdr *)(elfbase + ehdr->e_shoff);
+        shdr = (Elf_Shdr *)(image + ehdr->e_shoff);
     }
 
     for ( h = 0; h < ehdr->e_shnum; h++ ) 
@@ -234,7 +469,7 @@ static void loadelfsymtab(struct domain_
              (shdr[h].sh_type == SHT_SYMTAB) )
         {
             if (doload) {
-                memcpy((void *)maxva, elfbase + shdr[h].sh_offset,
+                memcpy((void *)maxva, image + shdr[h].sh_offset,
                        shdr[h].sh_size);
 
                 /* Mangled to be based on ELF header location. */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/multicall.c
--- a/xen/common/multicall.c    Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/multicall.c    Sun Aug 27 10:24:41 2006 -0600
@@ -6,7 +6,6 @@
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
-#include <xen/perfc.h>
 #include <xen/sched.h>
 #include <xen/event.h>
 #include <xen/multicall.h>
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/perfc.c
--- a/xen/common/perfc.c        Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/perfc.c        Sun Aug 27 10:24:41 2006 -0600
@@ -7,7 +7,6 @@
 #include <xen/spinlock.h>
 #include <xen/mm.h>
 #include <xen/guest_access.h>
-#include <public/dom0_ops.h>
 #include <asm/perfc.h>
 
 #undef  PERFCOUNTER
@@ -218,20 +217,19 @@ int perfc_control(dom0_perfccontrol_t *p
 int perfc_control(dom0_perfccontrol_t *pc)
 {
     static DEFINE_SPINLOCK(lock);
-    u32 op = pc->op;
     int rc;
 
     spin_lock(&lock);
 
-    switch ( op )
-    {
-    case DOM0_PERFCCONTROL_OP_RESET:
+    switch ( pc->cmd )
+    {
+    case XEN_SYSCTL_PERFCOP_reset:
         perfc_copy_info(pc->desc, pc->val);
         perfc_reset(0);
         rc = 0;
         break;
 
-    case DOM0_PERFCCONTROL_OP_QUERY:
+    case XEN_SYSCTL_PERFCOP_query:
         perfc_copy_info(pc->desc, pc->val);
         rc = 0;
         break;
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/sched_credit.c Sun Aug 27 10:24:41 2006 -0600
@@ -614,34 +614,34 @@ static int
 static int
 csched_dom_cntl(
     struct domain *d,
-    struct sched_adjdom_cmd *cmd)
+    struct xen_domctl_scheduler_op *op)
 {
     struct csched_dom * const sdom = CSCHED_DOM(d);
     unsigned long flags;
 
-    if ( cmd->direction == SCHED_INFO_GET )
-    {
-        cmd->u.credit.weight = sdom->weight;
-        cmd->u.credit.cap = sdom->cap;
+    if ( op->cmd == XEN_DOMCTL_SCHEDOP_getinfo )
+    {
+        op->u.credit.weight = sdom->weight;
+        op->u.credit.cap = sdom->cap;
     }
     else
     {
-        ASSERT( cmd->direction == SCHED_INFO_PUT );
+        ASSERT(op->cmd == XEN_DOMCTL_SCHEDOP_putinfo);
 
         spin_lock_irqsave(&csched_priv.lock, flags);
 
-        if ( cmd->u.credit.weight != 0 )
+        if ( op->u.credit.weight != 0 )
         {
             if ( !list_empty(&sdom->active_sdom_elem) )
             {
                 csched_priv.weight -= sdom->weight;
-                csched_priv.weight += cmd->u.credit.weight;
+                csched_priv.weight += op->u.credit.weight;
             }
-            sdom->weight = cmd->u.credit.weight;
-        }
-
-        if ( cmd->u.credit.cap != (uint16_t)~0U )
-            sdom->cap = cmd->u.credit.cap;
+            sdom->weight = op->u.credit.weight;
+        }
+
+        if ( op->u.credit.cap != (uint16_t)~0U )
+            sdom->cap = op->u.credit.cap;
 
         spin_unlock_irqrestore(&csched_priv.lock, flags);
     }
@@ -1215,7 +1215,7 @@ struct scheduler sched_credit_def = {
 struct scheduler sched_credit_def = {
     .name           = "SMP Credit Scheduler",
     .opt_name       = "credit",
-    .sched_id       = SCHED_CREDIT,
+    .sched_id       = XEN_SCHEDULER_CREDIT,
 
     .init_vcpu      = csched_vcpu_init,
     .destroy_domain = csched_dom_destroy,
@@ -1225,7 +1225,7 @@ struct scheduler sched_credit_def = {
 
     .set_affinity   = csched_vcpu_set_affinity,
 
-    .adjdom         = csched_dom_cntl,
+    .adjust         = csched_dom_cntl,
 
     .tick           = csched_tick,
     .do_schedule    = csched_schedule,
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/sched_sedf.c
--- a/xen/common/sched_sedf.c   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/sched_sedf.c   Sun Aug 27 10:24:41 2006 -0600
@@ -8,7 +8,6 @@
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/sched-if.h>
-#include <public/sched_ctl.h>
 #include <xen/timer.h>
 #include <xen/softirq.h>
 #include <xen/time.h>
@@ -1297,7 +1296,7 @@ static void sedf_dump_cpu_state(int i)
 
 
 /* Adjusts periods and slices of the domains accordingly to their weights. */
-static int sedf_adjust_weights(struct sched_adjdom_cmd *cmd)
+static int sedf_adjust_weights(struct xen_domctl_scheduler_op *cmd)
 {
     struct vcpu *p;
     struct domain      *d;
@@ -1352,29 +1351,29 @@ static int sedf_adjust_weights(struct sc
 
 
 /* set or fetch domain scheduling parameters */
-static int sedf_adjdom(struct domain *p, struct sched_adjdom_cmd *cmd)
+static int sedf_adjust(struct domain *p, struct xen_domctl_scheduler_op *op)
 {
     struct vcpu *v;
 
-    PRINT(2,"sedf_adjdom was called, domain-id %i new period %"PRIu64" "
+    PRINT(2,"sedf_adjust was called, domain-id %i new period %"PRIu64" "
           "new slice %"PRIu64"\nlatency %"PRIu64" extra:%s\n",
-          p->domain_id, cmd->u.sedf.period, cmd->u.sedf.slice,
-          cmd->u.sedf.latency, (cmd->u.sedf.extratime)?"yes":"no");
-
-    if ( cmd->direction == SCHED_INFO_PUT )
+          p->domain_id, op->u.sedf.period, op->u.sedf.slice,
+          op->u.sedf.latency, (op->u.sedf.extratime)?"yes":"no");
+
+    if ( op->cmd == XEN_DOMCTL_SCHEDOP_putinfo )
     {
         /* Check for sane parameters. */
-        if ( !cmd->u.sedf.period && !cmd->u.sedf.weight )
+        if ( !op->u.sedf.period && !op->u.sedf.weight )
             return -EINVAL;
-        if ( cmd->u.sedf.weight )
-        {
-            if ( (cmd->u.sedf.extratime & EXTRA_AWARE) &&
-                 (!cmd->u.sedf.period) )
+        if ( op->u.sedf.weight )
+        {
+            if ( (op->u.sedf.extratime & EXTRA_AWARE) &&
+                 (!op->u.sedf.period) )
             {
                 /* Weight-driven domains with extratime only. */
                 for_each_vcpu ( p, v )
                 {
-                    EDOM_INFO(v)->extraweight = cmd->u.sedf.weight;
+                    EDOM_INFO(v)->extraweight = op->u.sedf.weight;
                     EDOM_INFO(v)->weight = 0;
                     EDOM_INFO(v)->slice = 0;
                     EDOM_INFO(v)->period = WEIGHT_PERIOD;
@@ -1384,7 +1383,7 @@ static int sedf_adjdom(struct domain *p,
             {
                 /* Weight-driven domains with real-time execution. */
                 for_each_vcpu ( p, v )
-                    EDOM_INFO(v)->weight = cmd->u.sedf.weight;
+                    EDOM_INFO(v)->weight = op->u.sedf.weight;
             }
         }
         else
@@ -1396,51 +1395,51 @@ static int sedf_adjdom(struct domain *p,
                  * Sanity checking: note that disabling extra weight requires
                  * that we set a non-zero slice.
                  */
-                if ( (cmd->u.sedf.period > PERIOD_MAX) ||
-                     (cmd->u.sedf.period < PERIOD_MIN) ||
-                     (cmd->u.sedf.slice  > cmd->u.sedf.period) ||
-                     (cmd->u.sedf.slice  < SLICE_MIN) )
+                if ( (op->u.sedf.period > PERIOD_MAX) ||
+                     (op->u.sedf.period < PERIOD_MIN) ||
+                     (op->u.sedf.slice  > op->u.sedf.period) ||
+                     (op->u.sedf.slice  < SLICE_MIN) )
                     return -EINVAL;
                 EDOM_INFO(v)->weight = 0;
                 EDOM_INFO(v)->extraweight = 0;
                 EDOM_INFO(v)->period_orig = 
-                    EDOM_INFO(v)->period  = cmd->u.sedf.period;
+                    EDOM_INFO(v)->period  = op->u.sedf.period;
                 EDOM_INFO(v)->slice_orig  = 
-                    EDOM_INFO(v)->slice   = cmd->u.sedf.slice;
+                    EDOM_INFO(v)->slice   = op->u.sedf.slice;
             }
         }
 
-        if ( sedf_adjust_weights(cmd) )
+        if ( sedf_adjust_weights(op) )
             return -EINVAL;
 
         for_each_vcpu ( p, v )
         {
             EDOM_INFO(v)->status  = 
                 (EDOM_INFO(v)->status &
-                 ~EXTRA_AWARE) | (cmd->u.sedf.extratime & EXTRA_AWARE);
-            EDOM_INFO(v)->latency = cmd->u.sedf.latency;
+                 ~EXTRA_AWARE) | (op->u.sedf.extratime & EXTRA_AWARE);
+            EDOM_INFO(v)->latency = op->u.sedf.latency;
             extraq_check(v);
         }
     }
-    else if ( cmd->direction == SCHED_INFO_GET )
+    else if ( op->cmd == XEN_DOMCTL_SCHEDOP_getinfo )
     {
         if ( p->vcpu[0] == NULL )
             return -EINVAL;
-        cmd->u.sedf.period    = EDOM_INFO(p->vcpu[0])->period;
-        cmd->u.sedf.slice     = EDOM_INFO(p->vcpu[0])->slice;
-        cmd->u.sedf.extratime = EDOM_INFO(p->vcpu[0])->status & EXTRA_AWARE;
-        cmd->u.sedf.latency   = EDOM_INFO(p->vcpu[0])->latency;
-        cmd->u.sedf.weight    = EDOM_INFO(p->vcpu[0])->weight;
-    }
-
-    PRINT(2,"sedf_adjdom_finished\n");
+        op->u.sedf.period    = EDOM_INFO(p->vcpu[0])->period;
+        op->u.sedf.slice     = EDOM_INFO(p->vcpu[0])->slice;
+        op->u.sedf.extratime = EDOM_INFO(p->vcpu[0])->status & EXTRA_AWARE;
+        op->u.sedf.latency   = EDOM_INFO(p->vcpu[0])->latency;
+        op->u.sedf.weight    = EDOM_INFO(p->vcpu[0])->weight;
+    }
+
+    PRINT(2,"sedf_adjust_finished\n");
     return 0;
 }
 
 struct scheduler sched_sedf_def = {
     .name     = "Simple EDF Scheduler",
     .opt_name = "sedf",
-    .sched_id = SCHED_SEDF,
+    .sched_id = XEN_SCHEDULER_SEDF,
     
     .init_vcpu      = sedf_init_vcpu,
     .destroy_domain = sedf_destroy_domain,
@@ -1449,7 +1448,7 @@ struct scheduler sched_sedf_def = {
     .dump_cpu_state = sedf_dump_cpu_state,
     .sleep          = sedf_sleep,
     .wake           = sedf_wake,
-    .adjdom         = sedf_adjdom,
+    .adjust         = sedf_adjust,
     .set_affinity   = sedf_set_affinity
 };
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/schedule.c
--- a/xen/common/schedule.c     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/schedule.c     Sun Aug 27 10:24:41 2006 -0600
@@ -30,7 +30,6 @@
 #include <xen/errno.h>
 #include <xen/guest_access.h>
 #include <public/sched.h>
-#include <public/sched_ctl.h>
 
 extern void arch_getdomaininfo_ctxt(struct vcpu *,
                                     struct vcpu_guest_context *);
@@ -49,11 +48,9 @@ static void poll_timer_fn(void *data);
 /* This is global for now so that private implementations can reach it */
 DEFINE_PER_CPU(struct schedule_data, schedule_data);
 
-extern struct scheduler sched_bvt_def;
 extern struct scheduler sched_sedf_def;
 extern struct scheduler sched_credit_def;
 static struct scheduler *schedulers[] = { 
-    &sched_bvt_def,
     &sched_sedf_def,
     &sched_credit_def,
     NULL
@@ -429,31 +426,15 @@ int sched_id(void)
     return ops.sched_id;
 }
 
-long sched_ctl(struct sched_ctl_cmd *cmd)
-{
-    if ( cmd->sched_id != ops.sched_id )
-        return -EINVAL;
-
-    SCHED_OP(control, cmd);
-    TRACE_0D(TRC_SCHED_CTL);
-    return 0;
-}
-
-
 /* Adjust scheduling parameter for a given domain. */
-long sched_adjdom(struct sched_adjdom_cmd *cmd)
-{
-    struct domain *d;
+long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)
+{
     struct vcpu *v;
     
-    if ( (cmd->sched_id != ops.sched_id) ||
-         ((cmd->direction != SCHED_INFO_PUT) &&
-          (cmd->direction != SCHED_INFO_GET)) )
+    if ( (op->sched_id != ops.sched_id) ||
+         ((op->cmd != XEN_DOMCTL_SCHEDOP_putinfo) &&
+          (op->cmd != XEN_DOMCTL_SCHEDOP_getinfo)) )
         return -EINVAL;
-
-    d = find_domain_by_id(cmd->domain);
-    if ( d == NULL )
-        return -ESRCH;
 
     /*
      * Most VCPUs we can simply pause. If we are adjusting this VCPU then
@@ -477,7 +458,7 @@ long sched_adjdom(struct sched_adjdom_cm
     if ( d == current->domain )
         vcpu_schedule_lock_irq(current);
 
-    SCHED_OP(adjdom, d, cmd);
+    SCHED_OP(adjust, d, op);
     TRACE_1D(TRC_SCHED_ADJDOM, d->domain_id);
 
     if ( d == current->domain )
@@ -488,8 +469,6 @@ long sched_adjdom(struct sched_adjdom_cm
         if ( v != current )
             vcpu_unpause(v);
     }
-
-    put_domain(d);
 
     return 0;
 }
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/trace.c
--- a/xen/common/trace.c        Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/common/trace.c        Sun Aug 27 10:24:41 2006 -0600
@@ -14,9 +14,6 @@
  * The trace buffer code is designed to allow debugging traces of Xen to be
  * generated on UP / SMP machines.  Each trace entry is timestamped so that
  * it's possible to reconstruct a chronological record of trace events.
- *
- * See also include/xen/trace.h and the dom0 op in
- * include/public/dom0_ops.h
  */
 
 #include <xen/config.h>
@@ -33,7 +30,7 @@
 #include <xen/mm.h>
 #include <xen/percpu.h>
 #include <asm/atomic.h>
-#include <public/dom0_ops.h>
+#include <public/sysctl.h>
 
 /* opt_tbuf_size: trace buffer size (in pages) */
 static unsigned int opt_tbuf_size = 0;
@@ -56,7 +53,7 @@ int tb_init_done;
 int tb_init_done;
 
 /* which CPUs tracing is enabled on */
-static unsigned long tb_cpu_mask = (~0UL);
+static cpumask_t tb_cpu_mask = CPU_MASK_ALL;
 
 /* which tracing events are enabled */
 static u32 tb_event_mask = TRC_ALL;
@@ -171,43 +168,41 @@ void init_trace_bufs(void)
     }
 }
 
-
-/**
- * tb_control - DOM0 operations on trace buffers.
- * @tbc: a pointer to a dom0_tbufcontrol_t to be filled out
- */
-int tb_control(dom0_tbufcontrol_t *tbc)
+/**
+ * tb_control - sysctl operations on trace buffers.
+ * @tbc: a pointer to a xen_sysctl_tbuf_op_t to be filled out
+ */
+int tb_control(xen_sysctl_tbuf_op_t *tbc)
 {
     static DEFINE_SPINLOCK(lock);
     int rc = 0;
 
     spin_lock(&lock);
 
-    switch ( tbc->op )
-    {
-    case DOM0_TBUF_GET_INFO:
-        tbc->cpu_mask   = tb_cpu_mask;
+    switch ( tbc->cmd )
+    {
+    case XEN_SYSCTL_TBUFOP_get_info:
         tbc->evt_mask   = tb_event_mask;
         tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(per_cpu(t_bufs, 0)) : 0;
         tbc->size       = opt_tbuf_size * PAGE_SIZE;
         break;
-    case DOM0_TBUF_SET_CPU_MASK:
-        tb_cpu_mask = tbc->cpu_mask;
-        break;
-    case DOM0_TBUF_SET_EVT_MASK:
+    case XEN_SYSCTL_TBUFOP_set_cpu_mask:
+        cpumask_to_xenctl_cpumap(&tbc->cpu_mask, &tb_cpu_mask);
+        break;
+    case XEN_SYSCTL_TBUFOP_set_evt_mask:
         tb_event_mask = tbc->evt_mask;
         break;
-    case DOM0_TBUF_SET_SIZE:
+    case XEN_SYSCTL_TBUFOP_set_size:
         rc = !tb_init_done ? tb_set_size(tbc->size) : -EINVAL;
         break;
-    case DOM0_TBUF_ENABLE:
+    case XEN_SYSCTL_TBUFOP_enable:
         /* Enable trace buffers. Check buffers are already allocated. */
         if ( opt_tbuf_size == 0 ) 
             rc = -EINVAL;
         else
             tb_init_done = 1;
         break;
-    case DOM0_TBUF_DISABLE:
+    case XEN_SYSCTL_TBUFOP_disable:
         /*
          * Disable trace buffers. Just stops new records from being written,
          * does not deallocate any memory.
@@ -254,7 +249,7 @@ void trace(u32 event, unsigned long d1, 
                 & ((event >> TRC_SUBCLS_SHIFT) & 0xf )) == 0 )
         return;
 
-    if ( (tb_cpu_mask & (1UL << smp_processor_id())) == 0 )
+    if ( !cpu_isset(smp_processor_id(), tb_cpu_mask) )
         return;
 
     /* Read tb_init_done /before/ t_bufs. */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/acm/acm_hooks.h
--- a/xen/include/acm/acm_hooks.h       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/acm/acm_hooks.h       Sun Aug 27 10:24:41 2006 -0600
@@ -28,7 +28,7 @@
 #include <xen/multiboot.h>
 #include <public/acm.h>
 #include <acm/acm_core.h>
-#include <public/dom0_ops.h>
+#include <public/domctl.h>
 #include <public/event_channel.h>
 #include <asm/current.h>
 
@@ -129,11 +129,11 @@ extern struct acm_operations *acm_second
 
 #ifndef ACM_SECURITY
 
-static inline int acm_pre_dom0_op(struct dom0_op *op, void **ssid) 
-{ return 0; }
-static inline void acm_post_dom0_op(struct dom0_op *op, void *ssid) 
+static inline int acm_pre_domctl(struct xen_domctl *op, void **ssid) 
+{ return 0; }
+static inline void acm_post_domctl(struct xen_domctl *op, void *ssid) 
 { return; }
-static inline void acm_fail_dom0_op(struct dom0_op *op, void *ssid) 
+static inline void acm_fail_domctl(struct xen_domctl *op, void *ssid) 
 { return; }
 static inline int acm_pre_eventchannel_unbound(domid_t id1, domid_t id2)
 { return 0; }
@@ -225,23 +225,23 @@ static inline int acm_pre_eventchannel_i
         return ACM_ACCESS_PERMITTED;
 }
 
-static inline int acm_pre_dom0_op(struct dom0_op *op, void **ssid) 
+static inline int acm_pre_domctl(struct xen_domctl *op, void **ssid) 
 {
     int ret = -EACCES;
     struct domain *d;
 
     switch(op->cmd) {
-    case DOM0_CREATEDOMAIN:
+    case XEN_DOMCTL_createdomain:
         ret = acm_pre_domain_create(
             current->domain->ssid, op->u.createdomain.ssidref);
         break;
-    case DOM0_DESTROYDOMAIN:
+    case XEN_DOMCTL_destroydomain:
         if (*ssid != NULL) {
             printkd("%s: Warning. Overlapping destruction.\n", 
                     __func__);
             return -EACCES;
         }
-        d = find_domain_by_id(op->u.destroydomain.domain);
+        d = find_domain_by_id(op->domain);
         if (d != NULL) {
             *ssid = d->ssid; /* save for post destroy when d is gone */
             if (*ssid == NULL) {
@@ -262,23 +262,23 @@ static inline int acm_pre_dom0_op(struct
     return ret;
 }
 
-static inline void acm_post_dom0_op(struct dom0_op *op, void **ssid)
+static inline void acm_post_domctl(struct xen_domctl *op, void **ssid)
 {
     switch(op->cmd) {
-    case DOM0_CREATEDOMAIN:
+    case XEN_DOMCTL_createdomain:
         /* initialialize shared sHype security labels for new domain */
         acm_init_domain_ssid(
-            op->u.createdomain.domain, op->u.createdomain.ssidref);
+            op->domain, op->u.createdomain.ssidref);
         acm_post_domain_create(
-            op->u.createdomain.domain, op->u.createdomain.ssidref);
-        break;
-    case DOM0_DESTROYDOMAIN:
+            op->domain, op->u.createdomain.ssidref);
+        break;
+    case XEN_DOMCTL_destroydomain:
         if (*ssid == NULL) {
             printkd("%s: ERROR. SSID unset.\n",
                     __func__);
             break;
         }
-        acm_post_domain_destroy(*ssid, op->u.destroydomain.domain);
+        acm_post_domain_destroy(*ssid, op->domain);
         /* free security ssid for the destroyed domain (also if null policy */
         acm_free_domain_ssid((struct acm_ssid_domain *)(*ssid));
         *ssid = NULL;
@@ -286,14 +286,14 @@ static inline void acm_post_dom0_op(stru
     }
 }
 
-static inline void acm_fail_dom0_op(struct dom0_op *op, void **ssid)
+static inline void acm_fail_domctl(struct xen_domctl *op, void **ssid)
 {
     switch(op->cmd) {
-    case DOM0_CREATEDOMAIN:
+    case XEN_DOMCTL_createdomain:
         acm_fail_domain_create(
             current->domain->ssid, op->u.createdomain.ssidref);
         break;
-    case DOM0_DESTROYDOMAIN:
+    case XEN_DOMCTL_destroydomain:
         /*  we don't handle domain destroy failure but at least free the ssid 
*/
         if (*ssid == NULL) {
             printkd("%s: ERROR. SSID unset.\n",
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/asm-ia64/domain.h     Sun Aug 27 10:24:41 2006 -0600
@@ -53,7 +53,7 @@ extern void domain_cache_flush (struct d
 extern void domain_cache_flush (struct domain *d, int sync_only);
 
 /* Control the shadow mode.  */
-extern int shadow_mode_control(struct domain *d, dom0_shadow_control_t *sc);
+extern int shadow_mode_control(struct domain *d, xen_domctl_shadow_op_t *sc);
 
 /* Cleanly crash the current domain with a message.  */
 extern void panic_domain(struct pt_regs *, const char *, ...)
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/asm-x86/perfc_defn.h
--- a/xen/include/asm-x86/perfc_defn.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/asm-x86/perfc_defn.h  Sun Aug 27 10:24:41 2006 -0600
@@ -1,27 +1,6 @@
 /* This file is legitimately included multiple times. */
 /*#ifndef __XEN_PERFC_DEFN_H__*/
 /*#define __XEN_PERFC_DEFN_H__*/
-
-#define PERFC_MAX_PT_UPDATES 64
-#define PERFC_PT_UPDATES_BUCKET_SIZE 3
-PERFCOUNTER_ARRAY(wpt_updates,          "writable pt updates",
-                  PERFC_MAX_PT_UPDATES)
-PERFCOUNTER_ARRAY(bpt_updates,          "batched pt updates",
-                  PERFC_MAX_PT_UPDATES)
-PERFCOUNTER_ARRAY(l1_entries_checked,   "l1 entries checked",
-                  PERFC_MAX_PT_UPDATES)
-PERFCOUNTER_ARRAY(shm_l2_updates,       "shadow mode L2 pt updates",
-                  PERFC_MAX_PT_UPDATES)
-PERFCOUNTER_ARRAY(shm_hl2_updates,      "shadow mode HL2 pt updates",
-                  PERFC_MAX_PT_UPDATES)
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-PERFCOUNTER_ARRAY(shm_l3_updates,       "shadow mode L3 pt updates",
-                  PERFC_MAX_PT_UPDATES)
-PERFCOUNTER_ARRAY(shm_l4_updates,       "shadow mode L4 pt updates",
-                  PERFC_MAX_PT_UPDATES)
-#endif
-PERFCOUNTER_ARRAY(snapshot_copies,      "entries copied per snapshot",
-                  PERFC_MAX_PT_UPDATES)
 
 PERFCOUNTER_ARRAY(exceptions,           "exceptions", 32)
 
@@ -36,7 +15,6 @@ PERFCOUNTER_CPU(seg_fixups,             
 PERFCOUNTER_CPU(seg_fixups,             "segmentation fixups")
 
 PERFCOUNTER_CPU(apic_timer,             "apic timer interrupts")
-PERFCOUNTER_CPU(timer_max,           "timer max error (ns)")
 
 PERFCOUNTER_CPU(domain_page_tlb_flush,  "domain page tlb flushes")
 
@@ -46,107 +24,17 @@ PERFCOUNTER_CPU(page_faults,            
 PERFCOUNTER_CPU(page_faults,            "page faults")
 PERFCOUNTER_CPU(copy_user_faults,       "copy_user faults")
 
-PERFCOUNTER_CPU(shadow_fault_calls,     "calls to shadow_fault")
-PERFCOUNTER_CPU(shadow_fault_bail_pde_not_present,
-                "sf bailed due to pde not present")
-PERFCOUNTER_CPU(shadow_fault_bail_pte_not_present,
-                "sf bailed due to pte not present")
-PERFCOUNTER_CPU(shadow_fault_bail_ro_mapping,
-                "sf bailed due to a ro mapping")
-PERFCOUNTER_CPU(shadow_fault_fixed,     "sf fixed the pgfault")
-PERFCOUNTER_CPU(write_fault_bail,       "sf bailed due to write_fault")
-PERFCOUNTER_CPU(read_fault_bail,        "sf bailed due to read_fault")
-
 PERFCOUNTER_CPU(map_domain_page_count,  "map_domain_page count")
 PERFCOUNTER_CPU(ptwr_emulations,        "writable pt emulations")
 
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-PERFCOUNTER_CPU(shadow_l4_table_count,  "shadow_l4_table count")
-PERFCOUNTER_CPU(shadow_l3_table_count,  "shadow_l3_table count")
-#endif
-PERFCOUNTER_CPU(shadow_l2_table_count,  "shadow_l2_table count")
-PERFCOUNTER_CPU(shadow_l1_table_count,  "shadow_l1_table count")
-PERFCOUNTER_CPU(unshadow_table_count,   "unshadow_table count")
-PERFCOUNTER_CPU(shadow_fixup_count,     "shadow_fixup count")
-PERFCOUNTER_CPU(shadow_update_va_fail1, "shadow_update_va_fail1")
-PERFCOUNTER_CPU(shadow_update_va_fail2, "shadow_update_va_fail2")
+PERFCOUNTER_CPU(exception_fixed,        "pre-exception fixed")
 
-/* STATUS counters do not reset when 'P' is hit */
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-PERFSTATUS(shadow_l4_pages,             "current # shadow L4 pages")
-PERFSTATUS(shadow_l3_pages,             "current # shadow L3 pages")
-#endif
-PERFSTATUS(shadow_l2_pages,             "current # shadow L2 pages")
-PERFSTATUS(shadow_l1_pages,             "current # shadow L1 pages")
-PERFSTATUS(hl2_table_pages,             "current # hl2 pages")
-PERFSTATUS(snapshot_pages,              "current # fshadow snapshot pages")
-PERFSTATUS(writable_pte_predictions,    "# writable pte predictions")
-PERFSTATUS(free_l1_pages,               "current # free shadow L1 pages")
-
-PERFCOUNTER_CPU(check_pagetable,        "calls to check_pagetable")
-PERFCOUNTER_CPU(check_all_pagetables,   "calls to check_all_pagetables")
-
-PERFCOUNTER_CPU(shadow_hl2_table_count, "shadow_hl2_table count")
-PERFCOUNTER_CPU(shadow_set_l1e_force_map, "shadow_set_l1e forced to map l1")
-PERFCOUNTER_CPU(shadow_set_l1e_unlinked, "shadow_set_l1e found unlinked l1")
-PERFCOUNTER_CPU(shadow_set_l1e_fail,    "shadow_set_l1e failed (no sl1)")
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-PERFCOUNTER_CPU(shadow_set_l2e_force_map, "shadow_set_l2e forced to map l2")
-PERFCOUNTER_CPU(shadow_set_l3e_force_map, "shadow_set_l3e forced to map l3")
-#endif
-PERFCOUNTER_CPU(shadow_invlpg_faults,   "shadow_invlpg's get_user faulted")
-PERFCOUNTER_CPU(unshadow_l2_count,      "unpinned L2 count")
-
-PERFCOUNTER_CPU(shadow_status_shortcut, "fastpath miss on shadow cache")
-PERFCOUNTER_CPU(shadow_status_calls,    "calls to shadow_status")
-PERFCOUNTER_CPU(shadow_status_miss,     "missed shadow cache")
-PERFCOUNTER_CPU(shadow_status_hit_head, "hits on head of bucket")
-PERFCOUNTER_CPU(shadow_max_type,        "calls to shadow_max_type")
-
-PERFCOUNTER_CPU(shadow_sync_all,        "calls to shadow_sync_all")
-PERFCOUNTER_CPU(shadow_sync_va,         "calls to shadow_sync_va")
-PERFCOUNTER_CPU(resync_l1,              "resync L1 page")
-PERFCOUNTER_CPU(resync_l2,              "resync L2 page")
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-PERFCOUNTER_CPU(resync_l3,              "resync L3 page")
-PERFCOUNTER_CPU(resync_l4,              "resync L4 page")
-#endif
-PERFCOUNTER_CPU(resync_hl2,             "resync HL2 page")
-PERFCOUNTER_CPU(shadow_make_snapshot,   "snapshots created")
-PERFCOUNTER_CPU(shadow_mark_mfn_out_of_sync_calls,
-                "calls to shadow_mk_out_of_sync")
-PERFCOUNTER_CPU(shadow_out_of_sync_calls, "calls to shadow_out_of_sync")
-PERFCOUNTER_CPU(snapshot_entry_matches_calls, "calls to ss_entry_matches")
-PERFCOUNTER_CPU(snapshot_entry_matches_true, "ss_entry_matches returns true")
-
-PERFCOUNTER_CPU(validate_pte_calls,     "calls to validate_pte_change")
-PERFCOUNTER_CPU(validate_pte_changes1,  "validate_pte makes changes1")
-PERFCOUNTER_CPU(validate_pte_changes2,  "validate_pte makes changes2")
-PERFCOUNTER_CPU(validate_pte_changes3,  "validate_pte makes changes3")
-PERFCOUNTER_CPU(validate_pte_changes4,  "validate_pte makes changes4")
-PERFCOUNTER_CPU(validate_pde_calls,     "calls to validate_pde_change")
-PERFCOUNTER_CPU(validate_pde_changes,   "validate_pde makes changes")
-PERFCOUNTER_CPU(shadow_get_page_fail,   "shadow_get_page_from_l1e fails")
-PERFCOUNTER_CPU(validate_hl2e_calls,    "calls to validate_hl2e_change")
-PERFCOUNTER_CPU(validate_hl2e_changes,  "validate_hl2e makes changes")
-#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
-PERFCOUNTER_CPU(validate_entry_changes,  "validate_entry changes")
-#endif
-PERFCOUNTER_CPU(exception_fixed,        "pre-exception fixed")
-PERFCOUNTER_CPU(get_mfn_from_gpfn_foreign, "calls to 
get_mfn_from_gpfn_foreign")
-PERFCOUNTER_CPU(remove_all_access,      "calls to remove_all_access")
-PERFCOUNTER_CPU(remove_write_access,    "calls to remove_write_access")
-PERFCOUNTER_CPU(remove_write_access_easy, "easy outs of remove_write_access")
-PERFCOUNTER_CPU(remove_write_no_work,   "no work in remove_write_access")
-PERFCOUNTER_CPU(remove_write_not_writable, "remove_write non-writable page")
-PERFCOUNTER_CPU(remove_write_fast_exit, "remove_write hit predicted entry")
-PERFCOUNTER_CPU(remove_write_predicted, "remove_write predict hit&exit")
-PERFCOUNTER_CPU(remove_write_bad_prediction, "remove_write bad prediction")
-PERFCOUNTER_CPU(update_hl2e_invlpg,     "update_hl2e calls invlpg")
 
 /* Shadow2 counters */
 PERFCOUNTER_CPU(shadow2_alloc,          "calls to shadow2_alloc")
 PERFCOUNTER_CPU(shadow2_alloc_tlbflush, "shadow2_alloc flushed TLBs")
+
+/* STATUS counters do not reset when 'P' is hit */
 PERFSTATUS(shadow2_alloc_count,         "number of shadow pages in use")
 PERFCOUNTER_CPU(shadow2_free,           "calls to shadow2_free")
 PERFCOUNTER_CPU(shadow2_prealloc_1,     "shadow2 recycles old shadows")
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/asm-x86/processor.h
--- a/xen/include/asm-x86/processor.h   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/asm-x86/processor.h   Sun Aug 27 10:24:41 2006 -0600
@@ -130,11 +130,11 @@
 #define TF_kernel_mode         (1<<_TF_kernel_mode)
 
 /* #PF error code values. */
-#define PGERR_page_present   (1U<<0)
-#define PGERR_write_access   (1U<<1)
-#define PGERR_user_mode      (1U<<2)
-#define PGERR_reserved_bit   (1U<<3)
-#define PGERR_instr_fetch    (1U<<4)
+#define PFEC_page_present   (1U<<0)
+#define PFEC_write_access   (1U<<1)
+#define PFEC_user_mode      (1U<<2)
+#define PFEC_reserved_bit   (1U<<3)
+#define PFEC_insn_fetch     (1U<<4)
 
 #ifndef __ASSEMBLY__
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/asm-x86/shadow2-types.h
--- a/xen/include/asm-x86/shadow2-types.h       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/asm-x86/shadow2-types.h       Sun Aug 27 10:24:41 2006 -0600
@@ -460,19 +460,6 @@ struct shadow2_walk_t
     mfn_t l2mfn;                /* MFN that the level 2 entry is in */
     mfn_t l1mfn;                /* MFN that the level 1 entry is in */
 };
-
-
-/* X86 error code bits:
- * These bits certainly ought to be defined somewhere other than here,
- * but until that place is determined, here they sit.
- *
- * "PFEC" == "Page Fault Error Code"
- */
-#define X86_PFEC_PRESENT            1  /* 0 == page was not present */
-#define X86_PFEC_WRITE_FAULT        2  /* 0 == reading, 1 == writing */
-#define X86_PFEC_SUPERVISOR_FAULT   4  /* 0 == supervisor-mode, 1 == user */
-#define X86_PFEC_RESERVED_BIT_FAULT 8  /* 1 == reserved bits set in pte */
-#define X86_PFEC_INSN_FETCH_FAULT  16  /* 0 == normal, 1 == instr'n fetch */
 
 /* macros for dealing with the naming of the internal function names of the
  * shadow code's external entry points.
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/asm-x86/shadow2.h
--- a/xen/include/asm-x86/shadow2.h     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/asm-x86/shadow2.h     Sun Aug 27 10:24:41 2006 -0600
@@ -23,7 +23,7 @@
 #ifndef _XEN_SHADOW2_H
 #define _XEN_SHADOW2_H
 
-#include <public/dom0_ops.h> 
+#include <public/domctl.h> 
 #include <xen/sched.h>
 #include <xen/perfc.h>
 #include <asm/flushtlb.h>
@@ -34,14 +34,14 @@
 /* We're in one of the shadow modes */
 #define SHM2_enable    (1U << SHM2_shift)
 /* Refcounts based on shadow tables instead of guest tables */
-#define SHM2_refcounts (DOM0_SHADOW_ENABLE_REFCOUNT << SHM2_shift)
+#define SHM2_refcounts (XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT << SHM2_shift)
 /* Enable log dirty mode */
-#define SHM2_log_dirty (DOM0_SHADOW_ENABLE_LOG_DIRTY << SHM2_shift)
+#define SHM2_log_dirty (XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY << SHM2_shift)
 /* Xen does p2m translation, not guest */
-#define SHM2_translate (DOM0_SHADOW_ENABLE_TRANSLATE << SHM2_shift)
+#define SHM2_translate (XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE << SHM2_shift)
 /* Xen does not steal address space from the domain for its own booking;
  * requires VT or similar mechanisms */
-#define SHM2_external  (DOM0_SHADOW_ENABLE_EXTERNAL << SHM2_shift)
+#define SHM2_external  (XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL << SHM2_shift)
 
 #define shadow2_mode_enabled(_d)   ((_d)->arch.shadow2.mode)
 #define shadow2_mode_refcounts(_d) ((_d)->arch.shadow2.mode & SHM2_refcounts)
@@ -297,9 +297,9 @@ int shadow2_test_enable(struct domain *d
 
 /* Handler for shadow control ops: enabling and disabling shadow modes, 
  * and log-dirty bitmap ops all happen through here. */
-int shadow2_control_op(struct domain *d, 
-                       dom0_shadow_control_t *sc,
-                       XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op);
+int shadow2_domctl(struct domain *d, 
+                   xen_domctl_shadow_op_t *sc,
+                   XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
 
 /* Call when destroying a domain */
 void shadow2_teardown(struct domain *d);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/acm.h
--- a/xen/include/public/acm.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/acm.h  Sun Aug 27 10:24:41 2006 -0600
@@ -9,7 +9,6 @@
 #define _XEN_PUBLIC_ACM_H
 
 #include "xen.h"
-#include "sched_ctl.h"
 
 /* if ACM_DEBUG defined, all hooks should
  * print a short trace message (comment it out
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/acm_ops.h
--- a/xen/include/public/acm_ops.h      Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/acm_ops.h      Sun Aug 27 10:24:41 2006 -0600
@@ -9,7 +9,6 @@
 #define __XEN_PUBLIC_ACM_OPS_H__
 
 #include "xen.h"
-#include "sched_ctl.h"
 #include "acm.h"
 
 /*
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/arch-ia64.h    Sun Aug 27 10:24:41 2006 -0600
@@ -18,12 +18,15 @@
 
 #define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
 #define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define XEN_GUEST_HANDLE_64(name)       __guest_handle_ ## name
 #define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
 #ifdef __XEN_TOOLS__
 #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
 #endif
 
 #ifndef __ASSEMBLY__
+typedef uint64_t uint64_aligned_t;
+
 /* Guest handles for primitive C types. */
 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
 __DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/arch-powerpc.h
--- a/xen/include/public/arch-powerpc.h Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/arch-powerpc.h Sun Aug 27 10:24:41 2006 -0600
@@ -29,6 +29,7 @@
 
 #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
 #define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+#define XEN_GUEST_HANDLE_64(name)     __guest_handle_ ## name
 #define set_xen_guest_handle(hnd, val) \
     do { \
         if (sizeof ((hnd).__pad)) \
@@ -41,6 +42,8 @@
 #endif
 
 #ifndef __ASSEMBLY__
+typedef uint64_t uint64_aligned_t;
+
 /* Guest handles for primitive C types. */
 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
 __DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/arch-x86_32.h  Sun Aug 27 10:24:41 2006 -0600
@@ -27,9 +27,15 @@
 #define TRAP_INSTR "int $0x82"
 #endif
 
-
 /* Structural guest handles introduced in 0x00030201. */
-#if __XEN_INTERFACE_VERSION__ >= 0x00030201
+#if (defined(__XEN__) || defined(__XEN_TOOLS__)) && !defined(__ASSEMBLY__)
+typedef uint64_t __attribute__((aligned(8))) uint64_aligned_t;
+#define __DEFINE_XEN_GUEST_HANDLE(name, type)                   \
+    typedef struct { type *p; }                                 \
+        __guest_handle_ ## name;                                \
+    typedef struct { union { type *p; uint64_aligned_t q; }; }  \
+        __guest_handle_64_ ## name
+#elif __XEN_INTERFACE_VERSION__ >= 0x00030201
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
@@ -39,9 +45,15 @@
 
 #define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
 #define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
-#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
+#define XEN_GUEST_HANDLE_64(name)       __guest_handle_64_ ## name
 #ifdef __XEN_TOOLS__
 #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
+#define set_xen_guest_handle(hnd, val)                      \
+    do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0;   \
+         (hnd).p = val;                                     \
+    } while ( 0 )
+#else
+#define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
 #endif
 
 #ifndef __ASSEMBLY__
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/arch-x86_64.h  Sun Aug 27 10:24:41 2006 -0600
@@ -39,12 +39,15 @@
 
 #define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
 #define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define XEN_GUEST_HANDLE_64(name)       __guest_handle_ ## name
 #define set_xen_guest_handle(hnd, val)  do { (hnd).p = val; } while (0)
 #ifdef __XEN_TOOLS__
 #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
 #endif
 
 #ifndef __ASSEMBLY__
+typedef uint64_t uint64_aligned_t;
+
 /* Guest handles for primitive C types. */
 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
 __DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/dom0_ops.h     Sun Aug 27 10:24:41 2006 -0600
@@ -4,133 +4,49 @@
  * Process command requests from domain-0 guest OS.
  * 
  * Copyright (c) 2002-2003, B Dragovic
- * Copyright (c) 2002-2004, K Fraser
+ * Copyright (c) 2002-2006, K Fraser
  */
-
 
 #ifndef __XEN_PUBLIC_DOM0_OPS_H__
 #define __XEN_PUBLIC_DOM0_OPS_H__
 
 #include "xen.h"
-#include "sched_ctl.h"
+#include "platform.h"
 
-/*
- * Make sure you increment the interface version whenever you modify this file!
- * This makes sure that old versions of dom0 tools will stop working in a
- * well-defined way (rather than crashing the machine, for instance).
- * 
- * Separate kernel from tools as the kernel uses a small subset of the dom0
- * operations and so it is unnecessary to break backward compatibility so
- * often.
- */
-#define DOM0_TOOLS_INTERFACE_VERSION  0x13000001
-#define DOM0_KERNEL_INTERFACE_VERSION 0x03000001
-
-#ifdef __XEN_TOOLS__
-#define DOM0_INTERFACE_VERSION DOM0_TOOLS_INTERFACE_VERSION
-#else
-#define DOM0_INTERFACE_VERSION DOM0_KERNEL_INTERFACE_VERSION
+#if __XEN_INTERFACE_VERSION__ >= 0x00030204
+#error "dom0_ops.h is a compatibility interface only"
 #endif
 
-/************************************************************************/
+#define DOM0_INTERFACE_VERSION XENPF_INTERFACE_VERSION
 
-#define DOM0_GETMEMLIST        2
-struct dom0_getmemlist {
-    /* IN variables. */
-    domid_t       domain;
-    uint64_t max_pfns;
-    XEN_GUEST_HANDLE(xen_pfn_t) buffer;
-    /* OUT variables. */
-    uint64_t num_pfns;
-};
-typedef struct dom0_getmemlist dom0_getmemlist_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getmemlist_t);
+#define DOM0_SETTIME          XENPF_settime
+#define dom0_settime          xenpf_settime
+#define dom0_settime_t        xenpf_settime_t
 
-#define DOM0_SCHEDCTL          6
- /* struct sched_ctl_cmd is from sched-ctl.h   */
-typedef struct sched_ctl_cmd dom0_schedctl_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_schedctl_t);
+#define DOM0_ADD_MEMTYPE      XENPF_add_memtype
+#define dom0_add_memtype      xenpf_add_memtype
+#define dom0_add_memtype_t    xenpf_add_memtype_t
 
-#define DOM0_ADJUSTDOM         7
-/* struct sched_adjdom_cmd is from sched-ctl.h */
-typedef struct sched_adjdom_cmd dom0_adjustdom_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_adjustdom_t);
+#define DOM0_DEL_MEMTYPE      XENPF_del_memtype
+#define dom0_del_memtype      xenpf_del_memtype
+#define dom0_del_memtype_t    xenpf_del_memtype_t
 
-#define DOM0_CREATEDOMAIN      8
-struct dom0_createdomain {
-    /* IN parameters */
-    uint32_t ssidref;
-    xen_domain_handle_t handle;
-    /* IN/OUT parameters. */
-    /* Identifier for new domain (auto-allocate if zero is specified). */
-    domid_t domain;
-};
-typedef struct dom0_createdomain dom0_createdomain_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_createdomain_t);
+#define DOM0_READ_MEMTYPE     XENPF_read_memtype
+#define dom0_read_memtype     xenpf_read_memtype
+#define dom0_read_memtype_t   xenpf_read_memtype_t
 
-#define DOM0_DESTROYDOMAIN     9
-struct dom0_destroydomain {
-    /* IN variables. */
-    domid_t domain;
-};
-typedef struct dom0_destroydomain dom0_destroydomain_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_destroydomain_t);
+#define DOM0_MICROCODE        XENPF_microcode_update
+#define dom0_microcode        xenpf_microcode_update
+#define dom0_microcode_t      xenpf_microcode_update_t
 
-#define DOM0_PAUSEDOMAIN      10
-struct dom0_pausedomain {
-    /* IN parameters. */
-    domid_t domain;
-};
-typedef struct dom0_pausedomain dom0_pausedomain_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_pausedomain_t);
+#define DOM0_PLATFORM_QUIRK   XENPF_platform_quirk
+#define dom0_platform_quirk   xenpf_platform_quirk
+#define dom0_platform_quirk_t xenpf_platform_quirk_t
 
-#define DOM0_UNPAUSEDOMAIN    11
-struct dom0_unpausedomain {
-    /* IN parameters. */
-    domid_t domain;
-};
-typedef struct dom0_unpausedomain dom0_unpausedomain_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_unpausedomain_t);
+typedef uint64_t cpumap_t;
 
-#define DOM0_GETDOMAININFO    12
-struct dom0_getdomaininfo {
-    /* IN variables. */
-    domid_t  domain;                  /* NB. IN/OUT variable. */
-    /* OUT variables. */
-#define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
-#define DOMFLAGS_SHUTDOWN  (1<<2) /* The guest OS has shut down.             */
-#define DOMFLAGS_PAUSED    (1<<3) /* Currently paused by control software.   */
-#define DOMFLAGS_BLOCKED   (1<<4) /* Currently blocked pending an event.     */
-#define DOMFLAGS_RUNNING   (1<<5) /* Domain is currently running.            */
-#define DOMFLAGS_CPUMASK      255 /* CPU to which this domain is bound.      */
-#define DOMFLAGS_CPUSHIFT       8
-#define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code.  */
-#define DOMFLAGS_SHUTDOWNSHIFT 16
-    uint32_t flags;
-    uint64_t tot_pages;
-    uint64_t max_pages;
-    xen_pfn_t shared_info_frame;  /* MFN of shared_info struct */
-    uint64_t cpu_time;
-    uint32_t nr_online_vcpus;     /* Number of VCPUs currently online. */
-    uint32_t max_vcpu_id;         /* Maximum VCPUID in use by this domain. */
-    uint32_t ssidref;
-    xen_domain_handle_t handle;
-};
-typedef struct dom0_getdomaininfo dom0_getdomaininfo_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getdomaininfo_t);
-
-#define DOM0_SETVCPUCONTEXT   13
-struct dom0_setvcpucontext {
-    /* IN variables. */
-    domid_t               domain;
-    uint32_t              vcpu;
-    /* IN/OUT parameters */
-    XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt;
-};
-typedef struct dom0_setvcpucontext dom0_setvcpucontext_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_setvcpucontext_t);
-
-#define DOM0_MSR              15
+/* Unsupported legacy operation -- defined for API compatibility. */
+#define DOM0_MSR                 15
 struct dom0_msr {
     /* IN variables. */
     uint32_t write;
@@ -145,361 +61,8 @@ typedef struct dom0_msr dom0_msr_t;
 typedef struct dom0_msr dom0_msr_t;
 DEFINE_XEN_GUEST_HANDLE(dom0_msr_t);
 
-/*
- * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
- * 1 January, 1970 if the current system time was <system_time>.
- */
-#define DOM0_SETTIME          17
-struct dom0_settime {
-    /* IN variables. */
-    uint32_t secs;
-    uint32_t nsecs;
-    uint64_t system_time;
-};
-typedef struct dom0_settime dom0_settime_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_settime_t);
-
-#define DOM0_GETPAGEFRAMEINFO 18
-#define LTAB_SHIFT 28
-#define NOTAB 0         /* normal page */
-#define L1TAB (1<<LTAB_SHIFT)
-#define L2TAB (2<<LTAB_SHIFT)
-#define L3TAB (3<<LTAB_SHIFT)
-#define L4TAB (4<<LTAB_SHIFT)
-#define LPINTAB  (1<<31)
-#define XTAB  (0xf<<LTAB_SHIFT) /* invalid page */
-#define LTAB_MASK XTAB
-#define LTABTYPE_MASK (0x7<<LTAB_SHIFT)
-
-struct dom0_getpageframeinfo {
-    /* IN variables. */
-    xen_pfn_t gmfn;        /* GMFN to query.                            */
-    domid_t domain;        /* To which domain does the frame belong?    */
-    /* OUT variables. */
-    /* Is the page PINNED to a type? */
-    uint32_t type;         /* see above type defs */
-};
-typedef struct dom0_getpageframeinfo dom0_getpageframeinfo_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getpageframeinfo_t);
-
-/*
- * Read console content from Xen buffer ring.
- */
-#define DOM0_READCONSOLE      19
-struct dom0_readconsole {
-    /* IN variables. */
-    uint32_t clear;                /* Non-zero -> clear after reading. */
-    XEN_GUEST_HANDLE(char) buffer; /* Buffer start */
-    /* IN/OUT variables. */
-    uint32_t count;            /* In: Buffer size;  Out: Used buffer size  */
-};
-typedef struct dom0_readconsole dom0_readconsole_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_readconsole_t);
-
-/*
- * Set which physical cpus a vcpu can execute on.
- */
-#define DOM0_SETVCPUAFFINITY  20
-struct dom0_setvcpuaffinity {
-    /* IN variables. */
-    domid_t   domain;
-    uint32_t  vcpu;
-    cpumap_t  cpumap;
-};
-typedef struct dom0_setvcpuaffinity dom0_setvcpuaffinity_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_setvcpuaffinity_t);
-
-/* Get trace buffers machine base address */
-#define DOM0_TBUFCONTROL       21
-struct dom0_tbufcontrol {
-    /* IN variables */
-#define DOM0_TBUF_GET_INFO     0
-#define DOM0_TBUF_SET_CPU_MASK 1
-#define DOM0_TBUF_SET_EVT_MASK 2
-#define DOM0_TBUF_SET_SIZE     3
-#define DOM0_TBUF_ENABLE       4
-#define DOM0_TBUF_DISABLE      5
-    uint32_t      op;
-    /* IN/OUT variables */
-    cpumap_t      cpu_mask;
-    uint32_t      evt_mask;
-    /* OUT variables */
-    xen_pfn_t buffer_mfn;
-    uint32_t size;
-};
-typedef struct dom0_tbufcontrol dom0_tbufcontrol_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_tbufcontrol_t);
-
-/*
- * Get physical information about the host machine
- */
-#define DOM0_PHYSINFO         22
-struct dom0_physinfo {
-    uint32_t threads_per_core;
-    uint32_t cores_per_socket;
-    uint32_t sockets_per_node;
-    uint32_t nr_nodes;
-    uint32_t cpu_khz;
-    uint64_t total_pages;
-    uint64_t free_pages;
-    uint64_t scrub_pages;
-    uint32_t hw_cap[8];
-};
-typedef struct dom0_physinfo dom0_physinfo_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_physinfo_t);
-
-/*
- * Get the ID of the current scheduler.
- */
-#define DOM0_SCHED_ID        24
-struct dom0_sched_id {
-    /* OUT variable */
-    uint32_t sched_id;
-};
-typedef struct dom0_physinfo dom0_sched_id_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_sched_id_t);
-
-/*
- * Control shadow pagetables operation
- */
-#define DOM0_SHADOW_CONTROL  25
-
-/* Disable shadow mode. */
-#define DOM0_SHADOW_CONTROL_OP_OFF         0
-
-/* Enable shadow mode (mode contains ORed DOM0_SHADOW_ENABLE_* flags). */
-#define DOM0_SHADOW_CONTROL_OP_ENABLE      32
-
-/* Log-dirty bitmap operations. */
- /* Return the bitmap and clean internal copy for next round. */
-#define DOM0_SHADOW_CONTROL_OP_CLEAN       11
- /* Return the bitmap but do not modify internal copy. */
-#define DOM0_SHADOW_CONTROL_OP_PEEK        12
-
-/* Memory allocation accessors. */
-#define DOM0_SHADOW_CONTROL_OP_GET_ALLOCATION   30
-#define DOM0_SHADOW_CONTROL_OP_SET_ALLOCATION   31
-
-/* Legacy enable operations. */
- /* Equiv. to ENABLE with no mode flags. */
-#define DOM0_SHADOW_CONTROL_OP_ENABLE_TEST       1
- /* Equiv. to ENABLE with mode flag ENABLE_LOG_DIRTY. */
-#define DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY   2
- /* Equiv. to ENABLE with mode flags ENABLE_REFCOUNT and ENABLE_TRANSLATE. */
-#define DOM0_SHADOW_CONTROL_OP_ENABLE_TRANSLATE  3
-
-/* Mode flags for DOM0_SHADOW_CONTROL_OP_ENABLE. */
- /*
-  * Shadow pagetables are refcounted: guest does not use explicit mmu
-  * operations nor write-protect its pagetables.
-  */
-#define DOM0_SHADOW_ENABLE_REFCOUNT  (1 << 1)
- /*
-  * Log pages in a bitmap as they are dirtied.
-  * Used for live relocation to determine which pages must be re-sent.
-  */
-#define DOM0_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
- /*
-  * Automatically translate GPFNs into MFNs.
-  */
-#define DOM0_SHADOW_ENABLE_TRANSLATE (1 << 3)
- /*
-  * Xen does not steal virtual address space from the guest.
-  * Requires HVM support.
-  */
-#define DOM0_SHADOW_ENABLE_EXTERNAL  (1 << 4)
-
-struct dom0_shadow_control_stats {
-    uint32_t fault_count;
-    uint32_t dirty_count;
-};
-typedef struct dom0_shadow_control_stats dom0_shadow_control_stats_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_shadow_control_stats_t);
-
-struct dom0_shadow_control {
-    /* IN variables. */
-    domid_t        domain;
-    uint32_t       op;       /* DOM0_SHADOW_CONTROL_OP_* */
-
-    /* OP_ENABLE */
-    uint32_t       mode;     /* DOM0_SHADOW_ENABLE_* */
-
-    /* OP_GET_ALLOCATION / OP_SET_ALLOCATION */
-    uint32_t       mb;       /* Shadow memory allocation in MB */
-
-    /* OP_PEEK / OP_CLEAN */
-    XEN_GUEST_HANDLE(ulong) dirty_bitmap;
-    uint64_t       pages;    /* Size of buffer. Updated with actual size. */
-    struct dom0_shadow_control_stats stats;
-};
-typedef struct dom0_shadow_control dom0_shadow_control_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_shadow_control_t);
-
-#define DOM0_SETDOMAINMAXMEM   28
-struct dom0_setdomainmaxmem {
-    /* IN variables. */
-    domid_t  domain;
-    uint64_t max_memkb;
-};
-typedef struct dom0_setdomainmaxmem dom0_setdomainmaxmem_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_setdomainmaxmem_t);
-
-#define DOM0_GETPAGEFRAMEINFO2 29   /* batched interface */
-struct dom0_getpageframeinfo2 {
-    /* IN variables. */
-    domid_t  domain;
-    uint64_t num;
-    /* IN/OUT variables. */
-    XEN_GUEST_HANDLE(ulong) array;
-};
-typedef struct dom0_getpageframeinfo2 dom0_getpageframeinfo2_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getpageframeinfo2_t);
-
-/*
- * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
- * On x86, @type is an architecture-defined MTRR memory type.
- * On success, returns the MTRR that was used (@reg) and a handle that can
- * be passed to DOM0_DEL_MEMTYPE to accurately tear down the new setting.
- * (x86-specific).
- */
-#define DOM0_ADD_MEMTYPE         31
-struct dom0_add_memtype {
-    /* IN variables. */
-    xen_pfn_t mfn;
-    uint64_t nr_mfns;
-    uint32_t type;
-    /* OUT variables. */
-    uint32_t handle;
-    uint32_t reg;
-};
-typedef struct dom0_add_memtype dom0_add_memtype_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_add_memtype_t);
-
-/*
- * Tear down an existing memory-range type. If @handle is remembered then it
- * should be passed in to accurately tear down the correct setting (in case
- * of overlapping memory regions with differing types). If it is not known
- * then @handle should be set to zero. In all cases @reg must be set.
- * (x86-specific).
- */
-#define DOM0_DEL_MEMTYPE         32
-struct dom0_del_memtype {
-    /* IN variables. */
-    uint32_t handle;
-    uint32_t reg;
-};
-typedef struct dom0_del_memtype dom0_del_memtype_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_del_memtype_t);
-
-/* Read current type of an MTRR (x86-specific). */
-#define DOM0_READ_MEMTYPE        33
-struct dom0_read_memtype {
-    /* IN variables. */
-    uint32_t reg;
-    /* OUT variables. */
-    xen_pfn_t mfn;
-    uint64_t nr_mfns;
-    uint32_t type;
-};
-typedef struct dom0_read_memtype dom0_read_memtype_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_read_memtype_t);
-
-/* Interface for controlling Xen software performance counters. */
-#define DOM0_PERFCCONTROL        34
-/* Sub-operations: */
-#define DOM0_PERFCCONTROL_OP_RESET 1   /* Reset all counters to zero. */
-#define DOM0_PERFCCONTROL_OP_QUERY 2   /* Get perfctr information. */
-struct dom0_perfc_desc {
-    char         name[80];             /* name of perf counter */
-    uint32_t     nr_vals;              /* number of values for this counter */
-};
-typedef struct dom0_perfc_desc dom0_perfc_desc_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_perfc_desc_t);
-typedef uint32_t dom0_perfc_val_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_perfc_val_t);
-
-struct dom0_perfccontrol {
-    /* IN variables. */
-    uint32_t       op;                /*  DOM0_PERFCCONTROL_OP_??? */
-    /* OUT variables. */
-    uint32_t       nr_counters;       /*  number of counters description  */
-    uint32_t       nr_vals;                      /*  number of values  */
-    XEN_GUEST_HANDLE(dom0_perfc_desc_t) desc; /*  counter information (or 
NULL) */
-    XEN_GUEST_HANDLE(dom0_perfc_val_t) val;   /*  counter values (or NULL)  */
-};
-typedef struct dom0_perfccontrol dom0_perfccontrol_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_perfccontrol_t);
-
-#define DOM0_MICROCODE           35
-struct dom0_microcode {
-    /* IN variables. */
-    XEN_GUEST_HANDLE(void) data;          /* Pointer to microcode data */
-    uint32_t length;                  /* Length of microcode data. */
-};
-typedef struct dom0_microcode dom0_microcode_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_microcode_t);
-
-#define DOM0_IOPORT_PERMISSION   36
-struct dom0_ioport_permission {
-    domid_t  domain;                  /* domain to be affected */
-    uint32_t first_port;              /* first port int range */
-    uint32_t nr_ports;                /* size of port range */
-    uint8_t  allow_access;            /* allow or deny access to range? */
-};
-typedef struct dom0_ioport_permission dom0_ioport_permission_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_ioport_permission_t);
-
-#define DOM0_GETVCPUCONTEXT      37
-struct dom0_getvcpucontext {
-    /* IN variables. */
-    domid_t  domain;                  /* domain to be affected */
-    uint32_t vcpu;                    /* vcpu # */
-    /* OUT variables. */
-    XEN_GUEST_HANDLE(vcpu_guest_context_t) ctxt;
-};
-typedef struct dom0_getvcpucontext dom0_getvcpucontext_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getvcpucontext_t);
-
-#define DOM0_GETVCPUINFO         43
-struct dom0_getvcpuinfo {
-    /* IN variables. */
-    domid_t  domain;                  /* domain to be affected */
-    uint32_t vcpu;                    /* vcpu # */
-    /* OUT variables. */
-    uint8_t  online;                  /* currently online (not hotplugged)? */
-    uint8_t  blocked;                 /* blocked waiting for an event? */
-    uint8_t  running;                 /* currently scheduled on its CPU? */
-    uint64_t cpu_time;                /* total cpu time consumed (ns) */
-    uint32_t cpu;                     /* current mapping   */
-    cpumap_t cpumap;                  /* allowable mapping */
-};
-typedef struct dom0_getvcpuinfo dom0_getvcpuinfo_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getvcpuinfo_t);
-
-#define DOM0_GETDOMAININFOLIST   38
-struct dom0_getdomaininfolist {
-    /* IN variables. */
-    domid_t               first_domain;
-    uint32_t              max_domains;
-    XEN_GUEST_HANDLE(dom0_getdomaininfo_t) buffer;
-    /* OUT variables. */
-    uint32_t              num_domains;
-};
-typedef struct dom0_getdomaininfolist dom0_getdomaininfolist_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_getdomaininfolist_t);
-
-#define DOM0_PLATFORM_QUIRK      39
-#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
-#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
-#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
-struct dom0_platform_quirk {
-    /* IN variables. */
-    uint32_t quirk_id;
-};
-typedef struct dom0_platform_quirk dom0_platform_quirk_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_platform_quirk_t);
-
-#define DOM0_PHYSICAL_MEMORY_MAP 40   /* Unimplemented from 3.0.3 onwards */
+/* Unsupported legacy operation -- defined for API compatibility. */
+#define DOM0_PHYSICAL_MEMORY_MAP 40
 struct dom0_memory_map_entry {
     uint64_t start, end;
     uint32_t flags; /* reserved */
@@ -508,135 +71,18 @@ typedef struct dom0_memory_map_entry dom
 typedef struct dom0_memory_map_entry dom0_memory_map_entry_t;
 DEFINE_XEN_GUEST_HANDLE(dom0_memory_map_entry_t);
 
-struct dom0_physical_memory_map {
-    /* IN variables. */
-    uint32_t max_map_entries;
-    /* OUT variables. */
-    uint32_t nr_map_entries;
-    XEN_GUEST_HANDLE(dom0_memory_map_entry_t) memory_map;
-};
-typedef struct dom0_physical_memory_map dom0_physical_memory_map_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_physical_memory_map_t);
-
-#define DOM0_MAX_VCPUS 41
-struct dom0_max_vcpus {
-    domid_t  domain;        /* domain to be affected */
-    uint32_t max;           /* maximum number of vcpus */
-};
-typedef struct dom0_max_vcpus dom0_max_vcpus_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_max_vcpus_t);
-
-#define DOM0_SETDOMAINHANDLE 44
-struct dom0_setdomainhandle {
-    domid_t domain;
-    xen_domain_handle_t handle;
-};
-typedef struct dom0_setdomainhandle dom0_setdomainhandle_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_setdomainhandle_t);
-
-#define DOM0_SETDEBUGGING 45
-struct dom0_setdebugging {
-    domid_t domain;
-    uint8_t enable;
-};
-typedef struct dom0_setdebugging dom0_setdebugging_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_setdebugging_t);
-
-#define DOM0_IRQ_PERMISSION 46
-struct dom0_irq_permission {
-    domid_t domain;          /* domain to be affected */
-    uint8_t pirq;
-    uint8_t allow_access;    /* flag to specify enable/disable of IRQ access */
-};
-typedef struct dom0_irq_permission dom0_irq_permission_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_irq_permission_t);
-
-#define DOM0_IOMEM_PERMISSION 47
-struct dom0_iomem_permission {
-    domid_t  domain;          /* domain to be affected */
-    xen_pfn_t first_mfn;      /* first page (physical page number) in range */
-    uint64_t nr_mfns;         /* number of pages in range (>0) */
-    uint8_t allow_access;     /* allow (!0) or deny (0) access to range? */
-};
-typedef struct dom0_iomem_permission dom0_iomem_permission_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_iomem_permission_t);
-
-#define DOM0_HYPERCALL_INIT   48
-struct dom0_hypercall_init {
-    domid_t   domain;          /* domain to be affected */
-    xen_pfn_t gmfn;            /* GMFN to be initialised */
-};
-typedef struct dom0_hypercall_init dom0_hypercall_init_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_hypercall_init_t);
-
-#define DOM0_DOMAIN_SETUP     49
-#define _XEN_DOMAINSETUP_hvm_guest 0
-#define XEN_DOMAINSETUP_hvm_guest  (1UL<<_XEN_DOMAINSETUP_hvm_guest)
-#define _XEN_DOMAINSETUP_query 1       /* Get parameters (for save)  */
-#define XEN_DOMAINSETUP_query  (1UL<<_XEN_DOMAINSETUP_query)
-typedef struct dom0_domain_setup {
-    domid_t  domain;          /* domain to be affected */
-    unsigned long flags;      /* XEN_DOMAINSETUP_* */
-#ifdef __ia64__
-    unsigned long bp;         /* mpaddr of boot param area */
-    unsigned long maxmem;        /* Highest memory address for MDT.  */
-    unsigned long xsi_va;     /* Xen shared_info area virtual address.  */
-    unsigned int hypercall_imm;        /* Break imm for Xen hypercalls.  */
-#endif
-} dom0_domain_setup_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_domain_setup_t);
-
-#define DOM0_SETTIMEOFFSET    50
-struct dom0_settimeoffset {
-    domid_t  domain;
-    int32_t  time_offset_seconds; /* applied to domain wallclock time */
-};
-typedef struct dom0_settimeoffset dom0_settimeoffset_t;
-DEFINE_XEN_GUEST_HANDLE(dom0_settimeoffset_t);
-
 struct dom0_op {
     uint32_t cmd;
     uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
     union {
-        struct dom0_createdomain      createdomain;
-        struct dom0_pausedomain       pausedomain;
-        struct dom0_unpausedomain     unpausedomain;
-        struct dom0_destroydomain     destroydomain;
-        struct dom0_getmemlist        getmemlist;
-        struct sched_ctl_cmd          schedctl;
-        struct sched_adjdom_cmd       adjustdom;
-        struct dom0_setvcpucontext    setvcpucontext;
-        struct dom0_getdomaininfo     getdomaininfo;
-        struct dom0_getpageframeinfo  getpageframeinfo;
         struct dom0_msr               msr;
         struct dom0_settime           settime;
-        struct dom0_readconsole       readconsole;
-        struct dom0_setvcpuaffinity   setvcpuaffinity;
-        struct dom0_tbufcontrol       tbufcontrol;
-        struct dom0_physinfo          physinfo;
-        struct dom0_sched_id          sched_id;
-        struct dom0_shadow_control    shadow_control;
-        struct dom0_setdomainmaxmem   setdomainmaxmem;
-        struct dom0_getpageframeinfo2 getpageframeinfo2;
         struct dom0_add_memtype       add_memtype;
         struct dom0_del_memtype       del_memtype;
         struct dom0_read_memtype      read_memtype;
-        struct dom0_perfccontrol      perfccontrol;
         struct dom0_microcode         microcode;
-        struct dom0_ioport_permission ioport_permission;
-        struct dom0_getvcpucontext    getvcpucontext;
-        struct dom0_getvcpuinfo       getvcpuinfo;
-        struct dom0_getdomaininfolist getdomaininfolist;
         struct dom0_platform_quirk    platform_quirk;
-        struct dom0_physical_memory_map physical_memory_map;
-        struct dom0_max_vcpus         max_vcpus;
-        struct dom0_setdomainhandle   setdomainhandle;
-        struct dom0_setdebugging      setdebugging;
-        struct dom0_irq_permission    irq_permission;
-        struct dom0_iomem_permission  iomem_permission;
-        struct dom0_hypercall_init    hypercall_init;
-        struct dom0_domain_setup      domain_setup;
-        struct dom0_settimeoffset     settimeoffset;
+        struct dom0_memory_map_entry  physical_memory_map;
         uint8_t                       pad[128];
     } u;
 };
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/xen-compat.h
--- a/xen/include/public/xen-compat.h   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/xen-compat.h   Sun Aug 27 10:24:41 2006 -0600
@@ -9,7 +9,7 @@
 #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
 #define __XEN_PUBLIC_XEN_COMPAT_H__
 
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030203
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030204
 
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Xen is built with matching headers and implements the latest interface. */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/public/xen.h
--- a/xen/include/public/xen.h  Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/public/xen.h  Sun Aug 27 10:24:41 2006 -0600
@@ -34,7 +34,7 @@
 #define __HYPERVISOR_set_callbacks         4
 #define __HYPERVISOR_fpu_taskswitch        5
 #define __HYPERVISOR_sched_op_compat       6 /* compat since 0x00030101 */
-#define __HYPERVISOR_dom0_op               7
+#define __HYPERVISOR_platform_op           7
 #define __HYPERVISOR_set_debugreg          8
 #define __HYPERVISOR_get_debugreg          9
 #define __HYPERVISOR_update_descriptor    10
@@ -61,6 +61,8 @@
 #define __HYPERVISOR_event_channel_op     32
 #define __HYPERVISOR_physdev_op           33
 #define __HYPERVISOR_hvm_op               34
+#define __HYPERVISOR_sysctl               35
+#define __HYPERVISOR_domctl               36
 
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
@@ -88,6 +90,11 @@
 #define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
 #undef __HYPERVISOR_physdev_op
 #define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
+#endif
+
+/* New platform_op hypercall introduced in 0x00030204. */
+#if __XEN_INTERFACE_VERSION__ < 0x00030204
+#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
 #endif
 
 /* 
@@ -530,13 +537,16 @@ typedef struct dom0_vga_console_info {
     uint8_t rsvd_size;
 } dom0_vga_console_info_t;
 
-typedef uint64_t cpumap_t;
-
 typedef uint8_t xen_domain_handle_t[16];
 
 /* Turn a plain number into a C unsigned long constant. */
 #define __mk_unsigned_long(x) x ## UL
 #define mk_unsigned_long(x) __mk_unsigned_long(x)
+
+DEFINE_XEN_GUEST_HANDLE(uint8_t);
+DEFINE_XEN_GUEST_HANDLE(uint16_t);
+DEFINE_XEN_GUEST_HANDLE(uint32_t);
+DEFINE_XEN_GUEST_HANDLE(uint64_t);
 
 #else /* __ASSEMBLY__ */
 
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/cpumask.h
--- a/xen/include/xen/cpumask.h Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/cpumask.h Sun Aug 27 10:24:41 2006 -0600
@@ -379,4 +379,11 @@ extern cpumask_t cpu_present_map;
 #define for_each_online_cpu(cpu)  for_each_cpu_mask((cpu), cpu_online_map)
 #define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
 
+/* Copy to/from cpumap provided by control tools. */
+struct xenctl_cpumap;
+void cpumask_to_xenctl_cpumap(
+    struct xenctl_cpumap *enctl_cpumap, cpumask_t *cpumask);
+void xenctl_cpumap_to_cpumask(
+    cpumask_t *cpumask, struct xenctl_cpumap *enctl_cpumap);
+
 #endif /* __XEN_CPUMASK_H */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/elf.h
--- a/xen/include/xen/elf.h     Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/elf.h     Sun Aug 27 10:24:41 2006 -0600
@@ -529,6 +529,10 @@ extern int loadelfimage(struct domain_se
 extern int loadelfimage(struct domain_setup_info *);
 extern int parseelfimage(struct domain_setup_info *);
 
+extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
+                                             int type, int *defined);
+extern const char *xen_elfnote_string(struct domain_setup_info *dsi, int type);
+
 #ifdef Elf_Ehdr
 extern int elf_sanity_check(Elf_Ehdr *ehdr);
 #endif
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/hypercall.h
--- a/xen/include/xen/hypercall.h       Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/hypercall.h       Sun Aug 27 10:24:41 2006 -0600
@@ -9,7 +9,9 @@
 #include <xen/types.h>
 #include <xen/time.h>
 #include <public/xen.h>
-#include <public/dom0_ops.h>
+#include <public/domctl.h>
+#include <public/sysctl.h>
+#include <public/platform.h>
 #include <public/acm_ops.h>
 #include <public/event_channel.h>
 #include <asm/hypercall.h>
@@ -29,8 +31,16 @@ do_sched_op(
     XEN_GUEST_HANDLE(void) arg);
 
 extern long
-do_dom0_op(
-    XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op);
+do_domctl(
+    XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
+
+extern long
+do_sysctl(
+    XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
+
+extern long
+do_platform_op(
+    XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op);
 
 extern long
 do_memory_op(
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/perfc_defn.h
--- a/xen/include/xen/perfc_defn.h      Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/perfc_defn.h      Sun Aug 27 10:24:41 2006 -0600
@@ -8,7 +8,6 @@ PERFCOUNTER_ARRAY(hypercalls,           
 
 PERFCOUNTER_CPU(irqs,                   "#interrupts")
 PERFCOUNTER_CPU(ipis,                   "#IPIs")
-PERFCOUNTER_CPU(irq_time,               "cycles spent in irq handler")
 
 PERFCOUNTER_CPU(sched_irq,              "sched: timer")
 PERFCOUNTER_CPU(sched_run,              "sched: runs through scheduler")
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/sched-if.h
--- a/xen/include/xen/sched-if.h        Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/sched-if.h        Sun Aug 27 10:24:41 2006 -0600
@@ -73,9 +73,8 @@ struct scheduler {
 
     struct task_slice (*do_schedule) (s_time_t);
 
-    int          (*control)        (struct sched_ctl_cmd *);
-    int          (*adjdom)         (struct domain *,
-                                    struct sched_adjdom_cmd *);
+    int          (*adjust)         (struct domain *,
+                                    struct xen_domctl_scheduler_op *);
     void         (*dump_settings)  (void);
     void         (*dump_cpu_state) (int);
 };
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/sched.h
--- a/xen/include/xen/sched.h   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/sched.h   Sun Aug 27 10:24:41 2006 -0600
@@ -7,7 +7,7 @@
 #include <xen/spinlock.h>
 #include <xen/smp.h>
 #include <public/xen.h>
-#include <public/dom0_ops.h>
+#include <public/domctl.h>
 #include <public/vcpu.h>
 #include <xen/time.h>
 #include <xen/timer.h>
@@ -179,13 +179,24 @@ struct domain_setup_info
     unsigned long v_kernstart;
     unsigned long v_kernend;
     unsigned long v_kernentry;
+#define PAEKERN_no           0
+#define PAEKERN_yes          1
+#define PAEKERN_extended_cr3 2
+    unsigned int  pae_kernel;
     /* Initialised by loader: Private. */
     unsigned long elf_paddr_offset;
     unsigned int  load_symtab;
     unsigned long symtab_addr;
     unsigned long symtab_len;
-    /* Indicate whether it's xen specific image */
-    char *xen_section_string;
+    /*
+     * Only one of __elfnote_* or __xen_guest_string will be
+     * non-NULL.
+     *
+     * You should use the xen_elfnote_* accessors below in order to
+     * pickup the correct one and retain backwards compatibility.
+     */
+    void *__elfnote_section, *__elfnote_section_end;
+    char *__xen_guest_string;
 };
 
 extern struct vcpu *idle_vcpu[NR_CPUS];
@@ -232,7 +243,7 @@ extern int construct_dom0(
     unsigned long image_start, unsigned long image_len, 
     unsigned long initrd_start, unsigned long initrd_len,
     char *cmdline);
-extern int set_info_guest(struct domain *d, dom0_setvcpucontext_t *);
+extern int set_info_guest(struct domain *d, xen_domctl_vcpucontext_t *);
 
 struct domain *find_domain_by_id(domid_t dom);
 extern void domain_destroy(struct domain *d);
@@ -271,8 +282,7 @@ void schedulers_start(void);
 void schedulers_start(void);
 int  sched_init_vcpu(struct vcpu *);
 void sched_destroy_domain(struct domain *);
-long sched_ctl(struct sched_ctl_cmd *);
-long sched_adjdom(struct sched_adjdom_cmd *);
+long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *);
 int  sched_id(void);
 void vcpu_wake(struct vcpu *d);
 void vcpu_sleep_nosync(struct vcpu *d);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/include/xen/trace.h
--- a/xen/include/xen/trace.h   Fri Aug 25 16:21:39 2006 -0600
+++ b/xen/include/xen/trace.h   Sun Aug 27 10:24:41 2006 -0600
@@ -16,15 +16,13 @@
  *
  * Access to the trace buffers is via a dom0 hypervisor op and analysis of
  * trace buffer contents can then be performed using a userland tool.
- *
- * See also common/trace.c and the dom0 op in include/public/dom0_ops.h
  */
 
 #ifndef __XEN_TRACE_H__
 #define __XEN_TRACE_H__
 
 #include <xen/config.h>
-#include <public/dom0_ops.h>
+#include <public/sysctl.h>
 #include <public/trace.h>
 
 extern int tb_init_done;
@@ -33,7 +31,7 @@ void init_trace_bufs(void);
 void init_trace_bufs(void);
 
 /* used to retrieve the physical address of the trace buffers */
-int tb_control(dom0_tbufcontrol_t *tbc);
+int tb_control(struct xen_sysctl_tbuf_op *tbc);
 
 void trace(u32 event, unsigned long d1, unsigned long d2,
            unsigned long d3, unsigned long d4, unsigned long d5);
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 
patches/linux-2.6.16.13/x86-elfnote-as-preprocessor-macro.patch
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/linux-2.6.16.13/x86-elfnote-as-preprocessor-macro.patch   Sun Aug 
27 10:24:41 2006 -0600
@@ -0,0 +1,44 @@
+
+diff -r 4b7cd997c08f include/linux/elfnote.h
+--- a/include/linux/elfnote.h  Wed Aug 23 11:48:46 2006 +0100
++++ b/include/linux/elfnote.h  Wed Aug 23 12:44:27 2006 +0100
+@@ -31,22 +31,24 @@
+ /*
+  * Generate a structure with the same shape as Elf{32,64}_Nhdr (which
+  * turn out to be the same size and shape), followed by the name and
+- * desc data with appropriate padding.  The 'desc' argument includes
+- * the assembler pseudo op defining the type of the data: .asciz
+- * "hello, world"
++ * desc data with appropriate padding.  The 'desctype' argument is the
++ * assembler pseudo op defining the type of the data e.g. .asciz while
++ * 'descdata' is the data itself e.g.  "hello, world".
++ *
++ * e.g. ELFNOTE(XYZCo, 42, .asciz, "forty-two")
++ *      ELFNOTE(XYZCo, 12, .long, 0xdeadbeef)
+  */
+-.macro ELFNOTE name type desc:vararg
+-.pushsection ".note.\name"
+-  .align 4
+-  .long 2f - 1f                       /* namesz */
+-  .long 4f - 3f                       /* descsz */
+-  .long \type
+-1:.asciz "\name"
+-2:.align 4
+-3:\desc
+-4:.align 4
+-.popsection
+-.endm
++#define ELFNOTE(name, type, desctype, descdata)       \
++.pushsection .note.name                       ;       \
++  .align 4                            ;       \
++  .long 2f - 1f               /* namesz */    ;       \
++  .long 4f - 3f               /* descsz */    ;       \
++  .long type                          ;       \
++1:.asciz "name"                               ;       \
++2:.align 4                            ;       \
++3:desctype descdata                   ;       \
++4:.align 4                            ;       \
++.popsection                           ;
+ #else /* !__ASSEMBLER__ */
+ #include <linux/elf.h>
+ /*
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 tools/xcutils/readnotes.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xcutils/readnotes.c Sun Aug 27 10:24:41 2006 -0600
@@ -0,0 +1,326 @@
+#include <elf.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#include <xen/elfnote.h>
+
+#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_)))
+#define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->n_namesz+3)&~3))
+#define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->n_descsz+3)&~3))
+
+#ifndef ELFSIZE
+#include <limits.h>
+#if UINT_MAX == ULONG_MAX
+#define ELFSIZE 32
+#else
+#define ELFSIZE 64
+#endif
+#endif
+
+#if (ELFSIZE == 32)
+typedef Elf32_Nhdr Elf_Nhdr;
+typedef Elf32_Half Elf_Half;
+typedef Elf32_Word Elf_Word;
+#elif (ELFSIZE == 64)
+typedef Elf64_Nhdr Elf_Nhdr;
+typedef Elf64_Half Elf_Half;
+typedef Elf64_Word Elf_Word;
+#else
+#error "Unknown ELFSIZE"
+#endif
+
+static void print_string_note(const char *prefix, Elf_Nhdr *note)
+{
+       printf("%s: %s\n", prefix, (const char *)ELFNOTE_DESC(note));
+}
+
+static void print_numeric_note(const char *prefix,Elf_Nhdr *note)
+{
+       switch (note->n_descsz)
+       {
+       case 4:
+               printf("%s: %#010" PRIx32 " (4 bytes)\n",
+                      prefix, *(uint32_t *)ELFNOTE_DESC(note));
+               break;
+       case 8:
+               printf("%s: %#018" PRIx64 " (8 bytes)\n",
+                      prefix, *(uint64_t *)ELFNOTE_DESC(note));
+               break;
+       default:
+               printf("%s: unknown data size %#x\n", prefix, note->n_descsz);
+               break;
+       }
+}
+
+static inline int is_elf(void *image)
+{
+       /*
+        * Since we are only accessing the e_ident field we can
+        * acccess the bytes directly without needing to figure out
+        * which version of Elf*_Ehdr structure to use.
+        */
+       const unsigned char *hdr = image;
+       return ( hdr[EI_MAG0] == ELFMAG0 &&
+                hdr[EI_MAG1] == ELFMAG1 &&
+                hdr[EI_MAG2] == ELFMAG2 &&
+                hdr[EI_MAG3] == ELFMAG3 );
+}
+
+static inline unsigned char ehdr_class(void *image)
+{
+       /*
+        * Since we are only accessing the e_ident field we can
+        * acccess the bytes directly without needing to figure out
+        * which version of Elf*_Ehdr structure to use.
+        */
+       const unsigned char *hdr = image;
+       switch (hdr[EI_CLASS])
+       {
+       case ELFCLASS32:
+       case ELFCLASS64:
+               return hdr[EI_CLASS];
+       default:
+               fprintf(stderr, "Unknown ELF class %d\n", hdr[EI_CLASS]);
+               exit(1);
+       }
+}
+
+static inline Elf_Half ehdr_shnum(void *image)
+{
+       switch (ehdr_class(image))
+       {
+       case ELFCLASS32:
+               return ((Elf32_Ehdr *)image)->e_shnum;
+       case ELFCLASS64:
+               return ((Elf64_Ehdr *)image)->e_shnum;
+       default:
+               exit(1);
+       }
+}
+
+static inline Elf_Word shdr_type(void *image, int shnum)
+{
+       switch (ehdr_class(image))
+       {
+       case ELFCLASS32:
+       {
+               Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image;
+               Elf32_Shdr *shdr = (Elf32_Shdr*)(image + ehdr->e_shoff +
+                                                (shnum*ehdr->e_shentsize));
+               return shdr->sh_type;
+       }
+       case ELFCLASS64:
+       {
+               Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image;
+               Elf64_Shdr *shdr = (Elf64_Shdr*)(image + ehdr->e_shoff +
+                                                (shnum*ehdr->e_shentsize));
+               return shdr->sh_type;
+       }
+       default:
+               exit(1);
+       }
+}
+
+static inline const char *shdr_name(void *image, int shnum)
+{
+       const char *shstrtab;
+
+       switch (ehdr_class(image))
+       {
+       case ELFCLASS32:
+       {
+               Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image;
+               Elf32_Shdr *shdr;
+               /* Find the section-header strings table. */
+               if ( ehdr->e_shstrndx == SHN_UNDEF )
+                       return NULL;
+               shdr = (Elf32_Shdr *)(image + ehdr->e_shoff +
+                                     (ehdr->e_shstrndx*ehdr->e_shentsize));
+               shstrtab = image + shdr->sh_offset;
+
+               shdr= (Elf32_Shdr*)(image + ehdr->e_shoff +
+                                   (shnum*ehdr->e_shentsize));
+               return &shstrtab[shdr->sh_name];
+       }
+       case ELFCLASS64:
+       {
+               Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image;
+               Elf64_Shdr *shdr;
+               /* Find the section-header strings table. */
+               if ( ehdr->e_shstrndx == SHN_UNDEF )
+                       return NULL;
+               shdr = (Elf64_Shdr *)(image + ehdr->e_shoff +
+                                     (ehdr->e_shstrndx*ehdr->e_shentsize));
+               shstrtab = image + shdr->sh_offset;
+
+               shdr= (Elf64_Shdr*)(image + ehdr->e_shoff +
+                                   (shnum*ehdr->e_shentsize));
+               return &shstrtab[shdr->sh_name];
+       }
+       default:
+               exit(1);
+       }
+}
+static inline void *shdr_start(void *image, int shnum)
+{
+       switch (ehdr_class(image))
+       {
+       case ELFCLASS32:
+       {
+               Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image;
+               Elf32_Shdr *shdr = (Elf32_Shdr*)(image + ehdr->e_shoff +
+                                                (shnum*ehdr->e_shentsize));
+               return image + shdr->sh_offset;
+       }
+       case ELFCLASS64:
+       {
+               Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image;
+               Elf64_Shdr *shdr = (Elf64_Shdr*)(image + ehdr->e_shoff +
+                                                (shnum*ehdr->e_shentsize));
+               return image + shdr->sh_offset;
+       }
+       default:
+               exit(1);
+       }
+}
+
+static inline void *shdr_end(void *image, int shnum)
+{
+       switch (ehdr_class(image))
+       {
+       case ELFCLASS32:
+       {
+               Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image;
+               Elf32_Shdr *shdr = (Elf32_Shdr*)(image + ehdr->e_shoff +
+                                                (shnum*ehdr->e_shentsize));
+               return image + shdr->sh_offset + shdr->sh_size;
+       }
+       case ELFCLASS64:
+       {
+               Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image;
+               Elf64_Shdr *shdr = (Elf64_Shdr*)(image + ehdr->e_shoff +
+                                                (shnum*ehdr->e_shentsize));
+               return image + shdr->sh_offset + shdr->sh_size;
+       }
+       default:
+               exit(1);
+       }
+}
+
+int main(int argc, char **argv)
+{
+       const char *f;
+       int fd,h;
+       void *image;
+       struct stat st;
+       Elf_Nhdr *note;
+
+       if (argc != 2)
+       {
+               fprintf(stderr, "Usage: readnotes <elfimage>\n");
+               return 1;
+       }
+       f = argv[1];
+
+       fd = open(f, O_RDONLY);
+       if (fd == -1)
+       {
+               fprintf(stderr, "Unable to open %s: %s\n", f, strerror(errno));
+               return 1;
+       }
+       if (fstat(fd, &st) == -1)
+       {
+               fprintf(stderr, "Unable to determine size of %s: %s\n",
+                       f, strerror(errno));
+               return 1;
+       }
+
+       image = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+       if (image == MAP_FAILED)
+       {
+               fprintf(stderr, "Unable to map %s: %s\n", f, strerror(errno));
+               return 1;
+       }
+
+       if ( !is_elf(image) )
+       {
+               fprintf(stderr, "File %s is not an ELF image\n", f);
+               return 1;
+       }
+
+       for ( h=0; h < ehdr_shnum(image); h++)
+       {
+               if (shdr_type(image,h) != SHT_NOTE)
+                       continue;
+               for (note = (Elf_Nhdr*)shdr_start(image,h);
+                    note < (Elf_Nhdr*)shdr_end(image,h);
+                    note = (Elf_Nhdr*)(ELFNOTE_NEXT(note)))
+               {
+                       switch(note->n_type)
+                       {
+                       case XEN_ELFNOTE_INFO:
+                               print_string_note("INFO", note);
+                               break;
+                       case XEN_ELFNOTE_ENTRY:
+                               print_numeric_note("ENTRY", note);
+                               break;
+                       case XEN_ELFNOTE_HYPERCALL_PAGE:
+                               print_numeric_note("HYPERCALL_PAGE", note);
+                               break;
+                       case XEN_ELFNOTE_VIRT_BASE:
+                               print_numeric_note("VIRT_BASE", note);
+                               break;
+                       case XEN_ELFNOTE_PADDR_OFFSET:
+                               print_numeric_note("PADDR_OFFSET", note);
+                               break;
+                       case XEN_ELFNOTE_XEN_VERSION:
+                               print_string_note("XEN_VERSION", note);
+                               break;
+                       case XEN_ELFNOTE_GUEST_OS:
+                               print_string_note("GUEST_OS", note);
+                               break;
+                       case XEN_ELFNOTE_GUEST_VERSION:
+                               print_string_note("GUEST_VERSION", note);
+                               break;
+                       case XEN_ELFNOTE_LOADER:
+                               print_string_note("LOADER", note);
+                               break;
+                       case XEN_ELFNOTE_PAE_MODE:
+                               print_string_note("PAE_MODE", note);
+                               break;
+                       case XEN_ELFNOTE_FEATURES:
+                               print_string_note("FEATURES", note);
+                               break;
+                       default:
+                               printf("unknown note type %#x\n", note->n_type);
+                               break;
+                       }
+               }
+       }
+
+       for ( h=0; h < ehdr_shnum(image); h++)
+       {
+               const char *name = shdr_name(image,h);
+
+               if ( name == NULL )
+                       continue;
+               if ( strcmp(name, "__xen_guest") != 0 )
+                       continue;
+
+               printf("__xen_guest: %s\n", (const char *)shdr_start(image, h));
+               break;
+       }
+
+       return 0;
+}
+
+
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/domctl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/domctl.c     Sun Aug 27 10:24:41 2006 -0600
@@ -0,0 +1,326 @@
+/******************************************************************************
+ * Arch-specific domctl.c
+ * 
+ * Copyright (c) 2002-2006, K A Fraser
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/guest_access.h>
+#include <public/domctl.h>
+#include <xen/sched.h>
+#include <xen/event.h>
+#include <xen/domain_page.h>
+#include <asm/msr.h>
+#include <xen/trace.h>
+#include <xen/console.h>
+#include <xen/iocap.h>
+#include <asm/shadow.h>
+#include <asm/irq.h>
+#include <asm/hvm/hvm.h>
+#include <asm/hvm/support.h>
+#include <asm/processor.h>
+
+long arch_do_domctl(
+    struct xen_domctl *domctl,
+    XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
+{
+    long ret = 0;
+
+    switch ( domctl->cmd )
+    {
+
+    case XEN_DOMCTL_shadow_op:
+    {
+        struct domain *d;
+        ret = -ESRCH;
+        d = find_domain_by_id(domctl->domain);
+        if ( d != NULL )
+        {
+            ret = shadow2_domctl(d, &domctl->u.shadow_op, u_domctl);
+            put_domain(d);
+            copy_to_guest(u_domctl, domctl, 1);
+        } 
+    }
+    break;
+
+    case XEN_DOMCTL_ioport_permission:
+    {
+        struct domain *d;
+        unsigned int fp = domctl->u.ioport_permission.first_port;
+        unsigned int np = domctl->u.ioport_permission.nr_ports;
+
+        ret = -EINVAL;
+        if ( (fp + np) > 65536 )
+            break;
+
+        ret = -ESRCH;
+        if ( unlikely((d = find_domain_by_id(domctl->domain)) == NULL) )
+            break;
+
+        if ( np == 0 )
+            ret = 0;
+        else if ( domctl->u.ioport_permission.allow_access )
+            ret = ioports_permit_access(d, fp, fp + np - 1);
+        else
+            ret = ioports_deny_access(d, fp, fp + np - 1);
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_getpageframeinfo:
+    {
+        struct page_info *page;
+        unsigned long mfn = domctl->u.getpageframeinfo.gmfn;
+        domid_t dom = domctl->domain;
+        struct domain *d;
+
+        ret = -EINVAL;
+
+        if ( unlikely(!mfn_valid(mfn)) ||
+             unlikely((d = find_domain_by_id(dom)) == NULL) )
+            break;
+
+        page = mfn_to_page(mfn);
+
+        if ( likely(get_page(page, d)) )
+        {
+            ret = 0;
+
+            domctl->u.getpageframeinfo.type = XEN_DOMCTL_PFINFO_NOTAB;
+
+            if ( (page->u.inuse.type_info & PGT_count_mask) != 0 )
+            {
+                switch ( page->u.inuse.type_info & PGT_type_mask )
+                {
+                case PGT_l1_page_table:
+                    domctl->u.getpageframeinfo.type = XEN_DOMCTL_PFINFO_L1TAB;
+                    break;
+                case PGT_l2_page_table:
+                    domctl->u.getpageframeinfo.type = XEN_DOMCTL_PFINFO_L2TAB;
+                    break;
+                case PGT_l3_page_table:
+                    domctl->u.getpageframeinfo.type = XEN_DOMCTL_PFINFO_L3TAB;
+                    break;
+                case PGT_l4_page_table:
+                    domctl->u.getpageframeinfo.type = XEN_DOMCTL_PFINFO_L4TAB;
+                    break;
+                }
+            }
+            
+            put_page(page);
+        }
+
+        put_domain(d);
+
+        copy_to_guest(u_domctl, domctl, 1);
+    }
+    break;
+
+    case XEN_DOMCTL_getpageframeinfo2:
+    {
+#define GPF2_BATCH (PAGE_SIZE / sizeof(long))
+        int n,j;
+        int num = domctl->u.getpageframeinfo2.num;
+        domid_t dom = domctl->domain;
+        struct domain *d;
+        unsigned long *l_arr;
+        ret = -ESRCH;
+
+        if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
+            break;
+
+        if ( unlikely(num > 1024) )
+        {
+            ret = -E2BIG;
+            put_domain(d);
+            break;
+        }
+
+        l_arr = alloc_xenheap_page();
+ 
+        ret = 0;
+        for ( n = 0; n < num; )
+        {
+            int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
+
+            if ( copy_from_guest_offset(l_arr,
+                                        domctl->u.getpageframeinfo2.array,
+                                        n, k) )
+            {
+                ret = -EINVAL;
+                break;
+            }
+     
+            for ( j = 0; j < k; j++ )
+            {      
+                struct page_info *page;
+                unsigned long mfn = l_arr[j];
+
+                page = mfn_to_page(mfn);
+
+                if ( likely(mfn_valid(mfn) && get_page(page, d)) ) 
+                {
+                    unsigned long type = 0;
+
+                    switch( page->u.inuse.type_info & PGT_type_mask )
+                    {
+                    case PGT_l1_page_table:
+                        type = XEN_DOMCTL_PFINFO_L1TAB;
+                        break;
+                    case PGT_l2_page_table:
+                        type = XEN_DOMCTL_PFINFO_L2TAB;
+                        break;
+                    case PGT_l3_page_table:
+                        type = XEN_DOMCTL_PFINFO_L3TAB;
+                        break;
+                    case PGT_l4_page_table:
+                        type = XEN_DOMCTL_PFINFO_L4TAB;
+                        break;
+                    }
+
+                    if ( page->u.inuse.type_info & PGT_pinned )
+                        type |= XEN_DOMCTL_PFINFO_LPINTAB;
+                    l_arr[j] |= type;
+                    put_page(page);
+                }
+                else
+                    l_arr[j] |= XEN_DOMCTL_PFINFO_XTAB;
+
+            }
+
+            if ( copy_to_guest_offset(domctl->u.getpageframeinfo2.array,
+                                      n, l_arr, k) )
+            {
+                ret = -EINVAL;
+                break;
+            }
+
+            n += k;
+        }
+
+        free_xenheap_page(l_arr);
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_getmemlist:
+    {
+        int i;
+        struct domain *d = find_domain_by_id(domctl->domain);
+        unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
+        unsigned long mfn;
+        struct list_head *list_ent;
+
+        ret = -EINVAL;
+        if ( d != NULL )
+        {
+            ret = 0;
+
+            spin_lock(&d->page_alloc_lock);
+            list_ent = d->page_list.next;
+            for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
+            {
+                mfn = page_to_mfn(list_entry(
+                    list_ent, struct page_info, list));
+                if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
+                                          i, &mfn, 1) )
+                {
+                    ret = -EFAULT;
+                    break;
+                }
+                list_ent = mfn_to_page(mfn)->list.next;
+            }
+            spin_unlock(&d->page_alloc_lock);
+
+            domctl->u.getmemlist.num_pfns = i;
+            copy_to_guest(u_domctl, domctl, 1);
+
+            put_domain(d);
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_hypercall_init:
+    {
+        struct domain *d = find_domain_by_id(domctl->domain);
+        unsigned long gmfn = domctl->u.hypercall_init.gmfn;
+        unsigned long mfn;
+        void *hypercall_page;
+
+        ret = -ESRCH;
+        if ( unlikely(d == NULL) )
+            break;
+
+        mfn = gmfn_to_mfn(d, gmfn);
+
+        ret = -EACCES;
+        if ( !mfn_valid(mfn) ||
+             !get_page_and_type(mfn_to_page(mfn), d, PGT_writable_page) )
+        {
+            put_domain(d);
+            break;
+        }
+
+        ret = 0;
+
+        hypercall_page = map_domain_page(mfn);
+        hypercall_page_initialise(d, hypercall_page);
+        unmap_domain_page(hypercall_page);
+
+        put_page_and_type(mfn_to_page(mfn));
+
+        put_domain(d);
+    }
+    break;
+
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    return ret;
+}
+
+void arch_getdomaininfo_ctxt(
+    struct vcpu *v, struct vcpu_guest_context *c)
+{
+    memcpy(c, &v->arch.guest_context, sizeof(*c));
+
+    if ( hvm_guest(v) )
+    {
+        hvm_store_cpu_guest_regs(v, &c->user_regs, c->ctrlreg);
+    }
+    else
+    {
+        /* IOPL privileges are virtualised: merge back into returned eflags. */
+        BUG_ON((c->user_regs.eflags & EF_IOPL) != 0);
+        c->user_regs.eflags |= v->arch.iopl << 12;
+    }
+
+    c->flags = 0;
+    if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) )
+        c->flags |= VGCF_I387_VALID;
+    if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) )
+        c->flags |= VGCF_IN_KERNEL;
+    if ( hvm_guest(v) )
+        c->flags |= VGCF_HVM_GUEST;
+
+    c->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table));
+
+    c->vm_assist = v->domain->vm_assist;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/platform_hypercall.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/platform_hypercall.c Sun Aug 27 10:24:41 2006 -0600
@@ -0,0 +1,159 @@
+/******************************************************************************
+ * platform_hypercall.c
+ * 
+ * Hardware platform operations. Intended for use by domain-0 kernel.
+ * 
+ * Copyright (c) 2002-2006, K Fraser
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
+#include <xen/domain.h>
+#include <xen/event.h>
+#include <xen/domain_page.h>
+#include <xen/trace.h>
+#include <xen/console.h>
+#include <xen/iocap.h>
+#include <xen/guest_access.h>
+#include <asm/current.h>
+#include <public/platform.h>
+#include <asm/mtrr.h>
+#include "cpu/mtrr/mtrr.h"
+
+long do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
+{
+    long ret = 0;
+    struct xen_platform_op curop, *op = &curop;
+    static DEFINE_SPINLOCK(xenpf_lock);
+
+    if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+
+    if ( copy_from_guest(op, u_xenpf_op, 1) )
+        return -EFAULT;
+
+    if ( op->interface_version != XENPF_INTERFACE_VERSION )
+        return -EACCES;
+
+    spin_lock(&xenpf_lock);
+
+    switch ( op->cmd )
+    {
+    case XENPF_settime:
+    {
+        do_settime(op->u.settime.secs, 
+                   op->u.settime.nsecs, 
+                   op->u.settime.system_time);
+        ret = 0;
+    }
+    break;
+
+    case XENPF_add_memtype:
+    {
+        ret = mtrr_add_page(
+            op->u.add_memtype.mfn,
+            op->u.add_memtype.nr_mfns,
+            op->u.add_memtype.type,
+            1);
+        if ( ret > 0 )
+        {
+            op->u.add_memtype.handle = 0;
+            op->u.add_memtype.reg    = ret;
+            (void)copy_to_guest(u_xenpf_op, op, 1);
+            ret = 0;
+        }
+    }
+    break;
+
+    case XENPF_del_memtype:
+    {
+        if (op->u.del_memtype.handle == 0
+            /* mtrr/main.c otherwise does a lookup */
+            && (int)op->u.del_memtype.reg >= 0)
+        {
+            ret = mtrr_del_page(op->u.del_memtype.reg, 0, 0);
+            if (ret > 0)
+                ret = 0;
+        }
+        else
+            ret = -EINVAL;
+    }
+    break;
+
+    case XENPF_read_memtype:
+    {
+        unsigned long mfn;
+        unsigned int  nr_mfns;
+        mtrr_type     type;
+
+        ret = -EINVAL;
+        if ( op->u.read_memtype.reg < num_var_ranges )
+        {
+            mtrr_if->get(op->u.read_memtype.reg, &mfn, &nr_mfns, &type);
+            op->u.read_memtype.mfn     = mfn;
+            op->u.read_memtype.nr_mfns = nr_mfns;
+            op->u.read_memtype.type    = type;
+            (void)copy_to_guest(u_xenpf_op, op, 1);
+            ret = 0;
+        }
+    }
+    break;
+
+    case XENPF_microcode_update:
+    {
+        extern int microcode_update(void *buf, unsigned long len);
+        ret = microcode_update(op->u.microcode.data.p,
+                               op->u.microcode.length);
+    }
+    break;
+
+    case XENPF_platform_quirk:
+    {
+        extern int opt_noirqbalance;
+        int quirk_id = op->u.platform_quirk.quirk_id;
+        switch ( quirk_id )
+        {
+        case QUIRK_NOIRQBALANCING:
+            printk("Platform quirk -- Disabling IRQ balancing/affinity.\n");
+            opt_noirqbalance = 1;
+            setup_ioapic_dest();
+            break;
+        case QUIRK_IOAPIC_BAD_REGSEL:
+        case QUIRK_IOAPIC_GOOD_REGSEL:
+#ifndef sis_apic_bug
+            sis_apic_bug = (quirk_id == QUIRK_IOAPIC_BAD_REGSEL);
+            DPRINTK("Domain 0 says that IO-APIC REGSEL is %s\n",
+                    sis_apic_bug ? "bad" : "good");
+#else
+            BUG_ON(sis_apic_bug != (quirk_id == QUIRK_IOAPIC_BAD_REGSEL));
+#endif
+            break;
+        default:
+            ret = -EINVAL;
+            break;
+        }
+    }
+    break;
+
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    spin_unlock(&xenpf_lock);
+
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/arch/x86/sysctl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/sysctl.c     Sun Aug 27 10:24:41 2006 -0600
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * Arch-specific sysctl.c
+ * 
+ * System management operations. For use by node control stack.
+ * 
+ * Copyright (c) 2002-2006, K Fraser
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/guest_access.h>
+#include <public/sysctl.h>
+#include <xen/sched.h>
+#include <xen/event.h>
+#include <xen/domain_page.h>
+#include <asm/msr.h>
+#include <xen/trace.h>
+#include <xen/console.h>
+#include <xen/iocap.h>
+#include <asm/shadow.h>
+#include <asm/irq.h>
+#include <asm/hvm/hvm.h>
+#include <asm/hvm/support.h>
+#include <asm/processor.h>
+
+long arch_do_sysctl(
+    struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
+{
+    long ret = 0;
+
+    switch ( sysctl->cmd )
+    {
+
+    case XEN_SYSCTL_physinfo:
+    {
+        xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
+
+        pi->threads_per_core =
+            cpus_weight(cpu_sibling_map[0]);
+        pi->cores_per_socket =
+            cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
+        pi->sockets_per_node = 
+            num_online_cpus() / cpus_weight(cpu_core_map[0]);
+
+        pi->nr_nodes         = 1;
+        pi->total_pages      = total_pages;
+        pi->free_pages       = avail_domheap_pages();
+        pi->scrub_pages      = avail_scrub_pages();
+        pi->cpu_khz          = cpu_khz;
+        memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
+        memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
+        ret = 0;
+        if ( copy_to_guest(u_sysctl, sysctl, 1) )
+            ret = -EFAULT;
+    }
+    break;
+    
+
+    default:
+        ret = -ENOSYS;
+        break;
+    }
+
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/domctl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/common/domctl.c       Sun Aug 27 10:24:41 2006 -0600
@@ -0,0 +1,681 @@
+/******************************************************************************
+ * domctl.c
+ * 
+ * Domain management operations. For use by node control stack.
+ * 
+ * Copyright (c) 2002-2006, K A Fraser
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
+#include <xen/domain.h>
+#include <xen/event.h>
+#include <xen/domain_page.h>
+#include <xen/trace.h>
+#include <xen/console.h>
+#include <xen/iocap.h>
+#include <xen/guest_access.h>
+#include <asm/current.h>
+#include <public/domctl.h>
+#include <acm/acm_hooks.h>
+
+extern long arch_do_domctl(
+    struct xen_domctl *op, XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
+extern void arch_getdomaininfo_ctxt(
+    struct vcpu *, struct vcpu_guest_context *);
+
+void cpumask_to_xenctl_cpumap(
+    struct xenctl_cpumap *xenctl_cpumap, cpumask_t *cpumask)
+{
+    unsigned int guest_bytes, copy_bytes, i;
+    uint8_t zero = 0;
+
+    if ( guest_handle_is_null(xenctl_cpumap->bitmap) )
+        return;
+
+    guest_bytes = (xenctl_cpumap->nr_cpus + 7) / 8;
+    copy_bytes  = min_t(unsigned int, guest_bytes, (NR_CPUS + 7) / 8);
+
+    copy_to_guest(xenctl_cpumap->bitmap,
+                  (uint8_t *)cpus_addr(*cpumask),
+                  copy_bytes);
+
+    for ( i = copy_bytes; i < guest_bytes; i++ )
+        copy_to_guest_offset(xenctl_cpumap->bitmap, i, &zero, 1);
+}
+
+void xenctl_cpumap_to_cpumask(
+    cpumask_t *cpumask, struct xenctl_cpumap *xenctl_cpumap)
+{
+    unsigned int guest_bytes, copy_bytes;
+
+    guest_bytes = (xenctl_cpumap->nr_cpus + 7) / 8;
+    copy_bytes  = min_t(unsigned int, guest_bytes, (NR_CPUS + 7) / 8);
+
+    cpus_clear(*cpumask);
+
+    if ( guest_handle_is_null(xenctl_cpumap->bitmap) )
+        return;
+
+    copy_from_guest((uint8_t *)cpus_addr(*cpumask),
+                    xenctl_cpumap->bitmap,
+                    copy_bytes);
+}
+
+static inline int is_free_domid(domid_t dom)
+{
+    struct domain *d;
+
+    if ( dom >= DOMID_FIRST_RESERVED )
+        return 0;
+
+    if ( (d = find_domain_by_id(dom)) == NULL )
+        return 1;
+
+    put_domain(d);
+    return 0;
+}
+
+void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info)
+{
+    struct vcpu   *v;
+    u64 cpu_time = 0;
+    int flags = DOMFLAGS_BLOCKED;
+    struct vcpu_runstate_info runstate;
+    
+    info->domain = d->domain_id;
+    info->nr_online_vcpus = 0;
+    
+    /* 
+     * - domain is marked as blocked only if all its vcpus are blocked
+     * - domain is marked as running if any of its vcpus is running
+     */
+    for_each_vcpu ( d, v ) {
+        vcpu_runstate_get(v, &runstate);
+        cpu_time += runstate.time[RUNSTATE_running];
+        info->max_vcpu_id = v->vcpu_id;
+        if ( !test_bit(_VCPUF_down, &v->vcpu_flags) )
+        {
+            if ( !(v->vcpu_flags & VCPUF_blocked) )
+                flags &= ~DOMFLAGS_BLOCKED;
+            if ( v->vcpu_flags & VCPUF_running )
+                flags |= DOMFLAGS_RUNNING;
+            info->nr_online_vcpus++;
+        }
+    }
+    
+    info->cpu_time = cpu_time;
+    
+    info->flags = flags |
+        ((d->domain_flags & DOMF_dying)      ? DOMFLAGS_DYING    : 0) |
+        ((d->domain_flags & DOMF_shutdown)   ? DOMFLAGS_SHUTDOWN : 0) |
+        ((d->domain_flags & DOMF_ctrl_pause) ? DOMFLAGS_PAUSED   : 0) |
+        d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
+
+    if (d->ssid != NULL)
+        info->ssidref = ((struct acm_ssid_domain *)d->ssid)->ssidref;
+    else    
+        info->ssidref = ACM_DEFAULT_SSID;
+    
+    info->tot_pages         = d->tot_pages;
+    info->max_pages         = d->max_pages;
+    info->shared_info_frame = __pa(d->shared_info) >> PAGE_SHIFT;
+
+    memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
+}
+
+static unsigned int default_vcpu0_location(void)
+{
+    struct domain *d;
+    struct vcpu   *v;
+    unsigned int   i, cpu, cnt[NR_CPUS] = { 0 };
+    cpumask_t      cpu_exclude_map;
+
+    /* Do an initial CPU placement. Pick the least-populated CPU. */
+    read_lock(&domlist_lock);
+    for_each_domain ( d )
+        for_each_vcpu ( d, v )
+        if ( !test_bit(_VCPUF_down, &v->vcpu_flags) )
+            cnt[v->processor]++;
+    read_unlock(&domlist_lock);
+
+    /*
+     * If we're on a HT system, we only auto-allocate to a non-primary HT. We 
+     * favour high numbered CPUs in the event of a tie.
+     */
+    cpu = first_cpu(cpu_sibling_map[0]);
+    if ( cpus_weight(cpu_sibling_map[0]) > 1 )
+        cpu = next_cpu(cpu, cpu_sibling_map[0]);
+    cpu_exclude_map = cpu_sibling_map[0];
+    for_each_online_cpu ( i )
+    {
+        if ( cpu_isset(i, cpu_exclude_map) )
+            continue;
+        if ( (i == first_cpu(cpu_sibling_map[i])) &&
+             (cpus_weight(cpu_sibling_map[i]) > 1) )
+            continue;
+        cpus_or(cpu_exclude_map, cpu_exclude_map, cpu_sibling_map[i]);
+        if ( cnt[i] <= cnt[cpu] )
+            cpu = i;
+    }
+
+    return cpu;
+}
+
+long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
+{
+    long ret = 0;
+    struct xen_domctl curop, *op = &curop;
+    void *ssid = NULL; /* save security ptr between pre and post/fail hooks */
+    static DEFINE_SPINLOCK(domctl_lock);
+
+    if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+
+    if ( copy_from_guest(op, u_domctl, 1) )
+        return -EFAULT;
+
+    if ( op->interface_version != XEN_DOMCTL_INTERFACE_VERSION )
+        return -EACCES;
+
+    if ( acm_pre_domctl(op, &ssid) )
+        return -EPERM;
+
+    spin_lock(&domctl_lock);
+
+    switch ( op->cmd )
+    {
+
+    case XEN_DOMCTL_setvcpucontext:
+    {
+        struct domain *d = find_domain_by_id(op->domain);
+        ret = -ESRCH;
+        if ( d != NULL )
+        {
+            ret = set_info_guest(d, &op->u.vcpucontext);
+            put_domain(d);
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_pausedomain:
+    {
+        struct domain *d = find_domain_by_id(op->domain);
+        ret = -ESRCH;
+        if ( d != NULL )
+        {
+            ret = -EINVAL;
+            if ( d != current->domain )
+            {
+                domain_pause_by_systemcontroller(d);
+                ret = 0;
+            }
+            put_domain(d);
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_unpausedomain:
+    {
+        struct domain *d = find_domain_by_id(op->domain);
+        ret = -ESRCH;
+        if ( d != NULL )
+        {
+            ret = -EINVAL;
+            if ( (d != current->domain) && (d->vcpu[0] != NULL) &&
+                 test_bit(_VCPUF_initialised, &d->vcpu[0]->vcpu_flags) )
+            {
+                domain_unpause_by_systemcontroller(d);
+                ret = 0;
+            }
+            put_domain(d);
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_createdomain:
+    {
+        struct domain *d;
+        domid_t        dom;
+        static domid_t rover = 0;
+
+        /*
+         * Running the domain 0 kernel in ring 0 is not compatible
+         * with multiple guests.
+         */
+        if ( supervisor_mode_kernel )
+            return -EINVAL;
+
+        dom = op->domain;
+        if ( (dom > 0) && (dom < DOMID_FIRST_RESERVED) )
+        {
+            ret = -EINVAL;
+            if ( !is_free_domid(dom) )
+                break;
+        }
+        else
+        {
+            for ( dom = rover + 1; dom != rover; dom++ )
+            {
+                if ( dom == DOMID_FIRST_RESERVED )
+                    dom = 0;
+                if ( is_free_domid(dom) )
+                    break;
+            }
+
+            ret = -ENOMEM;
+            if ( dom == rover )
+                break;
+
+            rover = dom;
+        }
+
+        ret = -ENOMEM;
+        if ( (d = domain_create(dom)) == NULL )
+            break;
+
+        memcpy(d->handle, op->u.createdomain.handle,
+               sizeof(xen_domain_handle_t));
+
+        ret = 0;
+
+        op->domain = d->domain_id;
+        if ( copy_to_guest(u_domctl, op, 1) )
+            ret = -EFAULT;
+    }
+    break;
+
+    case XEN_DOMCTL_max_vcpus:
+    {
+        struct domain *d;
+        unsigned int i, max = op->u.max_vcpus.max, cpu;
+
+        ret = -EINVAL;
+        if ( max > MAX_VIRT_CPUS )
+            break;
+
+        ret = -ESRCH;
+        if ( (d = find_domain_by_id(op->domain)) == NULL )
+            break;
+
+        /* Needed, for example, to ensure writable p.t. state is synced. */
+        domain_pause(d);
+
+        /* We cannot reduce maximum VCPUs. */
+        ret = -EINVAL;
+        if ( (max != MAX_VIRT_CPUS) && (d->vcpu[max] != NULL) )
+            goto maxvcpu_out;
+
+        ret = -ENOMEM;
+        for ( i = 0; i < max; i++ )
+        {
+            if ( d->vcpu[i] != NULL )
+                continue;
+
+            cpu = (i == 0) ?
+                default_vcpu0_location() :
+                (d->vcpu[i-1]->processor + 1) % num_online_cpus();
+
+            if ( alloc_vcpu(d, i, cpu) == NULL )
+                goto maxvcpu_out;
+        }
+
+        ret = 0;
+
+    maxvcpu_out:
+        domain_unpause(d);
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_destroydomain:
+    {
+        struct domain *d = find_domain_by_id(op->domain);
+        ret = -ESRCH;
+        if ( d != NULL )
+        {
+            ret = -EINVAL;
+            if ( d != current->domain )
+            {
+                domain_kill(d);
+                ret = 0;
+            }
+            put_domain(d);
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_setvcpuaffinity:
+    case XEN_DOMCTL_getvcpuaffinity:
+    {
+        domid_t dom = op->domain;
+        struct domain *d = find_domain_by_id(dom);
+        struct vcpu *v;
+        cpumask_t new_affinity;
+
+        if ( d == NULL )
+        {
+            ret = -ESRCH;            
+            break;
+        }
+        
+        if ( (op->u.vcpuaffinity.vcpu >= MAX_VIRT_CPUS) ||
+             !d->vcpu[op->u.vcpuaffinity.vcpu] )
+        {
+            ret = -EINVAL;
+            put_domain(d);
+            break;
+        }
+
+        v = d->vcpu[op->u.vcpuaffinity.vcpu];
+        if ( v == NULL )
+        {
+            ret = -ESRCH;
+            put_domain(d);
+            break;
+        }
+
+        if ( op->cmd == XEN_DOMCTL_setvcpuaffinity )
+        {
+            if ( v == current )
+            {
+                ret = -EINVAL;
+                put_domain(d);
+                break;
+            }
+
+            xenctl_cpumap_to_cpumask(
+                &new_affinity, &op->u.vcpuaffinity.cpumap);
+            ret = vcpu_set_affinity(v, &new_affinity);
+        }
+        else
+        {
+            cpumask_to_xenctl_cpumap(
+                &op->u.vcpuaffinity.cpumap, &v->cpu_affinity);
+        }
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_scheduler_op:
+    {
+        struct domain *d;
+
+        ret = -ESRCH;
+        if ( (d = find_domain_by_id(op->domain)) == NULL )
+            break;
+
+        ret = sched_adjust(d, &op->u.scheduler_op);
+        if ( copy_to_guest(u_domctl, op, 1) )
+            ret = -EFAULT;
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_getdomaininfo:
+    { 
+        struct domain *d;
+        domid_t dom;
+
+        dom = op->domain;
+        if ( dom == DOMID_SELF )
+            dom = current->domain->domain_id;
+
+        read_lock(&domlist_lock);
+
+        for_each_domain ( d )
+        {
+            if ( d->domain_id >= dom )
+                break;
+        }
+
+        if ( (d == NULL) || !get_domain(d) )
+        {
+            read_unlock(&domlist_lock);
+            ret = -ESRCH;
+            break;
+        }
+
+        read_unlock(&domlist_lock);
+
+        getdomaininfo(d, &op->u.getdomaininfo);
+
+        op->domain = op->u.getdomaininfo.domain;
+        if ( copy_to_guest(u_domctl, op, 1) )
+            ret = -EFAULT;
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_getvcpucontext:
+    { 
+        struct vcpu_guest_context *c;
+        struct domain             *d;
+        struct vcpu               *v;
+
+        ret = -ESRCH;
+        if ( (d = find_domain_by_id(op->domain)) == NULL )
+            break;
+
+        ret = -EINVAL;
+        if ( op->u.vcpucontext.vcpu >= MAX_VIRT_CPUS )
+            goto getvcpucontext_out;
+
+        ret = -ESRCH;
+        if ( (v = d->vcpu[op->u.vcpucontext.vcpu]) == NULL )
+            goto getvcpucontext_out;
+
+        ret = -ENODATA;
+        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
+            goto getvcpucontext_out;
+
+        ret = -ENOMEM;
+        if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
+            goto getvcpucontext_out;
+
+        if ( v != current )
+            vcpu_pause(v);
+
+        arch_getdomaininfo_ctxt(v,c);
+        ret = 0;
+
+        if ( v != current )
+            vcpu_unpause(v);
+
+        if ( copy_to_guest(op->u.vcpucontext.ctxt, c, 1) )
+            ret = -EFAULT;
+
+        xfree(c);
+
+        if ( copy_to_guest(u_domctl, op, 1) )
+            ret = -EFAULT;
+
+    getvcpucontext_out:
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_getvcpuinfo:
+    { 
+        struct domain *d;
+        struct vcpu   *v;
+        struct vcpu_runstate_info runstate;
+
+        ret = -ESRCH;
+        if ( (d = find_domain_by_id(op->domain)) == NULL )
+            break;
+
+        ret = -EINVAL;
+        if ( op->u.getvcpuinfo.vcpu >= MAX_VIRT_CPUS )
+            goto getvcpuinfo_out;
+
+        ret = -ESRCH;
+        if ( (v = d->vcpu[op->u.getvcpuinfo.vcpu]) == NULL )
+            goto getvcpuinfo_out;
+
+        vcpu_runstate_get(v, &runstate);
+
+        op->u.getvcpuinfo.online   = !test_bit(_VCPUF_down, &v->vcpu_flags);
+        op->u.getvcpuinfo.blocked  = test_bit(_VCPUF_blocked, &v->vcpu_flags);
+        op->u.getvcpuinfo.running  = test_bit(_VCPUF_running, &v->vcpu_flags);
+        op->u.getvcpuinfo.cpu_time = runstate.time[RUNSTATE_running];
+        op->u.getvcpuinfo.cpu      = v->processor;
+        ret = 0;
+
+        if ( copy_to_guest(u_domctl, op, 1) )
+            ret = -EFAULT;
+
+    getvcpuinfo_out:
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_max_mem:
+    {
+        struct domain *d;
+        unsigned long new_max;
+
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d == NULL )
+            break;
+
+        ret = -EINVAL;
+        new_max = op->u.max_mem.max_memkb >> (PAGE_SHIFT-10);
+
+        spin_lock(&d->page_alloc_lock);
+        if ( new_max >= d->tot_pages )
+        {
+            d->max_pages = new_max;
+            ret = 0;
+        }
+        spin_unlock(&d->page_alloc_lock);
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_setdomainhandle:
+    {
+        struct domain *d;
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d != NULL )
+        {
+            memcpy(d->handle, op->u.setdomainhandle.handle,
+                   sizeof(xen_domain_handle_t));
+            put_domain(d);
+            ret = 0;
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_setdebugging:
+    {
+        struct domain *d;
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d != NULL )
+        {
+            if ( op->u.setdebugging.enable )
+                set_bit(_DOMF_debugging, &d->domain_flags);
+            else
+                clear_bit(_DOMF_debugging, &d->domain_flags);
+            put_domain(d);
+            ret = 0;
+        }
+    }
+    break;
+
+    case XEN_DOMCTL_irq_permission:
+    {
+        struct domain *d;
+        unsigned int pirq = op->u.irq_permission.pirq;
+
+        ret = -EINVAL;
+        if ( pirq >= NR_IRQS )
+            break;
+
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d == NULL )
+            break;
+
+        if ( op->u.irq_permission.allow_access )
+            ret = irq_permit_access(d, pirq);
+        else
+            ret = irq_deny_access(d, pirq);
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_iomem_permission:
+    {
+        struct domain *d;
+        unsigned long mfn = op->u.iomem_permission.first_mfn;
+        unsigned long nr_mfns = op->u.iomem_permission.nr_mfns;
+
+        ret = -EINVAL;
+        if ( (mfn + nr_mfns - 1) < mfn ) /* wrap? */
+            break;
+
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d == NULL )
+            break;
+
+        if ( op->u.iomem_permission.allow_access )
+            ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1);
+        else
+            ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1);
+
+        put_domain(d);
+    }
+    break;
+
+    case XEN_DOMCTL_settimeoffset:
+    {
+        struct domain *d;
+
+        ret = -ESRCH;
+        d = find_domain_by_id(op->domain);
+        if ( d != NULL )
+        {
+            d->time_offset_seconds = op->u.settimeoffset.time_offset_seconds;
+            put_domain(d);
+            ret = 0;
+        }
+    }
+    break;
+
+    default:
+        ret = arch_do_domctl(op, u_domctl);
+        break;
+    }
+
+    spin_unlock(&domctl_lock);
+
+    if ( ret == 0 )
+        acm_post_domctl(op, &ssid);
+    else
+        acm_fail_domctl(op, &ssid);
+
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 3e0685ecfe64 -r c4ea8d4d2ae1 xen/common/sysctl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/common/sysctl.c       Sun Aug 27 10:24:41 2006 -0600
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * sysctl.c
+ * 
+ * System management operations. For use by node control stack.
+ * 
+ * Copyright (c) 2002-2006, K Fraser
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
+#include <xen/domain.h>
+#include <xen/event.h>
+#include <xen/domain_page.h>
+#include <xen/trace.h>
+#include <xen/console.h>
+#include <xen/iocap.h>
+#include <xen/guest_access.h>
+#include <asm/current.h>
+#include <public/sysctl.h>
+
+extern long arch_do_sysctl(
+    struct xen_sysctl *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
+extern void getdomaininfo(
+    struct domain *d, struct xen_domctl_getdomaininfo *info);
+
+long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
+{
+    long ret = 0;
+    struct xen_sysctl curop, *op = &curop;
+    static DEFINE_SPINLOCK(sysctl_lock);
+
+    if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+
+    if ( copy_from_guest(op, u_sysctl, 1) )
+        return -EFAULT;
+
+    if ( op->interface_version != XEN_SYSCTL_INTERFACE_VERSION )
+        return -EACCES;
+
+    spin_lock(&sysctl_lock);
+
+    switch ( op->cmd )
+    {
+    case XEN_SYSCTL_readconsole:
+    {
+        ret = read_console_ring(
+            guest_handle_cast(op->u.readconsole.buffer, char),
+            &op->u.readconsole.count,
+            op->u.readconsole.clear);
+        if ( copy_to_guest(u_sysctl, op, 1) )
+            ret = -EFAULT;
+    }
+    break;
+
+    case XEN_SYSCTL_tbuf_op:
+    {
+        ret = tb_control(&op->u.tbuf_op);
+        if ( copy_to_guest(u_sysctl, op, 1) )
+            ret = -EFAULT;
+    }
+    break;
+    
+    case XEN_SYSCTL_sched_id:
+    {
+        op->u.sched_id.sched_id = sched_id();
+        if ( copy_to_guest(u_sysctl, op, 1) )
+            ret = -EFAULT;
+        else
+            ret = 0;
+    }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.