Mailing List Archive

[xen-unstable] merge with xen-unstable.hg
# HG changeset patch
# User Alex Williamson <alex.williamson@hp.com>
# Date 1185545716 21600
# Node ID 4492a0285bae734ee18f6acbb6b3f9c80f153be7
# Parent 37833b33ae779151a9d88edd15b93d0d3f56d0fc
# Parent 5682f899c7ae7fa945085aaded75cd1220fd8d17
merge with xen-unstable.hg
---
xen/arch/x86/mm/hap/support.c | 334 --
xen/include/xen/shadow.h | 23
.hgignore | 7
Config.mk | 8
buildconfigs/enable-xen-config | 4
buildconfigs/mk.linux-2.6 | 14
buildconfigs/mk.linux-2.6-git | 2
buildconfigs/mk.linux-2.6-mm | 14
buildconfigs/mk.linux-2.6-rc | 14
buildconfigs/mk.linux-2.6-tip | 14
docs/man/xm.pod.1 | 167 -
docs/xen-api/xenapi-datamodel-graph.dot | 4
docs/xen-api/xenapi-datamodel.tex | 1375 ++++++++--
tools/examples/vtpm-common.sh | 56
tools/firmware/hvmloader/acpi/dsdt.asl | 21
tools/firmware/hvmloader/acpi/dsdt.c | 25
tools/firmware/hvmloader/config.h | 2
tools/firmware/hvmloader/hvmloader.c | 12
tools/firmware/rombios/rombios.c | 48
tools/ioemu/hw/cirrus_vga.c | 2
tools/ioemu/hw/ide.c | 3
tools/ioemu/hw/rtl8139.c | 11
tools/ioemu/keymaps.c | 16
tools/ioemu/target-i386-dm/exec-dm.c | 6
tools/ioemu/target-i386-dm/helper2.c | 43
tools/ioemu/vl.c | 38
tools/ioemu/vl.h | 1
tools/ioemu/vnc.c | 92
tools/ioemu/xenstore.c | 98
tools/libxc/xc_domain.c | 21
tools/libxc/xc_linux.c | 2
tools/libxc/xenctrl.h | 14
tools/libxen/include/xen/api/xen_acmpolicy.h | 117
tools/libxen/include/xen/api/xen_vdi.h | 13
tools/libxen/include/xen/api/xen_vif.h | 14
tools/libxen/include/xen/api/xen_vm.h | 14
tools/libxen/include/xen/api/xen_xspolicy.h | 271 +
tools/libxen/include/xen/api/xen_xspolicy_decl.h | 31
tools/libxen/src/xen_acmpolicy.c | 234 +
tools/libxen/src/xen_vdi.c | 39
tools/libxen/src/xen_vif.c | 39
tools/libxen/src/xen_vm.c | 45
tools/libxen/src/xen_xspolicy.c | 327 ++
tools/python/xen/lowlevel/acm/acm.c | 9
tools/python/xen/util/acmpolicy.py | 98
tools/python/xen/util/security.py | 146 -
tools/python/xen/xend/XendAPI.py | 48
tools/python/xen/xend/XendCheckpoint.py | 6
tools/python/xen/xend/XendConfig.py | 28
tools/python/xen/xend/XendDevices.py | 3
tools/python/xen/xend/XendDomain.py | 57
tools/python/xen/xend/XendDomainInfo.py | 52
tools/python/xen/xend/XendPIF.py | 10
tools/python/xen/xend/XendVDI.py | 1
tools/python/xen/xend/XendXSPolicyAdmin.py | 21
tools/python/xen/xend/balloon.py | 8
tools/python/xen/xend/image.py | 42
tools/python/xen/xend/server/SrvServer.py | 3
tools/python/xen/xend/server/netif.py | 43
tools/python/xen/xend/server/tpmif.py | 5
tools/python/xen/xm/activatepolicy.py | 86
tools/python/xen/xm/addlabel.py | 176 +
tools/python/xen/xm/cfgbootpolicy.py | 77
tools/python/xen/xm/create.dtd | 10
tools/python/xen/xm/create.py | 25
tools/python/xen/xm/getlabel.py | 71
tools/python/xen/xm/getpolicy.py | 94
tools/python/xen/xm/labels.py | 37
tools/python/xen/xm/loadpolicy.py | 32
tools/python/xen/xm/main.py | 115
tools/python/xen/xm/makepolicy.py | 14
tools/python/xen/xm/resources.py | 33
tools/python/xen/xm/rmlabel.py | 101
tools/python/xen/xm/setpolicy.py | 117
tools/python/xen/xm/xenapi_create.py | 68
tools/security/policies/security_policy.xsd | 7
tools/vtpm_manager/util/hashtable_itr.c | 8
tools/xcutils/xc_save.c | 29
tools/xenfb/vncfb.c | 110
tools/xenstore/talloc.c | 18
tools/xenstore/xenstored_core.c | 144 -
tools/xenstore/xenstored_domain.c | 14
tools/xenstore/xenstored_watch.c | 5
tools/xenstore/xsls.c | 37
tools/xm-test/lib/XmTestLib/XenAPIDomain.py | 4
tools/xm-test/lib/XmTestLib/acm.py | 52
tools/xm-test/tests/security-acm/01_security-acm_basic.py | 24
tools/xm-test/tests/security-acm/07_security-acm_pol_update.py | 303 ++
tools/xm-test/tests/security-acm/08_security-acm_xapi.py | 354 ++
tools/xm-test/tests/security-acm/09_security-acm_pol_update.py | 427 +++
tools/xm-test/tests/security-acm/Makefile.am | 5
tools/xm-test/tests/security-acm/xm-test-new-security_policy.xml | 97
tools/xm-test/tests/vtpm/01_vtpm-list_pos.py | 8
tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py | 9
tools/xm-test/tests/vtpm/03_vtpm-susp_res.py | 16
tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py | 15
tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py | 15
tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py | 20
tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py | 19
tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py | 19
tools/xm-test/tests/vtpm/vtpm_utils.py | 14
unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h | 9
unmodified_drivers/linux-2.6/netfront/Kbuild | 1
xen/Makefile | 16
xen/acm/acm_chinesewall_hooks.c | 190 -
xen/acm/acm_core.c | 29
xen/acm/acm_policy.c | 309 +-
xen/acm/acm_simple_type_enforcement_hooks.c | 397 +-
xen/arch/ia64/linux-xen/perfmon.c | 2
xen/arch/ia64/xen/oprofile/perfmon.c | 11
xen/arch/powerpc/Rules.mk | 4
xen/arch/powerpc/exceptions.h | 3
xen/arch/powerpc/mpic_init.c | 4
xen/arch/powerpc/of-devtree.c | 2
xen/arch/powerpc/of-devwalk.c | 8
xen/arch/powerpc/of_handler/ofh.c | 24
xen/arch/powerpc/of_handler/papr.S | 2
xen/arch/powerpc/ofd_fixup.c | 13
xen/arch/powerpc/papr/Makefile | 1
xen/arch/powerpc/papr/h_perfmon.c | 158 +
xen/arch/powerpc/powerpc64/domain.c | 46
xen/arch/powerpc/powerpc64/exceptions.S | 25
xen/arch/powerpc/sysctl.c | 1
xen/arch/x86/acpi/Makefile | 1
xen/arch/x86/acpi/boot.c | 93
xen/arch/x86/acpi/power.c | 282 ++
xen/arch/x86/acpi/suspend.c | 73
xen/arch/x86/acpi/wakeup_prot.S | 267 +
xen/arch/x86/apic.c | 2
xen/arch/x86/boot/Makefile | 3
xen/arch/x86/boot/head.S | 2
xen/arch/x86/boot/wakeup.S | 212 +
xen/arch/x86/cpu/common.c | 11
xen/arch/x86/cpu/intel_cacheinfo.c | 4
xen/arch/x86/crash.c | 4
xen/arch/x86/dmi_scan.c | 1
xen/arch/x86/domain.c | 72
xen/arch/x86/domain_build.c | 3
xen/arch/x86/domctl.c | 40
xen/arch/x86/e820.c | 71
xen/arch/x86/hvm/hvm.c | 6
xen/arch/x86/hvm/svm/svm.c | 20
xen/arch/x86/hvm/svm/vmcb.c | 10
xen/arch/x86/hvm/vlapic.c | 9
xen/arch/x86/hvm/vmx/vmcs.c | 219 +
xen/arch/x86/hvm/vmx/vmx.c | 109
xen/arch/x86/hvm/vpt.c | 8
xen/arch/x86/i8259.c | 6
xen/arch/x86/io_apic.c | 3
xen/arch/x86/irq.c | 33
xen/arch/x86/machine_kexec.c | 4
xen/arch/x86/mm.c | 23
xen/arch/x86/mm/hap/Makefile | 10
xen/arch/x86/mm/hap/guest_walk.c | 181 +
xen/arch/x86/mm/hap/hap.c | 383 +-
xen/arch/x86/mm/hap/private.h | 55
xen/arch/x86/mm/shadow/multi.c | 46
xen/arch/x86/nmi.c | 2
xen/arch/x86/oprofile/nmi_int.c | 83
xen/arch/x86/platform_hypercall.c | 5
xen/arch/x86/setup.c | 4
xen/arch/x86/shutdown.c | 2
xen/arch/x86/smp.c | 2
xen/arch/x86/smpboot.c | 340 ++
xen/arch/x86/x86_32/traps.c | 2
xen/arch/x86/x86_64/mm.c | 3
xen/arch/x86/x86_64/platform_hypercall.c | 3
xen/arch/x86/x86_64/traps.c | 2
xen/common/compat/kernel.c | 1
xen/common/domctl.c | 2
xen/common/grant_table.c | 13
xen/common/kernel.c | 4
xen/common/keyhandler.c | 1
xen/common/memory.c | 8
xen/common/page_alloc.c | 60
xen/common/sysctl.c | 14
xen/common/xenoprof.c | 58
xen/drivers/acpi/tables.c | 3
xen/drivers/char/ns16550.c | 4
xen/drivers/char/serial.c | 4
xen/include/acm/acm_core.h | 7
xen/include/acm/acm_hooks.h | 62
xen/include/asm-ia64/xenoprof.h | 2
xen/include/asm-powerpc/domain.h | 21
xen/include/asm-powerpc/numa.h | 1
xen/include/asm-powerpc/papr.h | 1
xen/include/asm-powerpc/processor.h | 138 -
xen/include/asm-powerpc/reg_defs.h | 27
xen/include/asm-powerpc/xenoprof.h | 76
xen/include/asm-x86/acpi.h | 20
xen/include/asm-x86/config.h | 12
xen/include/asm-x86/desc.h | 5
xen/include/asm-x86/domain.h | 10
xen/include/asm-x86/hap.h | 3
xen/include/asm-x86/hvm/hvm.h | 21
xen/include/asm-x86/hvm/support.h | 1
xen/include/asm-x86/hvm/vmx/vmcs.h | 9
xen/include/asm-x86/page.h | 15
xen/include/asm-x86/processor.h | 18
xen/include/asm-x86/smp.h | 15
xen/include/asm-x86/system.h | 2
xen/include/asm-x86/xenoprof.h | 4
xen/include/public/acm.h | 5
xen/include/public/platform.h | 12
xen/include/public/sysctl.h | 13
xen/include/xen/acpi.h | 1
xen/include/xen/cpumask.h | 2
xen/include/xen/irq.h | 10
xen/include/xen/mm.h | 5
xen/include/xen/paging.h | 26
xen/include/xen/xenoprof.h | 2
211 files changed, 9151 insertions(+), 2580 deletions(-)

diff -r 37833b33ae77 -r 4492a0285bae .hgignore
--- a/.hgignore Thu Jul 26 14:35:01 2007 -0600
+++ b/.hgignore Fri Jul 27 08:15:16 2007 -0600
@@ -62,14 +62,11 @@
^extras/mini-os/h/xen-public$
^extras/mini-os/mini-os.*$
^install/.*$
-^linux-[^/]*-native/.*$
-^linux-[^/]*-xen/.*$
-^linux-[^/]*-xen0/.*$
-^linux-[^/]*-xenU/.*$
^linux-[^/]*-paravirt/.*$
-^linux-[^/]*-mm/.*$
+^linux-2.6[^/]*/.*$
^linux-[^/]*-rc/.*$
^linux-[^/]*-tip/.*$
+^linux-[^/]*-git/.*$
^linux-[^/]*\.patch$
^mkddbxen$
^netbsd-[^/]*-tools/.*$
diff -r 37833b33ae77 -r 4492a0285bae Config.mk
--- a/Config.mk Thu Jul 26 14:35:01 2007 -0600
+++ b/Config.mk Fri Jul 27 08:15:16 2007 -0600
@@ -81,14 +81,6 @@ CFLAGS += $(foreach i, $(EXTRA_INCLUDES)
# n - Do not build the Xen ACM framework
ACM_SECURITY ?= n

-# If ACM_SECURITY = y and no boot policy file is installed,
-# then the ACM defaults to the security policy set by
-# ACM_DEFAULT_SECURITY_POLICY
-# Supported models are:
-# ACM_NULL_POLICY
-# ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY
-ACM_DEFAULT_SECURITY_POLICY ?= ACM_NULL_POLICY
-
# Optional components
XENSTAT_XENTOP ?= y
VTPM_TOOLS ?= n
diff -r 37833b33ae77 -r 4492a0285bae buildconfigs/enable-xen-config
--- a/buildconfigs/enable-xen-config Thu Jul 26 14:35:01 2007 -0600
+++ b/buildconfigs/enable-xen-config Fri Jul 27 08:15:16 2007 -0600
@@ -28,9 +28,13 @@ setopt CONFIG_PARAVIRT y
setopt CONFIG_PARAVIRT y
setopt CONFIG_XEN y
setopt CONFIG_VMI y
+setopt CONFIG_KVM y
+setopt CONFIG_KVM_INTEL y
+setopt CONFIG_KVM_AMD y
setopt CONFIG_LGUEST n
setopt CONFIG_XEN_BLKDEV_FRONTEND y
setopt CONFIG_XEN_NETDEV_FRONTEND y
setopt CONFIG_HVC_XEN y
+setopt CONFIG_NUMA n

exit 0
diff -r 37833b33ae77 -r 4492a0285bae buildconfigs/mk.linux-2.6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/buildconfigs/mk.linux-2.6 Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,14 @@
+XEN_LINUX_SOURCE ?= tarball
+LINUX_VER ?= 2.6
+
+XEN_LINUX_TARBALL_KETCHUP := y
+
+IMAGE_TARGET ?= vmlinux bzImage
+
+XEN_LINUX_ALLOW_INTERFACE_MISMATCH := y
+
+XEN_LINUX_CONFIG_UPDATE := buildconfigs/enable-xen-config
+
+EXTRAVERSION ?=
+
+include buildconfigs/mk.linux-2.6-xen
diff -r 37833b33ae77 -r 4492a0285bae buildconfigs/mk.linux-2.6-git
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/buildconfigs/mk.linux-2.6-git Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,2 @@
+LINUX_VER ?= 2.6-git
+include buildconfigs/mk.linux-2.6
diff -r 37833b33ae77 -r 4492a0285bae buildconfigs/mk.linux-2.6-mm
--- a/buildconfigs/mk.linux-2.6-mm Thu Jul 26 14:35:01 2007 -0600
+++ b/buildconfigs/mk.linux-2.6-mm Fri Jul 27 08:15:16 2007 -0600
@@ -1,14 +1,2 @@ XEN_LINUX_SOURCE ?= tarball
-XEN_LINUX_SOURCE ?= tarball
LINUX_VER ?= 2.6-mm
-
-XEN_LINUX_TARBALL_KETCHUP := y
-
-IMAGE_TARGET ?= vmlinux bzImage
-
-XEN_LINUX_ALLOW_INTERFACE_MISMATCH := y
-
-XEN_LINUX_CONFIG_UPDATE := buildconfigs/enable-xen-config
-
-EXTRAVERSION ?=
-
-include buildconfigs/mk.linux-2.6-xen
+include buildconfigs/mk.linux-2.6
diff -r 37833b33ae77 -r 4492a0285bae buildconfigs/mk.linux-2.6-rc
--- a/buildconfigs/mk.linux-2.6-rc Thu Jul 26 14:35:01 2007 -0600
+++ b/buildconfigs/mk.linux-2.6-rc Fri Jul 27 08:15:16 2007 -0600
@@ -1,14 +1,2 @@ XEN_LINUX_SOURCE ?= tarball
-XEN_LINUX_SOURCE ?= tarball
LINUX_VER ?= 2.6-rc
-
-XEN_LINUX_TARBALL_KETCHUP := y
-
-IMAGE_TARGET ?= vmlinux bzImage
-
-XEN_LINUX_ALLOW_INTERFACE_MISMATCH := y
-
-XEN_LINUX_CONFIG_UPDATE := buildconfigs/enable-xen-config
-
-EXTRAVERSION ?=
-
-include buildconfigs/mk.linux-2.6-xen
+include buildconfigs/mk.linux-2.6
diff -r 37833b33ae77 -r 4492a0285bae buildconfigs/mk.linux-2.6-tip
--- a/buildconfigs/mk.linux-2.6-tip Thu Jul 26 14:35:01 2007 -0600
+++ b/buildconfigs/mk.linux-2.6-tip Fri Jul 27 08:15:16 2007 -0600
@@ -1,14 +1,2 @@ XEN_LINUX_SOURCE ?= tarball
-XEN_LINUX_SOURCE ?= tarball
LINUX_VER ?= 2.6-tip
-
-XEN_LINUX_TARBALL_KETCHUP := y
-
-IMAGE_TARGET ?= vmlinux bzImage
-
-XEN_LINUX_ALLOW_INTERFACE_MISMATCH := y
-
-XEN_LINUX_CONFIG_UPDATE := buildconfigs/enable-xen-config
-
-EXTRAVERSION ?=
-
-include buildconfigs/mk.linux-2.6-xen
+include buildconfigs/mk.linux-2.6
diff -r 37833b33ae77 -r 4492a0285bae docs/man/xm.pod.1
--- a/docs/man/xm.pod.1 Thu Jul 26 14:35:01 2007 -0600
+++ b/docs/man/xm.pod.1 Fri Jul 27 08:15:16 2007 -0600
@@ -822,13 +822,15 @@ described under "Configuring Security" b
described under "Configuring Security" below. There, you will find
also examples of each subcommand described here.

-=item B<makepolicy> I<policy>
-
-Compiles the XML source representation of the security I<policy>. It
-creates a mapping (.map) as well as a binary (.bin) version of the
-policy. The compiled policy can be loaded into Xen with the
-B<loadpolicy> subcommand or can be configured to be loaded at boot
-time with the B<cfgbootpolicy> subcommand.
+=item B<setpolicy> ACM I<policy> I<[--load|--boot]>
+
+Makes the given ACM policy available to xend as a I<xend-managed policy>.
+The policy is compiled and a mapping (.map) as well as a binary (.bin)
+version of the policy is created. If the option I<--load> is provided
+the policy is loaded into Xen. If the option I<--boot> is provided the
+system is configure to be loaded with the policy at boot time. If these
+options are not provided with the B<setpolicy> subcommand, the
+B<activatepolicy> subcommand provides this functionality.

=over 4

@@ -843,18 +845,26 @@ global policy root directory.

=back

-=item B<loadpolicy> I<policy>
-
-Loads the binary representation of the I<policy> into Xen. The binary
-representation can be created with the B<makepolicy> subcommand.
-
-=item B<cfgbootpolicy> I<policy> [I<boot title>]
-
-Configures I<policy> as the boot policy for Xen. It copies the binary
-policy representation into the /boot directory and adds a module line
-specifying the binary policy to the /boot/grub/menu.lst file. If your
-boot configuration includes multiple Xen boot titles, then use the
-I<boot title> parameter to specify a unique part of the proper title.
+=item B<activatepolicy> I<[--load|--boot]>
+
+Activates the xend-managed policy by loading it into Xen using the
+I<--load> option or configures the system to boot with the
+xend-managed policy during the next reboot as a result of the
+I<--boot> option. The latter is only supported if the system is booted
+with the grub boot loader and the default boot title is modified.
+It copies the binary policy representation into the /boot directory and
+adds a module line specifying the binary policy to the /boot/grub/menu.lst
+or /boot/grub/grub.conf file.
+
+=item B<getpolicy> [--dumpxml]
+
+Displays information about the current xend-managed policy, such as
+name and type of the policy, the uuid xend has assigned to it on the
+local system, the version of the XML representation and the status
+of the policy, such as whether it is currently loaded into Xen or
+whether the policy is automatically loaded during system boot. With
+the I<--dumpxml> option, the XML representation of the policy is
+displayed.

=item B<dumppolicy>

@@ -869,28 +879,47 @@ is 'dom'. The labels are arranged in alp

=item B<addlabel> I<label> B<dom> I<configfile> [I<policy>]

+=item B<addlabel> I<label> B<mgt> I<domain name> [I<policy type>:I<policy>]
+
=item B<addlabel> I<label> B<res> I<resource> [I<policy>]

+=item B<addlabel> I<label> B<vif-idx> I<domain name> [I<policy type>:I<policy>]
+
+
Adds the security label with name I<label> to a domain
-I<configfile> (dom) or to the global resource label file for the
-given I<resource> (res). Unless specified, the default I<policy> is the
-currently enforced access control policy. This subcommand also
-verifies that the I<policy> definition supports the specified I<label>
-name.
+I<configfile> (dom), a Xend-managed domain (mgt), to the global resource label
+file for the given I<resource> (res), or to a managed domain's virtual network
+interface (vif) that is specified by its index. Unless specified,
+the default I<policy> is the currently enforced access control policy.
+This subcommand also verifies that the I<policy> definition supports the
+specified I<label> name.
+
+The only I<policy type> that is currently supported is I<ACM>.

=item B<rmlabel> B<dom> I<configfile>

+=item B<rmlabel> B<mgt> I<domain name>
+
=item B<rmlabel> B<res> I<resource>

+=item B<rmlabel> B<vif-idx> I<domain name>
+
Works the same as the B<addlabel> command (above), except that this
-command will remove the label from the domain I<configfile> (dom) or
-the global resource label file (res).
+command will remove the label from the domain I<configfile> (dom),
+a Xend-managed domain (mgt), the global resource label file (res),
+or a managed domain's network interface (vif).

=item B<getlabel> B<dom> I<configfile>

+=item B<getlabel> B<mgt> I<domain name>
+
=item B<getlabel> B<res> I<resource>

-Shows the label for the given I<configfile> or I<resource>
+=item B<getlabel> B<vif-idx> I<domain name>
+
+Shows the label for a domain's configuration in the given I<configfile>,
+a xend-managed domain (mgt), a resource, or a managed domain's network
+interface (vif).

=item B<resources>

@@ -908,12 +937,9 @@ B<CONFIGURING SECURITY>

=over 4

-In xen_source_dir/Config.mk set the following parameters:
+In xen_source_dir/Config.mk set the following parameter:

ACM_SECURITY ?= y
- ACM_DEFAULT_SECURITY_POLICY ?= \
- ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY
-
Then recompile and install xen and the security tools and then reboot:

cd xen_source_dir/xen; make clean; make; cp xen.gz /boot;
@@ -922,26 +948,26 @@ Then recompile and install xen and the s

=back

-B<COMPILING A SECURITY POLICY>
-
-=over 4
-
-This step creates client_v1.map and client_v1.bin files in
-/etc/xen/acm-security/policies/example/chwall_ste.
-
- xm makepolicy example.chwall_ste.client_v1
-
-=back
-
-B<LOADING A SECURITY POLICY>
-
-=over 4
-
-This step activates client_v1.bin as new security policy in Xen. You
-can use the dumppolicy subcommand before and afterwards to see the
+B<SETTING A SECURITY POLICY>
+
+=over 4
+
+This step makes the policy available to xend and creates the client_v1.map and
+client_v1.bin files in /etc/xen/acm-security/policies/example/chwall_ste.
+
+ xm setpolicy ACM example.client_v1
+
+=back
+
+B<ACTIVATING THE XEND-MANAGED SECURITY POLICY>
+
+=over 4
+
+This step activates the xend-manged policy as new security policy in Xen.
+You can use the dumppolicy subcommand before and afterwards to see the
change in the Xen policy state.

- xm loadpolicy example.chwall_ste.client_v1
+ xm activatpolicy --load

=back

@@ -949,11 +975,11 @@ B<CONFIGURING A BOOT SECURITY POLICY>

=over 4

-This configures the boot loader to load client_v1.bin at boot
-time. During system start, the ACM configures Xen with this policy and
+This configures the boot loader to load the current xend-managed policy at
+boot time. During system start, the ACM configures Xen with this policy and
Xen enforces this policy from then on.

- xm cfgbootpolicy example.chwall_ste.client_v1
+ xm activatepolicy --boot

=back

@@ -964,7 +990,7 @@ This subcommand shows all labels that ar
This subcommand shows all labels that are defined and which can be
attached to domains.

- xm labels example.chwall_ste.client_v1 type=dom
+ xm labels example.client_v1 type=dom

will print for our example policy:

@@ -1019,6 +1045,28 @@ permitted".

=back

+B<ATTACHING A SECURITY LABEL TO A XEND-MANAGED DOMAIN>
+
+=over 4
+
+The addlabel subcommand supports labeling of domains that are managed
+by xend. This includes domains that are currently running, such as for
+example Domain-0, or those that are in a dormant state.
+Depending on the state of the system, it is possible that the new label
+is rejected. An example for a reason for the rejection of the relabeling
+of a domain would be if a domain is currently allowed to
+access its labeled resources but due to the new label would be prevented
+from accessing one or more of them.
+
+ xm addlabel dom_Fun mgt Domain-0
+
+This changes the label of Domain-0 to dom_Fun under the condition that
+this new label of Domain-0 would not prevent any other domain from
+accessing its resources that are provided through Domain-0, such as for
+example network or block device access.
+
+=back
+
B<ATTACHING A SECURITY LABEL TO A RESOURCE>

=over 4
@@ -1072,9 +1120,11 @@ B<LISTING LABELED RESOURCES>
xm resources

phy:hda6
+ type: ACM
policy: example.chwall_ste.client_v1
label: res_LogicalDiskPartition1(hda1)
file:/xen/disk_image/disk.img
+ type: ACM
policy: example.chwall_ste.client_v1
label: res_LogicalDiskPartition2(hda2)

@@ -1094,19 +1144,19 @@ The XML version is the version that user
The XML version is the version that users are supposed to create or
change, either by manually editing the XML file or by using the Xen
policy generation tool (B<xensec_gen>). After changing the XML file,
-run the B<makepolicy> subcommand to ensure that these changes are
-reflected in the other versions. Use, for example, the subcommand
-B<cfgbootpolicy> to activate the changes during the next system
+run the B<setpolicy> subcommand to ensure that the new policy is
+available to xend. Use, for example, the subcommand
+B<activatepolicy> to activate the changes during the next system
reboot.

The binary version of the policy is derived from the XML policy by
tokenizing the specified labels and is used inside Xen only. It is
-created with the B<makepolicy> subcommand. Essentially, the binary
+created with the B<setpolicy> subcommand. Essentially, the binary
version is much more compact than the XML version and is easier to
evaluate during access control decisions.

The mapping version of the policy is created during the XML-to-binary
-policy translation (B<makepolicy>) and is used by the Xen management
+policy translation (B<setpolicy>) and is used by xend and the management
tools to translate between label names used as input to the tools and
their binary identifiers (ssidrefs) used inside Xen.

@@ -1121,5 +1171,6 @@ B<xmdomain.cfg>(5), B<xentop>(1)
Sean Dague <sean at dague dot net>
Daniel Stekloff <dsteklof at us dot ibm dot com>
Reiner Sailer <sailer at us dot ibm dot com>
+ Stefan Berger <stefanb at us dot ibm dot com>

=head1 BUGS
diff -r 37833b33ae77 -r 4492a0285bae docs/xen-api/xenapi-datamodel-graph.dot
--- a/docs/xen-api/xenapi-datamodel-graph.dot Thu Jul 26 14:35:01 2007 -0600
+++ b/docs/xen-api/xenapi-datamodel-graph.dot Fri Jul 27 08:15:16 2007 -0600
@@ -12,7 +12,7 @@ digraph "Xen-API Class Diagram" {
digraph "Xen-API Class Diagram" {
fontname="Verdana";

-node [ shape=box ]; session VM host network VIF PIF SR VDI VBD PBD user;
+node [ shape=box ]; session VM host network VIF PIF SR VDI VBD PBD user XSPolicy ACMPolicy;
node [shape=ellipse]; PIF_metrics VIF_metrics VM_metrics VBD_metrics PBD_metrics VM_guest_metrics host_metrics;
node [shape=box]; host_cpu console
session -> host [ arrowhead="none" ]
@@ -36,4 +36,6 @@ VBD -> VM [ arrowhead="none", arrowtail=
VBD -> VM [ arrowhead="none", arrowtail="crow" ]
VTPM -> VM [ arrowhead="none", arrowtail="crow" ]
VBD -> VBD_metrics [ arrowhead="none" ]
+XSPolicy -> host [ arrowhead="none" ]
+XSPolicy -> ACMPolicy [ arrowhead="none" ]
}
diff -r 37833b33ae77 -r 4492a0285bae docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Thu Jul 26 14:35:01 2007 -0600
+++ b/docs/xen-api/xenapi-datamodel.tex Fri Jul 27 08:15:16 2007 -0600
@@ -46,6 +46,8 @@ Name & Description \\
{\tt console} & A console \\
{\tt user} & A user of the system \\
{\tt debug} & A basic class for testing \\
+{\tt XSPolicy} & A class for handling Xen Security Policies \\
+{\tt ACMPolicy} & A class for handling ACM-type policies \\
\hline
\end{tabular}\end{center}
\section{Relationships Between Classes}
@@ -225,6 +227,261 @@ The following enumeration types are used
\end{longtable}

\vspace{1cm}
+\newpage
+
+\section{Error Handling}
+When a low-level transport error occurs, or a request is malformed at the HTTP
+or XML-RPC level, the server may send an XML-RPC Fault response, or the client
+may simulate the same. The client must be prepared to handle these errors,
+though they may be treated as fatal. On the wire, these are transmitted in a
+form similar to this:
+
+\begin{verbatim}
+ <methodResponse>
+ <fault>
+ <value>
+ <struct>
+ <member>
+ <name>faultCode</name>
+ <value><int>-1</int></value>
+ </member>
+ <member>
+ <name>faultString</name>
+ <value><string>Malformed request</string></value>
+ </member>
+ </struct>
+ </value>
+ </fault>
+ </methodResponse>
+\end{verbatim}
+
+All other failures are reported with a more structured error response, to
+allow better automatic response to failures, proper internationalisation of
+any error message, and easier debugging. On the wire, these are transmitted
+like this:
+
+\begin{verbatim}
+ <struct>
+ <member>
+ <name>Status</name>
+ <value>Failure</value>
+ </member>
+ <member>
+ <name>ErrorDescription</name>
+ <value>
+ <array>
+ <data>
+ <value>MAP_DUPLICATE_KEY</value>
+ <value>Customer</value>
+ <value>eSpeil Inc.</value>
+ <value>eSpeil Incorporated</value>
+ </data>
+ </array>
+ </value>
+ </member>
+ </struct>
+\end{verbatim}
+
+Note that {\tt ErrorDescription} value is an array of string values. The
+first element of the array is an error code; the remainder of the array are
+strings representing error parameters relating to that code. In this case,
+the client has attempted to add the mapping {\tt Customer $\rightarrow$
+eSpiel Incorporated} to a Map, but it already contains the mapping
+{\tt Customer $\rightarrow$ eSpiel Inc.}, and so the request has failed.
+
+The reference below lists each possible error returned by each method.
+As well as the errors explicitly listed, any method may return low-level
+errors as described above, or any of the following generic errors:
+
+\begin{itemize}
+\item HANDLE\_INVALID
+\item INTERNAL\_ERROR
+\item MAP\_DUPLICATE\_KEY
+\item MESSAGE\_METHOD\_UNKNOWN
+\item MESSAGE\_PARAMETER\_COUNT\_MISMATCH
+\item OPERATION\_NOT\_ALLOWED
+\item PERMISSION\_DENIED
+\item SESSION\_INVALID
+\end{itemize}
+
+Each possible error code is documented in the following section.
+
+\subsection{Error Codes}
+
+\subsubsection{HANDLE\_INVALID}
+
+You gave an invalid handle. The object may have recently been deleted.
+The class parameter gives the type of reference given, and the handle
+parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}HANDLE_INVALID(class, handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{INTERNAL\_ERROR}
+
+The server failed to handle your request, due to an internal error. The
+given message may give details useful for debugging the problem.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}INTERNAL_ERROR(message)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{MAP\_DUPLICATE\_KEY}
+
+You tried to add a key-value pair to a map, but that key is already there.
+The key, current value, and the new value that you tried to set are all
+echoed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}MAP_DUPLICATE_KEY(key, current value, new value)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{MESSAGE\_METHOD\_UNKNOWN}
+
+You tried to call a method that does not exist. The method name that you
+used is echoed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}MESSAGE_METHOD_UNKNOWN(method)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{MESSAGE\_PARAMETER\_COUNT\_MISMATCH}
+
+You tried to call a method with the incorrect number of parameters. The
+fully-qualified method name that you used, and the number of received and
+expected parameters are returned.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}MESSAGE_PARAMETER_COUNT_MISMATCH(method, expected, received)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{NETWORK\_ALREADY\_CONNECTED}
+
+You tried to create a PIF, but the network you tried to attach it to is
+already attached to some other PIF, and so the creation failed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}NETWORK_ALREADY_CONNECTED(network, connected PIF)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{OPERATION\_NOT\_ALLOWED}
+
+You attempted an operation that was not allowed.
+
+\vspace{0.3cm}
+No parameters.
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{PERMISSION\_DENIED}
+
+You do not have the required permissions to perform the operation.
+
+\vspace{0.3cm}
+No parameters.
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{PIF\_IS\_PHYSICAL}
+
+You tried to destroy a PIF, but it represents an aspect of the physical
+host configuration, and so cannot be destroyed. The parameter echoes the
+PIF handle you gave.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}PIF_IS_PHYSICAL(PIF)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SESSION\_AUTHENTICATION\_FAILED}
+
+The credentials given by the user are incorrect, so access has been denied,
+and you have not been issued a session handle.
+
+\vspace{0.3cm}
+No parameters.
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SESSION\_INVALID}
+
+You gave an invalid session handle. It may have been invalidated by a
+server restart, or timed out. You should get a new session handle, using
+one of the session.login\_ calls. This error does not invalidate the
+current connection. The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}SESSION_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SESSION\_NOT\_REGISTERED}
+
+This session is not registered to receive events. You must call
+event.register before event.next. The session handle you are using is
+echoed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}SESSION_NOT_REGISTERED(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VALUE\_NOT\_SUPPORTED}
+
+You attempted to set a value that is not supported by this implementation.
+The fully-qualified field name and the value that you tried to set are
+returned. Also returned is a developer-only diagnostic reason.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VALUE_NOT_SUPPORTED(field, value, reason)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VLAN\_TAG\_INVALID}
+
+You tried to create a VLAN, but the tag you gave was invalid -- it mmust be
+between 0 and 4095. The parameter echoes the VLAN tag you gave.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VLAN_TAG_INVALID(VLAN)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VM\_BAD\_POWER\_STATE}
+
+You attempted an operation on a VM that was not in an appropriate power
+state at the time; for example, you attempted to start a VM that was
+already running. The parameters returned are the VM's handle, and the
+expected and actual VM state at the time of the call.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VM_BAD_POWER_STATE(vm, expected, actual)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VM\_HVM\_REQUIRED}
+
+HVM is required for this operation
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VM_HVM_REQUIRED(vm)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SECURITY\_ERROR}
+
+A security error occurred. The parameter provides the xen security
+error code and a message describing the error.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}SECURITY_ERROR(xserr, message)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+

\newpage
\section{Class: session}
@@ -275,6 +532,11 @@ session ref


ID of newly created session
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SESSION\_AUTHENTICATION\_FAILED}
+
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
@@ -1153,6 +1415,7 @@ Quals & Field & Type & Description \\
$\mathit{RO}_\mathit{run}$ & {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
$\mathit{RO}_\mathit{run}$ & {\tt metrics} & VM\_metrics ref & metrics associated with this VM \\
$\mathit{RO}_\mathit{run}$ & {\tt guest\_metrics} & VM\_guest\_metrics ref & metrics associated with the running guest \\
+$\mathit{RO}_\mathit{run}$ & {\tt security/label} & string & the VM's security label \\
\hline
\end{longtable}
\subsection{RPCs associated with class: VM}
@@ -4147,6 +4410,82 @@ VM\_guest\_metrics ref


value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_security\_label}
+
+{\bf Overview:}
+Get the security label field of the given VM. Refer to the XSPolicy class
+for the format of the security label.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_security_label (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_security\_label}
+
+{\bf Overview:}
+Set the security label field of the given VM. Refer to the XSPolicy class
+for the format of the security label.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} int set_security_label (session_id s, VM ref self, string
+security_label, string old_label)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline
+{\tt string } & security\_label & security label for the VM \\ \hline
+{\tt string } & old\_label & Optional label value that the security label \\
+& & must currently have for the change to succeed.\\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+int
+}
+
+
+Returns the ssidref in case of an VM that is currently running or
+paused, zero in case of a dormant VM (halted, suspended).
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SECURITY\_ERROR}
+
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
@@ -7100,7 +7439,9 @@ value of the field
\subsubsection{RPC name:~get\_flags}

{\bf Overview:}
-Get the flags field of the given host\_cpu.
+Get the flags field of the given host\_cpu. As of this version of the
+API, the semantics of the returned string are explicitly unspecified,
+and may change in the future.

\noindent {\bf Signature:}
\begin{verbatim} string get_flags (session_id s, host_cpu ref self)\end{verbatim}
@@ -7132,7 +7473,9 @@ value of the field
\subsubsection{RPC name:~get\_features}

{\bf Overview:}
-Get the features field of the given host\_cpu.
+Get the features field of the given host\_cpu. As of this version of the
+API, the semantics of the returned string are explicitly unspecified,
+and may change in the future.

\noindent {\bf Signature:}
\begin{verbatim} string get_features (session_id s, host_cpu ref self)\end{verbatim}
@@ -8634,6 +8977,79 @@ value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
+\subsubsection{RPC name:~set\_security\_label}
+
+{\bf Overview:}
+Set the security label of the given VIF. Refer to the XSPolicy class
+for the format of the security label.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_security_label (session_id s, VIF ref self, string
+security_label, string old_label)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline
+
+{\tt string } & security\_label & New value of the security label \\ \hline
+{\tt string } & old\_label & Optional label value that the security label \\
+& & must currently have for the change to succeed.\\ \hline
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+void
+}
+
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SECURITY\_ERROR}
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_security\_label}
+
+{\bf Overview:}
+Get the security label of the given VIF.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_security_label (session_id s, VIF ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+value of the given field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
\subsubsection{RPC name:~create}

{\bf Overview:}
@@ -10382,6 +10798,7 @@ Quals & Field & Type & Description \\
$\mathit{RW}$ & {\tt sharable} & bool & true if this disk may be shared \\
$\mathit{RW}$ & {\tt read\_only} & bool & true if this disk may ONLY be mounted read-only \\
$\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
+$\mathit{RO}_\mathit{run}$ & {\tt security/label} & string & the VM's security label \\
\hline
\end{longtable}
\subsection{RPCs associated with class: VDI}
@@ -11062,6 +11479,79 @@ void



+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_security\_label}
+
+{\bf Overview:}
+Set the security label of the given VDI. Refer to the XSPolicy class
+for the format of the security label.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_security_label (session_id s, VDI ref self, string
+security_label, string old_label)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VDI ref } & self & reference to the object \\ \hline
+
+{\tt string } & security\_label & New value of the security label \\ \hline
+{\tt string } & old\_label & Optional label value that the security label \\
+& & must currently have for the change to succeed.\\ \hline
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+void
+}
+
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SECURITY\_ERROR}
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_security\_label}
+
+{\bf Overview:}
+Get the security label of the given VDI.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_security_label (session_id s, VDI ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VDI ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+value of the given field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
@@ -13172,6 +13662,38 @@ value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
+\subsubsection{RPC name:~get\_runtime\_properties}
+
+{\bf Overview:}
+Get the runtime\_properties field of the given VTPM.
+
+\noindent {\bf Signature:}
+\begin{verbatim} ((string -> string) Map) get_runtime_properties (session_id s, VTPM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VTPM ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+(string $\rightarrow$ string) Map
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
\subsubsection{RPC name:~create}

{\bf Overview:}
@@ -14016,6 +14538,634 @@ all fields from the object
\vspace{0.3cm}

\vspace{1cm}
+\newpage
+\section{Class: XSPolicy}
+\subsection{Fields for class: XSPolicy}
+\begin{longtable}{|lllp{0.38\textwidth}|}
+\hline
+\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf XSPolicy} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A Xen Security Policy}} \\
+\hline
+Quals & Field & Type & Description \\
+\hline
+$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier / object reference \\
+$\mathit{RW}$ & {\tt repr} & string & representation of policy, i.e., XML \\
+$\mathit{RO}_\mathit{run}$ & {\tt type} & xs\_type & type of the policy \\
+$\mathit{RO}_\mathit{run}$ & {\tt flags} & xs\_instantiationflags & policy
+status flags \\
+\hline
+\end{longtable}
+\subsection{Semantics of the class: XSPolicy}
+
+The XSPolicy class is used for administering Xen Security policies. Through
+this class a new policy can be uploaded to the system, loaded into the
+Xen hypervisor for enforcement and be set as the policy that the
+system is automatically loading when the machine is started.
+
+This class returns information about the currently administered policy,
+including a reference to the policy. This reference can then be used with
+policy-specific classes, i.e., the ACMPolicy class, to allow retrieval of
+information or changes to be made to a particular policy.
+
+\subsection{Structure and datatypes of class: XSPolicy}
+
+Format of the security label:
+
+A security label consist of the three different parts {\it policy type},
+{\it policy name} and {\it label} separated with colons. To specify
+the virtual machine label for an ACM-type policy {\it xm-test}, the
+security label string would be {\it ACM:xm-test:blue}, where blue
+denotes the virtual machine's label. The format of resource labels is
+the same.\\[0.5cm]
+The following flags are used by this class:
+
+\begin{longtable}{|l|l|l|}
+\hline
+{\tt xs\_type} & value & meaning \\
+\hline
+\hspace{0.5cm}{\tt XS\_POLICY\_ACM} & (1 $<<$ 0) & ACM-type policy \\
+\hline
+\end{longtable}
+
+\begin{longtable}{|l|l|l|}
+\hline
+{\tt xs\_instantiationflags} & value & meaning \\
+\hline
+\hspace{0.5cm}{\tt XS\_INST\_NONE} & 0 & do nothing \\
+\hspace{0.5cm}{\tt XS\_INST\_BOOT} & (1 $<<$ 0) & make system boot with this policy \\
+\hspace{0.5cm}{\tt XS\_INST\_LOAD} & (1 $<<$ 1) & load policy immediately \\
+\hline
+\end{longtable}
+
+\begin{longtable}{|l|l|l|}
+\hline
+{\tt xs\_policystate} & type & meaning \\
+\hline
+\hspace{0.5cm}{\tt xserr} & int & Error code from operation (if applicable) \\
+\hspace{0.5cm}{\tt xs\_ref} & XSPolicy ref & reference to the XS policy as returned by the API \\
+\hspace{0.5cm}{\tt repr} & string & representation of the policy, i.e., XML \\
+\hspace{0.5cm}{\tt type} & xs\_type & the type of the policy \\
+\hspace{0.5cm}{\tt flags } & xs\_instantiationflags & instantiation flags of the policy \\
+\hspace{0.5cm}{\tt version} & string & version of the policy \\
+\hspace{0.5cm}{\tt errors} & string & Base64-encoded sequence of integer tuples consisting \\
+& & of (error code, detail); will be returned as part \\
+& & of the xs\_setpolicy function. \\
+\hline
+\end{longtable}
+
+\subsection{Additional RPCs associated with class: XSPolicy}
+\subsubsection{RPC name:~get\_xstype}
+
+{\bf Overview:}
+Return the Xen Security Policy types supported by this system
+
+ \noindent {\bf Signature:}
+\begin{verbatim} xs_type get_xstype (session_id s)\end{verbatim}
+
+ \noindent {\bf Return Type:}
+{\tt
+xs\_type
+}
+
+flags representing the supported Xen security policy types
+ \vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_xspolicy}
+
+{\bf Overview:}
+Set the current XSPolicy. This function can also be be used for updating of
+an existing policy whose name must be equivalent to the one of the
+currently running policy.
+
+\noindent {\bf Signature:}
+\begin{verbatim} xs_policystate set_xspolicy (session_id s, xs_type type, string repr,
+xs_instantiationflags flags, bool overwrite)\end{verbatim}
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs\_type } & type & the type of policy \\ \hline
+{\tt string} & repr & representation of the policy, i.e., XML \\ \hline
+{\tt xs\_instantiationflags} & flags & flags for the setting of the policy \\ \hline
+{\tt bool} & overwrite & whether to overwrite an existing policy \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+
+ \noindent {\bf Return Type:}
+{\tt
+xs\_policystate
+}
+
+
+State information about the policy. In case an error occurred, the 'xs\_err'
+field contains the error code. The 'errors' may contain further information
+about the error.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_xspolicy}
+
+{\bf Overview:}
+Get information regarding the currently set Xen Security Policy
+
+ \noindent {\bf Signature:}
+\begin{verbatim} xs_policystate get_xspolicy (session_id s)\end{verbatim}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+xs\_policystate
+}
+
+
+Policy state information.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~rm\_xsbootpolicy}
+
+{\bf Overview:}
+Remove any policy from the default boot configuration.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void rm_xsbootpolicy (session_id s)\end{verbatim}
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SECURITY\_ERROR}
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_labeled\_resources}
+
+{\bf Overview:}
+Get a list of resources that have been labeled.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} ((string -> string) Map) get_labeled_resources (session_id s)\end{verbatim}
+
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+(string $\rightarrow$ string) Map
+}
+
+
+A map of resources with their labels.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_resource\_label}
+
+{\bf Overview:}
+Label the given resource with the given label. An empty label removes any label
+from the resource.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_resource_label (session_id s, string resource, string
+label, string old_label)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt string } & resource & resource to label \\ \hline
+{\tt string } & label & label for the resource \\ \hline
+{\tt string } & old\_label & Optional label value that the security label \\
+& & must currently have for the change to succeed. \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SECURITY\_ERROR}
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_resource\_label}
+
+{\bf Overview:}
+Get the label of the given resource.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_resource_label (session_id s, string resource)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt string } & resource & resource to label \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+The label of the given resource.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~activate\_xspolicy}
+
+{\bf Overview:}
+Load the referenced policy into the hypervisor.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} xs_instantiationflags activate_xspolicy (session_id s, xs_ref xspolicy,
+xs_instantiationflags flags)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+{\tt xs\_instantiationflags } & flags & flags to activate on a policy; flags
+ can only be set \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+
+ \noindent {\bf Return Type:}
+{\tt
+xs\_instantiationflags
+}
+
+
+Currently active instantiation flags.
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt SECURITY\_ERROR}
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_all}
+
+{\bf Overview:}
+Return a list of all the XSPolicies known to the system.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} ((XSPolicy ref) Set) get_all (session_id s)\end{verbatim}
+
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+(XSPolicy ref) Set
+}
+
+
+A list of all the IDs of all the XSPolicies
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_uuid}
+
+{\bf Overview:}
+Get the uuid field of the given XSPolicy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_uuid (session_id s, XSPolicy ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt XSPolicy ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_record}
+
+{\bf Overview:}
+Get a record of the referenced XSPolicy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (XSPolicy record) get_record (session_id s, xs_ref xspolicy)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+XSPolicy record
+}
+
+
+all fields from the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\newpage
+\section{Class: ACMPolicy}
+\subsection{Fields for class: ACMPolicy}
+\begin{longtable}{|lllp{0.38\textwidth}|}
+\hline
+\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf ACMPolicy} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em An ACM Security Policy}} \\
+\hline
+Quals & Field & Type & Description \\
+\hline
+$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier / object reference \\
+$\mathit{RW}$ & {\tt repr} & string & representation of policy, in XML \\
+$\mathit{RO}_\mathit{run}$ & {\tt type} & xs\_type & type of the policy \\
+$\mathit{RO}_\mathit{run}$ & {\tt flags} & xs\_instantiationflags & policy
+status flags \\
+\hline
+\end{longtable}
+
+\subsection{Structure and datatypes of class: ACMPolicy}
+
+\vspace{0.5cm}
+The following data structures are used:
+
+\begin{longtable}{|l|l|l|}
+\hline
+{\tt RIP acm\_policyheader} & type & meaning \\
+\hline
+\hspace{0.5cm}{\tt policyname} & string & name of the policy \\
+\hspace{0.5cm}{\tt policyurl } & string & URL of the policy \\
+\hspace{0.5cm}{\tt date} & string & data of the policy \\
+\hspace{0.5cm}{\tt reference} & string & reference of the policy \\
+\hspace{0.5cm}{\tt namespaceurl} & string & namespaceurl of the policy \\
+\hspace{0.5cm}{\tt version} & string & version of the policy \\
+\hline
+\end{longtable}
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_header}
+
+{\bf Overview:}
+Get the referenced policy's header information.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} acm_policyheader get_header (session_id s, xs ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+acm\_policyheader
+}
+
+
+The policy's header information.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_xml}
+
+{\bf Overview:}
+Get the XML representation of the given policy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_XML (session_id s, xs ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+XML representation of the referenced policy
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_map}
+
+{\bf Overview:}
+Get the mapping information of the given policy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_map (session_id s, xs ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+Mapping information of the referenced policy.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_binary}
+
+{\bf Overview:}
+Get the binary policy representation of the referenced policy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_map (session_id s, xs ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+Base64-encoded representation of the binary policy.
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_all}
+
+{\bf Overview:}
+Return a list of all the ACMPolicies known to the system.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} ((ACMPolicy ref) Set) get_all (session_id s)\end{verbatim}
+
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+(ACMPolicy ref) Set
+}
+
+
+A list of all the IDs of all the ACMPolicies
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_uuid}
+
+{\bf Overview:}
+Get the uuid field of the given ACMPolicy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_uuid (session_id s, ACMPolicy ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt ACMPolicy ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_record}
+
+{\bf Overview:}
+Get a record of the referenced ACMPolicy.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (XSPolicy record) get_record (session_id s, xs_ref xspolicy)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+XSPolicy record
+}
+
+
+all fields from the object
+
\newpage
\section{Class: debug}
\subsection{Fields for class: debug}
@@ -14192,224 +15342,3 @@ all fields from the object
\vspace{0.3cm}
\vspace{0.3cm}

-\vspace{1cm}
-\newpage
-\section{Error Handling}
-When a low-level transport error occurs, or a request is malformed at the HTTP
-or XML-RPC level, the server may send an XML-RPC Fault response, or the client
-may simulate the same. The client must be prepared to handle these errors,
-though they may be treated as fatal. On the wire, these are transmitted in a
-form similar to this:
-
-\begin{verbatim}
- <methodResponse>
- <fault>
- <value>
- <struct>
- <member>
- <name>faultCode</name>
- <value><int>-1</int></value>
- </member>
- <member>
- <name>faultString</name>
- <value><string>Malformed request</string></value>
- </member>
- </struct>
- </value>
- </fault>
- </methodResponse>
-\end{verbatim}
-
-All other failures are reported with a more structured error response, to
-allow better automatic response to failures, proper internationalisation of
-any error message, and easier debugging. On the wire, these are transmitted
-like this:
-
-\begin{verbatim}
- <struct>
- <member>
- <name>Status</name>
- <value>Failure</value>
- </member>
- <member>
- <name>ErrorDescription</name>
- <value>
- <array>
- <data>
- <value>MAP_DUPLICATE_KEY</value>
- <value>Customer</value>
- <value>eSpeil Inc.</value>
- <value>eSpeil Incorporated</value>
- </data>
- </array>
- </value>
- </member>
- </struct>
-\end{verbatim}
-
-Note that {\tt ErrorDescription} value is an array of string values. The
-first element of the array is an error code; the remainder of the array are
-strings representing error parameters relating to that code. In this case,
-the client has attempted to add the mapping {\tt Customer $\rightarrow$
-eSpiel Incorporated} to a Map, but it already contains the mapping
-{\tt Customer $\rightarrow$ eSpiel Inc.}, and so the request has failed.
-
-Each possible error code is documented in the following section.
-
-\subsection{Error Codes}
-
-\subsubsection{HANDLE\_INVALID}
-
-You gave an invalid handle. The object may have recently been deleted.
-The class parameter gives the type of reference given, and the handle
-parameter echoes the bad value given.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}HANDLE_INVALID(class, handle)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{INTERNAL\_ERROR}
-
-The server failed to handle your request, due to an internal error. The
-given message may give details useful for debugging the problem.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}INTERNAL_ERROR(message)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{MAP\_DUPLICATE\_KEY}
-
-You tried to add a key-value pair to a map, but that key is already there.
-The key, current value, and the new value that you tried to set are all
-echoed.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}MAP_DUPLICATE_KEY(key, current value, new value)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{MESSAGE\_METHOD\_UNKNOWN}
-
-You tried to call a method that does not exist. The method name that you
-used is echoed.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}MESSAGE_METHOD_UNKNOWN(method)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{MESSAGE\_PARAMETER\_COUNT\_MISMATCH}
-
-You tried to call a method with the incorrect number of parameters. The
-fully-qualified method name that you used, and the number of received and
-expected parameters are returned.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}MESSAGE_PARAMETER_COUNT_MISMATCH(method, expected, received)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{NETWORK\_ALREADY\_CONNECTED}
-
-You tried to create a PIF, but the network you tried to attach it to is
-already attached to some other PIF, and so the creation failed.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}NETWORK_ALREADY_CONNECTED(network, connected PIF)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{OPERATION\_NOT\_ALLOWED}
-
-You attempted an operation that was not allowed.
-
-\vspace{0.3cm}
-No parameters.
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{PIF\_IS\_PHYSICAL}
-
-You tried to destroy a PIF, but it represents an aspect of the physical
-host configuration, and so cannot be destroyed. The parameter echoes the
-PIF handle you gave.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}PIF_IS_PHYSICAL(PIF)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{SESSION\_AUTHENTICATION\_FAILED}
-
-The credentials given by the user are incorrect, so access has been denied,
-and you have not been issued a session handle.
-
-\vspace{0.3cm}
-No parameters.
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{SESSION\_INVALID}
-
-You gave an invalid session handle. It may have been invalidated by a
-server restart, or timed out. You should get a new session handle, using
-one of the session.login\_ calls. This error does not invalidate the
-current connection. The handle parameter echoes the bad value given.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}SESSION_INVALID(handle)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{SESSION\_NOT\_REGISTERED}
-
-This session is not registered to receive events. You must call
-event.register before event.next. The session handle you are using is
-echoed.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}SESSION_NOT_REGISTERED(handle)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{VALUE\_NOT\_SUPPORTED}
-
-You attempted to set a value that is not supported by this implementation.
-The fully-qualified field name and the value that you tried to set are
-returned. Also returned is a developer-only diagnostic reason.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}VALUE_NOT_SUPPORTED(field, value, reason)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{VLAN\_TAG\_INVALID}
-
-You tried to create a VLAN, but the tag you gave was invalid -- it mmust be
-between 0 and 4095. The parameter echoes the VLAN tag you gave.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}VLAN_TAG_INVALID(VLAN)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{VM\_BAD\_POWER\_STATE}
-
-You attempted an operation on a VM that was not in an appropriate power
-state at the time; for example, you attempted to start a VM that was
-already running. The parameters returned are the VM's handle, and the
-expected and actual VM state at the time of the call.
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}VM_BAD_POWER_STATE(vm, expected, actual)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
-
-\subsubsection{VM\_HVM\_REQUIRED}
-
-HVM is required for this operation
-
-\vspace{0.3cm}
-{\bf Signature:}
-\begin{verbatim}VM_HVM_REQUIRED(vm)\end{verbatim}
-\begin{center}\rule{10em}{0.1pt}\end{center}
diff -r 37833b33ae77 -r 4492a0285bae tools/examples/vtpm-common.sh
--- a/tools/examples/vtpm-common.sh Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/examples/vtpm-common.sh Fri Jul 27 08:15:16 2007 -0600
@@ -20,7 +20,7 @@ dir=$(dirname "$0")
. "$dir/logging.sh"
. "$dir/locking.sh"

-VTPMDB="/etc/xen/vtpm.db"
+VTPMDB="/var/vtpm/vtpm.db"

#In the vtpm-impl file some commands should be defined:
# vtpm_create, vtpm_setup, vtpm_start, etc. (see below)
@@ -241,12 +241,21 @@ function vtpm_get_create_reason () {
# If no entry in the TPM database is found, the instance is
# created and an entry added to the database.
function vtpm_create_instance () {
- local res instance domname reason
- domname=$(xenstore_read "$XENBUS_PATH"/domain)
+ local res instance domname reason uuid
+ uuid=$(xenstore_read "$XENBUS_PATH"/uuid)
reason=$(vtpm_get_create_reason)

claim_lock vtpmdb
- instance=$(vtpmdb_find_instance $domname)
+
+ instance="0"
+
+ if [ "$uuid" != "" ]; then
+ instance=$(vtpmdb_find_instance $uuid)
+ fi
+ if [ "$instance" == "0" ]; then
+ domname=$(xenstore_read "$XENBUS_PATH"/domain)
+ instance=$(vtpmdb_find_instance $domname)
+ fi

if [ "$instance" == "0" -a "$reason" != "create" ]; then
release_lock vtpmdb
@@ -268,7 +277,11 @@ function vtpm_create_instance () {
vtpm_create $instance

if [ $vtpm_fatal_error -eq 0 ]; then
- vtpmdb_add_instance $domname $instance
+ if [ "$uuid" != "" ]; then
+ vtpmdb_add_instance $uuid $instance
+ else
+ vtpmdb_add_instance $domname $instance
+ fi
fi
else
if [ "$reason" == "resume" ]; then
@@ -288,22 +301,29 @@ function vtpm_create_instance () {
#Since it is assumed that the VM will appear again, the
#entry is kept in the VTPMDB file.
function vtpm_remove_instance () {
- local instance reason domname
+ local instance reason domname uuid
#Stop script execution quietly if path does not exist (anymore)
xenstore-exists "$XENBUS_PATH"/domain
- domname=$(xenstore_read "$XENBUS_PATH"/domain)
-
- if [ "$domname" != "" ]; then
- claim_lock vtpmdb
-
+ uuid=$(xenstore_read "$XENBUS_PATH"/uuid)
+
+ claim_lock vtpmdb
+
+ instance="0"
+
+ if [ "$uuid != "" ]; then
+ instance=$(vtpmdb_find_instance $uuid)
+ fi
+
+ if [ "$instance == "0" ]; then
+ domname=$(xenstore_read "$XENBUS_PATH"/domain)
instance=$(vtpmdb_find_instance $domname)
-
- if [ "$instance" != "0" ]; then
- vtpm_suspend $instance
- fi
-
- release_lock vtpmdb
- fi
+ fi
+
+ if [ "$instance" != "0" ]; then
+ vtpm_suspend $instance
+ fi
+
+ release_lock vtpmdb
}


diff -r 37833b33ae77 -r 4492a0285bae tools/firmware/hvmloader/acpi/dsdt.asl
--- a/tools/firmware/hvmloader/acpi/dsdt.asl Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/firmware/hvmloader/acpi/dsdt.asl Fri Jul 27 08:15:16 2007 -0600
@@ -123,11 +123,12 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2,
}

Name(BUFA, ResourceTemplate() {
- IRQ(Level, ActiveLow, Shared) { 5, 7, 10, 11 }
+ IRQ(Level, ActiveLow, Shared) { 5, 10, 11 }
})

Name(BUFB, Buffer() {
- 0x23, 0x00, 0x00, 0x18, 0x79, 0
+ 0x23, 0x00, 0x00, 0x18, /* IRQ descriptor */
+ 0x79, 0 /* End tag, null checksum */
})

CreateWordField(BUFB, 0x01, IRQV)
@@ -643,6 +644,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2,
IRQNoFlags () {4}
})
}
+
+ Device (LTP1)
+ {
+ Name (_HID, EisaId ("PNP0400"))
+ Name (_UID, 0x02)
+ Method (_STA, 0, NotSerialized)
+ {
+ Return (0x0F)
+ }
+
+ Name (_CRS, ResourceTemplate()
+ {
+ IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
+ IRQNoFlags () {7}
+ })
+ }
}
}
}
diff -r 37833b33ae77 -r 4492a0285bae tools/firmware/hvmloader/acpi/dsdt.c
--- a/tools/firmware/hvmloader/acpi/dsdt.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/firmware/hvmloader/acpi/dsdt.c Fri Jul 27 08:15:16 2007 -0600
@@ -1,19 +1,19 @@
/*
*
* Intel ACPI Component Architecture
- * ASL Optimizing Compiler version 20060707 [Dec 30 2006]
+ * ASL Optimizing Compiler version 20060707 [Feb 16 2007]
* Copyright (C) 2000 - 2006 Intel Corporation
* Supports ACPI Specification Revision 3.0a
*
- * Compilation of "dsdt.asl" - Sat May 12 16:13:55 2007
+ * Compilation of "dsdt.asl" - Wed Jul 11 13:34:30 2007
*
* C source code output
*
*/
unsigned char AmlCode[] =
{
- 0x44,0x53,0x44,0x54,0x67,0x0D,0x00,0x00, /* 00000000 "DSDTg..." */
- 0x02,0xE0,0x58,0x65,0x6E,0x00,0x00,0x00, /* 00000008 "..Xen..." */
+ 0x44,0x53,0x44,0x54,0x9F,0x0D,0x00,0x00, /* 00000000 "DSDT...." */
+ 0x02,0x2E,0x58,0x65,0x6E,0x00,0x00,0x00, /* 00000008 "..Xen..." */
0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00, /* 00000010 "HVM....." */
0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
0x07,0x07,0x06,0x20,0x08,0x50,0x4D,0x42, /* 00000020 "... .PMB" */
@@ -27,7 +27,7 @@ unsigned char AmlCode[] =
0x04,0x0A,0x07,0x0A,0x07,0x00,0x00,0x08, /* 00000060 "........" */
0x50,0x49,0x43,0x44,0x00,0x14,0x0C,0x5F, /* 00000068 "PICD..._" */
0x50,0x49,0x43,0x01,0x70,0x68,0x50,0x49, /* 00000070 "PIC.phPI" */
- 0x43,0x44,0x10,0x4C,0xCE,0x5F,0x53,0x42, /* 00000078 "CD.L._SB" */
+ 0x43,0x44,0x10,0x44,0xD2,0x5F,0x53,0x42, /* 00000078 "CD.D._SB" */
0x5F,0x5B,0x82,0x49,0x04,0x4D,0x45,0x4D, /* 00000080 "_[..I.MEM" */
0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41, /* 00000088 "0._HID.A" */
0xD0,0x0C,0x02,0x08,0x5F,0x43,0x52,0x53, /* 00000090 "...._CRS" */
@@ -37,7 +37,7 @@ unsigned char AmlCode[] =
0x00,0x00,0xFF,0xFF,0x09,0x00,0x00,0x00, /* 000000B0 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */
0x00,0x00,0x00,0x00,0x0A,0x00,0x00,0x00, /* 000000C0 "........" */
- 0x00,0x00,0x79,0x00,0x5B,0x82,0x49,0xC9, /* 000000C8 "..y.[..I." */
+ 0x00,0x00,0x79,0x00,0x5B,0x82,0x41,0xCD, /* 000000C8 "..y.[..A." */
0x50,0x43,0x49,0x30,0x08,0x5F,0x48,0x49, /* 000000D0 "PCI0._HI" */
0x44,0x0C,0x41,0xD0,0x0A,0x03,0x08,0x5F, /* 000000D8 "D.A...._" */
0x55,0x49,0x44,0x00,0x08,0x5F,0x41,0x44, /* 000000E0 "UID.._AD" */
@@ -59,7 +59,7 @@ unsigned char AmlCode[] =
0x00,0xF0,0xFF,0xFF,0xFF,0xF4,0x00,0x00, /* 00000160 "........" */
0x00,0x00,0x00,0x00,0x00,0x05,0x79,0x00, /* 00000168 "......y." */
0xA4,0x50,0x52,0x54,0x30,0x08,0x42,0x55, /* 00000170 ".PRT0.BU" */
- 0x46,0x41,0x11,0x09,0x0A,0x06,0x23,0xA0, /* 00000178 "FA....#." */
+ 0x46,0x41,0x11,0x09,0x0A,0x06,0x23,0x20, /* 00000178 "FA....# " */
0x0C,0x18,0x79,0x00,0x08,0x42,0x55,0x46, /* 00000180 "..y..BUF" */
0x42,0x11,0x09,0x0A,0x06,0x23,0x00,0x00, /* 00000188 "B....#.." */
0x18,0x79,0x00,0x8B,0x42,0x55,0x46,0x42, /* 00000190 ".y..BUFB" */
@@ -348,7 +348,7 @@ unsigned char AmlCode[] =
0x0C,0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A, /* 00000A68 "........" */
0x02,0x00,0x0A,0x2F,0x12,0x0C,0x04,0x0C, /* 00000A70 ".../...." */
0xFF,0xFF,0x0F,0x00,0x0A,0x03,0x00,0x0A, /* 00000A78 "........" */
- 0x10,0x5B,0x82,0x44,0x2E,0x49,0x53,0x41, /* 00000A80 ".[..D.ISA" */
+ 0x10,0x5B,0x82,0x4C,0x31,0x49,0x53,0x41, /* 00000A80 ".[..L1ISA" */
0x5F,0x08,0x5F,0x41,0x44,0x52,0x0C,0x00, /* 00000A88 "_._ADR.." */
0x00,0x01,0x00,0x5B,0x80,0x50,0x49,0x52, /* 00000A90 "...[..PIR" */
0x51,0x02,0x0A,0x60,0x0A,0x04,0x10,0x2E, /* 00000A98 "Q..`...." */
@@ -440,6 +440,13 @@ unsigned char AmlCode[] =
0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A, /* 00000D48 "._STA..." */
0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10, /* 00000D50 ".._CRS.." */
0x0A,0x0D,0x47,0x01,0xF8,0x03,0xF8,0x03, /* 00000D58 "..G....." */
- 0x01,0x08,0x22,0x10,0x00,0x79,0x00,
+ 0x01,0x08,0x22,0x10,0x00,0x79,0x00,0x5B, /* 00000D60 ".."..y.[." */
+ 0x82,0x36,0x4C,0x54,0x50,0x31,0x08,0x5F, /* 00000D68 ".6LTP1._" */
+ 0x48,0x49,0x44,0x0C,0x41,0xD0,0x04,0x00, /* 00000D70 "HID.A..." */
+ 0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,0x14, /* 00000D78 "._UID..." */
+ 0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A, /* 00000D80 "._STA..." */
+ 0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10, /* 00000D88 ".._CRS.." */
+ 0x0A,0x0D,0x47,0x01,0x78,0x03,0x78,0x03, /* 00000D90 "..G.x.x." */
+ 0x08,0x08,0x22,0x80,0x00,0x79,0x00,
};
int DsdtLen=sizeof(AmlCode);
diff -r 37833b33ae77 -r 4492a0285bae tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/firmware/hvmloader/config.h Fri Jul 27 08:15:16 2007 -0600
@@ -9,7 +9,7 @@
#define LAPIC_ID(vcpu_id) ((vcpu_id) * 2)

#define PCI_ISA_DEVFN 0x08 /* dev 1, fn 0 */
-#define PCI_ISA_IRQ_MASK 0x0ca0U /* ISA IRQs 5,7,10,11 are PCI connected */
+#define PCI_ISA_IRQ_MASK 0x0c20U /* ISA IRQs 5,10,11 are PCI connected */

#define ROMBIOS_SEG 0xF000
#define ROMBIOS_BEGIN 0x000F0000
diff -r 37833b33ae77 -r 4492a0285bae tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/firmware/hvmloader/hvmloader.c Fri Jul 27 08:15:16 2007 -0600
@@ -180,15 +180,13 @@ static void pci_setup(void)
unsigned int bar, pin, link, isa_irq;

/* Program PCI-ISA bridge with appropriate link routes. */
- link = 0;
- for ( isa_irq = 0; isa_irq < 15; isa_irq++ )
- {
- if ( !(PCI_ISA_IRQ_MASK & (1U << isa_irq)) )
- continue;
+ isa_irq = 0;
+ for ( link = 0; link < 4; link++ )
+ {
+ do { isa_irq = (isa_irq + 1) & 15;
+ } while ( !(PCI_ISA_IRQ_MASK & (1U << isa_irq)) );
pci_writeb(PCI_ISA_DEVFN, 0x60 + link, isa_irq);
printf("PCI-ISA link %u routed to IRQ%u\n", link, isa_irq);
- if ( link++ == 4 )
- break;
}

/* Program ELCR to match PCI-wired IRQs. */
diff -r 37833b33ae77 -r 4492a0285bae tools/firmware/rombios/rombios.c
--- a/tools/firmware/rombios/rombios.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/firmware/rombios/rombios.c Fri Jul 27 08:15:16 2007 -0600
@@ -9146,78 +9146,78 @@ pci_routing_table_structure:
db 0 ;; pci bus number
db 0x08 ;; pci device number (bit 7-3)
db 0x61 ;; link value INTA#: pointer into PCI2ISA config space
- dw 0x0ca0 ;; IRQ bitmap INTA#
+ dw 0x0c20 ;; IRQ bitmap INTA#
db 0x62 ;; link value INTB#
- dw 0x0ca0 ;; IRQ bitmap INTB#
+ dw 0x0c20 ;; IRQ bitmap INTB#
db 0x63 ;; link value INTC#
- dw 0x0ca0 ;; IRQ bitmap INTC#
+ dw 0x0c20 ;; IRQ bitmap INTC#
db 0x60 ;; link value INTD#
- dw 0x0ca0 ;; IRQ bitmap INTD#
+ dw 0x0c20 ;; IRQ bitmap INTD#
db 0 ;; physical slot (0 = embedded)
db 0 ;; reserved
;; second slot entry: 1st PCI slot
db 0 ;; pci bus number
db 0x10 ;; pci device number (bit 7-3)
db 0x62 ;; link value INTA#
- dw 0x0ca0 ;; IRQ bitmap INTA#
+ dw 0x0c20 ;; IRQ bitmap INTA#
db 0x63 ;; link value INTB#
- dw 0x0ca0 ;; IRQ bitmap INTB#
+ dw 0x0c20 ;; IRQ bitmap INTB#
db 0x60 ;; link value INTC#
- dw 0x0ca0 ;; IRQ bitmap INTC#
+ dw 0x0c20 ;; IRQ bitmap INTC#
db 0x61 ;; link value INTD#
- dw 0x0ca0 ;; IRQ bitmap INTD#
+ dw 0x0c20 ;; IRQ bitmap INTD#
db 1 ;; physical slot (0 = embedded)
db 0 ;; reserved
;; third slot entry: 2nd PCI slot
db 0 ;; pci bus number
db 0x18 ;; pci device number (bit 7-3)
db 0x63 ;; link value INTA#
- dw 0x0ca0 ;; IRQ bitmap INTA#
+ dw 0x0c20 ;; IRQ bitmap INTA#
db 0x60 ;; link value INTB#
- dw 0x0ca0 ;; IRQ bitmap INTB#
+ dw 0x0c20 ;; IRQ bitmap INTB#
db 0x61 ;; link value INTC#
- dw 0x0ca0 ;; IRQ bitmap INTC#
+ dw 0x0c20 ;; IRQ bitmap INTC#
db 0x62 ;; link value INTD#
- dw 0x0ca0 ;; IRQ bitmap INTD#
+ dw 0x0c20 ;; IRQ bitmap INTD#
db 2 ;; physical slot (0 = embedded)
db 0 ;; reserved
;; 4th slot entry: 3rd PCI slot
db 0 ;; pci bus number
db 0x20 ;; pci device number (bit 7-3)
db 0x60 ;; link value INTA#
- dw 0x0ca0 ;; IRQ bitmap INTA#
+ dw 0x0c20 ;; IRQ bitmap INTA#
db 0x61 ;; link value INTB#
- dw 0x0ca0 ;; IRQ bitmap INTB#
+ dw 0x0c20 ;; IRQ bitmap INTB#
db 0x62 ;; link value INTC#
- dw 0x0ca0 ;; IRQ bitmap INTC#
+ dw 0x0c20 ;; IRQ bitmap INTC#
db 0x63 ;; link value INTD#
- dw 0x0ca0 ;; IRQ bitmap INTD#
+ dw 0x0c20 ;; IRQ bitmap INTD#
db 3 ;; physical slot (0 = embedded)
db 0 ;; reserved
;; 5th slot entry: 4rd PCI slot
db 0 ;; pci bus number
db 0x28 ;; pci device number (bit 7-3)
db 0x61 ;; link value INTA#
- dw 0x0ca0 ;; IRQ bitmap INTA#
+ dw 0x0c20 ;; IRQ bitmap INTA#
db 0x62 ;; link value INTB#
- dw 0x0ca0 ;; IRQ bitmap INTB#
+ dw 0x0c20 ;; IRQ bitmap INTB#
db 0x63 ;; link value INTC#
- dw 0x0ca0 ;; IRQ bitmap INTC#
+ dw 0x0c20 ;; IRQ bitmap INTC#
db 0x60 ;; link value INTD#
- dw 0x0ca0 ;; IRQ bitmap INTD#
+ dw 0x0c20 ;; IRQ bitmap INTD#
db 4 ;; physical slot (0 = embedded)
db 0 ;; reserved
;; 6th slot entry: 5rd PCI slot
db 0 ;; pci bus number
db 0x30 ;; pci device number (bit 7-3)
db 0x62 ;; link value INTA#
- dw 0x0ca0 ;; IRQ bitmap INTA#
+ dw 0x0c20 ;; IRQ bitmap INTA#
db 0x63 ;; link value INTB#
- dw 0x0ca0 ;; IRQ bitmap INTB#
+ dw 0x0c20 ;; IRQ bitmap INTB#
db 0x60 ;; link value INTC#
- dw 0x0ca0 ;; IRQ bitmap INTC#
+ dw 0x0c20 ;; IRQ bitmap INTC#
db 0x61 ;; link value INTD#
- dw 0x0ca0 ;; IRQ bitmap INTD#
+ dw 0x0c20 ;; IRQ bitmap INTD#
db 5 ;; physical slot (0 = embedded)
db 0 ;; reserved
#endif // BX_PCIBIOS
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/hw/cirrus_vga.c
--- a/tools/ioemu/hw/cirrus_vga.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/hw/cirrus_vga.c Fri Jul 27 08:15:16 2007 -0600
@@ -3096,8 +3096,6 @@ static void cirrus_vga_save(QEMUFile *f,
qemu_put_be64s(f, (uint64_t*)&s->cirrus_lfb_addr);
qemu_put_be64s(f, (uint64_t*)&s->cirrus_lfb_end);
qemu_put_buffer(f, s->vram_ptr, VGA_RAM_SIZE);
- if (vga_acc)
- cirrus_stop_acc(s);
}

static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/hw/ide.c Fri Jul 27 08:15:16 2007 -0600
@@ -596,7 +596,8 @@ static void ide_identify(IDEState *s)
/* 13=flush_cache_ext,12=flush_cache,10=lba48 */
put_le16(p + 83, (1 << 14) | (1 << 13) | (1 <<12) | (1 << 10));
put_le16(p + 84, (1 << 14));
- put_le16(p + 85, (1 << 14));
+ /* 14=nop 5=write_cache */
+ put_le16(p + 85, (1 << 14) | (1 << 5));
/* 13=flush_cache_ext,12=flush_cache,10=lba48 */
put_le16(p + 86, (1 << 14) | (1 << 13) | (1 <<12) | (1 << 10));
put_le16(p + 87, (1 << 14));
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/hw/rtl8139.c
--- a/tools/ioemu/hw/rtl8139.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/hw/rtl8139.c Fri Jul 27 08:15:16 2007 -0600
@@ -53,9 +53,8 @@
/* debug RTL8139 card C+ mode only */
//#define DEBUG_RTL8139CP 1

-/* RTL8139 provides frame CRC with received packet, this feature seems to be
- ignored by most drivers, disabled by default */
-//#define RTL8139_CALCULATE_RXCRC 1
+/* Calculate CRCs propoerly on Rx packets */
+#define RTL8139_CALCULATE_RXCRC 1

/* Uncomment to enable on-board timer interrupts */
//#define RTL8139_ONBOARD_TIMER 1
@@ -754,7 +753,7 @@ static void rtl8139_write_buffer(RTL8139
int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize);

/* write packet data */
- if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s))
+ if (wrapped && !(s->RxBufferSize < 65536 && rtl8139_RxWrap(s)))
{
DEBUG_PRINT((">>> RTL8139: rx packet wrapped in buffer at %d\n", size-wrapped));

@@ -1030,7 +1029,7 @@ static void rtl8139_do_receive(void *opa

/* write checksum */
#if defined (RTL8139_CALCULATE_RXCRC)
- val = cpu_to_le32(crc32(~0, buf, size));
+ val = cpu_to_le32(crc32(0, buf, size));
#else
val = 0;
#endif
@@ -1136,7 +1135,7 @@ static void rtl8139_do_receive(void *opa

/* write checksum */
#if defined (RTL8139_CALCULATE_RXCRC)
- val = cpu_to_le32(crc32(~0, buf, size));
+ val = cpu_to_le32(crc32(0, buf, size));
#else
val = 0;
#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/keymaps.c
--- a/tools/ioemu/keymaps.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/keymaps.c Fri Jul 27 08:15:16 2007 -0600
@@ -49,6 +49,7 @@ typedef struct {
int extra_count;
struct key_range *keypad_range;
struct key_range *numlock_range;
+ struct key_range *shift_range;
} kbd_layout_t;

static void add_to_key_range(struct key_range **krp, int code) {
@@ -127,6 +128,10 @@ static kbd_layout_t *parse_keyboard_layo
add_to_key_range(&k->numlock_range, keysym);
fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
}
+ if (rest && strstr(rest, "shift")) {
+ add_to_key_range(&k->shift_range, keysym);
+ fprintf(stderr, "shift keysym %04x keycode %d\n", keysym, keycode);
+ }

/* if(keycode&0x80)
keycode=(keycode<<8)^0x80e0; */
@@ -205,3 +210,14 @@ static int keysymIsNumlock(void *kbd_lay
return 1;
return 0;
}
+
+static int keysymIsShift(void *kbd_layout, int keysym)
+{
+ kbd_layout_t *k = kbd_layout;
+ struct key_range *kr;
+
+ for (kr = k->shift_range; kr; kr = kr->next)
+ if (keysym >= kr->start && keysym <= kr->end)
+ return 1;
+ return 0;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/target-i386-dm/exec-dm.c Fri Jul 27 08:15:16 2007 -0600
@@ -446,18 +446,16 @@ extern unsigned long logdirty_bitmap_siz
#if defined(__x86_64__) || defined(__i386__)
static void memcpy_words(void *dst, void *src, size_t n)
{
- asm (
+ asm volatile (
" movl %%edx,%%ecx \n"
#ifdef __x86_64__
" shrl $3,%%ecx \n"
- " andl $7,%%edx \n"
" rep movsq \n"
" test $4,%%edx \n"
" jz 1f \n"
" movsl \n"
#else /* __i386__ */
" shrl $2,%%ecx \n"
- " andl $3,%%edx \n"
" rep movsl \n"
#endif
"1: test $2,%%edx \n"
@@ -467,7 +465,7 @@ static void memcpy_words(void *dst, void
" jz 1f \n"
" movsb \n"
"1: \n"
- : : "S" (src), "D" (dst), "d" (n) : "ecx" );
+ : "+S" (src), "+D" (dst) : "d" (n) : "ecx", "memory" );
}
#else
static void memcpy_words(void *dst, void *src, size_t n)
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/target-i386-dm/helper2.c
--- a/tools/ioemu/target-i386-dm/helper2.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/target-i386-dm/helper2.c Fri Jul 27 08:15:16 2007 -0600
@@ -618,6 +618,7 @@ int main_loop(void)
CPUState *env = cpu_single_env;
int evtchn_fd = xc_evtchn_fd(xce_handle);
char qemu_file[PATH_MAX];
+ fd_set fds;

buffered_io_timer = qemu_new_timer(rt_clock, handle_buffered_io,
cpu_single_env);
@@ -625,19 +626,35 @@ int main_loop(void)

qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);

- while (!(vm_running && suspend_requested))
- /* Wait up to 10 msec. */
- main_loop_wait(10);
-
- fprintf(logfile, "device model received suspend signal!\n");
-
- /* Pull all outstanding ioreqs through the system */
- handle_buffered_io(env);
- main_loop_wait(1); /* For the select() on events */
-
- /* Save the device state */
- snprintf(qemu_file, sizeof(qemu_file), "/var/lib/xen/qemu-save.%d", domid);
- do_savevm(qemu_file);
+ xenstore_record_dm_state("running");
+ while (1) {
+ while (!(vm_running && suspend_requested))
+ /* Wait up to 10 msec. */
+ main_loop_wait(10);
+
+ fprintf(logfile, "device model saving state\n");
+
+ /* Pull all outstanding ioreqs through the system */
+ handle_buffered_io(env);
+ main_loop_wait(1); /* For the select() on events */
+
+ /* Save the device state */
+ snprintf(qemu_file, sizeof(qemu_file),
+ "/var/lib/xen/qemu-save.%d", domid);
+ do_savevm(qemu_file);
+
+ xenstore_record_dm_state("paused");
+
+ /* Wait to be allowed to continue */
+ while (suspend_requested) {
+ FD_ZERO(&fds);
+ FD_SET(xenstore_fd(), &fds);
+ if (select(xenstore_fd() + 1, &fds, NULL, NULL, NULL) > 0)
+ xenstore_process_event(NULL);
+ }
+
+ xenstore_record_dm_state("running");
+ }

return 0;
}
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/vl.c
--- a/tools/ioemu/vl.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/vl.c Fri Jul 27 08:15:16 2007 -0600
@@ -6856,15 +6856,6 @@ int set_mm_mapping(int xc_handle, uint32
return 0;
}

-void suspend(int sig)
-{
- fprintf(logfile, "suspend sig handler called with requested=%d!\n",
- suspend_requested);
- if (sig != SIGUSR1)
- fprintf(logfile, "suspend signal dismatch, get sig=%d!\n", sig);
- suspend_requested = 1;
-}
-
#if defined(MAPCACHE)

#if defined(__i386__)
@@ -7057,6 +7048,7 @@ int main(int argc, char **argv)
xen_pfn_t *page_array;
extern void *buffered_pio_page;
#endif
+ sigset_t set;

char qemu_dm_logfilename[128];

@@ -7141,13 +7133,8 @@ int main(int argc, char **argv)
serial_devices[i][0] = '\0';
serial_device_index = 0;

-#ifndef CONFIG_DM
pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "vc");
for(i = 1; i < MAX_PARALLEL_PORTS; i++)
-#else
- /* Xen steals IRQ7 for PCI. Disable LPT1 by default. */
- for(i = 0; i < MAX_PARALLEL_PORTS; i++)
-#endif
parallel_devices[i][0] = '\0';
parallel_device_index = 0;

@@ -7987,24 +7974,11 @@ int main(int argc, char **argv)
close(fd);
}

- /* register signal for the suspend request when save */
- {
- struct sigaction act;
- sigset_t set;
- act.sa_handler = suspend;
- act.sa_flags = SA_RESTART;
- sigemptyset(&act.sa_mask);
-
- sigaction(SIGUSR1, &act, NULL);
-
- /* control panel mask some signals when spawn qemu, need unmask here*/
- sigemptyset(&set);
- sigaddset(&set, SIGUSR1);
- sigaddset(&set, SIGTERM);
- if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1)
- fprintf(stderr, "unblock signal fail, possible issue for HVM save!\n");
-
- }
+ /* Unblock SIGTERM, which may have been blocked by the caller */
+ sigemptyset(&set);
+ sigaddset(&set, SIGTERM);
+ if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1)
+ fprintf(stderr, "Failed to unblock SIGTERM\n");

main_loop();
quit_timers();
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/vl.h Fri Jul 27 08:15:16 2007 -0600
@@ -1456,6 +1456,7 @@ void xenstore_parse_domain_config(int do
void xenstore_parse_domain_config(int domid);
int xenstore_fd(void);
void xenstore_process_event(void *opaque);
+void xenstore_record_dm_state(char *state);
void xenstore_check_new_media_present(int timeout);
void xenstore_write_vncport(int vnc_display);
int xenstore_read_vncpasswd(int domid);
diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/vnc.c Fri Jul 27 08:15:16 2007 -0600
@@ -915,12 +915,69 @@ static void press_key(VncState *vs, int
kbd_put_keycode(keysym2scancode(vs->kbd_layout, keysym) | 0x80);
}

+static void press_key_shift_down(VncState *vs, int down, int keycode)
+{
+ if (down)
+ kbd_put_keycode(0x2a & 0x7f);
+
+ if (keycode & 0x80)
+ kbd_put_keycode(0xe0);
+ if (down)
+ kbd_put_keycode(keycode & 0x7f);
+ else
+ kbd_put_keycode(keycode | 0x80);
+
+ if (!down)
+ kbd_put_keycode(0x2a | 0x80);
+}
+
+static void press_key_shift_up(VncState *vs, int down, int keycode)
+{
+ if (down) {
+ if (vs->modifiers_state[0x2a])
+ kbd_put_keycode(0x2a | 0x80);
+ if (vs->modifiers_state[0x36])
+ kbd_put_keycode(0x36 | 0x80);
+ }
+
+ if (keycode & 0x80)
+ kbd_put_keycode(0xe0);
+ if (down)
+ kbd_put_keycode(keycode & 0x7f);
+ else
+ kbd_put_keycode(keycode | 0x80);
+
+ if (!down) {
+ if (vs->modifiers_state[0x2a])
+ kbd_put_keycode(0x2a & 0x7f);
+ if (vs->modifiers_state[0x36])
+ kbd_put_keycode(0x36 & 0x7f);
+ }
+}
+
static void do_key_event(VncState *vs, int down, uint32_t sym)
{
int keycode;
+ int shift_keys = 0;
+ int shift = 0;
+
+ if (is_graphic_console()) {
+ if (sym >= 'A' && sym <= 'Z') {
+ sym = sym - 'A' + 'a';
+ shift = 1;
+ }
+ else {
+ shift = keysymIsShift(vs->kbd_layout, sym & 0xFFFF);
+ }
+ }
+ shift_keys = vs->modifiers_state[0x2a] | vs->modifiers_state[0x36];

keycode = keysym2scancode(vs->kbd_layout, sym & 0xFFFF);
-
+ if (keycode == 0) {
+ fprintf(stderr, "Key lost : keysym=0x%x(%d)\n", sym, sym);
+ return;
+ }
+
/* QEMU console switch */
switch(keycode) {
case 0x2a: /* Left Shift */
@@ -929,11 +986,15 @@ static void do_key_event(VncState *vs, i
case 0x9d: /* Right CTRL */
case 0x38: /* Left ALT */
case 0xb8: /* Right ALT */
- if (down)
+ if (down) {
vs->modifiers_state[keycode] = 1;
- else
+ kbd_put_keycode(keycode & 0x7f);
+ }
+ else {
vs->modifiers_state[keycode] = 0;
- break;
+ kbd_put_keycode(keycode | 0x80);
+ }
+ return;
case 0x02 ... 0x0a: /* '1' to '9' keys */
if (down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) {
/* Reset the modifiers sent to the current console */
@@ -943,9 +1004,14 @@ static void do_key_event(VncState *vs, i
}
break;
case 0x45: /* NumLock */
- if (!down)
+ if (down) {
+ kbd_put_keycode(keycode & 0x7f);
+ }
+ else {
vs->modifiers_state[keycode] ^= 1;
- break;
+ kbd_put_keycode(keycode | 0x80);
+ }
+ return;
}

if (keycodeIsKeypad(vs->kbd_layout, keycode)) {
@@ -967,6 +1033,18 @@ static void do_key_event(VncState *vs, i
}

if (is_graphic_console()) {
+ /* If the shift state needs to change then simulate an additional
+ keypress before sending this one.
+ */
+ if (shift && !shift_keys) {
+ press_key_shift_down(vs, down, keycode);
+ return;
+ }
+ else if (!shift && shift_keys) {
+ press_key_shift_up(vs, down, keycode);
+ return;
+ }
+
if (keycode & 0x80)
kbd_put_keycode(0xe0);
if (down)
@@ -1021,8 +1099,6 @@ static void do_key_event(VncState *vs, i

static void key_event(VncState *vs, int down, uint32_t sym)
{
- if (sym >= 'A' && sym <= 'Z' && is_graphic_console())
- sym = sym - 'A' + 'a';
do_key_event(vs, down, sym);
}

diff -r 37833b33ae77 -r 4492a0285bae tools/ioemu/xenstore.c
--- a/tools/ioemu/xenstore.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/ioemu/xenstore.c Fri Jul 27 08:15:16 2007 -0600
@@ -181,11 +181,18 @@ void xenstore_parse_domain_config(int do
}

/* Set a watch for log-dirty requests from the migration tools */
- if (pasprintf(&buf, "%s/logdirty/next-active", path) != -1) {
+ if (pasprintf(&buf, "/local/domain/0/device-model/%u/logdirty/next-active",
+ domid) != -1) {
xs_watch(xsh, buf, "logdirty");
fprintf(logfile, "Watching %s\n", buf);
}

+ /* Set a watch for suspend requests from the migration tools */
+ if (pasprintf(&buf,
+ "/local/domain/0/device-model/%u/command", domid) != -1) {
+ xs_watch(xsh, buf, "dm-command");
+ fprintf(logfile, "Watching %s\n", buf);
+ }

out:
free(type);
@@ -218,33 +225,26 @@ void xenstore_process_logdirty_event(voi
unsigned int len;
int i;

- fprintf(logfile, "Triggered log-dirty buffer switch\n");
-
if (!seg) {
- char *path, *p, *key_ascii, key_terminated[17] = {0,};
+ char *path = NULL, *key_ascii, key_terminated[17] = {0,};
key_t key;
int shmid;

/* Find and map the shared memory segment for log-dirty bitmaps */
- if (!(path = xs_get_domain_path(xsh, domid))) {
- fprintf(logfile, "Log-dirty: can't get domain path in store\n");
- exit(1);
- }
- if (!(path = realloc(path, strlen(path)
- + strlen("/logdirty/next-active") + 1))) {
+ if (pasprintf(&path,
+ "/local/domain/0/device-model/%u/logdirty/key",
+ domid) == -1) {
fprintf(logfile, "Log-dirty: out of memory\n");
exit(1);
}
- strcat(path, "/logdirty/");
- p = path + strlen(path);
- strcpy(p, "key");

key_ascii = xs_read(xsh, XBT_NULL, path, &len);
- if (!key_ascii) {
+ free(path);
+
+ if (!key_ascii)
/* No key yet: wait for the next watch */
- free(path);
return;
- }
+
strncpy(key_terminated, key_ascii, 16);
free(key_ascii);
key = (key_t) strtoull(key_terminated, NULL, 16);
@@ -276,18 +276,21 @@ void xenstore_process_logdirty_event(voi
}

/* Remember the paths for the next-active and active entries */
- strcpy(p, "active");
- if (!(active_path = strdup(path))) {
+ if (pasprintf(&active_path,
+ "/local/domain/0/device-model/%u/logdirty/active",
+ domid) == -1) {
fprintf(logfile, "Log-dirty: out of memory\n");
exit(1);
}
- strcpy(p, "next-active");
- if (!(next_active_path = strdup(path))) {
+ if (pasprintf(&next_active_path,
+ "/local/domain/0/device-model/%u/logdirty/next-active",
+ domid) == -1) {
fprintf(logfile, "Log-dirty: out of memory\n");
exit(1);
}
- free(path);
- }
+ }
+
+ fprintf(logfile, "Triggered log-dirty buffer switch\n");

/* Read the required active buffer from the store */
act = xs_read(xsh, XBT_NULL, next_active_path, &len);
@@ -310,6 +313,52 @@ void xenstore_process_logdirty_event(voi
}


+/* Accept state change commands from the control tools */
+static void xenstore_process_dm_command_event(void)
+{
+ char *path = NULL, *command = NULL;
+ unsigned int len;
+ extern int suspend_requested;
+
+ if (pasprintf(&path,
+ "/local/domain/0/device-model/%u/command", domid) == -1) {
+ fprintf(logfile, "out of memory reading dm command\n");
+ goto out;
+ }
+ command = xs_read(xsh, XBT_NULL, path, &len);
+ if (!command)
+ goto out;
+
+ if (!strncmp(command, "save", len)) {
+ fprintf(logfile, "dm-command: pause and save state\n");
+ suspend_requested = 1;
+ } else if (!strncmp(command, "continue", len)) {
+ fprintf(logfile, "dm-command: continue after state save\n");
+ suspend_requested = 0;
+ } else {
+ fprintf(logfile, "dm-command: unknown command\"%*s\"\n", len, command);
+ }
+
+ out:
+ free(path);
+ free(command);
+}
+
+void xenstore_record_dm_state(char *state)
+{
+ char *path = NULL;
+
+ if (pasprintf(&path,
+ "/local/domain/0/device-model/%u/state", domid) == -1) {
+ fprintf(logfile, "out of memory recording dm state\n");
+ goto out;
+ }
+ if (!xs_write(xsh, XBT_NULL, path, state, strlen(state)))
+ fprintf(logfile, "error recording dm state\n");
+
+ out:
+ free(path);
+}

void xenstore_process_event(void *opaque)
{
@@ -322,6 +371,11 @@ void xenstore_process_event(void *opaque

if (!strcmp(vec[XS_WATCH_TOKEN], "logdirty")) {
xenstore_process_logdirty_event();
+ goto out;
+ }
+
+ if (!strcmp(vec[XS_WATCH_TOKEN], "dm-command")) {
+ xenstore_process_dm_command_event();
goto out;
}

diff -r 37833b33ae77 -r 4492a0285bae tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxc/xc_domain.c Fri Jul 27 08:15:16 2007 -0600
@@ -586,6 +586,27 @@ int xc_domain_ioport_permission(int xc_h
domctl.u.ioport_permission.allow_access = allow_access;

return do_domctl(xc_handle, &domctl);
+}
+
+int xc_availheap(int xc_handle,
+ int min_width,
+ int max_width,
+ int node,
+ uint64_t *bytes)
+{
+ DECLARE_SYSCTL;
+ int rc;
+
+ sysctl.cmd = XEN_SYSCTL_availheap;
+ sysctl.u.availheap.min_bitwidth = min_width;
+ sysctl.u.availheap.max_bitwidth = max_width;
+ sysctl.u.availheap.node = node;
+
+ rc = xc_sysctl(xc_handle, &sysctl);
+
+ *bytes = sysctl.u.availheap.avail_bytes;
+
+ return rc;
}

int xc_vcpu_setcontext(int xc_handle,
diff -r 37833b33ae77 -r 4492a0285bae tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxc/xc_linux.c Fri Jul 27 08:15:16 2007 -0600
@@ -456,7 +456,7 @@ void *xc_gnttab_map_grant_refs(int xcg_h

map->count = count;

- if ( ioctl(xcg_handle, IOCTL_GNTDEV_MAP_GRANT_REF, &map) )
+ if ( ioctl(xcg_handle, IOCTL_GNTDEV_MAP_GRANT_REF, map) )
goto out;

addr = mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, xcg_handle,
diff -r 37833b33ae77 -r 4492a0285bae tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxc/xenctrl.h Fri Jul 27 08:15:16 2007 -0600
@@ -628,6 +628,20 @@ int xc_get_pfn_type_batch(int xc_handle,
/* Get current total pages allocated to a domain. */
long xc_get_tot_pages(int xc_handle, uint32_t domid);

+/**
+ * This function retrieves the the number of bytes available
+ * in the heap in a specific range of address-widths and nodes.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm domid the domain to query
+ * @parm min_width the smallest address width to query (0 if don't care)
+ * @parm max_width the largest address width to query (0 if don't care)
+ * @parm node the node to query (-1 for all)
+ * @parm *bytes caller variable to put total bytes counted
+ * @return 0 on success, <0 on failure.
+ */
+int xc_availheap(int xc_handle, int min_width, int max_width, int node,
+ uint64_t *bytes);

/*
* Trace Buffer Operations
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/include/xen/api/xen_acmpolicy.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen/api/xen_acmpolicy.h Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2007, IBM Corp.
+ * Copyright (c) 2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_ACMPOLICY_H
+#define XEN_ACMPOLICY_H
+
+#include "xen_common.h"
+#include "xen_string_string_map.h"
+#include "xen_xspolicy_decl.h"
+#include "xen_vm_decl.h"
+
+/*
+ * Data structures.
+ */
+
+typedef struct xen_acmpolicy_record
+{
+ xen_xspolicy handle;
+ char *uuid;
+ char *repr;
+ xs_instantiationflags flags;
+ xs_type type;
+} xen_acmpolicy_record;
+
+/**
+ * Allocate a xen_acmpolicy_record.
+ */
+extern xen_acmpolicy_record *
+xen_acmpolicy_record_alloc(void);
+
+/**
+ * Free the given xen_xspolicy_record, and all referenced values. The
+ * given record must have been allocated by this library.
+ */
+extern void
+xen_acmpolicy_record_free(xen_acmpolicy_record *record);
+
+
+/**
+ * Data structures for the policy's header
+ */
+typedef struct xen_acm_header
+{
+ char *policyname;
+ char *policyurl;
+ char *date;
+ char *reference;
+ char *namespaceurl;
+ char *version;
+} xen_acm_header;
+
+extern xen_acm_header *
+xen_acm_header_alloc(void);
+
+extern void
+xen_acm_header_free(xen_acm_header *hdr);
+
+/**
+ * Get the referenced policy's record.
+ */
+bool
+xen_acmpolicy_get_record(xen_session *session, xen_acmpolicy_record **result,
+ xen_xspolicy xspolicy);
+
+/**
+ * Get the header of a policy.
+ */
+extern bool
+xen_acmpolicy_get_header(xen_session *session, xen_acm_header **hdr,
+ xen_xspolicy xspolicy);
+
+
+/**
+ * Get the XML representation of the policy.
+ */
+extern bool
+xen_acmpolicy_get_xml(xen_session *session, char **xml,
+ xen_xspolicy xspolicy);
+
+/**
+ * Get the mapping file of the policy.
+ */
+extern bool
+xen_acmpolicy_get_map(xen_session *session, char **map,
+ xen_xspolicy xspolicy);
+
+/**
+ * Get the binary representation (base64-encoded) of the policy.
+ */
+extern bool
+xen_acmpolicy_get_binary(xen_session *session, char **binary,
+ xen_xspolicy xspolicy);
+
+/**
+ * Get the UUID filed of the given policy.
+ */
+bool
+xen_acmpolicy_get_uuid(xen_session *session, char **result,
+ xen_xspolicy xspolicy);
+
+#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/include/xen/api/xen_vdi.h
--- a/tools/libxen/include/xen/api/xen_vdi.h Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxen/include/xen/api/xen_vdi.h Fri Jul 27 08:15:16 2007 -0600
@@ -344,4 +344,17 @@ xen_vdi_get_all(xen_session *session, st
xen_vdi_get_all(xen_session *session, struct xen_vdi_set **result);


+/**
+ * Set the security label of a VDI.
+ */
+extern bool
+xen_vdi_set_security_label(xen_session *session, int64_t *result, xen_vdi vdi,
+ char *label, char *oldlabel);
+
+/**
+ * Get the security label of a VDI.
+ */
+extern bool
+xen_vdi_get_security_label(xen_session *session, char **result, xen_vdi vdi);
+
#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/include/xen/api/xen_vif.h
--- a/tools/libxen/include/xen/api/xen_vif.h Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxen/include/xen/api/xen_vif.h Fri Jul 27 08:15:16 2007 -0600
@@ -362,4 +362,18 @@ xen_vif_get_all(xen_session *session, st
xen_vif_get_all(xen_session *session, struct xen_vif_set **result);


+/**
+ * Set the security label of a VIF.
+ */
+extern bool
+xen_vif_set_security_label(xen_session *session, int64_t *result, xen_vif vif,
+ char *label, char *oldlabel);
+
+
+/**
+ * Get the security label of a VIF.
+ */
+extern bool
+xen_vif_get_security_label(xen_session *session, char **result, xen_vif vif);
+
#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/include/xen/api/xen_vm.h
--- a/tools/libxen/include/xen/api/xen_vm.h Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxen/include/xen/api/xen_vm.h Fri Jul 27 08:15:16 2007 -0600
@@ -112,6 +112,7 @@ typedef struct xen_vm_record
bool is_control_domain;
struct xen_vm_metrics_record_opt *metrics;
struct xen_vm_guest_metrics_record_opt *guest_metrics;
+ char *security_label;
} xen_vm_record;

/**
@@ -891,4 +892,17 @@ xen_vm_get_all(xen_session *session, str
xen_vm_get_all(xen_session *session, struct xen_vm_set **result);


+/**
+ * Set the security label of a domain.
+ */
+extern bool
+xen_vm_set_security_label(xen_session *session, int64_t *result, xen_vm vm,
+ char *label, char *oldlabel);
+
+/**
+ * Get the security label of a domain.
+ */
+extern bool
+xen_vm_get_security_label(xen_session *session, char **result, xen_vm vm);
+
#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/include/xen/api/xen_xspolicy.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen/api/xen_xspolicy.h Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2007, IBM Corp.
+ * Copyright (c) 2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_XSPOLICY_H
+#define XEN_XSPOLICY_H
+
+#include "xen_common.h"
+#include "xen_xspolicy_decl.h"
+#include "xen_string_string_map.h"
+
+
+/*
+ * The XSPolicy and associated data structures.
+ *
+ */
+typedef int64_t xs_type;
+typedef int64_t xs_instantiationflags;
+
+enum xs_type {
+ XS_POLICY_ACM = (1 << 0),
+};
+
+enum xs_instantiationflags {
+ XS_INST_NONE = 0,
+ XS_INST_BOOT = (1 << 0),
+ XS_INST_LOAD = (1 << 1),
+};
+
+
+/* Error codes returned by xend following XSPolicy operations */
+#define XSERR_BASE 0x1000
+
+#define XSERR_SUCCESS 0
+#define XSERR_GENERAL_FAILURE 1 + XSERR_BASE
+#define XSERR_BAD_XML 2 + XSERR_BASE
+#define XSERR_XML_PROCESSING 3 + XSERR_BASE
+#define XSERR_POLICY_INCONSISTENT 4 + XSERR_BASE
+#define XSERR_FILE_ERROR 5 + XSERR_BASE
+#define XSERR_BAD_RESOURCE_FORMAT 6 + XSERR_BASE
+#define XSERR_BAD_LABEL_FORMAT 7 + XSERR_BASE
+#define XSERR_RESOURCE_NOT_LABELED 8 + XSERR_BASE
+#define XSERR_RESOURCE_ALREADY_LABELED 9 + XSERR_BASE
+#define XSERR_WRONG_POLICY_TYPE 10 + XSERR_BASE
+#define XSERR_BOOTPOLICY_INSTALLED 11 + XSERR_BASE
+#define XSERR_NO_DEFAULT_BOOT_TITLE 12 + XSERR_BASE
+#define XSERR_POLICY_LOAD_FAILED 13 + XSERR_BASE
+#define XSERR_POLICY_LOADED 14 + XSERR_BASE
+#define XSERR_POLICY_TYPE_UNSUPPORTED 15 + XSERR_BASE
+#define XSERR_BAD_CONFLICTSET 20 + XSERR_BASE
+#define XSERR_RESOURCE_IN_USE 21 + XSERR_BASE
+#define XSERR_BAD_POLICY_NAME 22 + XSERR_BASE
+#define XSERR_RESOURCE_ACCESS 23 + XSERR_BASE
+#define XSERR_HV_OP_FAILED 24 + XSERR_BASE
+#define XSERR_BOOTPOLICY_INSTALL_ERROR 25 + XSERR_BASE
+
+
+/**
+ * Free the given xen_xspolicy. The given handle must have been allocated
+ * by this library.
+ */
+extern void
+xen_xspolicy_free(xen_xspolicy xspolicy);
+
+
+typedef struct xen_xspolicy_set
+{
+ size_t size;
+ xen_xspolicy *contents[];
+} xen_xspolicy_set;
+
+/**
+ * Allocate a xen_xspolicy_set of the given size.
+ */
+extern xen_xspolicy_set *
+xen_xspolicy_set_alloc(size_t size);
+
+/**
+ * Free the given xen_xspolicy_set. The given set must have been allocated
+ * by this library.
+ */
+extern void
+xen_xspolicy_set_free(xen_xspolicy_set *set);
+
+
+typedef struct xen_xspolicy_record
+{
+ xen_xspolicy handle;
+ char *uuid;
+ char *repr;
+ xs_instantiationflags flags;
+ xs_type type;
+} xen_xspolicy_record;
+
+/**
+ * Allocate a xen_xspolicy_record.
+ */
+extern xen_xspolicy_record *
+xen_xspolicy_record_alloc(void);
+
+/**
+ * Free the given xen_xspolicy_record, and all referenced values. The
+ * given record must have been allocated by this library.
+ */
+extern void
+xen_xspolicy_record_free(xen_xspolicy_record *record);
+
+
+typedef struct xen_xspolicy_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_xspolicy handle;
+ xen_xspolicy_record *record;
+ } u;
+} xen_xspolicy_record_opt;
+
+/**
+ * Allocate a xen_xspolicy_record_opt.
+ */
+extern xen_xspolicy_record_opt *
+xen_xspolicy_record_opt_alloc(void);
+
+/**
+ * Free the given xen_xspolicy_record_opt, and all referenced values. The
+ * given record_opt must have been allocated by this library.
+ */
+extern void
+xen_xspolicy_record_opt_free(xen_xspolicy_record_opt *record_opt);
+
+
+typedef struct xen_xspolicy_record_set
+{
+ size_t size;
+ xen_xspolicy_record *contents[];
+} xen_xspolicy_record_set;
+
+/**
+ * Allocate a xen_xspolicy_record_set of the given size.
+ */
+extern xen_xspolicy_record_set *
+xen_xspolicy_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_xspolicy_record_set, and all referenced values. The
+ * given set must have been allocated by this library.
+ */
+extern void
+xen_xspolicy_record_set_free(xen_xspolicy_record_set *set);
+
+/**
+ * Data structures and function declarations for an XS Policy's state
+ * information.
+ */
+typedef struct xen_xs_policystate
+{
+ xen_xspolicy_record_opt *xs_ref;
+ int64_t xserr;
+ char *repr;
+ xs_type type;
+ xs_instantiationflags flags;
+ char *version;
+ char *errors;
+} xen_xs_policystate;
+
+void
+xen_xs_policystate_free(xen_xs_policystate *state);
+
+
+/**
+ * Get the referenced policy's record.
+ */
+bool
+xen_xspolicy_get_record(xen_session *session, xen_xspolicy_record **result,
+ xen_xspolicy xspolicy);
+
+/**
+ * Get the UUID field of the given policy.
+ */
+bool
+xen_xspolicy_get_uuid(xen_session *session, char **result,
+ xen_xspolicy xspolicy);
+
+/**
+ * Get a policy given it's UUID
+ */
+bool
+xen_xspolicy_get_by_uuid(xen_session *session, xen_xspolicy *result,
+ char *uuid);
+
+
+/**
+ * Get the types of policies supported by the system.
+ */
+bool
+xen_xspolicy_get_xstype(xen_session *session, xs_type *result);
+
+
+/**
+ * Get information about the currently managed policy.
+ * (The API allows only one policy to be on the system.)
+ */
+bool
+xen_xspolicy_get_xspolicy(xen_session *session, xen_xs_policystate **result);
+
+/**
+ * Activate the referenced policy by loading it into the hypervisor.
+ */
+bool
+xen_xspolicy_activate_xspolicy(xen_session *session, int64_t *result,
+ xen_xspolicy xspolicy,
+ xs_instantiationflags flags);
+
+
+/**
+ * Set the system's policy to the given information comprising
+ * type of policy, the xml representation of the policy, some flags
+ * on whether to load the policy immediately and whether to overwrite
+ * an existing policy on the system.
+ */
+bool
+xen_xspolicy_set_xspolicy(xen_session *session, xen_xs_policystate **result,
+ xs_type type, char *repr, int64_t flags,
+ bool overwrite);
+
+
+/**
+ * Remove any policy from having the system booted with.
+ */
+extern bool
+xen_xspolicy_rm_xsbootpolicy(xen_session *session);
+
+/**
+ * Retrieve all labeled resources.
+ */
+extern bool
+xen_xspolicy_get_labeled_resources(xen_session *session,
+ xen_string_string_map **resources);
+
+/**
+ * Label a resource such as for example a hard drive partition or file
+ */
+extern bool
+xen_xspolicy_set_resource_label(xen_session *session,
+ char *resource, char *label,
+ char *oldlabel);
+
+/**
+ * Get the label of a resource.
+ */
+extern bool
+xen_xspolicy_get_resource_label(xen_session *session, char **label,
+ char *resource);
+
+#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/include/xen/api/xen_xspolicy_decl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen/api/xen_xspolicy_decl.h Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2007, IBM Corp.
+ * Copyright (c) 2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_XSPOLICY_DECL_H
+#define XEN_XSPOLICY_DECL_H
+
+typedef void *xen_xspolicy;
+
+struct xen_xspolicy_set;
+struct xen_xspolicy_record;
+struct xen_xspolicy_record_set;
+struct xen_xspolicy_record_opt;
+struct xen_xspolicy_record_opt_set;
+
+#endif
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/src/xen_acmpolicy.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_acmpolicy.c Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2007, IBM Corp.
+ * Copyright (c) 2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_internal.h"
+#include "xen/api/xen_common.h"
+#include "xen/api/xen_xspolicy.h"
+#include "xen/api/xen_acmpolicy.h"
+
+
+static const struct_member xen_acmpolicy_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acmpolicy_record, uuid) },
+ { .key = "flags",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_acmpolicy_record, flags) },
+ { .key = "repr",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acmpolicy_record, repr) },
+ { .key = "type",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_acmpolicy_record, type) },
+ };
+
+const abstract_type xen_acmpolicy_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_acmpolicy_record),
+ .member_count =
+ sizeof(xen_acmpolicy_record_struct_members) / sizeof(struct_member),
+ .members = xen_acmpolicy_record_struct_members
+ };
+
+
+static const struct_member xen_acm_header_struct_members[] =
+ {
+ { .key = "policyname",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acm_header, policyname) },
+ { .key = "policyurl",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acm_header, policyurl) },
+ { .key = "date",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acm_header, date) },
+ { .key = "reference",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acm_header, reference) },
+ { .key = "namespaceurl",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acm_header, namespaceurl) },
+ { .key = "version",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_acm_header, version) },
+ };
+
+const abstract_type xen_acm_header_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_acm_header),
+ .member_count =
+ sizeof(xen_acm_header_struct_members) /
+ sizeof(struct_member),
+ .members = xen_acm_header_struct_members,
+ };
+
+void
+xen_acm_header_free(xen_acm_header *shdr)
+{
+ if (shdr == NULL)
+ {
+ return;
+ }
+ free(shdr->policyname);
+ free(shdr->policyurl);
+ free(shdr->date);
+ free(shdr->reference);
+ free(shdr->namespaceurl);
+ free(shdr->version);
+ free(shdr);
+}
+
+
+void
+xen_acmpolicy_record_free(xen_acmpolicy_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ free(record->repr);
+ free(record);
+}
+
+
+
+bool
+xen_acmpolicy_get_record(xen_session *session, xen_acmpolicy_record **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy }
+ };
+
+ abstract_type result_type = xen_acmpolicy_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("ACMPolicy.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_acmpolicy_get_header(xen_session *session,
+ xen_acm_header **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy },
+ };
+
+ abstract_type result_type = xen_acm_header_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("ACMPolicy.get_header");
+ return session->ok;
+}
+
+
+bool
+xen_acmpolicy_get_xml(xen_session *session,
+ char **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy },
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("ACMPolicy.get_xml");
+ return session->ok;
+}
+
+
+bool
+xen_acmpolicy_get_map(xen_session *session,
+ char **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy },
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("ACMPolicy.get_map");
+ return session->ok;
+}
+
+
+bool
+xen_acmpolicy_get_binary(xen_session *session, char **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy },
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("ACMPolicy.get_binary");
+ return session->ok;
+}
+
+
+bool
+xen_acmpolicy_get_uuid(xen_session *session, char **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("ACMPolicy.get_uuid");
+ return session->ok;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/src/xen_vdi.c
--- a/tools/libxen/src/xen_vdi.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxen/src/xen_vdi.c Fri Jul 27 08:15:16 2007 -0600
@@ -534,3 +534,42 @@ xen_vdi_get_uuid(xen_session *session, c
XEN_CALL_("VDI.get_uuid");
return session->ok;
}
+
+
+bool
+xen_vdi_set_security_label(xen_session *session, int64_t *result, xen_vdi vdi,
+ char *label, char *oldlabel)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string,
+ .u.string_val = label },
+ { .type = &abstract_type_string,
+ .u.string_val = oldlabel },
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ *result = 0;
+ XEN_CALL_("VDI.set_security_label");
+ return session->ok;
+}
+
+
+bool
+xen_vdi_get_security_label(xen_session *session, char **result, xen_vdi vdi)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VDI.get_security_label");
+ return session->ok;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/src/xen_vif.c
--- a/tools/libxen/src/xen_vif.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxen/src/xen_vif.c Fri Jul 27 08:15:16 2007 -0600
@@ -575,3 +575,42 @@ xen_vif_get_uuid(xen_session *session, c
XEN_CALL_("VIF.get_uuid");
return session->ok;
}
+
+
+bool
+xen_vif_set_security_label(xen_session *session, int64_t *result, xen_vif vif,
+ char *label, char *oldlabel)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vif },
+ { .type = &abstract_type_string,
+ .u.string_val = label },
+ { .type = &abstract_type_string,
+ .u.string_val = oldlabel },
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ *result = 0;
+ XEN_CALL_("VIF.set_security_label");
+ return session->ok;
+}
+
+
+bool
+xen_vif_get_security_label(xen_session *session, char **result, xen_vif vif)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vif },
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VIF.get_security_label");
+ return session->ok;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/src/xen_vm.c
--- a/tools/libxen/src/xen_vm.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/libxen/src/xen_vm.c Fri Jul 27 08:15:16 2007 -0600
@@ -162,7 +162,10 @@ static const struct_member xen_vm_record
.offset = offsetof(xen_vm_record, metrics) },
{ .key = "guest_metrics",
.type = &abstract_type_ref,
- .offset = offsetof(xen_vm_record, guest_metrics) }
+ .offset = offsetof(xen_vm_record, guest_metrics) },
+ { .key = "security_label",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_vm_record, security_label) }
};

const abstract_type xen_vm_record_abstract_type_ =
@@ -206,6 +209,7 @@ xen_vm_record_free(xen_vm_record *record
xen_string_string_map_free(record->other_config);
xen_vm_metrics_record_opt_free(record->metrics);
xen_vm_guest_metrics_record_opt_free(record->guest_metrics);
+ free(record->security_label);
free(record);
}

@@ -1738,3 +1742,42 @@ xen_vm_get_uuid(xen_session *session, ch
XEN_CALL_("VM.get_uuid");
return session->ok;
}
+
+
+bool
+xen_vm_set_security_label(xen_session *session, int64_t *result, xen_vm vm,
+ char *label, char *oldlabel)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm },
+ { .type = &abstract_type_string,
+ .u.string_val = label },
+ { .type = &abstract_type_string,
+ .u.string_val = oldlabel },
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ *result = 0;
+ XEN_CALL_("VM.set_security_label");
+ return session->ok;
+}
+
+
+bool
+xen_vm_get_security_label(xen_session *session, char **result, xen_vm vm)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm },
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VM.get_security_label");
+ return session->ok;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/libxen/src/xen_xspolicy.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_xspolicy.c Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2007, IBM Corp.
+ * Copyright (c) 2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen/api/xen_common.h"
+#include "xen/api/xen_internal.h"
+#include "xen/api/xen_xspolicy.h"
+
+
+XEN_FREE(xen_xspolicy)
+XEN_SET_ALLOC_FREE(xen_xspolicy)
+XEN_RECORD_OPT_FREE(xen_xspolicy)
+
+static const struct_member xen_xspolicy_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_xspolicy_record, uuid) },
+ { .key = "flags",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_xspolicy_record, flags) },
+ { .key = "repr",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_xspolicy_record, repr) },
+ { .key = "type",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_xspolicy_record, type) },
+ };
+
+const abstract_type xen_xspolicy_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_xspolicy_record),
+ .member_count =
+ sizeof(xen_xspolicy_record_struct_members) / sizeof(struct_member),
+ .members = xen_xspolicy_record_struct_members
+ };
+
+
+static const struct_member xen_xs_policystate_struct_members[] =
+ {
+ { .key = "xs_ref",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_xs_policystate, xs_ref) },
+ { .key = "xserr",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_xs_policystate, xserr) },
+ { .key = "repr",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_xs_policystate, repr) },
+ { .key = "type",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_xs_policystate, type) },
+ { .key = "flags",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_xs_policystate, flags) },
+ { .key = "version",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_xs_policystate, version) },
+ { .key = "errors",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_xs_policystate, errors) },
+ };
+
+const abstract_type xen_xs_policystate_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_xs_policystate),
+ .member_count =
+ sizeof(xen_xs_policystate_struct_members) /
+ sizeof(struct_member),
+ .members = xen_xs_policystate_struct_members,
+ };
+
+
+
+
+void
+xen_xs_policystate_free(xen_xs_policystate *state)
+{
+ if (state == NULL)
+ {
+ return;
+ }
+ xen_xspolicy_record_opt_free(state->xs_ref);
+ free(state->repr);
+ free(state->errors);
+ free(state->version);
+ free(state);
+}
+
+
+void
+xen_xspolicy_record_free(xen_xspolicy_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ free(record->repr);
+ free(record);
+}
+
+
+bool
+xen_xspolicy_get_record(xen_session *session, xen_xspolicy_record **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy }
+ };
+
+ abstract_type result_type = xen_xspolicy_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("XSPolicy.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_get_uuid(xen_session *session, char **result,
+ xen_xspolicy xspolicy)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("XSPolicy.get_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_get_by_uuid(xen_session *session, xen_xspolicy *result,
+ char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("XSPolicy.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_get_xstype(xen_session *session, xs_type *result)
+{
+ abstract_value param_values[] =
+ {
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ *result = 0;
+ XEN_CALL_("XSPolicy.get_xstype");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_set_xspolicy(xen_session *session, xen_xs_policystate **result,
+ xs_type type, char *repr,
+ xs_instantiationflags flags,
+ bool overwrite)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_int,
+ .u.int_val = type },
+ { .type = &abstract_type_string,
+ .u.string_val = repr },
+ { .type = &abstract_type_int,
+ .u.int_val = flags },
+ { .type = &abstract_type_bool,
+ .u.bool_val = overwrite }
+ };
+
+ abstract_type result_type = xen_xs_policystate_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("XSPolicy.set_xspolicy");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_get_xspolicy(xen_session *session, xen_xs_policystate **result)
+{
+ abstract_value param_values[] =
+ {
+ };
+
+ abstract_type result_type = xen_xs_policystate_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("XSPolicy.get_xspolicy");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_get_labeled_resources(xen_session *session,
+ xen_string_string_map **result)
+{
+ abstract_value param_values[] =
+ {
+ };
+
+ abstract_type result_type = abstract_type_string_string_map;
+
+ *result = NULL;
+ XEN_CALL_("XSPolicy.get_labeled_resources");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_set_resource_label(xen_session *session,
+ char *resource, char *label,
+ char *oldlabel)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = resource },
+ { .type = &abstract_type_string,
+ .u.string_val = label },
+ { .type = &abstract_type_string,
+ .u.string_val = oldlabel },
+ };
+
+ xen_call_(session, "XSPolicy.set_resource_label", param_values, 3,
+ NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_get_resource_label(xen_session *session, char **result,
+ char *resource)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = resource },
+ };
+
+ abstract_type result_type = abstract_type_string;
+ XEN_CALL_("XSPolicy.get_resource_label");
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_rm_xsbootpolicy(xen_session *session)
+{
+ abstract_value param_values[] =
+ {
+ };
+
+ xen_call_(session, "XSPolicy.rm_xsbootpolicy", param_values, 0,
+ NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_xspolicy_activate_xspolicy(xen_session *session,
+ xs_instantiationflags *result,
+ xen_xspolicy xspolicy,
+ xs_instantiationflags flags)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = xspolicy },
+ { .type = &abstract_type_int,
+ .u.int_val = flags },
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ *result = 0;
+ XEN_CALL_("XSPolicy.activate_xspolicy");
+ return session->ok;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/lowlevel/acm/acm.c
--- a/tools/python/xen/lowlevel/acm/acm.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/lowlevel/acm/acm.c Fri Jul 27 08:15:16 2007 -0600
@@ -148,9 +148,10 @@ static PyObject *getdecision(PyObject *
char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL;
struct acm_getdecision getdecision;
int xc_handle, rc;
-
- if (!PyArg_ParseTuple(args, "ssss", &arg1_name,
- &arg1, &arg2_name, &arg2)) {
+ uint32_t hooktype;
+
+ if (!PyArg_ParseTuple(args, "ssssi", &arg1_name,
+ &arg1, &arg2_name, &arg2, &hooktype)) {
return NULL;
}

@@ -163,7 +164,7 @@ static PyObject *getdecision(PyObject *
(strcmp(arg2_name, "domid") && strcmp(arg2_name, "ssidref")))
return NULL;

- getdecision.hook = ACMHOOK_sharing;
+ getdecision.hook = hooktype;
if (!strcmp(arg1_name, "domid")) {
getdecision.get_decision_by1 = ACM_GETBY_domainid;
getdecision.id1.domainid = atoi(arg1);
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/util/acmpolicy.py
--- a/tools/python/xen/util/acmpolicy.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/util/acmpolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -57,12 +57,20 @@ class ACMPolicy(XSPolicy):
def __init__(self, name=None, dom=None, ref=None, xml=None):
if name:
self.name = name
- self.dom = minidom.parse(self.path_from_policy_name(name))
+ try:
+ self.dom = minidom.parse(self.path_from_policy_name(name))
+ except Exception, e:
+ raise SecurityError(-xsconstants.XSERR_XML_PROCESSING,
+ str(e))
elif dom:
self.dom = dom
self.name = self.get_name()
elif xml:
- self.dom = minidom.parseString(xml)
+ try:
+ self.dom = minidom.parseString(xml)
+ except Exception, e:
+ raise SecurityError(-xsconstants.XSERR_XML_PROCESSING,
+ str(e))
self.name = self.get_name()
rc = self.validate()
if rc != xsconstants.XSERR_SUCCESS:
@@ -114,7 +122,8 @@ class ACMPolicy(XSPolicy):
rc = -xsconstants.XSERR_GENERAL_FAILURE
if rc != xsconstants.XSERR_SUCCESS:
log.warn("XML did not validate against schema")
- rc = self.__validate_name_and_labels()
+ if rc == xsconstants.XSERR_SUCCESS:
+ rc = self.__validate_name_and_labels()
return rc

def __validate_name_and_labels(self):
@@ -481,7 +490,8 @@ class ACMPolicy(XSPolicy):
strings = []
i = 0
while i < len(node.childNodes):
- if node.childNodes[i].nodeName == "Type":
+ if node.childNodes[i].nodeName == "Type" and \
+ len(node.childNodes[i].childNodes) > 0:
strings.append(node.childNodes[i].childNodes[0].nodeValue)
i += 1
return strings
@@ -564,7 +574,8 @@ class ACMPolicy(XSPolicy):
while i < len(node.childNodes):
if node.childNodes[i].nodeName == "VirtualMachineLabel":
name = self.policy_dom_get(node.childNodes[i], "Name")
- strings.append(name.childNodes[0].nodeValue)
+ if len(name.childNodes) > 0:
+ strings.append(name.childNodes[0].nodeValue)
i += 1
return strings

@@ -592,43 +603,46 @@ class ACMPolicy(XSPolicy):
i = 0
while i < len(node.childNodes):
if node.childNodes[i].nodeName == "VirtualMachineLabel":
- _res = {}
- _res['type'] = xsconstants.ACM_LABEL_VM
name = self.policy_dom_get(node.childNodes[i], "Name")
- _res['name'] = name.childNodes[0].nodeValue
- stes = self.policy_dom_get(node.childNodes[i],
- "SimpleTypeEnforcementTypes")
- if stes:
- _res['stes'] = self.policy_get_types(stes)
- else:
- _res['stes'] = []
- chws = self.policy_dom_get(node.childNodes[i],
- "ChineseWallTypes")
- if chws:
- _res['chws'] = self.policy_get_types(chws)
- else:
- _res['chws'] = []
- res.append(_res)
+ if len(name.childNodes) > 0:
+ _res = {}
+ _res['type'] = xsconstants.ACM_LABEL_VM
+ _res['name'] = name.childNodes[0].nodeValue
+ stes = self.policy_dom_get(node.childNodes[i],
+ "SimpleTypeEnforcementTypes")
+ if stes:
+ _res['stes'] = self.policy_get_types(stes)
+ else:
+ _res['stes'] = []
+ chws = self.policy_dom_get(node.childNodes[i],
+ "ChineseWallTypes")
+ if chws:
+ _res['chws'] = self.policy_get_types(chws)
+ else:
+ _res['chws'] = []
+ res.append(_res)
i += 1
return res

def policy_get_stes_of_vmlabel(self, vmlabel):
""" Get a list of all STEs of a given VMlabel """
return self.__policy_get_stes_of_labeltype(vmlabel,
- "VirtualMachineLabel")
+ "/SubjectLabels", "VirtualMachineLabel")

def policy_get_stes_of_resource(self, reslabel):
""" Get a list of all resources of a given VMlabel """
- return self.__policy_get_stes_of_labeltype(reslabel, "ResourceLabel")
-
- def __policy_get_stes_of_labeltype(self, label, labeltype):
- node = self.dom_get_node("SecurityLabelTemplate/SubjectLabels")
+ return self.__policy_get_stes_of_labeltype(reslabel,
+ "/ObjectLabels", "ResourceLabel")
+
+ def __policy_get_stes_of_labeltype(self, label, path, labeltype):
+ node = self.dom_get_node("SecurityLabelTemplate" + path)
if node:
i = 0
while i < len(node.childNodes):
if node.childNodes[i].nodeName == labeltype:
name = self.policy_dom_get(node.childNodes[i], "Name")
- if name.childNodes[0].nodeValue == label:
+ if len(name.childNodes) > 0 and \
+ name.childNodes[0].nodeValue == label:
stes = self.policy_dom_get(node.childNodes[i],
"SimpleTypeEnforcementTypes")
if not stes:
@@ -649,7 +663,8 @@ class ACMPolicy(XSPolicy):
return False
for res in resources:
res_stes = self.policy_get_stes_of_resource(res)
- if len( set(res_stes).union( set(vm_stes) ) ) == 0:
+ if len(res_stes) == 0 or \
+ len( set(res_stes).intersection( set(vm_stes) ) ) == 0:
return False
return True

@@ -662,7 +677,7 @@ class ACMPolicy(XSPolicy):
if node.childNodes[i].nodeName == labeltype:
name = self.policy_dom_get(node.childNodes[i], "Name")
from_name = name.getAttribute("from")
- if from_name:
+ if from_name and len(name.childNodes) > 0:
res.update({from_name : name.childNodes[0].nodeValue})
i += 1
return res
@@ -700,7 +715,7 @@ class ACMPolicy(XSPolicy):
name = self.policy_dom_get(node.childNodes[i], "Name")
stes = self.policy_dom_get(node.childNodes[i],
"SimpleTypeEnforcementTypes")
- if stes:
+ if stes and len(name.childNodes) > 0:
strings.append(name.childNodes[0].nodeValue)
i += 1
return strings
@@ -715,18 +730,19 @@ class ACMPolicy(XSPolicy):
i = 0
while i < len(node.childNodes):
if node.childNodes[i].nodeName == "ResourceLabel":
- _res = {}
- _res['type'] = xsconstants.ACM_LABEL_RES
name = self.policy_dom_get(node.childNodes[i], "Name")
- _res['name'] = name.childNodes[0].nodeValue
- stes = self.policy_dom_get(node.childNodes[i],
- "SimpleTypeEnforcementTypes")
- if stes:
- _res['stes'] = self.policy_get_types(stes)
- else:
- _res['stes'] = []
- _res['chws'] = []
- res.append(_res)
+ if len(name.childNodes) > 0:
+ _res = {}
+ _res['type'] = xsconstants.ACM_LABEL_RES
+ _res['name'] = name.childNodes[0].nodeValue
+ stes = self.policy_dom_get(node.childNodes[i],
+ "SimpleTypeEnforcementTypes")
+ if stes:
+ _res['stes'] = self.policy_get_types(stes)
+ else:
+ _res['stes'] = []
+ _res['chws'] = []
+ res.append(_res)
i += 1
return res

diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/util/security.py
--- a/tools/python/xen/util/security.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/util/security.py Fri Jul 27 08:15:16 2007 -0600
@@ -61,6 +61,10 @@ empty_line_re = re.compile("^\s*$")
empty_line_re = re.compile("^\s*$")
binary_name_re = re.compile(".*[chwall|ste|chwall_ste].*\.bin", re.IGNORECASE)
policy_name_re = re.compile(".*[chwall|ste|chwall_ste].*", re.IGNORECASE)
+
+#decision hooks known to the hypervisor
+ACMHOOK_sharing = 1
+ACMHOOK_authorization = 2

#other global variables
NULL_SSIDREF = 0
@@ -155,75 +159,6 @@ def calc_dom_ssidref_from_info(info):
raise VmError("security.calc_dom_ssidref_from_info: info of type '%s'"
"not supported." % type(info))

-# Assumes a 'security' info [security access_control ...] [ssidref ...]
-def get_security_info(info, field):
- """retrieves security field from self.info['security'])
- allowed search fields: ssidref, label, policy
- """
- if isinstance(info, dict):
- security = info['security']
- elif isinstance(info, list):
- security = sxp.child_value(info, 'security')
- if not security:
- if field == 'ssidref':
- #return default ssid
- return 0
- else:
- err("Security information not found in info struct.")
-
- if field == 'ssidref':
- search = 'ssidref'
- elif field in ['policy', 'label']:
- search = 'access_control'
- else:
- err("Illegal field in get_security_info.")
-
- for idx in range(0, len(security)):
- if search != security[idx][0]:
- continue
- if search == 'ssidref':
- return int(security[idx][1])
- else:
- for aidx in range(0, len(security[idx])):
- if security[idx][aidx][0] == field:
- return str(security[idx][aidx][1])
-
- if search == 'ssidref':
- return 0
- else:
- return None
-
-
-def get_security_printlabel(info):
- """retrieves printable security label from self.info['security']),
- preferably the label name and otherwise (if label is not specified
- in config and cannot be found in mapping file) a hex string of the
- ssidref or none if both not available
- """
- try:
- if not on():
- return "INACTIVE"
- if active_policy in ["DEFAULT"]:
- return "DEFAULT"
-
- printlabel = get_security_info(info, 'label')
- if printlabel:
- return printlabel
- ssidref = get_security_info(info, 'ssidref')
- if not ssidref:
- return None
- #try to translate ssidref to a label
- result = ssidref2label(ssidref)
- if not result:
- printlabel = "0x%08x" % ssidref
- else:
- printlabel = result
- return printlabel
- except ACMError:
- #don't throw an exception in xm list
- return "ERROR"
-
-

def getmapfile(policyname):
"""
@@ -522,7 +457,8 @@ def get_decision(arg1, arg2):
err("Invalid id or ssidref type, string or int required")

try:
- decision = acm.getdecision(arg1[0], arg1[1], arg2[0], arg2[1])
+ decision = acm.getdecision(arg1[0], arg1[1], arg2[0], arg2[1],
+ ACMHOOK_sharing)
except:
err("Cannot determine decision.")

@@ -530,6 +466,21 @@ def get_decision(arg1, arg2):
return decision
else:
err("Cannot determine decision (Invalid parameter).")
+
+
+def has_authorization(ssidref):
+ """ Check if the domain with the given ssidref has authorization to
+ run on this system. To have authoriztion dom0's STE types must
+ be a superset of that of the domain's given through its ssidref.
+ """
+ rc = True
+ dom0_ssidref = int(acm.getssid(0)['ssidref'])
+ decision = acm.getdecision('ssidref', str(dom0_ssidref),
+ 'ssidref', str(ssidref),
+ ACMHOOK_authorization)
+ if decision == "DENIED":
+ rc = False
+ return rc


def hv_chg_policy(bin_pol, del_array, chg_array):
@@ -868,9 +819,10 @@ def is_resource_in_use(resource):
lst.append(dominfo)
return lst

-def devices_equal(res1, res2):
+def devices_equal(res1, res2, mustexist=True):
""" Determine whether two devices are equal """
- return (unify_resname(res1) == unify_resname(res2))
+ return (unify_resname(res1, mustexist) ==
+ unify_resname(res2, mustexist))

def is_resource_in_use_by_dom(dominfo, resource):
""" Determine whether a resources is in use by a given domain
@@ -886,7 +838,7 @@ def is_resource_in_use_by_dom(dominfo, r
dev = devs[uuid]
if len(dev) >= 2 and dev[1].has_key('uname'):
# dev[0] is type, i.e. 'vbd'
- if devices_equal(dev[1]['uname'], resource):
+ if devices_equal(dev[1]['uname'], resource, mustexist=False):
log.info("RESOURCE IN USE: Domain %d uses %s." %
(dominfo.domid, resource))
return True
@@ -899,7 +851,7 @@ def get_domain_resources(dominfo):
Entries are strored in the following formats:
tap:qcow:/path/xyz.qcow
"""
- resources = { 'vbd' : [], 'tap' : []}
+ resources = { 'vbd' : [], 'tap' : [], 'vif' : []}
devs = dominfo.info['devices']
uuids = devs.keys()
for uuid in uuids:
@@ -907,6 +859,15 @@ def get_domain_resources(dominfo):
typ = dev[0]
if typ in [ 'vbd', 'tap' ]:
resources[typ].append(dev[1]['uname'])
+ if typ in [ 'vif' ]:
+ sec_lab = dev[1].get('security_label')
+ if sec_lab:
+ resources[typ].append(sec_lab)
+ else:
+ resources[typ].append("%s:%s:%s" %
+ (xsconstants.ACM_POLICY_ID,
+ active_policy,
+ "unlabeled"))

return resources

@@ -942,23 +903,36 @@ def __resources_compatible_with_vmlabel(
dictionary of the resource name to resource label mappings
under which the evaluation should be done.
"""
+ def collect_labels(reslabels, s_label, polname):
+ if len(s_label) != 3 or polname != s_label[1]:
+ return False
+ label = s_label[2]
+ if not label in reslabels:
+ reslabels.append(label)
+ return True
+
resources = get_domain_resources(dominfo)
reslabels = [] # all resource labels
+
polname = xspol.get_name()
- for key in resources.keys():
- for res in resources[key]:
- try:
- tmp = access_control[res]
- if len(tmp) != 3:
+ for key, value in resources.items():
+ if key in [ 'vbd', 'tap' ]:
+ for res in resources[key]:
+ try:
+ label = access_control[res]
+ if not collect_labels(reslabels, label, polname):
+ return False
+ except:
return False
-
- if polname != tmp[1]:
+ elif key in [ 'vif' ]:
+ for xapi_label in value:
+ label = xapi_label.split(":")
+ if not collect_labels(reslabels, label, polname):
return False
- label = tmp[2]
- if not label in reslabels:
- reslabels.append(label)
- except:
- return False
+ else:
+ log.error("Unhandled device type: %s" % key)
+ return False
+
# Check that all resource labes have a common STE type with the
# vmlabel
rc = xspol.policy_check_vmlabel_against_reslabels(vmlabel, reslabels)
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendAPI.py Fri Jul 27 08:15:16 2007 -0600
@@ -1410,22 +1410,22 @@ class XendAPI(object):
def VM_set_memory_dynamic_max(self, session, vm_ref, mem):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
dom.set_memory_dynamic_max(int(mem))
- return xen_api_success_void()
+ return self._VM_save(dom)

def VM_set_memory_dynamic_min(self, session, vm_ref, mem):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
dom.set_memory_dynamic_min(int(mem))
- return xen_api_success_void()
+ return self._VM_save(dom)

def VM_set_memory_static_max(self, session, vm_ref, mem):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
dom.set_memory_static_max(int(mem))
- return xen_api_success_void()
+ return self._VM_save(dom)

def VM_set_memory_static_min(self, session, vm_ref, mem):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
dom.set_memory_static_min(int(mem))
- return xen_api_success_void()
+ return self._VM_save(dom)

def VM_set_memory_dynamic_max_live(self, session, vm_ref, mem):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
@@ -1620,7 +1620,8 @@ class XendAPI(object):
(rc, errors, oldlabel, new_ssidref) = \
dom.set_security_label(sec_label, old_label)
if rc != xsconstants.XSERR_SUCCESS:
- return xen_api_error(['SECURITY_ERROR', rc])
+ return xen_api_error(['SECURITY_ERROR', rc,
+ xsconstants.xserr2string(-rc)])
if rc == 0:
rc = new_ssidref
return xen_api_success(rc)
@@ -2083,6 +2084,25 @@ class XendAPI(object):
def VIF_get_security_label(self, session, vif_ref):
return self._VIF_get(vif_ref, 'security_label')

+ def _VIF_set(self, ref, prop, val, old_val):
+ return XendDomain.instance().set_dev_property_by_uuid(
+ 'vif', ref, prop, val, old_val)
+
+ def VIF_set_security_label(self, session, vif_ref, sec_lab, old_lab):
+ xendom = XendDomain.instance()
+ dom = xendom.get_vm_with_dev_uuid('vif', vif_ref)
+ if not dom:
+ return xen_api_error(['HANDLE_INVALID', 'VIF', vif_ref])
+
+ if dom._stateGet() == XEN_API_VM_POWER_STATE_RUNNING:
+ raise SecurityError(-xsconstants.XSERR_RESOURCE_IN_USE)
+
+ rc = self._VIF_set(vif_ref, 'security_label', sec_lab, old_lab)
+ if rc == False:
+ raise SecurityError(-xsconstants.XSERR_BAD_LABEL)
+ return xen_api_success(xsconstants.XSERR_SUCCESS)
+
+
# Xen API: Class VIF_metrics
# ----------------------------------------------------------------

@@ -2239,7 +2259,8 @@ class XendAPI(object):
vdi = XendNode.instance().get_vdi_by_uuid(vdi_ref)
rc = vdi.set_security_label(sec_lab, old_lab)
if rc < 0:
- return xen_api_error(['SECURITY_ERROR', rc])
+ return xen_api_error(['SECURITY_ERROR', rc,
+ xsconstants.xserr2string(-rc)])
return xen_api_success(rc)

def VDI_get_security_label(self, session, vdi_ref):
@@ -2357,11 +2378,13 @@ class XendAPI(object):
return xen_api_success(cons)

def console_get_location(self, session, console_ref):
+ xendom = XendDomain.instance()
return xen_api_success(xendom.get_dev_property_by_uuid('console',
console_ref,
'location'))

def console_get_protocol(self, session, console_ref):
+ xendom = XendDomain.instance()
return xen_api_success(xendom.get_dev_property_by_uuid('console',
console_ref,
'protocol'))
@@ -2370,6 +2393,12 @@ class XendAPI(object):
xendom = XendDomain.instance()
vm = xendom.get_vm_with_dev_uuid('console', console_ref)
return xen_api_success(vm.get_uuid())
+
+ def console_get_other_config(self, session, console_ref):
+ xendom = XendDomain.instance()
+ return xen_api_success(xendom.get_dev_property_by_uuid('console',
+ console_ref,
+ 'other_config'))

# object methods
def console_get_record(self, session, console_ref):
@@ -2409,6 +2438,13 @@ class XendAPI(object):
except XendError, exn:
return xen_api_error(['INTERNAL_ERROR', str(exn)])

+ def console_set_other_config(self, session, console_ref, other_config):
+ xd = XendDomain.instance()
+ vm = xd.get_vm_with_dev_uuid('console', console_ref)
+ vm.set_console_other_config(console_ref, other_config)
+ xd.managed_config_save(vm)
+ return xen_api_success_void()
+
# Xen API: Class SR
# ----------------------------------------------------------------
SR_attr_ro = [.'VDIs',
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendCheckpoint.py Fri Jul 27 08:15:16 2007 -0600
@@ -98,10 +98,6 @@ def save(fd, dominfo, network, live, dst
log.info("Domain %d suspended.", dominfo.getDomid())
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP3,
domain_name)
- #send signal to device model for save
- if hvm:
- log.info("release_devices for hvm domain")
- dominfo._releaseDevices(True)
tochild.write("done\n")
tochild.flush()
log.debug('Written done')
@@ -139,7 +135,7 @@ def save(fd, dominfo, network, live, dst
except Exception, exn:
log.exception("Save failed on domain %s (%s).", domain_name,
dominfo.getDomid())
-
+
dominfo.resumeDomain()
log.debug("XendCheckpoint.save: resumeDomain")

diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendConfig.py Fri Jul 27 08:15:16 2007 -0600
@@ -128,6 +128,11 @@ XENAPI_PLATFORM_CFG = [. 'acpi', 'apic',
'soundhw','stdvga', 'usb', 'usbdevice', 'vnc',
'vncconsole', 'vncdisplay', 'vnclisten',
'vncpasswd', 'vncunused', 'xauthority']
+
+# Xen API console 'other_config' keys.
+XENAPI_CONSOLE_OTHER_CFG = ['vncunused', 'vncdisplay', 'vnclisten',
+ 'vncpasswd', 'type', 'display', 'xauthority',
+ 'keymap']

# List of XendConfig configuration keys that have no direct equivalent
# in the old world.
@@ -636,6 +641,8 @@ class XendConfig(dict):
except ValueError, e:
raise XendConfigError('cpus = %s: %s' % (cfg['cpus'], e))

+ if not 'security' in cfg and sxp.child_value(sxp_cfg, 'security'):
+ cfg['security'] = sxp.child_value(sxp_cfg, 'security')
if 'security' in cfg and not cfg.get('security_label'):
secinfo = cfg['security']
if isinstance(secinfo, list):
@@ -1083,6 +1090,12 @@ class XendConfig(dict):

self.device_duplicate_check(dev_type, dev_info, target)

+ if dev_type == 'vif':
+ if dev_info.get('policy') and dev_info.get('label'):
+ dev_info['security_label'] = "%s:%s:%s" % \
+ (xsconstants.ACM_POLICY_ID,
+ dev_info['policy'],dev_info['label'])
+
# create uuid if it doesn't exist
dev_uuid = dev_info.get('uuid', None)
if not dev_uuid:
@@ -1113,9 +1126,7 @@ class XendConfig(dict):
# with vfb

other_config = {}
- for key in ['vncunused', 'vncdisplay', 'vnclisten',
- 'vncpasswd', 'type', 'display', 'xauthority',
- 'keymap']:
+ for key in XENAPI_CONSOLE_OTHER_CFG:
if key in dev_info:
other_config[key] = dev_info[key]
target['devices'][dev_uuid][1]['other_config'] = other_config
@@ -1157,6 +1168,10 @@ class XendConfig(dict):
network = XendAPIStore.get(
cfg_xenapi.get('network'), 'network')
dev_info['bridge'] = network.get_name_label()
+
+ if cfg_xenapi.get('security_label'):
+ dev_info['security_label'] = \
+ cfg_xenapi.get('security_label')

dev_uuid = cfg_xenapi.get('uuid', None)
if not dev_uuid:
@@ -1299,6 +1314,13 @@ class XendConfig(dict):
for dev_uuid, (dev_type, dev_info) in self['devices'].items():
if dev_uuid == console_uuid:
dev_info[key] = value
+ # collapse other_config into dev_info for things
+ # such as vncpasswd, vncunused, etc.
+ if key == 'other_config':
+ for k in XENAPI_CONSOLE_OTHER_CFG:
+ if k in dev_info and k not in value:
+ del dev_info[k]
+ dev_info.update(value)
break

def console_get_all(self, protocol):
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendDevices.py
--- a/tools/python/xen/xend/XendDevices.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendDevices.py Fri Jul 27 08:15:16 2007 -0600
@@ -78,6 +78,7 @@ class XendDevices:
@param domain: domain this controller is handling devices for.
@type domain: XendDomainInfo
"""
- tpmif.destroy_vtpmstate(domain.getName())
+ from xen.xend.XendLogging import log
+ tpmif.destroy_vtpmstate(domain.info.get('vtpm_refs'))

destroy_device_state = classmethod(destroy_device_state)
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendDomain.py Fri Jul 27 08:15:16 2007 -0600
@@ -51,6 +51,7 @@ from xen.xend.xenstore.xswatch import xs
from xen.xend.xenstore.xswatch import xswatch
from xen.util import mkdir
from xen.xend import uuid
+from xen.xend import sxp

xc = xen.lowlevel.xc.xc()
xoptions = XendOptions.instance()
@@ -688,6 +689,29 @@ class XendDomain:

return value

+ def set_dev_property_by_uuid(self, klass, dev_uuid, field, value,
+ old_val = None):
+ rc = True
+ self.domains_lock.acquire()
+
+ try:
+ try:
+ dom = self.get_vm_with_dev_uuid(klass, dev_uuid)
+ if dom:
+ o_val = dom.get_dev_property(klass, dev_uuid, field)
+ log.info("o_val=%s, old_val=%s" % (o_val, old_val))
+ if old_val and old_val != o_val:
+ return False
+
+ dom.set_dev_property(klass, dev_uuid, field, value)
+ self.managed_config_save(dom)
+ except ValueError, e:
+ pass
+ finally:
+ self.domains_lock.release()
+
+ return rc
+
def is_valid_vm(self, vm_ref):
return (self.get_vm_by_uuid(vm_ref) != None)

@@ -945,6 +969,31 @@ class XendDomain:
try:
try:
domconfig = XendConfig.XendConfig(sxp_obj = config)
+
+ domains = self.list('all')
+ domains = map(lambda dom: dom.sxpr(), domains)
+ for dom in domains:
+ if sxp.child_value(config, 'uuid', None):
+ if domconfig['uuid'] == sxp.child_value(dom, 'uuid'):
+ if domconfig['name_label'] != sxp.child_value(dom, 'name'):
+ raise XendError("Domain UUID '%s' is already used." % \
+ domconfig['uuid'])
+ else:
+ # Update the config for that existing domain
+ # because it is same name and same UUID.
+ break
+ else:
+ if domconfig['name_label'] == sxp.child_value(dom, 'name'):
+ raise XendError("Domain name '%s' is already used." % \
+ domconfig['name_label'])
+ else:
+ if domconfig['name_label'] == sxp.child_value(dom, 'name'):
+ # Overwrite the auto-generated UUID by the UUID
+ # of the existing domain. And update the config
+ # for that existing domain.
+ domconfig['uuid'] = sxp.child_value(dom, 'uuid')
+ break
+
dominfo = XendDomainInfo.createDormant(domconfig)
log.debug("Creating new managed domain: %s" %
dominfo.getName())
@@ -1164,6 +1213,10 @@ class XendDomain:

if dominfo.getDomid() == DOM0_ID:
raise XendError("Cannot dump core for privileged domain %s" % domid)
+ if dominfo._stateGet() not in (DOM_STATE_PAUSED, DOM_STATE_RUNNING):
+ raise VMBadState("Domain '%s' is not started" % domid,
+ POWER_STATE_NAMES[DOM_STATE_PAUSED],
+ POWER_STATE_NAMES[dominfo._stateGet()])

try:
log.info("Domain core dump requested for domain %s (%d) "
@@ -1537,6 +1590,10 @@ class XendDomain:
dominfo = self.domain_lookup_nr(domid)
if not dominfo:
raise XendInvalidDomain(str(domid))
+ if dominfo._stateGet() not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+ raise VMBadState("Domain '%s' is not started" % domid,
+ POWER_STATE_NAMES[DOM_STATE_RUNNING],
+ POWER_STATE_NAMES[dominfo._stateGet()])
if trigger_name.lower() in TRIGGER_TYPE:
trigger = TRIGGER_TYPE[trigger_name.lower()]
else:
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py Fri Jul 27 08:15:16 2007 -0600
@@ -632,16 +632,27 @@ class XendDomainInfo:
['vcpu_count', self.info['VCPUs_max']]]

for i in range(0, self.info['VCPUs_max']):
- info = xc.vcpu_getinfo(self.domid, i)
-
- sxpr.append(['vcpu',
- ['number', i],
- ['online', info['online']],
- ['blocked', info['blocked']],
- ['running', info['running']],
- ['cpu_time', info['cpu_time'] / 1e9],
- ['cpu', info['cpu']],
- ['cpumap', info['cpumap']]])
+ if self.domid is not None:
+ info = xc.vcpu_getinfo(self.domid, i)
+
+ sxpr.append(['vcpu',
+ ['number', i],
+ ['online', info['online']],
+ ['blocked', info['blocked']],
+ ['running', info['running']],
+ ['cpu_time', info['cpu_time'] / 1e9],
+ ['cpu', info['cpu']],
+ ['cpumap', info['cpumap']]])
+ else:
+ sxpr.append(['vcpu',
+ ['number', i],
+ ['online', 0],
+ ['blocked', 0],
+ ['running', 0],
+ ['cpu_time', 0.0],
+ ['cpu', -1],
+ ['cpumap', self.info['cpus'] and \
+ self.info['cpus'] or range(64)]])

return sxpr

@@ -1111,6 +1122,8 @@ class XendDomainInfo:
self._clearRestart()

if reason == 'suspend':
+ if self._stateGet() != DOM_STATE_SUSPENDED:
+ self.image.saveDeviceModel()
self._stateSet(DOM_STATE_SUSPENDED)
# Don't destroy the domain. XendCheckpoint will do
# this once it has finished. However, stop watching
@@ -1447,9 +1460,13 @@ class XendDomainInfo:
# allocation of 1MB. We free up 2MB here to be on the safe side.
balloon.free(2*1024) # 2MB should be plenty

- ssidref = security.calc_dom_ssidref_from_info(self.info)
- if ssidref == 0 and security.on():
- raise VmError('VM is not properly labeled.')
+ ssidref = 0
+ if security.on():
+ ssidref = security.calc_dom_ssidref_from_info(self.info)
+ if ssidref == 0:
+ raise VmError('VM is not properly labeled.')
+ if security.has_authorization(ssidref) == False:
+ raise VmError("VM is not authorized to run.")

try:
self.domid = xc.domain_create(
@@ -1594,6 +1611,7 @@ class XendDomainInfo:
log.exception("Removing domain path failed.")

self._stateSet(DOM_STATE_HALTED)
+ self.domid = None # Do not push into _stateSet()!
finally:
self.refresh_shutdown_lock.release()

@@ -1752,6 +1770,9 @@ class XendDomainInfo:
ResumeDomain(self.domid)
except:
log.exception("XendDomainInfo.resume: xc.domain_resume failed on domain %s." % (str(self.domid)))
+ if self.is_hvm():
+ self.image.resumeDeviceModel()
+

#
# Channels for xenstore and console
@@ -2419,6 +2440,8 @@ class XendDomainInfo:
config['io_read_kbs'] = 0.0
config['io_write_kbs'] = 0.0

+ config['security_label'] = config.get('security_label', '')
+
if dev_class == 'vbd':

if self._stateGet() not in (XEN_API_VM_POWER_STATE_HALTED,):
@@ -2610,6 +2633,9 @@ class XendDomainInfo:

return dev_uuid

+ def set_console_other_config(self, console_uuid, other_config):
+ self.info.console_update(console_uuid, 'other_config', other_config)
+
def destroy_device_by_uuid(self, dev_type, dev_uuid):
if dev_uuid not in self.info['devices']:
raise XendError('Device does not exist')
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendPIF.py
--- a/tools/python/xen/xend/XendPIF.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendPIF.py Fri Jul 27 08:15:16 2007 -0600
@@ -24,6 +24,7 @@ from xen.xend.XendBase import XendBase
from xen.xend.XendBase import XendBase
from xen.xend.XendPIFMetrics import XendPIFMetrics
from xen.xend.XendError import *
+from xen.xend import Vifctl

log = logging.getLogger("xend.XendPIF")
log.setLevel(logging.TRACE)
@@ -31,14 +32,17 @@ MAC_RE = re.compile(':'.join(['[0-9a-f]{
MAC_RE = re.compile(':'.join(['[0-9a-f]{2}'] * 6))
IP_IFACE_RE = re.compile(r'^\d+: (\w+):.*mtu (\d+) .* link/\w+ ([0-9a-f:]+)')

+
+Vifctl.network('start')
+
def linux_phy_to_virt(pif_name):
return 'eth' + re.sub(r'^[a-z]+', '', pif_name)

def linux_get_phy_ifaces():
"""Returns a list of physical interfaces.

- Identifies PIFs as those that have a interface name starting with 'p'
- and have the fake 'fe:ff:ff:ff:ff:ff' MAC address.
+ Identifies PIFs as those that have a interface name starting with
+ 'peth'.

See /etc/xen/scripts/network-bridge for how the devices are renamed.

@@ -58,7 +62,7 @@ def linux_get_phy_ifaces():

# resolve pifs' mac addresses
for name, mtu, mac in ifaces.values():
- if name[0] == 'p' and mac == 'fe:ff:ff:ff:ff:ff':
+ if name.startswith('peth'):
bridged_ifname = linux_phy_to_virt(name)
bridged_if = ifaces.get(bridged_ifname)
if bridged_if:
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendVDI.py
--- a/tools/python/xen/xend/XendVDI.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendVDI.py Fri Jul 27 08:15:16 2007 -0600
@@ -24,6 +24,7 @@ from xen.util.xmlrpclib2 import stringif
from xen.util.xmlrpclib2 import stringify
from xmlrpclib import dumps, loads
from xen.util import security, xsconstants
+from xen.xend.XendError import SecurityError

KB = 1024
MB = 1024 * 1024
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/XendXSPolicyAdmin.py
--- a/tools/python/xen/xend/XendXSPolicyAdmin.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/XendXSPolicyAdmin.py Fri Jul 27 08:15:16 2007 -0600
@@ -56,7 +56,10 @@ class XSPolicyAdmin:
typ = data[1]
try:
if typ == xsconstants.ACM_POLICY_ID:
- self.xsobjs[ref] = ACMPolicy(name=name, ref=ref)
+ try:
+ self.xsobjs[ref] = ACMPolicy(name=name, ref=ref)
+ except Exception, e:
+ del self.policies[ref]
else:
del self.policies[ref]
except Exception, e:
@@ -271,6 +274,10 @@ class XSPolicyAdmin:
return pol
return None

+ def get_hv_loaded_policy_name(self):
+ security.refresh_security_policy()
+ return security.active_policy
+
def get_policy_by_name(self, name):
for pol in self.xsobjs.values():
if pol.get_name() == name:
@@ -305,6 +312,18 @@ class XSPolicyAdmin:
vmlabel = pol.policy_get_domain_label_by_ssidref_formatted(ssidref)
return vmlabel

+ def get_stes_of_vmlabel(self, vmlabel_xapi):
+ """ Get the list of STEs given a VM label in XenAPI format """
+ stes = []
+ loadedpol = self.get_loaded_policy()
+ if loadedpol:
+ tmp = vmlabel_xapi.split(":")
+ if len(tmp) != 3:
+ return []
+ stes = loadedpol.policy_get_stes_of_vmlabel(tmp[2])
+ return stes
+
+
poladmin = None

def XSPolicyAdminInstance(maxpolicies=1):
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/balloon.py
--- a/tools/python/xen/xend/balloon.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/balloon.py Fri Jul 27 08:15:16 2007 -0600
@@ -94,7 +94,9 @@ def free(need_mem):
# track the last used value so that we don't trigger too many watches.

xoptions = XendOptions.instance()
+ dom0 = XendDomain.instance().privilegedDomain()
xc = xen.lowlevel.xc.xc()
+ dom0_start_alloc_mb = get_dom0_current_alloc() / 1024

try:
dom0_min_mem = xoptions.get_dom0_min_mem() * 1024
@@ -133,7 +135,6 @@ def free(need_mem):
new_alloc_mb = new_alloc / 1024 # Round down
log.debug("Balloon: setting dom0 target to %d MiB.",
new_alloc_mb)
- dom0 = XendDomain.instance().privilegedDomain()
dom0.setMemoryTarget(new_alloc_mb)
last_new_alloc = new_alloc
# Continue to retry, waiting for ballooning or scrubbing.
@@ -158,7 +159,10 @@ def free(need_mem):
(need_mem, dom0_min_mem, dom0_min_mem,
free_mem + scrub_mem + dom0_alloc - dom0_min_mem))
else:
- raise VmError('The privileged domain did not balloon!')
+ dom0.setMemoryTarget(dom0_start_alloc_mb)
+ raise VmError(
+ ('Not enough memory is available, and dom0 cannot'
+ ' be shrunk any further'))

finally:
del xc
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/image.py Fri Jul 27 08:15:16 2007 -0600
@@ -20,6 +20,7 @@ import os, string
import os, string
import re
import math
+import time
import signal

import xen.lowlevel.xc
@@ -27,6 +28,7 @@ from xen.xend.XendError import VmError,
from xen.xend.XendError import VmError, XendError, HVMRequired
from xen.xend.XendLogging import log
from xen.xend.XendOptions import instance as xenopts
+from xen.xend.xenstore.xstransact import xstransact
from xen.xend.xenstore.xswatch import xswatch
from xen.xend import arch

@@ -175,6 +177,14 @@ class ImageHandler:
"""Create device model for the domain (define in subclass if needed)."""
pass

+ def saveDeviceModel(self):
+ """Save device model for the domain (define in subclass if needed)."""
+ pass
+
+ def resumeDeviceModel(self):
+ """Unpause device model for the domain (define in subclass if needed)."""
+ pass
+
def destroy(self):
"""Extra cleanup on domain destroy (define in subclass if needed)."""
pass
@@ -443,17 +453,34 @@ class HVMImageHandler(ImageHandler):
self.vm.storeDom("image/device-model-pid", self.pid)
log.info("device model pid: %d", self.pid)

+ def saveDeviceModel(self):
+ # Signal the device model to pause itself and save its state
+ xstransact.Store("/local/domain/0/device-model/%i"
+ % self.vm.getDomid(), ('command', 'save'))
+ # Wait for confirmation. Could do this with a watch but we'd
+ # still end up spinning here waiting for the watch to fire.
+ state = ''
+ count = 0
+ while state != 'paused':
+ state = xstransact.Read("/local/domain/0/device-model/%i/state"
+ % self.vm.getDomid())
+ time.sleep(0.1)
+ count += 1
+ if count > 100:
+ raise VmError('Timed out waiting for device model to save')
+
+ def resumeDeviceModel(self):
+ # Signal the device model to resume activity after pausing to save.
+ xstransact.Store("/local/domain/0/device-model/%i"
+ % self.vm.getDomid(), ('command', 'continue'))
+
def recreate(self):
self.pid = self.vm.gatherDom(('image/device-model-pid', int))

def destroy(self, suspend = False):
- if self.pid:
+ if self.pid and not suspend:
try:
- sig = signal.SIGKILL
- if suspend:
- log.info("use sigusr1 to signal qemu %d", self.pid)
- sig = signal.SIGUSR1
- os.kill(self.pid, sig)
+ os.kill(self.pid, signal.SIGKILL)
except OSError, exn:
log.exception(exn)
try:
@@ -464,6 +491,8 @@ class HVMImageHandler(ImageHandler):
# but we can't wait for it because it's not our child.
pass
self.pid = None
+ state = xstransact.Remove("/local/domain/0/device-model/%i"
+ % self.vm.getDomid())


class IA64_HVM_ImageHandler(HVMImageHandler):
@@ -506,6 +535,7 @@ class X86_HVM_ImageHandler(HVMImageHandl
# were given (but the Xen minimum is for safety, not performance).
return max(4 * (256 * self.vm.getVCpuCount() + 2 * (maxmem_kb / 1024)),
shadow_mem_kb)
+

class X86_Linux_ImageHandler(LinuxImageHandler):

diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/server/SrvServer.py
--- a/tools/python/xen/xend/server/SrvServer.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/server/SrvServer.py Fri Jul 27 08:15:16 2007 -0600
@@ -49,7 +49,6 @@ from xen.web.httpserver import HttpServe
from xen.web.httpserver import HttpServer, UnixHttpServer

from xen.xend import XendNode, XendOptions, XendAPI
-from xen.xend import Vifctl
from xen.xend.XendLogging import log
from xen.xend.XendClient import XEN_API_SOCKET
from xen.xend.XendDomain import instance as xenddomain
@@ -101,8 +100,6 @@ class XendServers:
if status:
fcntl.fcntl(status, fcntl.F_SETFD, fcntl.FD_CLOEXEC)

- Vifctl.network('start')
-
# Prepare to catch SIGTERM (received when 'xend stop' is executed)
# and call each server's cleanup if possible
signal.signal(signal.SIGTERM, self.cleanup)
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/server/netif.py Fri Jul 27 08:15:16 2007 -0600
@@ -26,6 +26,11 @@ import re

from xen.xend import XendOptions
from xen.xend.server.DevController import DevController
+from xen.xend.XendError import VmError
+from xen.util import security
+from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
+
+from xen.xend.XendLogging import log

xoptions = XendOptions.instance()

@@ -108,6 +113,7 @@ class NetifController(DevController):
ipaddr = config.get('ip')
model = config.get('model')
accel = config.get('accel')
+ sec_lab = config.get('security_label')

if not typ:
typ = xoptions.netback_type
@@ -134,6 +140,8 @@ class NetifController(DevController):
back['model'] = model
if accel:
back['accel'] = accel
+ if sec_lab:
+ back['security_label'] = sec_lab

config_path = "device/%s/%d/" % (self.deviceClass, devid)
for x in back:
@@ -149,7 +157,32 @@ class NetifController(DevController):
front = { 'handle' : "%i" % devid,
'mac' : mac }

+ if security.on():
+ self.do_access_control(config)
+
return (devid, back, front)
+
+
+ def do_access_control(self, config):
+ """ do access control checking. Throws a VMError if access is denied """
+ domain_label = self.vm.get_security_label()
+ stes = XSPolicyAdminInstance().get_stes_of_vmlabel(domain_label)
+ res_label = config.get('security_label')
+ if len(stes) > 1 or res_label:
+ if not res_label:
+ raise VmError("'VIF' must be labeled")
+ (label, ssidref, policy) = \
+ security.security_label_to_details(res_label)
+ if domain_label:
+ rc = security.res_security_check_xapi(label, ssidref,
+ policy,
+ domain_label)
+ if rc == 0:
+ raise VmError("VM's access to network device denied. "
+ "Check labeling")
+ else:
+ raise VmError("VM must have a security label to access "
+ "network device")


def getDeviceConfiguration(self, devid):
@@ -160,10 +193,12 @@ class NetifController(DevController):
config_path = "device/%s/%d/" % (self.deviceClass, devid)
devinfo = ()
for x in ( 'script', 'ip', 'bridge', 'mac',
- 'type', 'vifname', 'rate', 'uuid', 'model', 'accel'):
+ 'type', 'vifname', 'rate', 'uuid', 'model', 'accel',
+ 'security_label'):
y = self.vm._readVm(config_path + x)
devinfo += (y,)
- (script, ip, bridge, mac, typ, vifname, rate, uuid, model, accel) = devinfo
+ (script, ip, bridge, mac, typ, vifname, rate, uuid,
+ model, accel, security_label) = devinfo

if script:
result['script'] = script
@@ -185,5 +220,7 @@ class NetifController(DevController):
result['model'] = model
if accel:
result['accel'] = accel
-
+ if security_label:
+ result['security_label'] = security_label
+
return result
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xend/server/tpmif.py
--- a/tools/python/xen/xend/server/tpmif.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xend/server/tpmif.py Fri Jul 27 08:15:16 2007 -0600
@@ -31,9 +31,10 @@ import re

xoptions = XendOptions.instance()

-def destroy_vtpmstate(name):
+def destroy_vtpmstate(uuids):
if os.path.exists(VTPM_DELETE_SCRIPT):
- os.system(VTPM_DELETE_SCRIPT + " " + name)
+ for uuid in uuids:
+ os.system(VTPM_DELETE_SCRIPT + " " + uuid)

class TPMifController(DevController):
"""TPM interface controller. Handles all TPM devices for a domain.
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/activatepolicy.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xm/activatepolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,86 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (C) 2007 International Business Machines Corp.
+# Author: Stefan Berger <stefanb@us.ibm.com>
+#============================================================================
+
+"""Activate the managed policy of the system.
+"""
+
+import sys
+from xen.util import xsconstants
+from xml.dom import minidom
+from xen.xm.opts import OptionError
+from xen.xm import getpolicy
+from xen.xm import main as xm_main
+from xen.xm.main import server
+
+def help():
+ return """
+ Usage: xm activatepolicy [options]
+
+ Activate the xend-managed policy.
+
+ The following options are defined:
+ --load Load the policy into the hypervisor.
+ --boot Have the system boot with the policy. Changes the default
+ title in grub.conf.
+ --noboot Remove the policy from the default entry in grub.conf.
+ """
+
+def activate_policy(flags):
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ xs_ref = policystate['xs_ref']
+ if int(policystate['type']) == 0 or xs_ref == "":
+ print "No policy is installed."
+ return
+ rc = int(server.xenapi.XSPolicy.activate_xspolicy(xs_ref, flags))
+ if rc == flags:
+ print "Successfully activated the policy."
+ else:
+ print "An error occurred trying to activate the policy: %s" % \
+ xsconstants.xserr2string(rc)
+
+def remove_bootpolicy():
+ server.xenapi.XSPolicy.rm_xsbootpolicy()
+
+def main(argv):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('xm needs to be configured to use the xen-api.')
+ flags = 0
+ c = 1
+
+ while c < len(argv):
+ if '--boot' == argv[c]:
+ flags |= xsconstants.XS_INST_BOOT
+ elif '--load' == argv[c]:
+ flags |= xsconstants.XS_INST_LOAD
+ elif '--noboot' == argv[c]:
+ remove_bootpolicy()
+ else:
+ raise OptionError("Unknown command line option '%s'" % argv[c])
+ c += 1
+
+ if flags != 0:
+ activate_policy(flags)
+
+ getpolicy.getpolicy(False)
+
+if __name__ == '__main__':
+ try:
+ main(sys.argv)
+ except Exception, e:
+ sys.stderr.write('Error: %s\n' % str(e))
+ sys.exit(-1)
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/addlabel.py
--- a/tools/python/xen/xm/addlabel.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/addlabel.py Fri Jul 27 08:15:16 2007 -0600
@@ -25,17 +25,30 @@ from xen.util import dictio
from xen.util import dictio
from xen.util import security
from xen.xm.opts import OptionError
+from xen.util import xsconstants
+from xen.xm import main as xm_main
+from xen.xm.main import server

def help():
return """
Format: xm addlabel <label> dom <configfile> [<policy>]
- xm addlabel <label> res <resource> [<policy>]
+ xm addlabel <label> mgt <domain name> [<policy type>:<policy>]
+ xm addlabel <label> res <resource> [[<policy type>:]<policy>]
+ xm addlabel <label> vif-<idx> <domain name> [<policy type>:<policy>]

This program adds an acm_label entry into the 'configfile'
- for a domain or to the global resource label file for a
- resource. It derives the policy from the running hypervisor
+ for a domain or allows to label a xend-managed domain.
+ The global resource label file for is extended with labels for
+ resources. It derives the policy from the running hypervisor
if it is not given (optional parameter). If a label already
- exists for the given domain or resource, then addlabel fails."""
+ exists for the given domain or resource, then addlabel fails.
+
+ For xend-managed domains, the 'mgt' parameter should be used and
+ the 'xm' tool must have been configured to use the xen-api for
+ communication with xen. If a policy is provided as last parameter,
+ its type must also be given. Currently only one type of policy is
+ supported and identified as 'ACM'. An example for a valid string
+ is 'ACM:xm-test'. """


def validate_config_file(configfile):
@@ -66,32 +79,47 @@ def validate_config_file(configfile):
return 1


-def add_resource_label(label, resource, policyref):
+def add_resource_label(label, resource, policyref, policy_type):
"""Adds a resource label to the global resource label file.
"""
- # sanity check: make sure this label can be instantiated later on
- ssidref = security.label2ssidref(label, policyref, 'res')
-
- #build canonical resource name
- resource = security.unify_resname(resource)
-
- # see if this resource is already in the file
- access_control = {}
- file = security.res_label_filename
- try:
- access_control = dictio.dict_read("resources", file)
- except:
- print "Resource file not found, creating new file at:"
- print "%s" % (file)
-
- if access_control.has_key(resource):
- security.err("This resource is already labeled.")
-
- # write the data to file
- new_entry = { resource : tuple([policyref, label]) }
- access_control.update(new_entry)
- dictio.dict_write(access_control, "resources", file)
-
+
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+
+ # sanity check: make sure this label can be instantiated later on
+ ssidref = security.label2ssidref(label, policyref, 'res')
+
+ #build canonical resource name
+ resource = security.unify_resname(resource,mustexist=False)
+
+ # see if this resource is already in the file
+ access_control = {}
+ fil = security.res_label_filename
+ try:
+ access_control = dictio.dict_read("resources", fil)
+ except:
+ print "Resource file not found, creating new file at:"
+ print "%s" % (fil)
+
+ if access_control.has_key(resource):
+ security.err("This resource is already labeled.")
+
+ # write the data to file
+ new_entry = { resource : tuple([policy_type, policyref, label]) }
+ access_control.update(new_entry)
+ dictio.dict_write(access_control, "resources", fil)
+ else:
+ res = [ policy_type, policyref, label ]
+ res_xapi = security.format_resource_label(res)
+ old = server.xenapi.XSPolicy.get_resource_label(resource)
+ if old == "":
+ try:
+ server.xenapi.XSPolicy.set_resource_label(resource,
+ res_xapi,
+ "")
+ except Exception, e:
+ security.err("Could not label this resource: %s" % e)
+ else:
+ security.err("'%s' is already labeled with '%s'" % (resource,old))

def add_domain_label(label, configfile, policyref):
# sanity checks: make sure this label can be instantiated later on
@@ -109,9 +137,61 @@ def add_domain_label(label, configfile,
config_fd.write(new_label)
config_fd.close()

+def add_domain_label_xapi(label, domainname, policyref, policy_type):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('Xm must be configured to use the xen-api.')
+ uuids = server.xenapi.VM.get_by_name_label(domainname)
+ if len(uuids) == 0:
+ raise OptionError('A VM with that name does not exist.')
+ if len(uuids) != 1:
+ raise OptionError('There are multiple domains with the same name.')
+ uuid = uuids[0]
+ sec_lab = "%s:%s:%s" % (policy_type, policyref, label)
+ try:
+ old_lab = server.xenapi.VM.get_security_label(uuid)
+ rc = server.xenapi.VM.set_security_label(uuid, sec_lab, old_lab)
+ except:
+ rc = -1
+ if int(rc) < 0:
+ raise OptionError('Could not label domain.')
+ else:
+ ssidref = int(rc)
+ if ssidref != 0:
+ print "Set the label of domain '%s' to '%s'. New ssidref = %08x" % \
+ (domainname,label,ssidref)
+ else:
+ print "Set the label of dormant domain '%s' to '%s'." % \
+ (domainname,label)
+
+def add_vif_label(label, vmname, idx, policyref, policy_type):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('Need to be configure for using xen-api.')
+ vm_refs = server.xenapi.VM.get_by_name_label(vmname)
+ if len(vm_refs) == 0:
+ raise OptionError('A VM with the name %s does not exist.' %
+ vmname)
+ vif_refs = server.xenapi.VM.get_VIFs(vm_refs[0])
+ if len(vif_refs) <= idx:
+ raise OptionError("Bad VIF index.")
+ vif_ref = server.xenapi.VIF.get_by_uuid(vif_refs[idx])
+ if not vif_ref:
+ print "Internal error: VIF does not exist."
+ sec_lab = "%s:%s:%s" % (policy_type, policyref, label)
+ try:
+ old_lab = server.xenapi.VIF.get_security_label(vif_ref)
+ rc = server.xenapi.VIF.set_security_label(vif_ref,
+ sec_lab, old_lab)
+ if int(rc) != 0:
+ print "Could not label the VIF."
+ else:
+ print "Successfully labeled the VIF."
+ except Exception, e:
+ print "Could not label the VIF: %s" % str(e)
+

def main(argv):
policyref = None
+ policy_type = ""
if len(argv) not in (4, 5):
raise OptionError('Needs either 2 or 3 arguments')

@@ -121,6 +201,7 @@ def main(argv):
policyref = argv[4]
elif security.on():
policyref = security.active_policy
+ policy_type = xsconstants.ACM_POLICY_ID
else:
raise OptionError("No active policy. Must specify policy on the "
"command line.")
@@ -136,11 +217,41 @@ def main(argv):
raise OptionError('Invalid config file')
else:
add_domain_label(label, configfile, policyref)
+ elif argv[2].lower() == "mgt":
+ domain = argv[3]
+ if policy_type == "":
+ tmp = policyref.split(":")
+ if len(tmp) != 2:
+ raise OptionError("Policy name in wrong format.")
+ policy_type, policyref = tmp
+ add_domain_label_xapi(label, domain, policyref, policy_type)
elif argv[2].lower() == "res":
resource = argv[3]
- add_resource_label(label, resource, policyref)
- else:
- raise OptionError('Need to specify either "dom" or "res" as '
+ if policy_type == "":
+ tmp = policyref.split(":")
+ if len(tmp) == 1:
+ policy_type = xsconstants.ACM_POLICY_ID
+ elif len(tmp) == 2:
+ policy_type, policyref = tmp
+ else:
+ raise OptionError("Policy name in wrong format.")
+ add_resource_label(label, resource, policyref, policy_type)
+ elif argv[2].lower().startswith("vif-"):
+ try:
+ idx = int(argv[2][4:])
+ if idx < 0:
+ raise
+ except:
+ raise OptionError("Bad VIF device index.")
+ vmname = argv[3]
+ if policy_type == "":
+ tmp = policyref.split(":")
+ if len(tmp) != 2:
+ raise OptionError("Policy name in wrong format.")
+ policy_type, policyref = tmp
+ add_vif_label(label, vmname, idx, policyref, policy_type)
+ else:
+ raise OptionError('Need to specify either "dom", "mgt" or "res" as '
'object to add label to.')

if __name__ == '__main__':
@@ -149,6 +260,3 @@ if __name__ == '__main__':
except Exception, e:
sys.stderr.write('Error: %s\n' % str(e))
sys.exit(-1)
-
-
-
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/cfgbootpolicy.py
--- a/tools/python/xen/xm/cfgbootpolicy.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/cfgbootpolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -31,7 +31,11 @@ from xen.util.security import boot_filen
from xen.util.security import boot_filename, altboot_filename
from xen.util.security import any_title_re, xen_kernel_re, any_module_re
from xen.util.security import empty_line_re, binary_name_re, policy_name_re
+from xen.util import xsconstants
from xen.xm.opts import OptionError
+from xen.xm import main as xm_main
+from xen.xm.main import server
+from xen.util.acmpolicy import ACMPolicy

def help():
return """
@@ -144,6 +148,40 @@ def insert_policy(boot_file, alt_boot_fi
pass
return extended_titles[0]

+def cfgbootpolicy_xapi(policy, user_title=None):
+ xstype = int(server.xenapi.XSPolicy.get_xstype())
+ if xstype & xsconstants.XS_POLICY_ACM == 0:
+ raise OptionError("ACM policy not supported on system.")
+ if user_title:
+ raise OptionError("Only the default title is supported with Xen-API.")
+
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ if int(policystate['type']) == 0:
+ print "No policy is installed."
+ return
+
+ if int(policystate['type']) != xsconstants.XS_POLICY_ACM:
+ print "Unknown policy type '%s'." % policystate['type']
+ return
+ else:
+ xml = policystate['repr']
+ xs_ref = policystate['xs_ref']
+ if not xml:
+ OptionError("No policy installed on system?")
+ acmpol = ACMPolicy(xml=xml)
+ if acmpol.get_name() != policy:
+ raise OptionError("Policy installed on system '%s' does not "
+ "match the requested policy '%s'" %
+ (acmpol.get_name(), policy))
+ flags = int(policystate['flags']) | xsconstants.XS_INST_BOOT
+ rc = int(server.xenapi.XSPolicy.activate_xspolicy(xs_ref, flags))
+ if rc == flags:
+ print "Successfully enabled the policy for having the system" \
+ " booted with."
+ else:
+ print "An error occurred during the operation: %s" % \
+ xsconstants.xserr2string(rc)
+

def main(argv):
user_kver = None
@@ -159,24 +197,27 @@ def main(argv):
if not policy_name_re.match(policy):
raise OptionError("Illegal policy name: '%s'" % policy)

- policy_file = '/'.join([policy_dir_prefix] + policy.split('.'))
- src_binary_policy_file = policy_file + ".bin"
- #check if .bin exists or if policy file exists
- if not os.path.isfile(src_binary_policy_file):
- if not os.path.isfile(policy_file + "-security_policy.xml"):
- raise OptionError("Unknown policy '%s'" % policy)
- else:
- err_msg = "Cannot find binary file for policy '%s'." % policy
- err_msg += " Please use makepolicy to create binary file."
- raise OptionError(err_msg)
-
- dst_binary_policy_file = "/boot/" + policy + ".bin"
- shutil.copyfile(src_binary_policy_file, dst_binary_policy_file)
-
- entryname = insert_policy(boot_filename, altboot_filename,
- user_title, policy)
- print "Boot entry '%s' extended and \'%s\' copied to /boot" \
- % (entryname, policy + ".bin")
+ if xm_main.serverType == xm_main.SERVER_XEN_API:
+ cfgbootpolicy_xapi(policy)
+ else:
+ policy_file = '/'.join([policy_dir_prefix] + policy.split('.'))
+ src_binary_policy_file = policy_file + ".bin"
+ #check if .bin exists or if policy file exists
+ if not os.path.isfile(src_binary_policy_file):
+ if not os.path.isfile(policy_file + "-security_policy.xml"):
+ raise OptionError("Unknown policy '%s'" % policy)
+ else:
+ err_msg = "Cannot find binary file for policy '%s'." % policy
+ err_msg += " Please use makepolicy to create binary file."
+ raise OptionError(err_msg)
+
+ dst_binary_policy_file = "/boot/" + policy + ".bin"
+ shutil.copyfile(src_binary_policy_file, dst_binary_policy_file)
+
+ entryname = insert_policy(boot_filename, altboot_filename,
+ user_title, policy)
+ print "Boot entry '%s' extended and \'%s\' copied to /boot" \
+ % (entryname, policy + ".bin")

if __name__ == '__main__':
try:
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/create.dtd
--- a/tools/python/xen/xm/create.dtd Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/create.dtd Fri Jul 27 08:15:16 2007 -0600
@@ -38,6 +38,7 @@
memory,
vbd*,
vif*,
+ vtpm*,
console*,
platform*,
vcpu_param*,
@@ -49,7 +50,8 @@
actions_after_shutdown %NORMAL_EXIT; #REQUIRED
actions_after_reboot %NORMAL_EXIT; #REQUIRED
actions_after_crash %CRASH_BEHAVIOUR; #REQUIRED
- PCI_bus CDATA #REQUIRED>
+ PCI_bus CDATA #REQUIRED
+ security_label CDATA #IMPLIED>

<!ELEMENT memory EMPTY>
<!ATTLIST memory static_min CDATA #REQUIRED
@@ -72,7 +74,11 @@
mtu CDATA #REQUIRED
device CDATA #REQUIRED
qos_algorithm_type CDATA #REQUIRED
- network CDATA #IMPLIED>
+ network CDATA #IMPLIED
+ security_label CDATA #IMPLIED>
+
+<!ELEMENT vtpm (name*)>
+<!ATTLIST vtpm backend CDATA #REQUIRED>

<!ELEMENT console (other_config*)>
<!ATTLIST console protocol (vt100|rfb|rdp) #REQUIRED>
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/create.py Fri Jul 27 08:15:16 2007 -0600
@@ -643,22 +643,12 @@ def configure_security(config, vals):
['policy', policy],
['label', label] ]

- #ssidref cannot be specified together with access_control
- if sxp.child_value(config, 'ssidref'):
- err("ERROR: SSIDREF and access_control are mutually exclusive but both specified!")
- #else calculate ssidre from label
+ #calculate ssidref from label
ssidref = security.label2ssidref(label, policy, 'dom')
if not ssidref :
err("ERROR calculating ssidref from access_control.")
security_label = ['security', [ config_access_control, ['ssidref' , ssidref ] ] ]
config.append(security_label)
- elif num == 0:
- if hasattr(vals, 'ssidref'):
- if not security.on():
- err("ERROR: Security ssidref specified but no policy active.")
- ssidref = getattr(vals, 'ssidref')
- security_label = ['security', [ [ 'ssidref' , int(ssidref) ] ] ]
- config.append(security_label)
elif num > 1:
err("VM config error: Multiple access_control definitions!")

@@ -714,7 +704,8 @@ def configure_vifs(config_devs, vals):

def f(k):
if k not in [.'backend', 'bridge', 'ip', 'mac', 'script', 'type',
- 'vifname', 'rate', 'model', 'accel']:
+ 'vifname', 'rate', 'model', 'accel',
+ 'policy', 'label']:
err('Invalid vif option: ' + k)

config_vif.append([k, d[k]])
@@ -1231,13 +1222,13 @@ def config_security_check(config, verbos

except security.ACMError:
print " %s: DENIED" % (resource)
- (res_label, res_policy) = security.get_res_label(resource)
+ (poltype, res_label, res_policy) = security.get_res_label(resource)
if not res_label:
res_label = ""
- print " --> res: %s (%s)" % (str(res_label),
- str(res_policy))
- print " --> dom: %s (%s)" % (str(domain_label),
- str(domain_policy))
+ print " --> res: %s (%s:%s)" % (str(res_label),
+ str(poltype), str(res_policy))
+ print " --> dom: %s (%s:%s)" % (str(domain_label),
+ str(poltype), str(domain_policy))

answer = 0

diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/getlabel.py
--- a/tools/python/xen/xm/getlabel.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/getlabel.py Fri Jul 27 08:15:16 2007 -0600
@@ -21,14 +21,20 @@ import sys, os, re
import sys, os, re
from xen.util import dictio
from xen.util import security
+from xen.util import xsconstants
from xen.xm.opts import OptionError
+from xen.xm import main as xm_main
+from xen.xm.main import server

def help():
return """
Usage: xm getlabel dom <configfile>
+ xm getlabel mgt <domain name>
xm getlabel res <resource>
+ xm getlabel vif-<idx> <vmname>

- This program shows the label for a domain or resource."""
+ This program shows the label for a domain, resource or virtual network
+ interface of a Xend-managed domain."""

def get_resource_label(resource):
"""Gets the resource label
@@ -37,17 +43,24 @@ def get_resource_label(resource):
resource = security.unify_resname(resource)

# read in the resource file
- file = security.res_label_filename
+ fil = security.res_label_filename
try:
- access_control = dictio.dict_read("resources", file)
+ access_control = dictio.dict_read("resources", fil)
except:
raise OptionError("Resource label file not found")

# get the entry and print label
if access_control.has_key(resource):
- policy = access_control[resource][0]
- label = access_control[resource][1]
- print "policy="+policy+",label="+label
+ tmp = access_control[resource]
+ if len(tmp) == 2:
+ policy, label = tmp
+ policytype = xsconstants.ACM_POLICY_ID
+ elif len(tmp) == 3:
+ policytype, policy, label = tmp
+ else:
+ raise security.ACMError("Resource not properly labeled. "
+ "Please relabel the resource.")
+ print policytype+":"+policy+":"+label
else:
raise security.ACMError("Resource not labeled")

@@ -89,8 +102,35 @@ def get_domain_label(configfile):
data = data.strip()
data = data.lstrip("[\'")
data = data.rstrip("\']")
- print data
+ print "policytype=%s," % xsconstants.ACM_POLICY_ID + data

+def get_vif_label(vmname, idx):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('xm needs to be configure to use the xen-api.')
+ vm_refs = server.xenapi.VM.get_by_name_label(vmname)
+ if len(vm_refs) == 0:
+ raise OptionError('A VM with the name %s does not exist.' %
+ vmname)
+ vif_refs = server.xenapi.VM.get_VIFs(vm_refs[0])
+ if len(vif_refs) <= idx:
+ raise OptionError("Bad VIF index.")
+ vif_ref = server.xenapi.VIF.get_by_uuid(vif_refs[idx])
+ if not vif_ref:
+ print "No VIF with this UUID."
+ sec_lab = server.xenapi.VIF.get_security_label(vif_ref)
+ print "%s" % sec_lab
+
+def get_domain_label_xapi(domainname):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('xm needs to be configure to use the xen-api.')
+ uuids = server.xenapi.VM.get_by_name_label(domainname)
+ if len(uuids) == 0:
+ raise OptionError('A VM with that name does not exist.')
+ if len(uuids) != 1:
+ raise OptionError('There are multiple domains with the same name.')
+ uuid = uuids[0]
+ sec_lab = server.xenapi.VM.get_security_label(uuid)
+ print "%s" %sec_lab

def main(argv):
if len(argv) != 3:
@@ -99,11 +139,24 @@ def main(argv):
if argv[1].lower() == "dom":
configfile = argv[2]
get_domain_label(configfile)
+ elif argv[1].lower() == "mgt":
+ domainname = argv[2]
+ get_domain_label_xapi(domainname)
elif argv[1].lower() == "res":
resource = argv[2]
get_resource_label(resource)
+ elif argv[1].lower().startswith("vif-"):
+ try:
+ idx = int(argv[1][4:])
+ if idx < 0:
+ raise
+ except:
+ raise OptionError("Bad VIF device index.")
+ vmname = argv[2]
+ get_vif_label(vmname, idx)
else:
- raise OptionError('First subcommand argument must be "dom" or "res"')
+ raise OptionError('First subcommand argument must be "dom"'
+ ', "mgt" or "res"')

if __name__ == '__main__':
try:
@@ -111,6 +164,4 @@ if __name__ == '__main__':
except Exception, e:
sys.stderr.write('Error: %s\n' % str(e))
sys.exit(-1)
-

-
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/getpolicy.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xm/getpolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,94 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (C) 2007 International Business Machines Corp.
+# Author: Stefan Berger <stefanb@us.ibm.com>
+#============================================================================
+
+"""Get the managed policy of the system.
+"""
+
+import sys
+from xen.util import xsconstants
+from xml.dom import minidom
+from xen.xm.opts import OptionError
+from xen.util.acmpolicy import ACMPolicy
+from xen.xm import main as xm_main
+from xen.xm.main import server
+
+def help():
+ return """
+ Usage: xm getpolicy [options]
+
+ The following options are defined
+ --dumpxml Display the XML of the policy
+
+ Get the policy managed by xend."""
+
+def getpolicy(dumpxml):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('xm needs to be configured to use the xen-api.')
+ types = []
+ xstype = int(server.xenapi.XSPolicy.get_xstype())
+ if xstype & xsconstants.XS_POLICY_ACM:
+ types.append("ACM")
+ xstype ^= xsconstants.XS_POLICY_ACM
+ if xstype != 0:
+ types.append("unsupported (%08x)" % xstype)
+ print "Supported security subsystems : %s \n" % ", ".join(types)
+
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ if int(policystate['type']) == 0:
+ print "No policy is installed."
+ return
+ if int(policystate['type']) != xsconstants.XS_POLICY_ACM:
+ print "Unknown policy type '%s'." % policystate['type']
+ else:
+ xml = policystate['repr']
+ acmpol = None
+ if xml:
+ acmpol = ACMPolicy(xml=xml)
+ print "Policy installed on the system:"
+ if acmpol:
+ print "Policy name : %s" % acmpol.get_name()
+ print "Policy type : %s" % xsconstants.ACM_POLICY_ID
+ print "Reference : %s" % policystate['xs_ref']
+ print "Version of XML policy : %s" % policystate['version']
+ state = []
+ flags = int(policystate['flags'])
+ if flags & xsconstants.XS_INST_LOAD:
+ state.append("loaded")
+ if flags & xsconstants.XS_INST_BOOT:
+ state.append("system booted with")
+ print "State of the policy : %s" % ", ".join(state)
+ if dumpxml:
+ xml = policystate['repr']
+ if xml:
+ dom = minidom.parseString(xml.encode("utf-8"))
+ print "%s" % dom.toprettyxml(indent=" ",newl="\n")
+
+def main(argv):
+ dumpxml = False
+
+ if '--dumpxml' in argv:
+ dumpxml = True
+
+ getpolicy(dumpxml)
+
+if __name__ == '__main__':
+ try:
+ main(sys.argv)
+ except Exception, e:
+ sys.stderr.write('Error: %s\n' % str(e))
+ sys.exit(-1)
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/labels.py
--- a/tools/python/xen/xm/labels.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/labels.py Fri Jul 27 08:15:16 2007 -0600
@@ -24,6 +24,10 @@ from xen.util.security import ACMError,
from xen.util.security import ACMError, err, list_labels, active_policy
from xen.util.security import vm_label_re, res_label_re, all_label_re
from xen.xm.opts import OptionError
+from xen.util.acmpolicy import ACMPolicy
+from xen.util import xsconstants
+from xen.xm.main import server
+from xen.xm import main as xm_main


def help():
@@ -48,6 +52,12 @@ def main(argv):
else:
raise OptionError('Unrecognised option: %s' % arg)

+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ labels(policy, ptype)
+ else:
+ labels_xapi(policy, ptype)
+
+def labels(policy, ptype):
if not policy:
policy = active_policy
if active_policy in ['NULL', 'INACTIVE', 'DEFAULT']:
@@ -73,7 +83,30 @@ def main(argv):
except:
traceback.print_exc(limit = 1)

+def labels_xapi(policy, ptype):
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ if int(policystate['type']) == xsconstants.XS_POLICY_ACM:
+ acmpol = ACMPolicy(xml=policystate['repr'])
+ if policy and policy != acmpol.get_name():
+ print "Warning: '%s' is not the currently loaded policy." % policy
+ return labels(policy, ptype)
+ names1 = []
+ names2 = []
+ if not ptype or ptype == 'dom' or ptype == 'any':
+ names1 = acmpol.policy_get_virtualmachinelabel_names()
+ if ptype == 'res' or ptype == 'any':
+ names2 = acmpol.policy_get_resourcelabel_names()
+ if len(names1) > 0:
+ names = set(names1)
+ names.union(names2)
+ else:
+ names = set(names2)
+ for n in names:
+ print n
+ elif int(policystate['type']) == 0:
+ print "No policy installed on the system."
+ else:
+ print "Unsupported type of policy installed on the system."
+
if __name__ == '__main__':
main(sys.argv)
-
-
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/loadpolicy.py
--- a/tools/python/xen/xm/loadpolicy.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/loadpolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -22,6 +22,11 @@ import traceback
import traceback
from xen.util.security import ACMError, err, load_policy
from xen.xm.opts import OptionError
+from xen.xm import main as xm_main
+from xen.util import xsconstants
+from xen.xm.activatepolicy import activate_policy
+from xen.xm.main import server
+from xen.util.acmpolicy import ACMPolicy

def help():
return """Load the compiled binary (.bin) policy into the running
@@ -30,8 +35,31 @@ def main(argv):
def main(argv):
if len(argv) != 2:
raise OptionError('No policy defined')
-
- load_policy(argv[1])
+ if xm_main.serverType == xm_main.SERVER_XEN_API:
+ policy = argv[1]
+ print "This command is deprecated for use with Xen-API " \
+ "configuration. Consider using\n'xm activatepolicy'."
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ if int(policystate['type']) == 0:
+ print "No policy is installed."
+ return
+
+ if int(policystate['type']) != xsconstants.XS_POLICY_ACM:
+ print "Unknown policy type '%s'." % policystate['type']
+ return
+ else:
+ xml = policystate['repr']
+ xs_ref = policystate['xs_ref']
+ if not xml:
+ OptionError("No policy installed on system?")
+ acmpol = ACMPolicy(xml=xml)
+ if acmpol.get_name() != policy:
+ OptionError("Policy installed on system '%s' does not match"\
+ " the request policy '%s'" % \
+ (acmpol.get_name(), policy))
+ activate_policy(xsconstants.XS_INST_LOAD)
+ else:
+ load_policy(argv[1])

if __name__ == '__main__':
try:
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/main.py Fri Jul 27 08:15:16 2007 -0600
@@ -50,6 +50,7 @@ from xen.xm.opts import OptionError, Opt
from xen.xm.opts import OptionError, Opts, wrap, set_true
from xen.xm import console
from xen.util.xmlrpcclient import ServerProxy
+from xen.util.security import ACMError

import XenAPI

@@ -171,11 +172,12 @@ SUBCOMMAND_HELP = {

# security

- 'addlabel' : ('<label> {dom <ConfigFile>|res <resource>} [<policy>]',
+ 'addlabel' : ('<label> {dom <ConfigFile>|res <resource>|mgt <managed domain>}\n'
+ ' [<policy>]',
'Add security label to domain.'),
- 'rmlabel' : ('{dom <ConfigFile>|res <Resource>}',
+ 'rmlabel' : ('{dom <ConfigFile>|res <Resource>|mgt<managed domain>}',
'Remove a security label from domain.'),
- 'getlabel' : ('{dom <ConfigFile>|res <Resource>}',
+ 'getlabel' : ('{dom <ConfigFile>|res <Resource>|mgt <managed domain>}',
'Show security label for domain or resource.'),
'dry-run' : ('<ConfigFile>',
'Test if a domain can access its resources.'),
@@ -186,6 +188,10 @@ SUBCOMMAND_HELP = {
'loadpolicy' : ('<policy.bin>', 'Load binary policy into hypervisor.'),
'makepolicy' : ('<policy>', 'Build policy and create .bin/.map '
'files.'),
+ 'setpolicy' : ('<policytype> <policyfile> [options]',
+ 'Set the policy of the system.'),
+ 'getpolicy' : ('[options]', 'Get the policy of the system.'),
+ 'activatepolicy': ('[options]', 'Activate the xend-managed policy.'),
'labels' : ('[policy] [type=dom|res|any]',
'List <type> labels for (active) policy.'),
'serve' : ('', 'Proxy Xend XMLRPC over stdio.'),
@@ -343,6 +349,9 @@ acm_commands = [
"loadpolicy",
"cfgbootpolicy",
"dumppolicy",
+ "activatepolicy",
+ "setpolicy",
+ "getpolicy",
]

all_commands = (domain_commands + host_commands + scheduler_commands +
@@ -861,13 +870,13 @@ def parse_doms_info(info):
'up_time' : up_time
}

- # We're not supporting security stuff just yet via XenAPI
-
- if serverType != SERVER_XEN_API:
- from xen.util import security
- parsed_info['seclabel'] = security.get_security_printlabel(info)
- else:
- parsed_info['seclabel'] = ""
+ security_label = get_info('security_label', str, '')
+ tmp = security_label.split(":")
+ if len(tmp) != 3:
+ seclabel = ""
+ else:
+ seclabel = tmp[2]
+ parsed_info['seclabel'] = seclabel

if serverType == SERVER_XEN_API:
parsed_info['mem'] = get_info('memory_actual', int, 0) / 1024
@@ -925,28 +934,26 @@ def xm_brief_list(doms):
print format % d

def xm_label_list(doms):
- print '%-32s %5s %5s %5s %5s %9s %-8s' % \
+ print '%-32s %5s %5s %5s %10s %9s %-8s' % \
('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)', 'Label')

output = []
format = '%(name)-32s %(domid)5s %(mem)5d %(vcpus)5d %(state)10s ' \
'%(cpu_time)8.1f %(seclabel)9s'

- if serverType != SERVER_XEN_API:
- from xen.util import security
+ from xen.util import security

- for dom in doms:
- d = parse_doms_info(dom)
-
- if security.active_policy not in ['INACTIVE', 'NULL', 'DEFAULT']:
- if not d['seclabel']:
- d['seclabel'] = 'ERROR'
- elif security.active_policy in ['DEFAULT']:
- d['seclabel'] = 'DEFAULT'
- else:
- d['seclabel'] = 'INACTIVE'
-
- output.append((format % d, d['seclabel']))
+ for dom in doms:
+ d = parse_doms_info(dom)
+ if security.active_policy not in ['INACTIVE', 'NULL', 'DEFAULT']:
+ if not d['seclabel']:
+ d['seclabel'] = 'ERROR'
+ elif security.active_policy in ['DEFAULT']:
+ d['seclabel'] = 'DEFAULT'
+ else:
+ d['seclabel'] = 'INACTIVE'
+
+ output.append((format % d, d['seclabel']))

#sort by labels
output.sort(lambda x,y: cmp( x[1].lower(), y[1].lower()))
@@ -1016,13 +1023,13 @@ def xm_vcpu_list(args):
if args:
dominfo = map(server.xend.domain.getVCPUInfo, args)
else:
- doms = server.xend.domains(False)
+ doms = server.xend.domains_with_state(False, 'all', False)
dominfo = map(server.xend.domain.getVCPUInfo, doms)

print '%-32s %5s %5s %5s %5s %9s %s' % \
('Name', 'ID', 'VCPU', 'CPU', 'State', 'Time(s)', 'CPU Affinity')

- format = '%(name)-32s %(domid)5d %(number)5d %(c)5s %(s)5s ' \
+ format = '%(name)-32s %(domid)5s %(number)5d %(c)5s %(s)5s ' \
' %(cpu_time)8.1f %(cpumap)s'

for dom in dominfo:
@@ -1091,8 +1098,12 @@ def xm_vcpu_list(args):

return format_pairs(list_to_rangepairs(cpumap))

- name = get_info('name')
- domid = int(get_info('domid'))
+ name = get_info('name')
+ domid = get_info('domid')
+ if domid is not None:
+ domid = str(domid)
+ else:
+ domid = ''

for vcpu in sxp.children(dom, 'vcpu'):
def vinfo(n, t):
@@ -1106,7 +1117,10 @@ def xm_vcpu_list(args):
running = vinfo('running', int)
blocked = vinfo('blocked', int)

- if online:
+ if cpu < 0:
+ c = ''
+ s = ''
+ elif online:
c = str(cpu)
if running:
s = 'r'
@@ -1118,8 +1132,8 @@ def xm_vcpu_list(args):
s += '-'
s += '-'
else:
- c = "-"
- s = "--p"
+ c = '-'
+ s = '--p'

print format % locals()

@@ -1722,14 +1736,16 @@ def xm_uptime(args):
if k in ['-s', '--short']:
short_mode = 1

- doms = getDomains(params, 'running')
+ doms = getDomains(params, 'all')

if short_mode == 0:
print '%-33s %4s %s ' % ('Name','ID','Uptime')

for dom in doms:
d = parse_doms_info(dom)
- if int(d['domid']) > 0:
+ if d['domid'] == '':
+ uptime = 0
+ elif int(d['domid']) > 0:
uptime = int(round(d['up_time']))
else:
f=open('/proc/uptime', 'r')
@@ -1989,16 +2005,24 @@ def xm_block_list(args):
% ni)

def xm_vtpm_list(args):
- xenapi_unsupported()
(use_long, params) = arg_check_for_resource_list(args, "vtpm-list")

dom = params[0]
+
+ if serverType == SERVER_XEN_API:
+ vtpm_refs = server.xenapi.VM.get_VTPMs(get_single_vm(dom))
+ vtpm_properties = \
+ map(server.xenapi.VTPM.get_runtime_properties, vtpm_refs)
+ devs = map(lambda (handle, properties): [handle, map2sxp(properties)],
+ zip(range(len(vtpm_properties)), vtpm_properties))
+ else:
+ devs = server.xend.domain.getDeviceSxprs(dom, 'vtpm')
+
if use_long:
- devs = server.xend.domain.getDeviceSxprs(dom, 'vtpm')
map(PrettyPrint.prettyprint, devs)
else:
hdr = 0
- for x in server.xend.domain.getDeviceSxprs(dom, 'vtpm'):
+ for x in devs:
if hdr == 0:
print 'Idx BE handle state evt-ch ring-ref BE-path'
hdr = 1
@@ -2028,18 +2052,6 @@ def parse_block_configuration(args):
['mode', args[3]]]
if len(args) == 5:
vbd.append(['backend', args[4]])
-
- if serverType != SERVER_XEN_API:
- # verify that policy permits attaching this resource
- from xen.util import security
-
- if security.on():
- dominfo = server.xend.domain(dom)
- label = security.get_security_printlabel(dominfo)
- else:
- label = None
-
- security.res_security_check(args[1], label)

return (dom, vbd)

@@ -2440,6 +2452,9 @@ IMPORTED_COMMANDS = [
'getlabel',
'dry-run',
'resources',
+ 'getpolicy',
+ 'setpolicy',
+ 'activatepolicy',
]

for c in IMPORTED_COMMANDS:
@@ -2563,6 +2578,8 @@ def _run_cmd(cmd, cmd_name, args):
print e.usage
except XenAPIUnsupportedException, e:
err(str(e))
+ except ACMError, e:
+ err(str(e))
except Exception, e:
if serverType != SERVER_XEN_API:
from xen.util import security
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/makepolicy.py
--- a/tools/python/xen/xm/makepolicy.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/makepolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -20,7 +20,10 @@ import sys
import sys
import traceback
from xen.util.security import ACMError, err, make_policy
+from xen.util import xsconstants
from xen.xm.opts import OptionError
+from xen.xm import main as xm_main
+from xen.xm.setpolicy import setpolicy

def usage():
print "\nUsage: xm makepolicy <policy>\n"
@@ -32,8 +35,13 @@ def main(argv):
def main(argv):
if len(argv) != 2:
raise OptionError('No XML policy file specified')
-
- make_policy(argv[1])
+ if xm_main.serverType == xm_main.SERVER_XEN_API:
+ print "This command is deprecated for use with Xen-API " \
+ "configuration. Consider using\n'xm setpolicy'."
+ setpolicy(xsconstants.ACM_POLICY_ID, argv[1],
+ xsconstants.XS_INST_LOAD, True)
+ else:
+ make_policy(argv[1])

if __name__ == '__main__':
try:
@@ -41,5 +49,3 @@ if __name__ == '__main__':
except Exception, e:
sys.stderr.write('Error: %s\n' % str(e))
sys.exit(-1)
-
-
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/resources.py
--- a/tools/python/xen/xm/resources.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/resources.py Fri Jul 27 08:15:16 2007 -0600
@@ -21,7 +21,10 @@ import sys
import sys
from xen.util import dictio
from xen.util import security
+from xen.util import xsconstants
from xen.xm.opts import OptionError
+from xen.xm import main as xm_main
+from xen.xm.main import server

def help():
return """
@@ -32,20 +35,32 @@ def print_resource_data(access_control):
"""Prints out a resource dictionary to stdout
"""
for resource in access_control:
- (policy, label) = access_control[resource]
+ tmp = access_control[resource]
+ if len(tmp) == 2:
+ policytype = xsconstants.ACM_POLICY_ID
+ (policy, label) = access_control[resource]
+ elif len(tmp) == 3:
+ policytype, policy, label = access_control[resource]
print resource
- print " policy: "+policy
- print " label: "+label
+ print " type: "+ policytype
+ print " policy: "+ policy
+ print " label: "+ label

def main (argv):
if len(argv) > 1:
raise OptionError("No arguments required")
-
- try:
- filename = security.res_label_filename
- access_control = dictio.dict_read("resources", filename)
- except:
- raise OptionError("Resource file not found")
+
+ if xm_main.serverType == xm_main.SERVER_XEN_API:
+ access_control = server.xenapi.XSPolicy.get_labeled_resources()
+ for key, value in access_control.items():
+ access_control[key] = tuple(value.split(':'))
+ else:
+ try:
+ filename = security.res_label_filename
+ access_control = dictio.dict_read("resources", filename)
+ print access_control
+ except:
+ raise OptionError("Resource file not found")

print_resource_data(access_control)

diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/rmlabel.py
--- a/tools/python/xen/xm/rmlabel.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/rmlabel.py Fri Jul 27 08:15:16 2007 -0600
@@ -22,35 +22,53 @@ from xen.util import dictio
from xen.util import dictio
from xen.util import security
from xen.xm.opts import OptionError
+from xen.xm import main as xm_main
+from xen.xm.main import server

def help():
return """
Example: xm rmlabel dom <configfile>
xm rmlabel res <resource>
+ xm rmlabel mgt <domain name>
+ xm rmlabel vif-<idx> <domain name>

This program removes an acm_label entry from the 'configfile'
- for a domain or from the global resource label file for a
- resource. If the label does not exist for the given domain or
- resource, then rmlabel fails."""
+ for a domain, from a Xend-managed domain, from the global resource label
+ file for a resource or from the virtual network interface of a Xend-managed
+ domain. If the label does not exist for the given domain or resource, then
+ rmlabel fails."""


def rm_resource_label(resource):
"""Removes a resource label from the global resource label file.
"""
+ # Try Xen-API first if configured to use it
+ if xm_main.serverType == xm_main.SERVER_XEN_API:
+ try:
+ oldlabel = server.xenapi.XSPolicy.get_resource_label(resource)
+ if oldlabel != "":
+ server.xenapi.XSPolicy.set_resource_label(resource,"",
+ oldlabel)
+ else:
+ raise security.ACMError("Resource not labeled")
+ except Exception, e:
+ print "Could not remove label from resource: %s" % e
+ return
+
#build canonical resource name
resource = security.unify_resname(resource)

# read in the resource file
- file = security.res_label_filename
+ fil = security.res_label_filename
try:
- access_control = dictio.dict_read("resources", file)
+ access_control = dictio.dict_read("resources", fil)
except:
raise security.ACMError("Resource file not found, cannot remove label!")

# remove the entry and update file
if access_control.has_key(resource):
del access_control[resource]
- dictio.dict_write(access_control, "resources", file)
+ dictio.dict_write(access_control, "resources", fil)
else:
raise security.ACMError("Resource not labeled")

@@ -58,15 +76,15 @@ def rm_domain_label(configfile):
def rm_domain_label(configfile):
# open the domain config file
fd = None
- file = None
+ fil = None
if configfile[0] == '/':
- file = configfile
- fd = open(file, "rb")
+ fil = configfile
+ fd = open(fil, "rb")
else:
for prefix in [".", "/etc/xen"]:
- file = prefix + "/" + configfile
- if os.path.isfile(file):
- fd = open(file, "rb")
+ fil = prefix + "/" + configfile
+ if os.path.isfile(fil):
+ fd = open(fil, "rb")
break
if not fd:
raise OptionError("Configuration file '%s' not found." % configfile)
@@ -93,9 +111,47 @@ def rm_domain_label(configfile):
raise security.ACMError('Domain not labeled')

# write the data back out to the file
- fd = open(file, "wb")
+ fd = open(fil, "wb")
fd.writelines(file_contents)
fd.close()
+
+def rm_domain_label_xapi(domainname):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('Need to be configure for using xen-api.')
+ uuids = server.xenapi.VM.get_by_name_label(domainname)
+ if len(uuids) == 0:
+ raise OptionError('A VM with that name does not exist.')
+ if len(uuids) != 1:
+ raise OptionError('Too many domains with the same name.')
+ uuid = uuids[0]
+ try:
+ old_lab = server.xenapi.VM.get_security_label(uuid)
+ server.xenapi.VM.set_security_label(uuid, "", old_lab)
+ except Exception, e:
+ print('Could not remove label from domain: %s' % e)
+
+def rm_vif_label(vmname, idx):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('Need to be configure for using xen-api.')
+ vm_refs = server.xenapi.VM.get_by_name_label(vmname)
+ if len(vm_refs) == 0:
+ raise OptionError('A VM with the name %s does not exist.' %
+ vmname)
+ vif_refs = server.xenapi.VM.get_VIFs(vm_refs[0])
+ if len(vif_refs) <= idx:
+ raise OptionError("Bad VIF index.")
+ vif_ref = server.xenapi.VIF.get_by_uuid(vif_refs[idx])
+ if not vif_ref:
+ print "A VIF with this UUID does not exist."
+ try:
+ old_lab = server.xenapi.VIF.get_security_label(vif_ref)
+ rc = server.xenapi.VIF.set_security_label(vif_ref, "", old_lab)
+ if int(rc) != 0:
+ print "Could not remove the label from the VIF."
+ else:
+ print "Successfully removed the label from the VIF."
+ except Exception, e:
+ print "Could not remove the label the VIF: %s" % str(e)


def main (argv):
@@ -103,15 +159,26 @@ def main (argv):
if len(argv) != 3:
raise OptionError('Requires 2 arguments')

- if argv[1].lower() not in ('dom', 'res'):
- raise OptionError('Unrecognised type argument: %s' % argv[1])
-
if argv[1].lower() == "dom":
configfile = argv[2]
rm_domain_label(configfile)
+ elif argv[1].lower() == "mgt":
+ domain = argv[2]
+ rm_domain_label_xapi(domain)
+ elif argv[1].lower().startswith("vif-"):
+ try:
+ idx = int(argv[1][4:])
+ if idx < 0:
+ raise
+ except:
+ raise OptionError("Bad VIF device index.")
+ vmname = argv[2]
+ rm_vif_label(vmname, idx)
elif argv[1].lower() == "res":
resource = argv[2]
rm_resource_label(resource)
+ else:
+ raise OptionError('Unrecognised type argument: %s' % argv[1])

if __name__ == '__main__':
try:
@@ -119,5 +186,3 @@ if __name__ == '__main__':
except Exception, e:
sys.stderr.write('Error: %s\n' % str(e))
sys.exit(-1)
-
-
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/setpolicy.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xm/setpolicy.py Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,117 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (C) 2007 International Business Machines Corp.
+# Author: Stefan Berger <stefanb@us.ibm.com>
+#============================================================================
+
+"""Get the managed policy of the system.
+"""
+
+import base64
+import struct
+import sys
+import string
+from xen.util import xsconstants
+from xen.xm.opts import OptionError
+from xen.util.security import policy_dir_prefix
+from xen.xm import main as xm_main
+from xen.xm.main import server
+
+def help():
+ return """
+ Usage: xm setpolicy <policytype> <policy> [options]
+
+ Set the policy managed by xend.
+
+ The only policytype that is currently supported is 'ACM'.
+
+ The following options are defined
+ --load Load the policy immediately
+ --boot Have the system load the policy during boot
+ """
+
+def setpolicy(policytype, policy_name, flags, overwrite):
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('xm needs to be configured to use the xen-api.')
+ if policytype != xsconstants.ACM_POLICY_ID:
+ raise OptionError("Unsupported policytype '%s'." % policytype)
+ else:
+ xs_type = xsconstants.XS_POLICY_ACM
+
+ policy_file = policy_dir_prefix + "/" + \
+ string.join(string.split(policy_name, "."), "/")
+ policy_file += "-security_policy.xml"
+
+ try:
+ f = open(policy_file,"r")
+ xml = f.read(-1)
+ f.close()
+ except:
+ raise OptionError("Not a valid policy file")
+
+ try:
+ policystate = server.xenapi.XSPolicy.set_xspolicy(xs_type,
+ xml,
+ flags,
+ overwrite)
+ except Exception, e:
+ print "An error occurred setting the policy: %s" % str(e)
+ return
+ xserr = int(policystate['xserr'])
+ if xserr != 0:
+ print "An error occurred trying to set the policy: %s" % \
+ xsconstants.xserr2string(abs(xserr))
+ errors = policystate['errors']
+ if len(errors) > 0:
+ print "Hypervisor reported errors:"
+ err = base64.b64decode(errors)
+ i = 0
+ while i + 7 < len(err):
+ code, data = struct.unpack("!ii", errors[i:i+8])
+ print "(0x%08x, 0x%08x)" % (code, data)
+ i += 8
+ else:
+ print "Successfully set the new policy."
+
+
+def main(argv):
+ if len(argv) < 3:
+ raise OptionError("Need at least 3 arguments.")
+
+ if "-?" in argv:
+ help()
+ return
+
+ policytype = argv[1]
+ policy_name = argv[2]
+
+ flags = 0
+ if '--load' in argv:
+ flags |= xsconstants.XS_INST_LOAD
+ if '--boot' in argv:
+ flags |= xsconstants.XS_INST_BOOT
+
+ overwrite = True
+ if '--nooverwrite' in argv:
+ overwrite = False
+
+ setpolicy(policytype, policy_name, flags, overwrite)
+
+if __name__ == '__main__':
+ try:
+ main(sys.argv)
+ except Exception, e:
+ sys.stderr.write('Error: %s\n' % str(e))
+ sys.exit(-1)
diff -r 37833b33ae77 -r 4492a0285bae tools/python/xen/xm/xenapi_create.py
--- a/tools/python/xen/xm/xenapi_create.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/python/xen/xm/xenapi_create.py Fri Jul 27 08:15:16 2007 -0600
@@ -25,6 +25,7 @@ from xen.xend.XendAPIConstants import XE
from xen.xend.XendAPIConstants import XEN_API_ON_NORMAL_EXIT, \
XEN_API_ON_CRASH_BEHAVIOUR
from xen.xm.opts import OptionError
+from xen.util import xsconstants

import sys
import os
@@ -308,6 +309,12 @@ class xenapi_create:
""
}

+ if vm.attributes.has_key("security_label"):
+ vm_record.update({
+ "security_label":
+ vm.attributes["security_label"].value
+ })
+
if len(vm.getElementsByTagName("pv")) > 0:
vm_record.update({
"PV_bootloader":
@@ -348,6 +355,12 @@ class xenapi_create:

self.create_vifs(vm_ref, vifs, networks)

+ # Now create vtpms
+
+ vtpms = vm.getElementsByTagName("vtpm")
+
+ self.create_vtpms(vm_ref, vtpms)
+
# Now create consoles

consoles = vm.getElementsByTagName("console")
@@ -427,7 +440,9 @@ class xenapi_create:
vif.attributes["qos_algorithm_type"].value,
"qos_algorithm_params":
get_child_nodes_as_dict(vif,
- "qos_algorithm_param", "key", "value")
+ "qos_algorithm_param", "key", "value"),
+ "security_label":
+ vif.attributes["security_label"].value
}

return server.xenapi.VIF.create(vif_record)
@@ -440,6 +455,21 @@ class xenapi_create:
except IndexError:
self._network_refs = server.xenapi.network.get_all()
return self._network_refs.pop(0)
+
+ def create_vtpms(self, vm_ref, vtpms):
+ if len(vtpms) > 1:
+ vtpms = [ vtpms[0] ]
+ log(DEBUG, "create_vtpms")
+ return map(lambda vtpm: self.create_vtpm(vm_ref, vtpm), vtpms)
+
+ def create_vtpm(self, vm_ref, vtpm):
+ vtpm_record = {
+ "VM":
+ vm_ref,
+ "backend":
+ vtpm.attributes["backend"].value
+ }
+ return server.xenapi.VTPM.create(vtpm_record)

def create_consoles(self, vm_ref, consoles):
log(DEBUG, "create_consoles")
@@ -482,6 +512,10 @@ class sxp2xml:

vifs_sxp = map(lambda x: x[1], [device for device in devices
if device[1][0] == "vif"])
+
+ vtpms_sxp = map(lambda x: x[1], [device for device in devices
+ if device[1][0] == "vtpm"])
+
# Create XML Document

impl = getDOMImplementation()
@@ -530,6 +564,14 @@ class sxp2xml:
= str(get_child_by_name(config, "vcpus", 1))
vm.attributes["vcpus_at_startup"] \
= str(get_child_by_name(config, "vcpus", 1))
+
+ sec_data = get_child_by_name(config, "security")
+ if sec_data:
+ try :
+ vm.attributes['security_label'] = \
+ "%s:%s:%s" % (xsconstants.ACM_POLICY_ID, sec_data[0][1][1],sec_data[0][2][1])
+ except Exception, e:
+ raise "Invalid security data format: %s" % str(sec_data)

# Make the name tag

@@ -601,6 +643,12 @@ class sxp2xml:

map(vm.appendChild, vifs)

+ # And now the vTPMs
+
+ vtpms = map(lambda vtpm: self.extract_vtpm(vtpm, document), vtpms_sxp)
+
+ map(vm.appendChild, vtpms)
+
# Last but not least the consoles...

consoles = self.extract_consoles(image, document)
@@ -702,11 +750,29 @@ class sxp2xml:
vif.attributes["device"] = dev
vif.attributes["qos_algorithm_type"] = ""

+ policy = get_child_by_name(vif_sxp, "policy")
+ label = get_child_by_name(vif_sxp, "label")
+
+ if label and policy:
+ vif.attributes["security_label"] \
+ = "%s:%s:%s" % (xsconstants.ACM_POLICY_ID, policy, label)
+ else:
+ vif.attributes["security_label"] = ""
+
if get_child_by_name(vif_sxp, "bridge") is not None:
vif.attributes["network"] \
= get_child_by_name(vif_sxp, "bridge")

return vif
+
+ def extract_vtpm(self, vtpm_sxp, document):
+
+ vtpm = document.createElement("vtpm")
+
+ vtpm.attributes["backend"] \
+ = get_child_by_name(vtpm_sxp, "backend", "0")
+
+ return vtpm

_eths = -1

diff -r 37833b33ae77 -r 4492a0285bae tools/security/policies/security_policy.xsd
--- a/tools/security/policies/security_policy.xsd Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/security/policies/security_policy.xsd Fri Jul 27 08:15:16 2007 -0600
@@ -99,7 +99,7 @@
<xsd:sequence>
<xsd:element name="Name" type="NameWithFrom"></xsd:element>
<xsd:element ref="SimpleTypeEnforcementTypes" minOccurs="0" maxOccurs="unbounded" />
- <xsd:element name="ChineseWallTypes" type="SingleChineseWallType" />
+ <xsd:element ref="ChineseWallTypes" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
@@ -143,9 +143,4 @@
<xsd:element maxOccurs="1" minOccurs="1" ref="Type" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="SingleChineseWallType">
- <xsd:sequence>
- <xsd:element maxOccurs="1" minOccurs="1" ref="Type" />
- </xsd:sequence>
- </xsd:complexType>
</xsd:schema>
diff -r 37833b33ae77 -r 4492a0285bae tools/vtpm_manager/util/hashtable_itr.c
--- a/tools/vtpm_manager/util/hashtable_itr.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/vtpm_manager/util/hashtable_itr.c Fri Jul 27 08:15:16 2007 -0600
@@ -225,7 +225,7 @@ hashtable_iterator_search(struct hashtab

egress:
#ifdef HASHTABLE_THREADED
- pthread_mutex_lock(&h->mutex);
-#endif
- return ret;
-}
+ pthread_mutex_unlock(&h->mutex);
+#endif
+ return ret;
+}
diff -r 37833b33ae77 -r 4492a0285bae tools/xcutils/xc_save.c
--- a/tools/xcutils/xc_save.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xcutils/xc_save.c Fri Jul 27 08:15:16 2007 -0600
@@ -54,7 +54,17 @@ static int suspend(int domid)

static char *qemu_active_path;
static char *qemu_next_active_path;
+static int qemu_shmid = -1;
static struct xs_handle *xs;
+
+
+/* Mark the shared-memory segment for destruction */
+static void qemu_destroy_buffer(void)
+{
+ if (qemu_shmid != -1)
+ shmctl(qemu_shmid, IPC_RMID, NULL);
+ qemu_shmid = -1;
+}

/* Get qemu to change buffers. */
static void qemu_flip_buffer(int domid, int next_active)
@@ -97,22 +107,23 @@ static void * init_qemu_maps(int domid,
{
key_t key;
char key_ascii[17] = {0,};
- int shmid = -1;
void *seg;
char *path, *p;

/* Make a shared-memory segment */
- while (shmid == -1)
- {
+ do {
key = rand(); /* No security, just a sequence of numbers */
- shmid = shmget(key, 2 * bitmap_size,
+ qemu_shmid = shmget(key, 2 * bitmap_size,
IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR);
- if (shmid == -1 && errno != EEXIST)
+ if (qemu_shmid == -1 && errno != EEXIST)
errx(1, "can't get shmem to talk to qemu-dm");
- }
+ } while (qemu_shmid == -1);
+
+ /* Remember to tidy up after ourselves */
+ atexit(qemu_destroy_buffer);

/* Map it into our address space */
- seg = shmat(shmid, NULL, 0);
+ seg = shmat(qemu_shmid, NULL, 0);
if (seg == (void *) -1)
errx(1, "can't map shmem to talk to qemu-dm");
memset(seg, 0, 2 * bitmap_size);
@@ -123,11 +134,13 @@ static void * init_qemu_maps(int domid,
/* Tell qemu about it */
if ((xs = xs_daemon_open()) == NULL)
errx(1, "Couldn't contact xenstore");
- if (!(path = xs_get_domain_path(xs, domid)))
+ if (!(path = strdup("/local/domain/0/device-model/")))
errx(1, "can't get domain path in store");
if (!(path = realloc(path, strlen(path)
+ + 10
+ strlen("/logdirty/next-active") + 1)))
errx(1, "no memory for constructing xenstore path");
+ snprintf(path + strlen(path), 11, "%i", domid);
strcat(path, "/logdirty/");
p = path + strlen(path);

diff -r 37833b33ae77 -r 4492a0285bae tools/xenfb/vncfb.c
--- a/tools/xenfb/vncfb.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xenfb/vncfb.c Fri Jul 27 08:15:16 2007 -0600
@@ -55,11 +55,46 @@ unsigned char keycode_table[512];
unsigned char keycode_table[512];

static void *kbd_layout;
+uint8_t modifiers_state[256];

static int btnmap[] = {
BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_SIDE,
BTN_EXTRA, BTN_FORWARD, BTN_BACK, BTN_TASK
};
+
+static void press_key_shift_down(struct xenfb* xenfb, int down, int scancode)
+{
+ if (down)
+ xenfb_send_key(xenfb, 1, keycode_table[0x2a]);
+
+ if (xenfb_send_key(xenfb, down, keycode_table[scancode]) < 0)
+ fprintf(stderr, "Key %d %s lost (%s)\n",
+ scancode, "down", strerror(errno));
+
+ if (!down)
+ xenfb_send_key(xenfb, 0, keycode_table[0x2a]);
+}
+
+static void press_key_shift_up(struct xenfb* xenfb, int down, int scancode)
+{
+ if (down) {
+ if (modifiers_state[0x2a])
+ xenfb_send_key(xenfb, 0, keycode_table[0x2a]);
+ if (modifiers_state[0x36])
+ xenfb_send_key(xenfb, 0, keycode_table[0x36]);
+ }
+
+ if (xenfb_send_key(xenfb, down, keycode_table[scancode]) < 0)
+ fprintf(stderr, "Key %d %s lost (%s)\n",
+ scancode, "down", strerror(errno));
+
+ if (!down) {
+ if (modifiers_state[0x2a])
+ xenfb_send_key(xenfb, 1, keycode_table[0x2a]);
+ if (modifiers_state[0x36])
+ xenfb_send_key(xenfb, 1, keycode_table[0x36]);
+ }
+}

static void on_kbd_event(rfbBool down, rfbKeySym keycode, rfbClientPtr cl)
{
@@ -75,14 +110,75 @@ static void on_kbd_event(rfbBool down, r
rfbScreenInfoPtr server = cl->screen;
struct xenfb *xenfb = server->screenData;
int scancode;
-
- if (keycode >= 'A' && keycode <= 'Z')
+ int shift = 0;
+ int shift_keys = 0;
+
+ if (keycode >= 'A' && keycode <= 'Z') {
keycode += 'a' - 'A';
-
- scancode = keycode_table[keysym2scancode(kbd_layout, keycode)];
+ shift = 1;
+ }
+ else {
+ shift = keysymIsShift(kbd_layout, keycode);
+ }
+ shift_keys = modifiers_state[0x2a] | modifiers_state[0x36];
+
+ scancode = keysym2scancode(kbd_layout, keycode);
if (scancode == 0)
return;
- if (xenfb_send_key(xenfb, down, scancode) < 0)
+
+ switch(scancode) {
+ case 0x2a: /* Left Shift */
+ case 0x36: /* Right Shift */
+ case 0x1d: /* Left CTRL */
+ case 0x9d: /* Right CTRL */
+ case 0x38: /* Left ALT */
+ case 0xb8: /* Right ALT */
+ if (down)
+ modifiers_state[scancode] = 1;
+ else
+ modifiers_state[scancode] = 0;
+ xenfb_send_key(xenfb, down, keycode_table[scancode]);
+ return;
+ case 0x45: /* NumLock */
+ if (!down)
+ modifiers_state[scancode] ^= 1;
+ xenfb_send_key(xenfb, down, keycode_table[scancode]);
+ return;
+ }
+
+ if (keycodeIsKeypad(kbd_layout, scancode)) {
+ /* If the numlock state needs to change then simulate an additional
+ keypress before sending this one. This will happen if the user
+ toggles numlock away from the VNC window.
+ */
+ if (keysymIsNumlock(kbd_layout, keycode)) {
+ if (!modifiers_state[0x45]) {
+ modifiers_state[0x45] = 1;
+ xenfb_send_key(xenfb, 1, keycode_table[0x45]);
+ xenfb_send_key(xenfb, 0, keycode_table[0x45]);
+ }
+ } else {
+ if (modifiers_state[0x45]) {
+ modifiers_state[0x45] = 0;
+ xenfb_send_key(xenfb, 1, keycode_table[0x45]);
+ xenfb_send_key(xenfb, 0, keycode_table[0x45]);
+ }
+ }
+ }
+
+ /* If the shift state needs to change then simulate an additional
+ keypress before sending this one.
+ */
+ if (shift && !shift_keys) {
+ press_key_shift_down(xenfb, down, scancode);
+ return;
+ }
+ else if (!shift && shift_keys) {
+ press_key_shift_up(xenfb, down, scancode);
+ return;
+ }
+
+ if (xenfb_send_key(xenfb, down, keycode_table[scancode]) < 0)
fprintf(stderr, "Key %d %s lost (%s)\n",
scancode, down ? "down" : "up",
strerror(errno));
@@ -314,6 +410,10 @@ int main(int argc, char **argv)
atkbd_set2_keycode[atkbd_unxlate_table[i] | 0x80];
}

+ for (i = 0; i < 256; i++ ) {
+ modifiers_state[i] = 0;
+ }
+
fake_argv[2] = portstr;

if (title != NULL)
diff -r 37833b33ae77 -r 4492a0285bae tools/xenstore/talloc.c
--- a/tools/xenstore/talloc.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xenstore/talloc.c Fri Jul 27 08:15:16 2007 -0600
@@ -97,6 +97,7 @@ struct talloc_chunk {
struct talloc_chunk *next, *prev;
struct talloc_chunk *parent, *child;
struct talloc_reference_handle *refs;
+ unsigned int null_refs; /* references from null_context */
talloc_destructor_t destructor;
const char *name;
size_t size;
@@ -189,6 +190,7 @@ void *_talloc(const void *context, size_
tc->child = NULL;
tc->name = NULL;
tc->refs = NULL;
+ tc->null_refs = 0;

if (context) {
struct talloc_chunk *parent = talloc_chunk_from_ptr(context);
@@ -225,7 +227,11 @@ void talloc_set_destructor(const void *p
*/
void talloc_increase_ref_count(const void *ptr)
{
- talloc_reference(null_context, ptr);
+ struct talloc_chunk *tc;
+ if (ptr == NULL) return;
+
+ tc = talloc_chunk_from_ptr(ptr);
+ tc->null_refs++;
}

/*
@@ -285,6 +291,11 @@ static int talloc_unreference(const void

if (context == NULL) {
context = null_context;
+ }
+
+ if ((context == null_context) && tc->null_refs) {
+ tc->null_refs--;
+ return 0;
}

for (h=tc->refs;h;h=h->next) {
@@ -538,6 +549,11 @@ int talloc_free(void *ptr)
}

tc = talloc_chunk_from_ptr(ptr);
+
+ if (tc->null_refs) {
+ tc->null_refs--;
+ return -1;
+ }

if (tc->refs) {
talloc_reference_destructor(tc->refs);
diff -r 37833b33ae77 -r 4492a0285bae tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xenstore/xenstored_core.c Fri Jul 27 08:15:16 2007 -0600
@@ -299,10 +299,14 @@ static void set_fd(int fd, fd_set *set,
}


-static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock)
-{
- struct connection *i;
+static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock,
+ struct timeval **ptimeout)
+{
+ static struct timeval zero_timeout = { 0 };
+ struct connection *conn;
int max = -1;
+
+ *ptimeout = NULL;

FD_ZERO(inset);
FD_ZERO(outset);
@@ -314,13 +318,19 @@ static int initialize_set(fd_set *inset,
if (xce_handle != -1)
set_fd(xc_evtchn_fd(xce_handle), inset, &max);

- list_for_each_entry(i, &connections, list) {
- if (i->domain)
- continue;
- set_fd(i->fd, inset, &max);
- if (!list_empty(&i->out_list))
- FD_SET(i->fd, outset);
- }
+ list_for_each_entry(conn, &connections, list) {
+ if (conn->domain) {
+ if (domain_can_read(conn) ||
+ (domain_can_write(conn) &&
+ !list_empty(&conn->out_list)))
+ *ptimeout = &zero_timeout;
+ } else {
+ set_fd(conn->fd, inset, &max);
+ if (!list_empty(&conn->out_list))
+ FD_SET(conn->fd, outset);
+ }
+ }
+
return max;
}

@@ -1256,7 +1266,7 @@ static void handle_input(struct connecti
if (in->inhdr) {
bytes = conn->read(conn, in->hdr.raw + in->used,
sizeof(in->hdr) - in->used);
- if (bytes <= 0)
+ if (bytes < 0)
goto bad_client;
in->used += bytes;
if (in->used != sizeof(in->hdr))
@@ -1278,7 +1288,7 @@ static void handle_input(struct connecti

bytes = conn->read(conn, in->buffer + in->used,
in->hdr.msg.len - in->used);
- if (bytes <= 0)
+ if (bytes < 0)
goto bad_client;

in->used += bytes;
@@ -1331,12 +1341,40 @@ struct connection *new_connection(connwr

static int writefd(struct connection *conn, const void *data, unsigned int len)
{
- return write(conn->fd, data, len);
+ int rc;
+
+ while ((rc = write(conn->fd, data, len)) < 0) {
+ if (errno == EAGAIN) {
+ rc = 0;
+ break;
+ }
+ if (errno != EINTR)
+ break;
+ }
+
+ return rc;
}

static int readfd(struct connection *conn, void *data, unsigned int len)
{
- return read(conn->fd, data, len);
+ int rc;
+
+ while ((rc = read(conn->fd, data, len)) < 0) {
+ if (errno == EAGAIN) {
+ rc = 0;
+ break;
+ }
+ if (errno != EINTR)
+ break;
+ }
+
+ /* Reading zero length means we're done with this connection. */
+ if ((rc == 0) && (len != 0)) {
+ errno = EBADF;
+ rc = -1;
+ }
+
+ return rc;
}

static void accept_connection(int sock, bool canwrite)
@@ -1429,13 +1467,13 @@ static unsigned int hash_from_key_fn(voi
static unsigned int hash_from_key_fn(void *k)
{
char *str = k;
- unsigned int hash = 5381;
- char c;
-
- while ((c = *str++))
+ unsigned int hash = 5381;
+ char c;
+
+ while ((c = *str++))
hash = ((hash << 5) + hash) + (unsigned int)c;

- return hash;
+ return hash;
}


@@ -1709,6 +1747,7 @@ int main(int argc, char *argv[])
bool no_domain_init = false;
const char *pidfile = NULL;
int evtchn_fd = -1;
+ struct timeval *timeout;

while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:T:RLVW:", options,
NULL)) != -1) {
@@ -1850,17 +1889,16 @@ int main(int argc, char *argv[])
evtchn_fd = xc_evtchn_fd(xce_handle);

/* Get ready to listen to the tools. */
- max = initialize_set(&inset, &outset, *sock, *ro_sock);
+ max = initialize_set(&inset, &outset, *sock, *ro_sock, &timeout);

/* Tell the kernel we're up and running. */
xenbus_notify_running();

/* Main loop. */
- /* FIXME: Rewrite so noone can starve. */
for (;;) {
- struct connection *i;
-
- if (select(max+1, &inset, &outset, NULL, NULL) < 0) {
+ struct connection *conn, *old_conn;
+
+ if (select(max+1, &inset, &outset, NULL, timeout) < 0) {
if (errno == EINTR)
continue;
barf_perror("Select failed");
@@ -1882,41 +1920,31 @@ int main(int argc, char *argv[])
if (evtchn_fd != -1 && FD_ISSET(evtchn_fd, &inset))
handle_event();

- list_for_each_entry(i, &connections, list) {
- if (i->domain)
- continue;
-
- /* Operations can delete themselves or others
- * (xs_release): list is not safe after input,
- * so break. */
- if (FD_ISSET(i->fd, &inset)) {
- handle_input(i);
- break;
+ conn = list_entry(connections.next, typeof(*conn), list);
+ while (&conn->list != &connections) {
+ talloc_increase_ref_count(conn);
+
+ if (conn->domain) {
+ if (domain_can_read(conn))
+ handle_input(conn);
+ if (domain_can_write(conn) &&
+ !list_empty(&conn->out_list))
+ handle_output(conn);
+ } else {
+ if (FD_ISSET(conn->fd, &inset))
+ handle_input(conn);
+ if (FD_ISSET(conn->fd, &outset))
+ handle_output(conn);
}
- if (FD_ISSET(i->fd, &outset)) {
- handle_output(i);
- break;
- }
- }
-
- /* Handle all possible I/O for domain connections. */
- more:
- list_for_each_entry(i, &connections, list) {
- if (!i->domain)
- continue;
-
- if (domain_can_read(i)) {
- handle_input(i);
- goto more;
- }
-
- if (domain_can_write(i) && !list_empty(&i->out_list)) {
- handle_output(i);
- goto more;
- }
- }
-
- max = initialize_set(&inset, &outset, *sock, *ro_sock);
+
+ old_conn = conn;
+ conn = list_entry(old_conn->list.next,
+ typeof(*conn), list);
+ talloc_free(old_conn);
+ }
+
+ max = initialize_set(&inset, &outset, *sock, *ro_sock,
+ &timeout);
}
}

diff -r 37833b33ae77 -r 4492a0285bae tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xenstore/xenstored_domain.c Fri Jul 27 08:15:16 2007 -0600
@@ -76,7 +76,6 @@ struct domain

static LIST_HEAD(domains);

-/* FIXME: Mark connection as broken (close it?) when this happens. */
static bool check_indexes(XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod)
{
return ((prod - cons) <= XENSTORE_RING_SIZE);
@@ -102,7 +101,8 @@ static const void *get_input_chunk(XENST
return buf + MASK_XENSTORE_IDX(cons);
}

-static int writechn(struct connection *conn, const void *data, unsigned int len)
+static int writechn(struct connection *conn,
+ const void *data, unsigned int len)
{
uint32_t avail;
void *dest;
@@ -113,6 +113,7 @@ static int writechn(struct connection *c
cons = intf->rsp_cons;
prod = intf->rsp_prod;
mb();
+
if (!check_indexes(cons, prod)) {
errno = EIO;
return -1;
@@ -174,6 +175,8 @@ static int destroy_domain(void *_domain)

if (domain->interface)
munmap(domain->interface, getpagesize());
+
+ fire_watches(NULL, "@releaseDomain", false);

return 0;
}
@@ -197,7 +200,7 @@ static void domain_cleanup(void)
continue;
}
talloc_free(domain->conn);
- notify = 1;
+ notify = 0; /* destroy_domain() fires the watch */
}

if (notify)
@@ -246,7 +249,6 @@ static struct domain *new_domain(void *c
{
struct domain *domain;
int rc;
-

domain = talloc(context, struct domain);
domain->port = 0;
@@ -361,7 +363,7 @@ void do_introduce(struct connection *con
/* Now domain belongs to its connection. */
talloc_steal(domain->conn, domain);

- fire_watches(conn, "@introduceDomain", false);
+ fire_watches(NULL, "@introduceDomain", false);
} else if ((domain->mfn == mfn) && (domain->conn != conn)) {
/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
if (domain->port)
@@ -413,8 +415,6 @@ void do_release(struct connection *conn,
}

talloc_free(domain->conn);
-
- fire_watches(conn, "@releaseDomain", false);

send_ack(conn, XS_RELEASE);
}
diff -r 37833b33ae77 -r 4492a0285bae tools/xenstore/xenstored_watch.c
--- a/tools/xenstore/xenstored_watch.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xenstore/xenstored_watch.c Fri Jul 27 08:15:16 2007 -0600
@@ -73,11 +73,10 @@ static void add_event(struct connection
data = talloc_array(watch, char, len);
strcpy(data, name);
strcpy(data + strlen(name) + 1, watch->token);
- send_reply(conn, XS_WATCH_EVENT, data, len);
+ send_reply(conn, XS_WATCH_EVENT, data, len);
talloc_free(data);
}

-/* FIXME: we fail to fire on out of memory. Should drop connections. */
void fire_watches(struct connection *conn, const char *name, bool recurse)
{
struct connection *i;
@@ -130,7 +129,7 @@ void do_watch(struct connection *conn, s
/* Check for duplicates. */
list_for_each_entry(watch, &conn->watches, list) {
if (streq(watch->node, vec[0]) &&
- streq(watch->token, vec[1])) {
+ streq(watch->token, vec[1])) {
send_error(conn, EEXIST);
return;
}
diff -r 37833b33ae77 -r 4492a0285bae tools/xenstore/xsls.c
--- a/tools/xenstore/xsls.c Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xenstore/xsls.c Fri Jul 27 08:15:16 2007 -0600
@@ -8,6 +8,7 @@
#include <sys/ioctl.h>
#include <termios.h>

+#define STRING_MAX PATH_MAX
static int max_width = 80;
static int desired_width = 60;

@@ -19,7 +20,8 @@ void print_dir(struct xs_handle *h, char
void print_dir(struct xs_handle *h, char *path, int cur_depth, int show_perms)
{
char **e;
- char newpath[512], *val;
+ char newpath[STRING_MAX], *val;
+ int newpath_len;
int i;
unsigned int num, len;

@@ -33,13 +35,26 @@ void print_dir(struct xs_handle *h, char
unsigned int nperms;
int linewid;

- for (linewid=0; linewid<cur_depth; linewid++) putchar(' ');
+ /* Print indent and path basename */
+ for (linewid=0; linewid<cur_depth; linewid++) {
+ putchar(' ');
+ }
linewid += printf("%.*s",
(int) (max_width - TAG_LEN - linewid), e[i]);
- sprintf(newpath, "%s%s%s", path,
+
+ /* Compose fullpath and fetch value */
+ newpath_len = snprintf(newpath, sizeof(newpath), "%s%s%s", path,
path[strlen(path)-1] == '/' ? "" : "/",
e[i]);
- val = xs_read(h, XBT_NULL, newpath, &len);
+ if ( newpath_len < sizeof(newpath) ) {
+ val = xs_read(h, XBT_NULL, newpath, &len);
+ }
+ else {
+ /* Path was truncated and thus invalid */
+ val = NULL;
+ }
+
+ /* Print value */
if (val == NULL) {
printf(":\n");
}
@@ -88,7 +103,7 @@ void print_dir(struct xs_handle *h, char

void usage(int argc, char *argv[])
{
- fprintf(stderr, "Usage: %s [-p] [path]\n", argv[0]);
+ fprintf(stderr, "Usage: %s [-w] [-p] [path]\n", argv[0]);
}

int main(int argc, char *argv[])
@@ -104,11 +119,14 @@ int main(int argc, char *argv[])
if (!ret)
max_width = ws.ws_col - PAD;

- while (0 < (c = getopt(argc, argv, "ps"))) {
+ while (0 < (c = getopt(argc, argv, "psw"))) {
switch (c) {
+ case 'w':
+ max_width= STRING_MAX - PAD;
+ desired_width = 0;
+ break;
case 'p':
show_perm = 1;
- max_width -= 16;
break;
case 's':
socket = 1;
@@ -121,6 +139,11 @@ int main(int argc, char *argv[])
}
}

+ /* Adjust the width here to avoid argument order dependency */
+ if ( show_perm ) {
+ max_width -= 16;
+ }
+
xsh = socket ? xs_daemon_open() : xs_domain_open();
if (xsh == NULL)
err(1, socket ? "xs_daemon_open" : "xs_domain_open");
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/lib/XmTestLib/XenAPIDomain.py
--- a/tools/xm-test/lib/XmTestLib/XenAPIDomain.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/lib/XmTestLib/XenAPIDomain.py Fri Jul 27 08:15:16 2007 -0600
@@ -23,6 +23,7 @@ import sys
import sys
from XmTestLib import *
from types import DictType
+from acm import *


class XenAPIConfig:
@@ -38,6 +39,9 @@ class XenAPIConfig:
'kernel' : 'PV_kernel',
'ramdisk': 'PV_ramdisk',
'root' : 'PV_args'}
+ if isACMEnabled():
+ #A default so every VM can start with ACM enabled
+ self.opts["security_label"] = "ACM:xm-test:red"

def setOpt(self, name, value):
"""Set an option in the config"""
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/lib/XmTestLib/acm.py
--- a/tools/xm-test/lib/XmTestLib/acm.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/lib/XmTestLib/acm.py Fri Jul 27 08:15:16 2007 -0600
@@ -19,6 +19,9 @@
"""
from Test import *
from xen.util import security
+from xen.xm.main import server
+from xen.util import xsconstants
+import re

try:
from acm_config import *
@@ -32,16 +35,47 @@ def isACMEnabled():
return security.on()


+def getSystemPolicyName():
+ s,o = traceCommand("xm getpolicy")
+ m = re.compile("Policy name[\s]*: ([A-z\-]+)").search(o)
+ if m:
+ polname = m.group(1)
+ return polname
+ return ""
+
+
+def ACMLoadPolicy_XenAPI(policy='xm-test'):
+ polname = getSystemPolicyName()
+ if polname != policy:
+ # Try it, maybe it's not activated
+ traceCommand("xm setpolicy %s %s" %
+ (xsconstants.XS_POLICY_ACM, policy))
+ polname = getSystemPolicyName()
+ if polname != policy:
+ FAIL("Need to have a system with no or policy '%s' active, "
+ "not %s" % (policy,polname))
+ else:
+ s, o = traceCommand("xm activatepolicy --load")
+ else:
+ s, o = traceCommand("xm activatepolicy --load")
+ if not re.search("Successfully", o):
+ FAIL("Could not set the policy '%s'." % policy)
+
+
def ACMLoadPolicy(policy='xm-test'):
- s, o = traceCommand("xm makepolicy %s" % (policy))
- if s != 0:
- FAIL("Need to be able to do 'xm makepolicy %s' but could not" %
- (policy))
- s, o = traceCommand("xm loadpolicy %s" % (policy))
- if s != 0:
- FAIL("Could not load the required policy '%s'.\n"
- "Start the system without any policy.\n%s" %
- (policy, o))
+ from xen.xm import main
+ if main.serverType == main.SERVER_XEN_API:
+ ACMLoadPolicy_XenAPI()
+ else:
+ s, o = traceCommand("xm makepolicy %s" % (policy))
+ if s != 0:
+ FAIL("Need to be able to do 'xm makepolicy %s' but could not" %
+ (policy))
+ s, o = traceCommand("xm loadpolicy %s" % (policy))
+ if s != 0:
+ FAIL("Could not load the required policy '%s'.\n"
+ "Start the system without any policy.\n%s" %
+ (policy, o))

def ACMPrepareSystem(resources):
if isACMEnabled():
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/security-acm/01_security-acm_basic.py
--- a/tools/xm-test/tests/security-acm/01_security-acm_basic.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/security-acm/01_security-acm_basic.py Fri Jul 27 08:15:16 2007 -0600
@@ -15,6 +15,7 @@

from XmTestLib import *
from xen.util import security
+from xen.util import xsconstants
import commands
import os
import re
@@ -28,7 +29,7 @@ if not isACMEnabled():
SKIP("Not running this test since ACM not enabled.")

status, output = traceCommand("xm makepolicy %s" % (testpolicy))
-if status != 0 or output != "":
+if status != 0:
FAIL("'xm makepolicy' failed with status %d and output\n%s" %
(status,output));

@@ -47,7 +48,7 @@ status, output = traceCommand("xm addlab
status, output = traceCommand("xm addlabel %s dom %s %s" %
(testlabel, vmconfigfile, testpolicy))
if status != 0:
- FAIL("'xm addlabel' failed with status %d.\n" % status)
+ FAIL("(1) 'xm addlabel' failed with status %d.\n" % status)

status, output = traceCommand("xm getlabel dom %s" %
(vmconfigfile))
@@ -55,8 +56,9 @@ if status != 0:
if status != 0:
FAIL("'xm getlabel' failed with status %d, output:\n%s" %
(status, output))
-if output != "policy=%s,label=%s" % (testpolicy,testlabel):
- FAIL("Received unexpected output from 'xm getlabel': \n%s" %
+if output != "policytype=%s,policy=%s,label=%s" % \
+ (xsconstants.ACM_POLICY_ID, testpolicy, testlabel):
+ FAIL("(1) Received unexpected output from 'xm getlabel dom': \n%s" %
(output))


@@ -74,30 +76,34 @@ status, output = traceCommand("xm getlab
(vmconfigfile))

if output != "Error: 'Domain not labeled'":
- FAIL("Received unexpected output from 'xm getlabel': \n%s" %
+ FAIL("(2) Received unexpected output from 'xm getlabel dom': \n%s" %
(output))

#Whatever label the resource might have, remove it
status, output = traceCommand("xm rmlabel res %s" %
(testresource))
+if status != 0:
+ FAIL("'xm rmlabel' on resource failed with status %d.\n" % status)

status, output = traceCommand("xm addlabel %s res %s %s" %
(testlabel, testresource, testpolicy))
if status != 0:
- FAIL("'xm addlabel' on resource failed with status %d.\n" % status)
+ FAIL("(2) 'xm addlabel' on resource failed with status %d.\n" % status)

status, output = traceCommand("xm getlabel res %s" % (testresource))

if status != 0:
FAIL("'xm getlabel' on resource failed with status %d, output:\n%s" %
(status, output))
-if output != "policy=%s,label=%s" % (testpolicy,testlabel):
- FAIL("Received unexpected output from 'xm getlabel': \n%s" %
+if output != "%s:%s:%s" % (xsconstants.ACM_POLICY_ID,\
+ testpolicy,testlabel):
+ FAIL("Received unexpected output from 'xm getlabel res': \n%s" %
(output))

status, output = traceCommand("xm resources")

if status != 0:
+ print "status = %s" % str(status)
FAIL("'xm resources' did not run properly")
if not re.search(security.unify_resname(testresource), output):
FAIL("'xm resources' did not show the tested resource '%s'." %
@@ -117,5 +123,5 @@ status, output = traceCommand("xm getlab
(testresource))

if output != "Error: 'Resource not labeled'":
- FAIL("Received unexpected output from 'xm getlabel': \n%s" %
+ FAIL("Received unexpected output from 'xm getlabel res': \n%s" %
(output))
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/security-acm/07_security-acm_pol_update.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,303 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@us.ibm.com>
+
+# Test to exercise the xspolicy class
+
+from XmTestLib import xapi
+from XmTestLib.XenAPIDomain import XmTestAPIDomain
+from XmTestLib import *
+from xen.xend import XendAPIConstants
+from xen.util import acmpolicy, security, xsconstants
+from xen.util.acmpolicy import ACMPolicy
+from xen.xend.XendDomain import DOM0_UUID
+
+import commands
+import os
+import base64
+
+xm_test = {}
+xm_test['policyname'] = "xm-test"
+xm_test['date'] = "Fri Sep 29 14:44:38 2006"
+xm_test['url'] = None
+
+vm_label_red = "%s:xm-test:red" % xsconstants.ACM_POLICY_ID
+vm_label_green = "%s:xm-test:green" % xsconstants.ACM_POLICY_ID
+vm_label_blue = "%s:xm-test:blue" % xsconstants.ACM_POLICY_ID
+vm_label_sys = "%s:xm-test:SystemManagement" % xsconstants.ACM_POLICY_ID
+
+vm_label_black = "%s:xm-test:black"
+
+session = xapi.connect()
+
+oldlabel = session.xenapi.VM.get_security_label(DOM0_UUID)
+
+ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_sys,
+ oldlabel)
+if int(ssidref) <= 0 or int(ssidref) != 0x00010001:
+ FAIL("(0) Domain-0 label for '%s' has unexpected failure: %08x" %
+ (vm_label_sys, int(ssidref)))
+print "ssidref for '%s' is 0x%08x" % (vm_label_sys, int(ssidref))
+
+
+xstype = session.xenapi.XSPolicy.get_xstype()
+if int(xstype) & xsconstants.XS_POLICY_ACM == 0:
+ SKIP("ACM not enabled/compiled in Xen")
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+if not policystate.has_key('xs_ref'):
+ FAIL("get_xspolicy must return member 'xs_ref'")
+
+xs_ref = policystate['xs_ref']
+if xs_ref != "":
+ origpolicyxml = session.xenapi.ACMPolicy.get_xml(xs_ref)
+else:
+ origpolicyxml = ""
+
+f = open("xm-test-security_policy.xml", 'r')
+if f:
+ newpolicyxml = f.read()
+ f.close()
+else:
+ FAIL("Could not read 'xm-test' policy")
+
+try:
+ os.unlink("/boot/xm-test.bin")
+except:
+ pass
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+
+if int(policystate['type']) == 0:
+ policystate = session.xenapi.XSPolicy.set_xspolicy(
+ xsconstants.XS_POLICY_ACM,
+ newpolicyxml,
+ xsconstants.XS_INST_LOAD | xsconstants.XS_INST_BOOT,
+ 1)
+ if int(policystate['flags']) == -1:
+ FAIL("Could not set the new policy.")
+
+print "state of policy = %s " % policystate
+
+rc = session.xenapi.XSPolicy.activate_xspolicy(
+ policystate['xs_ref'],
+ xsconstants.XS_INST_LOAD | xsconstants.XS_INST_BOOT)
+if int(rc) != xsconstants.XS_INST_LOAD | xsconstants.XS_INST_BOOT:
+ FAIL("Could not activate the current policy: rc = %08x" % int(rc))
+
+if not os.path.exists("/boot/xm-test.bin"):
+ FAIL("Binary policy was not installed. Check grub config file.")
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+
+if int(policystate['flags']) != xsconstants.XS_INST_BOOT | \
+ xsconstants.XS_INST_LOAD:
+ FAIL("Flags (%x) are not indicating the correct state of the policy.",
+ int(policystate['flags']))
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+xs_ref = policystate['xs_ref']
+
+newpolicyxml = None
+f = open("xm-test-new-security_policy.xml", 'r')
+if f:
+ newpolicyxml = f.read()
+ f.close()
+else:
+ FAIL("Could not read 'xm-test-new' policy")
+
+cur_acmpol = ACMPolicy(xml = policystate['repr'])
+new_acmpol = ACMPolicy(xml = newpolicyxml)
+
+new_acmpol.update_frompolicy(cur_acmpol)
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ new_acmpol.toxml(),
+ xsconstants.XS_INST_LOAD | xsconstants.XS_INST_BOOT,
+ 1)
+
+f = open("xm-test-security_policy.xml", 'r')
+if f:
+ newpolicyxml = f.read()
+ f.close()
+else:
+ FAIL("Could not read 'xm-test-new' policy")
+
+cur_acmpol = new_acmpol
+new_acmpol = ACMPolicy(xml = newpolicyxml)
+
+new_acmpol.update_frompolicy(cur_acmpol)
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ new_acmpol.toxml(),
+ xsconstants.XS_INST_LOAD | xsconstants.XS_INST_BOOT,
+ 1)
+
+dom0_lab = session.xenapi.VM.get_security_label(DOM0_UUID)
+
+ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_sys, dom0_lab)
+if int(ssidref) <= 0 or int(ssidref) != 0x00010001:
+ FAIL("(1) Domain-0 label for '%s' has unexpected failure: %08x" %
+ (vm_label_sys, int(ssidref)))
+print "ssidref for '%s' is 0x%08x" % (vm_label_sys, int(ssidref))
+
+try:
+ ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_black,
+ vm_label_sys)
+ FAIL("Could set label '%s', although it's not in the policy. "
+ "ssidref=%s" % (vm_label_black, ssidref))
+except:
+ pass
+
+ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_red,
+ vm_label_sys)
+if int(ssidref) <= 0:
+ FAIL("(2) Domain-0 label for '%s' has unexpected failure: %08x" %
+ (vm_label_red, int(ssidref)))
+print "ssidref for '%s' is 0x%08x" % (vm_label_red, int(ssidref))
+
+label = session.xenapi.VM.get_security_label(DOM0_UUID)
+
+if label != vm_label_red:
+ FAIL("Dom0 label '%s' not as expected '%s'" % (label, vm_label_red))
+
+
+ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_sys,
+ vm_label_red)
+if int(ssidref) <= 0 or int(ssidref) != 0x00010001:
+ FAIL("(3) Domain-0 label for '%s' has unexpected failure: %08x" %
+ (vm_label_sys, int(ssidref)))
+
+label = session.xenapi.VM.get_security_label(DOM0_UUID)
+
+if label != vm_label_sys:
+ FAIL("Dom0 label '%s' not as expected '%s'" % label, dom0_label)
+
+header = session.xenapi.ACMPolicy.get_header(xs_ref)
+
+if header['policyname'] != xm_test['policyname']:
+ FAIL("Name in header is '%s', expected is '%s'." %
+ (header['policyname'],xm_test['policyname']))
+if header['date'] != xm_test['date']:
+ FAIL("Date in header is '%s', expected is '%s'." %
+ (header['date'],xm_test['date']))
+if header.has_key("url") and header['url' ] != xm_test['url' ]:
+ FAIL("URL in header is '%s', expected is '%s'." %
+ (header['url' ],xm_test['url' ]))
+
+# Create another domain
+try:
+ # XmTestAPIDomain tries to establish a connection to XenD
+ domain = XmTestAPIDomain(extraConfig={ 'security_label' : vm_label_blue })
+except Exception, e:
+ SKIP("Skipping test. Error: %s" % str(e))
+
+
+vm_uuid = domain.get_uuid()
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+if res != vm_label_blue:
+ FAIL("VM has security label '%s', expected is '%s'" %
+ (res, vm_label_blue))
+
+try:
+ domain.start(noConsole=True)
+except:
+ FAIL("Could not create domain")
+
+
+# Attempt to relabel the running domain
+ssidref = session.xenapi.VM.set_security_label(vm_uuid,
+ vm_label_red,
+ vm_label_blue)
+if int(ssidref) <= 0:
+ FAIL("Could not relabel running domain to '%s'." % vm_label_red)
+
+# user domain is 'red', dom0 is current 'SystemManagement'.
+# Try to move domain-0 to 'red' first, then to 'blue'.
+
+# Moving domain-0 to 'red' should work
+ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_red,
+ vm_label_sys)
+if int(ssidref) <= 0:
+ FAIL("Could not label domain-0 '%s'" % vm_label_red)
+
+# Moving the guest domain to 'blue' should not work due to conflict set
+try:
+ ssidref = session.xenapi.VM.set_security_label(vm_uuid,
+ vm_label_blue,
+ vm_label_red)
+ FAIL("Could label guest domain with '%s', although this is in a conflict "
+ "set. ssidref=%x" % (vm_label_blue,int(ssidref)))
+except:
+ pass
+
+label = session.xenapi.VM.get_security_label(vm_uuid)
+if label != vm_label_red:
+ FAIL("User domain has wrong label '%s', expected '%s'." %
+ (label, vm_label_red))
+
+label = session.xenapi.VM.get_security_label(DOM0_UUID)
+if label != vm_label_red:
+ FAIL("Domain-0 has wrong label '%s'; expected '%s'." %
+ (label, vm_label_red))
+
+ssidref = session.xenapi.VM.set_security_label(DOM0_UUID,
+ vm_label_sys,
+ vm_label_red)
+if int(ssidref) < 0:
+ FAIL("Could not set the domain-0 security label to '%s'." %
+ (vm_label_sys))
+
+# pause the domain and relabel it...
+session.xenapi.VM.pause(vm_uuid)
+
+label = session.xenapi.VM.get_security_label(vm_uuid)
+if label != vm_label_red:
+ FAIL("User domain has wrong label '%s', expected '%s'." %
+ (label, vm_label_red))
+
+ssidref = session.xenapi.VM.set_security_label(vm_uuid,
+ vm_label_blue,
+ vm_label_red)
+print "guest domain new label '%s'; ssidref is 0x%08x" % \
+ (vm_label_blue, int(ssidref))
+if int(ssidref) <= 0:
+ FAIL("Could not label guest domain with '%s'" % (vm_label_blue))
+
+label = session.xenapi.VM.get_security_label(vm_uuid)
+if label != vm_label_blue:
+ FAIL("User domain has wrong label '%s', expected '%s'." %
+ (label, vm_label_blue))
+
+session.xenapi.VM.unpause(vm_uuid)
+
+rc = session.xenapi.VM.suspend(vm_uuid)
+
+ssidref = session.xenapi.VM.set_security_label(vm_uuid,
+ vm_label_green,
+ vm_label_blue)
+print "guest domain new label '%s'; ssidref is 0x%08x" % \
+ (vm_label_green, int(ssidref))
+if int(ssidref) < 0:
+ FAIL("Could not label suspended guest domain with '%s'" % (vm_label_blue))
+
+label = session.xenapi.VM.get_security_label(vm_uuid)
+if label != vm_label_green:
+ FAIL("User domain has wrong label '%s', expected '%s'." %
+ (label, vm_label_green))
+
+
+rc = session.xenapi.VM.resume(vm_uuid, False)
+
+label = session.xenapi.VM.get_security_label(vm_uuid)
+if label != vm_label_green:
+ FAIL("User domain has wrong label '%s', expected '%s'." %
+ (label, vm_label_green))
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/security-acm/08_security-acm_xapi.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/security-acm/08_security-acm_xapi.py Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,354 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2007
+# Author: Stefan Berger <stefanb@us.ibm.com>
+
+# VM creation test with labeled VM and labeled VDI
+
+from XmTestLib import xapi
+from XmTestLib.XenAPIDomain import XmTestAPIDomain
+from XmTestLib import *
+from xen.xend import XendAPIConstants
+from xen.util import acmpolicy, security, xsconstants
+import commands
+import os
+
+vm_label_red = xsconstants.ACM_POLICY_ID + ":xm-test:red"
+vm_label_green = xsconstants.ACM_POLICY_ID + ":xm-test:green"
+vdi_label_red = xsconstants.ACM_POLICY_ID + ":xm-test:red"
+vdi_label_green = xsconstants.ACM_POLICY_ID + ":xm-test:green"
+
+vdi_file = "/dev/ram0"
+vdi_path = "phy:" + vdi_file
+
+#Note:
+# If during the suspend/resume operations 'red' instead of 'green' is
+# used, the Chinese Wall policy goes into effect and disallows the
+# suspended VM from being resumed...
+
+try:
+ # XmTestAPIDomain tries to establish a connection to XenD
+ domain = XmTestAPIDomain(extraConfig={ 'security_label' : vm_label_red })
+except Exception, e:
+ SKIP("Skipping test. Error: %s" % str(e))
+
+vm_uuid = domain.get_uuid()
+
+session = xapi.connect()
+xstype = session.xenapi.XSPolicy.get_xstype()
+if int(xstype) & xsconstants.XS_POLICY_ACM == 0:
+ SKIP("ACM not enabled/compiled in Xen")
+
+f = open("xm-test-security_policy.xml", 'r')
+if f:
+ newpolicyxml = f.read()
+ f.close()
+else:
+ FAIL("Could not read 'xm-test' policy")
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+if int(policystate['type']) == 0:
+ policystate = session.xenapi.XSPolicy.set_xspolicy(
+ xsconstants.XS_POLICY_ACM,
+ newpolicyxml,
+ xsconstants.XS_INST_BOOT | xsconstants.XS_INST_LOAD,
+ True)
+ if int(policystate['flags']) == -1:
+ FAIL("Could not set the new policy.")
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+print "policystate = %s" % policystate
+acm_ref = policystate['xs_ref']
+
+
+#
+# Some tests with labeling of resources
+#
+labels = session.xenapi.XSPolicy.get_labeled_resources()
+print "labeled resources are:\n%s" % labels
+
+oldlabel = session.xenapi.XSPolicy.get_resource_label("phy:/dev/ram0")
+
+rc = session.xenapi.XSPolicy.set_resource_label("phy:/dev/ram0", "",
+ oldlabel)
+
+rc = session.xenapi.XSPolicy.set_resource_label("phy:/dev/ram0",
+ vdi_label_green,
+ "")
+
+res = session.xenapi.XSPolicy.get_resource_label("phy:/dev/ram0")
+if res != vdi_label_green:
+ FAIL("(1) get_resource_label returned unexpected result %s, wanted %s" %
+ (res, vdi_label_green))
+
+
+#
+# Some test with labeling of VMs
+#
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+
+if res != vm_label_red:
+ FAIL("VM.get_security_label returned wrong security label '%s'." % res)
+
+res = session.xenapi.VM.set_security_label(vm_uuid, vm_label_green,
+ vm_label_red)
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+if res != vm_label_green:
+ FAIL("VM does not show expected label '%s' but '%s'." %
+ (vm_label_green, res))
+
+res = session.xenapi.VM.set_security_label(vm_uuid, "", vm_label_green)
+if int(res) != 0:
+ FAIL("Should be able to unlabel the domain while it's halted.")
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+if res != "":
+ FAIL("Unexpected VM security label after removal: %s" % res)
+
+res = session.xenapi.VM.set_security_label(vm_uuid, vm_label_red, res)
+if int(res) != 0:
+ FAIL("Could not label the VM to '%s'" % vm_label_red)
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+if res != vm_label_red:
+ FAIL("VM has wrong label '%s', expected '%s'." % (res, vm_label_red))
+
+sr_uuid = session.xenapi.SR.get_by_name_label("Local")
+if len(sr_uuid) == 0:
+ FAIL("Could not get a handle on SR 'Local'")
+
+
+vdi_rec = { 'name_label' : "My disk",
+ 'SR' : sr_uuid[0],
+ 'virtual_size': 0,
+ 'sector_size' : 512,
+ 'parent' : '',
+ 'SR_name' : 'Local',
+ 'type' : 'system',
+ 'shareable' : False,
+ 'read-only' : False,
+ 'other_config': {'location': vdi_path}
+}
+
+vdi_ref = session.xenapi.VDI.create(vdi_rec)
+
+res = session.xenapi.VDI.get_name_label(vdi_ref)
+if res != vdi_rec['name_label']:
+ print "Destroying VDI now"
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("VDI_get_name_label return wrong information")
+
+res = session.xenapi.VDI.get_record(vdi_ref)
+print "vdi_record : %s" % res
+
+oldlabel = session.xenapi.XSPolicy.get_resource_label(vdi_path)
+
+#Remove label from VDI device
+rc = session.xenapi.XSPolicy.set_resource_label(vdi_path,
+ "",
+ oldlabel)
+
+
+# Attach a VBD to the VM
+
+vbd_rec = { 'VM' : vm_uuid,
+ 'VDI' : vdi_ref,
+ 'device' : "xvda1",
+ 'mode' : 1,
+ 'bootable': 0,
+}
+
+vbd_ref = session.xenapi.VBD.create(vbd_rec)
+
+res = session.xenapi.VBD.get_record(vbd_ref)
+
+try:
+ domain.start(noConsole=True)
+ # Should not get here.
+ print "Destroying VDI now"
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could start VM with a VBD that it is not allowed to access.")
+except:
+ pass
+ print "Could not create domain -- that's good"
+
+
+#
+# Label the VDI now
+#
+
+rc = session.xenapi.VDI.set_security_label(vdi_ref, vdi_label_red, "")
+if int(rc) != 0:
+ FAIL("Could not set the VDI label to '%s'" % vdi_label_red)
+
+label = session.xenapi.VDI.get_security_label(vdi_ref)
+if label != vdi_label_red:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Unexpected label '%s' on VDI, wanted '%s'" %
+ (label, vdi_label_red))
+
+rc = session.xenapi.VDI.set_security_label(vdi_ref, "", label)
+if int(rc) != 0:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Should be able to unlabel VDI.")
+
+rc = session.xenapi.VDI.set_security_label(vdi_ref, vdi_label_red, "")
+if int(rc) != 0:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Should be able to label VDI with label '%s'" % vid_label_red)
+
+res = session.xenapi.XSPolicy.get_resource_label(vdi_path)
+if res != vdi_label_red:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("(2) get_resource_label on %s returned unexpected result %s, wanted '%s'" %
+ (vdi_path, res, vdi_label_red))
+
+res = session.xenapi.VDI.get_security_label(vdi_ref)
+if res != vdi_label_red:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("get_security_label returned unexpected result %s, wanted '%s'" %
+ (res, vdi_label_red))
+
+domain.start(noConsole=True)
+
+console = domain.getConsole()
+
+domName = domain.getName()
+
+try:
+ run = console.runCmd("cat /proc/interrupts")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL("Could not access proc-filesystem")
+
+# Try to relabel while VM is running
+try:
+ res = session.xenapi.VM.set_security_label(vm_uuid, vm_label_green,
+ vm_label_red)
+except:
+ pass
+
+lab = session.xenapi.VM.get_security_label(vm_uuid)
+if lab == vm_label_green:
+ FAIL("Should not be able to reset the security label while running."
+ "tried to set to %s, got %s, old: %s" %(vm_label_green, lab,
+ vm_label_red))
+
+
+#
+# Suspend the domain and relabel it
+#
+
+try:
+ status, output = traceCommand("xm suspend %s" % domName,
+ timeout=30)
+except TimeoutError, e:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Failure from suspending VM: %s." % str(e))
+
+# Try to relabel while VM is suspended -- this should work
+
+rc = session.xenapi.VM.set_security_label(vm_uuid, vm_label_green,
+ vm_label_red)
+if int(rc) != 0:
+ FAIL("VM security label could not be set to %s" % vm_label_green)
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+if res != vm_label_green:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("VM (suspended) has label '%s', expected '%s'." %
+ (res, vm_label_green))
+
+status, output = traceCommand("xm list")
+
+#Try to resume now -- should fail due to denied access to block device
+try:
+ status, output = traceCommand("xm resume %s" % domName,
+ timeout=30)
+ if status == 0:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could resume re-labeled VM: %s" % output)
+except Exception, e:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("1. Error resuming the VM: %s." % str(e))
+
+# Relabel VM so it would resume
+res = session.xenapi.VM.set_security_label(vm_uuid, vm_label_red,
+ vm_label_green)
+if int(res) != 0:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could not relabel VM to have it resume.")
+
+res = session.xenapi.VM.get_security_label(vm_uuid)
+if res != vm_label_red:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("VM (suspended) has label '%s', expected '%s'." %
+ (res, vm_label_red))
+
+
+# Relabel the resource so VM should not resume
+try:
+ session.xenapi.XSPolicy.set_resource_label(vdi_path,
+ vdi_label_green,
+ "")
+except Exception, e:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could not label the VDI to '%s': %x" %
+ (vdi_label_green, int(rc)))
+
+#Try to resume now -- should fail due to denied access to block device
+try:
+ status, output = traceCommand("xm resume %s" % domName,
+ timeout=30)
+ if status == 0:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could resume re-labeled VM: %s" % output)
+except Exception, e:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("2. Error resuming the VM: %s." % str(e))
+
+
+status, output = traceCommand("xm list")
+
+# Relabel the resource so VM can resume
+try:
+ session.xenapi.XSPolicy.set_resource_label(vdi_path,
+ vdi_label_red,
+ vdi_label_green)
+except Exception, e:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could not label the resource to '%s'" % vid_label_red)
+
+res = session.xenapi.XSPolicy.get_resource_label(vdi_path)
+if res != vdi_label_red:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("'%s' has label '%s', expected '%s'." %
+ (vdi_path, res, vdi_label_red))
+
+#Try to resume now -- should work
+try:
+ status, output = traceCommand("xm resume %s" % domName,
+ timeout=30)
+ if status != 0:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could not resume re-labeled VM: %s" % output)
+except Exception, e:
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("3. Error resuming the VM: %s." % str(e))
+
+
+status, output = traceCommand("xm list")
+
+console = domain.getConsole()
+
+try:
+ run = console.runCmd("cat /proc/interrupts")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ session.xenapi.VDI.destroy(vdi_ref)
+ FAIL("Could not access proc-filesystem")
+
+domain.stop()
+domain.destroy()
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/security-acm/09_security-acm_pol_update.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,427 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2007
+# Author: Stefan Berger <stefanb@us.ibm.com>
+
+# Test to exercise the xspolicy and acmpolicy classes
+
+from XmTestLib import xapi
+from XmTestLib.XenAPIDomain import XmTestAPIDomain
+from XmTestLib import *
+from xen.xend import XendAPIConstants
+from xen.util import security, xsconstants
+from xen.util.acmpolicy import ACMPolicy
+from xen.xend.XendDomain import DOM0_UUID
+import base64
+import struct
+import time
+
+def typestoxml(types):
+ res = ""
+ for t in types:
+ res += "<Type>" + t + "</Type>\n"
+ return res
+
+def cfstoxml(cfss):
+ res = ""
+ for cfs in cfss:
+ res += "<Conflict name=\"" + cfs['name'] + "\">\n" + \
+ typestoxml(cfs['chws']) + \
+ "</Conflict>\n"
+ return res
+
+def vmlabelstoxml(vmlabels, vmfrommap):
+ res = ""
+ for vmlabel in vmlabels:
+ res += "<VirtualMachineLabel>\n"
+ if vmlabel['name'] in vmfrommap:
+ res += "<Name from=\""+ vmfrommap[vmlabel['name']] +"\">"
+ else:
+ res += "<Name>"
+ res += vmlabel['name'] + "</Name>\n"
+ res += "<SimpleTypeEnforcementTypes>\n" + \
+ typestoxml(vmlabel['stes']) + \
+ "</SimpleTypeEnforcementTypes>\n"
+ if vmlabel.has_key('chws'):
+ res += "<ChineseWallTypes>\n" + \
+ typestoxml(vmlabel['chws']) + \
+ "</ChineseWallTypes>\n"
+ res += "</VirtualMachineLabel>\n"
+ return res
+
+
+def reslabelstoxml(reslabels, resfrommap):
+ res = ""
+ for reslabel in reslabels:
+ res += "<ResourceLabel>\n"
+ if resfrommap.has_key(reslabel['name']):
+ res += "<Name from=\""+ resfrommap[reslabel['name']] +"\">"
+ else:
+ res += "<Name>"
+ res += reslabel['name'] + "</Name>\n"
+ res += "<SimpleTypeEnforcementTypes>\n" + \
+ typestoxml(reslabel['stes']) + \
+ "</SimpleTypeEnforcementTypes>\n"
+ res += "</ResourceLabel>\n"
+ return res
+
+def create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss):
+ hdr_xml ="<PolicyHeader>\n" + \
+ " <PolicyName>" + hdr['name'] + "</PolicyName>\n" + \
+ " <Version>" + hdr['version'] + "</Version>\n" + \
+ " <FromPolicy>\n" + \
+ " <PolicyName>" + hdr['oldname'] + "</PolicyName>\n" + \
+ " <Version>" + hdr['oldversion'] + "</Version>\n" + \
+ " </FromPolicy>\n" + \
+ "</PolicyHeader>\n"
+
+ stes_xml = "<SimpleTypeEnforcement>\n" + \
+ " <SimpleTypeEnforcementTypes>\n" + \
+ typestoxml(stes) + \
+ " </SimpleTypeEnforcementTypes>\n" + \
+ "</SimpleTypeEnforcement>\n"
+
+ chws_xml = "<ChineseWall>\n" + \
+ " <ChineseWallTypes>\n" + \
+ typestoxml(chws) + \
+ " </ChineseWallTypes>\n" + \
+ " <ConflictSets>\n" + \
+ cfstoxml(cfss) + \
+ " </ConflictSets>\n" + \
+ "</ChineseWall>\n"
+
+ subjlabel_xml = "<SubjectLabels bootstrap=\""+ bootstrap +"\">\n" + \
+ vmlabelstoxml(vmlabels, vmfrommap) + \
+ "</SubjectLabels>\n"
+ objlabel_xml = "<ObjectLabels>\n" + \
+ reslabelstoxml(reslabels, resfrommap) + \
+ "</ObjectLabels>\n"
+
+ policyxml = "<?xml version=\"1.0\" ?>\n" + \
+ "<SecurityPolicyDefinition xmlns=\"http://www.ibm.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.ibm.com ../../security_policy.xsd \">\n" + \
+ hdr_xml + \
+ stes_xml + \
+ chws_xml + \
+ "<SecurityLabelTemplate>\n" + \
+ subjlabel_xml + \
+ objlabel_xml + \
+ "</SecurityLabelTemplate>\n" + \
+ "</SecurityPolicyDefinition>\n"
+ return policyxml
+
+
+def update_hdr(hdr):
+ """ Update the version information in the header """
+ hdr['oldversion'] = hdr['version']
+ hdr['oldname'] = hdr['name']
+ vers = hdr['version']
+ tmp = vers.split('.')
+ if len(tmp) == 1:
+ rev = 1
+ else:
+ rev = int(tmp[1]) + 1
+ hdr['version'] = "%s.%s" % (tmp[0],rev)
+ return hdr
+
+session = xapi.connect()
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+
+if policystate['repr'] != "":
+ print "%s" % policystate['repr']
+ try:
+ acmpol = ACMPolicy(xml=policystate['repr'])
+ except Exception, e:
+ FAIL("Failure from creating ACMPolicy object: %s" % str(e))
+ oldname = acmpol.policy_dom_get_hdr_item("PolicyName")
+ oldvers = acmpol.policy_dom_get_hdr_item("Version")
+ tmp = oldvers.split(".")
+ if len(tmp) == 1:
+ rev = 1
+ else:
+ rev = int(tmp[1]) + 1
+ newvers = "%s.%s" % (tmp[0], str(rev))
+ print "old name/version = %s/%s" % (oldname, oldvers)
+else:
+ oldname = None
+ oldvers = None
+ newvers = "1.0"
+
+# Initialize the header of the policy
+hdr = {}
+hdr['name'] = "xm-test"
+hdr['version'] = newvers
+
+if oldname:
+ hdr['oldname'] = oldname
+ if oldvers and oldvers != "":
+ hdr['oldversion'] = oldvers
+
+stes = [ "SystemManagement", "red", "green", "blue" ]
+
+chws = [ "SystemManagement", "red", "green", "blue" ]
+
+bootstrap = "SystemManagement"
+
+vm_sysmgt = { 'name' : bootstrap,
+ 'stes' : stes,
+ 'chws' : [ "SystemManagement" ] }
+
+vm_red = { 'name' : "red" ,
+ 'stes' : ["red"] ,
+ 'chws' : ["red"] }
+
+vm_green = { 'name' : "green" ,
+ 'stes' : ["green"] ,
+ 'chws' : ["green"] }
+
+vm_blue = { 'name' : "blue" ,
+ 'stes' : ["blue"] ,
+ 'chws' : ["blue"] }
+
+res_red = { 'name' : "red" ,
+ 'stes' : ["red"] }
+
+res_green = { 'name' : "green" ,
+ 'stes' : ["green"] }
+
+res_blue = { 'name' : "blue" ,
+ 'stes' : ["blue"] }
+
+cfs_1 = { 'name' : "CFS1",
+ 'chws' : [ "red" , "blue" ] }
+
+vmlabels = [ vm_sysmgt, vm_red, vm_green, vm_blue ]
+vmfrommap = {}
+reslabels = [ res_red, res_green, res_blue ]
+resfrommap = {}
+cfss = [ cfs_1 ]
+
+vm_label_red = xsconstants.ACM_POLICY_ID + ":xm-test:red"
+vm_label_green = xsconstants.ACM_POLICY_ID + ":xm-test:green"
+vm_label_blue = xsconstants.ACM_POLICY_ID + ":xm-test:blue"
+
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+
+xml_good = xml
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+
+print "\n\npolicystate = %s" % policystate
+
+policystate = session.xenapi.XSPolicy.get_xspolicy()
+
+#
+# Create two non-conflicting domains and start them
+#
+try:
+ # XmTestAPIDomain tries to establish a connection to XenD
+ domain1 = XmTestAPIDomain(extraConfig={ 'security_label' : vm_label_red })
+except Exception, e:
+ SKIP("Skipping test. Error: %s" % str(e))
+
+
+vm1_uuid = domain1.get_uuid()
+
+try:
+ domain1.start(noConsole=True)
+except:
+ FAIL("Could not start domain1")
+
+print "Domain 1 started"
+
+try:
+ # XmTestAPIDomain tries to establish a connection to XenD
+ domain2 = XmTestAPIDomain(extraConfig={'security_label': vm_label_green })
+except Exception, e:
+ SKIP("Skipping test. Error: %s" % str(e))
+
+vm2_uuid = domain2.get_uuid()
+
+try:
+ domain2.start(noConsole=True)
+except:
+ FAIL("Could not start domain1")
+
+
+print "Domain 2 started"
+
+# Try a policy that would put the two domains into conflict
+cfs_2 = { 'name' : "CFS1",
+ 'chws' : [ "red" , "green" ] }
+cfss = [ cfs_2 ]
+
+hdr = update_hdr(hdr)
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+
+print "policystate %s" % policystate
+
+if int(policystate['xserr']) == 0:
+ FAIL("(1) Should not have been able to set this policy.")
+
+if len(policystate['errors']) == 0:
+ FAIL("Hypervisor should have reported errros.")
+
+errors = base64.b64decode(policystate['errors'])
+
+print "Length of errors: %d" % len(errors)
+a,b = struct.unpack("!ii",errors)
+
+print "%08x , %08x" % (a,b)
+
+#
+# Create a faulty policy with 'red' STE missing
+#
+
+cfss = [ cfs_1 ]
+stes = [ "SystemManagement", "green", "blue" ]
+
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+
+print "Result from setting faulty(!) policy with STE 'red' missing:"
+print "policystate %s" % policystate
+
+if int(policystate['xserr']) == 0:
+ FAIL("(2) Should not have been able to set this policy.")
+
+#
+# Create a policy with 'red' VMLabel missing -- should not work since it is
+# in use.
+#
+stes = [ "SystemManagement", "red", "green", "blue" ]
+
+vmlabels = [ vm_sysmgt, vm_green, vm_blue ]
+
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+print "Result from setting faulty(!) policy with VMlabel 'red' missing:"
+print "policystate %s" % policystate
+
+if int(policystate['xserr']) == 0:
+ FAIL("(3) Should not have been able to set this policy.")
+
+#
+# Create a policy with 'blue' VMLabel missing -- should work since it is NOT
+# in use.
+#
+vmlabels = [ vm_sysmgt, vm_red, vm_green ]
+
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+
+print "Result from setting (good) policy with VMlabel 'blue' missing:"
+print "policystate %s" % policystate
+
+if int(policystate['xserr']) != 0:
+ FAIL("(4) Should have been able to set this policy: %s" % xml)
+
+#
+# Move the green VMLabel towards blue which should put the running
+# domain with label blue into a conflict set
+#
+vmlabels = [ vm_sysmgt, vm_red, vm_blue ]
+
+vmfrommap = { "blue" : "green" } # new : old
+
+hdr = update_hdr(hdr) #Needed, since last update was successful
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+
+print "policystate %s" % policystate
+
+if int(policystate['xserr']) == 0:
+ FAIL("(5) Should not have been able to set this policy.")
+
+#
+# Try to install a policy where a VM label has a faulty VM label name
+#
+vmfrommap = {}
+
+vm_blue_bad = { 'name' : "blue:x" , # ':' no allowed
+ 'stes' : ["blue"],
+ 'chws' : ["blue"] }
+
+vmlabels = [ vm_sysmgt, vm_red, vm_green, vm_blue_bad ]
+
+xml = create_xml_policy(hdr, stes, chws,
+ vmlabels, vmfrommap, bootstrap,
+ reslabels, resfrommap,
+ cfss)
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ xml,
+ xsconstants.XS_INST_LOAD,
+ True)
+
+print "policystate %s" % policystate
+
+if int(policystate['xserr']) == 0:
+ FAIL("(6) Should not have been able to set this policy.")
+
+#
+# End the test by installing the initial policy again
+#
+
+cur_version = hdr['version']
+(maj, min) = cur_version.split(".")
+cur_version = "%s.%s" % (maj, str(int(min)-1) )
+
+orig_acmpol = ACMPolicy(xml=xml_good)
+orig_acmpol.set_frompolicy_version(cur_version)
+orig_acmpol.set_policy_version(hdr['version'])
+
+policystate = session.xenapi.XSPolicy.set_xspolicy(xsconstants.XS_POLICY_ACM,
+ orig_acmpol.toxml(),
+ xsconstants.XS_INST_LOAD,
+ True)
+
+if int(policystate['xserr']) != 0:
+ FAIL("(END) Should have been able to set this policy.")
+
+domain1.stop()
+domain2.stop()
+domain1.destroy()
+domain2.destroy()
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/security-acm/Makefile.am
--- a/tools/xm-test/tests/security-acm/Makefile.am Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/security-acm/Makefile.am Fri Jul 27 08:15:16 2007 -0600
@@ -5,7 +5,10 @@ TESTS = 01_security-acm_basic.test \
03_security-acm_dom_conflict.test \
04_security-acm_dom_res.test \
05_security-acm_dom_res_conf.test \
- 06_security-acm_dom_block_attach.test
+ 06_security-acm_dom_block_attach.test \
+ 07_security-acm_pol_update.test \
+ 08_security-acm_xapi.test \
+ 09_security-acm_pol_update.test

XFAIL_TESTS =

diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/security-acm/xm-test-new-security_policy.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/security-acm/xm-test-new-security_policy.xml Fri Jul 27 08:15:16 2007 -0600
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Auto-generated by ezPolicy -->
+<SecurityPolicyDefinition xmlns="http://www.ibm.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com ../../security_policy.xsd ">
+ <PolicyHeader>
+ <PolicyName>xm-test</PolicyName>
+ <Date>Fri Sep 29 14:44:38 2006</Date>
+ <Version>1.1</Version>
+ <FromPolicy>
+ <PolicyName>xm-test</PolicyName>
+ <Version>1.0</Version>
+ </FromPolicy>
+ </PolicyHeader>
+
+ <SimpleTypeEnforcement>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ <Type>green</Type>
+ <Type>red</Type>
+ </SimpleTypeEnforcementTypes>
+ </SimpleTypeEnforcement>
+
+ <ChineseWall priority="PrimaryPolicyComponent">
+ <ChineseWallTypes>
+ <Type>SystemManagement</Type>
+ <Type>green</Type>
+ <Type>red</Type>
+ </ChineseWallTypes>
+
+ <ConflictSets>
+ <Conflict name="RER">
+ <Type>green</Type>
+ <Type>red</Type>
+ </Conflict>
+ </ConflictSets>
+ </ChineseWall>
+
+ <SecurityLabelTemplate>
+ <SubjectLabels bootstrap="SystemManagement">
+ <VirtualMachineLabel>
+ <Name>SystemManagement</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ <Type>green</Type>
+ <Type>red</Type>
+ </SimpleTypeEnforcementTypes>
+ <ChineseWallTypes>
+ <Type>SystemManagement</Type>
+ </ChineseWallTypes>
+ </VirtualMachineLabel>
+
+ <VirtualMachineLabel>
+ <Name>green</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>green</Type>
+ </SimpleTypeEnforcementTypes>
+ <ChineseWallTypes>
+ <Type>green</Type>
+ </ChineseWallTypes>
+ </VirtualMachineLabel>
+
+ <VirtualMachineLabel>
+ <Name>red</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>red</Type>
+ </SimpleTypeEnforcementTypes>
+ <ChineseWallTypes>
+ <Type>red</Type>
+ </ChineseWallTypes>
+ </VirtualMachineLabel>
+
+ </SubjectLabels>
+
+ <ObjectLabels>
+ <ResourceLabel>
+ <Name>SystemManagement</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ </SimpleTypeEnforcementTypes>
+ </ResourceLabel>
+
+ <ResourceLabel>
+ <Name>green</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>green</Type>
+ </SimpleTypeEnforcementTypes>
+ </ResourceLabel>
+
+ <ResourceLabel>
+ <Name>red</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>red</Type>
+ </SimpleTypeEnforcementTypes>
+ </ResourceLabel>
+
+ </ObjectLabels>
+ </SecurityLabelTemplate>
+</SecurityPolicyDefinition>
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
--- a/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py Fri Jul 27 08:15:16 2007 -0600
@@ -11,6 +11,7 @@ from vtpm_utils import *
from vtpm_utils import *
import commands
import os
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -23,18 +24,17 @@ except DomainError, e:
vtpm_cleanup(domain.getName())
FAIL("Unable to create domain")

+
domName = domain.getName()
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

status, output = traceCommand("xm vtpm-list %s" % domain.getId())
eyecatcher = "/local/domain/0/backend/vtpm"
where = output.find(eyecatcher)
if status != 0:
- vtpm_cleanup(domName)
FAIL("xm vtpm-list returned bad status, expected 0, status is %i" % status)
elif where < 0:
- vtpm_cleanup(domName)
FAIL("Fail to list virtual TPM device")

domain.stop()
-
-vtpm_cleanup(domName)
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
--- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py Fri Jul 27 08:15:16 2007 -0600
@@ -11,6 +11,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -21,32 +22,28 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

domain.closeConsole()

domain.stop()

-vtpm_cleanup(domName)
-
if not re.search("PCR-00:",run["output"]):
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
--- a/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py Fri Jul 27 08:15:16 2007 -0600
@@ -12,6 +12,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -23,25 +24,23 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

consoleHistory = console.getHistory()
@@ -56,12 +55,10 @@ while loop < 3:

except TimeoutError, e:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm save did not succeed")

try:
@@ -71,32 +68,27 @@ while loop < 3:
except TimeoutError, e:
os.remove("%s.save" % domName)
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

os.remove("%s.save" % domName)

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm restore did not succeed")

try:
console = domain.getConsole()
except ConsoleError, e:
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")

loop += 1
@@ -105,5 +97,3 @@ domain.closeConsole()

domain.stop()

-vtpm_cleanup(domName)
-
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py
--- a/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py Fri Jul 27 08:15:16 2007 -0600
@@ -13,6 +13,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -24,25 +25,23 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

consoleHistory = console.getHistory()
@@ -58,12 +57,10 @@ while loop < 3:
timeout=90)
except TimeoutError, e:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm migrate did not succeed. External device migration activated?")


@@ -71,26 +68,22 @@ while loop < 3:
new_domid = domid(domName)

if (old_domid == new_domid):
- vtpm_cleanup(domName)
FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
(old_domid,loop))

try:
console = domain.getConsole()
except ConsoleError, e:
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")

loop += 1
@@ -98,5 +91,3 @@ domain.closeConsole()
domain.closeConsole()

domain.stop()
-
-vtpm_cleanup(domName)
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py
--- a/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py Fri Jul 27 08:15:16 2007 -0600
@@ -13,6 +13,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -24,25 +25,23 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

consoleHistory = console.getHistory()
@@ -58,12 +57,10 @@ while loop < 3:
timeout=90)
except TimeoutError, e:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm migrate did not succeed. External device migration activated?")


@@ -71,26 +68,22 @@ while loop < 3:
new_domid = domid(domName)

if (old_domid == new_domid):
- vtpm_cleanup(domName)
FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
(old_domid,loop))

try:
console = domain.getConsole()
except ConsoleError, e:
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")

loop += 1
@@ -98,5 +91,3 @@ domain.closeConsole()
domain.closeConsole()

domain.stop()
-
-vtpm_cleanup(domName)
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py
--- a/tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py Fri Jul 27 08:15:16 2007 -0600
@@ -13,6 +13,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -24,45 +25,40 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("mknod /dev/tpm0 c 10 224")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Error while creating /dev/tpm0")

try:
run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > seq; cat seq > /dev/tpm0")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Error while extending PCR 0")

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")


if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])

if not re.search("PCR-00: 1E A7 BD",run["output"]):
@@ -81,12 +77,10 @@ while loop < 3:

except TimeoutError, e:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm save did not succeed")

try:
@@ -96,37 +90,31 @@ while loop < 3:
except TimeoutError, e:
os.remove("%s.save" % domName)
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

os.remove("%s.save" % domName)

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm restore did not succeed")

try:
console = domain.getConsole()
except ConsoleError, e:
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")

if not re.search("PCR-00: 1E A7 BD",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])

loop += 1
@@ -135,5 +123,3 @@ domain.closeConsole()

domain.stop()

-vtpm_cleanup(domName)
-
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py
--- a/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py Fri Jul 27 08:15:16 2007 -0600
@@ -14,6 +14,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -25,45 +26,40 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("mknod /dev/tpm0 c 10 224")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Error while creating /dev/tpm0")

try:
run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > seq; cat seq > /dev/tpm0")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Error while extending PCR 0")

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")


if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])

if not re.search("PCR-00: 1E A7 BD",run["output"]):
@@ -83,12 +79,10 @@ while loop < 3:
timeout=90)
except TimeoutError, e:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm migrate did not succeed. External device migration activated?")


@@ -96,31 +90,26 @@ while loop < 3:
new_domid = domid(domName)

if (old_domid == new_domid):
- vtpm_cleanup(domName)
FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
(old_domid,loop))

try:
console = domain.getConsole()
except ConsoleError, e:
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")

if not re.search("PCR-00: 1E A7 BD",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])

loop += 1
@@ -128,5 +117,3 @@ domain.closeConsole()
domain.closeConsole()

domain.stop()
-
-vtpm_cleanup(domName)
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py
--- a/tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py Fri Jul 27 08:15:16 2007 -0600
@@ -14,6 +14,7 @@ import commands
import commands
import os
import os.path
+import atexit

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)
@@ -25,45 +26,40 @@ except DomainError, e:
except DomainError, e:
if verbose:
print e.extra
- vtpm_cleanup(domName)
FAIL("Unable to create domain (%s)" % domName)
+
+atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))

try:
console.sendInput("input")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("mknod /dev/tpm0 c 10 224")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Error while creating /dev/tpm0")

try:
run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > seq; cat seq > /dev/tpm0")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Error while extending PCR 0")

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")


if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])

if not re.search("PCR-00: 1E A7 BD",run["output"]):
@@ -83,12 +79,10 @@ while loop < 3:
timeout=90)
except TimeoutError, e:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL(str(e))

if status != 0:
saveLog(consoleHistory)
- vtpm_cleanup(domName)
FAIL("xm migrate did not succeed. External device migration activated?")


@@ -96,31 +90,26 @@ while loop < 3:
new_domid = domid(domName)

if (old_domid == new_domid):
- vtpm_cleanup(domName)
FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
(old_domid,loop))

try:
console = domain.getConsole()
except ConsoleError, e:
- vtpm_cleanup(domName)
FAIL(str(e))

try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("No result from dumping the PCRs")

if not re.search("PCR-00:",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")

if not re.search("PCR-00: 1E A7 BD",run["output"]):
saveLog(console.getHistory())
- vtpm_cleanup(domName)
FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])

loop += 1
@@ -128,5 +117,3 @@ domain.closeConsole()
domain.closeConsole()

domain.stop()
-
-vtpm_cleanup(domName)
diff -r 37833b33ae77 -r 4492a0285bae tools/xm-test/tests/vtpm/vtpm_utils.py
--- a/tools/xm-test/tests/vtpm/vtpm_utils.py Thu Jul 26 14:35:01 2007 -0600
+++ b/tools/xm-test/tests/vtpm/vtpm_utils.py Fri Jul 27 08:15:16 2007 -0600
@@ -15,4 +15,16 @@ if output == "":
"need /dev/tpm0")

def vtpm_cleanup(domName):
- traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
+ traceCommand("/etc/xen/scripts/vtpm-delete "
+ "`xenstore-read /local/domain/0/backend/vtpm/%s/0/uuid`" %
+ str(domid(domName)))
+
+def vtpm_cleanup(uuid):
+ from xen.xm import main
+ if main.serverType != main.SERVER_XEN_API:
+ traceCommand("/etc/xen/scripts/vtpm-delete %s" % uuid)
+
+def vtpm_get_uuid(domainid):
+ s, o = traceCommand("xenstore-read "
+ "/local/domain/0/backend/vtpm/%s/0/uuid" % domainid)
+ return o
diff -r 37833b33ae77 -r 4492a0285bae unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Thu Jul 26 14:35:01 2007 -0600
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Fri Jul 27 08:15:16 2007 -0600
@@ -107,4 +107,13 @@ extern char *kasprintf(gfp_t gfp, const
#define __supported_pte_mask ((maddr_t)0)
#endif

+#if defined(_LINUX_NETDEVICE_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#define netif_tx_lock_bh(dev) (spin_lock_bh(&(dev)->xmit_lock))
+#define netif_tx_unlock_bh(dev) (spin_unlock_bh(&(dev)->xmit_lock))
#endif
+
+#if defined(__LINUX_SEQLOCK_H) && !defined(DEFINE_SEQLOCK)
+#define DEFINE_SEQLOCK(x) seqlock_t x = SEQLOCK_UNLOCKED
+#endif
+
+#endif
diff -r 37833b33ae77 -r 4492a0285bae unmodified_drivers/linux-2.6/netfront/Kbuild
--- a/unmodified_drivers/linux-2.6/netfront/Kbuild Thu Jul 26 14:35:01 2007 -0600
+++ b/unmodified_drivers/linux-2.6/netfront/Kbuild Fri Jul 27 08:15:16 2007 -0600
@@ -2,3 +2,4 @@ include $(M)/overrides.mk

obj-m = xen-vnif.o
xen-vnif-objs := netfront.o
+xen-vnif-objs += accel.o
diff -r 37833b33ae77 -r 4492a0285bae xen/Makefile
--- a/xen/Makefile Thu Jul 26 14:35:01 2007 -0600
+++ b/xen/Makefile Fri Jul 27 08:15:16 2007 -0600
@@ -59,7 +59,6 @@ _clean: delete-unfresh-files
$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) clean
rm -f include/asm *.o $(TARGET)* *~ core
rm -f include/asm-*/asm-offsets.h
- rm -f include/xen/acm_policy.h


_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog
[xen-unstable] merge with xen-unstable.hg [ In reply to ]
# HG changeset patch
# User Alex Williamson <alex.williamson@hp.com>
# Date 1186008030 21600
# Node ID d83c9d87ede41918c1d17d67560aed9852bc41d3
# Parent 77c87416fbd056dd9d5b21eed6b43ca252c725ba
# Parent 88bb0d305308a2cab31fd8559a6a2719db1ea55a
merge with xen-unstable.hg
---
tools/blktap/drivers/blktapctrl.c | 44 +-
tools/blktap/lib/blktaplib.h | 4
tools/firmware/hvmloader/smbios.c | 2
tools/libxc/ia64/Makefile | 2
tools/libxc/ia64/dom_fw_acpi.c | 13
tools/python/xen/util/acmpolicy.py | 7
tools/xenstore/utils.c | 80 ----
tools/xenstore/utils.h | 27 -
tools/xenstore/xenstored_core.c | 9
tools/xenstore/xenstored_domain.c | 9
tools/xenstore/xs_tdb_dump.c | 2
tools/xm-test/lib/XmTestLib/acm.py | 4
tools/xm-test/tests/security-acm/07_security-acm_pol_update.py | 9
tools/xm-test/tests/security-acm/09_security-acm_pol_update.py | 9
xen/arch/ia64/xen/dom_fw_common.c | 11
xen/arch/ia64/xen/dom_fw_dom0.c | 13
xen/arch/powerpc/Makefile | 1
xen/arch/powerpc/boot_of.c | 180 +---------
xen/arch/powerpc/domain.c | 2
xen/arch/powerpc/domain_build.c | 3
xen/arch/powerpc/domctl.c | 2
xen/arch/powerpc/exceptions.h | 3
xen/arch/powerpc/memory.c | 3
xen/arch/powerpc/mm.c | 2
xen/arch/powerpc/oftree.h | 4
xen/arch/powerpc/setup.c | 155 +++++---
xen/arch/powerpc/shadow.c | 2
xen/arch/powerpc/sysctl.c | 1
xen/arch/x86/acpi/boot.c | 15
xen/arch/x86/domain_build.c | 7
xen/arch/x86/hvm/instrlen.c | 113 ++----
xen/arch/x86/hvm/platform.c | 14
xen/arch/x86/hvm/svm/intr.c | 83 ++--
xen/arch/x86/hvm/svm/svm.c | 87 ++--
xen/arch/x86/hvm/vmx/intr.c | 78 +---
xen/arch/x86/hvm/vmx/vmcs.c | 17
xen/arch/x86/hvm/vmx/vmx.c | 167 +++------
xen/arch/x86/mm/shadow/multi.c | 2
xen/common/libelf/libelf-dominfo.c | 101 +++++
xen/common/libelf/libelf-loader.c | 44 ++
xen/common/libelf/libelf-tools.c | 30 +
xen/drivers/acpi/tables.c | 154 ++++++++
xen/include/asm-ia64/dom_fw_common.h | 1
xen/include/asm-powerpc/grant_table.h | 5
xen/include/asm-powerpc/mm.h | 9
xen/include/asm-powerpc/numa.h | 25 +
xen/include/asm-powerpc/shadow.h | 14
xen/include/asm-x86/hvm/hvm.h | 70 +++
xen/include/asm-x86/hvm/svm/vmcb.h | 8
xen/include/asm-x86/hvm/vmx/vmcs.h | 7
xen/include/asm-x86/hvm/vmx/vmx.h | 36 --
xen/include/public/libelf.h | 76 ++--
xen/include/xen/acpi.h | 3
53 files changed, 965 insertions(+), 804 deletions(-)

diff -r 77c87416fbd0 -r d83c9d87ede4 tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/blktap/drivers/blktapctrl.c Wed Aug 01 16:40:30 2007 -0600
@@ -42,6 +42,7 @@
#include <errno.h>
#include <sys/types.h>
#include <linux/types.h>
+#include <sys/wait.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/poll.h>
@@ -472,11 +473,38 @@ static int read_msg(int fd, int msgtype,

}

+int launch_tapdisk(char *wrctldev, char *rdctldev)
+{
+ char *argv[] = { "tapdisk", wrctldev, rdctldev, NULL };
+ pid_t child;
+
+ if ((child = fork()) < 0)
+ return -1;
+
+ if (!child) {
+ int i;
+ for (i = 0 ; i < sysconf(_SC_OPEN_MAX) ; i++)
+ if (i != STDIN_FILENO &&
+ i != STDOUT_FILENO &&
+ i != STDERR_FILENO)
+ close(i);
+
+ execvp("tapdisk", argv);
+ _exit(1);
+ } else {
+ pid_t got;
+ do {
+ got = waitpid(child, NULL, 0);
+ } while (got != child);
+ }
+ return 0;
+}
+
int blktapctrl_new_blkif(blkif_t *blkif)
{
blkif_info_t *blk;
int major, minor, fd_read, fd_write, type, new;
- char *rdctldev, *wrctldev, *cmd, *ptr;
+ char *rdctldev, *wrctldev, *ptr;
image_t *image;
blkif_t *exist = NULL;
static uint16_t next_cookie = 0;
@@ -504,12 +532,6 @@ int blktapctrl_new_blkif(blkif_t *blkif)
free(rdctldev);
return -1;
}
- if (asprintf(&cmd, "tapdisk %s %s", wrctldev, rdctldev) == -1) {
- free(rdctldev);
- free(wrctldev);
- return -1;
- }
-
blkif->fds[READ] = open_ctrl_socket(rdctldev);
blkif->fds[WRITE] = open_ctrl_socket(wrctldev);

@@ -517,15 +539,14 @@ int blktapctrl_new_blkif(blkif_t *blkif)
goto fail;

/*launch the new process*/
- DPRINTF("Launching process, CMDLINE [%s]\n",cmd);
- if (system(cmd) == -1) {
- DPRINTF("Unable to fork, cmdline: [%s]\n",cmd);
+ DPRINTF("Launching process, CMDLINE [tapdisk %s %s]\n",wrctldev, rdctldev);
+ if (launch_tapdisk(wrctldev, rdctldev) == -1) {
+ DPRINTF("Unable to fork, cmdline: [tapdisk %s %s]\n",wrctldev, rdctldev);
return -1;
}

free(rdctldev);
free(wrctldev);
- free(cmd);
} else {
DPRINTF("Process exists!\n");
blkif->fds[READ] = exist->fds[READ];
@@ -605,7 +626,6 @@ int open_ctrl_socket(char *devname)
{
int ret;
int ipc_fd;
- char *cmd;
fd_set socks;
struct timeval timeout;

diff -r 77c87416fbd0 -r d83c9d87ede4 tools/blktap/lib/blktaplib.h
--- a/tools/blktap/lib/blktaplib.h Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/blktap/lib/blktaplib.h Wed Aug 01 16:40:30 2007 -0600
@@ -169,12 +169,14 @@ typedef struct image {
unsigned int info;
} image_t;

+/* 16-byte message header, immediately followed by message payload. */
typedef struct msg_hdr {
- uint16_t type;
+ uint16_t type;
uint16_t len;
uint16_t drivertype;
uint16_t cookie;
uint8_t readonly;
+ uint8_t pad[7];
} msg_hdr_t;

typedef struct msg_newdev {
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/firmware/hvmloader/smbios.c
--- a/tools/firmware/hvmloader/smbios.c Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/firmware/hvmloader/smbios.c Wed Aug 01 16:40:30 2007 -0600
@@ -169,7 +169,7 @@ hvm_write_smbios_tables(void)
/* temporary variables used to build up Xen version string */
char *p = NULL; /* points to next point of insertion */
unsigned len = 0; /* length of string already composed */
- char *tmp = NULL; /* holds result of itoa() */
+ char tmp[16]; /* holds result of itoa() */
unsigned tmp_len; /* length of next string to add */

hypercall_xen_version(XENVER_guest_handle, uuid);
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/libxc/ia64/Makefile
--- a/tools/libxc/ia64/Makefile Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/libxc/ia64/Makefile Wed Aug 01 16:40:30 2007 -0600
@@ -5,6 +5,8 @@ GUEST_SRCS-y += ia64/xc_ia64_linux_resto
GUEST_SRCS-y += ia64/xc_ia64_linux_restore.c

GUEST_SRCS-y += ia64/xc_dom_ia64_util.c
+GUEST_SRCS-y += ia64/dom_fw_acpi.c
+
DOMFW_SRCS_BASE := dom_fw_common.c dom_fw_domu.c dom_fw_asm.S
DOMFW_SRCS := $(addprefix ia64/, $(DOMFW_SRCS_BASE))
$(DOMFW_SRCS):
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/libxc/ia64/dom_fw_acpi.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxc/ia64/dom_fw_acpi.c Wed Aug 01 16:40:30 2007 -0600
@@ -0,0 +1,13 @@
+#include <inttypes.h>
+#include <xen/acpi.h>
+
+uint8_t
+generate_acpi_checksum(void *tbl, unsigned long len)
+{
+ uint8_t *ptr, sum = 0;
+
+ for ( ptr = tbl; len > 0 ; len--, ptr++ )
+ sum += *ptr;
+
+ return 0 - sum;
+}
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/python/xen/util/acmpolicy.py
--- a/tools/python/xen/util/acmpolicy.py Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/python/xen/util/acmpolicy.py Wed Aug 01 16:40:30 2007 -0600
@@ -818,12 +818,13 @@ class ACMPolicy(XSPolicy):
if successful,the policy's flags will indicate that the
policy is the one loaded into the hypervisor
"""
- (ret, output) = commands.getstatusoutput(
+ if not self.isloaded():
+ (ret, output) = commands.getstatusoutput(
security.xensec_tool +
" loadpolicy " +
self.get_filename(".bin"))
- if ret != 0:
- return -xsconstants.XSERR_POLICY_LOAD_FAILED
+ if ret != 0:
+ return -xsconstants.XSERR_POLICY_LOAD_FAILED
return xsconstants.XSERR_SUCCESS

def isloaded(self):
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xenstore/utils.c
--- a/tools/xenstore/utils.c Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xenstore/utils.c Wed Aug 01 16:40:30 2007 -0600
@@ -8,20 +8,19 @@
#include <fcntl.h>
#include <sys/types.h>
#include <signal.h>
-
#include "utils.h"

void xprintf(const char *fmt, ...)
{
- static FILE *out = NULL;
va_list args;
- if (!out)
- out = stderr;
+
+ if (!stderr)
+ return; /* could trace()? */

va_start(args, fmt);
- vfprintf(out, fmt, args);
+ vfprintf(stderr, fmt, args);
va_end(args);
- fflush(out);
+ fflush(stderr);
}

void barf(const char *fmt, ...)
@@ -61,72 +60,3 @@ void barf_perror(const char *fmt, ...)
}
exit(1);
}
-
-void *_realloc_array(void *ptr, size_t size, size_t num)
-{
- if (num >= SIZE_MAX/size)
- return NULL;
- return realloc_nofail(ptr, size * num);
-}
-
-void *realloc_nofail(void *ptr, size_t size)
-{
- ptr = realloc(ptr, size);
- if (ptr)
- return ptr;
- barf("realloc of %zu failed", size);
-}
-
-void *malloc_nofail(size_t size)
-{
- void *ptr = malloc(size);
- if (ptr)
- return ptr;
- barf("malloc of %zu failed", size);
-}
-
-/* This version adds one byte (for nul term) */
-void *grab_file(const char *filename, unsigned long *size)
-{
- unsigned int max = 16384;
- int ret, fd;
- void *buffer;
-
- if (streq(filename, "-"))
- fd = dup(STDIN_FILENO);
- else
- fd = open(filename, O_RDONLY, 0);
-
- if (fd == -1)
- return NULL;
-
- buffer = malloc(max+1);
- if (!buffer)
- goto error;
- *size = 0;
- while ((ret = read(fd, buffer + *size, max - *size)) > 0) {
- *size += ret;
- if (*size == max) {
- void *nbuffer;
- max *= 2;
- nbuffer = realloc(buffer, max + 1);
- if (!nbuffer)
- goto error;
- buffer = nbuffer;
- }
- }
- if (ret < 0)
- goto error;
- ((char *)buffer)[*size] = '\0';
- close(fd);
- return buffer;
-error:
- free(buffer);
- close(fd);
- return NULL;
-}
-
-void release_file(void *data, unsigned long size __attribute__((unused)))
-{
- free(data);
-}
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xenstore/utils.h
--- a/tools/xenstore/utils.h Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xenstore/utils.h Wed Aug 01 16:40:30 2007 -0600
@@ -21,39 +21,12 @@ static inline bool strends(const char *a

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

-#define ___stringify(x) #x
-#define __stringify(x) ___stringify(x)
-
-/* Convenient wrappers for malloc and realloc. Use them. */
-#define new(type) ((type *)malloc_nofail(sizeof(type)))
-#define new_array(type, num) realloc_array((type *)0, (num))
-#define realloc_array(ptr, num) ((__typeof__(ptr))_realloc_array((ptr), sizeof((*ptr)), (num)))
-
-void *malloc_nofail(size_t size);
-void *realloc_nofail(void *ptr, size_t size);
-void *_realloc_array(void *ptr, size_t size, size_t num);
-
void barf(const char *fmt, ...) __attribute__((noreturn));
void barf_perror(const char *fmt, ...) __attribute__((noreturn));
-
-/* This version adds one byte (for nul term) */
-void *grab_file(const char *filename, unsigned long *size);
-void release_file(void *data, unsigned long size);
-
-/* Signal handling: returns fd to listen on. */
-int signal_to_fd(int signal);
-void close_signal(int fd);

void xprintf(const char *fmt, ...);

#define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
-#define iprintf(_fmt, _args...) xprintf("[INF] %s" _fmt, __FUNCTION__, ##_args)
-
-#ifdef DEBUG
-#define dprintf(_fmt, _args...) xprintf("[DBG] %s" _fmt, __FUNCTION__, ##_args)
-#else
-#define dprintf(_fmt, _args...) ((void)0)
-#endif

/*
* Mux errno values onto returned pointers.
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xenstore/xenstored_core.c Wed Aug 01 16:40:30 2007 -0600
@@ -1820,7 +1820,9 @@ int main(int argc, char *argv[])
if (pidfile)
write_pidfile(pidfile);

- talloc_enable_leak_report_full();
+ /* Talloc leak reports go to stderr, which is closed if we fork. */
+ if (!dofork)
+ talloc_enable_leak_report_full();

/* Create sockets for them to listen to. */
sock = talloc(talloc_autofree_context(), int);
@@ -1881,6 +1883,11 @@ int main(int argc, char *argv[])
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
+
+ /* Get ourselves a nice xenstored crash if these are used. */
+ stdin = NULL;
+ stdout = NULL;
+ stderr = NULL;
}

signal(SIGHUP, trigger_reopen_log);
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xenstore/xenstored_domain.c Wed Aug 01 16:40:30 2007 -0600
@@ -621,13 +621,8 @@ void domain_entry_fix(unsigned int domid
struct domain *d;

d = find_domain_by_domid(domid);
- if (d) {
- if ((d->nbentry += num) < 0) {
- eprintf("invalid domain entry number %d",
- d->nbentry);
- d->nbentry = 0;
- }
- }
+ if (d && ((d->nbentry += num) < 0))
+ d->nbentry = 0;
}

int domain_entry(struct connection *conn)
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xenstore/xs_tdb_dump.c
--- a/tools/xenstore/xs_tdb_dump.c Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xenstore/xs_tdb_dump.c Wed Aug 01 16:40:30 2007 -0600
@@ -4,7 +4,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
-
+#include <string.h>
#include "xs_lib.h"
#include "tdb.h"
#include "talloc.h"
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xm-test/lib/XmTestLib/acm.py
--- a/tools/xm-test/lib/XmTestLib/acm.py Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xm-test/lib/XmTestLib/acm.py Wed Aug 01 16:40:30 2007 -0600
@@ -67,6 +67,10 @@ def ACMLoadPolicy(policy='xm-test'):
if main.serverType == main.SERVER_XEN_API:
ACMLoadPolicy_XenAPI()
else:
+ cmd='xm dumppolicy | grep -E "^POLICY REFERENCE = ' + policy + '.$"'
+ s, o = traceCommand(cmd)
+ if o != "":
+ return
s, o = traceCommand("xm makepolicy %s" % (policy))
if s != 0:
FAIL("Need to be able to do 'xm makepolicy %s' but could not" %
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xm-test/tests/security-acm/07_security-acm_pol_update.py
--- a/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xm-test/tests/security-acm/07_security-acm_pol_update.py Wed Aug 01 16:40:30 2007 -0600
@@ -12,10 +12,19 @@ from xen.util import acmpolicy, security
from xen.util import acmpolicy, security, xsconstants
from xen.util.acmpolicy import ACMPolicy
from xen.xend.XendDomain import DOM0_UUID
+from XmTestLib.acm import *

import commands
import os
import base64
+
+if not isACMEnabled():
+ SKIP("Not running this test since ACM not enabled.")
+
+try:
+ session = xapi.connect()
+except:
+ SKIP("Skipping this test since xm is not using the Xen-API.")

xm_test = {}
xm_test['policyname'] = "xm-test"
diff -r 77c87416fbd0 -r d83c9d87ede4 tools/xm-test/tests/security-acm/09_security-acm_pol_update.py
--- a/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py Wed Aug 01 09:40:58 2007 -0600
+++ b/tools/xm-test/tests/security-acm/09_security-acm_pol_update.py Wed Aug 01 16:40:30 2007 -0600
@@ -7,6 +7,7 @@

from XmTestLib import xapi
from XmTestLib.XenAPIDomain import XmTestAPIDomain
+from XmTestLib.acm import *
from XmTestLib import *
from xen.xend import XendAPIConstants
from xen.util import security, xsconstants
@@ -15,6 +16,14 @@ import base64
import base64
import struct
import time
+
+if not isACMEnabled():
+ SKIP("Not running this test since ACM not enabled.")
+
+try:
+ session = xapi.connect()
+except:
+ SKIP("Skipping this test since xm is not using the Xen-API.")

def typestoxml(types):
res = ""
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/ia64/xen/dom_fw_common.c
--- a/xen/arch/ia64/xen/dom_fw_common.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/ia64/xen/dom_fw_common.c Wed Aug 01 16:40:30 2007 -0600
@@ -207,17 +207,6 @@ print_md(efi_memory_desc_t *md)
printk("(%luKB)\n", size >> 10);
}

-uint8_t
-generate_acpi_checksum(void *tbl, unsigned long len)
-{
- uint8_t *ptr, sum = 0;
-
- for (ptr = tbl; len > 0 ; len--, ptr++)
- sum += *ptr;
-
- return 0 - sum;
-}
-
struct fake_acpi_tables {
struct acpi20_table_rsdp rsdp;
struct xsdt_descriptor_rev2 xsdt;
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/ia64/xen/dom_fw_dom0.c
--- a/xen/arch/ia64/xen/dom_fw_dom0.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/ia64/xen/dom_fw_dom0.c Wed Aug 01 16:40:30 2007 -0600
@@ -103,6 +103,7 @@ acpi_update_madt_checksum(unsigned long
/* base is physical address of acpi table */
static void __init touch_acpi_table(void)
{
+ int result;
lsapic_nbr = 0;

if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
@@ -110,6 +111,18 @@ static void __init touch_acpi_table(void
if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC,
acpi_patch_plat_int_src, 0) < 0)
printk("Error parsing MADT - no PLAT_INT_SRC entries\n");
+
+ result = acpi_table_disable(ACPI_SRAT);
+ if ( result == 0 )
+ printk("Success Disabling SRAT\n");
+ else if ( result != -ENOENT )
+ printk("ERROR: Failed Disabling SRAT\n");
+
+ result = acpi_table_disable(ACPI_SLIT);
+ if ( result == 0 )
+ printk("Success Disabling SLIT\n");
+ else if ( result != -ENOENT )
+ printk("ERROR: Failed Disabling SLIT\n");

acpi_table_parse(ACPI_APIC, acpi_update_madt_checksum);

diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/Makefile
--- a/xen/arch/powerpc/Makefile Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/Makefile Wed Aug 01 16:40:30 2007 -0600
@@ -27,6 +27,7 @@ obj-y += mm.o
obj-y += mm.o
obj-y += mpic.o
obj-y += mpic_init.o
+obj-y += multiboot2.o
obj-y += numa.o
obj-y += of-devtree.o
obj-y += of-devwalk.o
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/boot_of.c
--- a/xen/arch/powerpc/boot_of.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/boot_of.c Wed Aug 01 16:40:30 2007 -0600
@@ -22,7 +22,6 @@
#include <xen/config.h>
#include <xen/init.h>
#include <xen/lib.h>
-#include <xen/multiboot.h>
#include <xen/version.h>
#include <xen/spinlock.h>
#include <xen/serial.h>
@@ -30,6 +29,7 @@
#include <xen/sched.h>
#include <asm/page.h>
#include <asm/io.h>
+#include <asm/boot.h>
#include "exceptions.h"
#include "of-devtree.h"
#include "oftree.h"
@@ -54,7 +54,6 @@ static ulong eomem;
#define MEM_AVAILABLE_PAGES ((32 << 20) >> PAGE_SHIFT)
static DECLARE_BITMAP(mem_available_pages, MEM_AVAILABLE_PAGES);

-extern char builtin_cmdline[];
extern struct ns16550_defaults ns16550;

#undef OF_DEBUG
@@ -648,23 +647,6 @@ static ulong boot_of_mem_init(void)
return 0;
}

-static void boot_of_bootargs(multiboot_info_t *mbi)
-{
- int rc;
-
- if (builtin_cmdline[0] == '\0') {
- rc = of_getprop(bof_chosen, "bootargs", builtin_cmdline,
- CONFIG_CMDLINE_SIZE);
- if (rc > CONFIG_CMDLINE_SIZE)
- of_panic("bootargs[] not big enough for /chosen/bootargs\n");
- }
-
- mbi->flags |= MBI_CMDLINE;
- mbi->cmdline = (ulong)builtin_cmdline;
-
- of_printf("bootargs = %s\n", builtin_cmdline);
-}
-
static int save_props(void *m, ofdn_t n, int pkg)
{
int ret;
@@ -933,8 +915,8 @@ static void __init boot_of_fix_maple(voi
}
}
}
-
-static int __init boot_of_serial(void *oft)
+
+void __init boot_of_serial(void *oft)
{
int n;
int p;
@@ -1014,11 +996,9 @@ static int __init boot_of_serial(void *o
__func__, ns16550.irq);
ns16550.irq = 0;
}
-
- return 1;
-}
-
-static int __init boot_of_rtas(module_t *mod, multiboot_info_t *mbi)
+}
+
+static int __init boot_of_rtas(void)
{
int rtas_node;
int rtas_instance;
@@ -1065,14 +1045,13 @@ static int __init boot_of_rtas(module_t
rtas_end = mem + size;
rtas_msr = of_msr;

- mod->mod_start = rtas_base;
- mod->mod_end = rtas_end;
return 1;
}

-static void * __init boot_of_devtree(module_t *mod, multiboot_info_t *mbi)
+void __init *boot_of_devtree(void)
{
void *oft;
+ ulong oft_sz = 48 * PAGE_SIZE;
ulong alloc_sz = 32 << 10; /* 32KiB should be plenty */
ulong sz;

@@ -1100,108 +1079,9 @@ static void * __init boot_of_devtree(mod

ofd_walk(oft, __func__, OFD_ROOT, /* add_hype_props */ NULL, 2);

- mod->mod_start = (ulong)oft;
- mod->mod_end = ALIGN_UP(mod->mod_start + sz, PAGE_SIZE);
-
- if (mod->mod_end -mod->mod_start > alloc_sz)
- of_panic("Could not fit all devtree module in 0x%lx of memory\n",
- alloc_sz);
-
- of_printf("%s: devtree mod @ 0x%016x - 0x%016x\n", __func__,
- mod->mod_start, mod->mod_end);
-
- return oft;
-}
-
-static void * __init boot_of_module(ulong r3, ulong r4, multiboot_info_t *mbi)
-{
- static module_t mods[4];
- ulong mod0_start;
- ulong mod0_size;
- static const char * sepr[] = {" -- ", " || "};
- int sepr_index;
- extern char dom0_start[] __attribute__ ((weak));
- extern char dom0_size[] __attribute__ ((weak));
- const char *p = NULL;
- int mod;
- void *oft;
-
- if ((r3 > 0) && (r4 > 0)) {
- /* was it handed to us in registers ? */
- mod0_start = r3;
- mod0_size = r4;
- of_printf("%s: Dom0 was loaded and found using r3/r4:"
- "0x%lx[size 0x%lx]\n",
- __func__, mod0_start, mod0_size);
- } else {
- /* see if it is in the boot params */
- p = strstr((char *)((ulong)mbi->cmdline), "dom0_start=");
- if ( p != NULL) {
- p += 11;
- mod0_start = simple_strtoul(p, NULL, 0);
-
- p = strstr((char *)((ulong)mbi->cmdline), "dom0_size=");
- p += 10;
- mod0_size = simple_strtoul(p, NULL, 0);
- of_printf("%s: Dom0 was loaded and found using cmdline:"
- "0x%lx[size 0x%lx]\n",
- __func__, mod0_start, mod0_size);
- } else if ( ((ulong)dom0_start != 0) && ((ulong)dom0_size != 0) ) {
- /* was it linked in ? */
-
- mod0_start = (ulong)dom0_start;
- mod0_size = (ulong)dom0_size;
- of_printf("%s: Dom0 is linked in: 0x%lx[size 0x%lx]\n",
- __func__, mod0_start, mod0_size);
- } else {
- mod0_start = (ulong)_end;
- mod0_size = 0;
- of_printf("%s: FYI Dom0 is unknown, will be caught later\n",
- __func__);
- }
- }
-
- if (mod0_size > 0) {
- const char *c = (const char *)mod0_start;
-
- of_printf("mod0: %o %c %c %c\n", c[0], c[1], c[2], c[3]);
- }
-
- mod = 0;
- mods[mod].mod_start = mod0_start;
- mods[mod].mod_end = mod0_start + mod0_size;
-
- of_printf("%s: dom0 mod @ 0x%016x[0x%x]\n", __func__,
- mods[mod].mod_start, mods[mod].mod_end);
-
- /* look for delimiter: "--" or "||" */
- for (sepr_index = 0; sepr_index < ARRAY_SIZE(sepr); sepr_index++){
- p = strstr((char *)(ulong)mbi->cmdline, sepr[sepr_index]);
- if (p != NULL)
- break;
- }
-
- if (p != NULL) {
- /* Xen proper should never know about the dom0 args. */
- *(char *)p = '\0';
- p += strlen(sepr[sepr_index]);
- mods[mod].string = (u32)(ulong)p;
- of_printf("%s: dom0 mod string: %s\n", __func__, p);
- }
-
- ++mod;
- if (boot_of_rtas(&mods[mod], mbi))
- ++mod;
-
- oft = boot_of_devtree(&mods[mod], mbi);
- if (oft == NULL)
- of_panic("%s: boot_of_devtree failed\n", __func__);
-
- ++mod;
-
- mbi->flags |= MBI_MODULES;
- mbi->mods_count = mod;
- mbi->mods_addr = (u32)mods;
+ oftree = (ulong)oft;
+ oftree = (ulong)oft + oft_sz;
+ oftree_len = oft_sz;

return oft;
}
@@ -1327,15 +1207,19 @@ static int __init boot_of_cpus(void)
return 1;
}

-multiboot_info_t __init *boot_of_init(
- ulong r3, ulong r4, ulong vec, ulong r6, ulong r7, ulong orig_msr)
-{
- static multiboot_info_t mbi;
- void *oft;
+void __init boot_of_init(ulong vec, ulong orig_msr)
+{
int r;

of_vec = vec;
of_msr = orig_msr;
+
+ if (is_kernel(vec)) {
+ of_panic("Hmm.. OF[0x%lx] seems to have stepped on our image "
+ "that ranges: %p .. %p.\n",
+ vec, _start, _end);
+ }
+ of_printf("%s: _start %p _end %p\n", __func__, _start, _end);

bof_chosen = of_finddevice("/chosen");
of_getprop(bof_chosen, "stdout", &of_out, sizeof (of_out));
@@ -1346,32 +1230,20 @@ multiboot_info_t __init *boot_of_init(
xen_compile_by(), xen_compile_domain(),
xen_compiler(), xen_compile_date());

- of_printf("%s args: 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n"
- "boot msr: 0x%lx\n",
- __func__,
- r3, r4, vec, r6, r7, orig_msr);
-
- if (is_kernel(vec)) {
- of_panic("Hmm.. OF[0x%lx] seems to have stepped on our image "
- "that ranges: %p .. %p.\n",
- vec, _start, _end);
- }
- of_printf("%s: _start %p _end %p 0x%lx\n", __func__, _start, _end, r6);
-
boot_of_fix_maple();
r = boot_of_mem_init();
if (r == 0)
of_panic("failure to initialize memory allocator");
- boot_of_bootargs(&mbi);
- oft = boot_of_module(r3, r4, &mbi);
+
+ boot_of_rtas();
boot_of_cpus();
- boot_of_serial(oft);
-
+}
+
+void __init boot_of_finish(void)
+{
/* end of OF */
of_printf("Quiescing Open Firmware ...\n");
of_call("quiesce", 0, 0, NULL);
-
- return &mbi;
}

/*
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/domain.c
--- a/xen/arch/powerpc/domain.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/domain.c Wed Aug 01 16:40:30 2007 -0600
@@ -29,7 +29,7 @@
#include <xen/domain.h>
#include <xen/console.h>
#include <xen/shutdown.h>
-#include <xen/shadow.h>
+#include <xen/paging.h>
#include <xen/mm.h>
#include <xen/softirq.h>
#include <asm/htab.h>
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/domain_build.c
--- a/xen/arch/powerpc/domain_build.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/domain_build.c Wed Aug 01 16:40:30 2007 -0600
@@ -26,10 +26,9 @@
#include <xen/init.h>
#include <xen/ctype.h>
#include <xen/iocap.h>
-#include <xen/shadow.h>
#include <xen/domain.h>
#include <xen/version.h>
-#include <xen/shadow.h>
+#include <xen/paging.h>
#include <asm/processor.h>
#include <asm/platform.h>
#include <asm/papr.h>
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/domctl.c
--- a/xen/arch/powerpc/domctl.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/domctl.c Wed Aug 01 16:40:30 2007 -0600
@@ -25,7 +25,7 @@
#include <xen/sched.h>
#include <xen/domain.h>
#include <xen/guest_access.h>
-#include <xen/shadow.h>
+#include <xen/paging.h>
#include <public/xen.h>
#include <public/domctl.h>
#include <public/sysctl.h>
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/exceptions.h
--- a/xen/arch/powerpc/exceptions.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/exceptions.h Wed Aug 01 16:40:30 2007 -0600
@@ -33,9 +33,6 @@ extern void ack_APIC_irq(void);
extern void ack_APIC_irq(void);
extern int ioapic_guest_read(unsigned long physbase, unsigned int reg, u32 *pval);
extern int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 val);
-extern void __start_xen_ppc(
- ulong r3, ulong r4, ulong r5, ulong r6, ulong r7, ulong orig_msr);
-extern multiboot_info_t *boot_of_init(ulong r3, ulong r4, ulong vec, ulong r6, ulong r7, ulong orig_msr);

extern void do_timer(struct cpu_user_regs *regs);
extern void do_dec(struct cpu_user_regs *regs);
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/memory.c
--- a/xen/arch/powerpc/memory.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/memory.c Wed Aug 01 16:40:30 2007 -0600
@@ -21,6 +21,7 @@
#include <xen/sched.h>
#include <xen/mm.h>
#include <xen/numa.h>
+#include <asm/boot.h>
#include "of-devtree.h"
#include "oftree.h"
#include "rtas.h"
@@ -116,7 +117,7 @@ static void ofd_walk_mem(void *m, walk_m
}
}

-void memory_init(module_t *mod, int mcount)
+void memory_init(void)
{
ulong eomem;
ulong bitmap_start = ~0UL;
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/mm.c Wed Aug 01 16:40:30 2007 -0600
@@ -22,7 +22,7 @@

#include <xen/config.h>
#include <xen/mm.h>
-#include <xen/shadow.h>
+#include <xen/paging.h>
#include <xen/kernel.h>
#include <xen/sched.h>
#include <xen/perfc.h>
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/oftree.h
--- a/xen/arch/powerpc/oftree.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/oftree.h Wed Aug 01 16:40:30 2007 -0600
@@ -13,7 +13,7 @@
* along with this program; if not, write to the Free Software
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Copyright (C) IBM Corp. 2005
+ * Copyright IBM Corp. 2005
*
* Authors: Jimi Xenidis <jimix@watson.ibm.com>
*/
@@ -35,6 +35,4 @@ extern int firmware_image_start[0];
extern int firmware_image_start[0];
extern int firmware_image_size[0];

-extern void memory_init(module_t *mod, int mcount);
-
#endif /* #ifndef _OFTREE_H */
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/setup.c
--- a/xen/arch/powerpc/setup.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/setup.c Wed Aug 01 16:40:30 2007 -0600
@@ -25,7 +25,7 @@
#include <xen/lib.h>
#include <xen/cpumask.h>
#include <xen/sched.h>
-#include <xen/multiboot.h>
+#include <xen/multiboot2.h>
#include <xen/serial.h>
#include <xen/softirq.h>
#include <xen/console.h>
@@ -48,6 +48,7 @@
#include <asm/delay.h>
#include <asm/percpu.h>
#include <asm/io.h>
+#include <asm/boot.h>
#include "exceptions.h"
#include "of-devtree.h"
#include "oftree.h"
@@ -78,6 +79,17 @@ ulong oftree;
ulong oftree;
ulong oftree_len;
ulong oftree_end;
+
+/* linked-in dom0: */
+extern char dom0_start[] __attribute__ ((weak));
+extern char dom0_size[] __attribute__ ((weak));
+
+char *xen_cmdline;
+char *dom0_cmdline;
+ulong dom0_addr;
+ulong dom0_len;
+ulong initrd_start;
+ulong initrd_len;

uint cpu_hard_id[NR_CPUS] __initdata;
cpumask_t cpu_present_map;
@@ -286,21 +298,15 @@ void secondary_cpu_init(int cpuid, unsig
panic("should never get here\n");
}

-static void __init __start_xen(multiboot_info_t *mbi)
-{
- char *cmdline;
- module_t *mod = (module_t *)((ulong)mbi->mods_addr);
- ulong dom0_start, dom0_len;
- ulong initrd_start, initrd_len;
-
+static void __init __start_xen(void)
+{
memcpy(0, exception_vectors, exception_vectors_end - exception_vectors);
synchronize_caches(0, exception_vectors_end - exception_vectors);

ticks_per_usec = timebase_freq / 1000000ULL;

/* Parse the command-line options. */
- if ((mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0))
- cmdline_parse(__va((ulong)mbi->cmdline));
+ cmdline_parse(xen_cmdline);

/* we need to be able to identify this CPU early on */
init_boot_cpu();
@@ -313,32 +319,20 @@ static void __init __start_xen(multiboot
serial_init_preirq();

init_console();
- /* let synchronize until we really get going */
- console_start_sync();
-
- /* Check that we have at least one Multiboot module. */
- if (!(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0)) {
- panic("FATAL ERROR: Require at least one Multiboot module.\n");
- }
-
- /* OF dev tree is the last module */
- oftree = mod[mbi->mods_count-1].mod_start;
- oftree_end = mod[mbi->mods_count-1].mod_end;
- oftree_len = oftree_end - oftree;
-
- /* remove it from consideration */
- mod[mbi->mods_count-1].mod_start = 0;
- mod[mbi->mods_count-1].mod_end = 0;
- --mbi->mods_count;
-
- if (rtas_entry) {
- rtas_init((void *)oftree);
- /* remove rtas module from consideration */
- mod[mbi->mods_count-1].mod_start = 0;
- mod[mbi->mods_count-1].mod_end = 0;
- --mbi->mods_count;
- }
- memory_init(mod, mbi->mods_count);
+ console_start_sync(); /* Stay synchronous for early debugging. */
+
+ rtas_init((void *)oftree);
+
+ memory_init();
+
+ printk("xen_cmdline: %016lx\n", (ulong)xen_cmdline);
+ printk("dom0_cmdline: %016lx\n", (ulong)dom0_cmdline);
+ printk("dom0_addr: %016lx\n", (ulong)dom0_addr);
+ printk("dom0_len: %016lx\n", (ulong)dom0_len);
+ printk("initrd_start: %016lx\n", (ulong)initrd_start);
+ printk("initrd_len: %016lx\n", (ulong)initrd_len);
+
+ printk("dom0: %016llx\n", *(unsigned long long *)dom0_addr);

#ifdef OF_DEBUG
key_ofdump(0);
@@ -382,30 +376,22 @@ static void __init __start_xen(multiboot

dom0->is_privileged = 1;

- cmdline = (char *)(mod[0].string ? __va((ulong)mod[0].string) : NULL);
-
/* scrub_heap_pages() requires IRQs enabled, and we're post IRQ setup... */
local_irq_enable();
/* Scrub RAM that is still free and so may go to an unprivileged domain. */
scrub_heap_pages();

- dom0_start = mod[0].mod_start;
- dom0_len = mod[0].mod_end - mod[0].mod_start;
- if (mbi->mods_count > 1) {
- initrd_start = mod[1].mod_start;
- initrd_len = mod[1].mod_end - mod[1].mod_start;
- } else {
- initrd_start = 0;
- initrd_len = 0;
- }
- if (construct_dom0(dom0, dom0_start, dom0_len,
+ if ((dom0_addr == 0) || (dom0_len == 0))
+ panic("No domain 0 found.\n");
+
+ if (construct_dom0(dom0, dom0_addr, dom0_len,
initrd_start, initrd_len,
- cmdline) != 0) {
+ dom0_cmdline) != 0) {
panic("Could not set up DOM0 guest OS\n");
}

- init_xenheap_pages(ALIGN_UP(dom0_start, PAGE_SIZE),
- ALIGN_DOWN(dom0_start + dom0_len, PAGE_SIZE));
+ init_xenheap_pages(ALIGN_UP(dom0_addr, PAGE_SIZE),
+ ALIGN_DOWN(dom0_addr + dom0_len, PAGE_SIZE));
if (initrd_start)
init_xenheap_pages(ALIGN_UP(initrd_start, PAGE_SIZE),
ALIGN_DOWN(initrd_start + initrd_len, PAGE_SIZE));
@@ -426,25 +412,74 @@ static void __init __start_xen(multiboot
startup_cpu_idle_loop();
}

+static void ofd_bootargs(void)
+{
+ static const char *sepr[] = {" -- ", " || "};
+ char *p;
+ ofdn_t chosen;
+ int sepr_index;
+ int rc;
+
+ if (builtin_cmdline[0] == '\0') {
+ chosen = ofd_node_find((void *)oftree, "/chosen");
+ rc = ofd_getprop((void *)oftree, chosen, "bootargs", builtin_cmdline,
+ CONFIG_CMDLINE_SIZE);
+ }
+
+ /* look for delimiter: "--" or "||" */
+ for (sepr_index = 0; sepr_index < ARRAY_SIZE(sepr); sepr_index++){
+ p = strstr(builtin_cmdline, sepr[sepr_index]);
+ if (p != NULL) {
+ /* Xen proper should never know about the dom0 args. */
+ *p = '\0';
+ p += strlen(sepr[sepr_index]);
+ dom0_cmdline = p;
+ break;
+ }
+ }
+
+ xen_cmdline = builtin_cmdline;
+}
+
+void __init __start_xen_ppc(ulong, ulong, ulong, ulong, ulong, ulong);
void __init __start_xen_ppc(
ulong r3, ulong r4, ulong r5, ulong r6, ulong r7, ulong orig_msr)
{
- multiboot_info_t *mbi = NULL;
-
/* clear bss */
memset(__bss_start, 0, (ulong)_end - (ulong)__bss_start);

- if (r5 > 0) {
- /* we were booted by OpenFirmware */
- mbi = boot_of_init(r3, r4, r5, r6, r7, orig_msr);
-
+ if (r5) {
+ /* We came from Open Firmware. */
+ boot_of_init(r5, orig_msr);
+ oftree = (ulong)boot_of_devtree(); /* Copy the device tree. */
+ /* Use the device tree to find the Xen console. */
+ boot_of_serial((void *)oftree);
+ boot_of_finish(); /* End firmware. */
} else {
- /* booted by someone else that hopefully has a trap handler */
+ /* XXX handle flat device tree here */
__builtin_trap();
}

- __start_xen(mbi);
-
+ ofd_bootargs();
+
+ if (r3 == MB2_BOOTLOADER_MAGIC) {
+ /* Get dom0 info from multiboot structures. */
+ parse_multiboot(r4);
+ }
+
+ if ((dom0_len == 0) && r3 && r4) {
+ /* Maybe dom0's location handed to us in registers. */
+ dom0_addr = r3;
+ dom0_len = r4;
+ }
+
+ if (dom0_len == 0) {
+ /* Dom0 had better be built in. */
+ dom0_addr = (ulong)dom0_start;
+ dom0_len = (ulong)dom0_size;
+ }
+
+ __start_xen();
}

extern void arch_get_xen_caps(xen_capabilities_info_t *info);
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/shadow.c
--- a/xen/arch/powerpc/shadow.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/shadow.c Wed Aug 01 16:40:30 2007 -0600
@@ -20,7 +20,7 @@

#include <xen/config.h>
#include <xen/types.h>
-#include <xen/shadow.h>
+#include <xen/paging.h>

static ulong htab_calc_sdr1(ulong htab_addr, ulong log_htab_size)
{
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/powerpc/sysctl.c
--- a/xen/arch/powerpc/sysctl.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/powerpc/sysctl.c Wed Aug 01 16:40:30 2007 -0600
@@ -24,7 +24,6 @@
#include <xen/nodemask.h>
#include <xen/sched.h>
#include <xen/guest_access.h>
-#include <xen/shadow.h>
#include <public/xen.h>
#include <public/domctl.h>
#include <public/sysctl.h>
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/acpi/boot.c
--- a/xen/arch/x86/acpi/boot.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/acpi/boot.c Wed Aug 01 16:40:30 2007 -0600
@@ -371,11 +371,18 @@ extern u32 pmtmr_ioport;

#ifdef CONFIG_ACPI_SLEEP
/* Get pm1x_cnt and pm1x_evt information for ACPI sleep */
-static int __init
+static void __init
acpi_fadt_parse_sleep_info(struct fadt_descriptor_rev2 *fadt)
{
+ struct acpi_table_rsdp *rsdp;
+ unsigned long rsdp_phys;
struct facs_descriptor_rev2 *facs = NULL;
uint64_t facs_pa;
+
+ rsdp_phys = acpi_find_rsdp();
+ if (!rsdp_phys || acpi_disabled)
+ goto bad;
+ rsdp = __va(rsdp_phys);

if (fadt->revision >= FADT2_REVISION_ID) {
/* Sanity check on FADT Rev. 2 */
@@ -432,8 +439,7 @@ acpi_fadt_parse_sleep_info(struct fadt_d
"FACS is shorter than ACPI spec allow: 0x%x",
facs->length);

- if ((acpi_rsdp_rev < 2) ||
- (facs->length < 32)) {
+ if ((rsdp->revision < 2) || (facs->length < 32)) {
acpi_sinfo.wakeup_vector = facs_pa +
offsetof(struct facs_descriptor_rev2,
firmware_waking_vector);
@@ -451,10 +457,9 @@ acpi_fadt_parse_sleep_info(struct fadt_d
acpi_sinfo.pm1a_cnt, acpi_sinfo.pm1b_cnt,
acpi_sinfo.pm1a_evt, acpi_sinfo.pm1b_cnt,
acpi_sinfo.wakeup_vector, acpi_sinfo.vector_width);
- return 0;
+ return;
bad:
memset(&acpi_sinfo, 0, sizeof(acpi_sinfo));
- return 0;
}
#endif

diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/domain_build.c Wed Aug 01 16:40:30 2007 -0600
@@ -316,6 +316,9 @@ int __init construct_dom0(
parms.pae ? ", PAE" : "",
elf_msb(&elf) ? "msb" : "lsb",
elf.pstart, elf.pend);
+ if ( parms.bsd_symtab )
+ printk(" Dom0 symbol map 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
+ elf.sstart, elf.send);

if ( !compatible )
{
@@ -385,7 +388,7 @@ int __init construct_dom0(
v_start = parms.virt_base;
vkern_start = parms.virt_kstart;
vkern_end = parms.virt_kend;
- vinitrd_start = round_pgup(vkern_end);
+ vinitrd_start = round_pgup(parms.virt_end);
vinitrd_end = vinitrd_start + initrd_len;
vphysmap_start = round_pgup(vinitrd_end);
vphysmap_end = vphysmap_start + (nr_pages * (!is_pv_32on64_domain(d) ?
@@ -795,7 +798,7 @@ int __init construct_dom0(

/* Copy the OS image and free temporary buffer. */
elf.dest = (void*)vkern_start;
- elf_load_binary(&elf);
+ elf_xen_dom_load_binary(&elf, &parms);

if ( UNSET_ADDR != parms.virt_hypercall )
{
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/instrlen.c
--- a/xen/arch/x86/hvm/instrlen.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/instrlen.c Wed Aug 01 16:40:30 2007 -0600
@@ -7,14 +7,6 @@
*
* Essentially a very, very stripped version of Keir Fraser's work in
* x86_emulate.c. Used for MMIO.
- */
-
-/*
- * TODO: The way in which we use hvm_instruction_length is very inefficient as
- * it now stands. It will be worthwhile to return the actual instruction buffer
- * along with the instruction length since one of the reasons we are getting
- * the instruction length is to know how many instruction bytes we need to
- * fetch.
*/

#include <xen/config.h>
@@ -194,31 +186,51 @@ static uint8_t twobyte_table[256] = {
/*
* insn_fetch - fetch the next byte from instruction stream
*/
-#define insn_fetch() \
-({ uint8_t _x; \
- if ( length >= 15 ) \
- return -1; \
- if ( inst_copy_from_guest(&_x, pc, 1) != 1 ) { \
- gdprintk(XENLOG_WARNING, \
- "Cannot read from address %lx (eip %lx, mode %d)\n", \
- pc, org_pc, address_bytes); \
- return -1; \
- } \
- pc += 1; \
- length += 1; \
- _x; \
+#define insn_fetch() \
+({ uint8_t _x; \
+ if ( length >= 15 ) \
+ return -1; \
+ if ( inst_copy_from_guest(&_x, pc, 1) != 1 ) { \
+ unsigned long err; \
+ struct segment_register cs; \
+ gdprintk(XENLOG_WARNING, \
+ "Cannot read from address %lx (eip %lx, mode %d)\n", \
+ pc, org_pc, address_bytes); \
+ err = 0; /* Must be not-present: we don't enforce reserved bits */ \
+ if ( hvm_nx_enabled(current) ) \
+ err |= PFEC_insn_fetch; \
+ hvm_get_segment_register(current, x86_seg_cs, &cs); \
+ if ( cs.attr.fields.dpl != 0 ) \
+ err |= PFEC_user_mode; \
+ hvm_inject_exception(TRAP_page_fault, err, pc); \
+ return -1; \
+ } \
+ if ( buf ) \
+ buf[length] = _x; \
+ length += 1; \
+ pc += 1; \
+ _x; \
})

+#define insn_skip(_n) do { \
+ int _i; \
+ for ( _i = 0; _i < (_n); _i++) { \
+ (void) insn_fetch(); \
+ } \
+} while (0)
+
/**
- * hvm_instruction_length - returns the current instructions length
+ * hvm_instruction_fetch - read the current instruction and return its length
*
* @org_pc: guest instruction pointer
- * @mode: guest operating mode
+ * @address_bytes: guest address width
+ * @buf: (optional) buffer to load actual instruction bytes into
*
- * EXTERNAL this routine calculates the length of the current instruction
- * pointed to by org_pc. The guest state is _not_ changed by this routine.
+ * Doesn't increment the guest's instruction pointer, but may
+ * issue faults to the guest. Returns -1 on failure.
*/
-int hvm_instruction_length(unsigned long org_pc, int address_bytes)
+int hvm_instruction_fetch(unsigned long org_pc, int address_bytes,
+ unsigned char *buf)
{
uint8_t b, d, twobyte = 0, rex_prefix = 0, modrm_reg = 0;
unsigned int op_default, op_bytes, ad_default, ad_bytes, tmp;
@@ -317,18 +329,13 @@ done_prefixes:
{
case 0:
if ( modrm_rm == 6 )
- {
- length += 2;
- pc += 2; /* skip disp16 */
- }
+ insn_skip(2); /* skip disp16 */
break;
case 1:
- length += 1;
- pc += 1; /* skip disp8 */
+ insn_skip(1); /* skip disp8 */
break;
case 2:
- length += 2;
- pc += 2; /* skip disp16 */
+ insn_skip(2); /* skip disp16 */
break;
}
}
@@ -340,33 +347,19 @@ done_prefixes:
case 0:
if ( (modrm_rm == 4) &&
((insn_fetch() & 7) == 5) )
- {
- length += 4;
- pc += 4; /* skip disp32 specified by SIB.base */
- }
+ insn_skip(4); /* skip disp32 specified by SIB.base */
else if ( modrm_rm == 5 )
- {
- length += 4;
- pc += 4; /* skip disp32 */
- }
+ insn_skip(4); /* skip disp32 */
break;
case 1:
if ( modrm_rm == 4 )
- {
- length += 1;
- pc += 1;
- }
- length += 1;
- pc += 1; /* skip disp8 */
+ insn_skip(1);
+ insn_skip(1); /* skip disp8 */
break;
case 2:
if ( modrm_rm == 4 )
- {
- length += 1;
- pc += 1;
- }
- length += 4;
- pc += 4; /* skip disp32 */
+ insn_skip(1);
+ insn_skip(4); /* skip disp32 */
break;
}
}
@@ -387,12 +380,10 @@ done_prefixes:
tmp = (d & ByteOp) ? 1 : op_bytes;
if ( tmp == 8 ) tmp = 4;
/* NB. Immediates are sign-extended as necessary. */
- length += tmp;
- pc += tmp;
+ insn_skip(tmp);
break;
case SrcImmByte:
- length += 1;
- pc += 1;
+ insn_skip(1);
break;
}

@@ -402,8 +393,7 @@ done_prefixes:
switch ( b )
{
case 0xa0 ... 0xa3: /* mov */
- length += ad_bytes;
- pc += ad_bytes; /* skip src/dst displacement */
+ insn_skip(ad_bytes); /* skip src/dst displacement */
break;
case 0xf6 ... 0xf7: /* Grp3 */
switch ( modrm_reg )
@@ -412,8 +402,7 @@ done_prefixes:
/* Special case in Grp3: test has an immediate source operand. */
tmp = (d & ByteOp) ? 1 : op_bytes;
if ( tmp == 8 ) tmp = 4;
- length += tmp;
- pc += tmp;
+ insn_skip(tmp);
break;
}
break;
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/platform.c
--- a/xen/arch/x86/hvm/platform.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/platform.c Wed Aug 01 16:40:30 2007 -0600
@@ -1041,17 +1041,13 @@ void handle_mmio(unsigned long gpa)
/* real or vm86 modes */
address_bytes = 2;
inst_addr = hvm_get_segment_base(v, x86_seg_cs) + regs->eip;
- inst_len = hvm_instruction_length(inst_addr, address_bytes);
+ memset(inst, 0, MAX_INST_LEN);
+ inst_len = hvm_instruction_fetch(inst_addr, address_bytes, inst);
if ( inst_len <= 0 )
{
- printk("handle_mmio: failed to get instruction length\n");
- domain_crash_synchronous();
- }
-
- memset(inst, 0, MAX_INST_LEN);
- if ( inst_copy_from_guest(inst, inst_addr, inst_len) != inst_len ) {
- printk("handle_mmio: failed to copy instruction\n");
- domain_crash_synchronous();
+ gdprintk(XENLOG_DEBUG, "handle_mmio: failed to get instruction\n");
+ /* hvm_instruction_fetch() will have injected a #PF; get out now */
+ return;
}

if ( mmio_decode(address_bytes, inst, mmio_op, &ad_size,
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/svm/intr.c
--- a/xen/arch/x86/hvm/svm/intr.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/svm/intr.c Wed Aug 01 16:40:30 2007 -0600
@@ -58,7 +58,7 @@ static void svm_inject_nmi(struct vcpu *

event.bytes = 0;
event.fields.v = 1;
- event.fields.type = EVENTTYPE_NMI;
+ event.fields.type = X86_EVENTTYPE_NMI;
event.fields.vector = 2;

ASSERT(vmcb->eventinj.fields.v == 0);
@@ -72,34 +72,39 @@ static void svm_inject_extint(struct vcp

event.bytes = 0;
event.fields.v = 1;
- event.fields.type = EVENTTYPE_INTR;
+ event.fields.type = X86_EVENTTYPE_EXT_INTR;
event.fields.vector = vector;

ASSERT(vmcb->eventinj.fields.v == 0);
vmcb->eventinj = event;
}

+static void enable_intr_window(struct vcpu *v, enum hvm_intack intr_source)
+{
+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+
+ ASSERT(intr_source != hvm_intack_none);
+
+ /*
+ * Create a dummy virtual interrupt to intercept as soon as the
+ * guest can accept the real interrupt.
+ *
+ * TODO: Better NMI handling. We need a way to skip a MOV SS interrupt
+ * shadow. This is hard to do without hardware support. We should also
+ * track 'NMI blocking' from NMI injection until IRET. This can be done
+ * quite easily in software by intercepting the unblocking IRET.
+ */
+ vmcb->general1_intercepts |= GENERAL1_INTERCEPT_VINTR;
+ HVMTRACE_2D(INJ_VIRQ, v, 0x0, /*fake=*/ 1);
+ svm_inject_dummy_vintr(v);
+}
+
asmlinkage void svm_intr_assist(void)
{
struct vcpu *v = current;
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
enum hvm_intack intr_source;
int intr_vector;
-
- /*
- * Previous event delivery caused this intercept?
- * This will happen if the injection is latched by the processor (hence
- * clearing vintr.fields.irq or eventinj.v) but then subsequently a fault
- * occurs (e.g., due to lack of shadow mapping of guest IDT or guest-kernel
- * stack).
- */
- if ( vmcb->exitintinfo.fields.v )
- {
- vmcb->eventinj = vmcb->exitintinfo;
- vmcb->exitintinfo.bytes = 0;
- HVMTRACE_1D(REINJ_VIRQ, v, intr_vector);
- return;
- }

/* Crank the handle on interrupt state. */
pt_update_irq(v);
@@ -111,32 +116,23 @@ asmlinkage void svm_intr_assist(void)
return;

/*
- * If the guest can't take an interrupt right now, create a 'fake'
- * virtual interrupt on to intercept as soon as the guest _can_ take
- * interrupts. Do not obtain the next interrupt from the vlapic/pic
- * if unable to inject.
- *
- * Also do this if there is an injection already pending. This is
- * because the event delivery can arbitrarily delay the injection
- * of the vintr (for example, if the exception is handled via an
- * interrupt gate, hence zeroing RFLAGS.IF). In the meantime:
- * - the vTPR could be modified upwards, so we need to wait until the
- * exception is delivered before we can safely decide that an
- * interrupt is deliverable; and
- * - the guest might look at the APIC/PIC state, so we ought not to
- * have cleared the interrupt out of the IRR.
- *
- * TODO: Better NMI handling. We need a way to skip a MOV SS interrupt
- * shadow. This is hard to do without hardware support. We should also
- * track 'NMI blocking' from NMI injection until IRET. This can be done
- * quite easily in software by intercepting the unblocking IRET.
+ * Pending IRQs must be delayed if:
+ * 1. An event is already pending. This is despite the fact that SVM
+ * provides a VINTR delivery method quite separate from the EVENTINJ
+ * mechanism. The event delivery can arbitrarily delay the injection
+ * of the vintr (for example, if the exception is handled via an
+ * interrupt gate, hence zeroing RFLAGS.IF). In the meantime:
+ * - the vTPR could be modified upwards, so we need to wait until
+ * the exception is delivered before we can safely decide that an
+ * interrupt is deliverable; and
+ * - the guest might look at the APIC/PIC state, so we ought not to
+ * have cleared the interrupt out of the IRR.
+ * 2. The IRQ is masked.
*/
- if ( !hvm_interrupts_enabled(v, intr_source) ||
- vmcb->eventinj.fields.v )
+ if ( unlikely(vmcb->eventinj.fields.v) ||
+ !hvm_interrupts_enabled(v, intr_source) )
{
- vmcb->general1_intercepts |= GENERAL1_INTERCEPT_VINTR;
- HVMTRACE_2D(INJ_VIRQ, v, 0x0, /*fake=*/ 1);
- svm_inject_dummy_vintr(v);
+ enable_intr_window(v, intr_source);
return;
}
} while ( !hvm_vcpu_ack_pending_irq(v, intr_source, &intr_vector) );
@@ -151,6 +147,11 @@ asmlinkage void svm_intr_assist(void)
svm_inject_extint(v, intr_vector);
pt_intr_post(v, intr_vector, intr_source);
}
+
+ /* Is there another IRQ to queue up behind this one? */
+ intr_source = hvm_vcpu_has_pending_irq(v);
+ if ( unlikely(intr_source != hvm_intack_none) )
+ enable_intr_window(v, intr_source);
}

/*
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/svm/svm.c Wed Aug 01 16:40:30 2007 -0600
@@ -71,8 +71,8 @@ static void *root_vmcb[NR_CPUS] __read_m
/* hardware assisted paging bits */
extern int opt_hap_enabled;

-static void svm_inject_exception(struct vcpu *v, int trap,
- int ev, int error_code)
+static void svm_inject_exception(
+ struct vcpu *v, int trap, int ev, int error_code)
{
eventinj_t event;
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
@@ -84,13 +84,11 @@ static void svm_inject_exception(struct

event.bytes = 0;
event.fields.v = 1;
- event.fields.type = EVENTTYPE_EXCEPTION;
+ event.fields.type = X86_EVENTTYPE_HW_EXCEPTION;
event.fields.vector = trap;
event.fields.ev = ev;
event.fields.errorcode = error_code;

- ASSERT(vmcb->eventinj.fields.v == 0);
-
vmcb->eventinj = event;
}

@@ -362,21 +360,14 @@ int svm_vmcb_save(struct vcpu *v, struct
c->sysenter_esp = vmcb->sysenter_esp;
c->sysenter_eip = vmcb->sysenter_eip;

- /* Save any event/interrupt that was being injected when we last exited. */
- if ( vmcb->exitintinfo.fields.v )
- {
- c->pending_event = vmcb->exitintinfo.bytes & 0xffffffff;
- c->error_code = vmcb->exitintinfo.fields.errorcode;
- }
- else if ( vmcb->eventinj.fields.v )
- {
- c->pending_event = vmcb->eventinj.bytes & 0xffffffff;
+ c->pending_event = 0;
+ c->error_code = 0;
+ if ( vmcb->eventinj.fields.v &&
+ hvm_event_needs_reinjection(vmcb->eventinj.fields.type,
+ vmcb->eventinj.fields.vector) )
+ {
+ c->pending_event = (uint32_t)vmcb->eventinj.bytes;
c->error_code = vmcb->eventinj.fields.errorcode;
- }
- else
- {
- c->pending_event = 0;
- c->error_code = 0;
}

return 1;
@@ -495,11 +486,11 @@ int svm_vmcb_restore(struct vcpu *v, str
vmcb->sysenter_esp = c->sysenter_esp;
vmcb->sysenter_eip = c->sysenter_eip;

- /* update VMCB for nested paging restore */
- if ( paging_mode_hap(v->domain) ) {
+ if ( paging_mode_hap(v->domain) )
+ {
vmcb->cr0 = v->arch.hvm_svm.cpu_shadow_cr0;
- vmcb->cr4 = v->arch.hvm_svm.cpu_shadow_cr4 |
- (HVM_CR4_HOST_MASK & ~X86_CR4_PAE);
+ vmcb->cr4 = (v->arch.hvm_svm.cpu_shadow_cr4 |
+ (HVM_CR4_HOST_MASK & ~X86_CR4_PAE));
vmcb->cr3 = c->cr3;
vmcb->np_enable = 1;
vmcb->g_pat = 0x0007040600070406ULL; /* guest PAT */
@@ -514,26 +505,23 @@ int svm_vmcb_restore(struct vcpu *v, str
gdprintk(XENLOG_INFO, "Re-injecting 0x%"PRIx32", 0x%"PRIx32"\n",
c->pending_event, c->error_code);

- /* VMX uses a different type for #OF and #BP; fold into "Exception" */
- if ( c->pending_type == 6 )
- c->pending_type = 3;
- /* Sanity check */
- if ( c->pending_type == 1 || c->pending_type > 4
- || c->pending_reserved != 0 )
+ if ( (c->pending_type == 1) || (c->pending_type > 6) ||
+ (c->pending_reserved != 0) )
{
gdprintk(XENLOG_ERR, "Invalid pending event 0x%"PRIx32"\n",
c->pending_event);
return -EINVAL;
}
- /* Put this pending event in exitintinfo and svm_intr_assist()
- * will reinject it when we return to the guest. */
- vmcb->exitintinfo.bytes = c->pending_event;
- vmcb->exitintinfo.fields.errorcode = c->error_code;
+
+ if ( hvm_event_needs_reinjection(c->pending_type, c->pending_vector) )
+ {
+ vmcb->eventinj.bytes = c->pending_event;
+ vmcb->eventinj.fields.errorcode = c->error_code;
+ }
}

paging_update_paging_modes(v);
- /* signal paging update to ASID handler */
- svm_asid_g_update_paging (v);
+ svm_asid_g_update_paging(v);

return 0;

@@ -965,10 +953,10 @@ static void svm_hvm_inject_exception(
svm_inject_exception(v, trapnr, (errcode != -1), errcode);
}

-static int svm_event_injection_faulted(struct vcpu *v)
-{
- struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
- return vmcb->exitintinfo.fields.v;
+static int svm_event_pending(struct vcpu *v)
+{
+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+ return vmcb->eventinj.fields.v;
}

static struct hvm_function_table svm_function_table = {
@@ -1000,7 +988,7 @@ static struct hvm_function_table svm_fun
.inject_exception = svm_hvm_inject_exception,
.init_ap_context = svm_init_ap_context,
.init_hypercall_page = svm_init_hypercall_page,
- .event_injection_faulted = svm_event_injection_faulted
+ .event_pending = svm_event_pending
};

static void svm_npt_detect(void)
@@ -1667,6 +1655,17 @@ static int svm_set_cr0(unsigned long val
unsigned long old_base_mfn;

HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx", value);
+
+ if ( (u32)value != value )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_1,
+ "Guest attempts to set upper 32 bits in CR0: %lx",
+ value);
+ svm_inject_exception(v, TRAP_gp_fault, 1, 0);
+ return 0;
+ }
+
+ value &= ~HVM_CR0_GUEST_RESERVED_BITS;

/* ET is reserved and should be always be 1. */
value |= X86_CR0_ET;
@@ -2420,6 +2419,7 @@ asmlinkage void svm_vmexit_handler(struc
unsigned long eip;
struct vcpu *v = current;
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+ eventinj_t eventinj;
int inst_len, rc;

exit_reason = vmcb->exitcode;
@@ -2434,6 +2434,13 @@ asmlinkage void svm_vmexit_handler(struc

perfc_incra(svmexits, exit_reason);
eip = vmcb->rip;
+
+ /* Event delivery caused this intercept? Queue for redelivery. */
+ eventinj = vmcb->exitintinfo;
+ if ( unlikely(eventinj.fields.v) &&
+ hvm_event_needs_reinjection(eventinj.fields.type,
+ eventinj.fields.vector) )
+ vmcb->eventinj = eventinj;

switch ( exit_reason )
{
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/vmx/intr.c
--- a/xen/arch/x86/hvm/vmx/intr.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/intr.c Wed Aug 01 16:40:30 2007 -0600
@@ -76,10 +76,9 @@ static void enable_intr_window(struct vc
u32 *cpu_exec_control = &v->arch.hvm_vmx.exec_control;
u32 ctl = CPU_BASED_VIRTUAL_INTR_PENDING;

- if ( unlikely(intr_source == hvm_intack_none) )
- return;
+ ASSERT(intr_source != hvm_intack_none);

- if ( unlikely(intr_source == hvm_intack_nmi) && cpu_has_vmx_vnmi )
+ if ( (intr_source == hvm_intack_nmi) && cpu_has_vmx_vnmi )
{
/*
* We set MOV-SS blocking in lieu of STI blocking when delivering an
@@ -131,68 +130,27 @@ asmlinkage void vmx_intr_assist(void)
int intr_vector;
enum hvm_intack intr_source;
struct vcpu *v = current;
- unsigned int idtv_info_field;
- unsigned long inst_len;
+ unsigned int intr_info;

+ /* Crank the handle on interrupt state. */
pt_update_irq(v);
-
hvm_set_callback_irq_level();
-
- update_tpr_threshold(vcpu_vlapic(v));

do {
intr_source = hvm_vcpu_has_pending_irq(v);
+ if ( likely(intr_source == hvm_intack_none) )
+ goto out;

- if ( unlikely(v->arch.hvm_vmx.vector_injected) )
- {
- v->arch.hvm_vmx.vector_injected = 0;
- enable_intr_window(v, intr_source);
- return;
- }
-
- /* This could be moved earlier in the VMX resume sequence. */
- idtv_info_field = __vmread(IDT_VECTORING_INFO_FIELD);
- if ( unlikely(idtv_info_field & INTR_INFO_VALID_MASK) )
- {
- /* See SDM 3B 25.7.1.1 and .2 for info about masking resvd bits. */
- __vmwrite(VM_ENTRY_INTR_INFO_FIELD,
- idtv_info_field & ~INTR_INFO_RESVD_BITS_MASK);
-
- /*
- * Safe: the length will only be interpreted for software
- * exceptions and interrupts. If we get here then delivery of some
- * event caused a fault, and this always results in defined
- * VM_EXIT_INSTRUCTION_LEN.
- */
- inst_len = __vmread(VM_EXIT_INSTRUCTION_LEN); /* Safe */
- __vmwrite(VM_ENTRY_INSTRUCTION_LEN, inst_len);
-
- if ( unlikely(idtv_info_field & 0x800) ) /* valid error code */
- __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE,
- __vmread(IDT_VECTORING_ERROR_CODE));
-
- /*
- * Clear NMI-blocking interruptibility info if an NMI delivery
- * faulted. Re-delivery will re-set it (see SDM 3B 25.7.1.2).
- */
- if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI )
- __vmwrite(GUEST_INTERRUPTIBILITY_INFO,
- __vmread(GUEST_INTERRUPTIBILITY_INFO) &
- ~VMX_INTR_SHADOW_NMI);
-
- enable_intr_window(v, intr_source);
-
- HVM_DBG_LOG(DBG_LEVEL_1, "idtv_info_field=%x", idtv_info_field);
- return;
- }
-
- if ( likely(intr_source == hvm_intack_none) )
- return;
-
- if ( !hvm_interrupts_enabled(v, intr_source) )
+ /*
+ * An event is already pending or the pending interrupt is masked?
+ * Then the pending interrupt must be delayed.
+ */
+ intr_info = __vmread(VM_ENTRY_INTR_INFO);
+ if ( unlikely(intr_info & INTR_INFO_VALID_MASK) ||
+ !hvm_interrupts_enabled(v, intr_source) )
{
enable_intr_window(v, intr_source);
- return;
+ goto out;
}
} while ( !hvm_vcpu_ack_pending_irq(v, intr_source, &intr_vector) );

@@ -206,6 +164,14 @@ asmlinkage void vmx_intr_assist(void)
vmx_inject_extint(v, intr_vector);
pt_intr_post(v, intr_vector, intr_source);
}
+
+ /* Is there another IRQ to queue up behind this one? */
+ intr_source = hvm_vcpu_has_pending_irq(v);
+ if ( unlikely(intr_source != hvm_intack_none) )
+ enable_intr_window(v, intr_source);
+
+ out:
+ update_tpr_threshold(vcpu_vlapic(v));
}

/*
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Wed Aug 01 16:40:30 2007 -0600
@@ -240,8 +240,23 @@ int vmx_cpu_up(void)
{
u32 eax, edx;
int cpu = smp_processor_id();
+ u64 cr0, vmx_cr0_fixed0, vmx_cr0_fixed1;

BUG_ON(!(read_cr4() & X86_CR4_VMXE));
+
+ /*
+ * Ensure the current processor operating mode meets
+ * the requred CRO fixed bits in VMX operation.
+ */
+ cr0 = read_cr0();
+ rdmsrl(MSR_IA32_VMX_CR0_FIXED0, vmx_cr0_fixed0);
+ rdmsrl(MSR_IA32_VMX_CR0_FIXED1, vmx_cr0_fixed1);
+ if ( (~cr0 & vmx_cr0_fixed0) || (cr0 & ~vmx_cr0_fixed1) )
+ {
+ printk("CPU%d: some settings of host CR0 are "
+ "not allowed in VMX operation.\n", cpu);
+ return 0;
+ }

rdmsr(IA32_FEATURE_CONTROL_MSR, eax, edx);

@@ -418,7 +433,7 @@ static void construct_vmcs(struct vcpu *
__vmwrite(VM_EXIT_MSR_LOAD_COUNT, 0);
__vmwrite(VM_ENTRY_MSR_LOAD_COUNT, 0);

- __vmwrite(VM_ENTRY_INTR_INFO_FIELD, 0);
+ __vmwrite(VM_ENTRY_INTR_INFO, 0);

__vmwrite(CR0_GUEST_HOST_MASK, ~0UL);
__vmwrite(CR4_GUEST_HOST_MASK, ~0UL);
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/vmx.c Wed Aug 01 16:40:30 2007 -0600
@@ -613,28 +613,13 @@ void vmx_vmcs_save(struct vcpu *v, struc
c->sysenter_esp = __vmread(GUEST_SYSENTER_ESP);
c->sysenter_eip = __vmread(GUEST_SYSENTER_EIP);

- /*
- * Save any event/interrupt that was being injected when we last
- * exited. IDT_VECTORING_INFO_FIELD has priority, as anything in
- * VM_ENTRY_INTR_INFO_FIELD is either a fault caused by the first
- * event, which will happen the next time, or an interrupt, which we
- * never inject when IDT_VECTORING_INFO_FIELD is valid.
- */
- if ( (ev = __vmread(IDT_VECTORING_INFO_FIELD)) & INTR_INFO_VALID_MASK )
- {
- c->pending_event = ev;
- c->error_code = __vmread(IDT_VECTORING_ERROR_CODE);
- }
- else if ( (ev = __vmread(VM_ENTRY_INTR_INFO_FIELD)) &
- INTR_INFO_VALID_MASK )
+ c->pending_event = 0;
+ c->error_code = 0;
+ if ( ((ev = __vmread(VM_ENTRY_INTR_INFO)) & INTR_INFO_VALID_MASK) &&
+ hvm_event_needs_reinjection((ev >> 8) & 7, ev & 0xff) )
{
c->pending_event = ev;
c->error_code = __vmread(VM_ENTRY_EXCEPTION_ERROR_CODE);
- }
- else
- {
- c->pending_event = 0;
- c->error_code = 0;
}

vmx_vmcs_exit(v);
@@ -754,34 +739,9 @@ int vmx_vmcs_restore(struct vcpu *v, str

if ( c->pending_valid )
{
- vmx_vmcs_enter(v);
-
gdprintk(XENLOG_INFO, "Re-injecting 0x%"PRIx32", 0x%"PRIx32"\n",
c->pending_event, c->error_code);

- /* SVM uses type 3 ("Exception") for #OF and #BP; VMX uses type 6 */
- if ( (c->pending_type == 3) &&
- ((c->pending_vector == 3) || (c->pending_vector == 4)) )
- c->pending_type = 6;
-
- /* For software exceptions, we need to tell the hardware the
- * instruction length as well (hmmm). */
- if ( c->pending_type > 4 )
- {
- int addrbytes, ilen;
- if ( (c->cs_arbytes & X86_SEG_AR_CS_LM_ACTIVE) &&
- (c->msr_efer & EFER_LMA) )
- addrbytes = 8;
- else if ( c->cs_arbytes & X86_SEG_AR_DEF_OP_SIZE )
- addrbytes = 4;
- else
- addrbytes = 2;
-
- ilen = hvm_instruction_length(c->rip, addrbytes);
- __vmwrite(VM_ENTRY_INSTRUCTION_LEN, ilen);
- }
-
- /* Sanity check */
if ( (c->pending_type == 1) || (c->pending_type > 6) ||
(c->pending_reserved != 0) )
{
@@ -790,12 +750,13 @@ int vmx_vmcs_restore(struct vcpu *v, str
return -EINVAL;
}

- /* Re-inject the exception */
- __vmwrite(VM_ENTRY_INTR_INFO_FIELD, c->pending_event);
- __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, c->error_code);
- v->arch.hvm_vmx.vector_injected = 1;
-
- vmx_vmcs_exit(v);
+ if ( hvm_event_needs_reinjection(c->pending_type, c->pending_vector) )
+ {
+ vmx_vmcs_enter(v);
+ __vmwrite(VM_ENTRY_INTR_INFO, c->pending_event);
+ __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, c->error_code);
+ vmx_vmcs_exit(v);
+ }
}

return 0;
@@ -1203,14 +1164,10 @@ static void vmx_update_vtpr(struct vcpu
/* VMX doesn't have a V_TPR field */
}

-static int vmx_event_injection_faulted(struct vcpu *v)
-{
- unsigned int idtv_info_field;
-
+static int vmx_event_pending(struct vcpu *v)
+{
ASSERT(v == current);
-
- idtv_info_field = __vmread(IDT_VECTORING_INFO_FIELD);
- return (idtv_info_field & INTR_INFO_VALID_MASK);
+ return (__vmread(VM_ENTRY_INTR_INFO) & INTR_INFO_VALID_MASK);
}

static void disable_intercept_for_msr(u32 msr)
@@ -1261,7 +1218,7 @@ static struct hvm_function_table vmx_fun
.inject_exception = vmx_inject_exception,
.init_ap_context = vmx_init_ap_context,
.init_hypercall_page = vmx_init_hypercall_page,
- .event_injection_faulted = vmx_event_injection_faulted,
+ .event_pending = vmx_event_pending,
.cpu_up = vmx_cpu_up,
.cpu_down = vmx_cpu_down,
};
@@ -2199,6 +2156,17 @@ static int vmx_set_cr0(unsigned long val
unsigned long old_base_mfn;

HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx", value);
+
+ if ( (u32)value != value )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_1,
+ "Guest attempts to set upper 32 bits in CR0: %lx",
+ value);
+ vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
+ return 0;
+ }
+
+ value &= ~HVM_CR0_GUEST_RESERVED_BITS;

/* ET is reserved and should be always be 1. */
value |= X86_CR0_ET;
@@ -2842,47 +2810,6 @@ static void vmx_do_extint(struct cpu_use
}
}

-static void vmx_reflect_exception(struct vcpu *v)
-{
- int error_code, intr_info, vector;
-
- intr_info = __vmread(VM_EXIT_INTR_INFO);
- vector = intr_info & 0xff;
- if ( intr_info & INTR_INFO_DELIVER_CODE_MASK )
- error_code = __vmread(VM_EXIT_INTR_ERROR_CODE);
- else
- error_code = VMX_DELIVER_NO_ERROR_CODE;
-
-#ifndef NDEBUG
- {
- unsigned long rip;
-
- rip = __vmread(GUEST_RIP);
- HVM_DBG_LOG(DBG_LEVEL_1, "rip = %lx, error_code = %x",
- rip, error_code);
- }
-#endif /* NDEBUG */
-
- /*
- * According to Intel Virtualization Technology Specification for
- * the IA-32 Intel Architecture (C97063-002 April 2005), section
- * 2.8.3, SW_EXCEPTION should be used for #BP and #OV, and
- * HW_EXCEPTION used for everything else. The main difference
- * appears to be that for SW_EXCEPTION, the EIP/RIP is incremented
- * by VM_ENTER_INSTRUCTION_LEN bytes, whereas for HW_EXCEPTION,
- * it is not.
- */
- if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_SW_EXCEPTION )
- {
- int ilen = __get_instruction_length(); /* Safe: software exception */
- vmx_inject_sw_exception(v, vector, ilen);
- }
- else
- {
- vmx_inject_hw_exception(v, vector, error_code);
- }
-}
-
static void vmx_failed_vmentry(unsigned int exit_reason,
struct cpu_user_regs *regs)
{
@@ -2919,7 +2846,7 @@ static void vmx_failed_vmentry(unsigned

asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
{
- unsigned int exit_reason;
+ unsigned int exit_reason, idtv_info;
unsigned long exit_qualification, inst_len = 0;
struct vcpu *v = current;

@@ -2934,6 +2861,30 @@ asmlinkage void vmx_vmexit_handler(struc

if ( unlikely(exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) )
return vmx_failed_vmentry(exit_reason, regs);
+
+ /* Event delivery caused this intercept? Queue for redelivery. */
+ idtv_info = __vmread(IDT_VECTORING_INFO);
+ if ( unlikely(idtv_info & INTR_INFO_VALID_MASK) )
+ {
+ if ( hvm_event_needs_reinjection((idtv_info>>8)&7, idtv_info&0xff) )
+ {
+ /* See SDM 3B 25.7.1.1 and .2 for info about masking resvd bits. */
+ __vmwrite(VM_ENTRY_INTR_INFO,
+ idtv_info & ~INTR_INFO_RESVD_BITS_MASK);
+ if ( idtv_info & INTR_INFO_DELIVER_CODE_MASK )
+ __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE,
+ __vmread(IDT_VECTORING_ERROR_CODE));
+ }
+
+ /*
+ * Clear NMI-blocking interruptibility info if an NMI delivery faulted.
+ * Re-delivery will re-set it (see SDM 3B 25.7.1.2).
+ */
+ if ( (idtv_info & INTR_INFO_INTR_TYPE_MASK) == (X86_EVENTTYPE_NMI<<8) )
+ __vmwrite(GUEST_INTERRUPTIBILITY_INFO,
+ __vmread(GUEST_INTERRUPTIBILITY_INFO) &
+ ~VMX_INTR_SHADOW_NMI);
+ }

switch ( exit_reason )
{
@@ -2957,7 +2908,7 @@ asmlinkage void vmx_vmexit_handler(struc
* (NB. If we emulate this IRET for any reason, we should re-clear!)
*/
if ( unlikely(intr_info & INTR_INFO_NMI_UNBLOCKED_BY_IRET) &&
- !(__vmread(IDT_VECTORING_INFO_FIELD) & INTR_INFO_VALID_MASK) &&
+ !(__vmread(IDT_VECTORING_INFO) & INTR_INFO_VALID_MASK) &&
(vector != TRAP_double_fault) )
__vmwrite(GUEST_INTERRUPTIBILITY_INFO,
__vmread(GUEST_INTERRUPTIBILITY_INFO)|VMX_INTR_SHADOW_NMI);
@@ -2995,14 +2946,12 @@ asmlinkage void vmx_vmexit_handler(struc
vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code);
break;
case TRAP_nmi:
- if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI )
- {
- HVMTRACE_0D(NMI, v);
- vmx_store_cpu_guest_regs(v, regs, NULL);
- do_nmi(regs); /* Real NMI, vector 2: normal processing. */
- }
- else
- vmx_reflect_exception(v);
+ if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) !=
+ (X86_EVENTTYPE_NMI << 8) )
+ goto exit_and_crash;
+ HVMTRACE_0D(NMI, v);
+ vmx_store_cpu_guest_regs(v, regs, NULL);
+ do_nmi(regs); /* Real NMI, vector 2: normal processing. */
break;
case TRAP_machine_check:
HVMTRACE_0D(MCE, v);
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/arch/x86/mm/shadow/multi.c Wed Aug 01 16:40:30 2007 -0600
@@ -2905,7 +2905,7 @@ static int sh_page_fault(struct vcpu *v,
* stack is currently considered to be a page table, so we should
* unshadow the faulting page before exiting.
*/
- if ( unlikely(hvm_event_injection_faulted(v)) )
+ if ( unlikely(hvm_event_pending(v)) )
{
gdprintk(XENLOG_DEBUG, "write to pagetable during event "
"injection: cr2=%#lx, mfn=%#lx\n",
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/common/libelf/libelf-dominfo.c
--- a/xen/common/libelf/libelf-dominfo.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/common/libelf/libelf-dominfo.c Wed Aug 01 16:40:30 2007 -0600
@@ -333,6 +333,99 @@ static int elf_xen_note_check(struct elf
return 0;
}

+
+static void elf_xen_loadsymtab(struct elf_binary *elf,
+ struct elf_dom_parms *parms)
+{
+ unsigned long maxva, len;
+
+ if ( !parms->bsd_symtab )
+ return;
+
+ /* Calculate the required additional kernel space for the elf image */
+
+ /* The absolute base address of the elf image */
+ maxva = elf_round_up(elf, parms->virt_kend);
+ maxva += sizeof(long); /* Space to store the size of the elf image */
+ /* Space for the elf and elf section headers */
+ maxva += (elf_uval(elf, elf->ehdr, e_ehsize) +
+ elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize));
+ maxva = elf_round_up(elf, maxva);
+
+ /* Space for the symbol and string tabs */
+ len = (unsigned long)elf->send - (unsigned long)elf->sstart;
+ maxva = elf_round_up(elf, maxva + len);
+
+ /* The address the kernel must expanded to */
+ parms->virt_end = maxva;
+}
+
+int elf_xen_dom_load_binary(struct elf_binary *elf,
+ struct elf_dom_parms *parms)
+{
+ elf_ehdr *sym_ehdr;
+ unsigned long shdr, symtab_addr;
+ unsigned long maxva, symbase;
+ uint8_t i;
+ char *p;
+
+ elf_load_binary(elf);
+
+ if ( !parms->bsd_symtab )
+ return 0;
+
+#define elf_hdr_elm(_elf, _hdr, _elm, _val) \
+do { \
+ if ( elf_64bit(_elf) ) \
+ (_hdr)->e64._elm = _val; \
+ else \
+ (_hdr)->e32._elm = _val; \
+} while ( 0 )
+
+ /* ehdr right after the kernel image (4 byte aligned) */
+ symbase = elf_round_up(elf, parms->virt_kend);
+ symtab_addr = maxva = symbase + sizeof(long);
+
+ /* Set up Elf header. */
+ sym_ehdr = (elf_ehdr *)symtab_addr;
+ maxva = elf_copy_ehdr(elf, sym_ehdr);
+
+ elf_hdr_elm(elf, sym_ehdr, e_phoff, 0);
+ elf_hdr_elm(elf, sym_ehdr, e_shoff, elf_uval(elf, elf->ehdr, e_ehsize));
+ elf_hdr_elm(elf, sym_ehdr, e_phentsize, 0);
+ elf_hdr_elm(elf, sym_ehdr, e_phnum, 0);
+
+ /* Copy Elf section headers. */
+ shdr = maxva;
+ maxva = elf_copy_shdr(elf, (elf_shdr *)shdr);
+
+ for ( i = 0; i < elf_shdr_count(elf); i++ )
+ {
+ uint8_t type;
+ unsigned long tmp;
+ type = elf_uval(elf, (elf_shdr *)shdr, sh_type);
+ if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
+ {
+ elf_msg(elf, "%s: shdr %i at 0x%p -> 0x%p\n", __func__, i,
+ elf_section_start(elf, (elf_shdr *)shdr), (void *)maxva);
+ tmp = elf_copy_section(elf, (elf_shdr *)shdr, (void *)maxva);
+ /* Mangled to be based on ELF header location. */
+ elf_hdr_elm(elf, (elf_shdr *)shdr, sh_offset,
+ maxva - symtab_addr);
+ maxva = tmp;
+ }
+ shdr += elf_uval(elf, elf->ehdr, e_shentsize);
+ }
+
+ /* Write down the actual sym size. */
+ p = (char *)symbase;
+ *(long *)p = maxva - symtab_addr; /* sym size */
+
+#undef elf_ehdr_elm
+
+ return 0;
+}
+
static int elf_xen_addr_calc_check(struct elf_binary *elf,
struct elf_dom_parms *parms)
{
@@ -374,9 +467,13 @@ static int elf_xen_addr_calc_check(struc
parms->virt_offset = parms->virt_base - parms->elf_paddr_offset;
parms->virt_kstart = elf->pstart + parms->virt_offset;
parms->virt_kend = elf->pend + parms->virt_offset;
+ parms->virt_end = parms->virt_kend;

if ( parms->virt_entry == UNSET_ADDR )
parms->virt_entry = elf_uval(elf, elf->ehdr, e_entry);
+
+ if ( parms->bsd_symtab )
+ elf_xen_loadsymtab(elf, parms);

elf_msg(elf, "%s: addresses:\n", __FUNCTION__);
elf_msg(elf, " virt_base = 0x%" PRIx64 "\n", parms->virt_base);
@@ -384,12 +481,14 @@ static int elf_xen_addr_calc_check(struc
elf_msg(elf, " virt_offset = 0x%" PRIx64 "\n", parms->virt_offset);
elf_msg(elf, " virt_kstart = 0x%" PRIx64 "\n", parms->virt_kstart);
elf_msg(elf, " virt_kend = 0x%" PRIx64 "\n", parms->virt_kend);
+ elf_msg(elf, " virt_end = 0x%" PRIx64 "\n", parms->virt_end);
elf_msg(elf, " virt_entry = 0x%" PRIx64 "\n", parms->virt_entry);

if ( (parms->virt_kstart > parms->virt_kend) ||
(parms->virt_entry < parms->virt_kstart) ||
(parms->virt_entry > parms->virt_kend) ||
- (parms->virt_base > parms->virt_kstart) )
+ (parms->virt_base > parms->virt_kstart) ||
+ (parms->virt_kend > parms->virt_end) )
{
elf_err(elf, "%s: ERROR: ELF start or entries are out of bounds.\n",
__FUNCTION__);
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/common/libelf/libelf-loader.c
--- a/xen/common/libelf/libelf-loader.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/common/libelf/libelf-loader.c Wed Aug 01 16:40:30 2007 -0600
@@ -10,6 +10,8 @@ int elf_init(struct elf_binary *elf, con
{
const elf_shdr *shdr;
uint64_t i, count, section, offset;
+ uint64_t low = -1;
+ uint64_t high = 0;

if ( !elf_is_elfbinary(image) )
{
@@ -24,7 +26,11 @@ int elf_init(struct elf_binary *elf, con
elf->class = elf->ehdr->e32.e_ident[EI_CLASS];
elf->data = elf->ehdr->e32.e_ident[EI_DATA];

- /* sanity check phdr */
+#ifdef VERBOSE
+ elf_set_verbose(elf);
+#endif
+
+ /* Sanity check phdr. */
offset = elf_uval(elf, elf->ehdr, e_phoff) +
elf_uval(elf, elf->ehdr, e_phentsize) * elf_phdr_count(elf);
if ( offset > elf->size )
@@ -34,7 +40,7 @@ int elf_init(struct elf_binary *elf, con
return -1;
}

- /* sanity check shdr */
+ /* Sanity check shdr. */
offset = elf_uval(elf, elf->ehdr, e_shoff) +
elf_uval(elf, elf->ehdr, e_shentsize) * elf_shdr_count(elf);
if ( offset > elf->size )
@@ -44,29 +50,55 @@ int elf_init(struct elf_binary *elf, con
return -1;
}

- /* find section string table */
+ /* Find section string table. */
section = elf_uval(elf, elf->ehdr, e_shstrndx);
shdr = elf_shdr_by_index(elf, section);
if ( shdr != NULL )
elf->sec_strtab = elf_section_start(elf, shdr);

- /* find symbol table, symbol string table */
+ /* Find symbol table and symbol string table. */
count = elf_shdr_count(elf);
for ( i = 0; i < count; i++ )
{
+ const char *sh_symend, *sh_strend;
+
shdr = elf_shdr_by_index(elf, i);
if ( elf_uval(elf, shdr, sh_type) != SHT_SYMTAB )
continue;
elf->sym_tab = shdr;
+ sh_symend = (const char *)elf_section_end(elf, shdr);
shdr = elf_shdr_by_index(elf, elf_uval(elf, shdr, sh_link));
if ( shdr == NULL )
{
elf->sym_tab = NULL;
+ sh_symend = 0;
continue;
}
elf->sym_strtab = elf_section_start(elf, shdr);
- break;
- }
+ sh_strend = (const char *)elf_section_end(elf, shdr);
+
+ if ( low > (unsigned long)elf->sym_tab )
+ low = (unsigned long)elf->sym_tab;
+ if ( low > (unsigned long)shdr )
+ low = (unsigned long)shdr;
+
+ if ( high < ((unsigned long)sh_symend) )
+ high = (unsigned long)sh_symend;
+ if ( high < ((unsigned long)sh_strend) )
+ high = (unsigned long)sh_strend;
+
+ elf_msg(elf, "%s: shdr: sym_tab=%p size=0x%" PRIx64 "\n",
+ __FUNCTION__, elf->sym_tab,
+ elf_uval(elf, elf->sym_tab, sh_size));
+ elf_msg(elf, "%s: shdr: str_tab=%p size=0x%" PRIx64 "\n",
+ __FUNCTION__, elf->sym_strtab, elf_uval(elf, shdr, sh_size));
+
+ elf->sstart = low;
+ elf->send = high;
+ elf_msg(elf, "%s: symbol map: 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
+ __FUNCTION__, elf->sstart, elf->send);
+ }
+
return 0;
}

diff -r 77c87416fbd0 -r d83c9d87ede4 xen/common/libelf/libelf-tools.c
--- a/xen/common/libelf/libelf-tools.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/common/libelf/libelf-tools.c Wed Aug 01 16:40:30 2007 -0600
@@ -236,6 +236,36 @@ int elf_phdr_is_loadable(struct elf_bina
uint64_t p_flags = elf_uval(elf, phdr, p_flags);

return ((p_type == PT_LOAD) && (p_flags & (PF_W | PF_X)) != 0);
+}
+
+unsigned long
+elf_copy_ehdr(struct elf_binary *elf, void *dest)
+{
+ uint64_t size;
+
+ size = elf_uval(elf, elf->ehdr, e_ehsize);
+ memcpy(dest, elf->ehdr, size);
+ return elf_round_up(elf, (unsigned long)(dest) + size);
+}
+
+unsigned long
+elf_copy_shdr(struct elf_binary *elf, void *dest)
+{
+ uint64_t size;
+
+ size = elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize);
+ memcpy(dest, elf->image + elf_uval(elf, elf->ehdr, e_shoff), size);
+ return elf_round_up(elf, (unsigned long)(dest) + size);
+}
+
+unsigned long
+elf_copy_section(struct elf_binary *elf, const elf_shdr *shdr, void *dest)
+{
+ uint64_t size;
+
+ size = elf_uval(elf, shdr, sh_size);
+ memcpy(dest, elf_section_start(elf, shdr), size);
+ return elf_round_up(elf, (unsigned long)(dest) + size);
}

/*
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/drivers/acpi/tables.c
--- a/xen/drivers/acpi/tables.c Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/drivers/acpi/tables.c Wed Aug 01 16:40:30 2007 -0600
@@ -73,7 +73,6 @@ struct acpi_table_sdt {

static unsigned long sdt_pa; /* Physical Address */
static unsigned long sdt_count; /* Table count */
-unsigned char acpi_rsdp_rev;

static struct acpi_table_sdt sdt_entry[ACPI_MAX_TABLES] __initdata;

@@ -227,6 +226,17 @@ void acpi_table_print_madt_entry(acpi_ta
}
}

+uint8_t
+generate_acpi_checksum(void *tbl, unsigned long len)
+{
+ uint8_t *ptr, sum = 0;
+
+ for (ptr = tbl; len > 0 ; len--, ptr++)
+ sum += *ptr;
+
+ return 0 - sum;
+}
+
static int
acpi_table_compute_checksum(void *table_pointer, unsigned long length)
{
@@ -599,8 +609,6 @@ int __init acpi_table_init(void)
"RSDP (v%3.3d %6.6s ) @ 0x%p\n",
rsdp->revision, rsdp->oem_id, (void *)rsdp_phys);

- acpi_rsdp_rev = rsdp->revision;
-
if (rsdp->revision < 2)
result =
acpi_table_compute_checksum(rsdp,
@@ -623,3 +631,143 @@ int __init acpi_table_init(void)

return 0;
}
+
+int __init
+acpi_table_disable(enum acpi_table_id table_id)
+{
+ struct acpi_table_header *header = NULL;
+ struct acpi_table_rsdp *rsdp;
+ unsigned long rsdp_phys;
+ char *table_name;
+ int id;
+
+ rsdp_phys = acpi_find_rsdp();
+ if (!rsdp_phys)
+ return -ENODEV;
+
+ rsdp = (struct acpi_table_rsdp *)__acpi_map_table(rsdp_phys,
+ sizeof(struct acpi_table_rsdp));
+ if (!rsdp)
+ return -ENODEV;
+
+ for (id = 0; id < sdt_count; id++)
+ if (sdt_entry[id].id == table_id)
+ break;
+
+ if (id == sdt_count)
+ return -ENOENT;
+
+ table_name = acpi_table_signatures[table_id];
+
+ /* First check XSDT (but only on ACPI 2.0-compatible systems) */
+
+ if ((rsdp->revision >= 2) &&
+ (((struct acpi20_table_rsdp *)rsdp)->xsdt_address)) {
+
+ struct acpi_table_xsdt *mapped_xsdt = NULL;
+
+ sdt_pa = ((struct acpi20_table_rsdp *)rsdp)->xsdt_address;
+
+ /* map in just the header */
+ header = (struct acpi_table_header *)
+ __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
+
+ if (!header) {
+ printk(KERN_WARNING PREFIX
+ "Unable to map XSDT header\n");
+ return -ENODEV;
+ }
+
+ /* remap in the entire table before processing */
+ mapped_xsdt = (struct acpi_table_xsdt *)
+ __acpi_map_table(sdt_pa, header->length);
+ if (!mapped_xsdt) {
+ printk(KERN_WARNING PREFIX "Unable to map XSDT\n");
+ return -ENODEV;
+ }
+ header = &mapped_xsdt->header;
+
+ if (strncmp(header->signature, "XSDT", 4)) {
+ printk(KERN_WARNING PREFIX
+ "XSDT signature incorrect\n");
+ return -ENODEV;
+ }
+
+ if (acpi_table_compute_checksum(header, header->length)) {
+ printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
+ return -ENODEV;
+ }
+
+ if (id < sdt_count) {
+ header = (struct acpi_table_header *)
+ __acpi_map_table(mapped_xsdt->entry[id], sizeof(struct acpi_table_header));
+ } else {
+ printk(KERN_WARNING PREFIX
+ "Unable to disable entry %d\n",
+ id);
+ return -ENODEV;
+ }
+ }
+
+ /* Then check RSDT */
+
+ else if (rsdp->rsdt_address) {
+
+ struct acpi_table_rsdt *mapped_rsdt = NULL;
+
+ sdt_pa = rsdp->rsdt_address;
+
+ /* map in just the header */
+ header = (struct acpi_table_header *)
+ __acpi_map_table(sdt_pa, sizeof(struct acpi_table_header));
+ if (!header) {
+ printk(KERN_WARNING PREFIX
+ "Unable to map RSDT header\n");
+ return -ENODEV;
+ }
+
+ /* remap in the entire table before processing */
+ mapped_rsdt = (struct acpi_table_rsdt *)
+ __acpi_map_table(sdt_pa, header->length);
+ if (!mapped_rsdt) {
+ printk(KERN_WARNING PREFIX "Unable to map RSDT\n");
+ return -ENODEV;
+ }
+ header = &mapped_rsdt->header;
+
+ if (strncmp(header->signature, "RSDT", 4)) {
+ printk(KERN_WARNING PREFIX
+ "RSDT signature incorrect\n");
+ return -ENODEV;
+ }
+
+ if (acpi_table_compute_checksum(header, header->length)) {
+ printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
+ return -ENODEV;
+ }
+ if (id < sdt_count) {
+ header = (struct acpi_table_header *)
+ __acpi_map_table(mapped_rsdt->entry[id], sizeof(struct acpi_table_header));
+ } else {
+ printk(KERN_WARNING PREFIX
+ "Unable to disable entry %d\n",
+ id);
+ return -ENODEV;
+ }
+ }
+
+ else {
+ printk(KERN_WARNING PREFIX
+ "No System Description Table (RSDT/XSDT) specified in RSDP\n");
+ return -ENODEV;
+ }
+
+ memcpy(header->signature, "OEMx", 4);
+ memcpy(header->oem_id, "xxxxxx", 6);
+ memcpy(header->oem_id+1, table_name, 4);
+ memcpy(header->oem_table_id, "Xen ", 8);
+ header->checksum = 0;
+ header->checksum = generate_acpi_checksum(header, header->length);
+
+ return 0;
+}
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-ia64/dom_fw_common.h
--- a/xen/include/asm-ia64/dom_fw_common.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-ia64/dom_fw_common.h Wed Aug 01 16:40:30 2007 -0600
@@ -85,7 +85,6 @@ xen_ia64_efi_make_md(efi_memory_desc_t *
xen_ia64_efi_make_md(efi_memory_desc_t *md,
uint32_t type, uint64_t attr,
uint64_t start, uint64_t end);
-uint8_t generate_acpi_checksum(void *tbl, unsigned long len);
struct fake_acpi_tables;
void dom_fw_fake_acpi(domain_t *d, struct fake_acpi_tables *tables);
int efi_mdt_cmp(const void *a, const void *b);
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-powerpc/grant_table.h
--- a/xen/include/asm-powerpc/grant_table.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-powerpc/grant_table.h Wed Aug 01 16:40:30 2007 -0600
@@ -51,6 +51,11 @@ int replace_grant_host_mapping(
#define gnttab_shared_gmfn(d, t, i) \
(mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i)))

+static inline void mark_dirty(struct domain *d, unsigned int mfn)
+{
+ return;
+}
+#define gnttab_mark_dirty(d, f) mark_dirty((d), (f))
#define gnttab_log_dirty(d, f) mark_dirty((d), (f))

static inline void gnttab_clear_flag(unsigned long nr, uint16_t *addr)
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-powerpc/mm.h
--- a/xen/include/asm-powerpc/mm.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-powerpc/mm.h Wed Aug 01 16:40:30 2007 -0600
@@ -35,7 +35,6 @@
#define memguard_unguard_range(_p,_l) ((void)0)

extern unsigned long xenheap_phys_end;
-extern int boot_of_mem_avail(int pos, ulong *start, ulong *end);

/*
* Per-page-frame information.
@@ -275,4 +274,12 @@ extern int steal_page(struct domain *d,

#define domain_get_maximum_gpfn(d) (-ENOSYS)

+extern int guest_physmap_max_mem_pages(struct domain *d, unsigned long new_max);
+
+extern void guest_physmap_add_page(
+ struct domain *d, unsigned long gpfn, unsigned long mfn);
+
+extern void guest_physmap_remove_page(
+ struct domain *d, unsigned long gpfn, unsigned long mfn);
+
#endif
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-powerpc/numa.h
--- a/xen/include/asm-powerpc/numa.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-powerpc/numa.h Wed Aug 01 16:40:30 2007 -0600
@@ -1,3 +1,28 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright (C) IBM Corp. 2007
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#ifndef __ASM_NUMA_H__
+#define __ASM_NUMA_H__
+
#include <xen/init.h>
#include "../asm-x86/numa.h"
extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
+
+#endif
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-powerpc/shadow.h
--- a/xen/include/asm-powerpc/shadow.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-powerpc/shadow.h Wed Aug 01 16:40:30 2007 -0600
@@ -32,22 +32,8 @@
? machine_to_phys_mapping[(mfn)] \
: (mfn) )

-extern int guest_physmap_max_mem_pages(struct domain *d, unsigned long new_max);
-
-extern void guest_physmap_add_page(
- struct domain *d, unsigned long gpfn, unsigned long mfn);
-
-extern void guest_physmap_remove_page(
- struct domain *d, unsigned long gpfn, unsigned long mfn);
-
extern void shadow_drop_references(
struct domain *d, struct page_info *page);
-
-static inline void mark_dirty(struct domain *d, unsigned int mfn)
-{
- return;
-}
-#define gnttab_mark_dirty(d, f) mark_dirty((d), (f))

extern int shadow_domctl(struct domain *d,
xen_domctl_shadow_op_t *sc,
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-x86/hvm/hvm.h Wed Aug 01 16:40:30 2007 -0600
@@ -154,7 +154,7 @@ struct hvm_function_table {

void (*init_hypercall_page)(struct domain *d, void *hypercall_page);

- int (*event_injection_faulted)(struct vcpu *v);
+ int (*event_pending)(struct vcpu *v);

int (*cpu_up)(void);
void (*cpu_down)(void);
@@ -229,7 +229,8 @@ hvm_guest_x86_mode(struct vcpu *v)
return hvm_funcs.guest_x86_mode(v);
}

-int hvm_instruction_length(unsigned long pc, int address_bytes);
+int hvm_instruction_fetch(unsigned long pc, int address_bytes,
+ unsigned char *buf);

static inline void
hvm_update_host_cr3(struct vcpu *v)
@@ -295,24 +296,71 @@ hvm_inject_exception(unsigned int trapnr

int hvm_bringup_ap(int vcpuid, int trampoline_vector);

-static inline int hvm_event_injection_faulted(struct vcpu *v)
-{
- return hvm_funcs.event_injection_faulted(v);
-}
+static inline int hvm_event_pending(struct vcpu *v)
+{
+ return hvm_funcs.event_pending(v);
+}
+
+/* These reserved bits in lower 32 remain 0 after any load of CR0 */
+#define HVM_CR0_GUEST_RESERVED_BITS \
+ (~((unsigned long) \
+ (X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | \
+ X86_CR0_TS | X86_CR0_ET | X86_CR0_NE | \
+ X86_CR0_WP | X86_CR0_AM | X86_CR0_NW | \
+ X86_CR0_CD | X86_CR0_PG)))

/* These bits in CR4 are owned by the host. */
#define HVM_CR4_HOST_MASK (mmu_cr4_features & \
(X86_CR4_VMXE | X86_CR4_PAE | X86_CR4_MCE))

/* These bits in CR4 cannot be set by the guest. */
-#define HVM_CR4_GUEST_RESERVED_BITS \
- ~(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | \
- X86_CR4_DE | X86_CR4_PSE | X86_CR4_PAE | \
- X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \
- X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)
+#define HVM_CR4_GUEST_RESERVED_BITS \
+ (~((unsigned long) \
+ (X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | \
+ X86_CR4_DE | X86_CR4_PSE | X86_CR4_PAE | \
+ X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \
+ X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)))

/* These exceptions must always be intercepted. */
#define HVM_TRAP_MASK (1U << TRAP_machine_check)
+
+/*
+ * x86 event types. This enumeration is valid for:
+ * Intel VMX: {VM_ENTRY,VM_EXIT,IDT_VECTORING}_INTR_INFO[10:8]
+ * AMD SVM: eventinj[10:8] and exitintinfo[10:8] (types 0-4 only)
+ */
+#define X86_EVENTTYPE_EXT_INTR 0 /* external interrupt */
+#define X86_EVENTTYPE_NMI 2 /* NMI */
+#define X86_EVENTTYPE_HW_EXCEPTION 3 /* hardware exception */
+#define X86_EVENTTYPE_SW_INTERRUPT 4 /* software interrupt */
+#define X86_EVENTTYPE_SW_EXCEPTION 6 /* software exception */
+
+/*
+ * Need to re-inject a given event? We avoid re-injecting software exceptions
+ * and interrupts because the faulting/trapping instruction can simply be
+ * re-executed (neither VMX nor SVM update RIP when they VMEXIT during
+ * INT3/INTO/INTn).
+ */
+static inline int hvm_event_needs_reinjection(uint8_t type, uint8_t vector)
+{
+ switch ( type )
+ {
+ case X86_EVENTTYPE_EXT_INTR:
+ case X86_EVENTTYPE_NMI:
+ return 1;
+ case X86_EVENTTYPE_HW_EXCEPTION:
+ /*
+ * SVM uses type 3 ("HW Exception") for #OF and #BP. We explicitly
+ * check for these vectors, as they are really SW Exceptions. SVM has
+ * not updated RIP to point after the trapping instruction (INT3/INTO).
+ */
+ return (vector != 3) && (vector != 4);
+ default:
+ /* Software exceptions/interrupts can be re-executed (e.g., INT n). */
+ break;
+ }
+ return 0;
+}

static inline int hvm_cpu_up(void)
{
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-x86/hvm/svm/vmcb.h
--- a/xen/include/asm-x86/hvm/svm/vmcb.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h Wed Aug 01 16:40:30 2007 -0600
@@ -319,14 +319,6 @@ typedef union
u64 errorcode:32;
} fields;
} __attribute__ ((packed)) eventinj_t;
-
-enum EVENTTYPES
-{
- EVENTTYPE_INTR = 0,
- EVENTTYPE_NMI = 2,
- EVENTTYPE_EXCEPTION = 3,
- EVENTTYPE_SWINT = 4,
-};

typedef union
{
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Wed Aug 01 16:40:30 2007 -0600
@@ -66,9 +66,6 @@ struct arch_vmx_struct {

/* Cache of cpu execution control. */
u32 exec_control;
-
- /* If there is vector installed in the INTR_INFO_FIELD. */
- u32 vector_injected;

unsigned long cpu_cr0; /* copy of guest CR0 */
unsigned long cpu_shadow_cr0; /* copy of guest read shadow CR0 */
@@ -198,7 +195,7 @@ enum vmcs_field {
VM_EXIT_MSR_LOAD_COUNT = 0x00004010,
VM_ENTRY_CONTROLS = 0x00004012,
VM_ENTRY_MSR_LOAD_COUNT = 0x00004014,
- VM_ENTRY_INTR_INFO_FIELD = 0x00004016,
+ VM_ENTRY_INTR_INFO = 0x00004016,
VM_ENTRY_EXCEPTION_ERROR_CODE = 0x00004018,
VM_ENTRY_INSTRUCTION_LEN = 0x0000401a,
TPR_THRESHOLD = 0x0000401c,
@@ -207,7 +204,7 @@ enum vmcs_field {
VM_EXIT_REASON = 0x00004402,
VM_EXIT_INTR_INFO = 0x00004404,
VM_EXIT_INTR_ERROR_CODE = 0x00004406,
- IDT_VECTORING_INFO_FIELD = 0x00004408,
+ IDT_VECTORING_INFO = 0x00004408,
IDT_VECTORING_ERROR_CODE = 0x0000440a,
VM_EXIT_INSTRUCTION_LEN = 0x0000440c,
VMX_INSTRUCTION_INFO = 0x0000440e,
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/asm-x86/hvm/vmx/vmx.h
--- a/xen/include/asm-x86/hvm/vmx/vmx.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h Wed Aug 01 16:40:30 2007 -0600
@@ -94,11 +94,6 @@ void vmx_vlapic_msr_changed(struct vcpu
#define INTR_INFO_VALID_MASK 0x80000000 /* 31 */
#define INTR_INFO_RESVD_BITS_MASK 0x7ffff000

-#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */
-#define INTR_TYPE_NMI (2 << 8) /* NMI */
-#define INTR_TYPE_HW_EXCEPTION (3 << 8) /* hardware exception */
-#define INTR_TYPE_SW_EXCEPTION (6 << 8) /* software exception */
-
/*
* Exit Qualifications for MOV for Control Register Access
*/
@@ -263,8 +258,8 @@ static inline int __vmxon (u64 addr)
return rc;
}

-static inline void __vmx_inject_exception(struct vcpu *v, int trap, int type,
- int error_code, int ilen)
+static inline void __vmx_inject_exception(
+ struct vcpu *v, int trap, int type, int error_code)
{
unsigned long intr_fields;

@@ -276,16 +271,13 @@ static inline void __vmx_inject_exceptio
* VM entry]", PRM Vol. 3, 22.6.1 (Interruptibility State).
*/

- intr_fields = (INTR_INFO_VALID_MASK | type | trap);
+ intr_fields = (INTR_INFO_VALID_MASK | (type<<8) | trap);
if ( error_code != VMX_DELIVER_NO_ERROR_CODE ) {
__vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
intr_fields |= INTR_INFO_DELIVER_CODE_MASK;
}

- if ( ilen )
- __vmwrite(VM_ENTRY_INSTRUCTION_LEN, ilen);
-
- __vmwrite(VM_ENTRY_INTR_INFO_FIELD, intr_fields);
+ __vmwrite(VM_ENTRY_INTR_INFO, intr_fields);

if (trap == TRAP_page_fault)
HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_vmx.cpu_cr2, error_code);
@@ -296,29 +288,19 @@ static inline void vmx_inject_hw_excepti
static inline void vmx_inject_hw_exception(
struct vcpu *v, int trap, int error_code)
{
- v->arch.hvm_vmx.vector_injected = 1;
- __vmx_inject_exception(v, trap, INTR_TYPE_HW_EXCEPTION, error_code, 0);
-}
-
-static inline void vmx_inject_sw_exception(
- struct vcpu *v, int trap, int instruction_len)
-{
- v->arch.hvm_vmx.vector_injected = 1;
- __vmx_inject_exception(v, trap, INTR_TYPE_SW_EXCEPTION,
- VMX_DELIVER_NO_ERROR_CODE,
- instruction_len);
+ __vmx_inject_exception(v, trap, X86_EVENTTYPE_HW_EXCEPTION, error_code);
}

static inline void vmx_inject_extint(struct vcpu *v, int trap)
{
- __vmx_inject_exception(v, trap, INTR_TYPE_EXT_INTR,
- VMX_DELIVER_NO_ERROR_CODE, 0);
+ __vmx_inject_exception(v, trap, X86_EVENTTYPE_EXT_INTR,
+ VMX_DELIVER_NO_ERROR_CODE);
}

static inline void vmx_inject_nmi(struct vcpu *v)
{
- __vmx_inject_exception(v, 2, INTR_TYPE_NMI,
- VMX_DELIVER_NO_ERROR_CODE, 0);
+ __vmx_inject_exception(v, 2, X86_EVENTTYPE_NMI,
+ VMX_DELIVER_NO_ERROR_CODE);
}

#endif /* __ASM_X86_HVM_VMX_VMX_H__ */
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/public/libelf.h
--- a/xen/include/public/libelf.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/public/libelf.h Wed Aug 01 16:40:30 2007 -0600
@@ -65,6 +65,8 @@ struct elf_binary {

/* loaded to */
char *dest;
+ uint64_t sstart;
+ uint64_t send;
uint64_t pstart;
uint64_t pend;
uint64_t reloc_offset;
@@ -91,33 +93,32 @@ struct elf_binary {
#define elf_lsb(elf) (ELFDATA2LSB == (elf)->data)
#define elf_swap(elf) (NATIVE_ELFDATA != (elf)->data)

-#define elf_uval(elf, str, elem) \
- ((ELFCLASS64 == (elf)->class) \
- ? elf_access_unsigned((elf), (str), \
- offsetof(typeof(*(str)),e64.elem), \
- sizeof((str)->e64.elem)) \
- : elf_access_unsigned((elf), (str), \
- offsetof(typeof(*(str)),e32.elem), \
- sizeof((str)->e32.elem)))
-
-#define elf_sval(elf, str, elem) \
- ((ELFCLASS64 == (elf)->class) \
- ? elf_access_signed((elf), (str), \
- offsetof(typeof(*(str)),e64.elem), \
- sizeof((str)->e64.elem)) \
- : elf_access_signed((elf), (str), \
- offsetof(typeof(*(str)),e32.elem), \
- sizeof((str)->e32.elem)))
-
-#define elf_size(elf, str) \
- ((ELFCLASS64 == (elf)->class) \
- ? sizeof((str)->e64) \
- : sizeof((str)->e32))
+#define elf_uval(elf, str, elem) \
+ ((ELFCLASS64 == (elf)->class) \
+ ? elf_access_unsigned((elf), (str), \
+ offsetof(typeof(*(str)),e64.elem), \
+ sizeof((str)->e64.elem)) \
+ : elf_access_unsigned((elf), (str), \
+ offsetof(typeof(*(str)),e32.elem), \
+ sizeof((str)->e32.elem)))
+
+#define elf_sval(elf, str, elem) \
+ ((ELFCLASS64 == (elf)->class) \
+ ? elf_access_signed((elf), (str), \
+ offsetof(typeof(*(str)),e64.elem), \
+ sizeof((str)->e64.elem)) \
+ : elf_access_signed((elf), (str), \
+ offsetof(typeof(*(str)),e32.elem), \
+ sizeof((str)->e32.elem)))
+
+#define elf_size(elf, str) \
+ ((ELFCLASS64 == (elf)->class) \
+ ? sizeof((str)->e64) : sizeof((str)->e32))

uint64_t elf_access_unsigned(struct elf_binary *elf, const void *ptr,
- uint64_t offset, size_t size);
+ uint64_t offset, size_t size);
int64_t elf_access_signed(struct elf_binary *elf, const void *ptr,
- uint64_t offset, size_t size);
+ uint64_t offset, size_t size);

uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr);

@@ -149,6 +150,11 @@ int elf_is_elfbinary(const void *image);
int elf_is_elfbinary(const void *image);
int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr);

+unsigned long elf_copy_ehdr(struct elf_binary *elf, void *dest);
+unsigned long elf_copy_shdr(struct elf_binary *elf, void *dest);
+unsigned long elf_copy_section(struct elf_binary *elf,
+ const elf_shdr *shdr, void *dest);
+
/* ------------------------------------------------------------------------ */
/* xc_libelf_loader.c */

@@ -185,8 +191,8 @@ struct xen_elfnote {
enum xen_elfnote_type type;
const char *name;
union {
- const char *str;
- uint64_t num;
+ const char *str;
+ uint64_t num;
} data;
};

@@ -215,7 +221,8 @@ struct elf_dom_parms {
/* calculated */
uint64_t virt_offset;
uint64_t virt_kstart;
- uint64_t virt_kend;
+ uint64_t virt_kend; /* end of kernel image */
+ uint64_t virt_end; /* end of kernel symtab (== virt_kend if none) */
};

static inline void elf_xen_feature_set(int nr, uint32_t * addr)
@@ -228,14 +235,17 @@ static inline int elf_xen_feature_get(in
}

int elf_xen_parse_features(const char *features,
- uint32_t *supported,
- uint32_t *required);
+ uint32_t *supported,
+ uint32_t *required);
int elf_xen_parse_note(struct elf_binary *elf,
- struct elf_dom_parms *parms,
- const elf_note *note);
+ struct elf_dom_parms *parms,
+ const elf_note *note);
int elf_xen_parse_guest_info(struct elf_binary *elf,
- struct elf_dom_parms *parms);
+ struct elf_dom_parms *parms);
int elf_xen_parse(struct elf_binary *elf,
- struct elf_dom_parms *parms);
+ struct elf_dom_parms *parms);
+
+int elf_xen_dom_load_binary(struct elf_binary *elf,
+ struct elf_dom_parms *parms);

#endif /* __XC_LIBELF__ */
diff -r 77c87416fbd0 -r d83c9d87ede4 xen/include/xen/acpi.h
--- a/xen/include/xen/acpi.h Wed Aug 01 09:40:58 2007 -0600
+++ b/xen/include/xen/acpi.h Wed Aug 01 16:40:30 2007 -0600
@@ -383,6 +383,7 @@ int acpi_numa_init (void);
int acpi_numa_init (void);

int acpi_table_init (void);
+int acpi_table_disable(enum acpi_table_id table_id);
int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler);
int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header);
int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries);
@@ -390,6 +391,7 @@ void acpi_table_print (struct acpi_table
void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr);
void acpi_table_print_madt_entry (acpi_table_entry_header *madt);
void acpi_table_print_srat_entry (acpi_table_entry_header *srat);
+uint8_t generate_acpi_checksum(void *tbl, unsigned long len);

/* the following four functions are architecture-dependent */
void acpi_numa_slit_init (struct acpi_table_slit *slit);
@@ -534,6 +536,5 @@ static inline int acpi_get_pxm(acpi_hand
#endif

extern int pnpacpi_disabled;
-extern unsigned char acpi_rsdp_rev;

#endif /*_LINUX_ACPI_H*/

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog
[xen-unstable] merge with xen-unstable.hg [ In reply to ]
# HG changeset patch
# User Alex Williamson <alex.williamson@hp.com>
# Date 1186951802 21600
# Node ID cd51fa91956be20dbd744d46117f7f989e08c334
# Parent 5b19839d036508fb2721a567798359dd11f68916
# Parent 7953164cebb6dfbbee08d06c91f424b63d87ed71
merge with xen-unstable.hg
---
xen/arch/x86/genapic/es7000.c | 27
xen/arch/x86/genapic/es7000plat.c | 141
xen/include/asm-x86/mach-es7000/mach_mpparse.h | 45
extras/mini-os/Makefile | 4
extras/mini-os/arch/x86/Makefile | 3
extras/mini-os/arch/x86/mm.c | 6
tools/firmware/etherboot/README | 3
tools/firmware/etherboot/eb-rtl8139.zrom.h | 2051 +++++++++++++
tools/firmware/hvmloader/Makefile | 4
tools/libxc/xc_dom_x86.c | 2
tools/pygrub/src/LiloConf.py | 24
tools/python/xen/util/acmpolicy.py | 96
tools/python/xen/util/security.py | 40
tools/python/xen/xend/XendDomainInfo.py | 16
tools/python/xen/xend/server/DevController.py | 27
tools/python/xen/xend/server/blkif.py | 42
tools/python/xen/xm/activatepolicy.py | 27
tools/python/xen/xm/main.py | 5
tools/python/xen/xm/new.py | 3
tools/python/xen/xm/resources.py | 1
tools/python/xen/xm/setpolicy.py | 40
tools/security/Makefile | 11
tools/security/policies/default-security_policy.xml | 30
tools/security/policies/default-ul-security_policy.xml | 41
tools/security/xensec_ezpolicy | 7
tools/xenstat/libxenstat/src/xenstat.c | 2
tools/xenstore/utils.c | 7
tools/xenstore/utils.h | 2
tools/xenstore/xenstored_core.c | 16
unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c | 10
xen/acm/acm_chinesewall_hooks.c | 199 -
xen/acm/acm_policy.c | 6
xen/acm/acm_simple_type_enforcement_hooks.c | 2
xen/arch/powerpc/multiboot2.c | 67
xen/arch/x86/domain_build.c | 8
xen/arch/x86/genapic/Makefile | 2
xen/arch/x86/genapic/bigsmp.c | 10
xen/arch/x86/genapic/probe.c | 2
xen/arch/x86/hvm/irq.c | 26
xen/arch/x86/hvm/svm/svm.c | 1
xen/arch/x86/hvm/vmx/vmx.c | 1
xen/arch/x86/mm/hap/guest_walk.c | 2
xen/arch/x86/mm/hap/hap.c | 56
xen/arch/x86/mm/p2m.c | 180 -
xen/arch/x86/mm/paging.c | 86
xen/common/compat/grant_table.c | 4
xen/common/libelf/libelf-dominfo.c | 104
xen/common/libelf/libelf-loader.c | 132
xen/common/libelf/libelf-tools.c | 30
xen/common/page_alloc.c | 14
xen/include/asm-powerpc/boot.h | 46
xen/include/asm-x86/domain.h | 17
xen/include/asm-x86/hap.h | 2
xen/include/asm-x86/msr.h | 5
xen/include/public/libelf.h | 18
xen/include/xen/multiboot2.h | 99
firmware/etherboot/eb-rtl8139.zrom | 0
57 files changed, 3074 insertions(+), 778 deletions(-)

diff -r 5b19839d0365 -r cd51fa91956b extras/mini-os/Makefile
--- a/extras/mini-os/Makefile Sun Aug 12 12:19:13 2007 -0600
+++ b/extras/mini-os/Makefile Sun Aug 12 14:50:02 2007 -0600
@@ -123,3 +123,7 @@ tags:
tags:
$(all_sources) | xargs ctags

+.PHONY: TAGS
+TAGS:
+ $(all_sources) | xargs etags
+
diff -r 5b19839d0365 -r cd51fa91956b extras/mini-os/arch/x86/Makefile
--- a/extras/mini-os/arch/x86/Makefile Sun Aug 12 12:19:13 2007 -0600
+++ b/extras/mini-os/arch/x86/Makefile Sun Aug 12 14:50:02 2007 -0600
@@ -2,6 +2,9 @@
# x86 architecture specific makefiles.
# It's is used for x86_32, x86_32y and x86_64
#
+
+XEN_ROOT = ../../../..
+include $(XEN_ROOT)/Config.mk

# include arch.mk has to be before mini-os.mk!

diff -r 5b19839d0365 -r cd51fa91956b extras/mini-os/arch/x86/mm.c
--- a/extras/mini-os/arch/x86/mm.c Sun Aug 12 12:19:13 2007 -0600
+++ b/extras/mini-os/arch/x86/mm.c Sun Aug 12 14:50:02 2007 -0600
@@ -405,9 +405,9 @@ void *map_frames(unsigned long *f, unsig

void arch_init_p2m(unsigned long max_pfn)
{
-#define L1_P2M_SHIFT 10
-#define L2_P2M_SHIFT 20
-#define L3_P2M_SHIFT 30
+#define L1_P2M_SHIFT 9
+#define L2_P2M_SHIFT 18
+#define L3_P2M_SHIFT 27
#define L1_P2M_ENTRIES (1 << L1_P2M_SHIFT)
#define L2_P2M_ENTRIES (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT))
#define L3_P2M_ENTRIES (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT))
diff -r 5b19839d0365 -r cd51fa91956b tools/firmware/etherboot/README
--- a/tools/firmware/etherboot/README Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/firmware/etherboot/README Sun Aug 12 14:50:02 2007 -0600
@@ -6,3 +6,6 @@ Rom-o-matic.net will provide this image
Rom-o-matic.net will provide this image at the following URL:

http://rom-o-matic.net/5.4.3/build.php?version=5.4.3&F=ignore&nic=rtl8139%3Artl8139+--+%5B0x10ec%2C0x8139%5D&ofmt=Binary+ROM+Image%28.zrom%29&arch=i386&ASK_BOOT=-1&BOOT_FIRST=BOOT_NIC&BOOT_SECOND=BOOT_NOTHING&BOOT_THIRD=BOOT_NOTHING&BOOT_INDEX=0&STATIC_CLIENT_IP=&STATIC_SUBNET_MASK=&STATIC_SERVER_IP=&STATIC_GATEWAY_IP=&STATIC_BOOTFILE=&EXIT_ON_FILE_LOAD_ERROR=on&DHCP_CLIENT_ID=&DHCP_CLIENT_ID_LEN=&DHCP_CLIENT_ID_TYPE=&DHCP_USER_CLASS=&DHCP_USER_CLASS_LEN=&ALLOW_ONLY_ENCAPSULATED=on&DEFAULT_BOOTFILE=&CONGESTED=on&BACKOFF_LIMIT=7&TIMEOUT=180&TRY_FLOPPY_FIRST=0&EXIT_IF_NO_OFFER=on&TAGGED_IMAGE=on&ELF_IMAGE=on&PXE_IMAGE=on&DOWNLOAD_PROTO_TFTP=on&COMCONSOLE=0x3F8&CONSPEED=9600&COMPARM=0x03&PXE_EXPORT=on&CONFIG_PCI=on&CONFIG_ISA=on&BUILD_ID=&PCBIOS=on&PXE_DHCP_STRICT=on&A=Get+ROM
+
+and the mkhex script in tools/firmware/hvmloader will make the header
+file from the downloaded image.
diff -r 5b19839d0365 -r cd51fa91956b tools/firmware/etherboot/eb-rtl8139.zrom
Binary file tools/firmware/etherboot/eb-rtl8139.zrom has changed
diff -r 5b19839d0365 -r cd51fa91956b tools/firmware/etherboot/eb-rtl8139.zrom.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/etherboot/eb-rtl8139.zrom.h Sun Aug 12 14:50:02 2007 -0600
@@ -0,0 +1,2051 @@
+unsigned etherboot[] = {
+0xeb40aa55, 0xbfe96c65, 0x68744500, 0x6f627265,
+0x0000746f, 0x00540000, 0x0034001c, 0x52494350,
+0x813910ec, 0x00180000, 0x00000200, 0x00010040,
+0x00008000, 0x506e5024, 0x00000201, 0x00008a00,
+0x00090000, 0x00027fd7, 0x00001400, 0x00cc0000,
+0x00000000, 0x49444e55, 0x0000a016, 0x01000201,
+0x10001000, 0x43500abe, 0x81265249, 0x5024007d,
+0x81260c75, 0x506e027d, 0x20b80475, 0x1e50cb00,
+0xd88ec031, 0x3d0304a1, 0x1d74e44c, 0xa30064a1,
+0x66a10300, 0x0302a300, 0xa300afb8, 0xc88c0064,
+0xb80066a3, 0x04a3e44c, 0xb8581f03, 0x31cb0020,
+0xa3d88ec0, 0x02a10304, 0x0066a303, 0xa30300a1,
+0x50660064, 0x0aeb026a, 0x06eb006a, 0x016a5066,
+0xe78900eb, 0x1e505716, 0xb60f2e0e, 0xc1000206,
+0x6a5009e0, 0x012be812, 0x8ec88c58, 0x4a068fd8,
+0x48068f06, 0x50581f06, 0x6a0c6a66, 0x0060e900,
+0x16e08953, 0x55506650, 0x468be589, 0x02468910,
+0x8912468b, 0x685d0446, 0x5066104d, 0x0f2e0e50,
+0x000206b6, 0x5009e0c1, 0xe6e8146a, 0x8f2e5800,
+0x2e064a06, 0x0648068f, 0xc72e6658, 0x00038006,
+0x66000000, 0x00020168, 0x50686600, 0xe8000178,
+0xc4830010, 0x89175b12, 0x3ce85bdc, 0x0002ca01,
+0x6650006a, 0xc0200f50, 0x586601a8, 0x832d7458,
+0x0000247c, 0x44871175, 0x44890424, 0x00b80024,
+0x87000500, 0x50042444, 0x0002b4b8, 0x74c08500,
+0x011ee805, 0xe9580000, 0x000006c0, 0xe5895550,
+0x00067e83, 0x8b501375, 0x46890646, 0x46c76602,
+0x05000004, 0xeb5d5800, 0x1e585d02, 0xb8665066,
+0x000002b4, 0x74c08566, 0x0f061e2f, 0x83a80fa0,
+0x895508ec, 0x46010fe5, 0xe80e1602, 0xd1e803a8,
+0xe8000000, 0x0000027e, 0x010f5858, 0x835d0256,
+0xa90f08c4, 0x1f07a10f, 0x8cc03166, 0x66d88ec8,
+0x6604e0c1, 0x00038005, 0x0ba36600, 0x1f586604,
+0x500175e9, 0xbb061e60, 0xc38e0040, 0x131e8b26,
+0x06e3c100, 0x0d7feb81, 0x2606ebc1, 0x00131e89,
+0x8c06e3c1, 0x89d88ed0, 0x4c8b36e6, 0x78c98518,
+0x47878d15, 0xbfc08e0c, 0xc1831000, 0x8ecf291a,
+0xfcfc89d0, 0x6066a4f3, 0x1f0ec38e, 0x57afb966,
+0x89660000, 0xcf8966ce, 0xf3fd4166, 0x66fca467,
+0x66506661, 0xd889c031, 0x04e0c166, 0x80a32666,
+0xc7266603, 0xf0038406, 0x660000d7, 0x87e58958,
+0x5e89165e, 0x611f0714, 0xb80650cb, 0xc08e0040,
+0x0013a126, 0x0506e0c1, 0xe8c10dbe, 0x13a32606,
+0xc3580700, 0x0000e860, 0x815d0000, 0x0002baed,
+0x56b9fd00, 0x8d000051, 0x06530db4, 0xbc8d0000,
+0x00457c0d, 0xfca4f300, 0x457db58d, 0xbd8d0000,
+0x00000650, 0xffffffbd, 0xa405ebff, 0x0775db01,
+0xee831e8b, 0x72db11fc, 0x40c031f2, 0x0775db01,
+0xee831e8b, 0x11db11fc, 0x75db01c0, 0x831e8b07,
+0xdb11fcee, 0xc931e673, 0x7203e883, 0x08e0c10d,
+0x8346068a, 0x5074fff0, 0xdb01c589, 0x1e8b0775,
+0x11fcee83, 0x01c911db, 0x8b0775db, 0xfcee831e,
+0xc911db11, 0x01411d75, 0x8b0775db, 0xfcee831e,
+0xc911db11, 0x0775db01, 0xee831e8b, 0x73db11fc,
+0x814141e6, 0xfff300fd, 0x01d183ff, 0x2f348d56,
+0xe95ea4f3, 0xffffff74, 0x9090c361, 0x90909090,
+0x00000000, 0x00000000, 0x0feb02eb, 0x89559c50,
+0x87c88ce5, 0x46870646, 0x9c9d5d04, 0x0fa80f50,
+0x161e06a0, 0x01dee80e, 0x550cec83, 0x24448b50,
+0x00000d28, 0x44890006, 0x00e81024, 0x5d000000,
+0x003fed81, 0x858b0000, 0x0000008b, 0x0000002d,
+0x04dc0500, 0x44890000, 0x858d0824, 0x00000067,
+0x0c244489, 0xe8c35d58, 0x0000007a, 0x071f1f1f,
+0xa90fa10f, 0x5502c483, 0xf766e589, 0x00000646,
+0x755d0004, 0x9dcb9d02, 0x000004ca, 0x53000000,
+0xe8555756, 0x00000000, 0x98ed815d, 0x8b000000,
+0x0001bb9d, 0xa3eb8100, 0x8f000002, 0x0002b783,
+0xb3838f00, 0x8f000002, 0x0002af83, 0xab838f00,
+0x8f000002, 0x0002a383, 0xa7a38900, 0x8b000002,
+0x0001b3a5, 0xb7b5ff00, 0xe8000001, 0x00000006,
+0xe904c483, 0x535500d9, 0x0000e850, 0x815d0000,
+0x0000eeed, 0x9b858d00, 0x89000001, 0x00019d85,
+0x44b70f00, 0xe0c11024, 0x24442904, 0xc1c3890c,
+0x896604eb, 0x890e245c, 0x04ebc1c3, 0x9d8d5366,
+0x0000018e, 0x5366c329, 0x00000868, 0x849d8d00,
+0x29000001, 0x896653c3, 0x0001a585, 0x10e8c100,
+0x01a78588, 0xa5880000, 0x000001aa, 0x2444b70f,
+0x04e0c11e, 0xad858966, 0x89000001, 0x10ebc1c3,
+0x01af9d88, 0xbd880000, 0x000001b2, 0x9b95010f,
+0x66000001, 0x8e0010bb, 0x8ec429d3, 0x8ec38edb,
+0xcbeb8ee3, 0x80c3200f, 0x220ffee3, 0xc166cbc3,
+0xd08e04e8, 0x5b665866, 0x17cb5d66, 0x00000000,
+0xff000000, 0x000000ff, 0xff00009b, 0x000000ff,
+0x00000093, 0x00000000, 0x00000000, 0x30000000,
+0x0042e801, 0x000000e8, 0xed815d00, 0x000001c9,
+0x02bbbd8b, 0x8d8b0000, 0x000002bf, 0xf3fce689,
+0xa7a58ba4, 0xff000002, 0x0002a3b5, 0xab9d8b00,
+0x8b000002, 0x0002afb5, 0xb3bd8b00, 0x8b000002,
+0x0002b7ad, 0x6afac300, 0x66556600, 0x89506653,
+0xdb3166e5, 0xdb8e5b0e, 0x04e3c166, 0x46b70f66,
+0xd801660e, 0x0c468966, 0x66dd8966, 0x00e8db31,
+0x8d665b00, 0x66005287, 0x8966e801, 0x66005487,
+0x003e878d, 0x66e80166, 0x006a8789, 0x16c03166,
+0xe0c16658, 0xb70f6604, 0xc50166ec, 0x97010f66,
+0x200f0052, 0x0f010cc0, 0xff66c022, 0x66006aaf,
+0x8e0010b8, 0x8eec89d0, 0x8ec08ed8, 0x58e88ee0,
+0x17c35d5b, 0x00000000, 0xff000000, 0x000000ff,
+0xff00cf9f, 0x000000ff, 0x6f00cf93, 0x08000002,
+0x00000000, 0x00000000, 0x00000000, 0x00000000,
+0x00000000, 0x00000000, 0x00000000, 0x00000000,
+0x02000000, 0x0002bd01, 0x00000000, 0x90909090,
+0x00008008, 0xfffffb7f, 0xc7835f58, 0x5b585e06,
+0x89d68e59, 0x00f883fc, 0x53510375, 0x750207cb,
+0xcd19cd02, 0xffeefdbb, 0x9090fb18, 0xf958fbfa,
+0x069c15cd, 0xbb660eb4, 0xcd000001, 0x5cd20c10,
+0xc0317f6e, 0xe43016cd, 0x9c01b407, 0xadff0258,
+0xe083fffb, 0x12cdfa03, 0x31c931f9, 0x523158d2,
+0xc4835048, 0x165b6606, 0xbff7ed07, 0x66e789fd,
+0x39e820b8, 0x4150ba66, 0xb966534d, 0x66154514,
+0xeddf7609, 0x5b9c50fe, 0x7c009a07, 0x1f0e5819,
+0x099e8d5d, 0x55cb1500, 0xdfffb7dd, 0x1eff2e18,
+0x729c002d, 0x81e5891c, 0x0f3c027e, 0x08009584,
+0xedff7f01, 0x8000c637, 0x0788037e, 0x5d9d0101,
+0x0002ca5d, 0xc1016600, 0x6ffffedb, 0x2966da02,
+0x660377c3, 0xff85db31, 0x39661274, 0x132b76c2,
+0xe6ed07c3, 0x13cb6ef6, 0x1eebd989, 0xd272ca1d,
+0xde28f766, 0x39f7ee76, 0x07e376da, 0x1527ca01,
+0xc11dd089, 0xfffe56c3, 0x5292eede, 0x2e4d9bbe,
+0x54045c8b, 0xffa5e804, 0x8108c683, 0xc877abfe,
+0xeaa4dede, 0x5ecb5a66, 0x660000c3, 0x97b7d33d,
+0x850fffed, 0x2666ff72, 0x00047d83, 0x66506809,
+0x458b0d51, 0xbbfedbe5, 0x084d0400, 0xe8ff3157,
+0x0b5fffa4, 0xfd891089, 0x66dbb7fb, 0x42e9ee59,
+0x91000c14, 0x06e8da87, 0xff33e905, 0x56f85757,
+0xbf5033d8, 0xc166aa60, 0x5b3010e1, 0x36dfdd6d,
+0xc14b6ced, 0xcb8910e9, 0x030a1359, 0xdb6fffe8,
+0x115a90b7, 0x45582a0a, 0xe853c35f, 0xe95bffc8,
+0x9b30fef7, 0x01f0d0bb, 0x09016866, 0x00686eeb,
+0xfe500507, 0x789785ed, 0x80002be8, 0xa19ccb08,
+0x9d137556, 0xad564eb8, 0x5317dbe1, 0x07004036,
+0x003e1ed7, 0x0f9d38f8, 0xd93c2ff7, 0x42c83a2e,
+0x66d55000, 0x4487c88c, 0x76030424, 0x7b05fbbb,
+0x0f08ec83, 0x0f660801, 0x66a002a8, 0xfb76dd5a,
+0x66164185, 0x128d600e, 0x0c038938, 0xfb6e4407,
+0xe850dff6, 0xed815d39, 0x89060514, 0x058138ad,
+0x7dbf168b, 0xbaa9bbfb, 0x8d217400, 0x09c470b5,
+0xd470bd8d, 0x72f43905, 0x6f8e3904, 0x76fcfeec,
+0xb9e6890d, 0xcf293248, 0xe8a4f36d, 0xb9b64fe3,
+0x2d8bdfb7, 0x686c2936, 0x450b83e8, 0xed12203f,
+0x0f7b6dfe, 0x04240ab7, 0x5026245c, 0x6088858d,
+0x6dbffa50, 0x548fb6ff, 0x01d38e7c, 0x6158cbec,
+0xa102a993, 0x1f660766, 0x6ffb9a14, 0x8b9d0ce4,
+0x9cd42464, 0x832696f7, 0x6fb7fec5, 0x9dcb9dbc,
+0x565507ca, 0x247c8b57, 0x983d2b10, 0xb6bfb7b8,
+0xafa81061, 0x0480e868, 0x7cbae855, 0x336edd63,
+0x0ee05b1f, 0x8904e2a3, 0x6dbfbe77, 0xb9237dfb,
+0xa3f129b4, 0x2015732e, 0x7ffe00ea, 0x00a80bf7,
+0x10b80008, 0x8ed88e1c, 0x8ed08ec0, 0x5fe88ee0,
+0xe6c35d5e, 0x35dbbbf3, 0x3589e620, 0x283d0524,
+0xddbf2c1d, 0xa358efdd, 0x34250b30, 0x70bb5905,
+0x5f1d033e, 0x770f6853, 0x4328bacf, 0xb1e8e451,
+0x0ca5890b, 0xcde9a528, 0x2f00bf75, 0x612974a5,
+0x768de4cf, 0x4d7b7f00, 0xbcfc77b7, 0x6020a88f,
+0x1b22ed0a, 0xa15bb7b1, 0x35b70234, 0xd0ff0b07,
+0x91cf7e8b, 0x8b8b9191, 0x8b158b8b, 0x23bbc28d,
+0xff041ca1, 0xda4c8be2, 0xb7ff1bd4, 0x5189680b,
+0x89045902, 0x69890861, 0x5e71890c, 0xdcd0bd79,
+0x006d148f, 0x431f1bc3, 0xbf4a8b08, 0x37b6dbfe,
+0x0862095a, 0x728b0c6a, 0x147a8b10, 0x59b80519,
+0xfd4f6b69, 0x9c284389, 0xb664bea0, 0x5401c2d8,
+0x208dce0c, 0xb849687e, 0x1f30b8b9, 0x5d5821a2,
+0x87bc3c9d, 0x3d282ef1, 0x50802b07, 0x2e4070f0,
+0x89003881, 0xb1fa8285, 0x6fd23921, 0x29077095,
+0x7ee68d4f, 0x530c281d, 0x9da95350, 0xdd4bed1d,
+0x43892a4b, 0x1d0a0302, 0x04438810, 0xfdb84702,
+0x63880cf2, 0x585b0f07, 0x560090c3, 0x6cbe72a1,
+0x1b0aed6e, 0x0483000d, 0x6a24c629, 0x33736f00,
+0xf2b801fd, 0xee2d0629, 0xdd056850, 0xe8efe37a,
+0x189008bc, 0x0dbd3b80, 0x057003c6, 0x2f62b63c,
+0x00b03cdc, 0x5b060e18, 0x51000c03, 0x1dbe9b63,
+0x24046f21, 0x0602026a, 0xcd0c0650, 0x50eebdb3,
+0x2d40f9b8, 0x70f24b52, 0xe816e589, 0x1a2d955a,
+0x7d550119, 0x79dfd6df, 0x0374c085, 0x6dd5b60f,
+0x49509b5a, 0x2f973488, 0x8f0203b6, 0x03060e46,
+0xf636b0f9, 0x9229f98c, 0xf7b42f1c, 0x0e722f6b,
+0x05212603, 0x672107e8, 0x2625b987, 0x16d861c0,
+0x32ee0e23, 0xe30e233c, 0xf7063e4c, 0x872723d0,
+0x1f298bcd, 0x2ece1616, 0x4db93ccc, 0xad1f2321,
+0x1f46792f, 0x53565795, 0x5b4bee27, 0xc76614ee,
+0x6c8dadc5, 0x570a6a04, 0x7778d7ca, 0x2ebb7497,
+0xeb81562a, 0x6c05f23e, 0xe8ee7598, 0x24f3375d,
+0x34750d83, 0x705eb6d8, 0xd2854c72, 0x3c835b75,
+0x7f68eb0a, 0xf51664da, 0x06e0c106, 0xae018c07,
+0x702ad7c8, 0xe87414c4, 0x1b060a15, 0xebd2f63b,
+0x88006dea, 0x025a5669, 0xc9ec60d8, 0x55cceb92,
+0x3b072094, 0xdba3ffee, 0x062b381d, 0x31617d7b,
+0x6ae089ed, 0xe102501e, 0xb8c3bdaf, 0xd09f6450,
+0x06c4e805, 0x607f78f7, 0x0282811b, 0x8b4175cd,
+0xdde3a404, 0x75b14777, 0x4334b22a, 0xd5283c8d,
+0x05b9fc0a, 0xffba5eb4, 0x5b14c5f7, 0x0b7da5f3,
+0xa874db85, 0x89a106ba, 0xc156b7da, 0xdeada599,
+0xf2eb3a14, 0x67eb102f, 0xd4e80c87, 0xabbbd601,
+0xbbddfffe, 0xa3bd02f7, 0x0a71ba40, 0x4c68206a,
+0x7bbba30b, 0x1044bedb, 0x6cff0f47, 0x0c48a35a,
+0xcb737559, 0x6f6fbb67, 0x0af22705, 0x0854a399,
+0xc70d44a1, 0xbc1ed7bd, 0x09f42005, 0x336e003c,
+0x5009b20f, 0x0f581589, 0xbac1055c, 0x1901b191,
+0x64091060, 0xd9360d23, 0x2268a3d8, 0x2c703c6c,
+0xafb876a1, 0x082e59e1, 0xe3073916, 0xd7861b73,
+0x83351763, 0x18744ebd, 0x9b181aff, 0xfc6bf033,
+0x77e7721d, 0x868bebed, 0x95bf0b7f, 0xdbfa837f,
+0x52779285, 0x7e24ff3d, 0x77e070ad, 0x8532be4b,
+0xb52b941e, 0xfdafe0df, 0x23d3391b, 0x770c72ce,
+0x0676c60e, 0x2d8d8b8b, 0x2c0db5bc, 0x3fc70729,
+0xc3b1d835, 0x19d209da, 0x629d8b3d, 0xdb7f0db6,
+0x228d08fb, 0x2e70870f, 0x0903f981, 0xe9bb1f7b,
+0xce89640b, 0xdf894203, 0x5230bd13, 0x70deedbd,
+0x04b7d739, 0x1d46820f, 0x0f6c0877, 0xdfec3c86,
+0x8009cdc1, 0xc1891b77, 0xc8291577, 0x8c89da19,
+0x6c7701db, 0x1de96289, 0x4c0e011e, 0xb03ec990,
+0x85c781ba, 0x66580954, 0xe970ddd0, 0x13b8bff0,
+0xab05d704, 0x1f12b86d, 0x6a83c39c, 0x2e400a0c,
+0x08b221de, 0xe208af48, 0xe07b8376, 0xef4c35ff,
+0x74e70d5b, 0x60380310, 0xa337f6f7, 0xfdd2e91e,
+0x770f684d, 0x704d3e1e, 0x38ed93bc, 0x0949feeb,
+0x2b8520a1, 0xc9b59b30, 0x1d4f4669, 0xf75837f5,
+0x59379ae8, 0xda380062, 0xbafc5357, 0x109ffc77,
+0x89d6ff05, 0x15c5e8c3, 0x0d8ba6ba, 0x48f16e2d,
+0xebc1ca65, 0x91028b46, 0x16a178b6, 0x891f2af6,
+0x62dff5c7, 0xcab6df6b, 0xc1d7bd3a, 0x071c0ae2,
+0x7625b7cb, 0x896802d1, 0x04aa9cd7, 0xd0a15b5a,
+0xf889c5e1, 0xf1516b63, 0x70edbbd6, 0x54689fe8,
+0x89587524, 0x78935bd8, 0x56c08fbf, 0x03c28984,
+0xe2815d15, 0xb102c575, 0x8c8d921f, 0xd66b801a,
+0xcdc5a9a9, 0xf289bdac, 0x4e1d280d, 0x7b7ffbbc,
+0x701474c9, 0x02c7044a, 0x45524621, 0x9a00c281,
+0xec754966, 0x6e867b19, 0x5c1deb47, 0x04a36965,
+0xe8b0df6e, 0x5a5863f8, 0x06fcb5e9, 0xedc75790,
+0xb96f81ad, 0x115429ca, 0xe7c1faaa, 0xb77d1bb2,
+0xfa81c06f, 0x81580280, 0x53754f3f, 0xed8bb603,
+0x5f0457da, 0xc9044f1d, 0xc3c5ebc7, 0xd9846170,
+0x53b0fe56, 0xa9998df8, 0x2dfdc184, 0x5900e381,
+0xa13b29b9, 0xde1866a3, 0x0c0eafc1, 0x51b5bb1b,
+0x6bf37268, 0x03768f00, 0xfba25795, 0x52561882,
+0x599161e8, 0x25b929d8, 0x3529eefc, 0xeb5b0046,
+0x5ab890e4, 0xbb65b856, 0x08fc4aed, 0x60158b46,
+0xbac5b350, 0x74da6f6f, 0xff475b02, 0x41144c39,
+0x587421b6, 0x097a05c7, 0xd5b87704, 0xd8eb5ae0,
+0x403d3417, 0xd72d4cd1, 0xc774dcd5, 0x22960d39,
+0xb1cdbdad, 0xe869df6b, 0x448a24c7, 0x6c2d82d1,
+0xeb87b83a, 0x365621db, 0xb62d7b54, 0x1c0777be,
+0x477a9639, 0x8b7008d8, 0xb854be9b, 0x37bbfbe3,
+0x43900578, 0x938389cf, 0xbd828d07, 0xfa63ba2f,
+0xb85d0183, 0xba0f2df2, 0xd1bbdffb, 0x9615be34,
+0xa13a148d, 0xc83bc46c, 0x7c4beac1, 0x8b1a5ef8,
+0x0d180409, 0x765689b6, 0x7ec103c7, 0x7605ab4f,
+0xae8d0001, 0xb0f08d8b, 0xb63e7489, 0x2fc57cbb,
+0x53b1a975, 0xb7926702, 0xc229760b, 0x9ec6fd3b,
+0xdfa315bd, 0x8294ea81, 0x86038992, 0x509c8789,
+0x2bdfeb00, 0xd32b696b, 0x109e4d81, 0xd5b139d0,
+0xfc3d3a70, 0xdb001822, 0x7fe9dd1b, 0x89130480,
+0x1c2d2bc5, 0x8bda1425, 0xc68ea96e, 0x7adc0c42,
+0x1fa291fe, 0x0d9eef64, 0x8f01bf42, 0x84e8560c,
+0x6ed9124c, 0xc601e3b1, 0x1cff20c4, 0x6c1730ff,
+0x9d76ee15, 0xc31b2c3f, 0xf45e5502, 0x08b0be03,
+0xc134b9ef, 0x4e1c4f01, 0x6a61731e, 0xe0304cfb,
+0x80972a78, 0x85b5a903, 0x3a0d06ed, 0x07c3248e,
+0x7ab84d45, 0x9e084377, 0x10438b14, 0xe08df891,
+0x1cded6db, 0x9c979902, 0x1859c541, 0xc05c7a03,
+0x033e5df4, 0x675e4d3d, 0x36ff5046, 0x756f847c,
+0x4bebe857, 0x730320f8, 0x45e9d70c, 0x3960e857,
+0x19744c29, 0xbf4e0873, 0x2d2befc2, 0x06e88933,
+0x2a0ee9ec, 0x056f6df4, 0xe0eb0419, 0xd10d9690,
+0x82eb7e03, 0xa110a32d, 0x08a5080a, 0xfce18303,
+0x2ed1beb6, 0x4355045f, 0x5154cc29, 0xd56bae3e,
+0x5f5b99dd, 0x3ef632e8, 0x830655d0, 0x89b89b08,
+0xc3415dec, 0x1eb76990, 0x387e1dbc, 0x9024ac8b,
+0xf7503658, 0xe0f873c5, 0x4c96e83a, 0x9c47c713,
+0x4a274674, 0x18ef9a94, 0x4e601236, 0x898984bc,
+0xc3830ffb, 0xe16fc818, 0x75118dd6, 0x108b2029,
+0xa12ab9ab, 0x99e056a5, 0x1a8ff9f7, 0xfe10c206,
+0x7d7709bb, 0x940e1810, 0xca114208, 0x5553f07c,
+0xeb718ef5, 0x29920862, 0xe581ca0b, 0x3db5c06b,
+0x087466bb, 0x140a7449, 0xb8956d38, 0x8f69f17b,
+0x106a102c, 0xa119e1c3, 0xd02db00f, 0x2900d028,
+0xc4ddcba1, 0x8b90d1fe, 0x020d68f3, 0xae07718a,
+0xc10a19c5, 0xa0882f72, 0x714719bd, 0x1b0e8ba3,
+0xc177ce3b, 0x0972edf5, 0x15154a72, 0xe685ed5e,
+0xc308b985, 0xe30b0abe, 0xb8077768, 0xd939d5d1,
+0x0b73288b, 0x5fa5ede1, 0x423204c1, 0x72d4c101,
+0xc10b5bf5, 0x1931c35e, 0x1007a60a, 0xea4ed4a1,
+0xb85bbde5, 0x6e85b75b, 0x840fd848, 0x50bd6a07,
+0x942d7c88, 0xb3f0e783, 0xb5e370cb, 0xb9f72724,
+0x01a13880, 0xaf94afde, 0x0e838d0f, 0xf7f63759,
+0x77982db4, 0xa00505b8, 0xaf081304, 0x5d038607,
+0x6e030ada, 0x6b04a77f, 0x8dc2b077, 0xf0e5566c,
+0x1febf622, 0x9a28776d, 0x772a6804, 0x05499d29,
+0xc6e57598, 0xc65899c6, 0x36880707, 0x38d7ec47,
+0x862b666f, 0xb61c18bb, 0x1cec7418, 0x12bf071d,
+0xeb2a076e, 0x02d8171e, 0xa166d622, 0x032e1661,
+0xac43335c, 0x3e1a3b26, 0xd6da2e0d, 0x285314dd,
+0x321b2003, 0x6da9182b, 0x2b127d9b, 0x0330155b,
+0x91919a7b, 0x43c770ce, 0x0e080542, 0x91919106,
+0x2c14160c, 0xdd236375, 0x1e1805ff, 0x40093670,
+0x7609db63, 0x6342435a, 0x48054607, 0x7c83637c,
+0x054e4a12, 0x1d521250, 0x5683475b, 0x49f558a9,
+0x325d28dc, 0x0543e97c, 0x60738d6a, 0xba082f68,
+0x2b584894, 0x14bbff52, 0x2c0846c6, 0x23a7e2bf,
+0xd5ad6ec5, 0xf40a466c, 0x917546c4, 0x0320bace,
+0x9b8bf714, 0x2bf7220f, 0x1603d739, 0x36fd2ddf,
+0x0311fb01, 0x2671ae77, 0xf295fa01, 0x0fe38337,
+0xdfb6cf0d, 0x23030c5c, 0x010646c7, 0x910e0402,
+0x23221246, 0x18056323, 0xb7761c1a, 0x46e6c76f,
+0x285e032a, 0x979e2c6a, 0x0946b1fd, 0x31e0c108,
+0x8c80c740, 0x3ea7f40d, 0x98a42372, 0xcde81c04,
+0x43318b47, 0x160a6377, 0xd0e85532, 0x91063503,
+0x027a4736, 0x38652510, 0xede9b4d8, 0xf8431011,
+0x0558c2d3, 0x6eee0981, 0x2d7a8585, 0x4e53deeb,
+0xb46eebe8, 0x9c8ae3a0, 0xf71d1cf7, 0x20d9de5b,
+0xc3bf3ee0, 0x813256de, 0xbb05ec52, 0x88ba830e,
+0x760fd788, 0x98f9044b, 0x2168be6d, 0x188b068d,
+0xf8ce54b2, 0x06815fe3, 0x89a4c24f, 0x840b5282,
+0xe11dfe13, 0x58824d19, 0x8019840c, 0x1bee5e06,
+0x82c7eebc, 0xf9601056, 0xb8da293a, 0x811b31b3,
+0x65018df7, 0x83c71689, 0x8393ec69, 0x34ad64f0,
+0x7581826f, 0xbd09b908, 0xc87a1fb3, 0x82b865c3,
+0xf7380b0e, 0x70928bef, 0x89e81089, 0xd967349a,
+0x090d75a8, 0xe835eb44, 0x136bd5e9, 0x1b1e754e,
+0xc4132305, 0x04afa1b8, 0xb2c75859, 0x7c4c2d00,
+0x833668e8, 0xf78843ba, 0xd9c13add, 0x8b8a5151,
+0x601376b5, 0x6d4b0c35, 0xe0e201bd, 0x23720beb,
+0xd81f68b4, 0x6a0ee2fa, 0x6fd01aae, 0x8d046780,
+0x96600f01, 0x57130835, 0x5f233e2f, 0x5c505067,
+0x115e70fa, 0xe8d8f08a, 0x43b01eb0, 0xfea75d38,
+0xc283d70c, 0xdb388104, 0x06d318c0, 0x4276d0ae,
+0x042d67a6, 0xde0fb8ef, 0x0842af8d, 0x1e045162,
+0x4a2581a2, 0xe3e88ebe, 0x0a13b4d1, 0x0a246cd0,
+0xac400e50, 0x21431a36, 0x6e25ca55, 0x5bc9cddb,
+0x012b518b, 0x75065209, 0x70effba9, 0x1058f42b,
+0xc4ebd109, 0x8b7ae068, 0x0bba5ad4, 0x25e8bbb1,
+0x3e40043f, 0x097b2013, 0x7343efc0, 0x0a6a13ef,
+0xb09e35e8, 0x4d42af0a, 0xb604c1c2, 0x0657a510,
+0x77a957cc, 0x77be1cb7, 0x8b07771b, 0xdb121934,
+0x7bc5b6ea, 0x7bc574ce, 0x05352218, 0x90b6ede9,
+0x1825178d, 0x76012648, 0x00ede007, 0x0f3b91ed,
+0xab6942c4, 0x01e8dc97, 0x5a14dd6a, 0xf1dae240,
+0x823749fc, 0xc917d19f, 0x755a405f, 0xdc1f81bc,
+0x08b302d3, 0x247b8df6, 0x3bc2d42b, 0xeb0024b2,
+0x03068797, 0xc868377f, 0xbb535212, 0x594503c7,
+0x1bddf2eb, 0xf0850222, 0x5c478b18, 0x0cef1c24,
+0x683e0dbf, 0x41e9c578, 0xfce0b953, 0x8e0b4789,
+0x8a68dbdb, 0x6c478855, 0xd33aa272, 0x0a145712,
+0x5e68da17, 0xee52795d, 0x789fb7b3, 0xc87e4b42,
+0xe4293d4f, 0xf0f0c094, 0xf0de02ff, 0x0636748d,
+0x8d56ed31, 0x837b0745, 0xdea56786, 0x5750028c,
+0x83280b45, 0x1ab4fafd, 0x7e03edfc, 0x684f48e0,
+0xec58518d, 0xeef70cb7, 0x51fc2fc7, 0xa9ed6662,
+0x7f7cbacf, 0x81ba0575, 0x7b1dc206, 0xb8520029,
+0x89b80e86, 0xad770f06, 0x5c77ee5d, 0x6807895e,
+0x427d6068, 0x736bdc09, 0x38fe81a6, 0xfebbf496,
+0x50965ad6, 0x267504b4, 0x364e07c7, 0xe84147c7,
+0x0c48efe7, 0x144c061b, 0x1c14501a, 0x77e0f022,
+0x68f75aa4, 0x40fc45a0, 0x60c5fc5b, 0x95eb0fb0,
+0x708bdd0c, 0x7fb61768, 0xbf283577, 0x50c6b506,
+0x0bd1e7d3, 0xbcb02428, 0x80a97f89, 0x88b0ee99,
+0xcb89edee, 0x8833788c, 0x80dddcd9, 0xf8d3895b,
+0xfa950ff9, 0x7be0d1c0, 0x7b7eedab, 0xc9f64c8a,
+0x0275e688, 0xbf30c888, 0xedb776f6, 0xc883158a,
+0x794b088c, 0xbb113dcd, 0xfdddf610, 0x8cb05876,
+0xb3e5d10a, 0x56c50901, 0x622df34b, 0xe97ffb40,
+0x2a08f7b0, 0x04fe1bb3, 0x5390a46e, 0xb968587f,
+0x53dc840e, 0x6db77144, 0x05efca1b, 0x06ff4f08,
+0x0b5bef0c, 0x6b98a50f, 0xb4b004b6, 0x3e905bc2,
+0x68ee37fa, 0xe0662e9a, 0x45e409a6, 0xe820f570,
+0x2df558d9, 0xaefc03d6, 0x74107626, 0x5908e809,
+0x460cea2f, 0x8bf685ad, 0x5c1a5c5f, 0x2fc48d8a,
+0x31ffa171, 0xf98341ee, 0xd0f37e05, 0xda41b037,
+0xdab78dee, 0x444ef76d, 0x897f00b8, 0x405675ca,
+0xef03550a, 0x167bbb5b, 0x9588d422, 0x24ef3056,
+0x42c2ee28, 0x251e6b17, 0xef534c23, 0x3eda059c,
+0x6ecd3fc7, 0x2d3c6f58, 0x8f08c3e9, 0x5067d6ef,
+0x76c48665, 0x874789e0, 0x86842425, 0xbe9da106,
+0x6820a96e, 0x5a136be8, 0x21abf30f, 0xee6877ce,
+0x1cf2040e, 0x86475d1a, 0xf310f46f, 0x315339fc,
+0xfec46f2c, 0xd0f668c0, 0xdee80ec3, 0x3bfb6414,
+0xddb46a77, 0x83c60def, 0x0c430047, 0xc883f376,
+0xd0fc09ef, 0x2c8d069d, 0xc1818690, 0x86e29b1f,
+0x55758dd6, 0xcb81efa3, 0x4e558d3d, 0x6d437b78,
+0xecf7e8ef, 0x12708db5, 0x7da03e27, 0x829a3573,
+0x0c256616, 0xded7c080, 0x33e0b82d, 0xf03920d6,
+0x5249de72, 0xbfc2837e, 0x8a548d27, 0x7428b510,
+0x01418d11, 0x896f8c42, 0x5818a3d9, 0x09c60566,
+0x985bc037, 0xa855f1eb, 0xc17bfb14, 0xe37f6150,
+0x836175f8, 0x8fdac4fc, 0x7496f886, 0x0e6e1655,
+0x9d0b6dad, 0x6dae1ae8, 0x70fdc3b2, 0x1f27036a,
+0xc68969ed, 0xef03f625, 0xee1d4ba0, 0xe93ea910,
+0xdefe830d, 0xa25a1b0b, 0x76aaee70, 0xec8d1b1d,
+0xbf4f7360, 0xe5751a29, 0x85d231c2, 0x4960da0d,
+0x166587d0, 0x7eeeadc5, 0x003dfcf7, 0x644f4520,
+0xfcbb6476, 0x53d32955, 0x374d42d3, 0x5658d8b9,
+0x0b9ee860, 0x9fd27189, 0x3ad8c2a9, 0x5f036ec3,
+0xdfd7f960, 0x1588dc06, 0x8c350322, 0x1707468d,
+0x5e2562e6, 0x05f60aa3, 0xefb12fcd, 0xb910db6b,
+0x51b6af38, 0xa3cfefc3, 0xebec06c7, 0x415c5185,
+0xb7eb0c46, 0xd0fb406f, 0x93015cc6, 0x17081176,
+0x00a8b71a, 0xbb528b75, 0xb636c237, 0xeeb11c17,
+0x25062d0a, 0x49307fac, 0xad6fbb58, 0x0dc34c07,
+0xf64d8053, 0xc60ccb90, 0x0b90b6e6, 0xed5326d9,
+0xfe3190c7, 0xe8ef3868, 0x53db55fd, 0x1c9a50f2,
+0x7a24562c, 0xbd77134c, 0xfa810183, 0xbeab6948,
+0xeb0ed03d, 0x3d8d806d, 0x05c61310, 0x9e261c0d,
+0x481a5bb5, 0x7722126f, 0x85dd523a, 0xb024a3ad,
+0x0ec50350, 0xcf637823, 0xbb08fde0, 0xffc8c33c,
+0x5ffa8954, 0x6d361588, 0x555b3ebd, 0xe8013f56,
+0xe24b5c19, 0xb76dc4cb, 0x752e5041, 0x4ce819c2,
+0x1f445c68, 0x91c3601e, 0x3d5630b8, 0xd52db62a,
+0xc61753e6, 0xf00b4005, 0x175c1637, 0x1833dce8,
+0x57a7e803, 0xf81b6fdd, 0xd6c81556, 0x5884665d,
+0x1ee85975, 0x3a27e8dc, 0x17a9dd76, 0xe84f6e04,
+0xdae880d1, 0xeedba471, 0x13ba2468, 0x3d0ee953,
+0xa8fceaff, 0x6716836e, 0xdc0d5f18, 0xbbae0860,
+0x5e1763c4, 0x00c3f275, 0x5b572aa9, 0x8ebc0c84,
+0x0da1115b, 0x26b63703, 0x1017151c, 0x78e0e7c2,
+0x1407c18f, 0xebc73be7, 0x064fa187, 0x25ba23bb,
+0xff681cfc, 0x6ea37100, 0x4bc705a0, 0x3369e8fc,
+0xafa9043d, 0x7e091a96, 0x0f71be0c, 0xdb20e21b,
+0x440802fb, 0xdbc1d58f, 0x6c36ed74, 0x7e035cb7,
+0x27e48417, 0xff54eca1, 0x43a15b50, 0x17cba72c,
+0xc0fd2728, 0x74f0f7ee, 0x613b6826, 0xf43d796d,
+0xb5bb0220, 0x0b376cff, 0x0e097f58, 0x31d47ef8,
+0xe1d0ebdb, 0xf6360895, 0xf4eb030c, 0xc3c5a209,
+0xe022a21f, 0x0fe85d74, 0x5bd87e23, 0x893cf4c2,
+0x2818ab75, 0x5d0db91c, 0x51d900b8, 0x38f0a3a2,
+0x9b30fd82, 0xc77c4e5d, 0x8025e405, 0x2fe8125d,
+0x300939a8, 0xb6348d33, 0x265436d9, 0xcfe74303,
+0xe7f876b2, 0xe604b5b6, 0x7c04008b, 0x77fb8111,
+0xb9d72110, 0xe92857dd, 0xe4280430, 0xc1890e7d,
+0x53575f62, 0xba04f873, 0xb7f12c5b, 0x5916158b,
+0x5bf17a83, 0xc6ffa107, 0x66e884ec, 0x1939eb22,
+0x7420423b, 0x3bb76814, 0x124487d8, 0xe9ad3a5a,
+0x02bb78ce, 0x66c1df09, 0xa204c5cf, 0xf0b1e9b6,
+0xd4c15e83, 0x208edb00, 0x6a37716a, 0x82abd76f,
+0x5e23a158, 0xc200a6d6, 0x907bfdf7, 0x0c8d4362,
+0xe1a1359d, 0x6a162cd3, 0xe62e8174, 0x079efd0f,
+0xb61ac70f, 0x89b6035a, 0x62158924, 0xb0b84f7e,
+0xc46a0a84, 0x039e0975, 0x7a6c0a74, 0x08fe52ad,
+0xf8397fc1, 0x0b52c533, 0xa2d4eca9, 0xdf8b1ce4,
+0x770a8bec, 0x89d440c7, 0xb6fbf448, 0x1c705b0b,
+0xbb75200c, 0x8400e94b, 0xd40de2bb, 0x1378e802,
+0xfdf1e9f6, 0xf70b1833, 0x5cfd8a70, 0xd5ed35a4,
+0xc2664777, 0x0f970832, 0x3d25c588, 0x5d001f76,
+0xc709bbe9, 0xb1c28105, 0xe80ef88d, 0x328b4293,
+0x8d8cf685, 0x72dcdee1, 0x8e0fb21c, 0x618c076a,
+0xeadd830e, 0x0001b12d, 0xb48d5652, 0x0fd09e86,
+0x99788321, 0x05872724, 0x85ce4bbe, 0x03018c39,
+0x3bdbf004, 0x2c68eed2, 0x2abb59bf, 0x4b1ee913,
+0x01baeb86, 0x53d7ae47, 0x4aa1bdf3, 0x7b719fc4,
+0x3c89b10c, 0xbcd88a24, 0x31078a50, 0xc2fe25ba,
+0x10d284f6, 0x0c743a3c, 0x0b3e5446, 0x81b76d04,
+0xbbf4755f, 0xfbd37548, 0x1e730550, 0x7a463a7f,
+0x4ac0338a, 0x30020c70, 0x0db3c6df, 0x721d08c8,
+0x5a354be2, 0xdcd03e68, 0x5306568f, 0xda8a0938,
+0x89d81bfa, 0x699d01d6, 0xa9764a4f, 0x6ad33f75,
+0x27656803, 0xfbf8698d, 0x02d04e3a, 0x881e0a34,
+0x5ffdda01, 0x894e94aa, 0x78802414, 0x1a742f03,
+0x5250a88d, 0x5827a9fd, 0x081e1223, 0x3a388025,
+0x737a705e, 0x2a2fec4b, 0x89752f09, 0xd78b6ceb,
+0x4c69d26d, 0x37357ea3, 0x5d02eb79, 0xcc40bd11,
+0xb61b0453, 0x81f13e06, 0x8d0ab240, 0x9f7152c6,
+0xebc0fe9f, 0xe2faa34e, 0x21e890b6, 0xddfb0887,
+0x9b086ac6, 0x6a00902e, 0xe0b3ebfe, 0xe4c1b167,
+0x8005ffff, 0x833e653d, 0x5f14301b, 0x1f74288e,
+0xe0563ccd, 0x1652d454, 0x551d860f, 0xac36fde1,
+0x8112ee81, 0x8ed705c7, 0xdfb6b97d, 0x298e88c7,
+0xb6852460, 0xedc860ad, 0x0b64a005, 0x230f68ff,
+0x25801eee, 0x89105c29, 0xbe822bea, 0x1ed59c2a,
+0x4a11a35a, 0xd0708db4, 0x8af284f6, 0xaa16ddbd,
+0x88d5192b, 0x893803e8, 0x8dba370d, 0x48a24ff7,
+0x3c53d63c, 0x09c8840b, 0x077cb1f7, 0x5434ac02,
+0xefbb201a, 0x68a3775f, 0x8a04a106, 0x13a3240c,
+0x58a34403, 0x7ab90b7a, 0x15f7696f, 0x73685b42,
+0x57ee1455, 0x02904e3c, 0x7a57ec3d, 0x4ec9842a,
+0xb55b7490, 0x4b764a84, 0xcec41734, 0x74ce7c51,
+0xfdbb1a37, 0x39179995, 0xf3aa76f3, 0x6c575d53,
+0xaab044b7, 0xde76398f, 0x3a232029, 0x1d0177e2,
+0xefdf011a, 0x144b97ef, 0x5ec7c072, 0x50825dec,
+0x5fc3843f, 0xffffe361, 0x72377603, 0x701caed1,
+0x036d47e9, 0x8ebc1b1d, 0xe941a3c5, 0x14b4a53b,
+0x87bf8847, 0x92444806, 0x7b507958, 0xb76f4090,
+0x52d115b1, 0x0515507e, 0x7da082ec, 0xf34844a0,
+0xc733e23e, 0x24dd13e2, 0xc02e7c20, 0x05f61935,
+0xbd4bbec1, 0xbba89045, 0x08dbd0fe, 0x06dd7b6e,
+0x68057095, 0x21483c49, 0x60a9f740, 0x53e95442,
+0x0644901a, 0x37ca3058, 0xd230ce14, 0xa2128876,
+0xd04b1810, 0x182a3407, 0x1b29ca2e, 0x084466d0,
+0x662907cd, 0x34efe1e2, 0x32e80557, 0x602807ec,
+0x8a5df886, 0x35628068, 0x4851b64e, 0x60a6bd1b,
+0x508d0310, 0xd358a515, 0x0375ba2d, 0x4dc753c2,
+0xaa608efe, 0x2a367134, 0xdc3d95e2, 0xad7285ad,
+0x141a4c0f, 0x3502bb07, 0x7710eef5, 0x7614050f,
+0xad546609, 0x581b6868, 0x5231c31d, 0x2974ed03,
+0xdf89c8ee, 0xfb398303, 0x35882b54, 0x01dc9103,
+0x6a170683, 0x7308acff, 0x8d138b29, 0x8d468042,
+0x6db1d64b, 0x348d0ce3, 0xc0e74386, 0x77302c0e,
+0xff6f8e6f, 0xfa830b77, 0x083e7408, 0xd772eb89,
+0x29743218, 0x4cea7783, 0x74403cb7, 0x28579e23,
+0xa3fb079d, 0x4e245dd8, 0xd1787520, 0x3433e967,
+0x6f77ac0b, 0x68080624, 0xe8511a8e, 0x2d0836f2,
+0xae3b40b4, 0x6cf83d66, 0xda16d540, 0x147704da,
+0x03e89e83, 0x5d5ddb78, 0x75d312a2, 0xeb04aa93,
+0xfd03188d, 0x75ab7d86, 0x2b068bb6, 0x66e5bc74,
+0x7c0ec3a3, 0x3589f2f8, 0xc866e90b, 0x7fd21d37,
+0x0e57654b, 0x4fe92434, 0x6e1ccdff, 0x95c03e81,
+0xc48631a6, 0x88466b32, 0x93e5ff8d, 0x4bd0ad00,
+0xfeab946f, 0x74c809d8, 0xf8c82534, 0x2d03d339,
+0x0e72fa6d, 0xd8c4870f, 0xbc2cc139, 0xc21ec183,
+0xc7253d5f, 0x053ed405, 0x8bba09d0, 0xd8a1dc06,
+0x6b442308, 0x77fb2934, 0x772d4a14, 0x343ef229,
+0x576cfa01, 0xc0a1e0b0, 0xd48ee4ad, 0x720b2d35,
+0x2efc11a9, 0x683aadc0, 0xa36f1268, 0xac610713,
+0xed0cd62a, 0x62ed312b, 0x7e70ab62, 0x69adf1df,
+0xa12e740a, 0xcc15aec8, 0xcb80bc7b, 0x83cce376,
+0xd0e6c0be, 0x61a007ff, 0x624517b0, 0x3920c683,
+0xa1e67cc5, 0x78574437, 0x9beb3e3d, 0xe6c1c677,
+0xf75ff7da, 0xcc868b05, 0x897aa32c, 0xc48e8bf8,
+0x09efdb69, 0x9435f23f, 0xc1291358, 0x1189d319,
+0x84f742d9, 0x25d0861d, 0xa534f23b, 0xe9820f78,
+0x3245ba82, 0x0c0025c8, 0x584c2fb7, 0x5e493499,
+0xdf11c601, 0x3b350116, 0x4f7e7c2d, 0xac0f3d11,
+0x2c3d8958, 0x6e5336d6, 0x4afba1ff, 0xfe3f8238,
+0x1537a2da, 0xd9985e34, 0xee9215b7, 0x290719ba,
+0xdf1031e6, 0xc22f750c, 0x0aba1a90, 0x2f5b7e09,
+0x13cc0d14, 0x40269cdd, 0xaf6da555, 0x9a4e0957,
+0xe06a6c66, 0x34a4f5e8, 0x0b0a696b, 0x6943ee43,
+0x056e4deb, 0x52e82691, 0xa21da216, 0x2a65de00,
+0xd6211680, 0x2c710e60, 0x36e77f09, 0x4b29d05a,
+0x788dd539, 0x5c1a7d34, 0x2db04270, 0x5a494576,
+0xc15a15e8, 0x817fa5c3, 0x68f08f5c, 0xaf5a99a8,
+0xb6ff5c4d, 0x30bb2cd4, 0xf1f2a984, 0x4d6f09e2,
+0x214b63bc, 0xbe03941a, 0x1beb2921, 0xa9b4381a,
+0x43735c5f, 0xc1968d47, 0x84be15d0, 0xf991f887,
+0xbbe29514, 0x1366c271, 0x77a8d339, 0x261c8290,
+0x876e087b, 0x07148290, 0xb41674de, 0xb7ddc6c5,
+0x8b22808b, 0x40423937, 0x048ff4b0, 0x890ddbf7,
+0xe9e9202d, 0x3ce9d30a, 0x73d48d7c, 0x405b923f,
+0x43d48b6e, 0xa6f210a0, 0x7037ddba, 0x86418abf,
+0x261020a1, 0x7ab75206, 0x988dee89, 0xc7502600,
+0xeb50501e, 0x8a7000a1, 0xf4c0623b, 0x592b566c,
+0xedd2215e, 0x32f3179a, 0x8336ffd8, 0xe8190a0d,
+0x035b462d, 0xe29a8cf4, 0xec41bf5e, 0xe2c3e894,
+0xa3603c53, 0x61344abc, 0xe0715a23, 0x2d50e81f,
+0x6ce67460, 0x0cec91b7, 0x90046a0d, 0xb5b80729,
+0xa0c0456a, 0x236deeeb, 0x68c5fa1e, 0x2fd77b96,
+0x014258fa, 0xd984a814, 0xd4281027, 0xe95bf683,
+0xd2077f07, 0xc740bad6, 0x03c0246c, 0x46e0ce2c,
+0x013ee893, 0xc28152c4, 0x2781f82b, 0x7612d51f,
+0x7ddc050f, 0xc5d7056a, 0x3461bb59, 0x54ece0be,
+0x34181ced, 0x3bb1d818, 0x105c24b9, 0x000c0b10,
+0x9f020809, 0x257304ae, 0x65035d51, 0x6db8a024,
+0x750a8855, 0x134a815b, 0x3d0c3014, 0x19aadbb1,
+0x3b573e15, 0xc5137691, 0x5e76eb6d, 0x2b092b2c,
+0x89e00807, 0xace046e9, 0x140c1b2a, 0xe0345531,
+0x80480be1, 0x034deaa0, 0xe3468bb8, 0x888be2c7,
+0x00964edb, 0x32988bb3, 0x025bb8b0, 0x70da4eee,
+0x2e857228, 0x6dd6b6c8, 0x9d7b639d, 0x71fdfa13,
+0xc6137209, 0xf5db8468, 0x2bff6709, 0xdf6ca910,
+0x0ce42bd2, 0xc0396878, 0x03a38168, 0xe91420f6,
+0x7d001a76, 0x7b1e27f6, 0x9c68e3b8, 0x5a215f77,
+0xc42d56e9, 0x650f0dc2, 0x8d1c6353, 0x01cabd45,
+0x67bc22b7, 0x262575e8, 0x4bc7390b, 0x7b75384f,
+0x140d4514, 0x66143e47, 0x3b837741, 0x28ee7235,
+0xf7ef0059, 0xcc3595fb, 0x8bc48603, 0x9613d296,
+0x6ed7e2c8, 0xcf778901, 0xd3891c10, 0x11df847f,
+0x249e031c, 0xc37d818d, 0xc2390676, 0x307b4273,
+0xc20f6903, 0xc7090c76, 0x2ff606ee, 0x34a1c215,
+0x0a1e24be, 0x8df4153b, 0x1ccd1dfe, 0xd8f7e889,
+0x21ff1521, 0x41fd57c2, 0x3e225ca1, 0x843bd329,
+0x69ef409a, 0x61cc5a82, 0xb43b2ad7, 0x2e2b8d04,
+0x27f1e1bf, 0x5970073b, 0x330f4974, 0x05ad7501,
+0x68f0e1e0, 0x714d11ac, 0xe1a3995e, 0x582080b3,
+0x2d2924b8, 0x430781d4, 0x018a3534, 0x0aad2360,
+0xb3e84b1f, 0x0d91e82d, 0xaf5b8169, 0x39db982c,
+0xde283bd6, 0xe00ded12, 0x77c3615d, 0xd20c0f57,
+0xa1de9605, 0x9709d510, 0x3b5aa930, 0x203f8370,
+0x0155c529, 0x2015d8c7, 0xb1101dbe, 0x3f3bc0af,
+0x208520c7, 0x0c5a6300, 0xa04653b8, 0x61476a95,
+0x06396f64, 0x21c7dfed, 0x3d8bad72, 0x73ef3907,
+0xc0de182d, 0x05de17ed, 0xeac1071a, 0xfac93109,
+0x8d8dce19, 0xdbc78a5d, 0x898a8938, 0xad6ca39b,
+0x2930fbd5, 0xc9f8052d, 0x2587286a, 0x2c0982d9,
+0xf836e87e, 0x40cdb82e, 0xa0a35e11, 0xa519ca5a,
+0x638787c7, 0x2c321ab2, 0xfe36922c, 0x1163bab3,
+0x3e815457, 0x1b031336, 0xf3d2f174, 0xaf0b6add,
+0xcc682bd0, 0xc46f0928, 0x8159619f, 0x10ba9b28,
+0xbfe03a22, 0xf418fb40, 0xb9c0a107, 0x106a372c,
+0x41116856, 0xadd68e03, 0x454a9181, 0x379c2289,
+0x25422d48, 0x360e86be, 0x5207908e, 0x7e87b570,
+0xc750a3df, 0xfbef315c, 0xf7a2208a, 0x598fbc06,
+0x44a18674, 0x250f5ae8, 0xf52f5cf0, 0xe51d2996,
+0xf73c8d96, 0xdfbb003f, 0x3d7d5b78, 0x07864274,
+0x8a5a72c4, 0x16216f47, 0x3ac003a9, 0xc7db47c2,
+0x1b7df021, 0xea5659a1, 0x3a2d03f7, 0x81553076,
+0x02ea53e2, 0xdeacfc67, 0x0182550b, 0x013a2805,
+0x7c221cba, 0xad23138b, 0x0374d8e9, 0x60500847,
+0x142b5aad, 0x06fe0704, 0xfd881ecf, 0xe80477ff,
+0x3c60ae40, 0x5c5f037d, 0x08abd3ec, 0x078ac441,
+0xdb73b2b7, 0x97c5a46c, 0x1b5597b5, 0xb98f48b4,
+0x46e9a527, 0x96e9b10e, 0xbc0ba7fe, 0x57573a60,
+0x332061d8, 0x245e9577, 0x9242715e, 0xfe32dc34,
+0x366e0035, 0x0d3dbac0, 0x464c457f, 0x026e0fbb,
+0xa1d6ebd6, 0x004c2595, 0x0be0f63d, 0xd00001b4,
+0x90a166eb, 0x2d487ebf, 0x77a981f1, 0x6794b1dc,
+0xdb7016d9, 0x08a838d3, 0xc72320d0, 0x44eeeef8,
+0x740320cc, 0x75060506, 0x30d268b5, 0xe47d18df,
+0xd7782a24, 0xf4a2180b, 0xaac4693b, 0xd0af06ac,
+0x12e8e5e9, 0x5e78de70, 0xb51d493b, 0x97abb00c,
+0x76a20a61, 0xefa6bc6d, 0x36dd6815, 0xd7b85be1,
+0x241d3753, 0x5295d47e, 0xdfc801e7, 0x85df2c72,
+0x72c38b6f, 0x1403a33d, 0x3d860151, 0x7d180ec1,
+0x05fb005d, 0x986b09c4, 0x3074c488, 0xf7354247,
+0xfdb03df1, 0x04407a83, 0x15c6f235, 0x358e4218,
+0xf5f82080, 0xedd07c0f, 0x4dcb64d9, 0xc12b2d43,
+0xd84344e2, 0x788291d6, 0x405eed40, 0x5f64d1d3,
+0x05c7d642, 0xb0cc90c8, 0x5794a303, 0x3709d86b,
+0xb8786a1e, 0x3fd025ea, 0xb22f4075, 0xf0687ecc,
+0x300c2b0f, 0xd0240c89, 0x405a8ba6, 0x350bc5bd,
+0x03f56a0d, 0x55536d6a, 0x30ee0151, 0xf8f8a86e,
+0xdb101847, 0x22337208, 0x4ef3b213, 0xdbd28459,
+0xe94b823d, 0x8852fdec, 0xbb3743c4, 0x7e8609dd,
+0x5268f87d, 0xe8243651, 0xb11b1076, 0xe5b635a6,
+0xf83d8bfe, 0xa48c307d, 0xbecb0448, 0xecfd0b01,
+0xfe261342, 0xe1c1d189, 0x1184b952, 0x98a3460e,
+0x0cc71000, 0x9c6fa54b, 0x89a68dda, 0x6ec721f7,
+0x6d037dd8, 0x1e8675d5, 0x2b63565d, 0x681b8451,
+0x72f9a1ee, 0x894c76c0, 0x1acb46c1, 0xc72b1a2d,
+0x842967de, 0x267dc21f, 0xcc8801bf, 0x0e01b5a9,
+0x01dae8f1, 0x8dce640d, 0x5dc56b15, 0x2799e86a,
+0xdfb8fc8f, 0xeea56d1d, 0x8c998d49, 0xfa40433f,
+0x4aa9fbe0, 0x8103b0cc, 0xc6e844d4, 0xfa36dfd3,
+0x395018c5, 0x3e860ff0, 0x0579c6b5, 0x71235f98,
+0x01fd6cb1, 0x5d8c0a26, 0xd87c4cd2, 0x5d770e02,
+0x0ec1f729, 0xda263163, 0x9b3235ba, 0xfa120108,
+0x742dbf21, 0x400b76c0, 0xa0105f10, 0xd93941d0,
+0xa3805a72, 0xf70fd7b7, 0x7f215bd0, 0x28605d73,
+0x79f7cb45, 0xe8bae73d, 0x1ad2f7f6, 0xd28e0274,
+0x68213320, 0x423d58ef, 0x1a062d05, 0x28d8afe6,
+0xf08eecc4, 0x5eb78265, 0x08474c83, 0xd1a4b952,
+0x1c2eff6f, 0xc96933ad, 0x29da890a, 0xd269b2ca,
+0xa1b5684e, 0x690b9cb7, 0x2934b3f6, 0xa8d15cf2,
+0x2d1857f7, 0x06a10978, 0xddfa967a, 0xab82472e,
+0x0ea37f58, 0xd419eaeb, 0x097ba057, 0xc4440596,
+0x0660bfc4, 0x0159d2a0, 0x26991a5d, 0xf4b42c48,
+0x7501e4a4, 0xa05b1727, 0xf674fa01, 0xf886eee8,
+0xd0041ad3, 0x047806e9, 0xe2b31574, 0x859dfdba,
+0xc09e1b7f, 0xcac9d368, 0xebed17ff, 0x77da90e6,
+0x2abae829, 0x12ef6b5e, 0x0c1de84f, 0x7eef4274,
+0x0773d839, 0xeb31a2e8, 0xe3c35bf0, 0xdb92dcf5,
+0xeff3edf1, 0xed0e8958, 0x744d1dc6, 0x6a7bcbf7,
+0x7453e82e, 0x43f5eb58, 0x0dc42808, 0x84118af4,
+0x1074ebd2, 0x2f16318a, 0xe26e2370, 0x38df1ddf,
+0x52b774c2, 0x138afb9d, 0x100a018a, 0xd202cd0f,
+0xb6dd8c29, 0x41c36f0b, 0x742f432e, 0x4cde2be4,
+0xe893c08c, 0x5127d2eb, 0x168b71ab, 0x242c4597,
+0x1c8bc5ba, 0x1c239b5e, 0x50b59d4e, 0x4c142a16,
+0xe80795ae, 0x07ffe25e, 0x77c6b9b5, 0x02ff8337,
+0x428d0b7f, 0xfedf8501, 0x3a80efef, 0xc127752e,
+0x094708e6, 0x7e0315ce, 0xc0f089c1, 0xed0a1ba3,
+0x0410c8c1, 0x891cdb81, 0x81a11d30, 0xe829b548,
+0xc1f65dea, 0x94aa7ba2, 0xc50a29ef, 0x4c15ad0c,
+0x05741d7c, 0x50a18e2e, 0xff77d83e, 0x77093cd0,
+0x0ac36b14, 0x5c8d41b5, 0x7613d002, 0x0df685ec,
+0x18370a05, 0x9dea0e89, 0x4b06de4b, 0xbcd28ef5,
+0x64e41258, 0x841988ec, 0xe0edcb77, 0x0775d301,
+0xe80de002, 0x6b5bd2c1, 0x047ea978, 0xdeeb60e4,
+0x24016895, 0xbf14fe54, 0xbe85c1e1, 0xb054bdc1,
+0xe864e6d1, 0xdda1b8b4, 0xe6df087e, 0x4753ae26,
+0x0afb836f, 0xb71384e1, 0x09bcd00d, 0x6cc3137e,
+0x6aad889b, 0xeb42de50, 0x31bb77ec, 0x881377e8,
+0x4ad34fe8, 0x9a681875, 0x74db0680, 0x360d36ef,
+0xdc85bb12, 0x2debae1b, 0x200ae8f5, 0xac55627f,
+0x8edfebc5, 0xa93a9329, 0x0c9f0ac3, 0xa90dc68f,
+0x815f5d0f, 0xc581bcc6, 0xf0530a4e, 0x8de8f142,
+0x28a36b78, 0x00795e94, 0x8d83fff0, 0xc2d19cdc,
+0x60bb3f02, 0x83260051, 0xf7c3dc51, 0xec6d8f53,
+0xdd2dc381, 0x56882b74, 0xc1670555, 0xcc85d7ee,
+0x9404e068, 0xebe50423, 0x0daee807, 0x1acf9484,
+0xa93ec7e8, 0x1521c833, 0xcf839315, 0x9eefdb21,
+0x97778b3d, 0x86545817, 0x220553e8, 0x8b8b6e30,
+0xc7bf6e17, 0x9303cab4, 0xc3c1831a, 0xf08ef0e1,
+0xa9b75539, 0x0573caf7, 0x828c25ba, 0x16f72753,
+0x83cadd6a, 0x0211750a, 0xf16ba990, 0x740af896,
+0x3e07ea7b, 0x6bdc2826, 0x6d2cca19, 0xff47ab1e,
+0x2083f8dd, 0xd689c50b, 0xdd9e17e9, 0x0c5237fa,
+0x8de2a818, 0xc8d470b0, 0x9eb2c22a, 0xab10a32b,
+0x73087f09, 0xbcdca13e, 0x13abda5f, 0x123fc216,
+0xac503dbf, 0x042d59c3, 0xe6abc7fa, 0x1ef5674a,
+0x3826a35e, 0x12bc38a3, 0x63d597a7, 0xbe34a33b,
+0xacfe68a8, 0x81812e28, 0x5daf4c46, 0xa2a7dbe6,
+0xd9ebf26d, 0xa7757d58, 0x3cfc5808, 0x8b9e23c2,
+0x03cb1a8f, 0x73cb399f, 0x47785ff6, 0x76ce39f0,
+0x0e739e12, 0x3877cd39, 0xa9e8de39, 0x75cf1b81,
+0xc82943f1, 0x06001089, 0x055e0dba, 0x3b155faa,
+0xde0b9dfc, 0x1f558202, 0xc0890d1f, 0x9d4a2276,
+0xa673375d, 0x101bad1a, 0x35d9c889, 0x758df5f1,
+0xeb42c083, 0xa5a145be, 0x1b7c4529, 0xfc48ed2e,
+0xc40d3b85, 0x2c5df673, 0x3102ade2, 0x8d1889d0,
+0x06754841, 0x280dd8f0, 0xb9e5ebd0, 0x28478114,
+0xf843854e, 0xb06ff129, 0x217fb1a7, 0xf8598dc1,
+0x06411d3b, 0x2d435fa2, 0xd8e696e5, 0x4106fc30,
+0xd19858c8, 0x1533352b, 0x40b69003, 0x223b7034,
+0x83405c24, 0x8d4bb106, 0x03f09ffc, 0x0e071336,
+0xc25d80c6, 0xb52fa65d, 0x03343c18, 0x8b27b72d,
+0x44b6bb42, 0x8939fc89, 0xc27824f8, 0x939acd03,
+0xd1300db1, 0x46afc1c1, 0x47335a26, 0x32a00489,
+0xd3598941, 0x0b5a991f, 0xb6ec084b, 0x882c5b2a,
+0x4d5a5905, 0xdd7dec1c, 0x0314160c, 0x8c1f0453,
+0x9a604a82, 0x08bac022, 0x0e62b545, 0xa69ce496,
+0x8039a21d, 0x594edb01, 0x3b904dc3, 0xbc14d753,
+0x7e20684d, 0x21042003, 0x02bbbae2, 0x8314da34,
+0x11791968, 0x09e3ba45, 0xff6a16ec, 0xa6cd74f3,
+0xe64035ff, 0x2a2ebe66, 0x0f281c2a, 0xc8348210,
+0x18329e6d, 0x2a1e5ea1, 0x350b7cda, 0x3dc20d21,
+0x58590116, 0x2cefd475, 0xef114563, 0xf3582d1f,
+0xefc0a675, 0x155027fd, 0x733befd9, 0x54a12737,
+0x155c3d26, 0x07d12bc3, 0xfe5a8237, 0xac2dfb36,
+0x5def754b, 0x42745807, 0x172608b8, 0x655fdba7,
+0x689d1dbe, 0x3d972b69, 0x991ca3eb, 0x7f6818ef,
+0xcb9d8610, 0xb1730f05, 0xca7c78e8, 0xe144cca9,
+0xbf7ffd5d, 0x109f6653, 0xff740806, 0xa0e12ddc,
+0xa47a463f, 0xf17629cd, 0x4b007752, 0x8174a07a,
+0xa97e147b, 0x75f886ed, 0x0d046ae3, 0x6c1c438d,
+0xa20dec08, 0x232e3681, 0x22decacd, 0x1643f1d1,
+0x0aba6b50, 0x21c31e59, 0x44135200, 0xadd76402,
+0x1deb46d3, 0x3c7d240c, 0x5d10558b, 0x582edae6,
+0x342414e8, 0xb020b646, 0x0e356b04, 0x05230837,
+0xf729324e, 0x0e9f6d88, 0x8bf6c203, 0xb019b827,
+0x5f036341, 0xfefd6446, 0x6da8e8ae, 0xc904f37a,
+0xb016f5f5, 0x6bdbfef4, 0xbc800ac6, 0x06847303,
+0xf47dd17c, 0xed7e05f6, 0x28740604, 0x681c3c11,
+0xec1d13d9, 0xfdcd9301, 0x7b96b8bc, 0x24d2341f,
+0x012566de, 0xaedefd06, 0x23c955ab, 0x04090406,
+0xdbc4d610, 0xd8010436, 0x14253b68, 0xf672cc3f,
+0x0403efc7, 0x26104068, 0x6160b6de, 0x3a8d8f89,
+0xd6d9e316, 0xc701a245, 0x24045004, 0x082c7b1e,
+0x03bbbfcd, 0x681c6a16, 0xe1a84664, 0x75649982,
+0xb4b03f7a, 0x1fdff80e, 0x00139e91, 0x50383300,
+0x3a386856, 0x8faeab05, 0x28340cbe, 0x430333c8,
+0x0362d8dc, 0x0f14fbbc, 0xb5eb9f8f, 0x60a58c79,
+0xb3d27a01, 0x1f495aec, 0xe9d073f6, 0x68ee0d31,
+0x10e95c00, 0xc28c10ff, 0xe0b58b35, 0x577f68ae,
+0x45408d70, 0x43c60388, 0xb90f5891, 0x98b712a2,
+0x42bd8895, 0x9c43a1ed, 0xda310610, 0xa045b785,
+0x10062a15, 0x22fb723f, 0x433d452e, 0x0506be04,
+0x14c2ed03, 0xf5e3301a, 0x0526a6bb, 0x585b0c37,
+0x516c4911, 0x09171573, 0x18a31136, 0x5bdc4329,
+0x88bbf578, 0x704917b7, 0xbe147e8d, 0x6c35eb83,
+0x8014b1bf, 0x024782df, 0x476d5f03, 0xca5c45cd,
+0x0b23c05c, 0x68230b77, 0xc36689ef, 0xc33e1506,
+0xd18deef8, 0x68a61c87, 0x6a565318, 0xbfc7bd3c,
+0x0450dd06, 0xb028a366, 0x236bf1d5, 0x9341b08a,
+0x3fc3e6e3, 0x14563839, 0xc40c6823, 0x28a9ea0e,
+0x4610c037, 0x88bb63c6, 0x25744214, 0x3910404f,
+0x1106a37b, 0x97c8ec29, 0x1a9c40ed, 0x13602ac0,
+0x1ef54f8e, 0x892ec1b9, 0x715796e3, 0x453418e4,
+0x1e059800, 0x85a21e00, 0x59393f11, 0xd586c989,
+0xd603915d, 0xb457adc8, 0x39ff0997, 0xe0ba193f,
+0xc1a868c3, 0x5e021bf1, 0x711e081f, 0x7132aec8,
+0xf108c7d1, 0x1c93529f, 0xd42e2239, 0x0c18f708,
+0x7eedae1c, 0x9d86e6f6, 0xd8500642, 0xc56832ff,
+0x401e6849, 0x18ddda26, 0xdf1b8ce8, 0xf7ab1fc0,
+0xca688975, 0x91b40d93, 0x03611b00, 0xb82305b9,
+0x5241ae0a, 0xb759b75f, 0xc90c1758, 0x15108a51,
+0xd82bddb6, 0xba5fe34e, 0xa8bc08b7, 0x0722d9ee,
+0x7c5b02c0, 0xfa7d6b1d, 0x74ed30f7, 0x75171c0b,
+0x19e28c0a, 0xeb5f0eb1, 0x361145c7, 0x3a1780d6,
+0xc2504a48, 0xddbea267, 0x36b83dc0, 0xb72be80b,
+0x39eb61f4, 0x24d57f23, 0x7a09a194, 0x428aea0d,
+0x3c7a7444, 0x39b1b7ec, 0x29fa3f6d, 0x50770ca3,
+0x2f64ba4b, 0xff66f834, 0xb844d005, 0x774833b3,
+0xd1b4b607, 0x4837b63d, 0x82ae14e9, 0xaf638358,
+0x09120cd8, 0x950b325d, 0xe1d63db4, 0x5840e9c2,
+0x0e4b8dde, 0x9a11417c, 0x8d12ddc3, 0xaa08f670,
+0xa584127d, 0x1c0b6c62, 0x1505de0d, 0x96d58d2d,
+0x0512ca46, 0x84efb88f, 0x08db382d, 0xa8a1644a,
+0x6c759b00, 0x1e926a2f, 0xe6369ba3, 0xf3c64218,
+0xc5ad20c2, 0x1fc9d436, 0x8b66dee9, 0xaeb6ecee,
+0x1e7cf211, 0x397d424c, 0xb18960d0, 0xc00d5f5d,
+0x028dd616, 0x5c0b85c2, 0x6f8e7725, 0x8d73892e,
+0xb76d2b47, 0x2fa3d9da, 0x427b0ec0, 0xf70805fe,
+0x0bad40b1, 0xbc9c2003, 0xe1141685, 0xb10c5b04,
+0x88b5925c, 0x190d0fad, 0x06f8114d, 0xb850445c,
+0x43586dc3, 0x01d5562c, 0xf112c6d0, 0xbb92a5b6,
+0x241ff677, 0xbd1a3428, 0x19428fed, 0xe1eeb09c,
+0x5850ad52, 0x7672782b, 0x014352ae, 0x0efe505e,
+0xbb78477e, 0x47148a35, 0x0f9c0641, 0xcb0eed8e,
+0x682dec7e, 0xae2098dc, 0x1f1942f1, 0xa4171d6f,
+0xaa18e1e8, 0x14479b21, 0xa5cc0842, 0x081b861b,
+0x8ee91c58, 0x0eea3728, 0x3b4fa91e, 0x59e8f2e1,
+0xba210975, 0x80e82e6f, 0x967e077a, 0x8901508d,
+0xe115380e, 0xf22d36ae, 0xd272d0c6, 0x85412c53,
+0xc51de560, 0xde8f0767, 0xb7a3ec12, 0xb7ef9b12,
+0x67c9c3f0, 0x6a2e538d, 0xf2688352, 0x40fba05d,
+0xcb9f57b8, 0xb8721be9, 0x7dc20474, 0x093be9a4,
+0x5f3b8011, 0xd5b6f0a0, 0x743c0415, 0x8d4d6116,
+0x93801804, 0x78d5c258, 0xeb1fa702, 0xb0c0563c,
+0xe6096ac0, 0x6f5e417a, 0xe8b3123a, 0x0c061ae1,
+0x01a3ce75, 0x2dabb40a, 0xe29b1cd6, 0xc9a0d0a3,
+0x817feda6, 0x46efa65e, 0x8d21156d, 0x11762a5f,
+0xb8add208, 0x874ad1d0, 0x0774ee3b, 0xddbdd04e,
+0x7f804d15, 0xa1f3632a, 0xb8391b24, 0x922f0b85,
+0x7b66e975, 0x2a990fab, 0xbb6c9a37, 0x756c961d,
+0x723e473e, 0x0d46e06e, 0xc0c7ab46, 0x005746f3,
+0x71cec30b, 0xd7d88b55, 0xdbb0fb85, 0x211443ef,
+0xbf64a314, 0xa958044e, 0x068e6c88, 0x781a1a21,
+0x5854cf21, 0x6b3a1053, 0xb40e28de, 0xa3b53333,
+0xc5a38218, 0x0baacc07, 0x1858fbc1, 0x7f717fa8,
+0x117e7aba, 0x00debf3d, 0xd3136e6f, 0x0706057e,
+0x2705c068, 0xfa30039a, 0xaaf73fa1, 0xe8f8210b,
+0x0000199c, 0xe2a4c3f7, 0x2f513108, 0x469e04e9,
+0xa377dc88, 0x0462885e, 0x150fd0cc, 0x6888ec7e,
+0x6c43a580, 0x47e801b2, 0x52c59ba2, 0x57f16b19,
+0x9b66e8b3, 0x19849680, 0xe921f007, 0xd7dd590a,
+0x1a87ee1f, 0x10328d01, 0xf733205a, 0xae9fc7b2,
+0x3807e89a, 0xb3c5935d, 0xb99687d7, 0xd118f160,
+0x07ebb018, 0x326ce9dc, 0x50ec81ad, 0x8d48a0e0,
+0x03dbb7d7, 0xa00420a2, 0x3b210944, 0x7df60d1b,
+0x0c4505df, 0x09461622, 0xd9471623, 0x0cf5e860,
+0x59737724, 0xe9fe0240, 0x2c771176, 0x2e2d0401,
+0xc3e0e806, 0xa3e27c3e, 0xc6934627, 0x6de8f568,
+0xe048682f, 0x1beb7783, 0x167aba2c, 0xa3a83032,
+0x4cdb9d0f, 0x41e012d1, 0xdb143e2b, 0x677dcfbe,
+0x2df45984, 0x75db5413, 0x19bc0013, 0x8d193c19,
+0xed942494, 0x6e7fddd3, 0x680d6a24, 0xe852311c,
+0xc6ed0202, 0x14fe8425, 0x8b1889b9, 0xfffff8b0,
+0x1f86c20f, 0x17dfc531, 0x65c44094, 0x6da0cf09,
+0x06ca28c6, 0x1aff7f53, 0x17c0ec45, 0x6ae0418a,
+0x8b446a43, 0x7546e29f, 0x20b633e8, 0xd41b6a55,
+0xa86abfb7, 0xc2f9e833, 0x3c8d4511, 0x5fe24703,
+0x05c6ef6f, 0x7e5a7a0c, 0xa4b6531f, 0xee6c4f41,
+0x037f4676, 0xd2e8fb26, 0xdb46c329, 0xf7ae883b,
+0x3d83e17f, 0xf5e19576, 0xc0ef303d, 0x02f4742e,
+0xf1011ce3, 0xeef6dd20, 0x05c7de89, 0x8e31c71b,
+0xe068616a, 0x37b64efb, 0x131d3072, 0x93411031,
+0x13c660ed, 0x18160809, 0x91c221c2, 0x2616f22f,
+0x50d2230d, 0x13de4dc2, 0x9da223da, 0x18745330,
+0xf744eefc, 0x086c0712, 0x09af89e4, 0x3bada608,
+0x2e9ee02c, 0x712c3c43, 0xb3e85fd0, 0x7405cb09,
+0x7e13ef34, 0xc1dde8b1, 0x6c7f1ba1, 0xd1f112e9,
+0xf7acf029, 0xc0b132f1, 0x83c8c04b, 0x6b6513fd,
+0xc171e8c5, 0xc4817683, 0x0b72cb81, 0x5e3cbb09,
+0x2e1269c4, 0x22255098, 0x40552bb4, 0x636a09a8,
+0x5feeceae, 0xc1dbe874, 0x315f73ee, 0x33741cff,
+0x20b3ffc7, 0xc08ef5bd, 0xbce2e7a6, 0x07e08383,
+0x6be6e110, 0x47472ce0, 0x759eb60f, 0x82dfebdd,
+0x3944c383, 0xa1cf7cc7, 0x03408e72, 0xa382433c,
+0x81c33b19, 0x318f4be8, 0x3815b9c2, 0x6a0c5f28,
+0x73766949, 0x3b0dbc4f, 0x685ea166, 0x1b7c0ec7,
+0xe877068c, 0x71492692, 0x6b85686d, 0x49c28068,
+0xa100ca91, 0x1ac8429a, 0x5eaa59eb, 0xc10673ab,
+0x0d685c0a, 0x27083904, 0xe82fbfa9, 0x3b62f5c6,
+0x0a817308, 0x012a4e43, 0xc846f723, 0x8c6e83fe,
+0xfffedbe9, 0x0192beff, 0xe80f0de3, 0x45d314f3,
+0x3d766068, 0xde19a1da, 0xf6b914df, 0x231c786e,
+0xadf99d20, 0x0918921c, 0x59a35978, 0xab8f8120,
+0x80e46707, 0x979265c5, 0x9f0f1000, 0xa6499068,
+0x83346810, 0x6f8a31c3, 0xe9581844, 0x1403fe02,
+0xecd48a94, 0xafab1010, 0xc2c0505c, 0x76bcf785,
+0x00d4a009, 0x09b2c58a, 0xcf561366, 0x83c7a3b8,
+0x0a3014e8, 0xdb31806a, 0x2ce87d51, 0x58c626ea,
+0x62352d1f, 0x5022d97b, 0xb712cc54, 0x19c24ed4,
+0xec94c684, 0x0e230e49, 0xc0230064, 0x066368d1,
+0xbf0d0530, 0x157000fb, 0x3a34ac41, 0x2e27a50c,
+0xf05f1984, 0xf8915f8f, 0xfb803a0f, 0x83cf0d66,
+0xe0760df9, 0x341e3741, 0x423ae0ca, 0x92e1410c,
+0x3bfc2cab, 0xf833c509, 0xb9b16edf, 0x737506fd,
+0x6e762121, 0x8a0e5a8d, 0x8ddb0e52, 0xbb9c97e8,
+0xb1770a3c, 0x290fe065, 0x9a2a5502, 0x7e52d572,
+0xeadb7467, 0x5e590a77, 0xf7669875, 0x85a03f7e,
+0xc78b6279, 0x66bcf55c, 0x808bdc3d, 0x6e25bf16,
+0x14ea83fd, 0x8b66a148, 0xff70010c, 0x0174edd9,
+0x8122784b, 0xf739d129, 0x3235830f, 0x0a5df8a9,
+0x121529cd, 0xef1bf631, 0x4c7f80c1, 0x11097b80,
+0x3de44675, 0x063d358b, 0x83ec1eed, 0x8b5922c6,
+0x86f70456, 0xdc5f9fd6, 0xeb2bc5c2, 0xfd1587d1,
+0xdb91b683, 0x74727e8d, 0xfe7d9610, 0xabca8d5a,
+0xf70270ad, 0x8bc5281c, 0xec654628, 0xd1540338,
+0xda9dbb61, 0xea4da31f, 0xd4290806, 0xf45c24d1,
+0x860f6fd9, 0xfef9e5c7, 0x2f406f18, 0xc2562677,
+0xe80e6f8d, 0xb683128d, 0x81e4a11d, 0x3401697d,
+0x2299b798, 0x0ef357d2, 0x16da7790, 0x1a69a95b,
+0x391c2602, 0xae8fc0b1, 0x776c5ded, 0xb6567216,
+0xe52fc061, 0x4ee85720, 0x41a5a012, 0xc60416dd,
+0x2bb1244b, 0xf0550f31, 0x81019b70, 0xdfeec12a,
+0x8ac1c71c, 0x68122f43, 0x00366743, 0x67f2851f,
+0x31743624, 0xdab617b1, 0xfd7f7c03, 0xbde9fc3c,
+0x6c7c7dc0, 0x890cc4a7, 0xeea09506, 0xd6352d2d,
+0x05c72ddb, 0xe5c65c16, 0xc2f40ae8, 0x292c3218,
+0x831ee80f, 0x01f82f80, 0xfdd58648, 0x9c2a9567,
+0x9228f136, 0x68560d8a, 0x37e37faf, 0xca38dfe1,
+0xc2171473, 0x6644c06b, 0xb8149839, 0x74edf02d,
+0x72134205, 0x06fa80ec, 0x1d74081e, 0x6ece9c6e,
+0x50034623, 0xc6d70522, 0xaebd1165, 0xc37b204e,
+0x134aa22d, 0x41832380, 0x8fcceb89, 0x6053359e,
+0x1c363668, 0x5c00908d, 0xb97abeae, 0xa6bc649c,
+0x8a6a3ffe, 0x3c3c0246, 0x3cb00276, 0x588b5050,
+0xf90b8810, 0x81fc10e4, 0x4349c52e, 0x6f4833b3,
+0x53448368, 0xf3490af4, 0x29715f64, 0xa2279318,
+0x20607403, 0x0a74832e, 0x03220152, 0x75fb4360,
+0x13048006, 0x1f76b882, 0xd0f81aea, 0x0dc468b2,
+0xc618c805, 0xd045ad80, 0x487cc1dd, 0x4c6b66bf,
+0x558e067a, 0xd80135a1, 0xbdc35fe8, 0xd39a06a3,
+0x85c5892c, 0x636bb5ff, 0x01ceeb2c, 0xee397e3f,
+0xdff16b76, 0x7358071e, 0x841e8a0b, 0x0f5c75db,
+0xc286f572, 0x893bdaf4, 0x3505382d, 0xaa1d2e1a,
+0xc73f0827, 0x1b5001bb, 0x979b6a8d, 0x0bfb02c0,
+0xd6c0e858, 0x18f20ce9, 0x6e047310, 0x04a225ba,
+0x22a17fd7, 0x454b8a68, 0x7b3fd093, 0xfffff0c9,
+0x6eef51c3, 0xfbdddb60, 0x1038dcff, 0x60d0158a,
+0x2875d284, 0x06c18dae, 0x0996d179, 0x0cb0f81b,
+0x020fd8c8, 0xe2031215, 0x7ed99d20, 0x0812fbbe,
+0x483e1ed0, 0x353146d9, 0x9d4a0121, 0xc45eca61,
+0x4a017e84, 0xa015640c, 0x7ddb1efb, 0xdb6d3c10,
+0x840d2200, 0x102b1dc0, 0x668db7ef, 0x6102fe9d,
+0x4974810c, 0x54a33d80, 0x386d876d, 0x1605410e,
+0x97e0fe96, 0x46b6afba, 0x023074ec, 0xff26c8e9,
+0xc35405c6, 0x0125fbc0, 0x7b16c515, 0xecdd8282,
+0x16fffe08, 0x0d14cecd, 0x8e82c7b7, 0xa3231abc,
+0xa6ebcc68, 0xbbb50bb7, 0x809a7c49, 0x947605a2,
+0xf524c3a9, 0x007560ec, 0x9a0eba39, 0xeeec2e79,
+0x0969ae6e, 0x0500ff6f, 0x8337b02c, 0x0317c980,
+0x0003902e, 0xeed17acb, 0x8d1e79dd, 0xfb2cd1fd,
+0xe73b7408, 0xc236d1fb, 0x097a1885, 0x5ef90f08,
+0xc436c202, 0x183c1f02, 0x2e15fb39, 0xb7d4e82f,
+0x6200b95a, 0x185c50c4, 0xb7eca646, 0x72581503,
+0x2916e9ed, 0x733b4204, 0xec834990, 0x8200e1fe,
+0x20dd8917, 0xd6e90804, 0xc0589343, 0xd956a116,
+0xbf70140d, 0xfebeef70, 0xe99c2e3f, 0xe1760db0,
+0xe905a1bb, 0x01edfea7, 0x389d86eb, 0x5c3d837f,
+0x0cc52a54, 0x89b8ff20, 0xc49237f5, 0x083589ef,
+0xa3fd4b5f, 0x170d83d1, 0xe2520370, 0x04c3a1e9,
+0x65ada883, 0xb955ebb7, 0x089d24fc, 0x10f0061d,
+0x94b02c98, 0x1c18d8bc, 0xd6970986, 0xdc014c36,
+0x8d9c1c9f, 0xbae9332c, 0xb410b20a, 0xae0ca0da,
+0xfc54c807, 0x00807453, 0xe3d3c320, 0x8a5456e8,
+0xbaf7bf42, 0x071c71c7, 0x295164a0, 0x8f9f6ab6,
+0x41880f12, 0x51c363f0, 0x80c8b951, 0xf785aa51,
+0x8128ce85, 0xc70de0f9, 0x6d775430, 0x02138c13,
+0x13732c12, 0xdfd98501, 0x7401393e, 0x18c18365,
+0x166c5c24, 0x7fcb725b, 0x26134020, 0x9901aa44,
+0xed6e5812, 0xd21df442, 0x75cb3908, 0x39e2b0e6,
+0xb82dc1a8, 0xdc742ce9, 0xeac1209f, 0xbe14410a,
+0xbebe2d45, 0x4f89cd75, 0x0847092a, 0x81bdcdeb,
+0x932bc19b, 0x21718b8f, 0x867df339, 0xa0d737fe,
+0x94a3731c, 0x74d02c3b, 0xf239420a, 0x0bdcdf7c,
+0x8d6ede16, 0xd06c14a4, 0x81317502, 0x7eeab776,
+0xeb4704d0, 0x8a14cbb9, 0x236e757f, 0x428b3c07,
+0x83f66a1c, 0xc0574b51, 0x800675bf, 0x0bbd1b7a,
+0x39d51e8e, 0x70f61a10, 0xb6826ade, 0x09580319,
+0x6af04923, 0x89b58e0e, 0xddf8e325, 0x4c471ece,
+0xf753aac7, 0xc6353fd7, 0x19031a42, 0xf5177e39,
+0xdd897247, 0xfe815773, 0x77f7896f, 0xd8c7f742,
+0x781d2d7d, 0x7c127301, 0xb01e797a, 0xf020dd50,
+0x5515561c, 0x6bc5c8f1, 0x9b914a72, 0x16a2dfea,
+0x24759637, 0xfeff8147, 0x7b77e800, 0xbe765492,
+0xfd81a345, 0x00a97258, 0xfd10500c, 0x4745cd09,
+0x0684b5d1, 0x78ac4c72, 0x9208955d, 0x9bc24eb0,
+0x4c770589, 0xdb4664ff, 0x232248e2, 0x50897771,
+0x11560836, 0x371be85c, 0xdffb7728, 0x7883de7e,
+0x899174bf, 0x195088fa, 0x1a04ea89, 0xce6d5566,
+0x50de06c5, 0x58069b04, 0xee93bd30, 0x306a0f18,
+0xf72856a8, 0xbbba0fdd, 0x0a890a78, 0x2e144289,
+0x361f146a, 0x2735b517, 0x0c185c34, 0x516374b7,
+0x53202e80, 0x2d00161f, 0x89209f7e, 0xfce2eac2,
+0xf75aa68e, 0x0b74152e, 0x6d10c386, 0xe06f749b,
+0x24fb014b, 0x0fabcd7e, 0x483d6a53, 0xbab75844,
+0x5019a80d, 0x5a261a04, 0xf6c39a1d, 0xc4408602,
+0x368a1075, 0x9219c10f, 0x4288fdcd, 0xd0e9e918,
+0xd62a3c2f, 0xeb3c2215, 0x82b9bbd5, 0x70fb1217,
+0x7ee97a3f, 0x18505389, 0x751c0cc6, 0x2941d7cd,
+0x30433743, 0x128d6624, 0x1295d76e, 0x2e05caa8,
+0x17665872, 0xc21f11b6, 0xb04bc126, 0x43e5d603,
+0xb2180dc8, 0xa216a71c, 0x1f01f015, 0x9a2053e4,
+0x1fc26c1a, 0x0be5974c, 0x86a83856, 0xaf043f87,
+0xcd675a14, 0x65262ae7, 0x46e74626, 0x48d54d8b,
+0x05a91f74, 0x68fc0018, 0x1c670c21, 0x5bbc4bca,
+0x866e026a, 0x06e015d6, 0x6f6009e0, 0xe344a9ff,
+0x89dcebf0, 0x0453dae0, 0xd00b4c52, 0x279a3208,
+0x60fdd7a9, 0x9c3f51cb, 0x0629f860, 0x41822573,
+0x008ff6a5, 0x58d53b6c, 0x8f685c8f, 0x0ac0b656,
+0x425706cc, 0x136614c1, 0x89f8e4f6, 0x152c2ae0,
+0xf6072608, 0x80cb1666, 0x49415c36, 0x6afc3a0d,
+0xa9efb36b, 0x21daf7c2, 0xbf11cad0, 0x0f0ebaec,
+0x069cf486, 0x211c7514, 0x6016c072, 0x1b8f4706,
+0x828c69a3, 0x10e0f8db, 0x1913084a, 0xb74418ba,
+0x0bed0537, 0x2f80c98e, 0xe0cd3121, 0xa1840ba0,
+0x7e21087f, 0x0628b109, 0xdea5db35, 0xb01c87f0,
+0x1af03034, 0xbe3f3c04, 0x4146d12f, 0x75044d17,
+0x826b839d, 0x887bbf1a, 0x49db5c17, 0x50c06c06,
+0x3c03bd32, 0xc88fd2f7, 0x391d77b5, 0x062e74f8,
+0x59c6f52a, 0x2c40b01b, 0x832dc14e, 0xf6b5d886,
+0x65a774ec, 0x1c5ea377, 0x8134e929, 0xc43d8f8f,
+0x68e91492, 0x30bba7ff, 0xd681155b, 0xff0f3657,
+0x836826e3, 0xcc611d73, 0x91e810c3, 0x51ccf815,
+0x725a1af0, 0xed4f41e6, 0xe8a319a8, 0x4a105768,
+0x7a9626f7, 0x1614fb1f, 0x78745a24, 0x50d12f09,
+0x7b760153, 0x100a0a1f, 0xefc246c7, 0xa42a688e,
+0x41fa8113, 0x7f9743c7, 0x733f816c, 0x10468b4c,
+0x2dd23539, 0x2046ff03, 0x300872ff, 0x6a716df4,
+0x06e2fb4e, 0xe754adea, 0x0c701534, 0xa5c06356,
+0x75f300da, 0xdf5cd90a, 0x5d50b6a2, 0x7eed9e81,
+0x410e3b54, 0x4c897ddb, 0xf8eb5c31, 0x50eed8b3,
+0x24466085, 0xe6c87667, 0x6fa50220, 0x29bec8df,
+0xe81843e4, 0x906f038a, 0x0616bd6a, 0xdf591feb,
+0x728ace58, 0xe3620db6, 0xf07b17b5, 0x741c056a,
+0xd5e8c6c9, 0xce586d20, 0x76e901c1, 0x042d02c0,
+0x0904465f, 0x6ce8fe06, 0x0878061b, 0x43c914e6,
+0xc80c531c, 0x7ae1c2f3, 0x9020a0de, 0x5397c2ec,
+0x388d76ff, 0x30aedc1b, 0x826912d8, 0x03f2c679,
+0xbbb2e2a4, 0x001c8819, 0xa754fd00, 0x106c75d5,
+0x54c9408f, 0x355b58d8, 0x3e6003d4, 0x8a3f5c41,
+0xf47c1682, 0x74253c06, 0xcee254cd, 0x86bbdd76,
+0x89420288, 0x75214606, 0x150717e2, 0xcd27831c,
+0x29548bc6, 0x8ba0c414, 0x2040b1a9, 0xa377edad,
+0xddc59758, 0x4c46ccb4, 0x87b4d883, 0x0ab8046d,
+0x46f67609, 0x6e8f656e, 0xd70d849f, 0x53297b1b,
+0x1c73b6ec, 0x233cbeb5, 0xcceafbe9, 0xc2b90ef6,
+0x6c228e18, 0x33db7d40, 0x07683cb0, 0xed161162,
+0x1abea607, 0x783c20c8, 0x64fae912, 0xdbcb1208,
+0x4000bccf, 0x21047e74, 0x5a634974, 0xf53a1e89,
+0x8c471788, 0x83a3319e, 0xc8175e15, 0xe2ede017,
+0xb9aadd43, 0xe7721c6f, 0xc41d13e9, 0x6f00e8b2,
+0xc4de3440, 0x89eaeb58, 0x88041e0e, 0xadbb4407,
+0x0abeebdb, 0x06e2188b, 0x88d3390d, 0x35bf7e1b,
+0xeb4f0372, 0x82682aab, 0x3de857bf, 0x47ed1b70,
+0xc7010c22, 0x371c1c3b, 0x02eb2fe1, 0x78ff2077,
+0xc438104d, 0xc3fa5748, 0x3271ca73, 0x9b770a88,
+0x31e322db, 0xc03b268d, 0xebe0721f, 0xb9ffadc1,
+0x852c38a8, 0x893778d2, 0xb9995efb, 0x4c85ee45,
+0xc2832d40, 0xada3c630, 0xa0a1a2de, 0x994f8dea,
+0xf6fd03d9, 0xad286c6e, 0x8801c311, 0xd9c14913,
+0x14e9f177, 0xdd6f556e, 0x2d07c613, 0xc1eb47de,
+0x5620e2f0, 0x4ae562d0, 0xb53dbd9e, 0x74e15b0b,
+0x301d2f0c, 0xd3475832, 0xbe8fc002, 0x880fc94c,
+0xd3d85ae4, 0xb77d481a, 0x808a0ffb, 0xd009978c,
+0x04e98319, 0xe0b9e979, 0xfa86e03e, 0xc60cb968,
+0x40820e8f, 0x462003f7, 0xc70a84e9, 0xc33b0d54,
+0x43640ddb, 0x3b806a1e, 0x0b72cdab, 0x63fd8439,
+0x1d061d18, 0xe9761784, 0x9b64fdae, 0x053d54db,
+0xe9ebedb8, 0x6311ed40, 0x12a878ff, 0xf90c6a27,
+0x02a90ce4, 0x085a1ef5, 0x72535e15, 0x135828cc,
+0x1c0dbc2f, 0x7e481d1b, 0xab3bbbf6, 0x7650be37,
+0x5d8a3a74, 0x47451711, 0x7b7103b0, 0x842f747b,
+0xd3382beb, 0x08d88823, 0xe0a17d9f, 0x4bb2d988,
+0x0dd08820, 0x63d188cb, 0x0f776fe1, 0x0838204a,
+0x4e0375ca, 0xc396c675, 0xc06a2dc1, 0x5fd2045b,
+0x7ab72329, 0xd81e8ee1, 0x8ad389c3, 0x4241025a,
+0xba201062, 0x5423f6f9, 0x231000dd, 0xd689b0a8,
+0xdbefd049, 0x0a9de51a, 0xf02443e1, 0x0f66b65b,
+0x3f5eb0b6, 0x42003a80, 0x801e421a, 0x750bed85,
+0x14a34afa, 0xf46baddc, 0x1027634d, 0x2622744b,
+0xc8fec9b1, 0x4b0d742c, 0xf3390f74, 0xc41ef75f,
+0xeb41c6a5, 0x1c3eedf6, 0x76a836f0, 0x1d1a2ac3,
+0xb78241d8, 0x5aad89df, 0x84c3c3ca, 0x809d1038,
+0xad002e38, 0x09405575, 0x57c33677, 0xf5d86fd3,
+0xffc95133, 0xaef20833, 0xc249d1f7, 0xeec16f6e,
+0x092ac801, 0x73087f48, 0xc35f1ef5, 0xf88ae017,
+0x7e634a3d, 0x7c15bbb5, 0x801174c8, 0x404a9739,
+0xae05740d, 0x321ddee0, 0xc3c829f4, 0xdf1b85e1,
+0xb1107d76, 0xf289271f, 0x38028a26, 0xdfdd8001,
+0xd3f4c860, 0x22434107, 0x7889e175, 0x904e07b1,
+0x9da632b9, 0x19a3b60c, 0x32da8913, 0x37004110,
+0xe72cf053, 0xfaeb789c, 0x621df015, 0x3e6225cd,
+0xb1db96ed, 0x01e3855f, 0x75f238c3, 0xb05c260f,
+0x9e1f152a, 0x8846d75d, 0x7c9c1ee8, 0x22f9ce59,
+0x04c0075e, 0x8521a3c8, 0x265ef006, 0x091d8bde,
+0x7e882dcf, 0xebb6e04f, 0x1e8bdbd0, 0xb018740f,
+0xbac6c767, 0x5a593d5e, 0xb3068938, 0xd1d76337,
+0x8bfc4a2f, 0x05b1195c, 0x03697734, 0x4143774a,
+0xcb6bb113, 0x5b18d605, 0xfe030125, 0x331ceb25,
+0x3b43080e, 0x377dc973, 0x4b11c157, 0x1602165d,
+0x0bf41729, 0xc5efc2a5, 0x75494346, 0x746b5fef,
+0x854d3f78, 0xb731fcd2, 0x7c2c5621, 0xd839017b,
+0x754a4197, 0x675b18f5, 0x37bb4e11, 0x894c6bca,
+0x5ace02d1, 0x576d5b6b, 0x53dfc289, 0xb0550512,
+0x3910c7f5, 0x7dce89e9, 0x9a5bf909, 0x9a880bad,
+0x75e81cfd, 0x46b7ed4e, 0x3b07738a, 0xebe87dee,
+0x811f2fdd, 0xdbebdf18, 0x20d6109c, 0x01428a4a,
+0xe31bfc78, 0xc7443a42, 0xee751608, 0x9ebfdb31,
+0xa722c608, 0x0977eab8, 0x30b704fe, 0x34fb403d,
+0x6c7f3d80, 0xb1d88fd2, 0x3d623d74, 0xc095ff80,
+0x03815fc5, 0xa3ff00f8, 0x55528d54, 0xa8cf0449,
+0x14754cdb, 0x8cc152de, 0x3100027a, 0x80cc1bad,
+0x8554d285, 0x162b9048, 0x06696135, 0xc05e0edc,
+0x4569aedc, 0x430458e8, 0x8026bc1b, 0xf5dc7b0d,
+0xe28440d4, 0x53603823, 0x42e24c75, 0x24ce551b,
+0x72760102, 0xe65bae11, 0x0f21fd3d, 0xbf4282a4,
+0x54e81797, 0xf3eb0eb7, 0xc45c8d27, 0xe8e6343b,
+0xdaadb6c0, 0x8d55b0e8, 0x50812401, 0x3ec7b5a4,
+0xffa4b617, 0x66840e75, 0x758603c7, 0x6c4a97b0,
+0x02438a2a, 0xd8538aeb, 0x09a860bd, 0x1538298f,
+0x4c740f7e, 0x2850487b, 0x82584e8e, 0x156208a0,
+0x3064bf3c, 0x9343b641, 0x841cc004, 0xc2363d8b,
+0x883f05c6, 0x827da23f, 0x00752e66, 0x95ebfdfe,
+0x750e0538, 0x57edebac, 0x530cf603, 0x0c75e91b,
+0x85c6c38f, 0xf52f61d9, 0xfeee2825, 0x896e4ad1,
+0xc84b252c, 0xc80600fe, 0xc8a225b6, 0x2596cf61,
+0xe874638a, 0x2db0e931, 0x7d707600, 0xb2574a3f,
+0x3d25bec1, 0xffffd984, 0x58f75b2c, 0x1cec8901,
+0x5adec953, 0xf3562edf, 0x255b28fd, 0x006a071c,
+0x8a49e283, 0x47b70f18, 0xf828c780, 0x5706046d,
+0x020c8d08, 0x63d92913, 0x66f0b05b, 0x5f067983,
+0x1c040643, 0xf6f74951, 0x348d02ff, 0x80de2902,
+0x8901037f, 0x74090ef5, 0x25063771, 0x63a96d82,
+0xf2da1a14, 0x0aa5d4f5, 0x5174dafa, 0x5d7435df,
+0x29c04740, 0x6c6e07e1, 0x6f151d40, 0x35b88fba,
+0x047a519b, 0x8001bbea, 0x5107c7d8, 0xb577e910,
+0x6f099070, 0x8515275a, 0xd105351a, 0xd897a110,
+0xf2196d00, 0x7c0e6ede, 0xfd0aeb0e, 0x1da9041a,
+0xaa23bac3, 0x06e88bdb, 0x003f3d98, 0x421e4103,
+0x1237db90, 0xb30b01fd, 0x37e00408, 0x4f447a06,
+0x35ff4c37, 0x418e6c9c, 0xa996c229, 0x23c00163,
+0xdd8538e7, 0xeb07065c, 0xfcbc55d1, 0x403c407e,
+0x0ca8a15f, 0x37230243, 0xac95006b, 0x0acb3e0b,
+0xdc602dda, 0x2a0843ab, 0xe0bb3689, 0x066a40ee,
+0x6dcf8379, 0xe87ecb96, 0xfffffaea, 0xa1d91c10,
+0xbeeb1c98, 0x2c3f6407, 0x30392e33, 0x8826b201,
+0x90f7e961, 0x51b0e49b, 0x00bb0f96, 0x46578c0d,
+0x49d73aa1, 0x847b0069, 0xf9fbc23d, 0xe152b9a1,
+0x31e6c3c3, 0x01c60de1, 0xc960a394, 0xbd0ce24d,
+0x366bb543, 0x0392c413, 0x84d00908, 0x0be1ae0b,
+0x2e1ed869, 0xea2c68a1, 0x03ed93d7, 0xa1056a09,
+0x54e8c103, 0x6056df68, 0x880aa033, 0xfd0a5437,
+0x5cf38874, 0x08e2c1e7, 0xdb7c418a, 0x4e0b2aeb,
+0x0d520a03, 0x38add40c, 0x7ce99d54, 0x5d22db45,
+0x0db41724, 0x10b40df2, 0x4d01502c, 0xa1beae9d,
+0xf6a15583, 0x801243ad, 0xc6119896, 0x16bfeba4,
+0x8d585faa, 0x10821a7b, 0x08f06216, 0x5690cb7c,
+0xc085534a, 0xf021c673, 0x0974e6a1, 0x28620d79,
+0x5e034cb8, 0xba0df441, 0xed830b87, 0x030e0508,
+0xbddb140f, 0x1e6b38db, 0x74483b7f, 0x96024337,
+0xd5db3bc2, 0x628fc012, 0x180faed5, 0xe999f4f5,
+0x1aaaeb4e, 0xeb5e2e95, 0x2fb9d6e7, 0x80032517,
+0x362b1b14, 0x36d9eeb8, 0x2108375e, 0x64fac6eb,
+0x758add14, 0x25eef00b, 0xce811e0c, 0xf045d68b,
+0xfa81b947, 0x7c1074ea, 0x4b415e16, 0xa482c2a0,
+0x30ed7d8b, 0x1db489b9, 0x03b4b803, 0xfb58ec71,
+0x05f5ff52, 0x62008390, 0xf82ce0c1, 0x0f0a0f5d,
+0xc2b29388, 0x20b49034, 0xb2b4934c, 0x72711036,
+0x2ace6415, 0x2aa25b1e, 0x7f0a40f3, 0x1a9e3d2c,
+0x1f4e7875, 0x56c85610, 0x369044a1, 0x158df89d,
+0x3b41ba23, 0xac01e975, 0x3ddf641e, 0xfddddc60,
+0x0cd47529, 0x05d2eb03, 0x93cceb02, 0xb7190d60,
+0x93f92ef8, 0x8025ed04, 0x6f577113, 0x60c258dd,
+0x29040d0d, 0xcd55aa10, 0xcc2e8990, 0x00e128e6,
+0x053b5a36, 0xde36d812, 0x02bf2323, 0x0a2c18a3,
+0x226c0700, 0xd4838bae, 0x11b83da8, 0xfe0d040a,
+0x55353e66, 0x75871eb8, 0xc40283da, 0x98488011,
+0x87d87425, 0x158df858, 0x3b031b5a, 0x8e268797,
+0x6e1048b5, 0x82c73e34, 0x1f82a646, 0x78546640,
+0xb622ea59, 0x9482e831, 0x98091415, 0x9110de28,
+0x810cb9b1, 0x289a9cc2, 0xb5509f49, 0x390baaf6,
+0x28749e0c, 0xf8229f9d, 0x002376a5, 0x2818e889,
+0x3ecff7f9, 0x0f0a1390, 0x96c35b10, 0x3436ba81,
+0x748f61e2, 0xaf644954, 0xd87588d7, 0xcdc4f684,
+0x18f1c821, 0x2e08f3a1, 0x0757e2f0, 0xfe532036,
+0x61d0018f, 0x6b394483, 0x0eb103f3, 0xaa225de0,
+0x6cc9828d, 0x6281d880, 0x31eadaea, 0x11e00821,
+0x91151438, 0x92e463b3, 0x70839753, 0x750fb3ec,
+0x013b2f74, 0x72393bd8, 0x20991e05, 0x3323f54a,
+0xc6c5b8c4, 0x7c3f0319, 0xf153f586, 0xa863bd44,
+0xdd199801, 0xcd466114, 0xe3c7f201, 0x69a92c11,
+0x8ff6e7b2, 0x0523c706, 0x5eb9148f, 0x3ab65302,
+0x7711092c, 0x86868b4b, 0x36f69691, 0x69896c55,
+0xc4828626, 0x2821f590, 0x8284c736, 0x183e668a,
+0x02c61d89, 0xfe5a6cd6, 0x51786806, 0x9ceb5edc,
+0x28989750, 0xbd43c180, 0x92adf664, 0xbe41086d,
+0xd698090b, 0x605848e6, 0x3b9eeb9d, 0x69718c66,
+0xa5c711e6, 0x1b110500, 0xb16deb1b, 0x89338b47,
+0x024e401b, 0xdd9c1687, 0xb3fbf5e4, 0x0d1b149c,
+0x40a30540, 0x91183ac4, 0x39e12ec3, 0x914077aa,
+0x77bf460a, 0xa31aa440, 0x741c8cd2, 0x630b520e,
+0x57061e5b, 0x3208ca47, 0x2ab404ab, 0xd8332bfd,
+0xd6602140, 0x418b15d2, 0x09404a22, 0xdb11dc3c,
+0xe2afdea5, 0x465f478b, 0xb5011202, 0xc05ceac7,
+0x8d580419, 0x7518f858, 0x2d2b5eeb, 0x0c192b47,
+0x050e4613, 0x2003060a, 0xdf305958, 0x0e75b8e8,
+0x10560312, 0x8d8f5392, 0xc3520851, 0x7321e2ae,
+0x0e5e6ff3, 0x1c24e4b2, 0x80ebfe23, 0xadf4e003,
+0x0ef64ec5, 0xd089c9ba, 0xa00a0fcb, 0x49056f1d,
+0x08684868, 0x9ecfdf37, 0x89fd1c44, 0xd2ebdc74,
+0xe02c62eb, 0x555dd3a1, 0xc8f1743f, 0x53170916,
+0x10755f8c, 0x80a031fb, 0x5e8b2f5a, 0xefdf860a,
+0x41035017, 0xb8d91574, 0x4eedfab5, 0x0c7e130e,
+0x8a1c698d, 0x05fd81e3, 0xa41fb064, 0xd17ec789,
+0x088f8bc5, 0xcd51d0b6, 0x8b3bc061, 0x9db055fa,
+0x550c86f2, 0x43a2b739, 0xe80c4940, 0x938c1910,
+0x75d0d3aa, 0xc1118076, 0x79e90770, 0x16e0fd2d,
+0x11351a19, 0xd3b802ab, 0x0283a249, 0x05062a58,
+0x3882c104, 0xadf4a88c, 0x6c4563bf, 0xb2548bd3,
+0x9e8dd9f3, 0x1f524c30, 0x07f75a9d, 0xf406c4fd,
+0x86c6cd6d, 0x01230216, 0xd685159a, 0x220306e7,
+0x0583c876, 0x10071a03, 0x44864aa1, 0xa114f231,
+0x71441854, 0xd6258830, 0xac862480, 0x52307c44,
+0x2c13f1f7, 0x8a45b233, 0xfc199452, 0xbb3e799e,
+0x15049a05, 0x017cbf2c, 0x168a5888, 0x24834084,
+0x1e8df46c, 0xecd8c7a4, 0xca317504, 0x1860f07f,
+0xd8892adc, 0xe951a4b4, 0x57b77d76, 0x260647cc,
+0x0abc1e04, 0xc70f9082, 0x8c42d1e1, 0xded042d8,
+0x2dd7807b, 0x6fec4531, 0x997c04b9, 0xd12f25ed,
+0x186f5351, 0x094ac2e3, 0x8e5164e4, 0x776da0f2,
+0x2d46bc04, 0x21a0a0e8, 0x578da92d, 0x3f9809e9,
+0x50992364, 0x54419815, 0x1f1d4270, 0xd07500bf,
+0xb0aa5ce8, 0xe9c46003, 0x11be8033, 0x03a3c3aa,
+0xc6b68dd1, 0x035d4035, 0x40687435, 0xa8f4e037,
+0xfbb13908, 0xb43775dd, 0x20e8c73f, 0x50e50fc9,
+0xee9e48e8, 0x04d9afbe, 0x1396b60f, 0x28100905,
+0x77cac7e8, 0xe6b914fa, 0x54d6297d, 0xc70b5cfa,
+0xdbd0296d, 0x4931a602, 0xcf1973cf, 0xe8b7313a,
+0x6a2cc085, 0x8a0c0c55, 0xc2382247, 0x8dc1a76f,
+0x5b601354, 0x63b71046, 0xc116fc11, 0x164619e9,
+0x76124e03, 0x47145b18, 0xcbc15f14, 0x20985ad8,
+0xc718db56, 0xbb8899be, 0x90840ffc, 0x8f0f0d93,
+0xf57d0131, 0x0808fb6c, 0x7f081d11, 0x896e4a7b,
+0x04da3eaf, 0x287c357f, 0x751d0b63, 0x256e0c15,
+0x5d0b359e, 0x076ddb0c, 0xeb2744c1, 0xb2521aec,
+0x7507e3eb, 0xdc67a017, 0x277474db, 0xad857c04,
+0x068c50b5, 0x68070470, 0x6e6b6796, 0xbff2b81b,
+0x22b78207, 0x796796fb, 0xeca74caf, 0xcd2c9f3b,
+0x0d6dcfdb, 0x0d008988, 0x0a04407f, 0x9b7c3074,
+0x209797b6, 0x0c10740b, 0xce298675, 0x1972e91b,
+0xdc5436f9, 0x670ab3e8, 0x67a01f52, 0x51575ce4,
+0xb6740f3d, 0x34b92b40, 0x0d045904, 0xd6330414,
+0x0f11fb1c, 0x74224285, 0x3b0a2ef4, 0xc8cf233c,
+0x15181023, 0xf639b70d, 0x024eea8d, 0xf7f2190a,
+0xbcfd59fe, 0xa730db9d, 0x8f080142, 0x7420008d,
+0x66cd2e7d, 0x707f04d7, 0x7c147414, 0xd8fed115,
+0x39fcd637, 0x0abdf6a7, 0x0ab25abc, 0xe6b1be79,
+0x4fa7f503, 0x2322a922, 0xedb1cd63, 0x22983825,
+0x0a84f938, 0x462ed8a9, 0x6479f89a, 0x0a6ee966,
+0xcf237d8d, 0x6468637f, 0xdf714e58, 0xec558bb6,
+0x04447f08, 0xe6325c32, 0x333cf2d8, 0x55303b70,
+0xcd66fbfb, 0x9c0a27b1, 0x72511cfa, 0x7bae0a11,
+0x153e1bec, 0x74755106, 0x3e7f043f, 0x977e6cff,
+0x1dfdfc73, 0xfde8fc72, 0x3d167476, 0x36467b4d,
+0xe11ad653, 0x910acdcb, 0xb419e467, 0x1cb799c2,
+0x0abec6fb, 0xd50aac7a, 0xec0aa1d7, 0x030105f2,
+0x11c396d4, 0x052f5137, 0xb62c35f9, 0x97cce803,
+0x6ff725a0, 0xd6ff0e16, 0xf1e8fcfa, 0x8dc85e09,
+0x9a17d56a, 0x80c1832e, 0xd82ba1b1, 0xb857ad54,
+0xc2ea43e5, 0x8149b679, 0x2fc013f4, 0x914da5e2,
+0x37ebeb83, 0xa8e6eb1a, 0x858b3e23, 0xba08e3c1,
+0x7003bb0b, 0x30350d1b, 0x08b86662, 0xbf4030b1,
+0x6962ac9b, 0x02720987, 0x0a88e430, 0xdec899e4,
+0xc35fc4a6, 0x24093d90, 0x99052b0d, 0xf93e8b49,
+0x3d85b362, 0x0a3d4339, 0xf21c8361, 0x890b96e6,
+0xd65ef97b, 0x334c8a0e, 0x3d0bb87f, 0x26c0b9a8,
+0x3b96cd27, 0x9e49908b, 0x916c0c0b, 0x839e4992,
+0xad55300d, 0x5b1444be, 0x49435024, 0xdef513d3,
+0x85c6ac44, 0x1134a3f6, 0x5f90e411, 0x95f83701,
+0x20054a1d, 0x8b128017, 0x837b92c1, 0xfa810853,
+0x7c15573a, 0x7eb76886, 0xe8672c80, 0x54003f1f,
+0xe949e04f, 0x534c90c3, 0xd56e05b8, 0xbb00fb6e,
+0xd329f108, 0x5b07ff50, 0x2cc7398a, 0x811a7725,
+0x32335f3b, 0x9823745f, 0x2362ab41, 0xc6a26149,
+0xe69a205e, 0x75253d83, 0xf51cab60, 0x09b3a479,
+0x6c013ff6, 0x4ad47492, 0x02087dc2, 0x07421a0c,
+0xffdb61d5, 0xc984f87c, 0x7b80c075, 0x33272a08,
+0xc2a36fb1, 0x313d552d, 0x5511a3c1, 0xebf7ea19,
+0xa34068a0, 0xccc0e7c3, 0xc3c258d7, 0x12925069,
+0x044f0fb0, 0xc00a4faf, 0x87608311, 0xc43db140,
+0xa9102786, 0x35ab554d, 0x217aa72c, 0xd2bae99d,
+0x218936e8, 0x032c0e89, 0x9354b5e0, 0xfc2390e8,
+0xe4702d4b, 0x96fdf761, 0xb061e601, 0x1243e6b0,
+0x5600d81c, 0xd8e142e6, 0xb6d83514, 0xc01dc308,
+0xa06d5372, 0xe95fa338, 0x5fa17dcf, 0xba1d3fe2,
+0x3b9aca00, 0xdcc0694c, 0x48521234, 0xf7b00dd5,
+0x8ae967f1, 0xe4b85f02, 0x8cbad6ef, 0xa91d0000,
+0x706c0004, 0xf00e8247, 0x40bff1ae, 0xb901d0a3,
+0x28c4bd05, 0x7fb60a41, 0x68e94fbb, 0x05c71558,
+0x1fb0071b, 0x1144090e, 0x2267a236, 0x16844847,
+0x0874c151, 0xd76c3d4a, 0x07b9470a, 0x3c099e56,
+0x0448cd05, 0xe9d90554, 0x22c11508, 0xc6475727,
+0xe9a09b76, 0xa3217468, 0xbf686664, 0x40c9926e,
+0x0609706c, 0x20e8f540, 0x68207d40, 0xd92cb690,
+0x89f6324d, 0x843d801d, 0x028c0988, 0xec5d35e1,
+0xb73d9a8c, 0x1cc81368, 0xba6ebb05, 0xe8179c04,
+0x82b02aa3, 0x344ec1df, 0xb9282eb9, 0x3bafb1a5,
+0x304cb9ec, 0x74420209, 0x35f23280, 0x31c5cc14,
+0x33af404c, 0xb9444ecc, 0x030918a8, 0xbe464931,
+0x076042bf, 0x602ecb68, 0x466bef54, 0x070958ba,
+0x132e015c, 0x485632a3, 0x3118a042, 0xd09c8368,
+0x80096c4d, 0x25e1b913, 0xe7b3d003, 0x6e680192,
+0x0f64d847, 0x31f4b645, 0x613d59f8, 0xb9222289,
+0x5aafe84f, 0x31d0f0e8, 0xd368c068, 0xf0f8bd43,
+0xe3f62bd0, 0x0975cfa3, 0x41175e99, 0x21b8f7d8,
+0x1e201be3, 0x91363e52, 0xc0e9c311, 0xd1c7096f,
+0x99547398, 0xe0977705, 0xfb1e28cf, 0xf339db53,
+0x5a060372, 0x6eff187c, 0x5aea0d43, 0xe8e22de0,
+0xf3f1be2b, 0xe69f7258, 0xabeee2bf, 0x5a144949,
+0x746285e8, 0xbb510807, 0xeb1e1742, 0x52ed33f0,
+0x51da1bc5, 0x9f037851, 0x548a37b0, 0x00755002,
+0x7445e400, 0x9026a568, 0x3500ff91, 0xec0e2338,
+0x050239ff, 0x001161dc, 0xefbeadde, 0xff025d03,
+0x9195a85f, 0x50203c21, 0x6c434558, 0x746e6569,
+0xff75bf3a, 0x637241fd, 0x00303a68, 0x444e553a,
+0x02320a49, 0x010d3731, 0xec2fbe03, 0x3c2b0cff,
+0x83828180, 0x87868584, 0x0436035f, 0x033d3208,
+0x6b05c580, 0x09b2110e, 0xdf6c812c, 0x5f627303,
+0x2b5fab64, 0xffdb4706, 0x63ca2c27, 0x544146a4,
+0x203a4c41, 0x4b756f4e, 0x7220ffff, 0x2d6c6165,
+0x65646f6d, 0x61747320, 0x215e6b63, 0xdcd90041,
+0x4e03dc6f, 0x612d2b56, 0x746f6e6e, 0xbf762023,
+0x145ccedd, 0x50252124, 0x636f1772, 0xfe736c6f,
+0x446ffb5b, 0x50434844, 0x54465420, 0x696e1604,
+0x69640063, 0x1bdb6b73, 0x6c81b7d4, 0x3170706f,
+0x0b202d20, 0xb6b6e675, 0xda6c6cc6, 0x30ca6666,
+0x6b7f0302, 0x7872fdbd, 0x40726520, 0xca252072,
+0x6c747233, 0xb7323138, 0x39b3edfa, 0x62393307,
+0x35656640, 0x6d863833, 0xb0dbb563, 0x3131166f,
+0x1809312d, 0x5d7e6c65, 0x23e17b6c, 0x74646403,
+0x2e0b6e40, 0x6ec6b436, 0x743039fb, 0x65686478,
+0xa27630e1, 0x8ff6b16b, 0x1d640235, 0x33776e66,
+0x1e333036, 0xb7b07d09, 0x303038e6, 0x656e9c63,
+0x52006f2d, 0xb6f14c54, 0x55078fb5, 0xb375736e,
+0x20397495, 0xbdd65041, 0x22032f6d, 0x22016325,
+0x62613c9f, 0xfb083e14, 0x57ddedb7, 0x69206771,
+0x0c78866e, 0x70746674, 0x886f4c00, 0x6efb7b2d,
+0x40251369, 0xe873253a, 0x122f2f3a, 0xd60217b6,
+0x3f0c0a0f, 0x3f697372, 0x8285c23a, 0x693c0be6,
+0xc2406f42, 0xbab5d6ff, 0x69980a87, 0x7a73656c,
+0x6d203e20, 0xb0d84567, 0x280f07b5, 0x21002968,
+0xa1ed6dbe, 0x3d617f2e, 0x699569d1, 0x5b67616d,
+0x2fef6dc2, 0x49424e28, 0x7b44281f, 0x0ad0002e,
+0x8c2061ff, 0x6d617267, 0x9bcb6820, 0xa142f75b,
+0x62d69855, 0x73b96769, 0xd08b6558, 0xb970b9bd,
+0x5f746983, 0x08f2701d, 0xfdb6bad7, 0x756f6620,
+0x0f1a2ec8, 0x089d3353, 0x11336f77, 0x654d0a10,
+0x2c0040a4, 0xeeb83bd8, 0x28200ab1, 0x12290626,
+0x60e11de6, 0x8c520617, 0x470b7961, 0x50ad3461,
+0x0d776d78, 0x752e450c, 0x76ebd9bd, 0xfc6c2083,
+0x0965db20, 0xb735b62d, 0x25bf6d1b, 0x97d873c9,
+0x6b76de38, 0x726135f3, 0x5735748e, 0x62176237,
+0x6e771647, 0x706d603d, 0x6b5b52ba, 0x62615b16,
+0x6c73380b, 0x90146b6d, 0x06740e74, 0x2f4b6b2d,
+0x7a4e2e18, 0x52f6a265, 0x38ae4346, 0x8cec1663,
+0x19005332, 0xf4926649, 0x284905b6, 0x000a293b,
+0xbdb18c1c, 0x63d3e5d1, 0x64f66965, 0xe87662d5,
+0x7d8c306e, 0x643a756e, 0x61a3ae64, 0xb4b1b473,
+0x2b6a4249, 0x6b76b473, 0x4455b6a5, 0x5e36510c,
+0xdc586d75, 0x06691876, 0x61cfe062, 0xb6d93c35,
+0x5b128c19, 0x70175d07, 0x6dda6963, 0xeceb8634,
+0x002e5d3a, 0x5fb7f0a0, 0x34333284, 0x39b23635,
+0x44434241, 0xe870c545, 0x4f3b66be, 0x5f2f0083,
+0xbdb0ceac, 0xe520f7f0, 0xd633534f, 0xb2f40064,
+0x9a0df6de, 0x2e342e35, 0x18435b33, 0x4d8b7c1f,
+0x24204216, 0x4c5047ef, 0x68eb0e29, 0xa474e92c,
+0x2e1c6594, 0xd1bba998, 0x724416b3, 0x3fb872f7,
+0x1da3dc3a, 0x155cea20, 0xdd3e205c, 0x175a3822,
+0x11784500, 0x53873a73, 0x9f0ec158, 0x6d276f69,
+0xeb6da178, 0x69ace423, 0x2c737172, 0x370de120,
+0x0121129c, 0x5370624d, 0x75642d73, 0x57188fcf,
+0x3f0a78b6, 0x35133543, 0xe10ab58c, 0xb920ef73,
+0x42c6c66f, 0x1249b9e3, 0x40613f6b, 0xc2d817d6,
+0x7f0a8975, 0x9b4d4f52, 0xe1afb5b6, 0x74c36765,
+0x09337884, 0xdbb63c67, 0x350bb368, 0x780a634d,
+0x7468bf0a, 0x770314a5, 0x6db78964, 0x708dda41,
+0x6e74344c, 0x8849866e, 0x36c935d0, 0x7bff1e0a,
+0xf71cec63, 0xa13d2157, 0x1819ac75, 0x67096576,
+0x051b9c0a, 0x6c1ed857, 0xe59c0321, 0xa5488165,
+0x09190549, 0xbae6d76b, 0x6f017c5a, 0x2b677b83,
+0x30361362, 0x3f203e45, 0x06a5d26c, 0x70827292,
+0x0c18cf73, 0xe4b604b2, 0xb2047e3f, 0x11441e64,
+0xd0bb6162, 0x0e45d486, 0x6e679407, 0x82946c52,
+0x2900cb14, 0xb2b65277, 0x666fac37, 0x3f823220,
+0xc618230c, 0xf8d37632, 0x04bdeb66, 0x7bb59dd6,
+0xb83fbf64, 0xde60ad1b, 0x64698fa6, 0xad83e133,
+0x4373666d, 0x52b56f3d, 0xa78586e2, 0x5f7385d6,
+0xd654788e, 0xc60a19d0, 0x6d78d08b, 0x0085ed78,
+0x6f74ecb6, 0x40ff610c, 0xfb0a15ec, 0x088a3ec2,
+0x119c0e07, 0xbf620128, 0xb6c42214, 0x295f63a6,
+0x92c08bb2, 0xea50a92b, 0xb11f8120, 0x405b0229,
+0x78f9ea6e, 0xdee72d79, 0x71e61222, 0x79a16575,
+0xc8112c4d, 0x8d004462, 0xd845b045, 0x67af871a,
+0x2861bb48, 0xad88e898, 0x9f6e7056, 0x9a3db4d8,
+0xf2a07245, 0x79200267, 0x561b0ee1, 0x4fcaa302,
+0x7dce1b0b, 0x48777334, 0xcdc48a76, 0x176a5874,
+0x66374a68, 0x41821966, 0x3dcb1600, 0x008a9fc3,
+0x830f8161, 0x4f4f42a9, 0x20402d36, 0x439a0f02,
+0x6051b5ae, 0x00b3cd91, 0x6ee3bbf6, 0x6c75e02b,
+0x623436b1, 0x524142cf, 0xee6e0335, 0x7838307d,
+0x133c043a, 0x6113736f, 0xb45e2d81, 0x648d6522,
+0x01ee6491, 0x23623a69, 0x64003f58, 0x0b0247c7,
+0x4d70433f, 0x06651855, 0xb15d9f2a, 0x21b810c0,
+0xad523a52, 0x39e0c479, 0x0fe781a0, 0xc360185c,
+0x8a106f0e, 0x19e04172, 0x709c8298, 0x60c37482,
+0x67316aa5, 0xeb58b468, 0xb346d4b0, 0x8ce24276,
+0x02c0dd16, 0x6b75b93f, 0x02d68441, 0x826b36c0,
+0x79d5e9a9, 0x6d82bd61, 0x342ec018, 0x7719b743,
+0x9b266340, 0xa6aa2e6f, 0x7529db06, 0x9c831b57,
+0x9704ccfd, 0x7e81608c, 0xe0003700, 0x47672080,
+0x9f7f07ea, 0xc89307cf, 0x9bd83656, 0x001f9317,
+0x26ceaeba, 0xde670610, 0xf770036b, 0xec6fb1f3,
+0x9b812910, 0x13813907, 0xa3813878, 0xbbbe690f,
+0x13ac8651, 0x111307ac, 0x12b31211, 0xa6f9b2d8,
+0x601500bd, 0x4033c513, 0xdf3627cf, 0x1340f77c,
+0x13d107db, 0x59e5ab06, 0xeea11712, 0x7b7014ea,
+0xf90fdb1f, 0x03ab0707, 0x0d5fbf78, 0x82ba8078,
+0xd0614108, 0xb6803766, 0x6a933c8c, 0xecaf9339,
+0x0517fd95, 0x7777b204, 0x51826313, 0x53dfeff6,
+0x0b960763, 0x003705af, 0xfa0302b1, 0xd80ab0ad,
+0xe8ed0b01, 0x00857b2d, 0x000338cc, 0x819176ca,
+0xb042135b, 0x2a40002b, 0x4507d0fb, 0x0000014f,
+0x00000000, 0xffffff20, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
+0xffffffff, 0x72ffffff, 0x31386c74, 0x7a2e3933,
+0x206d6f72, 0x2e342e35, 0x47282033, 0x20294c50,
+0x65687465, 0x6f6f6272, 0x726f2e74, 0xffff0067,
+0100000,
+};
diff -r 5b19839d0365 -r cd51fa91956b tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/firmware/hvmloader/Makefile Sun Aug 12 14:50:02 2007 -0600
@@ -51,12 +51,12 @@ acpi/acpi.a:
acpi/acpi.a:
$(MAKE) -C acpi

-roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin ../etherboot/eb-rtl8139.zrom
+roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin ../etherboot/eb-rtl8139.zrom.h
sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h
- sh ./mkhex etherboot ../etherboot/eb-rtl8139.zrom >> roms.h
+ cat ../etherboot/eb-rtl8139.zrom.h >> roms.h

.PHONY: clean
clean:
diff -r 5b19839d0365 -r cd51fa91956b tools/libxc/xc_dom_x86.c
--- a/tools/libxc/xc_dom_x86.c Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/libxc/xc_dom_x86.c Sun Aug 12 14:50:02 2007 -0600
@@ -417,6 +417,7 @@ static int start_info_x86_32(struct xc_d

xc_dom_printf("%s: called\n", __FUNCTION__);

+ memset(start_info, 0, sizeof(*start_info));
sprintf(start_info->magic, dom->guest_type);
start_info->nr_pages = dom->total_pages;
start_info->shared_info = shinfo << PAGE_SHIFT_X86;
@@ -455,6 +456,7 @@ static int start_info_x86_64(struct xc_d

xc_dom_printf("%s: called\n", __FUNCTION__);

+ memset(start_info, 0, sizeof(*start_info));
sprintf(start_info->magic, dom->guest_type);
start_info->nr_pages = dom->total_pages;
start_info->shared_info = shinfo << PAGE_SHIFT_X86;
diff -r 5b19839d0365 -r cd51fa91956b tools/pygrub/src/LiloConf.py
--- a/tools/pygrub/src/LiloConf.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/pygrub/src/LiloConf.py Sun Aug 12 14:50:02 2007 -0600
@@ -18,12 +18,13 @@ class LiloImage(object):
" initrd: %s\n" %(self.title, self.root, self.kernel,
self.args, self.initrd))
def reset(self, lines, path):
- self._root = self._initrd = self._kernel = self._args = None
+ self._initrd = self._kernel = self._readonly = None
+ self._args = ""
self.title = ""
self.lines = []
self.path = path
+ self.root = ""
map(self.set_from_line, lines)
- self.root = "" # dummy

def set_from_line(self, line, replace = None):
(com, arg) = GrubConf.grub_exact_split(line, 2)
@@ -55,6 +56,23 @@ class LiloImage(object):
return self._initrd
initrd = property(get_initrd, set_initrd)

+ def set_args(self, val):
+ self._args = val
+ def get_args(self):
+ args = self._args
+ if self.root:
+ args += " root=" + self.root
+ if self.readonly:
+ args += " ro"
+ return args
+ args = property(get_args, set_args)
+
+ def set_readonly(self, val):
+ self._readonly = 1
+ def get_readonly(self):
+ return self._readonly
+ readonly = property(get_readonly, set_readonly)
+
# set up command handlers
commands = { "label": "self.title",
"root": "self.root",
@@ -62,7 +80,7 @@ class LiloImage(object):
"image": "self.kernel",
"initrd": "self.initrd",
"append": "self.args",
- "read-only": None,
+ "read-only": "self.readonly",
"chainloader": None,
"module": None}

diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/util/acmpolicy.py
--- a/tools/python/xen/util/acmpolicy.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/util/acmpolicy.py Sun Aug 12 14:50:02 2007 -0600
@@ -46,6 +46,9 @@ ACM_POLICY_UNDEFINED = 15


ACM_SCHEMA_FILE = "/etc/xen/acm-security/policies/security_policy.xsd"
+
+ACM_LABEL_UNLABELED = "__UNLABELED__"
+ACM_LABEL_UNLABELED_DISPLAY = "unlabeled"

class ACMPolicy(XSPolicy):
"""
@@ -139,6 +142,21 @@ class ACMPolicy(XSPolicy):
return xsconstants.XSERR_SUCCESS


+ def is_default_policy(self):
+ """
+ Determine whether this is the default policy
+ """
+ default = ['SystemManagement']
+ if self.policy_get_virtualmachinelabel_names() == default and \
+ self.policy_get_bootstrap_vmlabel() == default[0] and \
+ self.policy_get_stetypes_types() == default and \
+ self.policy_get_stes_of_vmlabel(default[0]) == default and \
+ self.policy_get_resourcelabel_names() == [] and \
+ self.policy_get_chwall_types() == default and \
+ self.get_name() == "DEFAULT":
+ return True
+ return False
+
def update(self, xml_new):
"""
Update the policy with the new XML. The hypervisor decides
@@ -153,27 +171,18 @@ class ACMPolicy(XSPolicy):
return -xsconstants.XSERR_XML_PROCESSING, errors

vmlabel_map = acmpol_new.policy_get_vmlabel_translation_map()
+
# An update requires version information in the current
# and new policy. The version number of the current policy
# must be the same as what is in the FromPolicy/Version node
# in the new one and the current policy's name must be the
# same as in FromPolicy/PolicyName
-
- now_vers = acmpol_old.policy_dom_get_hdr_item("Version")
- now_name = acmpol_old.policy_dom_get_hdr_item("PolicyName")
- req_oldvers = acmpol_new.policy_dom_get_frompol_item("Version")
- req_oldname = acmpol_new.policy_dom_get_frompol_item("PolicyName")
-
- if now_vers == "" or \
- now_vers != req_oldvers or \
- now_name != req_oldname:
- log.info("Policy rejected: %s != %s or %s != %s" % \
- (now_vers,req_oldvers,now_name,req_oldname))
- return -xsconstants.XSERR_VERSION_PREVENTS_UPDATE, errors
-
- if not self.isVersionUpdate(acmpol_new):
- log.info("Policy rejected since new version is not an update.")
- return -xsconstants.XSERR_VERSION_PREVENTS_UPDATE, errors
+ # The default policy when it is set skips this step.
+ if not acmpol_new.is_default_policy() and \
+ not acmpol_old.is_default_policy():
+ irc = self.__do_update_version_check(acmpol_new)
+ if irc != xsconstants.XSERR_SUCCESS:
+ return irc, errors

if self.isloaded():
newvmnames = \
@@ -255,6 +264,29 @@ class ACMPolicy(XSPolicy):
self.compile()
return rc, errors

+
+ def __do_update_version_check(self, acmpol_new):
+ acmpol_old = self
+
+ now_vers = acmpol_old.policy_dom_get_hdr_item("Version")
+ now_name = acmpol_old.policy_dom_get_hdr_item("PolicyName")
+ req_oldvers = acmpol_new.policy_dom_get_frompol_item("Version")
+ req_oldname = acmpol_new.policy_dom_get_frompol_item("PolicyName")
+
+ if now_vers == "" or \
+ now_vers != req_oldvers or \
+ now_name != req_oldname:
+ log.info("Policy rejected: %s != %s or %s != %s" % \
+ (now_vers,req_oldvers,now_name,req_oldname))
+ return -xsconstants.XSERR_VERSION_PREVENTS_UPDATE
+
+ if not self.isVersionUpdate(acmpol_new):
+ log.info("Policy rejected since new version is not an update.")
+ return -xsconstants.XSERR_VERSION_PREVENTS_UPDATE
+
+ return xsconstants.XSERR_SUCCESS
+
+
def compareVersions(self, v1, v2):
"""
Compare two policy versions given their tuples of major and
@@ -845,8 +877,7 @@ class ACMPolicy(XSPolicy):
if self.isloaded():
return -xsconstants.XSERR_POLICY_LOADED
files = [ self.get_filename(".map",""),
- self.get_filename(".bin",""),
- self.path_from_policy_name(self.get_name())]
+ self.get_filename(".bin","") ]
for f in files:
try:
os.unlink(f)
@@ -925,11 +956,13 @@ class ACMPolicy(XSPolicy):
return -xsconstants.XSERR_POLICY_INCONSISTENT, "", ""

vms_with_chws = []
- chws_by_vm = {}
+ chws_by_vm = { ACM_LABEL_UNLABELED : [] }
for v in vms:
if v.has_key("chws"):
vms_with_chws.append(v["name"])
chws_by_vm[v["name"]] = v["chws"]
+
+
if bootstrap in vms_with_chws:
vms_with_chws.remove(bootstrap)
vms_with_chws.sort()
@@ -937,18 +970,25 @@ class ACMPolicy(XSPolicy):
else:
vms_with_chws.sort()

+ if ACM_LABEL_UNLABELED in vms_with_chws:
+ vms_with_chws.remove(ACM_LABEL_UNLABELED) ; # @1
+
vms_with_stes = []
- stes_by_vm = {}
+ stes_by_vm = { ACM_LABEL_UNLABELED : [] }
for v in vms:
if v.has_key("stes"):
vms_with_stes.append(v["name"])
stes_by_vm[v["name"]] = v["stes"]
+
if bootstrap in vms_with_stes:
vms_with_stes.remove(bootstrap)
vms_with_stes.sort()
vms_with_stes.insert(0, bootstrap)
else:
vms_with_stes.sort()
+
+ if ACM_LABEL_UNLABELED in vms_with_stes:
+ vms_with_stes.remove(ACM_LABEL_UNLABELED) ; # @2

resnames = self.policy_get_resourcelabel_names()
resnames.sort()
@@ -957,6 +997,9 @@ class ACMPolicy(XSPolicy):
for r in res:
if r.has_key("stes"):
stes_by_res[r["name"]] = r["stes"]
+
+ if ACM_LABEL_UNLABELED in resnames:
+ resnames.remove(ACM_LABEL_UNLABELED)

max_chw_ssids = 1 + len(vms_with_chws)
max_chw_types = 1 + len(vms_with_chws)
@@ -1083,6 +1126,8 @@ class ACMPolicy(XSPolicy):
pr_bin += "\x00"

# Build chinese wall part
+ vms_with_chws.insert(0, ACM_LABEL_UNLABELED)
+
cfses_names = self.policy_get_chwall_cfses_names_sorted()
cfses = self.policy_get_chwall_cfses()

@@ -1105,9 +1150,7 @@ class ACMPolicy(XSPolicy):
chw_running_types_offset,
chw_conf_agg_offset)
chw_bin_body = ""
- # simulate __NULL_LABEL__
- for c in chws:
- chw_bin_body += struct.pack("!h",0)
+
# VMs that are listed and their chinese walls
for v in vms_with_chws:
for c in chws:
@@ -1143,6 +1186,8 @@ class ACMPolicy(XSPolicy):
chw_bin += "\x00"

# Build STE part
+ vms_with_stes.insert(0, ACM_LABEL_UNLABELED) # Took out in @2
+
steformat="!iiiii"
ste_bin = struct.pack(steformat,
ACM_STE_VERSION,
@@ -1152,10 +1197,7 @@ class ACMPolicy(XSPolicy):
struct.calcsize(steformat))
ste_bin_body = ""
if stes:
- # Simulate __NULL_LABEL__
- for s in stes:
- ste_bin_body += struct.pack("!h",0)
- # VMs that are listed and their chinese walls
+ # VMs that are listed and their STE types
for v in vms_with_stes:
unknown_ste |= (set(stes_by_vm[v]) - set(stes))
for s in stes:
diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/util/security.py
--- a/tools/python/xen/util/security.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/util/security.py Sun Aug 12 14:50:02 2007 -0600
@@ -146,7 +146,7 @@ def calc_dom_ssidref_from_info(info):
raise VmError("VM label '%s' in wrong format." % seclab)
typ, policyname, vmlabel = seclab.split(":")
if typ != xsconstants.ACM_POLICY_ID:
- raise VmError("Policy type '%s' not supported." % typ)
+ raise VmError("Policy type '%s' must be changed." % typ)
refresh_security_policy()
if active_policy != policyname:
raise VmError("Active policy '%s' different than "
@@ -155,7 +155,7 @@ def calc_dom_ssidref_from_info(info):
ssidref = label2ssidref(vmlabel, policyname, "dom")
return ssidref
else:
- return 0
+ return 0x0
raise VmError("security.calc_dom_ssidref_from_info: info of type '%s'"
"not supported." % type(info))

@@ -231,6 +231,10 @@ def ssidref2label(ssidref_var):
ssidref = ssidref_var
else:
err("Instance type of ssidref not supported (must be of type 'str' or 'int')")
+
+ if ssidref == 0:
+ from xen.util.acmpolicy import ACM_LABEL_UNLABELED
+ return ACM_LABEL_UNLABELED

try:
mapfile_lock()
@@ -498,7 +502,7 @@ def hv_chg_policy(bin_pol, del_array, ch
rc, errors = acm.chgpolicy(bin_pol, del_array, chg_array)
except Exception, e:
pass
- if (len(errors) > 0):
+ if len(errors) > 0:
rc = -xsconstants.XSERR_HV_OP_FAILED
return rc, errors

@@ -781,6 +785,24 @@ def res_security_check_xapi(rlabel, rssi
return rtnval


+def validate_label(label, policyref):
+ """
+ Make sure that this label is part of the currently enforced policy
+ and that it reference the current policy.
+ """
+ rc = xsconstants.XSERR_SUCCESS
+ from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
+ curpol = XSPolicyAdminInstance().get_loaded_policy()
+ if not curpol or curpol.get_name() != policyref:
+ rc = -xsconstants.XSERR_BAD_LABEL
+ else:
+ try:
+ label2ssidref(label, curpol.get_name() , 'res')
+ except:
+ rc = -xsconstants.XSERR_BAD_LABEL
+ return rc
+
+
def set_resource_label_xapi(resource, reslabel_xapi, oldlabel_xapi):
"""Assign a resource label to a resource
@param resource: The name of a resource, i.e., "phy:/dev/hda", or
@@ -805,9 +827,15 @@ def set_resource_label_xapi(resource, re
return -xsconstants.XSERR_BAD_LABEL_FORMAT
otyp, opolicyref, olabel = tmp
# Only ACM is supported
- if otyp != xsconstants.ACM_POLICY_ID:
+ if otyp != xsconstants.ACM_POLICY_ID and \
+ otyp != xsconstants.INVALID_POLICY_PREFIX + \
+ xsconstants.ACM_POLICY_ID:
return -xsconstants.XSERR_WRONG_POLICY_TYPE
+ rc = validate_label(label, policyref)
+ if rc != xsconstants.XSERR_SUCCESS:
+ return rc
return set_resource_label(resource, typ, policyref, label, olabel)
+

def is_resource_in_use(resource):
""" Investigate all running domains whether they use this device """
@@ -867,7 +895,7 @@ def get_domain_resources(dominfo):
resources[typ].append("%s:%s:%s" %
(xsconstants.ACM_POLICY_ID,
active_policy,
- "unlabeled"))
+ ACM_LABEL_UNLABELED))

return resources

@@ -1224,7 +1252,7 @@ def change_acm_policy(bin_pol, del_array
sec_lab, new_seclab = labels
if sec_lab != new_seclab:
log.info("Updating domain %s to new label '%s'." % \
- (new_seclab, sec_lab))
+ (sec_lab, new_seclab))
# This better be working!
dominfo.set_security_label(new_seclab,
sec_lab,
diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py Sun Aug 12 14:50:02 2007 -0600
@@ -559,18 +559,8 @@ class XendDomainInfo:
self.getDeviceController(devclass).waitForDevices()

def destroyDevice(self, deviceClass, devid, force = False):
- try:
- dev = int(devid)
- except ValueError:
- # devid is not a number but a string containing either device
- # name (e.g. xvda) or device_type/device_id (e.g. vbd/51728)
- dev = type(devid) is str and devid.split('/')[-1] or None
- if dev == None:
- log.debug("Could not find the device %s", devid)
- return None
-
- log.debug("dev = %s", dev)
- return self.getDeviceController(deviceClass).destroyDevice(dev, force)
+ log.debug("dev = %s", devid)
+ return self.getDeviceController(deviceClass).destroyDevice(devid, force)

def getDeviceSxprs(self, deviceClass):
if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
@@ -1463,8 +1453,6 @@ class XendDomainInfo:
ssidref = 0
if security.on():
ssidref = security.calc_dom_ssidref_from_info(self.info)
- if ssidref == 0:
- raise VmError('VM is not properly labeled.')
if security.has_authorization(ssidref) == False:
raise VmError("VM is not authorized to run.")

diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xend/server/DevController.py Sun Aug 12 14:50:02 2007 -0600
@@ -203,27 +203,32 @@ class DevController:

The implementation here simply deletes the appropriate paths from the
store. This may be overridden by subclasses who need to perform other
- tasks on destruction. Further, the implementation here can only
- accept integer device IDs, or values that can be converted to
- integers. Subclasses may accept other values and convert them to
- integers before passing them here.
- """
-
- devid = int(devid)
+ tasks on destruction. The implementation here accepts integer device
+ IDs or paths containg integer deviceIDs, e.g. vfb/0. Subclasses may
+ accept other values and convert them to integers before passing them
+ here.
+ """
+
+ try:
+ dev = int(devid)
+ except ValueError:
+ # Does devid contain devicetype/deviceid?
+ # Propogate exception if unable to find an integer devid
+ dev = int(type(devid) is str and devid.split('/')[-1] or None)

# Modify online status /before/ updating state (latter is watched by
# drivers, so this ordering avoids a race).
- self.writeBackend(devid, 'online', "0")
- self.writeBackend(devid, 'state', str(xenbusState['Closing']))
+ self.writeBackend(dev, 'online', "0")
+ self.writeBackend(dev, 'state', str(xenbusState['Closing']))

if force:
- frontpath = self.frontendPath(devid)
+ frontpath = self.frontendPath(dev)
backpath = xstransact.Read(frontpath, "backend")
if backpath:
xstransact.Remove(backpath)
xstransact.Remove(frontpath)

- self.vm._removeVm("device/%s/%d" % (self.deviceClass, devid))
+ self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev))

def configurations(self):
return map(self.configuration, self.deviceIDs())
diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xend/server/blkif.py Sun Aug 12 14:50:02 2007 -0600
@@ -73,17 +73,7 @@ class BlkifController(DevController):
back['uuid'] = uuid

if security.on():
- (label, ssidref, policy) = \
- security.get_res_security_details(uname)
- domain_label = self.vm.get_security_label()
- if domain_label:
- rc = security.res_security_check_xapi(label, ssidref, policy,
- domain_label)
- if rc == 0:
- raise VmError("VM's access to block device '%s' denied." %
- uname)
- else:
- raise VmError("VM must have a security label.")
+ self.do_access_control(config, uname)

devid = blkif.blkdev_name_to_number(dev)
if devid is None:
@@ -95,6 +85,21 @@ class BlkifController(DevController):

return (devid, back, front)

+ def do_access_control(self, config, uname):
+ (label, ssidref, policy) = \
+ security.get_res_security_details(uname)
+ domain_label = self.vm.get_security_label()
+ if domain_label:
+ rc = security.res_security_check_xapi(label, ssidref, policy,
+ domain_label)
+ if rc == 0:
+ raise VmError("VM's access to block device '%s' denied" %
+ uname)
+ else:
+ from xen.util.acmpolicy import ACM_LABEL_UNLABELED
+ if label != ACM_LABEL_UNLABELED:
+ raise VmError("VM must have a security label to access "
+ "block device '%s'" % uname)

def reconfigureDevice(self, _, config):
"""@see DevController.reconfigureDevice"""
@@ -149,13 +154,16 @@ class BlkifController(DevController):
def destroyDevice(self, devid, force):
"""@see DevController.destroyDevice"""

- # If we are given a device name, then look up the device ID from it,
- # and destroy that ID instead. If what we are given is an integer,
- # then assume it's a device ID and pass it straight through to our
- # superclass's method.
-
+ # vbd device IDs can be either string or integer. Further, the
+ # following string values are possible:
+ # - devicetype/deviceid (vbd/51728)
+ # - devicetype/devicename (/dev/xvdb)
+ # - devicename (xvdb)
+ # Let our superclass handle integer or devicetype/deviceid forms.
+ # If we are given a device name form, then look up the device ID
+ # from it, and destroy that ID instead.
try:
- DevController.destroyDevice(self, int(devid), force)
+ DevController.destroyDevice(self, devid, force)
except ValueError:
devid_end = type(devid) is str and devid.split('/')[-1] or None

diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xm/activatepolicy.py
--- a/tools/python/xen/xm/activatepolicy.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xm/activatepolicy.py Sun Aug 12 14:50:02 2007 -0600
@@ -23,7 +23,7 @@ from xen.util import xsconstants
from xen.util import xsconstants
from xml.dom import minidom
from xen.xm.opts import OptionError
-from xen.xm import getpolicy
+from xen.xm import getpolicy, setpolicy
from xen.xm import main as xm_main
from xen.xm.main import server

@@ -38,6 +38,9 @@ def help():
--boot Have the system boot with the policy. Changes the default
title in grub.conf.
--noboot Remove the policy from the default entry in grub.conf.
+ --remove Attempt to remove the current policy by installing the
+ default policy; this works only if no domains are
+ running.
"""

def activate_policy(flags):
@@ -56,6 +59,25 @@ def remove_bootpolicy():
def remove_bootpolicy():
server.xenapi.XSPolicy.rm_xsbootpolicy()

+def install_default_policy():
+ if xm_main.serverType != xm_main.SERVER_XEN_API:
+ raise OptionError('xm needs to be configured to use the xen-api.')
+ xs_type = int(server.xenapi.XSPolicy.get_xstype())
+ if xs_type & xsconstants.XS_POLICY_ACM == 0:
+ raise OptionError('ACM policy type not supported on system.')
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ if int(policystate['type']) == 0:
+ print 'No policy is installed.'
+ return
+ if int(policystate['type']) != xsconstants.XS_POLICY_ACM:
+ print "Unknown policy type '%s'." % policystate['type']
+ flags = int(policystate['flags'])
+ if flags & xsconstants.XS_INST_LOAD == 0:
+ print "Default policy is already loaded."
+ return
+ setpolicy.setpolicy(xsconstants.ACM_POLICY_ID, 'default', flags, True,
+ False)
+
def main(argv):
if xm_main.serverType != xm_main.SERVER_XEN_API:
raise OptionError('xm needs to be configured to use the xen-api.')
@@ -69,6 +91,9 @@ def main(argv):
flags |= xsconstants.XS_INST_LOAD
elif '--noboot' == argv[c]:
remove_bootpolicy()
+ elif '--remove' == argv[c]:
+ install_default_policy()
+ return
else:
raise OptionError("Unknown command line option '%s'" % argv[c])
c += 1
diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xm/main.py Sun Aug 12 14:50:02 2007 -0600
@@ -25,7 +25,6 @@ import cmd
import cmd
import os
import pprint
-import readline
import shlex
import sys
import re
@@ -51,6 +50,7 @@ from xen.xm import console
from xen.xm import console
from xen.util.xmlrpcclient import ServerProxy
from xen.util.security import ACMError
+from xen.util.acmpolicy import ACM_LABEL_UNLABELED_DISPLAY

import XenAPI

@@ -615,6 +615,7 @@ class Shell(cmd.Cmd):

def preloop(self):
cmd.Cmd.preloop(self)
+ import readline
readline.set_completer_delims(' ')

def default(self, line):
@@ -947,7 +948,7 @@ def xm_label_list(doms):
d = parse_doms_info(dom)
if security.active_policy not in ['INACTIVE', 'NULL', 'DEFAULT']:
if not d['seclabel']:
- d['seclabel'] = 'ERROR'
+ d['seclabel'] = ACM_LABEL_UNLABELED_DISPLAY
elif security.active_policy in ['DEFAULT']:
d['seclabel'] = 'DEFAULT'
else:
diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xm/new.py
--- a/tools/python/xen/xm/new.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xm/new.py Sun Aug 12 14:50:02 2007 -0600
@@ -75,7 +75,8 @@ def main(argv):
doc = sxp2xml_inst.convert_sxp_to_xml(config)

xenapi_create_inst = xenapi_create()
- vm_refs = xenapi_create_inst.create(document = doc)
+ vm_refs = xenapi_create_inst.create(document = doc,
+ skipdtd=opts.vals.skipdtd)
else:
make_unstarted_domain(opts, config)

diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xm/resources.py
--- a/tools/python/xen/xm/resources.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xm/resources.py Sun Aug 12 14:50:02 2007 -0600
@@ -58,7 +58,6 @@ def main (argv):
try:
filename = security.res_label_filename
access_control = dictio.dict_read("resources", filename)
- print access_control
except:
raise OptionError("Resource file not found")

diff -r 5b19839d0365 -r cd51fa91956b tools/python/xen/xm/setpolicy.py
--- a/tools/python/xen/xm/setpolicy.py Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/python/xen/xm/setpolicy.py Sun Aug 12 14:50:02 2007 -0600
@@ -24,6 +24,7 @@ import sys
import sys
import string
from xen.util import xsconstants
+from xen.util.acmpolicy import ACMPolicy
from xen.xm.opts import OptionError
from xen.util.security import policy_dir_prefix
from xen.xm import main as xm_main
@@ -40,9 +41,38 @@ def help():
The following options are defined
--load Load the policy immediately
--boot Have the system load the policy during boot
+ --update Automatically adapt the policy so that it will be
+ treated as an update to the current policy
"""

-def setpolicy(policytype, policy_name, flags, overwrite):
+def create_update_xml(xml):
+ """
+ Adapt the new policy's xml header to be a simple type of an
+ update to the currently enforce policy on the remote system.
+ Increases the minor number by '1'.
+ """
+ policystate = server.xenapi.XSPolicy.get_xspolicy()
+ if int(policystate['type']) == 0:
+ return xml
+ curpol = ACMPolicy(xml = policystate['repr'])
+ curpol_version = curpol.get_version()
+ tmp = curpol_version.split('.')
+ if len(tmp) == 2:
+ maj = int(tmp[0])
+ min = int(tmp[1])
+ else:
+ maj = int(tmp)
+ min = 0
+ min += 1
+ newpol_version = ""+str(maj)+"."+str(min)
+
+ newpol = ACMPolicy(xml = xml)
+ newpol.set_frompolicy_name(curpol.get_name())
+ newpol.set_frompolicy_version(curpol.get_version())
+ newpol.set_policy_version(newpol_version)
+ return newpol.toxml()
+
+def setpolicy(policytype, policy_name, flags, overwrite, is_update=False):
if xm_main.serverType != xm_main.SERVER_XEN_API:
raise OptionError('xm needs to be configured to use the xen-api.')
if policytype != xsconstants.ACM_POLICY_ID:
@@ -60,6 +90,9 @@ def setpolicy(policytype, policy_name, f
f.close()
except:
raise OptionError("Not a valid policy file")
+
+ if is_update:
+ xml = create_update_xml(xml)

try:
policystate = server.xenapi.XSPolicy.set_xspolicy(xs_type,
@@ -96,18 +129,21 @@ def main(argv):

policytype = argv[1]
policy_name = argv[2]
+ is_update = False

flags = 0
if '--load' in argv:
flags |= xsconstants.XS_INST_LOAD
if '--boot' in argv:
flags |= xsconstants.XS_INST_BOOT
+ if '--update' in argv:
+ is_update = True

overwrite = True
if '--nooverwrite' in argv:
overwrite = False

- setpolicy(policytype, policy_name, flags, overwrite)
+ setpolicy(policytype, policy_name, flags, overwrite, is_update)

if __name__ == '__main__':
try:
diff -r 5b19839d0365 -r cd51fa91956b tools/security/Makefile
--- a/tools/security/Makefile Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/security/Makefile Sun Aug 12 14:50:02 2007 -0600
@@ -12,13 +12,6 @@ CFLAGS += $(shell xml2-config --cfla
CFLAGS += $(shell xml2-config --cflags )
CFLAGS += $(shell if [[ $(XML2VERSION) < 2.6.20 ]]; then echo ""; else echo "-DVALIDATE_SCHEMA"; fi )
LDFLAGS += $(shell xml2-config --libs ) # if this does not work, try -L/usr/lib -lxml2 -lz -lpthread -lm
-
-ifeq ($(ACM_DEFAULT_SECURITY_POLICY),ACM_NULL_POLICY)
-POLICY=null
-endif
-ifeq ($(ACM_DEFAULT_SECURITY_POLICY),ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY)
-POLICY=chwall_ste
-endif

SRCS_TOOL = secpol_tool.c
OBJS_TOOL := $(patsubst %.c,%.o,$(filter %.c,$(SRCS_TOOL)))
@@ -41,6 +34,7 @@ ACM_SECGEN_CGIDIR = $(ACM_SECGEN_HTMLDIR

ACM_SCHEMA = security_policy.xsd
ACM_EXAMPLES = client_v1 test
+ACM_DEF_POLICIES = default default-ul
ACM_POLICY_SUFFIX = security_policy.xml

ifeq ($(ACM_SECURITY),y)
@@ -61,6 +55,9 @@ install: all $(ACM_CONFIG_FILE)
$(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)/example
for i in $(ACM_EXAMPLES); do \
$(INSTALL_DATA) policies/example/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR)/example/; \
+ done
+ for i in $(ACM_DEF_POLICIES); do \
+ $(INSTALL_DATA) policies/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR); \
done
$(INSTALL_DIR) $(DESTDIR)$(ACM_SCRIPT_DIR)
$(INSTALL_PROG) $(ACM_SCRIPTS) $(DESTDIR)$(ACM_SCRIPT_DIR)
diff -r 5b19839d0365 -r cd51fa91956b tools/security/policies/default-security_policy.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/security/policies/default-security_policy.xml Sun Aug 12 14:50:02 2007 -0600
@@ -0,0 +1,30 @@
+<?xml version="1.0" ?>
+<SecurityPolicyDefinition xmlns="http://www.ibm.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com ../../security_policy.xsd">
+ <PolicyHeader>
+ <PolicyName>DEFAULT</PolicyName>
+ <Version>1.0</Version>
+ </PolicyHeader>
+ <SimpleTypeEnforcement>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ </SimpleTypeEnforcementTypes>
+ </SimpleTypeEnforcement>
+ <ChineseWall>
+ <ChineseWallTypes>
+ <Type>SystemManagement</Type>
+ </ChineseWallTypes>
+ </ChineseWall>
+ <SecurityLabelTemplate>
+ <SubjectLabels bootstrap="SystemManagement">
+ <VirtualMachineLabel>
+ <Name>SystemManagement</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ </SimpleTypeEnforcementTypes>
+ <ChineseWallTypes>
+ <Type/>
+ </ChineseWallTypes>
+ </VirtualMachineLabel>
+ </SubjectLabels>
+ </SecurityLabelTemplate>
+</SecurityPolicyDefinition>
diff -r 5b19839d0365 -r cd51fa91956b tools/security/policies/default-ul-security_policy.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/security/policies/default-ul-security_policy.xml Sun Aug 12 14:50:02 2007 -0600
@@ -0,0 +1,41 @@
+<?xml version="1.0" ?>
+<SecurityPolicyDefinition xmlns="http://www.ibm.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com ../../security_policy.xsd">
+ <PolicyHeader>
+ <PolicyName>DEFAULT-UL</PolicyName>
+ <Version>1.0</Version>
+ </PolicyHeader>
+ <SimpleTypeEnforcement>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ <Type>__UNLABELED__</Type>
+ </SimpleTypeEnforcementTypes>
+ </SimpleTypeEnforcement>
+ <ChineseWall>
+ <ChineseWallTypes>
+ <Type>SystemManagement</Type>
+ </ChineseWallTypes>
+ </ChineseWall>
+ <SecurityLabelTemplate>
+ <SubjectLabels bootstrap="SystemManagement">
+ <VirtualMachineLabel>
+ <Name>SystemManagement</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>SystemManagement</Type>
+ <Type>__UNLABELED__</Type>
+ </SimpleTypeEnforcementTypes>
+ <ChineseWallTypes>
+ <Type/>
+ </ChineseWallTypes>
+ </VirtualMachineLabel>
+ <VirtualMachineLabel>
+ <Name>__UNLABELED__</Name>
+ <SimpleTypeEnforcementTypes>
+ <Type>__UNLABELED__</Type>
+ </SimpleTypeEnforcementTypes>
+ <ChineseWallTypes>
+ <Type/>
+ </ChineseWallTypes>
+ </VirtualMachineLabel>
+ </SubjectLabels>
+ </SecurityLabelTemplate>
+</SecurityPolicyDefinition>
diff -r 5b19839d0365 -r cd51fa91956b tools/security/xensec_ezpolicy
--- a/tools/security/xensec_ezpolicy Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/security/xensec_ezpolicy Sun Aug 12 14:50:02 2007 -0600
@@ -35,6 +35,8 @@ conflict_bmp = None
conflict_bmp = None
realm_icon = None
workload_icon = None
+
+ACM_LABEL_UNLABELED = '__UNLABELED__'

class orgTreeCtrl(wx.TreeCtrl):

@@ -870,7 +872,8 @@ class ezFrame(wx.Frame):
self.realm_menu.Enable(self.ID_ORGDEL, True)
self.realm_menu.Enable(self.ID_ORGEDT, True)
self.realm_menu.Enable(self.ID_ORGADD, True)
- if len(self.orgs.GetSelections()) > 1:
+ if len(self.orgs.GetSelections()) > 1 or \
+ ACM_LABEL_UNLABELED == self.orgs.GetItemText(item):
self.realm_menu.Enable(self.ID_ORGEDT, False)
self.realm_menu.Enable(self.ID_ORGADD, False)
self.PopupMenu(self.realm_menu)
@@ -1622,6 +1625,8 @@ def main():
app = ezApp(0)
if len(sys.argv) in [2]:
app.Load(sys.argv[1])
+ else:
+ dict2org({'orgs' : [[ACM_LABEL_UNLABELED,[]]], 'cons': []})
app.MainLoop()
print "Goodbye"

diff -r 5b19839d0365 -r cd51fa91956b tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/xenstat/libxenstat/src/xenstat.c Sun Aug 12 14:50:02 2007 -0600
@@ -677,7 +677,7 @@ static void xenstat_prune_domain(xenstat
/* shift entries following specified entry up by one */
if (entry < node->num_domains) {
xenstat_domain *domain = &node->domains[entry];
- memmove(domain,domain+1,node->num_domains-entry);
+ memmove(domain,domain+1,(node->num_domains - entry) * sizeof(xenstat_domain) );
}

/* zero out original last entry from node -- not
diff -r 5b19839d0365 -r cd51fa91956b tools/xenstore/utils.c
--- a/tools/xenstore/utils.c Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/xenstore/utils.c Sun Aug 12 14:50:02 2007 -0600
@@ -10,18 +10,17 @@
#include <signal.h>
#include "utils.h"

-void xprintf(const char *fmt, ...)
+static void default_xprintf(const char *fmt, ...)
{
va_list args;
-
- if (!stderr)
- return; /* could trace()? */

va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fflush(stderr);
}
+
+void (*xprintf)(const char *fmt, ...) = default_xprintf;

void barf(const char *fmt, ...)
{
diff -r 5b19839d0365 -r cd51fa91956b tools/xenstore/utils.h
--- a/tools/xenstore/utils.h Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/xenstore/utils.h Sun Aug 12 14:50:02 2007 -0600
@@ -24,7 +24,7 @@ void barf(const char *fmt, ...) __attrib
void barf(const char *fmt, ...) __attribute__((noreturn));
void barf_perror(const char *fmt, ...) __attribute__((noreturn));

-void xprintf(const char *fmt, ...);
+void (*xprintf)(const char *fmt, ...);

#define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)

diff -r 5b19839d0365 -r cd51fa91956b tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Sun Aug 12 12:19:13 2007 -0600
+++ b/tools/xenstore/xenstored_core.c Sun Aug 12 14:50:02 2007 -0600
@@ -1880,14 +1880,14 @@ int main(int argc, char *argv[])

/* close stdin/stdout now we're ready to accept connections */
if (dofork) {
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
- /* Get ourselves a nice xenstored crash if these are used. */
- stdin = NULL;
- stdout = NULL;
- stderr = NULL;
+ int devnull = open("/dev/null", O_RDWR);
+ if (devnull == -1)
+ barf_perror("Could not open /dev/null\n");
+ close(STDIN_FILENO); dup2(STDIN_FILENO, devnull);
+ close(STDOUT_FILENO); dup2(STDOUT_FILENO, devnull);
+ close(STDERR_FILENO); dup2(STDERR_FILENO, devnull);
+ close(devnull);
+ xprintf = trace;
}

signal(SIGHUP, trigger_reopen_log);
diff -r 5b19839d0365 -r cd51fa91956b unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c
--- a/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c Sun Aug 12 12:19:13 2007 -0600
+++ b/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c Sun Aug 12 14:50:02 2007 -0600
@@ -10,6 +10,12 @@ struct ap_suspend_info {
int do_spin;
atomic_t nr_spinning;
};
+
+/*
+ * Use a rwlock to protect the hypercall page from being executed in AP context
+ * while the BSP is re-initializing it after restore.
+ */
+static DEFINE_RWLOCK(suspend_lock);

/*
* Spinning prevents, for example, APs touching grant table entries while
@@ -27,7 +33,9 @@ static void ap_suspend(void *_info)

while (info->do_spin) {
cpu_relax();
+ read_lock(&suspend_lock);
HYPERVISOR_yield();
+ read_unlock(&suspend_lock);
}

mb();
@@ -43,7 +51,9 @@ static int bp_suspend(void)
suspend_cancelled = HYPERVISOR_shutdown(SHUTDOWN_suspend);

if (!suspend_cancelled) {
+ write_lock(&suspend_lock);
platform_pci_resume();
+ write_unlock(&suspend_lock);
gnttab_resume();
irq_resume();
}
diff -r 5b19839d0365 -r cd51fa91956b xen/acm/acm_chinesewall_hooks.c
--- a/xen/acm/acm_chinesewall_hooks.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/acm/acm_chinesewall_hooks.c Sun Aug 12 14:50:02 2007 -0600
@@ -93,6 +93,7 @@ int acm_init_chwall_policy(void)
return ACM_OK;
}

+
static int chwall_init_domain_ssid(void **chwall_ssid, ssidref_t ssidref)
{
struct chwall_ssid *chwall_ssidp = xmalloc(struct chwall_ssid);
@@ -104,10 +105,10 @@ static int chwall_init_domain_ssid(void
chwall_ssidp->chwall_ssidref =
GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);

- if ( (chwall_ssidp->chwall_ssidref >= chwall_bin_pol.max_ssidrefs)
- || (chwall_ssidp->chwall_ssidref == ACM_DEFAULT_LOCAL_SSID) )
- {
- printkd("%s: ERROR chwall_ssidref(%x) undefined (>max) or unset (0).\n",
+ if ( chwall_ssidp->chwall_ssidref >= chwall_bin_pol.max_ssidrefs )
+ {
+ printkd("%s: ERROR chwall_ssidref(%x) undefined (>max) or unset "
+ "(0).\n",
__func__, chwall_ssidp->chwall_ssidref);
xfree(chwall_ssidp);
return ACM_INIT_SSID_ERROR;
@@ -117,6 +118,7 @@ static int chwall_init_domain_ssid(void
__func__, chwall_ssidp->chwall_ssidref);
return ACM_OK;
}
+

static void chwall_free_domain_ssid(void *chwall_ssid)
{
@@ -205,7 +207,9 @@ chwall_init_state(struct acm_chwall_poli

read_lock(&ssid_list_rwlock);

- /* go through all domains and adjust policy as if this domain was started now */
+ /* go through all domains and adjust policy as if this domain was
+ * started now
+ */
for_each_acmssid( rawssid )
{
chwall_ssid =
@@ -220,8 +224,8 @@ chwall_init_state(struct acm_chwall_poli

/* b) check for conflict */
for ( i = 0; i < chwall_buf->chwall_max_types; i++ )
- if (conflict_aggregate_set[i] &&
- ssidrefs[chwall_ssidref * chwall_buf->chwall_max_types + i])
+ if ( conflict_aggregate_set[i] &&
+ ssidrefs[chwall_ssidref * chwall_buf->chwall_max_types + i] )
{
printk("%s: CHINESE WALL CONFLICT in type %02x.\n",
__func__, i);
@@ -231,37 +235,46 @@ chwall_init_state(struct acm_chwall_poli

goto out;
}
+
/* set violation and break out of the loop */
- /* c) adapt conflict aggregate set for this domain (notice conflicts) */
+ /* c) adapt conflict aggregate set for this domain
+ * (notice conflicts)
+ */
for ( i = 0; i < chwall_buf->chwall_max_conflictsets; i++ )
{
int common = 0;
/* check if conflict_set_i and ssidref have common types */
for ( j = 0; j < chwall_buf->chwall_max_types; j++ )
- if (conflict_sets[i * chwall_buf->chwall_max_types + j] &&
- ssidrefs[chwall_ssidref *
- chwall_buf->chwall_max_types + j])
+ if ( conflict_sets[i * chwall_buf->chwall_max_types + j] &&
+ ssidrefs[chwall_ssidref *
+ chwall_buf->chwall_max_types + j] )
{
common = 1;
break;
}
- if (common == 0)
+
+ if ( common == 0 )
continue; /* try next conflict set */
- /* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+
+ /* now add types of the conflict set to conflict_aggregate_set
+ * (except types in chwall_ssidref)
+ */
for ( j = 0; j < chwall_buf->chwall_max_types; j++ )
- if (conflict_sets[i * chwall_buf->chwall_max_types + j] &&
- !ssidrefs[chwall_ssidref *
- chwall_buf->chwall_max_types + j])
+ if ( conflict_sets[i * chwall_buf->chwall_max_types + j] &&
+ !ssidrefs[chwall_ssidref *
+ chwall_buf->chwall_max_types + j] )
conflict_aggregate_set[j]++;
}
}
out:
read_unlock(&ssid_list_rwlock);
return violation;
- /* returning "violation != 0" means that the currently running set of domains would
- * not be possible if the new policy had been enforced before starting them; for chinese
- * wall, this means that the new policy includes at least one conflict set of which
- * more than one type is currently running */
+ /* returning "violation != 0" means that the currently running set of
+ * domains would not be possible if the new policy had been enforced
+ * before starting them; for chinese wall, this means that the new
+ * policy includes at least one conflict set of which more than one
+ * type is currently running
+ */
}


@@ -348,8 +361,10 @@ static int _chwall_update_policy(u8 *buf
memset(conflict_aggregate_set, 0,
sizeof(domaintype_t) * chwall_buf->chwall_max_types);

- /* 3. now re-calculate the state for the new policy based on running domains;
- * this can fail if new policy is conflicting with running domains */
+ /* 3. now re-calculate the state for the new policy based on
+ * running domains; this can fail if new policy is conflicting
+ * with running domains
+ */
if ( chwall_init_state(chwall_buf, ssids,
conflict_sets, running_types,
conflict_aggregate_set,
@@ -483,81 +498,27 @@ static int _chwall_pre_domain_create(voi

chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);

- if (chwall_ssidref == ACM_DEFAULT_LOCAL_SSID)
- {
- printk("%s: ERROR CHWALL SSID is NOT SET but policy enforced.\n",
- __func__);
- return ACM_ACCESS_DENIED; /* catching and indicating config error */
- }
-
- if (chwall_ssidref >= chwall_bin_pol.max_ssidrefs)
+ if ( chwall_ssidref >= chwall_bin_pol.max_ssidrefs )
{
printk("%s: ERROR chwall_ssidref > max(%x).\n",
__func__, chwall_bin_pol.max_ssidrefs - 1);
return ACM_ACCESS_DENIED;
}
+
/* A: chinese wall check for conflicts */
- for (i = 0; i < chwall_bin_pol.max_types; i++)
- if (chwall_bin_pol.conflict_aggregate_set[i] &&
- chwall_bin_pol.ssidrefs[chwall_ssidref *
- chwall_bin_pol.max_types + i])
+ for ( i = 0; i < chwall_bin_pol.max_types; i++ )
+ if ( chwall_bin_pol.conflict_aggregate_set[i] &&
+ chwall_bin_pol.ssidrefs[chwall_ssidref *
+ chwall_bin_pol.max_types + i] )
{
printk("%s: CHINESE WALL CONFLICT in type %02x.\n", __func__, i);
return ACM_ACCESS_DENIED;
}

/* B: chinese wall conflict set adjustment (so that other
- * other domains simultaneously created are evaluated against this new set)*/
- for ( i = 0; i < chwall_bin_pol.max_conflictsets; i++ )
- {
- int common = 0;
- /* check if conflict_set_i and ssidref have common types */
- for ( j = 0; j < chwall_bin_pol.max_types; j++ )
- if ( chwall_bin_pol.
- conflict_sets[i * chwall_bin_pol.max_types + j]
- && chwall_bin_pol.ssidrefs[chwall_ssidref *
- chwall_bin_pol.max_types + j] )
- {
- common = 1;
- break;
- }
- if (common == 0)
- continue; /* try next conflict set */
- /* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
- for ( j = 0; j < chwall_bin_pol.max_types; j++ )
- if ( chwall_bin_pol.
- conflict_sets[i * chwall_bin_pol.max_types + j]
- && !chwall_bin_pol.ssidrefs[chwall_ssidref *
- chwall_bin_pol.max_types + j])
- chwall_bin_pol.conflict_aggregate_set[j]++;
- }
- return ACM_ACCESS_PERMITTED;
-}
-
-
-static void _chwall_post_domain_create(domid_t domid, ssidref_t ssidref)
-{
- int i, j;
- ssidref_t chwall_ssidref;
-
- chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);
- /* adjust types ref-count for running domains */
- for ( i = 0; i < chwall_bin_pol.max_types; i++ )
- chwall_bin_pol.running_types[i] +=
- chwall_bin_pol.ssidrefs[chwall_ssidref *
- chwall_bin_pol.max_types + i];
- if ( domid )
- return;
-
- /* Xen does not call pre-create hook for DOM0;
- * to consider type conflicts of any domain with DOM0, we need
- * to adjust the conflict_aggregate for DOM0 here the same way it
- * is done for non-DOM0 domains in the pre-hook */
- printkd("%s: adjusting security state for DOM0 (ssidref=%x, chwall_ssidref=%x).\n",
- __func__, ssidref, chwall_ssidref);
-
- /* chinese wall conflict set adjustment (so that other
- * other domains simultaneously created are evaluated against this new set)*/
+ * other domains simultaneously created are evaluated against
+ * this new set)
+ */
for ( i = 0; i < chwall_bin_pol.max_conflictsets; i++ )
{
int common = 0;
@@ -578,6 +539,62 @@ static void _chwall_post_domain_create(d
if ( chwall_bin_pol.
conflict_sets[i * chwall_bin_pol.max_types + j]
&& !chwall_bin_pol.ssidrefs[chwall_ssidref *
+ chwall_bin_pol.max_types + j])
+ chwall_bin_pol.conflict_aggregate_set[j]++;
+ }
+ return ACM_ACCESS_PERMITTED;
+}
+
+
+static void _chwall_post_domain_create(domid_t domid, ssidref_t ssidref)
+{
+ int i, j;
+ ssidref_t chwall_ssidref;
+
+ chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);
+ /* adjust types ref-count for running domains */
+ for ( i = 0; i < chwall_bin_pol.max_types; i++ )
+ chwall_bin_pol.running_types[i] +=
+ chwall_bin_pol.ssidrefs[chwall_ssidref *
+ chwall_bin_pol.max_types + i];
+ if ( domid )
+ return;
+
+ /* Xen does not call pre-create hook for DOM0;
+ * to consider type conflicts of any domain with DOM0, we need
+ * to adjust the conflict_aggregate for DOM0 here the same way it
+ * is done for non-DOM0 domains in the pre-hook */
+ printkd("%s: adjusting security state for DOM0 (ssidref=%x, chwall_ssidref=%x).\n",
+ __func__, ssidref, chwall_ssidref);
+
+ /* chinese wall conflict set adjustment (so that other
+ * other domains simultaneously created are evaluated against this new set)*/
+ for ( i = 0; i < chwall_bin_pol.max_conflictsets; i++ )
+ {
+ int common = 0;
+ /* check if conflict_set_i and ssidref have common types */
+ for ( j = 0; j < chwall_bin_pol.max_types; j++ )
+ if ( chwall_bin_pol.
+ conflict_sets[i * chwall_bin_pol.max_types + j]
+ && chwall_bin_pol.ssidrefs[chwall_ssidref *
+ chwall_bin_pol.max_types + j] )
+ {
+ common = 1;
+ break;
+ }
+
+ if ( common == 0 )
+ {
+ /* try next conflict set */
+ continue;
+ }
+
+ /* now add types of the conflict set to conflict_aggregate_set
+ (except types in chwall_ssidref) */
+ for ( j = 0; j < chwall_bin_pol.max_types; j++ )
+ if ( chwall_bin_pol.
+ conflict_sets[i * chwall_bin_pol.max_types + j]
+ && !chwall_bin_pol.ssidrefs[chwall_ssidref *
chwall_bin_pol.max_types + j] )
chwall_bin_pol.conflict_aggregate_set[j]++;
}
@@ -638,9 +655,15 @@ static void chwall_domain_destroy(void *
common = 1;
break;
}
- if (common == 0)
- continue; /* try next conflict set, this one does not include any type of chwall_ssidref */
- /* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+ if ( common == 0 )
+ {
+ /* try next conflict set, this one does not include
+ any type of chwall_ssidref */
+ continue;
+ }
+
+ /* now add types of the conflict set to conflict_aggregate_set
+ (except types in chwall_ssidref) */
for ( j = 0; j < chwall_bin_pol.max_types; j++ )
if ( chwall_bin_pol.
conflict_sets[i * chwall_bin_pol.max_types + j]
diff -r 5b19839d0365 -r cd51fa91956b xen/acm/acm_policy.c
--- a/xen/acm/acm_policy.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/acm/acm_policy.c Sun Aug 12 14:50:02 2007 -0600
@@ -710,10 +710,10 @@ acm_change_policy(struct acm_change_poli
goto acm_chg_policy_exit;
}

- if ( copy_from_guest(dels.array,
+ if ( copy_from_guest((u8 *)dels.array,
chgpolicy->del_array,
chgpolicy->delarray_size) ||
- copy_from_guest(ssidmap.array,
+ copy_from_guest((u8 *)ssidmap.array,
chgpolicy->chg_array,
chgpolicy->chgarray_size) ||
copy_from_guest(binpolicy,
@@ -844,7 +844,7 @@ acm_relabel_domains(struct acm_relabel_d
memset(errors.array, 0x0, sizeof(uint32_t) * errors.num_items);
}

- if ( copy_from_guest(relabels.array,
+ if ( copy_from_guest((u8 *)relabels.array,
relabel->relabel_map,
relabel->relabel_map_size) )
{
diff -r 5b19839d0365 -r cd51fa91956b xen/acm/acm_simple_type_enforcement_hooks.c
--- a/xen/acm/acm_simple_type_enforcement_hooks.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/acm/acm_simple_type_enforcement_hooks.c Sun Aug 12 14:50:02 2007 -0600
@@ -408,7 +408,7 @@ _ste_update_policy(u8 *buf, u32 buf_size
ste_bin_pol.max_ssidrefs = ste_buf->ste_max_ssidrefs;
ste_bin_pol.ssidrefs = (domaintype_t *)ssidrefsbuf;

- if ( ste_init_state(NULL) )
+ if ( ste_init_state(errors) )
{
/* new policy conflicts with sharing of running domains */
printk("%s: New policy conflicts with running domains. "
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/powerpc/multiboot2.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/powerpc/multiboot2.c Sun Aug 12 14:50:02 2007 -0600
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2006, 2007
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#include <xen/config.h>
+#include <xen/lib.h>
+#include <xen/multiboot2.h>
+#include <asm/boot.h>
+#include <asm/init.h>
+
+static struct mb2_tag_module *mb2_tag_mod_find(struct mb2_tag_header *tags,
+ const char *type)
+{
+ struct mb2_tag_header *tag;
+
+ for_each_tag(tag, tags) {
+ if (tag->key == MB2_TAG_MODULE) {
+ struct mb2_tag_module *mod = (struct mb2_tag_module *)tag;
+ if (!strcmp((char *)mod->type, type))
+ return mod;
+ }
+ }
+ return NULL;
+}
+
+void parse_multiboot(ulong tags_addr)
+{
+ struct mb2_tag_header *tags = (struct mb2_tag_header *)tags_addr;
+ struct mb2_tag_module *mod;
+
+ if (tags->key != MB2_TAG_START)
+ return;
+
+ mod = mb2_tag_mod_find(tags, "kernel");
+ if (mod) {
+ xen_cmdline = (char *)mod->cmdline;
+ }
+
+ mod = mb2_tag_mod_find(tags, "dom0");
+ if (mod) {
+ dom0_addr = mod->addr;
+ dom0_len = mod->size;
+ dom0_cmdline = (char *)mod->cmdline;
+ }
+
+ mod = mb2_tag_mod_find(tags, "initrd");
+ if (mod) {
+ initrd_start = mod->addr;
+ initrd_len = mod->size;
+ }
+}
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/domain_build.c Sun Aug 12 14:50:02 2007 -0600
@@ -316,9 +316,9 @@ int __init construct_dom0(
parms.pae ? ", PAE" : "",
elf_msb(&elf) ? "msb" : "lsb",
elf.pstart, elf.pend);
- if ( parms.bsd_symtab )
+ if ( elf.bsd_symtab_pstart )
printk(" Dom0 symbol map 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
- elf.sstart, elf.send);
+ elf.bsd_symtab_pstart, elf.bsd_symtab_pend);

if ( !compatible )
{
@@ -388,7 +388,7 @@ int __init construct_dom0(
v_start = parms.virt_base;
vkern_start = parms.virt_kstart;
vkern_end = parms.virt_kend;
- vinitrd_start = round_pgup(parms.virt_end);
+ vinitrd_start = round_pgup(vkern_end);
vinitrd_end = vinitrd_start + initrd_len;
vphysmap_start = round_pgup(vinitrd_end);
vphysmap_end = vphysmap_start + (nr_pages * (!is_pv_32on64_domain(d) ?
@@ -798,7 +798,7 @@ int __init construct_dom0(

/* Copy the OS image and free temporary buffer. */
elf.dest = (void*)vkern_start;
- elf_xen_dom_load_binary(&elf, &parms);
+ elf_load_binary(&elf);

if ( UNSET_ADDR != parms.virt_hypercall )
{
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/genapic/Makefile
--- a/xen/arch/x86/genapic/Makefile Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/genapic/Makefile Sun Aug 12 14:50:02 2007 -0600
@@ -1,7 +1,5 @@ obj-y += bigsmp.o
obj-y += bigsmp.o
obj-y += default.o
obj-y += delivery.o
-obj-y += es7000.o
-obj-y += es7000plat.o
obj-y += probe.o
obj-y += summit.o
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/genapic/bigsmp.c
--- a/xen/arch/x86/genapic/bigsmp.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/genapic/bigsmp.c Sun Aug 12 14:50:02 2007 -0600
@@ -13,7 +13,7 @@

static int dmi_bigsmp; /* can be set by dmi scanners */

-static __init int hp_ht_bigsmp(struct dmi_system_id *d)
+static __init int force_bigsmp(struct dmi_system_id *d)
{
printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
dmi_bigsmp = 1;
@@ -22,15 +22,19 @@ static __init int hp_ht_bigsmp(struct dm


static struct dmi_system_id __initdata bigsmp_dmi_table[] = {
- { hp_ht_bigsmp, "HP ProLiant DL760 G2", {
+ { force_bigsmp, "HP ProLiant DL760 G2", {
DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
}},

- { hp_ht_bigsmp, "HP ProLiant DL740", {
+ { force_bigsmp, "HP ProLiant DL740", {
DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
DMI_MATCH(DMI_BIOS_VERSION, "P47-"),
}},
+ { force_bigsmp, "UNISYS ES7000-ONE", {
+ DMI_MATCH(DMI_PRODUCT_NAME, "ES7000-ONE")
+ }},
+
{ }
};

diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/genapic/es7000.c
--- a/xen/arch/x86/genapic/es7000.c Sun Aug 12 12:19:13 2007 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * APIC driver for the Unisys ES7000 chipset.
- */
-#include <xen/config.h>
-#include <xen/cpumask.h>
-#include <asm/current.h>
-#include <asm/mpspec.h>
-#include <asm/genapic.h>
-#include <asm/fixmap.h>
-#include <asm/apicdef.h>
-#include <asm/atomic.h>
-#include <xen/kernel.h>
-#include <xen/string.h>
-#include <xen/smp.h>
-#include <xen/init.h>
-#include <asm/mach-es7000/mach_mpparse.h>
-
-static __init int probe_es7000(void)
-{
- /* probed later in mptable/ACPI hooks */
- return 0;
-}
-
-struct genapic apic_es7000 = {
- APIC_INIT("es7000", probe_es7000),
- GENAPIC_PHYS
-};
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/genapic/es7000plat.c
--- a/xen/arch/x86/genapic/es7000plat.c Sun Aug 12 12:19:13 2007 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
- * Written by: Garry Forsgren, Unisys Corporation
- * Natalie Protasevich, Unisys Corporation
- * Modified by: Raj Subrahmanian <raj.subrahmanian@unisys.com> Unisys Corp.
- * This file contains the code to configure and interface
- * with Unisys ES7000 series hardware system manager.
- *
- * Copyright (c) 2003 Unisys Corporation. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Unisys Corporation, Township Line & Union Meeting
- * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or:
- *
- * http://www.unisys.com
- */
-
-#include <xen/config.h>
-#include <xen/types.h>
-#include <xen/kernel.h>
-#include <xen/smp.h>
-#include <xen/string.h>
-#include <xen/spinlock.h>
-#include <xen/errno.h>
-#include <xen/init.h>
-#include <xen/acpi.h>
-#include <asm/io.h>
-#include <asm/smp.h>
-#include <asm/apicdef.h>
-
-#define MIP_REG 1
-#define MIP_PSAI_REG 4
-
-struct acpi_table_sdt {
- unsigned long pa;
- unsigned long count;
- struct {
- unsigned long pa;
- enum acpi_table_id id;
- unsigned long size;
- } entry[50];
-};
-
-struct oem_table {
- struct acpi_table_header Header;
- u32 OEMTableAddr;
- u32 OEMTableSize;
-};
-
-int __init
-parse_unisys_oem(char *oemptr)
-{
- int i;
- int success = 0;
- unsigned char type, size;
- char *tp = NULL;
-
- tp = oemptr;
-
- tp += 8;
-
- for (i=0; i <= 6; i++) {
- type = *tp++;
- size = *tp++;
- tp -= 2;
- switch (type) {
- case MIP_REG:
- case MIP_PSAI_REG:
- success++;
- break;
- default:
- break;
- }
- tp += size;
- }
-
- return (success >= 2);
-}
-
-int __init
-find_unisys_acpi_oem_table(unsigned long *oem_addr)
-{
- struct acpi_table_rsdp *rsdp = NULL;
- unsigned long rsdp_phys = 0;
- struct acpi_table_header *header = NULL;
- int i;
- struct acpi_table_sdt sdt = { 0 }; /* initialise sdt.count */
-
- rsdp_phys = acpi_find_rsdp();
- rsdp = __va(rsdp_phys);
- if (rsdp->rsdt_address) {
- struct acpi_table_rsdt *mapped_rsdt = NULL;
- sdt.pa = rsdp->rsdt_address;
-
- header = (struct acpi_table_header *)
- __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
- if (!header)
- return -ENODEV;
-
- sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
- mapped_rsdt = (struct acpi_table_rsdt *)
- __acpi_map_table(sdt.pa, header->length);
- if (!mapped_rsdt)
- return -ENODEV;
-
- header = &mapped_rsdt->header;
-
- for (i = 0; i < sdt.count; i++)
- sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
- };
- for (i = 0; i < sdt.count; i++) {
-
- header = (struct acpi_table_header *)
- __acpi_map_table(sdt.entry[i].pa,
- sizeof(struct acpi_table_header));
- if (!header)
- continue;
- if (!strncmp((char *) &header->signature, "OEM1", 4)) {
- if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
- void *addr;
- struct oem_table *t;
- acpi_table_print(header, sdt.entry[i].pa);
- t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
- addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
- *oem_addr = (unsigned long) addr;
- return 0;
- }
- }
- }
- return -1;
-}
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/genapic/probe.c
--- a/xen/arch/x86/genapic/probe.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/genapic/probe.c Sun Aug 12 14:50:02 2007 -0600
@@ -16,7 +16,6 @@

extern struct genapic apic_summit;
extern struct genapic apic_bigsmp;
-extern struct genapic apic_es7000;
extern struct genapic apic_default;

struct genapic *genapic;
@@ -24,7 +23,6 @@ struct genapic *apic_probe[] __initdata
struct genapic *apic_probe[] __initdata = {
&apic_summit,
&apic_bigsmp,
- &apic_es7000,
&apic_default, /* must be last */
NULL,
};
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/hvm/irq.c
--- a/xen/arch/x86/hvm/irq.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/hvm/irq.c Sun Aug 12 14:50:02 2007 -0600
@@ -395,9 +395,33 @@ static int irq_save_pci(struct domain *d
static int irq_save_pci(struct domain *d, hvm_domain_context_t *h)
{
struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
+ unsigned int asserted, pdev, pintx;
+ int rc;
+
+ spin_lock(&d->arch.hvm_domain.irq_lock);
+
+ pdev = hvm_irq->callback_via.pci.dev;
+ pintx = hvm_irq->callback_via.pci.intx;
+ asserted = (hvm_irq->callback_via_asserted &&
+ (hvm_irq->callback_via_type == HVMIRQ_callback_pci_intx));
+
+ /*
+ * Deassert virtual interrupt via PCI INTx line. The virtual interrupt
+ * status is not save/restored, so the INTx line must be deasserted in
+ * the restore context.
+ */
+ if ( asserted )
+ __hvm_pci_intx_deassert(d, pdev, pintx);

/* Save PCI IRQ lines */
- return ( hvm_save_entry(PCI_IRQ, 0, h, &hvm_irq->pci_intx) );
+ rc = hvm_save_entry(PCI_IRQ, 0, h, &hvm_irq->pci_intx);
+
+ if ( asserted )
+ __hvm_pci_intx_assert(d, pdev, pintx);
+
+ spin_unlock(&d->arch.hvm_domain.irq_lock);
+
+ return rc;
}

static int irq_save_isa(struct domain *d, hvm_domain_context_t *h)
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/hvm/svm/svm.c Sun Aug 12 14:50:02 2007 -0600
@@ -2159,6 +2159,7 @@ static void svm_do_msr_access(
case MSR_K8_MC2_STATUS:
case MSR_K8_MC3_STATUS:
case MSR_K8_MC4_STATUS:
+ case MSR_K8_MC5_STATUS:
/* No point in letting the guest see real MCEs */
msr_content = 0;
break;
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/vmx.c Sun Aug 12 14:50:02 2007 -0600
@@ -2596,6 +2596,7 @@ static int vmx_do_msr_read(struct cpu_us
case MSR_K8_MC2_STATUS:
case MSR_K8_MC3_STATUS:
case MSR_K8_MC4_STATUS:
+ case MSR_K8_MC5_STATUS:
/* No point in letting the guest see real MCEs */
msr_content = 0;
break;
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/mm/hap/guest_walk.c
--- a/xen/arch/x86/mm/hap/guest_walk.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/mm/hap/guest_walk.c Sun Aug 12 14:50:02 2007 -0600
@@ -84,7 +84,7 @@ unsigned long hap_gva_to_gfn(GUEST_PAGIN
mfn = get_mfn_from_gpfn(gpfn);
if ( mfn == INVALID_MFN )
{
- HAP_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva,
+ HAP_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva,
lev);
success = 0;
break;
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/mm/hap/hap.c
--- a/xen/arch/x86/mm/hap/hap.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/mm/hap/hap.c Sun Aug 12 14:50:02 2007 -0600
@@ -73,7 +73,7 @@ int hap_disable_log_dirty(struct domain
hap_unlock(d);

/* set l1e entries of P2M table with normal mode */
- p2m_set_flags_global(d, __PAGE_HYPERVISOR|_PAGE_USER);
+ p2m_set_flags_global(d, __PAGE_HYPERVISOR|_PAGE_USER);
return 0;
}

@@ -111,7 +111,7 @@ static struct page_info *hap_alloc(struc

static void hap_free(struct domain *d, mfn_t mfn)
{
- struct page_info *pg = mfn_to_page(mfn);
+ struct page_info *pg = mfn_to_page(mfn);

ASSERT(hap_locked_by_me(d));

@@ -128,7 +128,7 @@ static struct page_info *hap_alloc_p2m_p

#if CONFIG_PAGING_LEVELS == 3
/* Under PAE mode, top-level P2M table should be allocated below 4GB space
- * because the size of h_cr3 is only 32-bit. We use alloc_domheap_pages to
+ * because the size of h_cr3 is only 32-bit. We use alloc_domheap_pages to
* force this requirement, and exchange the guaranteed 32-bit-clean
* page for the one we just hap_alloc()ed. */
if ( d->arch.paging.hap.p2m_pages == 0
@@ -166,9 +166,9 @@ void hap_free_p2m_page(struct domain *d,
HAP_ERROR("Odd p2m page count c=%#x t=%"PRtype_info"\n",
pg->count_info, pg->u.inuse.type_info);
pg->count_info = 0;
- /* Free should not decrement domain's total allocation, since
+ /* Free should not decrement domain's total allocation, since
* these pages were allocated without an owner. */
- page_set_owner(pg, NULL);
+ page_set_owner(pg, NULL);
free_domheap_page(pg);
d->arch.paging.hap.p2m_pages--;
ASSERT(d->arch.paging.hap.p2m_pages >= 0);
@@ -221,7 +221,7 @@ hap_set_allocation(struct domain *d, uns
pg->count_info = 0;
free_domheap_page(pg);
}
-
+
/* Check to see if we need to yield and try again */
if ( preempted && hypercall_preempt_check() )
{
@@ -275,7 +275,7 @@ static void hap_install_xen_entries_in_l

l2e = hap_map_domain_page(l2hmfn);
ASSERT(l2e != NULL);
-
+
/* Copy the common Xen mappings from the idle domain */
memcpy(&l2e[L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES-1)],
&idle_pg_table_l2[L2_PAGETABLE_FIRST_XEN_SLOT],
@@ -318,7 +318,7 @@ static void hap_install_xen_entries_in_l

l2e = hap_map_domain_page(l2mfn);
ASSERT(l2e != NULL);
-
+
/* Copy the common Xen mappings from the idle domain */
memcpy(&l2e[L2_PAGETABLE_FIRST_XEN_SLOT],
&idle_pg_table[L2_PAGETABLE_FIRST_XEN_SLOT],
@@ -362,7 +362,7 @@ static mfn_t hap_make_monitor_table(stru
}
#elif CONFIG_PAGING_LEVELS == 3
{
- mfn_t m3mfn, m2mfn;
+ mfn_t m3mfn, m2mfn;
l3_pgentry_t *l3e;
l2_pgentry_t *l2e;
int i;
@@ -384,8 +384,8 @@ static mfn_t hap_make_monitor_table(stru
l2e = hap_map_domain_page(m2mfn);
for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ )
l2e[l2_table_offset(LINEAR_PT_VIRT_START) + i] =
- (l3e_get_flags(l3e[i]) & _PAGE_PRESENT)
- ? l2e_from_pfn(l3e_get_pfn(l3e[i]), __PAGE_HYPERVISOR)
+ (l3e_get_flags(l3e[i]) & _PAGE_PRESENT)
+ ? l2e_from_pfn(l3e_get_pfn(l3e[i]), __PAGE_HYPERVISOR)
: l2e_empty();
hap_unmap_domain_page(l2e);
hap_unmap_domain_page(l3e);
@@ -536,7 +536,7 @@ void hap_teardown(struct domain *d)
d->arch.paging.hap.p2m_pages);
ASSERT(d->arch.paging.hap.total_pages == 0);
}
-
+
d->arch.paging.mode &= ~PG_log_dirty;

hap_unlock(d);
@@ -555,7 +555,7 @@ int hap_domctl(struct domain *d, xen_dom
hap_unlock(d);
if ( preempted )
/* Not finished. Set up to re-run the call. */
- rc = hypercall_create_continuation(__HYPERVISOR_domctl, "h",
+ rc = hypercall_create_continuation(__HYPERVISOR_domctl, "h",
u_domctl);
else
/* Finished. Return the new allocation */
@@ -578,11 +578,11 @@ void hap_vcpu_init(struct vcpu *v)
/************************************************/
/* HAP PAGING MODE FUNCTIONS */
/************************************************/
-/*
+/*
* HAP guests can handle page faults (in the guest page tables) without
* needing any action from Xen, so we should not be intercepting them.
*/
-static int hap_page_fault(struct vcpu *v, unsigned long va,
+static int hap_page_fault(struct vcpu *v, unsigned long va,
struct cpu_user_regs *regs)
{
HAP_ERROR("Intercepted a guest #PF (%u:%u) with HAP enabled.\n",
@@ -591,9 +591,9 @@ static int hap_page_fault(struct vcpu *v
return 0;
}

-/*
+/*
* HAP guests can handle invlpg without needing any action from Xen, so
- * should not be intercepting it.
+ * should not be intercepting it.
*/
static int hap_invlpg(struct vcpu *v, unsigned long va)
{
@@ -649,7 +649,7 @@ static void hap_update_paging_modes(stru
}

#if CONFIG_PAGING_LEVELS == 3
-static void p2m_install_entry_in_monitors(struct domain *d, l3_pgentry_t *l3e)
+static void p2m_install_entry_in_monitors(struct domain *d, l3_pgentry_t *l3e)
/* Special case, only used for PAE hosts: update the mapping of the p2m
* table. This is trivial in other paging modes (one top-level entry
* points to the top-level p2m, no maintenance needed), but PAE makes
@@ -660,13 +660,13 @@ static void p2m_install_entry_in_monitor
l2_pgentry_t *ml2e;
struct vcpu *v;
unsigned int index;
-
+
index = ((unsigned long)l3e & ~PAGE_MASK) / sizeof(l3_pgentry_t);
ASSERT(index < MACHPHYS_MBYTES>>1);
-
+
for_each_vcpu ( d, v )
{
- if ( pagetable_get_pfn(v->arch.monitor_table) == 0 )
+ if ( pagetable_get_pfn(v->arch.monitor_table) == 0 )
continue;

ASSERT(paging_mode_external(v->domain));
@@ -689,7 +689,7 @@ static void p2m_install_entry_in_monitor
}
#endif

-static void
+static void
hap_write_p2m_entry(struct vcpu *v, unsigned long gfn, l1_pgentry_t *p,
mfn_t table_mfn, l1_pgentry_t new, unsigned int level)
{
@@ -698,12 +698,12 @@ hap_write_p2m_entry(struct vcpu *v, unsi
safe_write_pte(p, new);
#if CONFIG_PAGING_LEVELS == 3
/* install P2M in monitor table for PAE Xen */
- if ( level == 3 )
+ if ( level == 3 )
/* We have written to the p2m l3: need to sync the per-vcpu
* copies of it in the monitor tables */
p2m_install_entry_in_monitors(v->domain, (l3_pgentry_t *)p);
#endif
-
+
hap_unlock(v->domain);
}

@@ -715,7 +715,7 @@ static unsigned long hap_gva_to_gfn_real

/* Entry points into this mode of the hap code. */
struct paging_mode hap_paging_real_mode = {
- .page_fault = hap_page_fault,
+ .page_fault = hap_page_fault,
.invlpg = hap_invlpg,
.gva_to_gfn = hap_gva_to_gfn_real_mode,
.update_cr3 = hap_update_cr3,
@@ -725,7 +725,7 @@ struct paging_mode hap_paging_real_mode
};

struct paging_mode hap_paging_protected_mode = {
- .page_fault = hap_page_fault,
+ .page_fault = hap_page_fault,
.invlpg = hap_invlpg,
.gva_to_gfn = hap_gva_to_gfn_2level,
.update_cr3 = hap_update_cr3,
@@ -735,7 +735,7 @@ struct paging_mode hap_paging_protected_
};

struct paging_mode hap_paging_pae_mode = {
- .page_fault = hap_page_fault,
+ .page_fault = hap_page_fault,
.invlpg = hap_invlpg,
.gva_to_gfn = hap_gva_to_gfn_3level,
.update_cr3 = hap_update_cr3,
@@ -745,7 +745,7 @@ struct paging_mode hap_paging_pae_mode =
};

struct paging_mode hap_paging_long_mode = {
- .page_fault = hap_page_fault,
+ .page_fault = hap_page_fault,
.invlpg = hap_invlpg,
.gva_to_gfn = hap_gva_to_gfn_4level,
.update_cr3 = hap_update_cr3,
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/mm/p2m.c Sun Aug 12 14:50:02 2007 -0600
@@ -2,12 +2,12 @@
* arch/x86/mm/p2m.c
*
* physical-to-machine mappings for automatically-translated domains.
- *
+ *
* Parts of this code are Copyright (c) 2007 by Advanced Micro Devices.
* Parts of this code are Copyright (c) 2006 by XenSource Inc.
* Parts of this code are Copyright (c) 2006 by Michael A Fetterman
* Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -34,7 +34,7 @@

/*
* The P2M lock. This protects all updates to the p2m table.
- * Updates are expected to be safe against concurrent reads,
+ * Updates are expected to be safe against concurrent reads,
* which do *not* require the lock.
*
* Locking discipline: always acquire this lock before the shadow or HAP one
@@ -80,7 +80,7 @@
#define P2M_DEBUG(_f, _a...) \
debugtrace_printk("p2mdebug: %s(): " _f, __func__, ##_a)
#else
-#define P2M_DEBUG(_f, _a...) do { (void)(_f); } while(0)
+#define P2M_DEBUG(_f, _a...) do { (void)(_f); } while(0)
#endif


@@ -119,8 +119,8 @@ p2m_find_entry(void *table, unsigned lon
// Returns 0 on error.
//
static int
-p2m_next_level(struct domain *d, mfn_t *table_mfn, void **table,
- unsigned long *gfn_remainder, unsigned long gfn, u32 shift,
+p2m_next_level(struct domain *d, mfn_t *table_mfn, void **table,
+ unsigned long *gfn_remainder, unsigned long gfn, u32 shift,
u32 max, unsigned long type)
{
l1_pgentry_t *p2m_entry;
@@ -146,7 +146,7 @@ p2m_next_level(struct domain *d, mfn_t *

switch ( type ) {
case PGT_l3_page_table:
- paging_write_p2m_entry(d, gfn,
+ paging_write_p2m_entry(d, gfn,
p2m_entry, *table_mfn, new_entry, 4);
break;
case PGT_l2_page_table:
@@ -154,11 +154,11 @@ p2m_next_level(struct domain *d, mfn_t *
/* for PAE mode, PDPE only has PCD/PWT/P bits available */
new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)), _PAGE_PRESENT);
#endif
- paging_write_p2m_entry(d, gfn,
+ paging_write_p2m_entry(d, gfn,
p2m_entry, *table_mfn, new_entry, 3);
break;
case PGT_l1_page_table:
- paging_write_p2m_entry(d, gfn,
+ paging_write_p2m_entry(d, gfn,
p2m_entry, *table_mfn, new_entry, 2);
break;
default:
@@ -216,7 +216,7 @@ set_p2m_entry(struct domain *d, unsigned
ASSERT(p2m_entry);

/* Track the highest gfn for which we have ever had a valid mapping */
- if ( mfn_valid(mfn) && (gfn > d->arch.p2m.max_mapped_pfn) )
+ if ( mfn_valid(mfn) && (gfn > d->arch.p2m.max_mapped_pfn) )
d->arch.p2m.max_mapped_pfn = gfn;

if ( mfn_valid(mfn) )
@@ -229,7 +229,7 @@ set_p2m_entry(struct domain *d, unsigned

/* Success */
rv = 1;
-
+
out:
unmap_domain_page(table);
return rv;
@@ -250,7 +250,7 @@ void p2m_init(struct domain *d)
// controlled by CONFIG_PAGING_LEVELS).
//
// The alloc_page and free_page functions will be used to get memory to
-// build the p2m, and to release it again at the end of day.
+// build the p2m, and to release it again at the end of day.
//
// Returns 0 for success or -errno.
//
@@ -264,7 +264,7 @@ int p2m_alloc_table(struct domain *d,
struct page_info *page, *p2m_top;
unsigned int page_count = 0;
unsigned long gfn;
-
+
p2m_lock(d);

if ( pagetable_get_pfn(d->arch.phys_table) != 0 )
@@ -288,7 +288,7 @@ int p2m_alloc_table(struct domain *d,
list_add_tail(&p2m_top->list, &d->arch.p2m.pages);

p2m_top->count_info = 1;
- p2m_top->u.inuse.type_info =
+ p2m_top->u.inuse.type_info =
#if CONFIG_PAGING_LEVELS == 4
PGT_l4_page_table
#elif CONFIG_PAGING_LEVELS == 3
@@ -301,7 +301,7 @@ int p2m_alloc_table(struct domain *d,
d->arch.phys_table = pagetable_from_mfn(page_to_mfn(p2m_top));

P2M_PRINTK("populating p2m table\n");
-
+
/* Initialise physmap tables for slot zero. Other code assumes this. */
gfn = 0;
mfn = _mfn(INVALID_MFN);
@@ -365,17 +365,17 @@ gfn_to_mfn_foreign(struct domain *d, uns
paddr_t addr = ((paddr_t)gpfn) << PAGE_SHIFT;
l2_pgentry_t *l2e;
l1_pgentry_t *l1e;
-
+
ASSERT(paging_mode_translate(d));
mfn = pagetable_get_mfn(d->arch.phys_table);


- if ( gpfn > d->arch.p2m.max_mapped_pfn )
+ if ( gpfn > d->arch.p2m.max_mapped_pfn )
/* This pfn is higher than the highest the p2m map currently holds */
return _mfn(INVALID_MFN);

#if CONFIG_PAGING_LEVELS >= 4
- {
+ {
l4_pgentry_t *l4e = map_domain_page(mfn_x(mfn));
l4e += l4_table_offset(addr);
if ( (l4e_get_flags(*l4e) & _PAGE_PRESENT) == 0 )
@@ -398,7 +398,7 @@ gfn_to_mfn_foreign(struct domain *d, uns
* the bounds of the p2m. */
l3e += (addr >> L3_PAGETABLE_SHIFT);
#else
- l3e += l3_table_offset(addr);
+ l3e += l3_table_offset(addr);
#endif
if ( (l3e_get_flags(*l3e) & _PAGE_PRESENT) == 0 )
{
@@ -443,18 +443,18 @@ static void audit_p2m(struct domain *d)
mfn_t p2mfn;
unsigned long orphans_d = 0, orphans_i = 0, mpbad = 0, pmbad = 0;
int test_linear;
-
+
if ( !paging_mode_translate(d) )
return;

//P2M_PRINTK("p2m audit starts\n");

- test_linear = ( (d == current->domain)
+ test_linear = ( (d == current->domain)
&& !pagetable_is_null(current->arch.monitor_table) );
if ( test_linear )
- local_flush_tlb();
-
- /* Audit part one: walk the domain's page allocation list, checking
+ local_flush_tlb();
+
+ /* Audit part one: walk the domain's page allocation list, checking
* the m2p entries. */
for ( entry = d->page_list.next;
entry != &d->page_list;
@@ -463,11 +463,11 @@ static void audit_p2m(struct domain *d)
page = list_entry(entry, struct page_info, list);
mfn = mfn_x(page_to_mfn(page));

- // P2M_PRINTK("auditing guest page, mfn=%#lx\n", mfn);
+ // P2M_PRINTK("auditing guest page, mfn=%#lx\n", mfn);

od = page_get_owner(page);

- if ( od != d )
+ if ( od != d )
{
P2M_PRINTK("wrong owner %#lx -> %p(%u) != %p(%u)\n",
mfn, od, (od?od->domain_id:-1), d, d->domain_id);
@@ -475,19 +475,19 @@ static void audit_p2m(struct domain *d)
}

gfn = get_gpfn_from_mfn(mfn);
- if ( gfn == INVALID_M2P_ENTRY )
+ if ( gfn == INVALID_M2P_ENTRY )
{
orphans_i++;
//P2M_PRINTK("orphaned guest page: mfn=%#lx has invalid gfn\n",
- // mfn);
+ // mfn);
continue;
}

- if ( gfn == 0x55555555 )
+ if ( gfn == 0x55555555 )
{
orphans_d++;
- //P2M_PRINTK("orphaned guest page: mfn=%#lx has debug gfn\n",
- // mfn);
+ //P2M_PRINTK("orphaned guest page: mfn=%#lx has debug gfn\n",
+ // mfn);
continue;
}

@@ -503,7 +503,7 @@ static void audit_p2m(struct domain *d)
: -1u));
/* This m2p entry is stale: the domain has another frame in
* this physical slot. No great disaster, but for neatness,
- * blow away the m2p entry. */
+ * blow away the m2p entry. */
set_gpfn_from_mfn(mfn, INVALID_M2P_ENTRY, __PAGE_HYPERVISOR|_PAGE_USER);
}

@@ -517,9 +517,9 @@ static void audit_p2m(struct domain *d)
}
}

- // P2M_PRINTK("OK: mfn=%#lx, gfn=%#lx, p2mfn=%#lx, lp2mfn=%#lx\n",
- // mfn, gfn, p2mfn, lp2mfn);
- }
+ // P2M_PRINTK("OK: mfn=%#lx, gfn=%#lx, p2mfn=%#lx, lp2mfn=%#lx\n",
+ // mfn, gfn, p2mfn, lp2mfn);
+ }

/* Audit part two: walk the domain's p2m table, checking the entries. */
if ( pagetable_get_pfn(d->arch.phys_table) != 0 )
@@ -527,7 +527,7 @@ static void audit_p2m(struct domain *d)
l2_pgentry_t *l2e;
l1_pgentry_t *l1e;
int i1, i2;
-
+
#if CONFIG_PAGING_LEVELS == 4
l4_pgentry_t *l4e;
l3_pgentry_t *l3e;
@@ -553,8 +553,8 @@ static void audit_p2m(struct domain *d)
}
l3e = map_domain_page(mfn_x(_mfn(l4e_get_pfn(l4e[i4]))));
#endif /* now at levels 3 or 4... */
- for ( i3 = 0;
- i3 < ((CONFIG_PAGING_LEVELS==4) ? L3_PAGETABLE_ENTRIES : 8);
+ for ( i3 = 0;
+ i3 < ((CONFIG_PAGING_LEVELS==4) ? L3_PAGETABLE_ENTRIES : 8);
i3++ )
{
if ( !(l3e_get_flags(l3e[i3]) & _PAGE_PRESENT) )
@@ -572,7 +572,7 @@ static void audit_p2m(struct domain *d)
continue;
}
l1e = map_domain_page(mfn_x(_mfn(l2e_get_pfn(l2e[i2]))));
-
+
for ( i1 = 0; i1 < L1_PAGETABLE_ENTRIES; i1++, gfn++ )
{
if ( !(l1e_get_flags(l1e[i1]) & _PAGE_PRESENT) )
@@ -610,14 +610,14 @@ static void audit_p2m(struct domain *d)
}

//P2M_PRINTK("p2m audit complete\n");
- //if ( orphans_i | orphans_d | mpbad | pmbad )
+ //if ( orphans_i | orphans_d | mpbad | pmbad )
// P2M_PRINTK("p2m audit found %lu orphans (%lu inval %lu debug)\n",
// orphans_i + orphans_d, orphans_i, orphans_d,
- if ( mpbad | pmbad )
+ if ( mpbad | pmbad )
P2M_PRINTK("p2m audit found %lu odd p2m, %lu bad m2p entries\n",
pmbad, mpbad);
}
-#else
+#else
#define audit_p2m(_d) do { (void)(_d); } while(0)
#endif /* P2M_AUDIT */

@@ -645,7 +645,7 @@ guest_physmap_remove_page(struct domain
audit_p2m(d);
p2m_remove_page(d, gfn, mfn);
audit_p2m(d);
- p2m_unlock(d);
+ p2m_unlock(d);
}

void
@@ -683,11 +683,11 @@ guest_physmap_add_page(struct domain *d,
/* This machine frame is already mapped at another physical address */
P2M_DEBUG("aliased! mfn=%#lx, old gfn=%#lx, new gfn=%#lx\n",
mfn, ogfn, gfn);
- if ( mfn_valid(omfn = gfn_to_mfn(d, ogfn)) )
- {
- P2M_DEBUG("old gfn=%#lx -> mfn %#lx\n",
+ if ( mfn_valid(omfn = gfn_to_mfn(d, ogfn)) )
+ {
+ P2M_DEBUG("old gfn=%#lx -> mfn %#lx\n",
ogfn , mfn_x(omfn));
- if ( mfn_x(omfn) == mfn )
+ if ( mfn_x(omfn) == mfn )
p2m_remove_page(d, ogfn, mfn);
}
}
@@ -720,15 +720,15 @@ void p2m_set_flags_global(struct domain
int i4;
#endif /* CONFIG_PAGING_LEVELS == 4 */
#endif /* CONFIG_PAGING_LEVELS >= 3 */
-
+
if ( !paging_mode_translate(d) )
return;
-
+
if ( pagetable_get_pfn(d->arch.phys_table) == 0 )
return;

p2m_lock(d);
-
+
#if CONFIG_PAGING_LEVELS == 4
l4e = map_domain_page(mfn_x(pagetable_get_mfn(d->arch.phys_table)));
#elif CONFIG_PAGING_LEVELS == 3
@@ -739,52 +739,52 @@ void p2m_set_flags_global(struct domain

#if CONFIG_PAGING_LEVELS >= 3
#if CONFIG_PAGING_LEVELS >= 4
- for ( i4 = 0; i4 < L4_PAGETABLE_ENTRIES; i4++ )
- {
- if ( !(l4e_get_flags(l4e[i4]) & _PAGE_PRESENT) )
- {
- continue;
- }
- l3e = map_domain_page(l4e_get_pfn(l4e[i4]));
+ for ( i4 = 0; i4 < L4_PAGETABLE_ENTRIES; i4++ )
+ {
+ if ( !(l4e_get_flags(l4e[i4]) & _PAGE_PRESENT) )
+ {
+ continue;
+ }
+ l3e = map_domain_page(l4e_get_pfn(l4e[i4]));
#endif /* now at levels 3 or 4... */
- for ( i3 = 0;
- i3 < ((CONFIG_PAGING_LEVELS==4) ? L3_PAGETABLE_ENTRIES : 8);
- i3++ )
- {
- if ( !(l3e_get_flags(l3e[i3]) & _PAGE_PRESENT) )
- {
- continue;
- }
- l2e = map_domain_page(l3e_get_pfn(l3e[i3]));
+ for ( i3 = 0;
+ i3 < ((CONFIG_PAGING_LEVELS==4) ? L3_PAGETABLE_ENTRIES : 8);
+ i3++ )
+ {
+ if ( !(l3e_get_flags(l3e[i3]) & _PAGE_PRESENT) )
+ {
+ continue;
+ }
+ l2e = map_domain_page(l3e_get_pfn(l3e[i3]));
#endif /* all levels... */
- for ( i2 = 0; i2 < L2_PAGETABLE_ENTRIES; i2++ )
- {
- if ( !(l2e_get_flags(l2e[i2]) & _PAGE_PRESENT) )
- {
- continue;
- }
+ for ( i2 = 0; i2 < L2_PAGETABLE_ENTRIES; i2++ )
+ {
+ if ( !(l2e_get_flags(l2e[i2]) & _PAGE_PRESENT) )
+ {
+ continue;
+ }

l1mfn = _mfn(l2e_get_pfn(l2e[i2]));
- l1e = map_domain_page(mfn_x(l1mfn));
-
- for ( i1 = 0; i1 < L1_PAGETABLE_ENTRIES; i1++, gfn++ )
- {
- if ( !(l1e_get_flags(l1e[i1]) & _PAGE_PRESENT) )
- continue;
- mfn = l1e_get_pfn(l1e[i1]);
- gfn = get_gpfn_from_mfn(mfn);
- /* create a new 1le entry using l1e_flags */
- l1e_content = l1e_from_pfn(mfn, l1e_flags);
- paging_write_p2m_entry(d, gfn, &l1e[i1],
+ l1e = map_domain_page(mfn_x(l1mfn));
+
+ for ( i1 = 0; i1 < L1_PAGETABLE_ENTRIES; i1++, gfn++ )
+ {
+ if ( !(l1e_get_flags(l1e[i1]) & _PAGE_PRESENT) )
+ continue;
+ mfn = l1e_get_pfn(l1e[i1]);
+ gfn = get_gpfn_from_mfn(mfn);
+ /* create a new 1le entry using l1e_flags */
+ l1e_content = l1e_from_pfn(mfn, l1e_flags);
+ paging_write_p2m_entry(d, gfn, &l1e[i1],
l1mfn, l1e_content, 1);
- }
- unmap_domain_page(l1e);
- }
+ }
+ unmap_domain_page(l1e);
+ }
#if CONFIG_PAGING_LEVELS >= 3
- unmap_domain_page(l2e);
- }
+ unmap_domain_page(l2e);
+ }
#if CONFIG_PAGING_LEVELS >= 4
- unmap_domain_page(l3e);
+ unmap_domain_page(l3e);
}
#endif
#endif
@@ -814,7 +814,7 @@ int p2m_set_flags(struct domain *d, padd
mfn = gfn_to_mfn(d, gfn);
if ( mfn_valid(mfn) )
set_p2m_entry(d, gfn, mfn, l1e_flags);
-
+
p2m_unlock(d);

return 1;
diff -r 5b19839d0365 -r cd51fa91956b xen/arch/x86/mm/paging.c
--- a/xen/arch/x86/mm/paging.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/arch/x86/mm/paging.c Sun Aug 12 14:50:02 2007 -0600
@@ -54,10 +54,10 @@ boolean_param("hap", opt_hap_enabled);
#define page_to_mfn(_pg) (_mfn((_pg) - frame_table))

/* The log-dirty lock. This protects the log-dirty bitmap from
- * concurrent accesses (and teardowns, etc).
- *
+ * concurrent accesses (and teardowns, etc).
+ *
* Locking discipline: always acquire shadow or HAP lock before this one.
- *
+ *
* Because mark_dirty is called from a lot of places, the log-dirty lock
* may be acquired with the shadow or HAP locks already held. When the
* log-dirty code makes callbacks into HAP or shadow code to reset
@@ -105,7 +105,7 @@ int paging_alloc_log_dirty_bitmap(struct

d->arch.paging.log_dirty.bitmap_size =
(domain_get_maximum_gpfn(d) + BITS_PER_LONG) & ~(BITS_PER_LONG - 1);
- d->arch.paging.log_dirty.bitmap =
+ d->arch.paging.log_dirty.bitmap =
xmalloc_array(unsigned long,
d->arch.paging.log_dirty.bitmap_size / BITS_PER_LONG);
if ( d->arch.paging.log_dirty.bitmap == NULL )
@@ -152,8 +152,8 @@ int paging_log_dirty_enable(struct domai

log_dirty_unlock(d);

- /* Safe because the domain is paused. */
- ret = d->arch.paging.log_dirty.enable_log_dirty(d);
+ /* Safe because the domain is paused. */
+ ret = d->arch.paging.log_dirty.enable_log_dirty(d);

/* Possibility of leaving the bitmap allocated here but it'll be
* tidied on domain teardown. */
@@ -202,7 +202,7 @@ void paging_mark_dirty(struct domain *d,
pfn = get_gpfn_from_mfn(mfn_x(gmfn));

/*
- * Values with the MSB set denote MFNs that aren't really part of the
+ * Values with the MSB set denote MFNs that aren't really part of the
* domain's pseudo-physical memory map (e.g., the shared info frame).
* Nothing to do here...
*/
@@ -212,11 +212,11 @@ void paging_mark_dirty(struct domain *d,
return;
}

- if ( likely(pfn < d->arch.paging.log_dirty.bitmap_size) )
- {
+ if ( likely(pfn < d->arch.paging.log_dirty.bitmap_size) )
+ {
if ( !__test_and_set_bit(pfn, d->arch.paging.log_dirty.bitmap) )
{
- PAGING_DEBUG(LOGDIRTY,
+ PAGING_DEBUG(LOGDIRTY,
"marked mfn %" PRI_mfn " (pfn=%lx), dom %d\n",
mfn_x(gmfn), pfn, d->domain_id);
d->arch.paging.log_dirty.dirty_count++;
@@ -227,21 +227,21 @@ void paging_mark_dirty(struct domain *d,
PAGING_PRINTK("mark_dirty OOR! "
"mfn=%" PRI_mfn " pfn=%lx max=%x (dom %d)\n"
"owner=%d c=%08x t=%" PRtype_info "\n",
- mfn_x(gmfn),
- pfn,
+ mfn_x(gmfn),
+ pfn,
d->arch.paging.log_dirty.bitmap_size,
d->domain_id,
(page_get_owner(mfn_to_page(gmfn))
? page_get_owner(mfn_to_page(gmfn))->domain_id
: -1),
- mfn_to_page(gmfn)->count_info,
+ mfn_to_page(gmfn)->count_info,
mfn_to_page(gmfn)->u.inuse.type_info);
}
-
- log_dirty_unlock(d);
-}
-
-/* Read a domain's log-dirty bitmap and stats. If the operation is a CLEAN,
+
+ log_dirty_unlock(d);
+}
+
+/* Read a domain's log-dirty bitmap and stats. If the operation is a CLEAN,
* clear the bitmap and stats as well. */
int paging_log_dirty_op(struct domain *d, struct xen_domctl_shadow_op *sc)
{
@@ -252,15 +252,15 @@ int paging_log_dirty_op(struct domain *d

clean = (sc->op == XEN_DOMCTL_SHADOW_OP_CLEAN);

- PAGING_DEBUG(LOGDIRTY, "log-dirty %s: dom %u faults=%u dirty=%u\n",
+ PAGING_DEBUG(LOGDIRTY, "log-dirty %s: dom %u faults=%u dirty=%u\n",
(clean) ? "clean" : "peek",
d->domain_id,
- d->arch.paging.log_dirty.fault_count,
+ d->arch.paging.log_dirty.fault_count,
d->arch.paging.log_dirty.dirty_count);

sc->stats.fault_count = d->arch.paging.log_dirty.fault_count;
sc->stats.dirty_count = d->arch.paging.log_dirty.dirty_count;
-
+
if ( clean )
{
d->arch.paging.log_dirty.fault_count = 0;
@@ -276,7 +276,7 @@ int paging_log_dirty_op(struct domain *d
rv = -EINVAL; /* perhaps should be ENOMEM? */
goto out;
}
-
+
if ( sc->pages > d->arch.paging.log_dirty.bitmap_size )
sc->pages = d->arch.paging.log_dirty.bitmap_size;

@@ -322,11 +322,11 @@ int paging_log_dirty_op(struct domain *d


/* Note that this function takes three function pointers. Callers must supply
- * these functions for log dirty code to call. This function usually is
- * invoked when paging is enabled. Check shadow_enable() and hap_enable() for
+ * these functions for log dirty code to call. This function usually is
+ * invoked when paging is enabled. Check shadow_enable() and hap_enable() for
* reference.
*
- * These function pointers must not be followed with the log-dirty lock held.
+ * These function pointers must not be followed with the log-dirty lock held.
*/
void paging_log_dirty_init(struct domain *d,
int (*enable_log_dirty)(struct domain *d),
@@ -335,7 +335,7 @@ void paging_log_dirty_init(struct domain
{
/* We initialize log dirty lock first */
log_dirty_lock_init(d);
-
+
d->arch.paging.log_dirty.enable_log_dirty = enable_log_dirty;
d->arch.paging.log_dirty.disable_log_dirty = disable_log_dirty;
d->arch.paging.log_dirty.clean_dirty_bitmap = clean_dirty_bitmap;
@@ -387,7 +387,7 @@ int paging_domctl(struct domain *d, xen_
d->domain_id);
return -EINVAL;
}
-
+
if ( unlikely(d->is_dying) )
{
gdprintk(XENLOG_INFO, "Ignoring paging op on dying domain %u\n",
@@ -401,38 +401,38 @@ int paging_domctl(struct domain *d, xen_
d->domain_id);
return -EINVAL;
}
-
+
/* Code to handle log-dirty. Note that some log dirty operations
- * piggy-back on shadow operations. For example, when
+ * piggy-back on shadow operations. For example, when
* XEN_DOMCTL_SHADOW_OP_OFF is called, it first checks whether log dirty
- * mode is enabled. If does, we disables log dirty and continues with
- * shadow code. For this reason, we need to further dispatch domctl
+ * mode is enabled. If does, we disables log dirty and continues with
+ * shadow code. For this reason, we need to further dispatch domctl
* to next-level paging code (shadow or hap).
*/
switch ( sc->op )
{
case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY:
- return paging_log_dirty_enable(d);
-
- case XEN_DOMCTL_SHADOW_OP_ENABLE:
+ return paging_log_dirty_enable(d);
+
+ case XEN_DOMCTL_SHADOW_OP_ENABLE:
if ( sc->mode & XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY )
return paging_log_dirty_enable(d);

case XEN_DOMCTL_SHADOW_OP_OFF:
if ( paging_mode_log_dirty(d) )
- if ( (rc = paging_log_dirty_disable(d)) != 0 )
+ if ( (rc = paging_log_dirty_disable(d)) != 0 )
return rc;

case XEN_DOMCTL_SHADOW_OP_CLEAN:
case XEN_DOMCTL_SHADOW_OP_PEEK:
- return paging_log_dirty_op(d, sc);
- }
-
+ return paging_log_dirty_op(d, sc);
+ }
+
/* Here, dispatch domctl to the appropriate paging code */
if ( opt_hap_enabled && is_hvm_domain(d) )
- return hap_domctl(d, sc, u_domctl);
- else
- return shadow_domctl(d, sc, u_domctl);
+ return hap_domctl(d, sc, u_domctl);
+ else
+ return shadow_domctl(d, sc, u_domctl);
}

/* Call when destroying a domain */
@@ -492,7 +492,7 @@ void paging_dump_vcpu_info(struct vcpu *
{
if ( paging_mode_enabled(v->domain) )
{
- printk(" paging assistance: ");
+ printk(" paging assistance: ");
if ( paging_mode_shadow(v->domain) )
{
if ( v->arch.paging.mode )
@@ -504,7 +504,7 @@ void paging_dump_vcpu_info(struct vcpu *
printk("not shadowed\n");
}
else if ( paging_mode_hap(v->domain) && v->arch.paging.mode )
- printk("hap, %u levels\n",
+ printk("hap, %u levels\n",
v->arch.paging.mode->guest_levels);
else
printk("none\n");
diff -r 5b19839d0365 -r cd51fa91956b xen/common/compat/grant_table.c
--- a/xen/common/compat/grant_table.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/common/compat/grant_table.c Sun Aug 12 14:50:02 2007 -0600
@@ -161,7 +161,7 @@ int compat_grant_table_op(unsigned int c
while ( n-- )
{
guest_handle_add_offset(xfer, -1);
- if ( __copy_field_to_guest(xfer, nat.xfer, status) )
+ if ( __copy_field_to_guest(xfer, nat.xfer + n, status) )
rc = -EFAULT;
}
}
@@ -199,7 +199,7 @@ int compat_grant_table_op(unsigned int c
while ( n-- )
{
guest_handle_add_offset(copy, -1);
- if ( __copy_field_to_guest(copy, nat.copy, status) )
+ if ( __copy_field_to_guest(copy, nat.copy + n, status) )
rc = -EFAULT;
}
}
diff -r 5b19839d0365 -r cd51fa91956b xen/common/libelf/libelf-dominfo.c
--- a/xen/common/libelf/libelf-dominfo.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/common/libelf/libelf-dominfo.c Sun Aug 12 14:50:02 2007 -0600
@@ -333,99 +333,6 @@ static int elf_xen_note_check(struct elf
return 0;
}

-
-static void elf_xen_loadsymtab(struct elf_binary *elf,
- struct elf_dom_parms *parms)
-{
- unsigned long maxva, len;
-
- if ( !parms->bsd_symtab )
- return;
-
- /* Calculate the required additional kernel space for the elf image */
-
- /* The absolute base address of the elf image */
- maxva = elf_round_up(elf, parms->virt_kend);
- maxva += sizeof(long); /* Space to store the size of the elf image */
- /* Space for the elf and elf section headers */
- maxva += (elf_uval(elf, elf->ehdr, e_ehsize) +
- elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize));
- maxva = elf_round_up(elf, maxva);
-
- /* Space for the symbol and string tabs */
- len = (unsigned long)elf->send - (unsigned long)elf->sstart;
- maxva = elf_round_up(elf, maxva + len);
-
- /* The address the kernel must expanded to */
- parms->virt_end = maxva;
-}
-
-int elf_xen_dom_load_binary(struct elf_binary *elf,
- struct elf_dom_parms *parms)
-{
- elf_ehdr *sym_ehdr;
- unsigned long shdr, symtab_addr;
- unsigned long maxva, symbase;
- uint8_t i;
- char *p;
-
- elf_load_binary(elf);
-
- if ( !parms->bsd_symtab )
- return 0;
-
-#define elf_hdr_elm(_elf, _hdr, _elm, _val) \
-do { \
- if ( elf_64bit(_elf) ) \
- (_hdr)->e64._elm = _val; \
- else \
- (_hdr)->e32._elm = _val; \
-} while ( 0 )
-
- /* ehdr right after the kernel image (4 byte aligned) */
- symbase = elf_round_up(elf, parms->virt_kend);
- symtab_addr = maxva = symbase + sizeof(long);
-
- /* Set up Elf header. */
- sym_ehdr = (elf_ehdr *)symtab_addr;
- maxva = elf_copy_ehdr(elf, sym_ehdr);
-
- elf_hdr_elm(elf, sym_ehdr, e_phoff, 0);
- elf_hdr_elm(elf, sym_ehdr, e_shoff, elf_uval(elf, elf->ehdr, e_ehsize));
- elf_hdr_elm(elf, sym_ehdr, e_phentsize, 0);
- elf_hdr_elm(elf, sym_ehdr, e_phnum, 0);
-
- /* Copy Elf section headers. */
- shdr = maxva;
- maxva = elf_copy_shdr(elf, (elf_shdr *)shdr);
-
- for ( i = 0; i < elf_shdr_count(elf); i++ )
- {
- uint8_t type;
- unsigned long tmp;
- type = elf_uval(elf, (elf_shdr *)shdr, sh_type);
- if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
- {
- elf_msg(elf, "%s: shdr %i at 0x%p -> 0x%p\n", __func__, i,
- elf_section_start(elf, (elf_shdr *)shdr), (void *)maxva);
- tmp = elf_copy_section(elf, (elf_shdr *)shdr, (void *)maxva);
- /* Mangled to be based on ELF header location. */
- elf_hdr_elm(elf, (elf_shdr *)shdr, sh_offset,
- maxva - symtab_addr);
- maxva = tmp;
- }
- shdr += elf_uval(elf, elf->ehdr, e_shentsize);
- }
-
- /* Write down the actual sym size. */
- p = (char *)symbase;
- *(long *)p = maxva - symtab_addr; /* sym size */
-
-#undef elf_ehdr_elm
-
- return 0;
-}
-
static int elf_xen_addr_calc_check(struct elf_binary *elf,
struct elf_dom_parms *parms)
{
@@ -467,13 +374,16 @@ static int elf_xen_addr_calc_check(struc
parms->virt_offset = parms->virt_base - parms->elf_paddr_offset;
parms->virt_kstart = elf->pstart + parms->virt_offset;
parms->virt_kend = elf->pend + parms->virt_offset;
- parms->virt_end = parms->virt_kend;

if ( parms->virt_entry == UNSET_ADDR )
parms->virt_entry = elf_uval(elf, elf->ehdr, e_entry);

if ( parms->bsd_symtab )
- elf_xen_loadsymtab(elf, parms);
+ {
+ elf_parse_bsdsyms(elf, parms->virt_kend);
+ if ( elf->bsd_symtab_pend )
+ parms->virt_kend = elf->bsd_symtab_pend + parms->virt_offset;
+ }

elf_msg(elf, "%s: addresses:\n", __FUNCTION__);
elf_msg(elf, " virt_base = 0x%" PRIx64 "\n", parms->virt_base);
@@ -481,14 +391,12 @@ static int elf_xen_addr_calc_check(struc
elf_msg(elf, " virt_offset = 0x%" PRIx64 "\n", parms->virt_offset);
elf_msg(elf, " virt_kstart = 0x%" PRIx64 "\n", parms->virt_kstart);
elf_msg(elf, " virt_kend = 0x%" PRIx64 "\n", parms->virt_kend);
- elf_msg(elf, " virt_end = 0x%" PRIx64 "\n", parms->virt_end);
elf_msg(elf, " virt_entry = 0x%" PRIx64 "\n", parms->virt_entry);

if ( (parms->virt_kstart > parms->virt_kend) ||
(parms->virt_entry < parms->virt_kstart) ||
(parms->virt_entry > parms->virt_kend) ||
- (parms->virt_base > parms->virt_kstart) ||
- (parms->virt_kend > parms->virt_end) )
+ (parms->virt_base > parms->virt_kstart) )
{
elf_err(elf, "%s: ERROR: ELF start or entries are out of bounds.\n",
__FUNCTION__);
diff -r 5b19839d0365 -r cd51fa91956b xen/common/libelf/libelf-loader.c
--- a/xen/common/libelf/libelf-loader.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/common/libelf/libelf-loader.c Sun Aug 12 14:50:02 2007 -0600
@@ -10,8 +10,6 @@ int elf_init(struct elf_binary *elf, con
{
const elf_shdr *shdr;
uint64_t i, count, section, offset;
- uint64_t low = -1;
- uint64_t high = 0;

if ( !elf_is_elfbinary(image) )
{
@@ -22,13 +20,9 @@ int elf_init(struct elf_binary *elf, con
memset(elf, 0, sizeof(*elf));
elf->image = image;
elf->size = size;
- elf->ehdr = (elf_ehdr *) image;
+ elf->ehdr = (elf_ehdr *)image;
elf->class = elf->ehdr->e32.e_ident[EI_CLASS];
elf->data = elf->ehdr->e32.e_ident[EI_DATA];
-
-#ifdef VERBOSE
- elf_set_verbose(elf);
-#endif

/* Sanity check phdr. */
offset = elf_uval(elf, elf->ehdr, e_phoff) +
@@ -60,43 +54,18 @@ int elf_init(struct elf_binary *elf, con
count = elf_shdr_count(elf);
for ( i = 0; i < count; i++ )
{
- const char *sh_symend, *sh_strend;
-
shdr = elf_shdr_by_index(elf, i);
if ( elf_uval(elf, shdr, sh_type) != SHT_SYMTAB )
continue;
elf->sym_tab = shdr;
- sh_symend = (const char *)elf_section_end(elf, shdr);
shdr = elf_shdr_by_index(elf, elf_uval(elf, shdr, sh_link));
if ( shdr == NULL )
{
elf->sym_tab = NULL;
- sh_symend = 0;
continue;
}
elf->sym_strtab = elf_section_start(elf, shdr);
- sh_strend = (const char *)elf_section_end(elf, shdr);
-
- if ( low > (unsigned long)elf->sym_tab )
- low = (unsigned long)elf->sym_tab;
- if ( low > (unsigned long)shdr )
- low = (unsigned long)shdr;
-
- if ( high < ((unsigned long)sh_symend) )
- high = (unsigned long)sh_symend;
- if ( high < ((unsigned long)sh_strend) )
- high = (unsigned long)sh_strend;
-
- elf_msg(elf, "%s: shdr: sym_tab=%p size=0x%" PRIx64 "\n",
- __FUNCTION__, elf->sym_tab,
- elf_uval(elf, elf->sym_tab, sh_size));
- elf_msg(elf, "%s: shdr: str_tab=%p size=0x%" PRIx64 "\n",
- __FUNCTION__, elf->sym_strtab, elf_uval(elf, shdr, sh_size));
-
- elf->sstart = low;
- elf->send = high;
- elf_msg(elf, "%s: symbol map: 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
- __FUNCTION__, elf->sstart, elf->send);
+ break;
}

return 0;
@@ -114,6 +83,101 @@ void elf_set_verbose(struct elf_binary *
elf->verbose = 1;
}
#endif
+
+/* Calculate the required additional kernel space for the elf image */
+void elf_parse_bsdsyms(struct elf_binary *elf, uint64_t pstart)
+{
+ uint64_t sz;
+ const elf_shdr *shdr;
+ int i, type;
+
+ if ( !elf->sym_tab )
+ return;
+
+ pstart = elf_round_up(elf, pstart);
+
+ /* Space to store the size of the elf image */
+ sz = sizeof(uint32_t);
+
+ /* Space for the elf and elf section headers */
+ sz += (elf_uval(elf, elf->ehdr, e_ehsize) +
+ elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize));
+ sz = elf_round_up(elf, sz);
+
+ /* Space for the symbol and string tables. */
+ for ( i = 0; i < elf_shdr_count(elf); i++ )
+ {
+ shdr = elf_shdr_by_index(elf, i);
+ type = elf_uval(elf, (elf_shdr *)shdr, sh_type);
+ if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
+ sz = elf_round_up(elf, sz + elf_uval(elf, shdr, sh_size));
+ }
+
+ elf->bsd_symtab_pstart = pstart;
+ elf->bsd_symtab_pend = pstart + sz;
+}
+
+static void elf_load_bsdsyms(struct elf_binary *elf)
+{
+ elf_ehdr *sym_ehdr;
+ unsigned long sz;
+ char *maxva, *symbase, *symtab_addr;
+ elf_shdr *shdr;
+ int i, type;
+
+ if ( !elf->bsd_symtab_pstart )
+ return;
+
+#define elf_hdr_elm(_elf, _hdr, _elm, _val) \
+do { \
+ if ( elf_64bit(_elf) ) \
+ (_hdr)->e64._elm = _val; \
+ else \
+ (_hdr)->e32._elm = _val; \
+} while ( 0 )
+
+ symbase = elf_get_ptr(elf, elf->bsd_symtab_pstart);
+ symtab_addr = maxva = symbase + sizeof(uint32_t);
+
+ /* Set up Elf header. */
+ sym_ehdr = (elf_ehdr *)symtab_addr;
+ sz = elf_uval(elf, elf->ehdr, e_ehsize);
+ memcpy(sym_ehdr, elf->ehdr, sz);
+ maxva += sz; /* no round up */
+
+ elf_hdr_elm(elf, sym_ehdr, e_phoff, 0);
+ elf_hdr_elm(elf, sym_ehdr, e_shoff, elf_uval(elf, elf->ehdr, e_ehsize));
+ elf_hdr_elm(elf, sym_ehdr, e_phentsize, 0);
+ elf_hdr_elm(elf, sym_ehdr, e_phnum, 0);
+
+ /* Copy Elf section headers. */
+ shdr = (elf_shdr *)maxva;
+ sz = elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize);
+ memcpy(shdr, elf->image + elf_uval(elf, elf->ehdr, e_shoff), sz);
+ maxva = (char *)(long)elf_round_up(elf, (long)maxva + sz);
+
+ for ( i = 0; i < elf_shdr_count(elf); i++ )
+ {
+ type = elf_uval(elf, shdr, sh_type);
+ if ( (type == SHT_STRTAB) || (type == SHT_SYMTAB) )
+ {
+ elf_msg(elf, "%s: shdr %i at 0x%p -> 0x%p\n", __func__, i,
+ elf_section_start(elf, shdr), maxva);
+ sz = elf_uval(elf, shdr, sh_size);
+ memcpy(maxva, elf_section_start(elf, shdr), sz);
+ /* Mangled to be based on ELF header location. */
+ elf_hdr_elm(elf, shdr, sh_offset, maxva - symtab_addr);
+ maxva = (char *)(long)elf_round_up(elf, (long)maxva + sz);
+ }
+ shdr = (elf_shdr *)((long)shdr +
+ (long)elf_uval(elf, elf->ehdr, e_shentsize));
+ }
+
+ /* Write down the actual sym size. */
+ *(uint32_t *)symbase = maxva - symtab_addr;
+
+#undef elf_ehdr_elm
+}

void elf_parse_binary(struct elf_binary *elf)
{
@@ -165,6 +229,8 @@ void elf_load_binary(struct elf_binary *
memcpy(dest, elf->image + offset, filesz);
memset(dest + filesz, 0, memsz - filesz);
}
+
+ elf_load_bsdsyms(elf);
}

void *elf_get_ptr(struct elf_binary *elf, unsigned long addr)
diff -r 5b19839d0365 -r cd51fa91956b xen/common/libelf/libelf-tools.c
--- a/xen/common/libelf/libelf-tools.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/common/libelf/libelf-tools.c Sun Aug 12 14:50:02 2007 -0600
@@ -236,36 +236,6 @@ int elf_phdr_is_loadable(struct elf_bina
uint64_t p_flags = elf_uval(elf, phdr, p_flags);

return ((p_type == PT_LOAD) && (p_flags & (PF_W | PF_X)) != 0);
-}
-
-unsigned long
-elf_copy_ehdr(struct elf_binary *elf, void *dest)
-{
- uint64_t size;
-
- size = elf_uval(elf, elf->ehdr, e_ehsize);
- memcpy(dest, elf->ehdr, size);
- return elf_round_up(elf, (unsigned long)(dest) + size);
-}
-
-unsigned long
-elf_copy_shdr(struct elf_binary *elf, void *dest)
-{
- uint64_t size;
-
- size = elf_shdr_count(elf) * elf_uval(elf, elf->ehdr, e_shentsize);
- memcpy(dest, elf->image + elf_uval(elf, elf->ehdr, e_shoff), size);
- return elf_round_up(elf, (unsigned long)(dest) + size);
-}
-
-unsigned long
-elf_copy_section(struct elf_binary *elf, const elf_shdr *shdr, void *dest)
-{
- uint64_t size;
-
- size = elf_uval(elf, shdr, sh_size);
- memcpy(dest, elf_section_start(elf, shdr), size);
- return elf_round_up(elf, (unsigned long)(dest) + size);
}

/*
diff -r 5b19839d0365 -r cd51fa91956b xen/common/page_alloc.c
--- a/xen/common/page_alloc.c Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/common/page_alloc.c Sun Aug 12 14:50:02 2007 -0600
@@ -91,6 +91,14 @@ custom_param("dma_emergency_pool", parse
#define round_pgdown(_p) ((_p)&PAGE_MASK)
#define round_pgup(_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK)

+#ifndef NDEBUG
+/* Avoid callers relying on allocations returning zeroed pages. */
+#define scrub_page(p) memset((p), 0xc2, PAGE_SIZE)
+#else
+/* For a production build, clear_page() is the fastest way to scrub. */
+#define scrub_page(p) clear_page(p)
+#endif
+
static DEFINE_SPINLOCK(page_scrub_lock);
LIST_HEAD(page_scrub_list);
static unsigned long scrub_pages;
@@ -618,13 +626,13 @@ void __init scrub_heap_pages(void)
{
p = page_to_virt(mfn_to_page(mfn));
memguard_unguard_range(p, PAGE_SIZE);
- clear_page(p);
+ scrub_page(p);
memguard_guard_range(p, PAGE_SIZE);
}
else
{
p = map_domain_page(mfn);
- clear_page(p);
+ scrub_page(p);
unmap_domain_page(p);
}
}
@@ -1018,7 +1026,7 @@ static void page_scrub_softirq(void)
pg = list_entry(ent, struct page_info, list);
ent = ent->prev;
p = map_domain_page(page_to_mfn(pg));
- clear_page(p);
+ scrub_page(p);
unmap_domain_page(p);
free_heap_pages(pfn_dom_zone_type(page_to_mfn(pg)), pg, 0);
}
diff -r 5b19839d0365 -r cd51fa91956b xen/include/asm-powerpc/boot.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/include/asm-powerpc/boot.h Sun Aug 12 14:50:02 2007 -0600
@@ -0,0 +1,46 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2007
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ */
+
+#ifndef _ASM_BOOT_H
+#define _ASM_BOOT_H
+
+/* a collection of interfaces used during boot. */
+
+extern void boot_of_init(ulong, ulong);
+extern void *boot_of_devtree(void);
+extern void boot_of_serial(void *);
+extern void boot_of_finish(void);
+extern int boot_of_mem_avail(int pos, ulong *startpage, ulong *endpage);
+
+extern void parse_multiboot(ulong tags_addr);
+
+extern void memory_init(void);
+
+extern char *xen_cmdline;
+extern ulong dom0_addr;
+extern ulong dom0_len;
+extern char *dom0_cmdline;
+extern ulong initrd_start;
+extern ulong initrd_len;
+
+/* From linker script. */
+extern char builtin_cmdline[];
+
+#endif
diff -r 5b19839d0365 -r cd51fa91956b xen/include/asm-x86/domain.h
--- a/xen/include/asm-x86/domain.h Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/include/asm-x86/domain.h Sun Aug 12 14:50:02 2007 -0600
@@ -77,10 +77,10 @@ struct shadow_domain {
int locker; /* processor which holds the lock */
const char *locker_function; /* Func that took it */
unsigned int opt_flags; /* runtime tunable optimizations on/off */
- struct list_head pinned_shadows;
+ struct list_head pinned_shadows;

/* Memory allocation */
- struct list_head freelists[SHADOW_MAX_ORDER + 1];
+ struct list_head freelists[SHADOW_MAX_ORDER + 1];
struct list_head p2m_freelist;
unsigned int total_pages; /* number of pages allocated */
unsigned int free_pages; /* number of pages on freelists */
@@ -116,7 +116,7 @@ struct hap_domain {
spinlock_t lock;
int locker;
const char *locker_function;
-
+
struct list_head freelist;
unsigned int total_pages; /* number of pages allocated */
unsigned int free_pages; /* number of pages on freelists */
@@ -131,13 +131,13 @@ struct p2m_domain {
spinlock_t lock;
int locker; /* processor which holds the lock */
const char *locker_function; /* Func that took it */
-
+
/* Pages used to construct the p2m */
struct list_head pages;

/* Functions to call to get or free pages for the p2m */
struct page_info * (*alloc_page )(struct domain *d);
- void (*free_page )(struct domain *d,
+ void (*free_page )(struct domain *d,
struct page_info *pg);

/* Highest guest frame that's ever been mapped in the p2m */
@@ -177,6 +177,7 @@ struct paging_domain {
/* log dirty support */
struct log_dirty_domain log_dirty;
};
+
struct paging_vcpu {
/* Pointers to mode-specific entry points. */
struct paging_mode *mode;
@@ -184,9 +185,9 @@ struct paging_vcpu {
unsigned int translate_enabled:1;
/* HVM guest: last emulate was to a pagetable */
unsigned int last_write_was_pt:1;
- /* Translated guest: virtual TLB */
+ /* Translated guest: virtual TLB */
struct shadow_vtlb *vtlb;
- spinlock_t vtlb_lock;
+ spinlock_t vtlb_lock;

/* paging support extension */
struct shadow_vcpu shadow;
@@ -303,7 +304,7 @@ struct arch_vcpu
* shadow refcounts are in use */
pagetable_t shadow_table[4]; /* (MFN) shadow(s) of guest */
pagetable_t monitor_table; /* (MFN) hypervisor PT (for HVM) */
- unsigned long cr3; /* (MA) value to install in HW CR3 */
+ unsigned long cr3; /* (MA) value to install in HW CR3 */

/* Current LDT details. */
unsigned long shadow_ldt_mapcnt;
diff -r 5b19839d0365 -r cd51fa91956b xen/include/asm-x86/hap.h
--- a/xen/include/asm-x86/hap.h Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/include/asm-x86/hap.h Sun Aug 12 14:50:02 2007 -0600
@@ -3,7 +3,7 @@
*
* hardware-assisted paging
* Copyright (c) 2007 Advanced Micro Devices (Wei Huang)
- *
+ *
* Parts of this code are Copyright (c) 2006 by XenSource Inc.
* Parts of this code are Copyright (c) 2006 by Michael A Fetterman
* Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
diff -r 5b19839d0365 -r cd51fa91956b xen/include/asm-x86/mach-es7000/mach_mpparse.h
--- a/xen/include/asm-x86/mach-es7000/mach_mpparse.h Sun Aug 12 12:19:13 2007 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#ifndef __ASM_MACH_MPPARSE_H
-#define __ASM_MACH_MPPARSE_H
-
-#include <xen/acpi.h>
-
-extern int parse_unisys_oem(char *oemptr);
-extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
-
-static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
- char *productid)
-{
- if (mpc->mpc_oemptr) {
- struct mp_config_oemtable *oem_table =
- (struct mp_config_oemtable *)(long)mpc->mpc_oemptr;
- if (!strncmp(oem, "UNISYS", 6))
- return parse_unisys_oem((char *)oem_table);
- }
- return 0;
-}
-
-static inline int es7000_check_dsdt(void)
-{
- struct acpi_table_header *header = NULL;
- if(!acpi_get_table_header_early(ACPI_DSDT, &header))
- acpi_table_print(header, 0);
- if (!strncmp(header->oem_id, "UNISYS", 6))
- return 1;
- return 0;
-}
-
-/* Hook from generic ACPI tables.c */
-static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
-{
- unsigned long oem_addr;
- if (!find_unisys_acpi_oem_table(&oem_addr)) {
- if (es7000_check_dsdt())
- return parse_unisys_oem((char *)oem_addr);
- else
- return 1;
- }
- return 0;
-}
-
-
-#endif /* __ASM_MACH_MPPARSE_H */
diff -r 5b19839d0365 -r cd51fa91956b xen/include/asm-x86/msr.h
--- a/xen/include/asm-x86/msr.h Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/include/asm-x86/msr.h Sun Aug 12 14:50:02 2007 -0600
@@ -239,6 +239,11 @@ static inline void write_efer(__u64 val)
#define MSR_K8_MC4_STATUS 0x411
#define MSR_K8_MC4_ADDR 0x412
#define MSR_K8_MC4_MISC 0x413
+
+#define MSR_K8_MC5_CTL 0x414
+#define MSR_K8_MC5_STATUS 0x415
+#define MSR_K8_MC5_ADDR 0x416
+#define MSR_K8_MC5_MISC 0x417

/* Pentium IV performance counter MSRs */
#define MSR_P4_BPU_PERFCTR0 0x300
diff -r 5b19839d0365 -r cd51fa91956b xen/include/public/libelf.h
--- a/xen/include/public/libelf.h Sun Aug 12 12:19:13 2007 -0600
+++ b/xen/include/public/libelf.h Sun Aug 12 14:50:02 2007 -0600
@@ -65,11 +65,12 @@ struct elf_binary {

/* loaded to */
char *dest;
- uint64_t sstart;
- uint64_t send;
uint64_t pstart;
uint64_t pend;
uint64_t reloc_offset;
+
+ uint64_t bsd_symtab_pstart;
+ uint64_t bsd_symtab_pend;

#ifndef __XEN__
/* misc */
@@ -150,11 +151,6 @@ int elf_is_elfbinary(const void *image);
int elf_is_elfbinary(const void *image);
int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr);

-unsigned long elf_copy_ehdr(struct elf_binary *elf, void *dest);
-unsigned long elf_copy_shdr(struct elf_binary *elf, void *dest);
-unsigned long elf_copy_section(struct elf_binary *elf,
- const elf_shdr *shdr, void *dest);
-
/* ------------------------------------------------------------------------ */
/* xc_libelf_loader.c */

@@ -170,6 +166,8 @@ void elf_load_binary(struct elf_binary *

void *elf_get_ptr(struct elf_binary *elf, unsigned long addr);
uint64_t elf_lookup_addr(struct elf_binary *elf, const char *symbol);
+
+void elf_parse_bsdsyms(struct elf_binary *elf, uint64_t pstart); /* private */

/* ------------------------------------------------------------------------ */
/* xc_libelf_relocate.c */
@@ -221,8 +219,7 @@ struct elf_dom_parms {
/* calculated */
uint64_t virt_offset;
uint64_t virt_kstart;
- uint64_t virt_kend; /* end of kernel image */
- uint64_t virt_end; /* end of kernel symtab (== virt_kend if none) */
+ uint64_t virt_kend;
};

static inline void elf_xen_feature_set(int nr, uint32_t * addr)
@@ -245,7 +242,4 @@ int elf_xen_parse(struct elf_binary *elf
int elf_xen_parse(struct elf_binary *elf,
struct elf_dom_parms *parms);

-int elf_xen_dom_load_binary(struct elf_binary *elf,
- struct elf_dom_parms *parms);
-
#endif /* __XC_LIBELF__ */
diff -r 5b19839d0365 -r cd51fa91956b xen/include/xen/multiboot2.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/include/xen/multiboot2.h Sun Aug 12 14:50:02 2007 -0600
@@ -0,0 +1,99 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2006, 2007
+ *
+ * Authors: Hollis Blanchard <hollisb@us.ibm.com>
+ *
+ */
+
+#ifndef _MULTIBOOT2_H_
+#define _MULTIBOOT2_H_
+
+/* How many bytes from the start of the file we search for the header. */
+#define MB2_HEADER_SEARCH 8192
+
+/* The magic field should contain this. */
+#define MB2_HEADER_MAGIC 0xe85250d6
+
+/* Passed from the bootloader to the kernel. */
+#define MB2_BOOTLOADER_MAGIC 0x36d76289
+
+#include <stdint.h>
+
+#define for_each_tag(_tag, _tags) \
+ for ((_tag) = (_tags); \
+ ((_tag)->key != MB2_TAG_END && (_tag)->key != 0); \
+ (_tag) = (void *)(_tag) + (_tag)->len)
+
+typedef uint32_t mb2_word;
+
+struct mb2_header
+{
+ uint32_t magic;
+};
+
+struct mb2_tag_header
+{
+ uint32_t key;
+ uint32_t len;
+};
+
+#define MB2_TAG_START 1
+struct mb2_tag_start
+{
+ struct mb2_tag_header header;
+ mb2_word size; /* Total size of all mb2 tags. */
+};
+
+#define MB2_TAG_NAME 2
+struct mb2_tag_name
+{
+ struct mb2_tag_header header;
+ char name[1];
+};
+
+#define MB2_TAG_MODULE 3
+struct mb2_tag_module
+{
+ struct mb2_tag_header header;
+ mb2_word addr;
+ mb2_word size;
+ unsigned char type[36];
+ unsigned char cmdline[1];
+};
+
+#define MB2_TAG_MEMORY 4
+struct mb2_tag_memory
+{
+ struct mb2_tag_header header;
+ mb2_word addr;
+ mb2_word size;
+ mb2_word type;
+};
+
+#define MB2_TAG_UNUSED 5
+struct mb2_tag_unused
+{
+ struct mb2_tag_header header;
+};
+
+#define MB2_TAG_END 0xffff
+struct mb2_tag_end
+{
+ struct mb2_tag_header header;
+};
+
+#endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog
[xen-unstable] merge with xen-unstable.hg [ In reply to ]
# HG changeset patch
# User Alex Williamson <alex.williamson@hp.com>
# Date 1187282853 21600
# Node ID 778985f246a01b054378cb551069b6455fc1159a
# Parent b5dbf184df6c643ab524945c3de207c59eaf08c5
# Parent 256160ff19b74057f5819af20d68e6e3388c80e3
merge with xen-unstable.hg
---
tools/libfsimage/fat/fsys_fat.c | 6
tools/libxc/xc_domain_restore.c | 37
tools/libxc/xc_evtchn.c | 7
tools/libxc/xc_linux.c | 30
tools/libxc/xc_solaris.c | 30
tools/libxc/xenctrl.h | 134 +-
tools/python/xen/util/acmpolicy.py | 21
tools/python/xen/util/security.py | 64 +
tools/python/xen/xend/XendCheckpoint.py | 3
tools/python/xen/xend/XendDomainInfo.py | 110 ++
tools/python/xen/xend/server/DevController.py | 71 +
tools/python/xen/xend/server/blkif.py | 18
tools/python/xen/xm/main.py | 5
tools/xm-test/configure.ac | 7
tools/xm-test/lib/XmTestLib/NetConfig.py | 14
tools/xm-test/lib/XmTestLib/XenDevice.py | 2
tools/xm-test/lib/XmTestLib/config.py.in | 1
unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c | 3
xen/acm/acm_policy.c | 12
xen/arch/x86/acpi/boot.c | 15
xen/arch/x86/hvm/hvm.c | 185 +++-
xen/arch/x86/hvm/svm/svm.c | 538 ++---------
xen/arch/x86/hvm/svm/vmcb.c | 20
xen/arch/x86/hvm/vioapic.c | 4
xen/arch/x86/hvm/vmx/vmcs.c | 82 +
xen/arch/x86/hvm/vmx/vmx.c | 588 +++----------
xen/arch/x86/hvm/vmx/x86_32/exits.S | 2
xen/arch/x86/hvm/vmx/x86_64/exits.S | 2
xen/arch/x86/mm.c | 4
xen/arch/x86/mm/hap/guest_walk.c | 2
xen/arch/x86/mm/hap/hap.c | 43
xen/arch/x86/mm/shadow/common.c | 4
xen/arch/x86/mm/shadow/multi.c | 27
xen/arch/x86/physdev.c | 19
xen/arch/x86/setup.c | 25
xen/arch/x86/string.c | 22
xen/arch/x86/traps.c | 28
xen/arch/x86/x86_32/asm-offsets.c | 2
xen/arch/x86/x86_32/traps.c | 7
xen/arch/x86/x86_64/asm-offsets.c | 2
xen/arch/x86/x86_64/compat/traps.c | 21
xen/arch/x86/x86_64/traps.c | 4
xen/common/domctl.c | 8
xen/common/page_alloc.c | 9
xen/common/xencomm.c | 203 ++--
xen/drivers/char/console.c | 14
xen/drivers/video/Makefile | 12
xen/drivers/video/vesa.c | 307 ++++++
xen/drivers/video/vga.c | 112 +-
xen/include/asm-x86/hvm/hvm.h | 76 -
xen/include/asm-x86/hvm/support.h | 4
xen/include/asm-x86/hvm/svm/asid.h | 14
xen/include/asm-x86/hvm/svm/vmcb.h | 5
xen/include/asm-x86/hvm/vcpu.h | 13
xen/include/asm-x86/hvm/vmx/vmcs.h | 6
xen/include/asm-x86/hvm/vmx/vmx.h | 4
xen/include/public/arch-x86/xen-x86_32.h | 36
xen/include/xen/vga.h | 8
xen/include/xen/xencomm.h | 15
59 files changed, 1607 insertions(+), 1460 deletions(-)

diff -r b5dbf184df6c -r 778985f246a0 tools/libfsimage/fat/fsys_fat.c
--- a/tools/libfsimage/fat/fsys_fat.c Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/libfsimage/fat/fsys_fat.c Thu Aug 16 10:47:33 2007 -0600
@@ -228,15 +228,15 @@ fat_read (fsi_file_t *ffi, char *buf, in
if (!devread (ffi, sector, 0, FAT_CACHE_SIZE, (char*) FAT_BUF))
return 0;
}
- next_cluster = * (unsigned long *) (FAT_BUF + (cached_pos >> 1));
+ next_cluster = ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[0];
if (FAT_SUPER->fat_size == 3)
{
if (cached_pos & 1)
next_cluster >>= 4;
next_cluster &= 0xFFF;
}
- else if (FAT_SUPER->fat_size == 4)
- next_cluster &= 0xFFFF;
+ else if (FAT_SUPER->fat_size > 4)
+ next_cluster |= ((__u16 *) (FAT_BUF + (cached_pos >> 1)))[1] << 16;

if (next_cluster >= FAT_SUPER->clust_eof_marker)
return ret;
diff -r b5dbf184df6c -r 778985f246a0 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/libxc/xc_domain_restore.c Thu Aug 16 10:47:33 2007 -0600
@@ -272,7 +272,8 @@ int xc_domain_restore(int xc_handle, int
/* The new domain's shared-info frame number. */
unsigned long shared_info_frame;
unsigned char shared_info_page[PAGE_SIZE]; /* saved contents from file */
- shared_info_t *shared_info = (shared_info_t *)shared_info_page;
+ shared_info_t *old_shared_info = (shared_info_t *)shared_info_page;
+ shared_info_t *new_shared_info;

/* A copy of the CPU context of the guest. */
vcpu_guest_context_t ctxt;
@@ -285,9 +286,6 @@ int xc_domain_restore(int xc_handle, int

/* Types of the pfns in the current region */
unsigned long region_pfn_type[MAX_BATCH_SIZE];
-
- /* A temporary mapping, and a copy, of one frame of guest memory. */
- unsigned long *page = NULL;

/* A copy of the pfn-to-mfn table frame list. */
xen_pfn_t *p2m_frame_list = NULL;
@@ -1084,17 +1082,30 @@ int xc_domain_restore(int xc_handle, int
goto out;
}

+ /* Restore contents of shared-info page. No checking needed. */
+ new_shared_info = xc_map_foreign_range(
+ xc_handle, dom, PAGE_SIZE, PROT_WRITE, shared_info_frame);
+
+ /* restore saved vcpu_info and arch specific info */
+ memcpy(&new_shared_info->vcpu_info,
+ &old_shared_info->vcpu_info,
+ sizeof(new_shared_info->vcpu_info));
+ memcpy(&new_shared_info->arch,
+ &old_shared_info->arch,
+ sizeof(new_shared_info->arch));
+
/* clear any pending events and the selector */
- memset(&(shared_info->evtchn_pending[0]), 0,
- sizeof (shared_info->evtchn_pending));
+ memset(&(new_shared_info->evtchn_pending[0]), 0,
+ sizeof (new_shared_info->evtchn_pending));
for ( i = 0; i < MAX_VIRT_CPUS; i++ )
- shared_info->vcpu_info[i].evtchn_pending_sel = 0;
-
- /* Copy saved contents of shared-info page. No checking needed. */
- page = xc_map_foreign_range(
- xc_handle, dom, PAGE_SIZE, PROT_WRITE, shared_info_frame);
- memcpy(page, shared_info, PAGE_SIZE);
- munmap(page, PAGE_SIZE);
+ new_shared_info->vcpu_info[i].evtchn_pending_sel = 0;
+
+ /* mask event channels */
+ memset(&(new_shared_info->evtchn_mask[0]), 0xff,
+ sizeof (new_shared_info->evtchn_mask));
+
+ /* leave wallclock time. set by hypervisor */
+ munmap(new_shared_info, PAGE_SIZE);

/* Uncanonicalise the pfn-to-mfn table frame-number list. */
for ( i = 0; i < P2M_FL_ENTRIES; i++ )
diff -r b5dbf184df6c -r 778985f246a0 tools/libxc/xc_evtchn.c
--- a/tools/libxc/xc_evtchn.c Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/libxc/xc_evtchn.c Thu Aug 16 10:47:33 2007 -0600
@@ -33,9 +33,10 @@ static int do_evtchn_op(int xc_handle, i
}


-int xc_evtchn_alloc_unbound(int xc_handle,
- uint32_t dom,
- uint32_t remote_dom)
+evtchn_port_or_error_t
+xc_evtchn_alloc_unbound(int xc_handle,
+ uint32_t dom,
+ uint32_t remote_dom)
{
int rc;
struct evtchn_alloc_unbound arg = {
diff -r b5dbf184df6c -r 778985f246a0 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/libxc/xc_linux.c Thu Aug 16 10:47:33 2007 -0600
@@ -254,7 +254,8 @@ int xc_evtchn_notify(int xce_handle, evt
return ioctl(xce_handle, IOCTL_EVTCHN_NOTIFY, &notify);
}

-evtchn_port_t xc_evtchn_bind_unbound_port(int xce_handle, int domid)
+evtchn_port_or_error_t
+xc_evtchn_bind_unbound_port(int xce_handle, int domid)
{
struct ioctl_evtchn_bind_unbound_port bind;

@@ -263,8 +264,9 @@ evtchn_port_t xc_evtchn_bind_unbound_por
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
}

-evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
- evtchn_port_t remote_port)
+evtchn_port_or_error_t
+xc_evtchn_bind_interdomain(int xce_handle, int domid,
+ evtchn_port_t remote_port)
{
struct ioctl_evtchn_bind_interdomain bind;

@@ -274,6 +276,16 @@ evtchn_port_t xc_evtchn_bind_interdomain
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
}

+evtchn_port_or_error_t
+xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
+{
+ struct ioctl_evtchn_bind_virq bind;
+
+ bind.virq = virq;
+
+ return ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind);
+}
+
int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
{
struct ioctl_evtchn_unbind unbind;
@@ -281,15 +293,6 @@ int xc_evtchn_unbind(int xce_handle, evt
unbind.port = port;

return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind);
-}
-
-evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
-{
- struct ioctl_evtchn_bind_virq bind;
-
- bind.virq = virq;
-
- return ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind);
}

static int dorw(int fd, char *data, size_t size, int do_write)
@@ -317,7 +320,8 @@ static int dorw(int fd, char *data, size
return 0;
}

-evtchn_port_t xc_evtchn_pending(int xce_handle)
+evtchn_port_or_error_t
+xc_evtchn_pending(int xce_handle)
{
evtchn_port_t port;

diff -r b5dbf184df6c -r 778985f246a0 tools/libxc/xc_solaris.c
--- a/tools/libxc/xc_solaris.c Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/libxc/xc_solaris.c Thu Aug 16 10:47:33 2007 -0600
@@ -165,7 +165,8 @@ int xc_evtchn_notify(int xce_handle, evt
return ioctl(xce_handle, IOCTL_EVTCHN_NOTIFY, &notify);
}

-evtchn_port_t xc_evtchn_bind_unbound_port(int xce_handle, int domid)
+evtchn_port_or_error_t
+xc_evtchn_bind_unbound_port(int xce_handle, int domid)
{
struct ioctl_evtchn_bind_unbound_port bind;

@@ -174,8 +175,9 @@ evtchn_port_t xc_evtchn_bind_unbound_por
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
}

-evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
- evtchn_port_t remote_port)
+evtchn_port_or_error_t
+xc_evtchn_bind_interdomain(int xce_handle, int domid,
+ evtchn_port_t remote_port)
{
struct ioctl_evtchn_bind_interdomain bind;

@@ -185,6 +187,16 @@ evtchn_port_t xc_evtchn_bind_interdomain
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
}

+evtchn_port_or_error_t
+xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
+{
+ struct ioctl_evtchn_bind_virq bind;
+
+ bind.virq = virq;
+
+ return ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind);
+}
+
int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
{
struct ioctl_evtchn_unbind unbind;
@@ -192,15 +204,6 @@ int xc_evtchn_unbind(int xce_handle, evt
unbind.port = port;

return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind);
-}
-
-evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
-{
- struct ioctl_evtchn_bind_virq bind;
-
- bind.virq = virq;
-
- return ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind);
}

static int dorw(int fd, char *data, size_t size, int do_write)
@@ -228,7 +231,8 @@ static int dorw(int fd, char *data, size
return 0;
}

-evtchn_port_t xc_evtchn_pending(int xce_handle)
+evtchn_port_or_error_t
+xc_evtchn_pending(int xce_handle)
{
evtchn_port_t port;

diff -r b5dbf184df6c -r 778985f246a0 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/libxc/xenctrl.h Thu Aug 16 10:47:33 2007 -0600
@@ -449,6 +449,9 @@ int xc_domain_setdebugging(int xc_handle
* EVENT CHANNEL FUNCTIONS
*/

+/* A port identifier is guaranteed to fit in 31 bits. */
+typedef int evtchn_port_or_error_t;
+
/**
* This function allocates an unbound port. Ports are named endpoints used for
* interdomain communication. This function is most useful in opening a
@@ -463,12 +466,77 @@ int xc_domain_setdebugging(int xc_handle
* @parm remote_dom the ID of the domain who will later bind
* @return allocated port (in @dom) on success, -1 on failure
*/
-int xc_evtchn_alloc_unbound(int xc_handle,
- uint32_t dom,
- uint32_t remote_dom);
+evtchn_port_or_error_t
+xc_evtchn_alloc_unbound(int xc_handle,
+ uint32_t dom,
+ uint32_t remote_dom);

int xc_evtchn_reset(int xc_handle,
uint32_t dom);
+
+/*
+ * Return a handle to the event channel driver, or -1 on failure, in which case
+ * errno will be set appropriately.
+ */
+int xc_evtchn_open(void);
+
+/*
+ * Close a handle previously allocated with xc_evtchn_open().
+ */
+int xc_evtchn_close(int xce_handle);
+
+/*
+ * Return an fd that can be select()ed on for further calls to
+ * xc_evtchn_pending().
+ */
+int xc_evtchn_fd(int xce_handle);
+
+/*
+ * Notify the given event channel. Returns -1 on failure, in which case
+ * errno will be set appropriately.
+ */
+int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
+
+/*
+ * Returns a new event port awaiting interdomain connection from the given
+ * domain ID, or -1 on failure, in which case errno will be set appropriately.
+ */
+evtchn_port_or_error_t
+xc_evtchn_bind_unbound_port(int xce_handle, int domid);
+
+/*
+ * Returns a new event port bound to the remote port for the given domain ID,
+ * or -1 on failure, in which case errno will be set appropriately.
+ */
+evtchn_port_or_error_t
+xc_evtchn_bind_interdomain(int xce_handle, int domid,
+ evtchn_port_t remote_port);
+
+/*
+ * Bind an event channel to the given VIRQ. Returns the event channel bound to
+ * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
+ */
+evtchn_port_or_error_t
+xc_evtchn_bind_virq(int xce_handle, unsigned int virq);
+
+/*
+ * Unbind the given event channel. Returns -1 on failure, in which case errno
+ * will be set appropriately.
+ */
+int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
+
+/*
+ * Return the next event channel to become pending, or -1 on failure, in which
+ * case errno will be set appropriately.
+ */
+evtchn_port_or_error_t
+xc_evtchn_pending(int xce_handle);
+
+/*
+ * Unmask the given event channel. Returns -1 on failure, in which case errno
+ * will be set appropriately.
+ */
+int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);

int xc_physdev_pci_access_modify(int xc_handle,
uint32_t domid,
@@ -699,66 +767,6 @@ int xc_version(int xc_handle, int cmd, v

int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size);

-/*
- * Return a handle to the event channel driver, or -1 on failure, in which case
- * errno will be set appropriately.
- */
-int xc_evtchn_open(void);
-
-/*
- * Close a handle previously allocated with xc_evtchn_open().
- */
-int xc_evtchn_close(int xce_handle);
-
-/*
- * Return an fd that can be select()ed on for further calls to
- * xc_evtchn_pending().
- */
-int xc_evtchn_fd(int xce_handle);
-
-/*
- * Notify the given event channel. Returns -1 on failure, in which case
- * errno will be set appropriately.
- */
-int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
-
-/*
- * Returns a new event port awaiting interdomain connection from the given
- * domain ID, or -1 on failure, in which case errno will be set appropriately.
- */
-evtchn_port_t xc_evtchn_bind_unbound_port(int xce_handle, int domid);
-
-/*
- * Returns a new event port bound to the remote port for the given domain ID,
- * or -1 on failure, in which case errno will be set appropriately.
- */
-evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
- evtchn_port_t remote_port);
-
-/*
- * Unbind the given event channel. Returns -1 on failure, in which case errno
- * will be set appropriately.
- */
-int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
-
-/*
- * Bind an event channel to the given VIRQ. Returns the event channel bound to
- * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
- */
-evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq);
-
-/*
- * Return the next event channel to become pending, or -1 on failure, in which
- * case errno will be set appropriately.
- */
-evtchn_port_t xc_evtchn_pending(int xce_handle);
-
-/*
- * Unmask the given event channel. Returns -1 on failure, in which case errno
- * will be set appropriately.
- */
-int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);
-
/**************************
* GRANT TABLE OPERATIONS *
**************************/
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/util/acmpolicy.py
--- a/tools/python/xen/util/acmpolicy.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/util/acmpolicy.py Thu Aug 16 10:47:33 2007 -0600
@@ -191,20 +191,21 @@ class ACMPolicy(XSPolicy):
acmpol_old.policy_get_virtualmachinelabel_names_sorted()
del_array = ""
chg_array = ""
+
for o in oldvmnames:
if o not in newvmnames:
- old_idx = oldvmnames.index(o) + 1 # for _NULL_LABEL_
+ old_idx = oldvmnames.index(o)
if vmlabel_map.has_key(o):
#not a deletion, but a renaming
new = vmlabel_map[o]
- new_idx = newvmnames.index(new) + 1 # for _NULL_LABEL_
+ new_idx = newvmnames.index(new)
chg_array += struct.pack("ii", old_idx, new_idx)
else:
del_array += struct.pack("i", old_idx)
for v in newvmnames:
if v in oldvmnames:
- old_idx = oldvmnames.index(v) + 1 # for _NULL_LABEL_
- new_idx = newvmnames.index(v) + 1 # for _NULL_LABEL_
+ old_idx = oldvmnames.index(v)
+ new_idx = newvmnames.index(v)
if old_idx != new_idx:
chg_array += struct.pack("ii", old_idx, new_idx)

@@ -348,7 +349,7 @@ class ACMPolicy(XSPolicy):
ssidref = xsconstants.INVALID_SSIDREF
names = self.policy_get_virtualmachinelabel_names_sorted()
try:
- vmidx = names.index(vm_label) + 1 # for _NULL_LABEL_
+ vmidx = names.index(vm_label)
ssidref = (vmidx << 16) | vmidx
except:
pass
@@ -618,6 +619,9 @@ class ACMPolicy(XSPolicy):
vmnames.remove(bootstrap)
vmnames.sort()
vmnames.insert(0, bootstrap)
+ if ACM_LABEL_UNLABELED in vmnames:
+ vmnames.remove(ACM_LABEL_UNLABELED)
+ vmnames.insert(0, ACM_LABEL_UNLABELED)
return vmnames

def policy_get_virtualmachinelabel_names_sorted(self):
@@ -625,7 +629,10 @@ class ACMPolicy(XSPolicy):
label will be the first one in that list, followed
by an alphabetically sorted list of VM label names """
vmnames = self.policy_get_virtualmachinelabel_names()
- return self.policy_sort_virtualmachinelabel_names(vmnames)
+ res = self.policy_sort_virtualmachinelabel_names(vmnames)
+ if res[0] != ACM_LABEL_UNLABELED:
+ res.insert(0, ACM_LABEL_UNLABELED)
+ return res

def policy_get_virtualmachinelabels(self):
""" Get a list of all virtual machine labels in this policy """
@@ -906,7 +913,7 @@ class ACMPolicy(XSPolicy):
allvmtypes = self.policy_get_virtualmachinelabel_names_sorted()
except:
return None
- return allvmtypes[chwall_ref-1] # skip _NULL_LABEL_
+ return allvmtypes[chwall_ref]

def policy_get_domain_label_formatted(self, domid):
label = self.policy_get_domain_label(domid)
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/util/security.py
--- a/tools/python/xen/util/security.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/util/security.py Thu Aug 16 10:47:33 2007 -0600
@@ -838,13 +838,28 @@ def set_resource_label_xapi(resource, re


def is_resource_in_use(resource):
- """ Investigate all running domains whether they use this device """
+ """
+ Domain-0 'owns' resources of type 'VLAN', the rest are owned by
+ the guests.
+ """
from xen.xend import XendDomain
- dominfos = XendDomain.instance().list('all')
lst = []
- for dominfo in dominfos:
- if is_resource_in_use_by_dom(dominfo, resource):
- lst.append(dominfo)
+ if resource.startswith('vlan'):
+ from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
+ curpol = XSPolicyAdminInstance().get_loaded_policy()
+ policytype, label, policy = get_res_label(resource)
+ if curpol and \
+ policytype == xsconstants.ACM_POLICY_ID and \
+ policy == curpol.get_name() and \
+ label in curpol.policy_get_resourcelabel_names():
+ # VLAN is in use.
+ lst.append(XendDomain.instance().
+ get_vm_by_uuid(XendDomain.DOM0_UUID))
+ else:
+ dominfos = XendDomain.instance().list('all')
+ for dominfo in dominfos:
+ if is_resource_in_use_by_dom(dominfo, resource):
+ lst.append(dominfo)
return lst

def devices_equal(res1, res2, mustexist=True):
@@ -892,6 +907,10 @@ def get_domain_resources(dominfo):
if sec_lab:
resources[typ].append(sec_lab)
else:
+ # !!! This should really get the label of the domain
+ # or at least a resource label that has the same STE type
+ # as the domain has
+ from xen.util.acmpolicy import ACM_LABEL_UNLABELED
resources[typ].append("%s:%s:%s" %
(xsconstants.ACM_POLICY_ID,
active_policy,
@@ -924,7 +943,8 @@ def resources_compatible_with_vmlabel(xs


def __resources_compatible_with_vmlabel(xspol, dominfo, vmlabel,
- access_control):
+ access_control,
+ is_policy_update=False):
"""
Check whether the resources' labels are compatible with the
given VM label. The access_control parameter provides a
@@ -955,15 +975,23 @@ def __resources_compatible_with_vmlabel(
elif key in [ 'vif' ]:
for xapi_label in value:
label = xapi_label.split(":")
- if not collect_labels(reslabels, label, polname):
- return False
+ from xen.util.acmpolicy import ACM_LABEL_UNLABELED
+ if not (is_policy_update and \
+ label[2] == ACM_LABEL_UNLABELED):
+ if not collect_labels(reslabels, label, polname):
+ return False
else:
log.error("Unhandled device type: %s" % key)
return False

# Check that all resource labes have a common STE type with the
# vmlabel
- rc = xspol.policy_check_vmlabel_against_reslabels(vmlabel, reslabels)
+ if len(reslabels) > 0:
+ rc = xspol.policy_check_vmlabel_against_reslabels(vmlabel, reslabels)
+ else:
+ rc = True
+ log.info("vmlabel=%s, reslabels=%s, rc=%s" %
+ (vmlabel, reslabels, str(rc)))
return rc;

def set_resource_label(resource, policytype, policyref, reslabel, \
@@ -1234,11 +1262,12 @@ def change_acm_policy(bin_pol, del_array
compatible = __resources_compatible_with_vmlabel(new_acmpol,
dominfo,
new_vmlabel,
- access_control)
+ access_control,
+ is_policy_update=True)
log.info("Domain %s with new label '%s' can access its "
"resources? : %s" %
(name, new_vmlabel, str(compatible)))
- log.info("VM labels in new domain: %s" %
+ log.info("VM labels in new policy: %s" %
new_acmpol.policy_get_virtualmachinelabel_names())
if not compatible:
return (-xsconstants.XSERR_RESOURCE_ACCESS, "")
@@ -1252,11 +1281,16 @@ def change_acm_policy(bin_pol, del_array
sec_lab, new_seclab = labels
if sec_lab != new_seclab:
log.info("Updating domain %s to new label '%s'." % \
- (sec_lab, new_seclab))
+ (dominfo.getName(), new_seclab))
# This better be working!
- dominfo.set_security_label(new_seclab,
- sec_lab,
- new_acmpol)
+ res = dominfo.set_security_label(new_seclab,
+ sec_lab,
+ new_acmpol,
+ cur_acmpol)
+ if res[0] != xsconstants.XSERR_SUCCESS:
+ log.info("ERROR: Could not chg label on domain %s: %s" %
+ (dominfo.getName(),
+ xsconstants.xserr2string(-int(res[0]))))
finally:
log.info("----------------------------------------------")
mapfile_unlock()
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/xend/XendCheckpoint.py Thu Aug 16 10:47:33 2007 -0600
@@ -98,6 +98,9 @@ def save(fd, dominfo, network, live, dst
log.info("Domain %d suspended.", dominfo.getDomid())
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP3,
domain_name)
+ if hvm:
+ dominfo.image.saveDeviceModel()
+
tochild.write("done\n")
tochild.flush()
log.debug('Written done')
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py Thu Aug 16 10:47:33 2007 -0600
@@ -558,9 +558,64 @@ class XendDomainInfo:
for devclass in XendDevices.valid_devices():
self.getDeviceController(devclass).waitForDevices()

- def destroyDevice(self, deviceClass, devid, force = False):
- log.debug("dev = %s", devid)
- return self.getDeviceController(deviceClass).destroyDevice(devid, force)
+ def destroyDevice(self, deviceClass, devid, force = False, rm_cfg = False):
+ log.debug("XendDomainInfo.destroyDevice: deviceClass = %s, device = %s",
+ deviceClass, devid)
+
+ if rm_cfg:
+ # Convert devid to device number. A device number is
+ # needed to remove its configuration.
+ dev = self.getDeviceController(deviceClass).convertToDeviceNumber(devid)
+
+ # Save current sxprs. A device number and a backend
+ # path are needed to remove its configuration but sxprs
+ # do not have those after calling destroyDevice.
+ sxprs = self.getDeviceSxprs(deviceClass)
+
+ rc = None
+ if self.domid is not None:
+ rc = self.getDeviceController(deviceClass).destroyDevice(devid, force)
+ if not force and rm_cfg:
+ # The backend path, other than the device itself,
+ # has to be passed because its accompanied frontend
+ # path may be void until its removal is actually
+ # issued. It is probable because destroyDevice is
+ # issued first.
+ for dev_num, dev_info in sxprs:
+ dev_num = int(dev_num)
+ if dev_num == dev:
+ for x in dev_info:
+ if x[0] == 'backend':
+ backend = x[1]
+ break
+ break
+ self._waitForDevice_destroy(deviceClass, devid, backend)
+
+ if rm_cfg:
+ if deviceClass == 'vif':
+ if self.domid is not None:
+ for dev_num, dev_info in sxprs:
+ dev_num = int(dev_num)
+ if dev_num == dev:
+ for x in dev_info:
+ if x[0] == 'mac':
+ mac = x[1]
+ break
+ break
+ dev_info = self.getDeviceInfo_vif(mac)
+ else:
+ _, dev_info = sxprs[dev]
+ else: # 'vbd' or 'tap'
+ dev_info = self.getDeviceInfo_vbd(dev)
+ if dev_info is None:
+ return rc
+
+ dev_uuid = sxp.child_value(dev_info, 'uuid')
+ del self.info['devices'][dev_uuid]
+ self.info['%s_refs' % deviceClass].remove(dev_uuid)
+ xen.xend.XendDomain.instance().managed_config_save(self)
+
+ return rc

def getDeviceSxprs(self, deviceClass):
if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
@@ -573,6 +628,23 @@ class XendDomainInfo:
sxprs.append([dev_num, dev_info])
dev_num += 1
return sxprs
+
+ def getDeviceInfo_vif(self, mac):
+ for dev_type, dev_info in self.info.all_devices_sxpr():
+ if dev_type != 'vif':
+ continue
+ if mac == sxp.child_value(dev_info, 'mac'):
+ return dev_info
+
+ def getDeviceInfo_vbd(self, devid):
+ for dev_type, dev_info in self.info.all_devices_sxpr():
+ if dev_type != 'vbd' and dev_type != 'tap':
+ continue
+ dev = sxp.child_value(dev_info, 'dev')
+ dev = dev.split(':')[0]
+ dev = self.getDeviceController(dev_type).convertToDeviceNumber(dev)
+ if devid == dev:
+ return dev_info


def setMemoryTarget(self, target):
@@ -1112,8 +1184,6 @@ class XendDomainInfo:
self._clearRestart()

if reason == 'suspend':
- if self._stateGet() != DOM_STATE_SUSPENDED:
- self.image.saveDeviceModel()
self._stateSet(DOM_STATE_SUSPENDED)
# Don't destroy the domain. XendCheckpoint will do
# this once it has finished. However, stop watching
@@ -1321,6 +1391,10 @@ class XendDomainInfo:
deviceClass, config = self.info['devices'].get(dev_uuid)
self._waitForDevice(deviceClass, config['devid'])

+ def _waitForDevice_destroy(self, deviceClass, devid, backpath):
+ return self.getDeviceController(deviceClass).waitForDevice_destroy(
+ devid, backpath)
+
def _reconfigureDevice(self, deviceClass, devid, devconfig):
return self.getDeviceController(deviceClass).reconfigureDevice(
devid, devconfig)
@@ -2187,11 +2261,18 @@ class XendDomainInfo:
return self.metrics.get_uuid();


- def get_security_label(self):
+ def get_security_label(self, xspol=None):
+ """
+ Get the security label of a domain
+ @param xspol The policy to use when converting the ssid into
+ a label; only to be passed during the updating
+ of the policy
+ """
domid = self.getDomid()

- from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
- xspol = XSPolicyAdminInstance().get_loaded_policy()
+ if not xspol:
+ from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
+ xspol = XSPolicyAdminInstance().get_loaded_policy()

if domid == 0:
if xspol:
@@ -2202,7 +2283,8 @@ class XendDomainInfo:
label = self.info.get('security_label', '')
return label

- def set_security_label(self, seclab, old_seclab, xspol=None):
+ def set_security_label(self, seclab, old_seclab, xspol=None,
+ xspol_old=None):
"""
Set the security label of a domain from its old to
a new value.
@@ -2213,6 +2295,8 @@ class XendDomainInfo:
@param xspol An optional policy under which this
update should be done. If not given,
then the current active policy is used.
+ @param xspol_old The old policy; only to be passed during
+ the updating of a policy
@return Returns return code, a string with errors from
the hypervisor's operation, old label of the
domain
@@ -2223,6 +2307,7 @@ class XendDomainInfo:
new_ssidref = 0
domid = self.getDomid()
res_labels = None
+ is_policy_update = (xspol_old != None)

from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
from xen.util import xsconstants
@@ -2276,13 +2361,16 @@ class XendDomainInfo:

# Check that all used resources are accessible under the
# new label
- if not security.resources_compatible_with_vmlabel(xspol,
+ if not is_policy_update and \
+ not security.resources_compatible_with_vmlabel(xspol,
self, label):
return (-xsconstants.XSERR_BAD_LABEL, "", "", 0)

#Check label against expected one.
- old_label = self.get_security_label()
+ old_label = self.get_security_label(xspol_old)
if old_label != old_seclab:
+ log.info("old_label != old_seclab: %s != %s" %
+ (old_label, old_seclab))
return (-xsconstants.XSERR_BAD_LABEL, "", "", 0)

# relabel domain in the hypervisor
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/xend/server/DevController.py Thu Aug 16 10:47:33 2007 -0600
@@ -28,17 +28,19 @@ from xen.xend.xenstore.xswatch import xs

import os

-DEVICE_CREATE_TIMEOUT = 100
+DEVICE_CREATE_TIMEOUT = 100
+DEVICE_DESTROY_TIMEOUT = 100
HOTPLUG_STATUS_NODE = "hotplug-status"
HOTPLUG_ERROR_NODE = "hotplug-error"
HOTPLUG_STATUS_ERROR = "error"
HOTPLUG_STATUS_BUSY = "busy"

-Connected = 1
-Error = 2
-Missing = 3
-Timeout = 4
-Busy = 5
+Connected = 1
+Error = 2
+Missing = 3
+Timeout = 4
+Busy = 5
+Disconnected = 6

xenbusState = {
'Unknown' : 0,
@@ -185,6 +187,18 @@ class DevController:
(devid, self.deviceClass, err))


+ def waitForDevice_destroy(self, devid, backpath):
+ log.debug("Waiting for %s - destroyDevice.", devid)
+
+ if not self.hotplug:
+ return
+
+ status = self.waitForBackend_destroy(backpath)
+
+ if status == Timeout:
+ raise VmError("Device %s (%s) could not be disconnected. " %
+ (devid, self.deviceClass))
+

def reconfigureDevice(self, devid, config):
"""Reconfigure the specified device.
@@ -209,12 +223,7 @@ class DevController:
here.
"""

- try:
- dev = int(devid)
- except ValueError:
- # Does devid contain devicetype/deviceid?
- # Propogate exception if unable to find an integer devid
- dev = int(type(devid) is str and devid.split('/')[-1] or None)
+ dev = self.convertToDeviceNumber(devid)

# Modify online status /before/ updating state (latter is watched by
# drivers, so this ordering avoids a race).
@@ -282,6 +291,15 @@ class DevController:
config_dict = self.getDeviceConfiguration(devid)
all_configs[devid] = config_dict
return all_configs
+
+
+ def convertToDeviceNumber(self, devid):
+ try:
+ return int(devid)
+ except ValueError:
+ # Does devid contain devicetype/deviceid?
+ # Propogate exception if unable to find an integer devid
+ return int(type(devid) is str and devid.split('/')[-1] or None)

## protected:

@@ -513,6 +531,19 @@ class DevController:
return (Missing, None)


+ def waitForBackend_destroy(self, backpath):
+
+ statusPath = backpath + '/' + HOTPLUG_STATUS_NODE
+ ev = Event()
+ result = { 'status': Timeout }
+
+ xswatch(statusPath, deviceDestroyCallback, ev, result)
+
+ ev.wait(DEVICE_DESTROY_TIMEOUT)
+
+ return result['status']
+
+
def backendPath(self, backdom, devid):
"""Construct backend path given the backend domain and device id.

@@ -561,3 +592,19 @@ def hotplugStatusCallback(statusPath, ev

ev.set()
return 0
+
+
+def deviceDestroyCallback(statusPath, ev, result):
+ log.debug("deviceDestroyCallback %s.", statusPath)
+
+ status = xstransact.Read(statusPath)
+
+ if status is None:
+ result['status'] = Disconnected
+ else:
+ return 1
+
+ log.debug("deviceDestroyCallback %d.", result['status'])
+
+ ev.set()
+ return 0
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/xend/server/blkif.py Thu Aug 16 10:47:33 2007 -0600
@@ -165,11 +165,23 @@ class BlkifController(DevController):
try:
DevController.destroyDevice(self, devid, force)
except ValueError:
- devid_end = type(devid) is str and devid.split('/')[-1] or None
+ dev = self.convertToDeviceNumber(devid)

for i in self.deviceIDs():
- d = self.readBackend(i, 'dev')
- if d == devid or (devid_end and d == devid_end):
+ if i == dev:
DevController.destroyDevice(self, i, force)
return
raise VmError("Device %s not connected" % devid)
+
+ def convertToDeviceNumber(self, devid):
+ try:
+ dev = int(devid)
+ except ValueError:
+ if type(devid) is not str:
+ raise VmError("devid %s is wrong type" % str(devid))
+ try:
+ dev = devid.split('/')[-1]
+ dev = int(dev)
+ except ValueError:
+ dev = blkif.blkdev_name_to_number(dev)
+ return dev
diff -r b5dbf184df6c -r 778985f246a0 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/python/xen/xm/main.py Thu Aug 16 10:47:33 2007 -0600
@@ -876,7 +876,7 @@ def parse_doms_info(info):
if len(tmp) != 3:
seclabel = ""
else:
- seclabel = tmp[2]
+ seclabel = security_label
parsed_info['seclabel'] = seclabel

if serverType == SERVER_XEN_API:
@@ -2186,6 +2186,7 @@ def xm_network_attach(args):


def detach(args, deviceClass):
+ rm_cfg = True
dom = args[0]
dev = args[1]
try:
@@ -2196,7 +2197,7 @@ def detach(args, deviceClass):
except IndexError:
force = None

- server.xend.domain.destroyDevice(dom, deviceClass, dev, force)
+ server.xend.domain.destroyDevice(dom, deviceClass, dev, force, rm_cfg)


def xm_block_detach(args):
diff -r b5dbf184df6c -r 778985f246a0 tools/xm-test/configure.ac
--- a/tools/xm-test/configure.ac Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/xm-test/configure.ac Thu Aug 16 10:47:33 2007 -0600
@@ -85,6 +85,13 @@ AC_SUBST(NETWORK_ADDRESS)
AC_SUBST(NETWORK_ADDRESS)
AC_SUBST(NETMASK)

+DOM0_INTF="vif0.0"
+AC_ARG_WITH(dom0-intf,
+ [ --with-dom0-intf=intf Set dom0 interface name [[default="vif0.0"]]],
+ [ DOM0_INTF="$withval" ])
+
+AC_SUBST(DOM0_INTF)
+
AC_ARG_WITH(hvm-kernel,
[[ --with-hvm-kernel=kernel Use this kernel for hvm disk.img testing]],
HVMKERNEL=$withval,
diff -r b5dbf184df6c -r 778985f246a0 tools/xm-test/lib/XmTestLib/NetConfig.py
--- a/tools/xm-test/lib/XmTestLib/NetConfig.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/xm-test/lib/XmTestLib/NetConfig.py Thu Aug 16 10:47:33 2007 -0600
@@ -104,8 +104,8 @@ class NetConfig:
if self.network == "169.254.0.0":
checkZeroconfAddresses()

- # Clean out any aliases in the network range for vif0.0. If
- # an alias exists, a test xendevice add command could fail.
+ # Clean out any aliases in the network range for dom0's interface.
+ # If an alias exists, a test xendevice add command could fail.
if NETWORK_IP_RANGE != "dhcp":
self.__cleanDom0Aliases()

@@ -139,20 +139,22 @@ class NetConfig:

def __cleanDom0Aliases(self):
# Remove any aliases within the supplied network IP range on dom0
- scmd = 'ip addr show dev vif0.0'
+ scmd = 'ip addr show dev %s' % (DOM0_INTF)

status, output = traceCommand(scmd)
if status:
- raise NetworkError("Failed to show vif0.0 aliases: %d" % status)
+ raise NetworkError("Failed to show %s aliases: %d" %
+ (DOM0_INTF, status))

lines = output.split("\n")
for line in lines:
ip = re.search('(\d+\.\d+\.\d+\.\d+)', line)
if ip and self.isIPInRange(ip.group(1)) == True:
- dcmd = 'ip addr del %s dev vif0.0' % ip.group(1)
+ dcmd = 'ip addr del %s dev %s' % (ip.group(1), DOM0_INTF)
dstatus, doutput = traceCommand(dcmd)
if dstatus:
- raise NetworkError("Failed to remove vif0.0 aliases: %d" % status)
+ raise NetworkError("Failed to remove %s aliases: %d" %
+ (DOM0_INTF, status))

def getNetEnv(self):
return self.netenv
diff -r b5dbf184df6c -r 778985f246a0 tools/xm-test/lib/XmTestLib/XenDevice.py
--- a/tools/xm-test/lib/XmTestLib/XenDevice.py Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/xm-test/lib/XmTestLib/XenDevice.py Thu Aug 16 10:47:33 2007 -0600
@@ -214,7 +214,7 @@ class XenNetDevice(XenDevice):
def removeDevice(self):
self.releaseNetDevIP()

- def addDom0AliasCmd(self, dev="vif0.0"):
+ def addDom0AliasCmd(self, dev=DOM0_INTF):
# Method to add start and remove dom0 alias cmds
acmd = 'ip addr add %s dev %s' % (self.dom0_alias_ip, dev)
rcmd = 'ip addr del %s dev %s' % (self.dom0_alias_ip, dev)
diff -r b5dbf184df6c -r 778985f246a0 tools/xm-test/lib/XmTestLib/config.py.in
--- a/tools/xm-test/lib/XmTestLib/config.py.in Thu Aug 16 10:03:26 2007 -0600
+++ b/tools/xm-test/lib/XmTestLib/config.py.in Thu Aug 16 10:47:33 2007 -0600
@@ -4,3 +4,4 @@ NETWORK_IP_RANGE = "@NET_IP_RANGE@"
NETWORK_IP_RANGE = "@NET_IP_RANGE@"
NETWORK = "@NETWORK_ADDRESS@"
NETMASK = "@NETMASK@"
+DOM0_INTF = "@DOM0_INTF@"
diff -r b5dbf184df6c -r 778985f246a0 unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c
--- a/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c Thu Aug 16 10:03:26 2007 -0600
+++ b/unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c Thu Aug 16 10:47:33 2007 -0600
@@ -1,5 +1,6 @@
#include <linux/config.h>
-#include <linux/stop_machine.h>
+#include <linux/cpumask.h>
+#include <linux/preempt.h>
#include <xen/evtchn.h>
#include <xen/gnttab.h>
#include <xen/xenbus.h>
diff -r b5dbf184df6c -r 778985f246a0 xen/acm/acm_policy.c
--- a/xen/acm/acm_policy.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/acm/acm_policy.c Thu Aug 16 10:47:33 2007 -0600
@@ -710,12 +710,12 @@ acm_change_policy(struct acm_change_poli
goto acm_chg_policy_exit;
}

- if ( copy_from_guest((u8 *)dels.array,
+ if ( copy_from_guest(dels.array,
chgpolicy->del_array,
- chgpolicy->delarray_size) ||
- copy_from_guest((u8 *)ssidmap.array,
+ dels.num_items) ||
+ copy_from_guest(ssidmap.array,
chgpolicy->chg_array,
- chgpolicy->chgarray_size) ||
+ ssidmap.num_items) ||
copy_from_guest(binpolicy,
chgpolicy->policy_pushcache,
chgpolicy->policy_pushcache_size ))
@@ -844,9 +844,9 @@ acm_relabel_domains(struct acm_relabel_d
memset(errors.array, 0x0, sizeof(uint32_t) * errors.num_items);
}

- if ( copy_from_guest((u8 *)relabels.array,
+ if ( copy_from_guest(relabels.array,
relabel->relabel_map,
- relabel->relabel_map_size) )
+ relabels.num_items) )
{
rc = -EFAULT;
goto acm_relabel_doms_exit;
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/acpi/boot.c
--- a/xen/arch/x86/acpi/boot.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/acpi/boot.c Thu Aug 16 10:47:33 2007 -0600
@@ -423,7 +423,7 @@ acpi_fadt_parse_sleep_info(struct fadt_d
goto bad;

if (strncmp(facs->signature, "FACS", 4)) {
- printk(KERN_ERR PREFIX "Invalid FACS signature %s\n",
+ printk(KERN_ERR PREFIX "Invalid FACS signature %.4s\n",
facs->signature);
goto bad;
}
@@ -451,12 +451,13 @@ acpi_fadt_parse_sleep_info(struct fadt_d
acpi_sinfo.vector_width = 64;
}

- printk (KERN_INFO PREFIX
- "ACPI SLEEP INFO: pm1x_cnt[%x,%x], pm1x_evt[%x,%x]\n"
- " wakeup_vec[%"PRIx64"], vec_size[%x]\n",
- acpi_sinfo.pm1a_cnt, acpi_sinfo.pm1b_cnt,
- acpi_sinfo.pm1a_evt, acpi_sinfo.pm1b_cnt,
- acpi_sinfo.wakeup_vector, acpi_sinfo.vector_width);
+ printk(KERN_INFO PREFIX
+ "ACPI SLEEP INFO: pm1x_cnt[%x,%x], pm1x_evt[%x,%x]\n",
+ acpi_sinfo.pm1a_cnt, acpi_sinfo.pm1b_cnt,
+ acpi_sinfo.pm1a_evt, acpi_sinfo.pm1b_cnt);
+ printk(KERN_INFO PREFIX
+ " wakeup_vec[%"PRIx64"], vec_size[%x]\n",
+ acpi_sinfo.wakeup_vector, acpi_sinfo.vector_width);
return;
bad:
memset(&acpi_sinfo, 0, sizeof(acpi_sinfo));
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/hvm.c Thu Aug 16 10:47:33 2007 -0600
@@ -76,13 +76,6 @@ void hvm_enable(struct hvm_function_tabl
hvm_enabled = 1;
}

-void hvm_stts(struct vcpu *v)
-{
- /* FPU state already dirty? Then no need to setup_fpu() lazily. */
- if ( !v->fpu_dirtied )
- hvm_funcs.stts(v);
-}
-
void hvm_set_guest_time(struct vcpu *v, u64 gtime)
{
u64 host_tsc;
@@ -112,7 +105,8 @@ void hvm_do_resume(struct vcpu *v)
{
ioreq_t *p;

- hvm_stts(v);
+ if ( !v->fpu_dirtied )
+ hvm_funcs.stts(v);

pt_thaw_time(v);

@@ -520,6 +514,174 @@ void hvm_triple_fault(void)
domain_shutdown(v->domain, SHUTDOWN_reboot);
}

+int hvm_set_cr0(unsigned long value)
+{
+ struct vcpu *v = current;
+ unsigned long mfn, old_base_mfn, old_value = v->arch.hvm_vcpu.guest_cr[0];
+
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx", value);
+
+ if ( (u32)value != value )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_1,
+ "Guest attempts to set upper 32 bits in CR0: %lx",
+ value);
+ hvm_inject_exception(TRAP_gp_fault, 0, 0);
+ return 0;
+ }
+
+ value &= ~HVM_CR0_GUEST_RESERVED_BITS;
+
+ /* ET is reserved and should be always be 1. */
+ value |= X86_CR0_ET;
+
+ if ( (value & (X86_CR0_PE|X86_CR0_PG)) == X86_CR0_PG )
+ {
+ hvm_inject_exception(TRAP_gp_fault, 0, 0);
+ return 0;
+ }
+
+ if ( (value & X86_CR0_PG) && !(old_value & X86_CR0_PG) )
+ {
+ if ( v->arch.hvm_vcpu.guest_efer & EFER_LME )
+ {
+ if ( !(v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PAE) )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_1, "Enable paging before PAE enable");
+ hvm_inject_exception(TRAP_gp_fault, 0, 0);
+ return 0;
+ }
+ HVM_DBG_LOG(DBG_LEVEL_1, "Enabling long mode");
+ v->arch.hvm_vcpu.guest_efer |= EFER_LMA;
+ hvm_update_guest_efer(v);
+ }
+
+ if ( !paging_mode_hap(v->domain) )
+ {
+ /* The guest CR3 must be pointing to the guest physical. */
+ mfn = get_mfn_from_gpfn(v->arch.hvm_vcpu.guest_cr[3]>>PAGE_SHIFT);
+ if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain))
+ {
+ gdprintk(XENLOG_ERR, "Invalid CR3 value = %lx (mfn=%lx)\n",
+ v->arch.hvm_vcpu.guest_cr[3], mfn);
+ domain_crash(v->domain);
+ return 0;
+ }
+
+ /* Now arch.guest_table points to machine physical. */
+ old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
+ v->arch.guest_table = pagetable_from_pfn(mfn);
+ if ( old_base_mfn )
+ put_page(mfn_to_page(old_base_mfn));
+
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx, mfn = %lx",
+ v->arch.hvm_vcpu.guest_cr[3], mfn);
+ }
+ }
+ else if ( !(value & X86_CR0_PG) && (old_value & X86_CR0_PG) )
+ {
+ /* When CR0.PG is cleared, LMA is cleared immediately. */
+ if ( hvm_long_mode_enabled(v) )
+ {
+ v->arch.hvm_vcpu.guest_efer &= ~EFER_LMA;
+ hvm_update_guest_efer(v);
+ }
+
+ if ( !paging_mode_hap(v->domain) )
+ {
+ put_page(mfn_to_page(get_mfn_from_gpfn(
+ v->arch.hvm_vcpu.guest_cr[3] >> PAGE_SHIFT)));
+ v->arch.guest_table = pagetable_null();
+ }
+ }
+
+ v->arch.hvm_vcpu.guest_cr[0] = value;
+ hvm_update_guest_cr(v, 0);
+
+ if ( (value ^ old_value) & X86_CR0_PG )
+ paging_update_paging_modes(v);
+
+ return 1;
+}
+
+int hvm_set_cr3(unsigned long value)
+{
+ unsigned long old_base_mfn, mfn;
+ struct vcpu *v = current;
+
+ if ( paging_mode_hap(v->domain) || !hvm_paging_enabled(v) )
+ {
+ /* Nothing to do. */
+ }
+ else if ( value == v->arch.hvm_vcpu.guest_cr[3] )
+ {
+ /* Shadow-mode TLB flush. Invalidate the shadow. */
+ mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
+ if ( mfn != pagetable_get_pfn(v->arch.guest_table) )
+ goto bad_cr3;
+ }
+ else
+ {
+ /* Shadow-mode CR3 change. Check PDBR and then make a new shadow. */
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value);
+ mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
+ if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
+ goto bad_cr3;
+
+ old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
+ v->arch.guest_table = pagetable_from_pfn(mfn);
+
+ if ( old_base_mfn )
+ put_page(mfn_to_page(old_base_mfn));
+
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx", value);
+ }
+
+ v->arch.hvm_vcpu.guest_cr[3] = value;
+ paging_update_cr3(v);
+ return 1;
+
+ bad_cr3:
+ gdprintk(XENLOG_ERR, "Invalid CR3\n");
+ domain_crash(v->domain);
+ return 0;
+}
+
+int hvm_set_cr4(unsigned long value)
+{
+ struct vcpu *v = current;
+ unsigned long old_cr;
+
+ if ( value & HVM_CR4_GUEST_RESERVED_BITS )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_1,
+ "Guest attempts to set reserved bit in CR4: %lx",
+ value);
+ goto gpf;
+ }
+
+ if ( !(value & X86_CR4_PAE) && hvm_long_mode_enabled(v) )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_1, "Guest cleared CR4.PAE while "
+ "EFER.LMA is set");
+ goto gpf;
+ }
+
+ old_cr = v->arch.hvm_vcpu.guest_cr[4];
+ v->arch.hvm_vcpu.guest_cr[4] = value;
+ hvm_update_guest_cr(v, 4);
+
+ /* Modifying CR4.{PSE,PAE,PGE} invalidates all TLB entries, inc. Global. */
+ if ( (old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE) )
+ paging_update_paging_modes(v);
+
+ return 1;
+
+ gpf:
+ hvm_inject_exception(TRAP_gp_fault, 0, 0);
+ return 0;
+}
+
/*
* __hvm_copy():
* @buf = hypervisor buffer
@@ -668,7 +830,6 @@ static hvm_hypercall_t *hvm_hypercall32_
static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
HYPERCALL(memory_op),
[ __HYPERVISOR_grant_table_op ] = (hvm_hypercall_t *)hvm_grant_table_op,
- HYPERCALL(multicall),
HYPERCALL(xen_version),
HYPERCALL(grant_table_op),
HYPERCALL(event_channel_op),
@@ -811,12 +972,6 @@ int hvm_do_hypercall(struct cpu_user_reg

return (this_cpu(hc_preempted) ? HVM_HCALL_preempted :
flush ? HVM_HCALL_invalidate : HVM_HCALL_completed);
-}
-
-void hvm_update_guest_cr3(struct vcpu *v, unsigned long guest_cr3)
-{
- v->arch.hvm_vcpu.hw_cr3 = guest_cr3;
- hvm_funcs.update_guest_cr3(v);
}

static void hvm_latch_shinfo_size(struct domain *d)
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/svm/svm.c Thu Aug 16 10:47:33 2007 -0600
@@ -59,8 +59,9 @@ int inst_copy_from_guest(unsigned char *
int inst_len);
asmlinkage void do_IRQ(struct cpu_user_regs *);

-static int svm_reset_to_realmode(struct vcpu *v,
- struct cpu_user_regs *regs);
+static int svm_reset_to_realmode(
+ struct vcpu *v, struct cpu_user_regs *regs);
+static void svm_update_guest_cr(struct vcpu *v, unsigned int cr);

/* va of hardware host save area */
static void *hsa[NR_CPUS] __read_mostly;
@@ -78,7 +79,7 @@ static void svm_inject_exception(
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;

if ( trap == TRAP_page_fault )
- HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_svm.cpu_cr2, error_code);
+ HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_vcpu.guest_cr[2], error_code);
else
HVMTRACE_2D(INJ_EXC, v, trap, error_code);

@@ -97,55 +98,14 @@ static void svm_cpu_down(void)
write_efer(read_efer() & ~EFER_SVME);
}

+static int svm_lme_is_set(struct vcpu *v)
+{
#ifdef __x86_64__
-
-static int svm_lme_is_set(struct vcpu *v)
-{
- u64 guest_efer = v->arch.hvm_svm.cpu_shadow_efer;
+ u64 guest_efer = v->arch.hvm_vcpu.guest_efer;
return guest_efer & EFER_LME;
-}
-
-static int svm_long_mode_enabled(struct vcpu *v)
-{
- u64 guest_efer = v->arch.hvm_svm.cpu_shadow_efer;
- return guest_efer & EFER_LMA;
-}
-
-#else /* __i386__ */
-
-static int svm_lme_is_set(struct vcpu *v)
-{ return 0; }
-static int svm_long_mode_enabled(struct vcpu *v)
-{ return 0; }
-
+#else
+ return 0;
#endif
-
-static int svm_cr4_pae_is_set(struct vcpu *v)
-{
- unsigned long guest_cr4 = v->arch.hvm_svm.cpu_shadow_cr4;
- return guest_cr4 & X86_CR4_PAE;
-}
-
-static int svm_paging_enabled(struct vcpu *v)
-{
- unsigned long guest_cr0 = v->arch.hvm_svm.cpu_shadow_cr0;
- return (guest_cr0 & X86_CR0_PE) && (guest_cr0 & X86_CR0_PG);
-}
-
-static int svm_pae_enabled(struct vcpu *v)
-{
- unsigned long guest_cr4 = v->arch.hvm_svm.cpu_shadow_cr4;
- return svm_paging_enabled(v) && (guest_cr4 & X86_CR4_PAE);
-}
-
-static int svm_nx_enabled(struct vcpu *v)
-{
- return v->arch.hvm_svm.cpu_shadow_efer & EFER_NX;
-}
-
-static int svm_pgbit_test(struct vcpu *v)
-{
- return v->arch.hvm_svm.cpu_shadow_cr0 & X86_CR0_PG;
}

static void svm_store_cpu_guest_regs(
@@ -165,10 +125,10 @@ static void svm_store_cpu_guest_regs(
if ( crs != NULL )
{
/* Returning the guest's regs */
- crs[0] = v->arch.hvm_svm.cpu_shadow_cr0;
- crs[2] = v->arch.hvm_svm.cpu_cr2;
- crs[3] = v->arch.hvm_svm.cpu_cr3;
- crs[4] = v->arch.hvm_svm.cpu_shadow_cr4;
+ crs[0] = v->arch.hvm_vcpu.guest_cr[0];
+ crs[2] = v->arch.hvm_vcpu.guest_cr[2];
+ crs[3] = v->arch.hvm_vcpu.guest_cr[3];
+ crs[4] = v->arch.hvm_vcpu.guest_cr[4];
}
}

@@ -202,7 +162,8 @@ static enum handler_return long_mode_do_
if ( (msr_content & EFER_LME) && !svm_lme_is_set(v) )
{
/* EFER.LME transition from 0 to 1. */
- if ( svm_paging_enabled(v) || !svm_cr4_pae_is_set(v) )
+ if ( hvm_paging_enabled(v) ||
+ !(v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PAE) )
{
gdprintk(XENLOG_WARNING, "Trying to set LME bit when "
"in paging mode or PAE bit is not set\n");
@@ -212,7 +173,7 @@ static enum handler_return long_mode_do_
else if ( !(msr_content & EFER_LME) && svm_lme_is_set(v) )
{
/* EFER.LME transistion from 1 to 0. */
- if ( svm_paging_enabled(v) )
+ if ( hvm_paging_enabled(v) )
{
gdprintk(XENLOG_WARNING,
"Trying to clear EFER.LME while paging enabled\n");
@@ -220,9 +181,9 @@ static enum handler_return long_mode_do_
}
}

- v->arch.hvm_svm.cpu_shadow_efer = msr_content;
+ v->arch.hvm_vcpu.guest_efer = msr_content;
vmcb->efer = msr_content | EFER_SVME;
- if ( !svm_paging_enabled(v) )
+ if ( !hvm_paging_enabled(v) )
vmcb->efer &= ~(EFER_LME | EFER_LMA);

break;
@@ -297,10 +258,10 @@ int svm_vmcb_save(struct vcpu *v, struct
c->rsp = vmcb->rsp;
c->rflags = vmcb->rflags;

- c->cr0 = v->arch.hvm_svm.cpu_shadow_cr0;
- c->cr2 = v->arch.hvm_svm.cpu_cr2;
- c->cr3 = v->arch.hvm_svm.cpu_cr3;
- c->cr4 = v->arch.hvm_svm.cpu_shadow_cr4;
+ c->cr0 = v->arch.hvm_vcpu.guest_cr[0];
+ c->cr2 = v->arch.hvm_vcpu.guest_cr[2];
+ c->cr3 = v->arch.hvm_vcpu.guest_cr[3];
+ c->cr4 = v->arch.hvm_vcpu.guest_cr[4];

#ifdef HVM_DEBUG_SUSPEND
printk("%s: cr3=0x%"PRIx64", cr0=0x%"PRIx64", cr4=0x%"PRIx64".\n",
@@ -383,58 +344,31 @@ int svm_vmcb_restore(struct vcpu *v, str
vmcb->rsp = c->rsp;
vmcb->rflags = c->rflags;

- v->arch.hvm_svm.cpu_shadow_cr0 = c->cr0;
- vmcb->cr0 = c->cr0 | X86_CR0_WP | X86_CR0_ET | X86_CR0_PG;
-
- v->arch.hvm_svm.cpu_cr2 = c->cr2;
+ v->arch.hvm_vcpu.guest_cr[0] = c->cr0 | X86_CR0_ET;
+ v->arch.hvm_vcpu.guest_cr[2] = c->cr2;
+ v->arch.hvm_vcpu.guest_cr[3] = c->cr3;
+ v->arch.hvm_vcpu.guest_cr[4] = c->cr4;
+ svm_update_guest_cr(v, 0);
+ svm_update_guest_cr(v, 2);
+ svm_update_guest_cr(v, 4);

#ifdef HVM_DEBUG_SUSPEND
printk("%s: cr3=0x%"PRIx64", cr0=0x%"PRIx64", cr4=0x%"PRIx64".\n",
- __func__,
- c->cr3,
- c->cr0,
- c->cr4);
+ __func__, c->cr3, c->cr0, c->cr4);
#endif

- if ( !svm_paging_enabled(v) )
- {
- printk("%s: paging not enabled.\n", __func__);
- goto skip_cr3;
- }
-
- if ( c->cr3 == v->arch.hvm_svm.cpu_cr3 )
- {
- /*
- * This is simple TLB flush, implying the guest has
- * removed some translation or changed page attributes.
- * We simply invalidate the shadow.
- */
- mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
- if ( mfn != pagetable_get_pfn(v->arch.guest_table) )
- goto bad_cr3;
- }
- else
- {
- /*
- * If different, make a shadow. Check if the PDBR is valid
- * first.
- */
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 c->cr3 = %"PRIx64, c->cr3);
+ if ( hvm_paging_enabled(v) && !paging_mode_hap(v->domain) )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 = %"PRIx64, c->cr3);
mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
if( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
goto bad_cr3;
-
old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
v->arch.guest_table = pagetable_from_pfn(mfn);
- if (old_base_mfn)
+ if ( old_base_mfn )
put_page(mfn_to_page(old_base_mfn));
- v->arch.hvm_svm.cpu_cr3 = c->cr3;
- }
-
- skip_cr3:
- vmcb->cr4 = c->cr4 | HVM_CR4_HOST_MASK;
- v->arch.hvm_svm.cpu_shadow_cr4 = c->cr4;
-
+ }
+
vmcb->idtr.limit = c->idtr_limit;
vmcb->idtr.base = c->idtr_base;

@@ -488,10 +422,6 @@ int svm_vmcb_restore(struct vcpu *v, str

if ( paging_mode_hap(v->domain) )
{
- vmcb->cr0 = v->arch.hvm_svm.cpu_shadow_cr0;
- vmcb->cr4 = (v->arch.hvm_svm.cpu_shadow_cr4 |
- (HVM_CR4_HOST_MASK & ~X86_CR4_PAE));
- vmcb->cr3 = c->cr3;
vmcb->np_enable = 1;
vmcb->g_pat = 0x0007040600070406ULL; /* guest PAT */
vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
@@ -521,7 +451,6 @@ int svm_vmcb_restore(struct vcpu *v, str
}

paging_update_paging_modes(v);
- svm_asid_g_update_paging(v);

return 0;

@@ -540,7 +469,7 @@ static void svm_save_cpu_state(struct vc
data->msr_star = vmcb->star;
data->msr_cstar = vmcb->cstar;
data->msr_syscall_mask = vmcb->sfmask;
- data->msr_efer = v->arch.hvm_svm.cpu_shadow_efer;
+ data->msr_efer = v->arch.hvm_vcpu.guest_efer;
data->msr_flags = -1ULL;

data->tsc = hvm_get_guest_time(v);
@@ -556,7 +485,7 @@ static void svm_load_cpu_state(struct vc
vmcb->star = data->msr_star;
vmcb->cstar = data->msr_cstar;
vmcb->sfmask = data->msr_syscall_mask;
- v->arch.hvm_svm.cpu_shadow_efer = data->msr_efer;
+ v->arch.hvm_vcpu.guest_efer = data->msr_efer;
vmcb->efer = data->msr_efer | EFER_SVME;
/* VMCB's EFER.LME isn't set unless we're actually in long mode
* (see long_mode_do_msr_write()) */
@@ -605,11 +534,11 @@ static int svm_guest_x86_mode(struct vcp
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;

- if ( unlikely(!(v->arch.hvm_svm.cpu_shadow_cr0 & X86_CR0_PE)) )
+ if ( unlikely(!(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PE)) )
return 0;
if ( unlikely(vmcb->rflags & X86_EFLAGS_VM) )
return 1;
- if ( svm_long_mode_enabled(v) && likely(vmcb->cs.attr.fields.l) )
+ if ( hvm_long_mode_enabled(v) && likely(vmcb->cs.attr.fields.l) )
return 8;
return (likely(vmcb->cs.attr.fields.db) ? 4 : 2);
}
@@ -619,9 +548,45 @@ static void svm_update_host_cr3(struct v
/* SVM doesn't have a HOST_CR3 equivalent to update. */
}

-static void svm_update_guest_cr3(struct vcpu *v)
-{
- v->arch.hvm_svm.vmcb->cr3 = v->arch.hvm_vcpu.hw_cr3;
+static void svm_update_guest_cr(struct vcpu *v, unsigned int cr)
+{
+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+
+ switch ( cr )
+ {
+ case 0:
+ vmcb->cr0 = v->arch.hvm_vcpu.guest_cr[0];
+ if ( !paging_mode_hap(v->domain) )
+ vmcb->cr0 |= X86_CR0_PG | X86_CR0_WP;
+ break;
+ case 2:
+ vmcb->cr2 = v->arch.hvm_vcpu.guest_cr[2];
+ break;
+ case 3:
+ vmcb->cr3 = v->arch.hvm_vcpu.hw_cr[3];
+ svm_asid_inv_asid(v);
+ break;
+ case 4:
+ vmcb->cr4 = HVM_CR4_HOST_MASK;
+ if ( paging_mode_hap(v->domain) )
+ vmcb->cr4 &= ~X86_CR4_PAE;
+ vmcb->cr4 |= v->arch.hvm_vcpu.guest_cr[4];
+ break;
+ default:
+ BUG();
+ }
+}
+
+static void svm_update_guest_efer(struct vcpu *v)
+{
+#ifdef __x86_64__
+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+
+ if ( v->arch.hvm_vcpu.guest_efer & EFER_LMA )
+ vmcb->efer |= EFER_LME | EFER_LMA;
+ else
+ vmcb->efer &= ~(EFER_LME | EFER_LMA);
+#endif
}

static void svm_flush_guest_tlbs(void)
@@ -639,24 +604,6 @@ static void svm_update_vtpr(struct vcpu
vmcb->vintr.fields.tpr = value & 0x0f;
}

-static unsigned long svm_get_ctrl_reg(struct vcpu *v, unsigned int num)
-{
- switch ( num )
- {
- case 0:
- return v->arch.hvm_svm.cpu_shadow_cr0;
- case 2:
- return v->arch.hvm_svm.cpu_cr2;
- case 3:
- return v->arch.hvm_svm.cpu_cr3;
- case 4:
- return v->arch.hvm_svm.cpu_shadow_cr4;
- default:
- BUG();
- }
- return 0; /* dummy */
-}
-
static void svm_sync_vmcb(struct vcpu *v)
{
struct arch_svm_struct *arch_svm = &v->arch.hvm_svm;
@@ -674,7 +621,7 @@ static unsigned long svm_get_segment_bas
static unsigned long svm_get_segment_base(struct vcpu *v, enum x86_segment seg)
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
- int long_mode = vmcb->cs.attr.fields.l && svm_long_mode_enabled(v);
+ int long_mode = vmcb->cs.attr.fields.l && hvm_long_mode_enabled(v);

switch ( seg )
{
@@ -748,7 +695,7 @@ static void svm_stts(struct vcpu *v)
* then this is not necessary: no FPU activity can occur until the guest
* clears CR0.TS, and we will initialise the FPU when that happens.
*/
- if ( !(v->arch.hvm_svm.cpu_shadow_cr0 & X86_CR0_TS) )
+ if ( !(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS) )
{
v->arch.hvm_svm.vmcb->exception_intercepts |= 1U << TRAP_no_device;
vmcb->cr0 |= X86_CR0_TS;
@@ -949,7 +896,7 @@ static void svm_hvm_inject_exception(
{
struct vcpu *v = current;
if ( trapnr == TRAP_page_fault )
- v->arch.hvm_svm.vmcb->cr2 = v->arch.hvm_svm.cpu_cr2 = cr2;
+ v->arch.hvm_svm.vmcb->cr2 = v->arch.hvm_vcpu.guest_cr[2] = cr2;
svm_inject_exception(v, trapnr, (errcode != -1), errcode);
}

@@ -970,17 +917,13 @@ static struct hvm_function_table svm_fun
.load_cpu_guest_regs = svm_load_cpu_guest_regs,
.save_cpu_ctxt = svm_save_vmcb_ctxt,
.load_cpu_ctxt = svm_load_vmcb_ctxt,
- .paging_enabled = svm_paging_enabled,
- .long_mode_enabled = svm_long_mode_enabled,
- .pae_enabled = svm_pae_enabled,
- .nx_enabled = svm_nx_enabled,
.interrupts_enabled = svm_interrupts_enabled,
.guest_x86_mode = svm_guest_x86_mode,
- .get_guest_ctrl_reg = svm_get_ctrl_reg,
.get_segment_base = svm_get_segment_base,
.get_segment_register = svm_get_segment_register,
.update_host_cr3 = svm_update_host_cr3,
- .update_guest_cr3 = svm_update_guest_cr3,
+ .update_guest_cr = svm_update_guest_cr,
+ .update_guest_efer = svm_update_guest_efer,
.flush_guest_tlbs = svm_flush_guest_tlbs,
.update_vtpr = svm_update_vtpr,
.stts = svm_stts,
@@ -1075,7 +1018,7 @@ static void svm_do_no_device_fault(struc
setup_fpu(v);
vmcb->exception_intercepts &= ~(1U << TRAP_no_device);

- if ( !(v->arch.hvm_svm.cpu_shadow_cr0 & X86_CR0_TS) )
+ if ( !(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS) )
vmcb->cr0 &= ~X86_CR0_TS;
}

@@ -1347,7 +1290,7 @@ static int svm_get_io_address(
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;

/* If we're in long mode, don't check the segment presence & limit */
- long_mode = vmcb->cs.attr.fields.l && svm_long_mode_enabled(v);
+ long_mode = vmcb->cs.attr.fields.l && hvm_long_mode_enabled(v);

/* d field of cs.attr is 1 for 32-bit, 0 for 16 or 64 bit.
* l field combined with EFER_LMA says whether it's 16 or 64 bit.
@@ -1650,31 +1593,11 @@ static int svm_set_cr0(unsigned long val
static int svm_set_cr0(unsigned long value)
{
struct vcpu *v = current;
- unsigned long mfn, old_value = v->arch.hvm_svm.cpu_shadow_cr0;
- struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
- unsigned long old_base_mfn;
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx", value);
-
- if ( (u32)value != value )
- {
- HVM_DBG_LOG(DBG_LEVEL_1,
- "Guest attempts to set upper 32 bits in CR0: %lx",
- value);
- svm_inject_exception(v, TRAP_gp_fault, 1, 0);
+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+ int rc = hvm_set_cr0(value);
+
+ if ( rc == 0 )
return 0;
- }
-
- value &= ~HVM_CR0_GUEST_RESERVED_BITS;
-
- /* ET is reserved and should be always be 1. */
- value |= X86_CR0_ET;
-
- if ( (value & (X86_CR0_PE|X86_CR0_PG)) == X86_CR0_PG )
- {
- svm_inject_exception(v, TRAP_gp_fault, 1, 0);
- return 0;
- }

/* TS cleared? Then initialise FPU now. */
if ( !(value & X86_CR0_TS) )
@@ -1683,76 +1606,9 @@ static int svm_set_cr0(unsigned long val
vmcb->exception_intercepts &= ~(1U << TRAP_no_device);
}

- if ( (value & X86_CR0_PG) && !(old_value & X86_CR0_PG) )
- {
- if ( svm_lme_is_set(v) )
- {
- if ( !svm_cr4_pae_is_set(v) )
- {
- HVM_DBG_LOG(DBG_LEVEL_1, "Enable paging before PAE enable");
- svm_inject_exception(v, TRAP_gp_fault, 1, 0);
- return 0;
- }
- HVM_DBG_LOG(DBG_LEVEL_1, "Enable the Long mode");
- v->arch.hvm_svm.cpu_shadow_efer |= EFER_LMA;
- vmcb->efer |= EFER_LMA | EFER_LME;
- }
-
- if ( !paging_mode_hap(v->domain) )
- {
- /* The guest CR3 must be pointing to the guest physical. */
- mfn = get_mfn_from_gpfn(v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain))
- {
- gdprintk(XENLOG_ERR, "Invalid CR3 value = %lx (mfn=%lx)\n",
- v->arch.hvm_svm.cpu_cr3, mfn);
- domain_crash(v->domain);
- return 0;
- }
-
- /* Now arch.guest_table points to machine physical. */
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx, mfn = %lx",
- v->arch.hvm_vmx.cpu_cr3, mfn);
- }
- }
- else if ( !(value & X86_CR0_PG) && (old_value & X86_CR0_PG) )
- {
- /* When CR0.PG is cleared, LMA is cleared immediately. */
- if ( svm_long_mode_enabled(v) )
- {
- vmcb->efer &= ~(EFER_LME | EFER_LMA);
- v->arch.hvm_svm.cpu_shadow_efer &= ~EFER_LMA;
- }
-
- if ( !paging_mode_hap(v->domain) && v->arch.hvm_svm.cpu_cr3 )
- {
- put_page(mfn_to_page(get_mfn_from_gpfn(
- v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT)));
- v->arch.guest_table = pagetable_null();
- }
- }
-
- vmcb->cr0 = v->arch.hvm_svm.cpu_shadow_cr0 = value;
- if ( !paging_mode_hap(v->domain) )
- vmcb->cr0 |= X86_CR0_PG | X86_CR0_WP;
-
- if ( (value ^ old_value) & X86_CR0_PG )
- {
- paging_update_paging_modes(v);
- svm_asid_g_update_paging(v);
- }
-
return 1;
}

-/*
- * Read from control registers. CR0 and CR4 are read from the shadow.
- */
static void mov_from_cr(int cr, int gp, struct cpu_user_regs *regs)
{
unsigned long value = 0;
@@ -1763,16 +1619,16 @@ static void mov_from_cr(int cr, int gp,
switch ( cr )
{
case 0:
- value = v->arch.hvm_svm.cpu_shadow_cr0;
+ value = v->arch.hvm_vcpu.guest_cr[0];
break;
case 2:
value = vmcb->cr2;
break;
case 3:
- value = (unsigned long)v->arch.hvm_svm.cpu_cr3;
+ value = (unsigned long)v->arch.hvm_vcpu.guest_cr[3];
break;
case 4:
- value = (unsigned long)v->arch.hvm_svm.cpu_shadow_cr4;
+ value = (unsigned long)v->arch.hvm_vcpu.guest_cr[4];
break;
case 8:
value = (unsigned long)vlapic_get_reg(vlapic, APIC_TASKPRI);
@@ -1791,13 +1647,9 @@ static void mov_from_cr(int cr, int gp,
HVM_DBG_LOG(DBG_LEVEL_VMMU, "mov_from_cr: CR%d, value = %lx", cr, value);
}

-
-/*
- * Write to control registers
- */
static int mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs)
{
- unsigned long value, old_cr, old_base_mfn, mfn;
+ unsigned long value;
struct vcpu *v = current;
struct vlapic *vlapic = vcpu_vlapic(v);
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
@@ -1815,131 +1667,10 @@ static int mov_to_cr(int gpreg, int cr,
return svm_set_cr0(value);

case 3:
- if ( paging_mode_hap(v->domain) )
- {
- vmcb->cr3 = v->arch.hvm_svm.cpu_cr3 = value;
- break;
- }
-
- /* If paging is not enabled yet, simply copy the value to CR3. */
- if ( !svm_paging_enabled(v) )
- {
- v->arch.hvm_svm.cpu_cr3 = value;
- break;
- }
-
- /* We make a new one if the shadow does not exist. */
- if ( value == v->arch.hvm_svm.cpu_cr3 )
- {
- /*
- * This is simple TLB flush, implying the guest has
- * removed some translation or changed page attributes.
- * We simply invalidate the shadow.
- */
- mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
- if ( mfn != pagetable_get_pfn(v->arch.guest_table) )
- goto bad_cr3;
- paging_update_cr3(v);
- /* signal paging update to ASID handler */
- svm_asid_g_mov_to_cr3 (v);
- }
- else
- {
- /*
- * If different, make a shadow. Check if the PDBR is valid
- * first.
- */
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value);
- mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
- goto bad_cr3;
-
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
-
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
-
- v->arch.hvm_svm.cpu_cr3 = value;
- update_cr3(v);
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx", value);
- /* signal paging update to ASID handler */
- svm_asid_g_mov_to_cr3 (v);
- }
- break;
-
- case 4: /* CR4 */
- if ( value & HVM_CR4_GUEST_RESERVED_BITS )
- {
- HVM_DBG_LOG(DBG_LEVEL_1,
- "Guest attempts to set reserved bit in CR4: %lx",
- value);
- svm_inject_exception(v, TRAP_gp_fault, 1, 0);
- break;
- }
-
- if ( paging_mode_hap(v->domain) )
- {
- v->arch.hvm_svm.cpu_shadow_cr4 = value;
- vmcb->cr4 = value | (HVM_CR4_HOST_MASK & ~X86_CR4_PAE);
- paging_update_paging_modes(v);
- /* signal paging update to ASID handler */
- svm_asid_g_update_paging (v);
- break;
- }
-
- old_cr = v->arch.hvm_svm.cpu_shadow_cr4;
- if ( value & X86_CR4_PAE && !(old_cr & X86_CR4_PAE) )
- {
- if ( svm_pgbit_test(v) )
- {
-#if CONFIG_PAGING_LEVELS >= 3
- /* The guest is a 32-bit PAE guest. */
- unsigned long mfn, old_base_mfn;
- mfn = get_mfn_from_gpfn(v->arch.hvm_svm.cpu_cr3 >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) ||
- !get_page(mfn_to_page(mfn), v->domain) )
- goto bad_cr3;
-
- /*
- * Now arch.guest_table points to machine physical.
- */
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
- paging_update_paging_modes(v);
- /* signal paging update to ASID handler */
- svm_asid_g_update_paging (v);
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU,
- "Update CR3 value = %lx, mfn = %lx",
- v->arch.hvm_svm.cpu_cr3, mfn);
-#endif
- }
- }
- else if ( !(value & X86_CR4_PAE) )
- {
- if ( svm_long_mode_enabled(v) )
- {
- svm_inject_exception(v, TRAP_gp_fault, 1, 0);
- }
- }
-
- v->arch.hvm_svm.cpu_shadow_cr4 = value;
- vmcb->cr4 = value | HVM_CR4_HOST_MASK;
-
- /*
- * Writing to CR4 to modify the PSE, PGE, or PAE flag invalidates
- * all TLB entries except global entries.
- */
- if ((old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE))
- {
- paging_update_paging_modes(v);
- /* signal paging update to ASID handler */
- svm_asid_g_update_paging (v);
- }
- break;
+ return hvm_set_cr3(value);
+
+ case 4:
+ return hvm_set_cr4(value);

case 8:
vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
@@ -1953,19 +1684,11 @@ static int mov_to_cr(int gpreg, int cr,
}

return 1;
-
- bad_cr3:
- gdprintk(XENLOG_ERR, "Invalid CR3\n");
- domain_crash(v->domain);
- return 0;
-}
-
-
-#define ARR_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
-
-static int svm_cr_access(struct vcpu *v, unsigned int cr, unsigned int type,
- struct cpu_user_regs *regs)
+}
+
+static void svm_cr_access(
+ struct vcpu *v, unsigned int cr, unsigned int type,
+ struct cpu_user_regs *regs)
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
int inst_len = 0;
@@ -1990,12 +1713,12 @@ static int svm_cr_access(struct vcpu *v,
if ( type == TYPE_MOV_TO_CR )
{
inst_len = __get_instruction_length_from_list(
- v, list_a, ARR_SIZE(list_a), &buffer[index], &match);
+ v, list_a, ARRAY_SIZE(list_a), &buffer[index], &match);
}
else /* type == TYPE_MOV_FROM_CR */
{
inst_len = __get_instruction_length_from_list(
- v, list_b, ARR_SIZE(list_b), &buffer[index], &match);
+ v, list_b, ARRAY_SIZE(list_b), &buffer[index], &match);
}

ASSERT(inst_len > 0);
@@ -2008,7 +1731,8 @@ static int svm_cr_access(struct vcpu *v,

HVM_DBG_LOG(DBG_LEVEL_1, "eip = %lx", (unsigned long) vmcb->rip);

- switch (match)
+ switch ( match )
+
{
case INSTR_MOV2CR:
gpreg = decode_src_reg(prefix, buffer[index+2]);
@@ -2025,18 +1749,18 @@ static int svm_cr_access(struct vcpu *v,
setup_fpu(current);
vmcb->exception_intercepts &= ~(1U << TRAP_no_device);
vmcb->cr0 &= ~X86_CR0_TS; /* clear TS */
- v->arch.hvm_svm.cpu_shadow_cr0 &= ~X86_CR0_TS; /* clear TS */
+ v->arch.hvm_vcpu.guest_cr[0] &= ~X86_CR0_TS; /* clear TS */
break;

case INSTR_LMSW:
gpreg = decode_src_reg(prefix, buffer[index+2]);
value = get_reg(gpreg, regs, vmcb) & 0xF;
- value = (v->arch.hvm_svm.cpu_shadow_cr0 & ~0xF) | value;
+ value = (v->arch.hvm_vcpu.guest_cr[0] & ~0xF) | value;
result = svm_set_cr0(value);
break;

case INSTR_SMSW:
- value = v->arch.hvm_svm.cpu_shadow_cr0 & 0xFFFF;
+ value = v->arch.hvm_vcpu.guest_cr[0] & 0xFFFF;
modrm = buffer[index+2];
addr_size = svm_guest_x86_mode(v);
if ( addr_size < 2 )
@@ -2099,9 +1823,8 @@ static int svm_cr_access(struct vcpu *v,

ASSERT(inst_len);

- __update_guest_eip(vmcb, inst_len);
-
- return result;
+ if ( result )
+ __update_guest_eip(vmcb, inst_len);
}

static void svm_do_msr_access(
@@ -2129,7 +1852,7 @@ static void svm_do_msr_access(
break;

case MSR_EFER:
- msr_content = v->arch.hvm_svm.cpu_shadow_efer;
+ msr_content = v->arch.hvm_vcpu.guest_efer;
break;

case MSR_K8_MC4_MISC: /* Threshold register */
@@ -2319,8 +2042,7 @@ void svm_handle_invlpg(const short invlp
HVMTRACE_3D(INVLPG, v, (invlpga?1:0), g_vaddr, (invlpga?regs->ecx:0));

paging_invlpg(v, g_vaddr);
- /* signal invplg to ASID handler */
- svm_asid_g_invlpg (v, g_vaddr);
+ svm_asid_g_invlpg(v, g_vaddr);
}


@@ -2335,29 +2057,23 @@ static int svm_reset_to_realmode(struct
{
struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;

- /* clear the vmcb and user regs */
memset(regs, 0, sizeof(struct cpu_user_regs));
-
- /* VMCB State */
- vmcb->cr0 = X86_CR0_ET | X86_CR0_PG | X86_CR0_WP;
- v->arch.hvm_svm.cpu_shadow_cr0 = X86_CR0_ET;
-
- vmcb->cr2 = 0;
+
+ v->arch.hvm_vcpu.guest_cr[0] = X86_CR0_ET;
+ svm_update_guest_cr(v, 0);
+
+ v->arch.hvm_vcpu.guest_cr[2] = 0;
+ svm_update_guest_cr(v, 2);
+
+ v->arch.hvm_vcpu.guest_cr[4] = 0;
+ svm_update_guest_cr(v, 4);
+
vmcb->efer = EFER_SVME;
-
- vmcb->cr4 = HVM_CR4_HOST_MASK;
- v->arch.hvm_svm.cpu_shadow_cr4 = 0;
-
- if ( paging_mode_hap(v->domain) ) {
- vmcb->cr0 = v->arch.hvm_svm.cpu_shadow_cr0;
- vmcb->cr4 = v->arch.hvm_svm.cpu_shadow_cr4 |
- (HVM_CR4_HOST_MASK & ~X86_CR4_PAE);
- }

/* This will jump to ROMBIOS */
vmcb->rip = 0xFFF0;

- /* setup the segment registers and all their hidden states */
+ /* Set up the segment registers and all their hidden states. */
vmcb->cs.sel = 0xF000;
vmcb->cs.attr.bytes = 0x089b;
vmcb->cs.limit = 0xffff;
@@ -2483,7 +2199,7 @@ asmlinkage void svm_vmexit_handler(struc
unsigned long va;
va = vmcb->exitinfo2;
regs->error_code = vmcb->exitinfo1;
- HVM_DBG_LOG(DBG_LEVEL_VMMU,
+ HVM_DBG_LOG(DBG_LEVEL_VMMU,
"eax=%lx, ebx=%lx, ecx=%lx, edx=%lx, esi=%lx, edi=%lx",
(unsigned long)regs->eax, (unsigned long)regs->ebx,
(unsigned long)regs->ecx, (unsigned long)regs->edx,
@@ -2495,7 +2211,7 @@ asmlinkage void svm_vmexit_handler(struc
break;
}

- v->arch.hvm_svm.cpu_cr2 = vmcb->cr2 = va;
+ v->arch.hvm_vcpu.guest_cr[2] = vmcb->cr2 = va;
svm_inject_exception(v, TRAP_page_fault, 1, regs->error_code);
break;
}
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/svm/vmcb.c Thu Aug 16 10:47:33 2007 -0600
@@ -111,7 +111,7 @@ static int construct_vmcb(struct vcpu *v
svm_segment_attributes_t attrib;

/* TLB control, and ASID assigment. */
- svm_asid_init_vcpu (v);
+ svm_asid_init_vcpu(v);

vmcb->general1_intercepts =
GENERAL1_INTERCEPT_INTR | GENERAL1_INTERCEPT_NMI |
@@ -216,27 +216,19 @@ static int construct_vmcb(struct vcpu *v
vmcb->tr.base = 0;
vmcb->tr.limit = 0xff;

- /* Guest CR0. */
- vmcb->cr0 = read_cr0();
- arch_svm->cpu_shadow_cr0 = vmcb->cr0 & ~(X86_CR0_PG | X86_CR0_TS);
- vmcb->cr0 |= X86_CR0_WP;
-
- /* Guest CR4. */
- arch_svm->cpu_shadow_cr4 =
- read_cr4() & ~(X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE);
- vmcb->cr4 = arch_svm->cpu_shadow_cr4 | HVM_CR4_HOST_MASK;
+ v->arch.hvm_vcpu.guest_cr[0] = X86_CR0_PE | X86_CR0_TS;
+ hvm_update_guest_cr(v, 0);
+
+ v->arch.hvm_vcpu.guest_cr[4] = 0;
+ hvm_update_guest_cr(v, 4);

paging_update_paging_modes(v);
- vmcb->cr3 = v->arch.hvm_vcpu.hw_cr3;

if ( paging_mode_hap(v->domain) )
{
- vmcb->cr0 = arch_svm->cpu_shadow_cr0;
vmcb->np_enable = 1; /* enable nested paging */
vmcb->g_pat = 0x0007040600070406ULL; /* guest PAT */
vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
- vmcb->cr4 = arch_svm->cpu_shadow_cr4 =
- (HVM_CR4_HOST_MASK & ~X86_CR4_PAE);
vmcb->exception_intercepts = HVM_TRAP_MASK;

/* No point in intercepting CR3/4 reads, because the hardware
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/vioapic.c
--- a/xen/arch/x86/hvm/vioapic.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/vioapic.c Thu Aug 16 10:47:33 2007 -0600
@@ -43,10 +43,6 @@
/* HACK: Route IRQ0 only to VCPU0 to prevent time jumps. */
#define IRQ0_SPECIAL_ROUTING 1

-#if defined(__ia64__)
-#define opt_hvm_debug_level opt_vmx_debug_level
-#endif
-
static void vioapic_deliver(struct hvm_hw_vioapic *vioapic, int irq);

static unsigned long vioapic_read_indirect(struct hvm_hw_vioapic *vioapic,
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Thu Aug 16 10:47:33 2007 -0600
@@ -315,34 +315,69 @@ void vmx_cpu_down(void)
local_irq_restore(flags);
}

+struct foreign_vmcs {
+ struct vcpu *v;
+ unsigned int count;
+};
+static DEFINE_PER_CPU(struct foreign_vmcs, foreign_vmcs);
+
void vmx_vmcs_enter(struct vcpu *v)
{
+ struct foreign_vmcs *fv;
+
/*
* NB. We must *always* run an HVM VCPU on its own VMCS, except for
* vmx_vmcs_enter/exit critical regions.
*/
- if ( v == current )
+ if ( likely(v == current) )
return;

- vcpu_pause(v);
- spin_lock(&v->arch.hvm_vmx.vmcs_lock);
-
- vmx_clear_vmcs(v);
- vmx_load_vmcs(v);
+ fv = &this_cpu(foreign_vmcs);
+
+ if ( fv->v == v )
+ {
+ BUG_ON(fv->count == 0);
+ }
+ else
+ {
+ BUG_ON(fv->v != NULL);
+ BUG_ON(fv->count != 0);
+
+ vcpu_pause(v);
+ spin_lock(&v->arch.hvm_vmx.vmcs_lock);
+
+ vmx_clear_vmcs(v);
+ vmx_load_vmcs(v);
+
+ fv->v = v;
+ }
+
+ fv->count++;
}

void vmx_vmcs_exit(struct vcpu *v)
{
- if ( v == current )
+ struct foreign_vmcs *fv;
+
+ if ( likely(v == current) )
return;

- /* Don't confuse vmx_do_resume (for @v or @current!) */
- vmx_clear_vmcs(v);
- if ( is_hvm_vcpu(current) )
- vmx_load_vmcs(current);
-
- spin_unlock(&v->arch.hvm_vmx.vmcs_lock);
- vcpu_unpause(v);
+ fv = &this_cpu(foreign_vmcs);
+ BUG_ON(fv->v != v);
+ BUG_ON(fv->count == 0);
+
+ if ( --fv->count == 0 )
+ {
+ /* Don't confuse vmx_do_resume (for @v or @current!) */
+ vmx_clear_vmcs(v);
+ if ( is_hvm_vcpu(current) )
+ vmx_load_vmcs(current);
+
+ spin_unlock(&v->arch.hvm_vmx.vmcs_lock);
+ vcpu_unpause(v);
+
+ fv->v = NULL;
+ }
}

struct xgt_desc {
@@ -380,7 +415,6 @@ static void vmx_set_host_env(struct vcpu

static void construct_vmcs(struct vcpu *v)
{
- unsigned long cr0, cr4;
union vmcs_arbytes arbytes;

vmx_vmcs_enter(v);
@@ -504,19 +538,11 @@ static void construct_vmcs(struct vcpu *

__vmwrite(EXCEPTION_BITMAP, HVM_TRAP_MASK | (1U << TRAP_page_fault));

- /* Guest CR0. */
- cr0 = read_cr0();
- v->arch.hvm_vmx.cpu_cr0 = cr0;
- __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
- v->arch.hvm_vmx.cpu_shadow_cr0 = cr0 & ~(X86_CR0_PG | X86_CR0_TS);
- __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr0);
-
- /* Guest CR4. */
- cr4 = read_cr4();
- __vmwrite(GUEST_CR4, cr4 & ~X86_CR4_PSE);
- v->arch.hvm_vmx.cpu_shadow_cr4 =
- cr4 & ~(X86_CR4_PGE | X86_CR4_VMXE | X86_CR4_PAE);
- __vmwrite(CR4_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr4);
+ v->arch.hvm_vcpu.guest_cr[0] = X86_CR0_PE | X86_CR0_ET;
+ hvm_update_guest_cr(v, 0);
+
+ v->arch.hvm_vcpu.guest_cr[4] = 0;
+ hvm_update_guest_cr(v, 4);

if ( cpu_has_vmx_tpr_shadow )
{
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Aug 16 10:47:33 2007 -0600
@@ -61,6 +61,8 @@ static int vmx_alloc_vlapic_mapping(str
static int vmx_alloc_vlapic_mapping(struct domain *d);
static void vmx_free_vlapic_mapping(struct domain *d);
static void vmx_install_vlapic_mapping(struct vcpu *v);
+static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr);
+static void vmx_update_guest_efer(struct vcpu *v);

static int vmx_domain_initialise(struct domain *d)
{
@@ -100,62 +102,7 @@ static void vmx_vcpu_destroy(struct vcpu
vmx_destroy_vmcs(v);
}

-static int vmx_paging_enabled(struct vcpu *v)
-{
- unsigned long cr0 = v->arch.hvm_vmx.cpu_shadow_cr0;
- return (cr0 & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG);
-}
-
-static int vmx_pgbit_test(struct vcpu *v)
-{
- unsigned long cr0 = v->arch.hvm_vmx.cpu_shadow_cr0;
- return cr0 & X86_CR0_PG;
-}
-
-static int vmx_pae_enabled(struct vcpu *v)
-{
- unsigned long cr4 = v->arch.hvm_vmx.cpu_shadow_cr4;
- return vmx_paging_enabled(v) && (cr4 & X86_CR4_PAE);
-}
-
-static int vmx_nx_enabled(struct vcpu *v)
-{
- return v->arch.hvm_vmx.efer & EFER_NX;
-}
-
#ifdef __x86_64__
-
-static int vmx_lme_is_set(struct vcpu *v)
-{
- return v->arch.hvm_vmx.efer & EFER_LME;
-}
-
-static int vmx_long_mode_enabled(struct vcpu *v)
-{
- return v->arch.hvm_vmx.efer & EFER_LMA;
-}
-
-static void vmx_enable_long_mode(struct vcpu *v)
-{
- unsigned long vm_entry_value;
-
- vm_entry_value = __vmread(VM_ENTRY_CONTROLS);
- vm_entry_value |= VM_ENTRY_IA32E_MODE;
- __vmwrite(VM_ENTRY_CONTROLS, vm_entry_value);
-
- v->arch.hvm_vmx.efer |= EFER_LMA;
-}
-
-static void vmx_disable_long_mode(struct vcpu *v)
-{
- unsigned long vm_entry_value;
-
- vm_entry_value = __vmread(VM_ENTRY_CONTROLS);
- vm_entry_value &= ~VM_ENTRY_IA32E_MODE;
- __vmwrite(VM_ENTRY_CONTROLS, vm_entry_value);
-
- v->arch.hvm_vmx.efer &= ~EFER_LMA;
-}

static DEFINE_PER_CPU(struct vmx_msr_state, host_msr_state);

@@ -190,7 +137,7 @@ static enum handler_return long_mode_do_
switch ( ecx )
{
case MSR_EFER:
- msr_content = v->arch.hvm_vmx.efer;
+ msr_content = v->arch.hvm_vcpu.guest_efer;
break;

case MSR_FS_BASE:
@@ -204,7 +151,7 @@ static enum handler_return long_mode_do_
case MSR_SHADOW_GS_BASE:
msr_content = v->arch.hvm_vmx.shadow_gs;
check_long_mode:
- if ( !(vmx_long_mode_enabled(v)) )
+ if ( !(hvm_long_mode_enabled(v)) )
{
vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
return HNDL_exception_raised;
@@ -263,9 +210,9 @@ static enum handler_return long_mode_do_
}

if ( (msr_content & EFER_LME)
- && !(v->arch.hvm_vmx.efer & EFER_LME) )
+ && !(v->arch.hvm_vcpu.guest_efer & EFER_LME) )
{
- if ( unlikely(vmx_paging_enabled(v)) )
+ if ( unlikely(hvm_paging_enabled(v)) )
{
gdprintk(XENLOG_WARNING,
"Trying to set EFER.LME with paging enabled\n");
@@ -273,9 +220,9 @@ static enum handler_return long_mode_do_
}
}
else if ( !(msr_content & EFER_LME)
- && (v->arch.hvm_vmx.efer & EFER_LME) )
+ && (v->arch.hvm_vcpu.guest_efer & EFER_LME) )
{
- if ( unlikely(vmx_paging_enabled(v)) )
+ if ( unlikely(hvm_paging_enabled(v)) )
{
gdprintk(XENLOG_WARNING,
"Trying to clear EFER.LME with paging enabled\n");
@@ -283,17 +230,17 @@ static enum handler_return long_mode_do_
}
}

- if ( (msr_content ^ v->arch.hvm_vmx.efer) & (EFER_NX|EFER_SCE) )
+ if ( (msr_content ^ v->arch.hvm_vcpu.guest_efer) & (EFER_NX|EFER_SCE) )
write_efer((read_efer() & ~(EFER_NX|EFER_SCE)) |
(msr_content & (EFER_NX|EFER_SCE)));

- v->arch.hvm_vmx.efer = msr_content;
+ v->arch.hvm_vcpu.guest_efer = msr_content;
break;

case MSR_FS_BASE:
case MSR_GS_BASE:
case MSR_SHADOW_GS_BASE:
- if ( !vmx_long_mode_enabled(v) )
+ if ( !hvm_long_mode_enabled(v) )
goto gp_fault;

if ( !is_canonical_address(msr_content) )
@@ -394,26 +341,17 @@ static void vmx_restore_guest_msrs(struc
clear_bit(i, &guest_flags);
}

- if ( (v->arch.hvm_vmx.efer ^ read_efer()) & (EFER_NX | EFER_SCE) )
+ if ( (v->arch.hvm_vcpu.guest_efer ^ read_efer()) & (EFER_NX | EFER_SCE) )
{
HVM_DBG_LOG(DBG_LEVEL_2,
"restore guest's EFER with value %lx",
- v->arch.hvm_vmx.efer);
+ v->arch.hvm_vcpu.guest_efer);
write_efer((read_efer() & ~(EFER_NX | EFER_SCE)) |
- (v->arch.hvm_vmx.efer & (EFER_NX | EFER_SCE)));
+ (v->arch.hvm_vcpu.guest_efer & (EFER_NX | EFER_SCE)));
}
}

#else /* __i386__ */
-
-static int vmx_lme_is_set(struct vcpu *v)
-{ return 0; }
-static int vmx_long_mode_enabled(struct vcpu *v)
-{ return 0; }
-static void vmx_enable_long_mode(struct vcpu *v)
-{ BUG(); }
-static void vmx_disable_long_mode(struct vcpu *v)
-{ BUG(); }

#define vmx_save_host_msrs() ((void)0)

@@ -427,13 +365,13 @@ static void vmx_restore_host_msrs(void)

static void vmx_restore_guest_msrs(struct vcpu *v)
{
- if ( (v->arch.hvm_vmx.efer ^ read_efer()) & EFER_NX )
+ if ( (v->arch.hvm_vcpu.guest_efer ^ read_efer()) & EFER_NX )
{
HVM_DBG_LOG(DBG_LEVEL_2,
"restore guest's EFER with value %lx",
- v->arch.hvm_vmx.efer);
+ v->arch.hvm_vcpu.guest_efer);
write_efer((read_efer() & ~EFER_NX) |
- (v->arch.hvm_vmx.efer & EFER_NX));
+ (v->arch.hvm_vcpu.guest_efer & EFER_NX));
}
}

@@ -444,7 +382,7 @@ static enum handler_return long_mode_do_

switch ( regs->ecx ) {
case MSR_EFER:
- msr_content = v->arch.hvm_vmx.efer;
+ msr_content = v->arch.hvm_vcpu.guest_efer;
break;

default:
@@ -475,10 +413,10 @@ static enum handler_return long_mode_do_
return HNDL_exception_raised;
}

- if ( (msr_content ^ v->arch.hvm_vmx.efer) & EFER_NX )
+ if ( (msr_content ^ v->arch.hvm_vcpu.guest_efer) & EFER_NX )
write_efer((read_efer() & ~EFER_NX) | (msr_content & EFER_NX));

- v->arch.hvm_vmx.efer = msr_content;
+ v->arch.hvm_vcpu.guest_efer = msr_content;
break;

default:
@@ -501,12 +439,12 @@ static int vmx_guest_x86_mode(struct vcp

ASSERT(v == current);

- if ( unlikely(!(v->arch.hvm_vmx.cpu_shadow_cr0 & X86_CR0_PE)) )
+ if ( unlikely(!(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PE)) )
return 0;
if ( unlikely(__vmread(GUEST_RFLAGS) & X86_EFLAGS_VM) )
return 1;
cs_ar_bytes = __vmread(GUEST_CS_AR_BYTES);
- if ( vmx_long_mode_enabled(v) &&
+ if ( hvm_long_mode_enabled(v) &&
likely(cs_ar_bytes & X86_SEG_AR_CS_LM_ACTIVE) )
return 8;
return (likely(cs_ar_bytes & X86_SEG_AR_DEF_OP_SIZE) ? 4 : 2);
@@ -551,12 +489,12 @@ void vmx_vmcs_save(struct vcpu *v, struc
c->rsp = __vmread(GUEST_RSP);
c->rflags = __vmread(GUEST_RFLAGS);

- c->cr0 = v->arch.hvm_vmx.cpu_shadow_cr0;
- c->cr2 = v->arch.hvm_vmx.cpu_cr2;
- c->cr3 = v->arch.hvm_vmx.cpu_cr3;
- c->cr4 = v->arch.hvm_vmx.cpu_shadow_cr4;
-
- c->msr_efer = v->arch.hvm_vmx.efer;
+ c->cr0 = v->arch.hvm_vcpu.guest_cr[0];
+ c->cr2 = v->arch.hvm_vcpu.guest_cr[2];
+ c->cr3 = v->arch.hvm_vcpu.guest_cr[3];
+ c->cr4 = v->arch.hvm_vcpu.guest_cr[4];
+
+ c->msr_efer = v->arch.hvm_vcpu.guest_efer;

#ifdef HVM_DEBUG_SUSPEND
printk("%s: cr3=0x%"PRIx64", cr0=0x%"PRIx64", cr4=0x%"PRIx64".\n",
@@ -635,51 +573,33 @@ int vmx_vmcs_restore(struct vcpu *v, str
__vmwrite(GUEST_RSP, c->rsp);
__vmwrite(GUEST_RFLAGS, c->rflags);

- v->arch.hvm_vmx.cpu_cr0 = (c->cr0 | X86_CR0_PE | X86_CR0_PG |
- X86_CR0_NE | X86_CR0_WP | X86_CR0_ET);
- __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
- v->arch.hvm_vmx.cpu_shadow_cr0 = c->cr0;
- __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr0);
-
- v->arch.hvm_vmx.cpu_cr2 = c->cr2;
-
- v->arch.hvm_vmx.efer = c->msr_efer;
+ v->arch.hvm_vcpu.guest_cr[0] = c->cr0 | X86_CR0_ET;
+ v->arch.hvm_vcpu.guest_cr[2] = c->cr2;
+ v->arch.hvm_vcpu.guest_cr[3] = c->cr3;
+ v->arch.hvm_vcpu.guest_cr[4] = c->cr4;
+ vmx_update_guest_cr(v, 0);
+ vmx_update_guest_cr(v, 2);
+ vmx_update_guest_cr(v, 4);

#ifdef HVM_DEBUG_SUSPEND
printk("%s: cr3=0x%"PRIx64", cr0=0x%"PRIx64", cr4=0x%"PRIx64".\n",
__func__, c->cr3, c->cr0, c->cr4);
#endif

- if ( !vmx_paging_enabled(v) )
- {
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "%s: paging not enabled.", __func__);
- goto skip_cr3;
- }
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 = %"PRIx64, c->cr3);
- /* current!=vcpu as not called by arch_vmx_do_launch */
- mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
- {
- gdprintk(XENLOG_ERR, "Invalid CR3 value=0x%"PRIx64".\n", c->cr3);
- vmx_vmcs_exit(v);
- return -EINVAL;
- }
-
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
-
- skip_cr3:
- v->arch.hvm_vmx.cpu_cr3 = c->cr3;
-
- if ( vmx_long_mode_enabled(v) )
- vmx_enable_long_mode(v);
-
- __vmwrite(GUEST_CR4, (c->cr4 | HVM_CR4_HOST_MASK));
- v->arch.hvm_vmx.cpu_shadow_cr4 = c->cr4;
- __vmwrite(CR4_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr4);
+ if ( hvm_paging_enabled(v) )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 = %"PRIx64, c->cr3);
+ mfn = gmfn_to_mfn(v->domain, c->cr3 >> PAGE_SHIFT);
+ if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
+ goto bad_cr3;
+ old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
+ v->arch.guest_table = pagetable_from_pfn(mfn);
+ if ( old_base_mfn )
+ put_page(mfn_to_page(old_base_mfn));
+ }
+
+ v->arch.hvm_vcpu.guest_efer = c->msr_efer;
+ vmx_update_guest_efer(v);

__vmwrite(GUEST_IDTR_LIMIT, c->idtr_limit);
__vmwrite(GUEST_IDTR_BASE, c->idtr_base);
@@ -760,6 +680,11 @@ int vmx_vmcs_restore(struct vcpu *v, str
}

return 0;
+
+ bad_cr3:
+ gdprintk(XENLOG_ERR, "Invalid CR3 value=0x%"PRIx64"\n", c->cr3);
+ vmx_vmcs_exit(v);
+ return -EINVAL;
}

#if defined(__x86_64__) && defined(HVM_DEBUG_SUSPEND)
@@ -884,10 +809,10 @@ static void vmx_store_cpu_guest_regs(

if ( crs != NULL )
{
- crs[0] = v->arch.hvm_vmx.cpu_shadow_cr0;
- crs[2] = v->arch.hvm_vmx.cpu_cr2;
- crs[3] = v->arch.hvm_vmx.cpu_cr3;
- crs[4] = v->arch.hvm_vmx.cpu_shadow_cr4;
+ crs[0] = v->arch.hvm_vcpu.guest_cr[0];
+ crs[2] = v->arch.hvm_vcpu.guest_cr[2];
+ crs[3] = v->arch.hvm_vcpu.guest_cr[3];
+ crs[4] = v->arch.hvm_vcpu.guest_cr[4];
}

vmx_vmcs_exit(v);
@@ -928,24 +853,6 @@ static void vmx_load_cpu_guest_regs(stru
vmx_vmcs_exit(v);
}

-static unsigned long vmx_get_ctrl_reg(struct vcpu *v, unsigned int num)
-{
- switch ( num )
- {
- case 0:
- return v->arch.hvm_vmx.cpu_cr0;
- case 2:
- return v->arch.hvm_vmx.cpu_cr2;
- case 3:
- return v->arch.hvm_vmx.cpu_cr3;
- case 4:
- return v->arch.hvm_vmx.cpu_shadow_cr4;
- default:
- BUG();
- }
- return 0; /* dummy */
-}
-
static unsigned long vmx_get_segment_base(struct vcpu *v, enum x86_segment seg)
{
unsigned long base = 0;
@@ -953,7 +860,7 @@ static unsigned long vmx_get_segment_bas

ASSERT(v == current);

- if ( vmx_long_mode_enabled(v) &&
+ if ( hvm_long_mode_enabled(v) &&
(__vmread(GUEST_CS_AR_BYTES) & X86_SEG_AR_CS_LM_ACTIVE) )
long_mode = 1;

@@ -1045,6 +952,9 @@ static void vmx_get_segment_register(str
}

reg->attr.bytes = (attr & 0xff) | ((attr >> 4) & 0xf00);
+ /* Unusable flag is folded into Present flag. */
+ if ( attr & (1u<<16) )
+ reg->attr.fields.p = 0;
}

/* Make sure that xen intercepts any FP accesses from current */
@@ -1059,10 +969,10 @@ static void vmx_stts(struct vcpu *v)
* then this is not necessary: no FPU activity can occur until the guest
* clears CR0.TS, and we will initialise the FPU when that happens.
*/
- if ( !(v->arch.hvm_vmx.cpu_shadow_cr0 & X86_CR0_TS) )
- {
- v->arch.hvm_vmx.cpu_cr0 |= X86_CR0_TS;
- __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
+ if ( !(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS) )
+ {
+ v->arch.hvm_vcpu.hw_cr[0] |= X86_CR0_TS;
+ __vmwrite(GUEST_CR0, v->arch.hvm_vcpu.hw_cr[0]);
__vm_set_bit(EXCEPTION_BITMAP, TRAP_no_device);
}
}
@@ -1135,12 +1045,58 @@ static void vmx_update_host_cr3(struct v
vmx_vmcs_exit(v);
}

-static void vmx_update_guest_cr3(struct vcpu *v)
+static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr)
{
ASSERT((v == current) || !vcpu_runnable(v));
+
vmx_vmcs_enter(v);
- __vmwrite(GUEST_CR3, v->arch.hvm_vcpu.hw_cr3);
+
+ switch ( cr )
+ {
+ case 0:
+ v->arch.hvm_vcpu.hw_cr[0] =
+ v->arch.hvm_vcpu.guest_cr[0] |
+ X86_CR0_PE | X86_CR0_NE | X86_CR0_PG | X86_CR0_WP;
+ __vmwrite(GUEST_CR0, v->arch.hvm_vcpu.hw_cr[0]);
+ __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vcpu.guest_cr[0]);
+ break;
+ case 2:
+ /* CR2 is updated in exit stub. */
+ break;
+ case 3:
+ __vmwrite(GUEST_CR3, v->arch.hvm_vcpu.hw_cr[3]);
+ break;
+ case 4:
+ v->arch.hvm_vcpu.hw_cr[4] =
+ v->arch.hvm_vcpu.guest_cr[4] | HVM_CR4_HOST_MASK;
+ __vmwrite(GUEST_CR4, v->arch.hvm_vcpu.hw_cr[4]);
+ __vmwrite(CR4_READ_SHADOW, v->arch.hvm_vcpu.guest_cr[4]);
+ break;
+ default:
+ BUG();
+ }
+
vmx_vmcs_exit(v);
+}
+
+static void vmx_update_guest_efer(struct vcpu *v)
+{
+#ifdef __x86_64__
+ unsigned long vm_entry_value;
+
+ ASSERT((v == current) || !vcpu_runnable(v));
+
+ vmx_vmcs_enter(v);
+
+ vm_entry_value = __vmread(VM_ENTRY_CONTROLS);
+ if ( v->arch.hvm_vcpu.guest_efer & EFER_LMA )
+ vm_entry_value |= VM_ENTRY_IA32E_MODE;
+ else
+ vm_entry_value &= ~VM_ENTRY_IA32E_MODE;
+ __vmwrite(VM_ENTRY_CONTROLS, vm_entry_value);
+
+ vmx_vmcs_exit(v);
+#endif
}

static void vmx_flush_guest_tlbs(void)
@@ -1156,7 +1112,7 @@ static void vmx_inject_exception(
struct vcpu *v = current;
vmx_inject_hw_exception(v, trapnr, errcode);
if ( trapnr == TRAP_page_fault )
- v->arch.hvm_vmx.cpu_cr2 = cr2;
+ v->arch.hvm_vcpu.guest_cr[2] = cr2;
}

static void vmx_update_vtpr(struct vcpu *v, unsigned long value)
@@ -1200,17 +1156,13 @@ static struct hvm_function_table vmx_fun
.load_cpu_guest_regs = vmx_load_cpu_guest_regs,
.save_cpu_ctxt = vmx_save_vmcs_ctxt,
.load_cpu_ctxt = vmx_load_vmcs_ctxt,
- .paging_enabled = vmx_paging_enabled,
- .long_mode_enabled = vmx_long_mode_enabled,
- .pae_enabled = vmx_pae_enabled,
- .nx_enabled = vmx_nx_enabled,
.interrupts_enabled = vmx_interrupts_enabled,
.guest_x86_mode = vmx_guest_x86_mode,
- .get_guest_ctrl_reg = vmx_get_ctrl_reg,
.get_segment_base = vmx_get_segment_base,
.get_segment_register = vmx_get_segment_register,
.update_host_cr3 = vmx_update_host_cr3,
- .update_guest_cr3 = vmx_update_guest_cr3,
+ .update_guest_cr = vmx_update_guest_cr,
+ .update_guest_efer = vmx_update_guest_efer,
.flush_guest_tlbs = vmx_flush_guest_tlbs,
.update_vtpr = vmx_update_vtpr,
.stts = vmx_stts,
@@ -1315,10 +1267,10 @@ static void vmx_do_no_device_fault(void)
__vm_clear_bit(EXCEPTION_BITMAP, TRAP_no_device);

/* Disable TS in guest CR0 unless the guest wants the exception too. */
- if ( !(v->arch.hvm_vmx.cpu_shadow_cr0 & X86_CR0_TS) )
- {
- v->arch.hvm_vmx.cpu_cr0 &= ~X86_CR0_TS;
- __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
+ if ( !(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS) )
+ {
+ v->arch.hvm_vcpu.hw_cr[0] &= ~X86_CR0_TS;
+ __vmwrite(GUEST_CR0, v->arch.hvm_vcpu.hw_cr[0]);
}
}

@@ -1773,7 +1725,7 @@ static void vmx_do_str_pio(unsigned long

sign = regs->eflags & X86_EFLAGS_DF ? -1 : 1;
ar_bytes = __vmread(GUEST_CS_AR_BYTES);
- if ( vmx_long_mode_enabled(current) &&
+ if ( hvm_long_mode_enabled(current) &&
(ar_bytes & X86_SEG_AR_CS_LM_ACTIVE) )
long_mode = 1;
addr = __vmread(GUEST_LINEAR_ADDRESS);
@@ -1900,9 +1852,9 @@ static void vmx_world_save(struct vcpu *
c->esp = __vmread(GUEST_RSP);
c->eflags = __vmread(GUEST_RFLAGS) & ~X86_EFLAGS_RF;

- c->cr0 = v->arch.hvm_vmx.cpu_shadow_cr0;
- c->cr3 = v->arch.hvm_vmx.cpu_cr3;
- c->cr4 = v->arch.hvm_vmx.cpu_shadow_cr4;
+ c->cr0 = v->arch.hvm_vcpu.guest_cr[0];
+ c->cr3 = v->arch.hvm_vcpu.guest_cr[3];
+ c->cr4 = v->arch.hvm_vcpu.guest_cr[4];

c->idtr_limit = __vmread(GUEST_IDTR_LIMIT);
c->idtr_base = __vmread(GUEST_IDTR_BASE);
@@ -1959,30 +1911,15 @@ static int vmx_world_restore(struct vcpu
__vmwrite(GUEST_RSP, c->esp);
__vmwrite(GUEST_RFLAGS, c->eflags);

- v->arch.hvm_vmx.cpu_shadow_cr0 = c->cr0;
- __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr0);
-
- if ( !vmx_paging_enabled(v) )
- goto skip_cr3;
-
- if ( c->cr3 == v->arch.hvm_vmx.cpu_cr3 )
- {
- /*
- * This is simple TLB flush, implying the guest has
- * removed some translation or changed page attributes.
- * We simply invalidate the shadow.
- */
- mfn = get_mfn_from_gpfn(c->cr3 >> PAGE_SHIFT);
- if ( mfn != pagetable_get_pfn(v->arch.guest_table) )
- goto bad_cr3;
- }
- else
- {
- /*
- * If different, make a shadow. Check if the PDBR is valid
- * first.
- */
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 c->cr3 = %x", c->cr3);
+ v->arch.hvm_vcpu.guest_cr[0] = c->cr0;
+ v->arch.hvm_vcpu.guest_cr[3] = c->cr3;
+ v->arch.hvm_vcpu.guest_cr[4] = c->cr4;
+ vmx_update_guest_cr(v, 0);
+ vmx_update_guest_cr(v, 4);
+
+ if ( hvm_paging_enabled(v) )
+ {
+ HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 = %x", c->cr3);
mfn = get_mfn_from_gpfn(c->cr3 >> PAGE_SHIFT);
if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
goto bad_cr3;
@@ -1990,18 +1927,7 @@ static int vmx_world_restore(struct vcpu
v->arch.guest_table = pagetable_from_pfn(mfn);
if ( old_base_mfn )
put_page(mfn_to_page(old_base_mfn));
- v->arch.hvm_vmx.cpu_cr3 = c->cr3;
- }
-
- skip_cr3:
- if ( !vmx_paging_enabled(v) )
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "switching to vmxassist. use phys table");
- else
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %x", c->cr3);
-
- __vmwrite(GUEST_CR4, (c->cr4 | HVM_CR4_HOST_MASK));
- v->arch.hvm_vmx.cpu_shadow_cr4 = c->cr4;
- __vmwrite(CR4_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr4);
+ }

__vmwrite(GUEST_IDTR_LIMIT, c->idtr_limit);
__vmwrite(GUEST_IDTR_BASE, c->idtr_base);
@@ -2149,108 +2075,17 @@ static int vmx_set_cr0(unsigned long val
static int vmx_set_cr0(unsigned long value)
{
struct vcpu *v = current;
- unsigned long mfn;
unsigned long eip;
- int paging_enabled;
- unsigned long old_cr0;
- unsigned long old_base_mfn;
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx", value);
-
- if ( (u32)value != value )
- {
- HVM_DBG_LOG(DBG_LEVEL_1,
- "Guest attempts to set upper 32 bits in CR0: %lx",
- value);
- vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
+ int rc = hvm_set_cr0(value);
+
+ if ( rc == 0 )
return 0;
- }
-
- value &= ~HVM_CR0_GUEST_RESERVED_BITS;
-
- /* ET is reserved and should be always be 1. */
- value |= X86_CR0_ET;
-
- if ( (value & (X86_CR0_PE | X86_CR0_PG)) == X86_CR0_PG )
- {
- vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
- return 0;
- }

/* TS cleared? Then initialise FPU now. */
if ( !(value & X86_CR0_TS) )
{
setup_fpu(v);
__vm_clear_bit(EXCEPTION_BITMAP, TRAP_no_device);
- }
-
- old_cr0 = v->arch.hvm_vmx.cpu_shadow_cr0;
- paging_enabled = old_cr0 & X86_CR0_PG;
-
- v->arch.hvm_vmx.cpu_cr0 = (value | X86_CR0_PE | X86_CR0_PG
- | X86_CR0_NE | X86_CR0_WP);
- __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
-
- v->arch.hvm_vmx.cpu_shadow_cr0 = value;
- __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr0);
-
- /* Trying to enable paging. */
- if ( (value & X86_CR0_PE) && (value & X86_CR0_PG) && !paging_enabled )
- {
- if ( vmx_lme_is_set(v) && !vmx_long_mode_enabled(v) )
- {
- if ( !(v->arch.hvm_vmx.cpu_shadow_cr4 & X86_CR4_PAE) )
- {
- HVM_DBG_LOG(DBG_LEVEL_1, "Guest enabled paging "
- "with EFER.LME set but not CR4.PAE");
- vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
- return 0;
- }
-
- HVM_DBG_LOG(DBG_LEVEL_1, "Enabling long mode");
- vmx_enable_long_mode(v);
- }
-
- /*
- * The guest CR3 must be pointing to the guest physical.
- */
- mfn = get_mfn_from_gpfn(v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
- {
- gdprintk(XENLOG_ERR, "Invalid CR3 value = %lx (mfn=%lx)\n",
- v->arch.hvm_vmx.cpu_cr3, mfn);
- domain_crash(v->domain);
- return 0;
- }
-
- /*
- * Now arch.guest_table points to machine physical.
- */
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx, mfn = %lx",
- v->arch.hvm_vmx.cpu_cr3, mfn);
-
- paging_update_paging_modes(v);
- }
-
- /* Trying to disable paging. */
- if ( ((value & (X86_CR0_PE | X86_CR0_PG)) != (X86_CR0_PE | X86_CR0_PG)) &&
- paging_enabled )
- {
- /* When CR0.PG is cleared, LMA is cleared immediately. */
- if ( vmx_long_mode_enabled(v) )
- vmx_disable_long_mode(v);
-
- if ( v->arch.hvm_vmx.cpu_cr3 )
- {
- put_page(mfn_to_page(get_mfn_from_gpfn(
- v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT)));
- v->arch.guest_table = pagetable_null();
- }
}

/*
@@ -2258,14 +2093,8 @@ static int vmx_set_cr0(unsigned long val
* real-mode by performing a world switch to VMXAssist whenever
* a partition disables the CR0.PE bit.
*/
- if ( (value & X86_CR0_PE) == 0 )
- {
- if ( value & X86_CR0_PG )
- {
- vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
- return 0;
- }
-
+ if ( !(value & X86_CR0_PE) )
+ {
if ( vmx_assist(v, VMX_ASSIST_INVOKE) )
{
eip = __vmread(GUEST_RIP);
@@ -2286,8 +2115,6 @@ static int vmx_set_cr0(unsigned long val
return 0; /* do not update eip! */
}
}
- else if ( (value & (X86_CR0_PE | X86_CR0_PG)) == X86_CR0_PE )
- paging_update_paging_modes(v);

return 1;
}
@@ -2316,12 +2143,9 @@ static int vmx_set_cr0(unsigned long val
CASE_ ## T ## ET_REG(R15, r15)
#endif

-/*
- * Write to control registers
- */
static int mov_to_cr(int gp, int cr, struct cpu_user_regs *regs)
{
- unsigned long value, old_cr, old_base_mfn, mfn;
+ unsigned long value;
struct vcpu *v = current;
struct vlapic *vlapic = vcpu_vlapic(v);

@@ -2353,108 +2177,10 @@ static int mov_to_cr(int gp, int cr, str
return vmx_set_cr0(value);

case 3:
- /*
- * If paging is not enabled yet, simply copy the value to CR3.
- */
- if ( !vmx_paging_enabled(v) )
- {
- v->arch.hvm_vmx.cpu_cr3 = value;
- break;
- }
-
- /*
- * We make a new one if the shadow does not exist.
- */
- if ( value == v->arch.hvm_vmx.cpu_cr3 ) {
- /*
- * This is simple TLB flush, implying the guest has
- * removed some translation or changed page attributes.
- * We simply invalidate the shadow.
- */
- mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
- if ( mfn != pagetable_get_pfn(v->arch.guest_table) )
- goto bad_cr3;
- paging_update_cr3(v);
- } else {
- /*
- * If different, make a shadow. Check if the PDBR is valid
- * first.
- */
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "CR3 value = %lx", value);
- mfn = get_mfn_from_gpfn(value >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) || !get_page(mfn_to_page(mfn), v->domain) )
- goto bad_cr3;
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
- v->arch.hvm_vmx.cpu_cr3 = value;
- update_cr3(v);
- HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx", value);
- }
- break;
-
- case 4: /* CR4 */
- old_cr = v->arch.hvm_vmx.cpu_shadow_cr4;
-
- if ( value & HVM_CR4_GUEST_RESERVED_BITS )
- {
- HVM_DBG_LOG(DBG_LEVEL_1,
- "Guest attempts to set reserved bit in CR4: %lx",
- value);
- vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
- return 0;
- }
-
- if ( (value & X86_CR4_PAE) && !(old_cr & X86_CR4_PAE) )
- {
- if ( vmx_pgbit_test(v) )
- {
-#if CONFIG_PAGING_LEVELS >= 3
- /* The guest is a 32-bit PAE guest. */
- unsigned long mfn, old_base_mfn;
- mfn = get_mfn_from_gpfn(v->arch.hvm_vmx.cpu_cr3 >> PAGE_SHIFT);
- if ( !mfn_valid(mfn) ||
- !get_page(mfn_to_page(mfn), v->domain) )
- goto bad_cr3;
-
- /*
- * Now arch.guest_table points to machine physical.
- */
- old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
- v->arch.guest_table = pagetable_from_pfn(mfn);
- if ( old_base_mfn )
- put_page(mfn_to_page(old_base_mfn));
-
- HVM_DBG_LOG(DBG_LEVEL_VMMU,
- "Update CR3 value = %lx, mfn = %lx",
- v->arch.hvm_vmx.cpu_cr3, mfn);
-#endif
- }
- }
- else if ( !(value & X86_CR4_PAE) )
- {
- if ( unlikely(vmx_long_mode_enabled(v)) )
- {
- HVM_DBG_LOG(DBG_LEVEL_1, "Guest cleared CR4.PAE while "
- "EFER.LMA is set");
- vmx_inject_hw_exception(v, TRAP_gp_fault, 0);
- return 0;
- }
- }
-
- __vmwrite(GUEST_CR4, value | HVM_CR4_HOST_MASK);
- v->arch.hvm_vmx.cpu_shadow_cr4 = value;
- __vmwrite(CR4_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr4);
-
- /*
- * Writing to CR4 to modify the PSE, PGE, or PAE flag invalidates
- * all TLB entries except global entries.
- */
- if ( (old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE) )
- paging_update_paging_modes(v);
-
- break;
+ return hvm_set_cr3(value);
+
+ case 4:
+ return hvm_set_cr4(value);

case 8:
vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4));
@@ -2462,14 +2188,11 @@ static int mov_to_cr(int gp, int cr, str

default:
gdprintk(XENLOG_ERR, "invalid cr: %d\n", cr);
- domain_crash(v->domain);
- return 0;
+ goto exit_and_crash;
}

return 1;

- bad_cr3:
- gdprintk(XENLOG_ERR, "Invalid CR3\n");
exit_and_crash:
domain_crash(v->domain);
return 0;
@@ -2487,7 +2210,7 @@ static void mov_from_cr(int cr, int gp,
switch ( cr )
{
case 3:
- value = (unsigned long)v->arch.hvm_vmx.cpu_cr3;
+ value = (unsigned long)v->arch.hvm_vcpu.guest_cr[3];
break;
case 8:
value = (unsigned long)vlapic_get_reg(vlapic, APIC_TASKPRI);
@@ -2530,7 +2253,8 @@ static int vmx_cr_access(unsigned long e
unsigned long value;
struct vcpu *v = current;

- switch ( exit_qualification & CONTROL_REG_ACCESS_TYPE ) {
+ switch ( exit_qualification & CONTROL_REG_ACCESS_TYPE )
+ {
case TYPE_MOV_TO_CR:
gp = exit_qualification & CONTROL_REG_ACCESS_REG;
cr = exit_qualification & CONTROL_REG_ACCESS_NUM;
@@ -2545,14 +2269,14 @@ static int vmx_cr_access(unsigned long e
setup_fpu(v);
__vm_clear_bit(EXCEPTION_BITMAP, TRAP_no_device);

- v->arch.hvm_vmx.cpu_cr0 &= ~X86_CR0_TS; /* clear TS */
- __vmwrite(GUEST_CR0, v->arch.hvm_vmx.cpu_cr0);
-
- v->arch.hvm_vmx.cpu_shadow_cr0 &= ~X86_CR0_TS; /* clear TS */
- __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vmx.cpu_shadow_cr0);
+ v->arch.hvm_vcpu.hw_cr[0] &= ~X86_CR0_TS; /* clear TS */
+ __vmwrite(GUEST_CR0, v->arch.hvm_vcpu.hw_cr[0]);
+
+ v->arch.hvm_vcpu.guest_cr[0] &= ~X86_CR0_TS; /* clear TS */
+ __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vcpu.guest_cr[0]);
break;
case TYPE_LMSW:
- value = v->arch.hvm_vmx.cpu_shadow_cr0;
+ value = v->arch.hvm_vcpu.guest_cr[0];
value = (value & ~0xF) |
(((exit_qualification & LMSW_SOURCE_DATA) >> 16) & 0xF);
return vmx_set_cr0(value);
@@ -2943,7 +2667,7 @@ asmlinkage void vmx_vmexit_handler(struc
break;
}

- v->arch.hvm_vmx.cpu_cr2 = exit_qualification;
+ v->arch.hvm_vcpu.guest_cr[2] = exit_qualification;
vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code);
break;
case TRAP_nmi:
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/vmx/x86_32/exits.S
--- a/xen/arch/x86/hvm/vmx/x86_32/exits.S Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S Thu Aug 16 10:47:33 2007 -0600
@@ -74,7 +74,7 @@ ENTRY(vmx_asm_do_vmentry)
jnz vmx_process_softirqs

call vmx_intr_assist
- movl VCPU_vmx_cr2(%ebx),%eax
+ movl VCPU_hvm_guest_cr2(%ebx),%eax
movl %eax,%cr2
call vmx_trace_vmentry

diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/hvm/vmx/x86_64/exits.S
--- a/xen/arch/x86/hvm/vmx/x86_64/exits.S Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S Thu Aug 16 10:47:33 2007 -0600
@@ -88,7 +88,7 @@ ENTRY(vmx_asm_do_vmentry)
jnz vmx_process_softirqs

call vmx_intr_assist
- movq VCPU_vmx_cr2(%rbx),%rax
+ movq VCPU_hvm_guest_cr2(%rbx),%rax
movq %rax,%cr2
call vmx_trace_vmentry

diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/mm.c Thu Aug 16 10:47:33 2007 -0600
@@ -394,8 +394,8 @@ void write_ptbase(struct vcpu *v)
write_cr3(v->arch.cr3);
}

-/* Should be called after CR3 is updated.
- * Updates vcpu->arch.cr3 and, for HVM guests, vcpu->arch.hvm_vcpu.cpu_cr3.
+/*
+ * Should be called after CR3 is updated.
*
* Uses values found in vcpu->arch.(guest_table and guest_table_user), and
* for HVM guests, arch.monitor_table and hvm's guest CR3.
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/mm/hap/guest_walk.c
--- a/xen/arch/x86/mm/hap/guest_walk.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/mm/hap/guest_walk.c Thu Aug 16 10:47:33 2007 -0600
@@ -62,7 +62,7 @@ unsigned long hap_gva_to_gfn(GUEST_PAGIN
unsigned long hap_gva_to_gfn(GUEST_PAGING_LEVELS)(
struct vcpu *v, unsigned long gva)
{
- unsigned long gcr3 = hvm_get_guest_ctrl_reg(v, 3);
+ unsigned long gcr3 = v->arch.hvm_vcpu.guest_cr[3];
int mode = GUEST_PAGING_LEVELS;
int lev, index;
paddr_t gpa = 0;
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/mm/hap/hap.c
--- a/xen/arch/x86/mm/hap/hap.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/mm/hap/hap.c Thu Aug 16 10:47:33 2007 -0600
@@ -603,47 +603,36 @@ static int hap_invlpg(struct vcpu *v, un
return 0;
}

-/*
- * HAP guests do not need to take any action on CR3 writes (they are still
- * intercepted, so that Xen's copy of the guest's CR3 can be kept in sync.)
- */
static void hap_update_cr3(struct vcpu *v, int do_locking)
{
+ v->arch.hvm_vcpu.hw_cr[3] = v->arch.hvm_vcpu.guest_cr[3];
+ hvm_update_guest_cr(v, 3);
}

static void hap_update_paging_modes(struct vcpu *v)
{
- struct domain *d;
-
- d = v->domain;
+ struct domain *d = v->domain;
+
hap_lock(d);

- /* update guest paging mode. Note that we rely on hvm functions to detect
- * guest's paging mode. So, make sure the shadow registers (CR0, CR4, EFER)
- * reflect guest's status correctly.
- */
- if ( hvm_paging_enabled(v) )
- {
- if ( hvm_long_mode_enabled(v) )
- v->arch.paging.mode = &hap_paging_long_mode;
- else if ( hvm_pae_enabled(v) )
- v->arch.paging.mode = &hap_paging_pae_mode;
- else
- v->arch.paging.mode = &hap_paging_protected_mode;
- }
- else
- {
- v->arch.paging.mode = &hap_paging_real_mode;
- }
-
- v->arch.paging.translate_enabled = !!hvm_paging_enabled(v);
+ v->arch.paging.mode =
+ !hvm_paging_enabled(v) ? &hap_paging_real_mode :
+ hvm_long_mode_enabled(v) ? &hap_paging_long_mode :
+ hvm_pae_enabled(v) ? &hap_paging_pae_mode :
+ &hap_paging_protected_mode;
+
+ v->arch.paging.translate_enabled = hvm_paging_enabled(v);

if ( pagetable_is_null(v->arch.monitor_table) )
{
mfn_t mmfn = hap_make_monitor_table(v);
v->arch.monitor_table = pagetable_from_mfn(mmfn);
make_cr3(v, mfn_x(mmfn));
- }
+ hvm_update_host_cr3(v);
+ }
+
+ /* CR3 is effectively updated by a mode change. Flush ASIDs, etc. */
+ hap_update_cr3(v, 0);

hap_unlock(d);
}
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/mm/shadow/common.c Thu Aug 16 10:47:33 2007 -0600
@@ -2266,7 +2266,7 @@ static void sh_update_paging_modes(struc
ASSERT(shadow_mode_translate(d));
ASSERT(shadow_mode_external(d));

- v->arch.paging.translate_enabled = !!hvm_paging_enabled(v);
+ v->arch.paging.translate_enabled = hvm_paging_enabled(v);
if ( !v->arch.paging.translate_enabled )
{
/* Set v->arch.guest_table to use the p2m map, and choose
@@ -2347,7 +2347,7 @@ static void sh_update_paging_modes(struc
SHADOW_PRINTK("new paging mode: d=%u v=%u pe=%d g=%u s=%u "
"(was g=%u s=%u)\n",
d->domain_id, v->vcpu_id,
- is_hvm_domain(d) ? !!hvm_paging_enabled(v) : 1,
+ is_hvm_domain(d) ? hvm_paging_enabled(v) : 1,
v->arch.paging.mode->guest_levels,
v->arch.paging.mode->shadow.shadow_levels,
old_mode ? old_mode->guest_levels : 0,
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/mm/shadow/multi.c Thu Aug 16 10:47:33 2007 -0600
@@ -175,7 +175,7 @@ guest_supports_superpages(struct vcpu *v
/* The _PAGE_PSE bit must be honoured in HVM guests, whenever
* CR4.PSE is set or the guest is in PAE or long mode */
return (is_hvm_vcpu(v) && (GUEST_PAGING_LEVELS != 2
- || (hvm_get_guest_ctrl_reg(v, 4) & X86_CR4_PSE)));
+ || (v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PSE)));
}

static inline int
@@ -3483,7 +3483,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
* Paravirtual guests should set v->arch.guest_table (and guest_table_user,
* if appropriate).
* HVM guests should also make sure hvm_get_guest_cntl_reg(v, 3) works;
- * this function will call hvm_update_guest_cr3() to tell them where the
+ * this function will call hvm_update_guest_cr(v, 3) to tell them where the
* shadow tables are.
* If do_locking != 0, assume we are being called from outside the
* shadow code, and must take and release the shadow lock; otherwise
@@ -3525,7 +3525,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
// Is paging enabled on this vcpu?
if ( paging_vcpu_mode_translate(v) )
{
- gfn = _gfn(paddr_to_pfn(hvm_get_guest_ctrl_reg(v, 3)));
+ gfn = _gfn(paddr_to_pfn(v->arch.hvm_vcpu.guest_cr[3]));
gmfn = vcpu_gfn_to_mfn(v, gfn);
ASSERT(mfn_valid(gmfn));
ASSERT(pagetable_get_pfn(v->arch.guest_table) == mfn_x(gmfn));
@@ -3576,11 +3576,11 @@ sh_update_cr3(struct vcpu *v, int do_loc

if ( shadow_mode_external(d) && paging_vcpu_mode_translate(v) )
/* Paging enabled: find where in the page the l3 table is */
- guest_idx = guest_index((void *)hvm_get_guest_ctrl_reg(v, 3));
- else
- /* Paging disabled or PV: l3 is at the start of a page */
- guest_idx = 0;
-
+ guest_idx = guest_index((void *)v->arch.hvm_vcpu.guest_cr[3]);
+ else
+ /* Paging disabled or PV: l3 is at the start of a page */
+ guest_idx = 0;
+
// Ignore the low 2 bits of guest_idx -- they are really just
// cache control.
guest_idx &= ~3;
@@ -3718,18 +3718,21 @@ sh_update_cr3(struct vcpu *v, int do_loc


///
- /// v->arch.hvm_vcpu.hw_cr3
+ /// v->arch.hvm_vcpu.hw_cr[3]
///
if ( shadow_mode_external(d) )
{
ASSERT(is_hvm_domain(d));
#if SHADOW_PAGING_LEVELS == 3
/* 2-on-3 or 3-on-3: Use the PAE shadow l3 table we just fabricated */
- hvm_update_guest_cr3(v, virt_to_maddr(&v->arch.paging.shadow.l3table));
+ v->arch.hvm_vcpu.hw_cr[3] =
+ virt_to_maddr(&v->arch.paging.shadow.l3table);
#else
/* 2-on-2 or 4-on-4: Just use the shadow top-level directly */
- hvm_update_guest_cr3(v, pagetable_get_paddr(v->arch.shadow_table[0]));
-#endif
+ v->arch.hvm_vcpu.hw_cr[3] =
+ pagetable_get_paddr(v->arch.shadow_table[0]);
+#endif
+ hvm_update_guest_cr(v, 3);
}

/* Fix up the linear pagetable mappings */
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/physdev.c Thu Aug 16 10:47:33 2007 -0600
@@ -28,6 +28,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
{
int irq;
ret_t ret;
+ struct vcpu *v = current;

switch ( cmd )
{
@@ -36,13 +37,13 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
ret = -EFAULT;
if ( copy_from_guest(&eoi, arg, 1) != 0 )
break;
- ret = pirq_guest_eoi(current->domain, eoi.irq);
+ ret = pirq_guest_eoi(v->domain, eoi.irq);
break;
}

/* Legacy since 0x00030202. */
case PHYSDEVOP_IRQ_UNMASK_NOTIFY: {
- ret = pirq_guest_unmask(current->domain);
+ ret = pirq_guest_unmask(v->domain);
break;
}

@@ -70,7 +71,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
if ( copy_from_guest(&apic, arg, 1) != 0 )
break;
ret = -EPERM;
- if ( !IS_PRIV(current->domain) )
+ if ( !IS_PRIV(v->domain) )
break;
ret = ioapic_guest_read(apic.apic_physbase, apic.reg, &apic.value);
if ( copy_to_guest(arg, &apic, 1) != 0 )
@@ -84,7 +85,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
if ( copy_from_guest(&apic, arg, 1) != 0 )
break;
ret = -EPERM;
- if ( !IS_PRIV(current->domain) )
+ if ( !IS_PRIV(v->domain) )
break;
ret = ioapic_guest_write(apic.apic_physbase, apic.reg, apic.value);
break;
@@ -98,7 +99,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
break;

ret = -EPERM;
- if ( !IS_PRIV(current->domain) )
+ if ( !IS_PRIV(v->domain) )
break;

irq = irq_op.irq;
@@ -120,7 +121,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
if ( set_iopl.iopl > 3 )
break;
ret = 0;
- current->arch.iopl = set_iopl.iopl;
+ v->arch.iopl = set_iopl.iopl;
break;
}

@@ -135,11 +136,11 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H
break;
ret = 0;
#ifndef COMPAT
- current->arch.iobmp = set_iobitmap.bitmap;
+ v->arch.iobmp = set_iobitmap.bitmap;
#else
- guest_from_compat_handle(current->arch.iobmp, set_iobitmap.bitmap);
+ guest_from_compat_handle(v->arch.iobmp, set_iobitmap.bitmap);
#endif
- current->arch.iobmp_limit = set_iobitmap.nr_ports;
+ v->arch.iobmp_limit = set_iobitmap.nr_ports;
break;
}

diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/setup.c Thu Aug 16 10:47:33 2007 -0600
@@ -106,6 +106,8 @@ extern void trap_init(void);
extern void trap_init(void);
extern void early_time_init(void);
extern void early_cpu_init(void);
+extern void vesa_init(void);
+extern void vesa_mtrr_init(void);

struct tss_struct init_tss[NR_CPUS];

@@ -282,9 +284,28 @@ static void __init srat_detect_node(int
printk(KERN_INFO "CPU %d APIC %d -> Node %d\n", cpu, apicid, node);
}

+/*
+ * Ensure a given physical memory range is present in the bootstrap mappings.
+ * Use superpage mappings to ensure that pagetable memory needn't be allocated.
+ */
+static void __init bootstrap_map(unsigned long start, unsigned long end)
+{
+ unsigned long mask = (1UL << L2_PAGETABLE_SHIFT) - 1;
+ start = start & ~mask;
+ end = (end + mask) & ~mask;
+ if ( end > BOOTSTRAP_DIRECTMAP_END )
+ panic("Cannot access memory beyond end of "
+ "bootstrap direct-map area\n");
+ map_pages_to_xen(
+ (unsigned long)maddr_to_bootstrap_virt(start),
+ start >> PAGE_SHIFT, (end-start) >> PAGE_SHIFT, PAGE_HYPERVISOR);
+}
+
static void __init move_memory(
unsigned long dst, unsigned long src_start, unsigned long src_end)
{
+ bootstrap_map(src_start, src_end);
+ bootstrap_map(dst, dst + src_end - src_start);
memmove(maddr_to_bootstrap_virt(dst),
maddr_to_bootstrap_virt(src_start),
src_end - src_start);
@@ -882,6 +903,7 @@ void __init __start_xen(unsigned long mb
#ifdef __x86_64__
init_xenheap_pages(xen_phys_start, __pa(&_start));
nr_pages += (__pa(&_start) - xen_phys_start) >> PAGE_SHIFT;
+ vesa_init();
#endif
xenheap_phys_start = xen_phys_start;
printk("Xen heap: %luMB (%lukB)\n",
@@ -947,6 +969,9 @@ void __init __start_xen(unsigned long mb
set_in_cr4(X86_CR4_OSFXSR);
if ( cpu_has_xmm )
set_in_cr4(X86_CR4_OSXMMEXCPT);
+#ifdef CONFIG_X86_64
+ vesa_mtrr_init();
+#endif

if ( opt_nosmp )
max_cpus = 0;
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/string.c
--- a/xen/arch/x86/string.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/string.c Thu Aug 16 10:47:33 2007 -0600
@@ -11,10 +11,18 @@
#undef memcpy
void *memcpy(void *dest, const void *src, size_t n)
{
- int d0, d1, d2;
+ long d0, d1, d2;

__asm__ __volatile__ (
- " rep ; movsl ; "
+#ifdef __i386__
+ " rep movsl ; "
+#else
+ " rep movsq ; "
+ " testb $4,%b4 ; "
+ " je 0f ; "
+ " movsl ; "
+ "0: ; "
+#endif
" testb $2,%b4 ; "
" je 1f ; "
" movsw ; "
@@ -23,7 +31,7 @@ void *memcpy(void *dest, const void *src
" movsb ; "
"2: "
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
- : "0" (n/4), "q" (n), "1" (dest), "2" (src)
+ : "0" (n/sizeof(long)), "q" (n), "1" (dest), "2" (src)
: "memory");

return dest;
@@ -32,10 +40,10 @@ void *memcpy(void *dest, const void *src
#undef memset
void *memset(void *s, int c, size_t n)
{
- int d0, d1;
+ long d0, d1;

__asm__ __volatile__ (
- "rep ; stosb"
+ "rep stosb"
: "=&c" (d0), "=&D" (d1)
: "a" (c), "1" (s), "0" (n)
: "memory");
@@ -46,14 +54,14 @@ void *memset(void *s, int c, size_t n)
#undef memmove
void *memmove(void *dest, const void *src, size_t n)
{
- int d0, d1, d2;
+ long d0, d1, d2;

if ( dest < src )
return memcpy(dest, src, n);

__asm__ __volatile__ (
" std ; "
- " rep ; movsb ; "
+ " rep movsb ; "
" cld "
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
: "0" (n), "1" (n-1+(const char *)src), "2" (n-1+(char *)dest)
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/traps.c Thu Aug 16 10:47:33 2007 -0600
@@ -1219,7 +1219,7 @@ static int emulate_privileged_op(struct
unsigned long code_base, code_limit;
char io_emul_stub[16];
void (*io_emul)(struct cpu_user_regs *) __attribute__((__regparm__(1)));
- u32 l, h;
+ u32 l, h, eax, edx;

if ( !read_descriptor(regs->cs, v, regs,
&code_base, &code_limit, &ar,
@@ -1696,43 +1696,43 @@ static int emulate_privileged_op(struct
break;

case 0x30: /* WRMSR */
+ eax = regs->eax;
+ edx = regs->edx;
+ res = ((u64)edx << 32) | eax;
switch ( regs->ecx )
{
#ifdef CONFIG_X86_64
case MSR_FS_BASE:
if ( is_pv_32on64_vcpu(v) )
goto fail;
- if ( wrmsr_safe(MSR_FS_BASE, regs->eax, regs->edx) )
+ if ( wrmsr_safe(MSR_FS_BASE, eax, edx) )
goto fail;
- v->arch.guest_context.fs_base =
- ((u64)regs->edx << 32) | regs->eax;
+ v->arch.guest_context.fs_base = res;
break;
case MSR_GS_BASE:
if ( is_pv_32on64_vcpu(v) )
goto fail;
- if ( wrmsr_safe(MSR_GS_BASE, regs->eax, regs->edx) )
+ if ( wrmsr_safe(MSR_GS_BASE, eax, edx) )
goto fail;
- v->arch.guest_context.gs_base_kernel =
- ((u64)regs->edx << 32) | regs->eax;
+ v->arch.guest_context.gs_base_kernel = res;
break;
case MSR_SHADOW_GS_BASE:
if ( is_pv_32on64_vcpu(v) )
goto fail;
- if ( wrmsr_safe(MSR_SHADOW_GS_BASE, regs->eax, regs->edx) )
+ if ( wrmsr_safe(MSR_SHADOW_GS_BASE, eax, edx) )
goto fail;
- v->arch.guest_context.gs_base_user =
- ((u64)regs->edx << 32) | regs->eax;
+ v->arch.guest_context.gs_base_user = res;
break;
#endif
default:
- if ( wrmsr_hypervisor_regs(regs->ecx, regs->eax, regs->edx) )
+ if ( wrmsr_hypervisor_regs(regs->ecx, eax, edx) )
break;

if ( (rdmsr_safe(regs->ecx, l, h) != 0) ||
- (regs->eax != l) || (regs->edx != h) )
+ (eax != l) || (edx != h) )
gdprintk(XENLOG_WARNING, "Domain attempted WRMSR %p from "
- "%08x:%08x to %08lx:%08lx.\n",
- _p(regs->ecx), h, l, (long)regs->edx, (long)regs->eax);
+ "%08x:%08x to %08x:%08x.\n",
+ _p(regs->ecx), h, l, edx, eax);
break;
}
break;
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/x86_32/asm-offsets.c
--- a/xen/arch/x86/x86_32/asm-offsets.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/x86_32/asm-offsets.c Thu Aug 16 10:47:33 2007 -0600
@@ -85,7 +85,7 @@ void __dummy__(void)
BLANK();

OFFSET(VCPU_vmx_launched, struct vcpu, arch.hvm_vmx.launched);
- OFFSET(VCPU_vmx_cr2, struct vcpu, arch.hvm_vmx.cpu_cr2);
+ OFFSET(VCPU_hvm_guest_cr2, struct vcpu, arch.hvm_vcpu.guest_cr[2]);
BLANK();

OFFSET(VMCB_rax, struct vmcb_struct, rax);
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/x86_32/traps.c
--- a/xen/arch/x86/x86_32/traps.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/x86_32/traps.c Thu Aug 16 10:47:33 2007 -0600
@@ -172,6 +172,7 @@ unsigned long do_iret(void)
unsigned long do_iret(void)
{
struct cpu_user_regs *regs = guest_cpu_user_regs();
+ struct vcpu *v = current;
u32 eflags;

/* Check worst-case stack frame for overlap with Xen protected area. */
@@ -215,10 +216,10 @@ unsigned long do_iret(void)
}

/* No longer in NMI context. */
- current->nmi_masked = 0;
+ v->nmi_masked = 0;

/* Restore upcall mask from supplied EFLAGS.IF. */
- current->vcpu_info->evtchn_upcall_mask = !(eflags & X86_EFLAGS_IF);
+ vcpu_info(v, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF);

/*
* The hypercall exit path will overwrite EAX with this return
@@ -228,7 +229,7 @@ unsigned long do_iret(void)

exit_and_crash:
gdprintk(XENLOG_ERR, "Fatal error\n");
- domain_crash(current->domain);
+ domain_crash(v->domain);
return 0;
}

diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/x86_64/asm-offsets.c
--- a/xen/arch/x86/x86_64/asm-offsets.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/x86_64/asm-offsets.c Thu Aug 16 10:47:33 2007 -0600
@@ -88,7 +88,7 @@ void __dummy__(void)
BLANK();

OFFSET(VCPU_vmx_launched, struct vcpu, arch.hvm_vmx.launched);
- OFFSET(VCPU_vmx_cr2, struct vcpu, arch.hvm_vmx.cpu_cr2);
+ OFFSET(VCPU_hvm_guest_cr2, struct vcpu, arch.hvm_vcpu.guest_cr[2]);
BLANK();

OFFSET(DOMAIN_is_32bit_pv, struct domain, arch.is_32bit_pv);
diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/x86_64/compat/traps.c
--- a/xen/arch/x86/x86_64/compat/traps.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/x86_64/compat/traps.c Thu Aug 16 10:47:33 2007 -0600
@@ -37,6 +37,7 @@ unsigned int compat_iret(void)
unsigned int compat_iret(void)
{
struct cpu_user_regs *regs = guest_cpu_user_regs();
+ struct vcpu *v = current;
u32 eflags;

/* Trim stack pointer to 32 bits. */
@@ -70,7 +71,7 @@ unsigned int compat_iret(void)
* mode frames).
*/
const struct trap_info *ti;
- u32 x, ksp = current->arch.guest_context.kernel_sp - 40;
+ u32 x, ksp = v->arch.guest_context.kernel_sp - 40;
unsigned int i;
int rc = 0;

@@ -95,9 +96,9 @@ unsigned int compat_iret(void)
if ( rc )
goto exit_and_crash;
regs->_esp = ksp;
- regs->ss = current->arch.guest_context.kernel_ss;
-
- ti = &current->arch.guest_context.trap_ctxt[13];
+ regs->ss = v->arch.guest_context.kernel_ss;
+
+ ti = &v->arch.guest_context.trap_ctxt[13];
if ( TI_GET_IF(ti) )
eflags &= ~X86_EFLAGS_IF;
regs->_eflags = eflags & ~(X86_EFLAGS_VM|X86_EFLAGS_RF|
@@ -121,10 +122,10 @@ unsigned int compat_iret(void)
regs->_esp += 16;

/* No longer in NMI context. */
- current->nmi_masked = 0;
+ v->nmi_masked = 0;

/* Restore upcall mask from supplied EFLAGS.IF. */
- vcpu_info(current, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF);
+ vcpu_info(v, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF);

/*
* The hypercall exit path will overwrite EAX with this return
@@ -134,11 +135,12 @@ unsigned int compat_iret(void)

exit_and_crash:
gdprintk(XENLOG_ERR, "Fatal error\n");
- domain_crash(current->domain);
+ domain_crash(v->domain);
return 0;
}

-static long compat_register_guest_callback(struct compat_callback_register *reg)
+static long compat_register_guest_callback(
+ struct compat_callback_register *reg)
{
long ret = 0;
struct vcpu *v = current;
@@ -175,7 +177,8 @@ static long compat_register_guest_callba
return ret;
}

-static long compat_unregister_guest_callback(struct compat_callback_unregister *unreg)
+static long compat_unregister_guest_callback(
+ struct compat_callback_unregister *unreg)
{
long ret;

diff -r b5dbf184df6c -r 778985f246a0 xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/arch/x86/x86_64/traps.c Thu Aug 16 10:47:33 2007 -0600
@@ -235,10 +235,10 @@ unsigned long do_iret(void)
}

/* No longer in NMI context. */
- current->nmi_masked = 0;
+ v->nmi_masked = 0;

/* Restore upcall mask from supplied EFLAGS.IF. */
- vcpu_info(current, evtchn_upcall_mask) = !(iret_saved.rflags & EF_IE);
+ vcpu_info(v, evtchn_upcall_mask) = !(iret_saved.rflags & EF_IE);

/* Saved %rax gets written back to regs->rax in entry.S. */
return iret_saved.rax;
diff -r b5dbf184df6c -r 778985f246a0 xen/common/domctl.c
--- a/xen/common/domctl.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/common/domctl.c Thu Aug 16 10:47:33 2007 -0600
@@ -463,19 +463,13 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc
case XEN_DOMCTL_getdomaininfo:
{
struct domain *d;
- domid_t dom;
-
- dom = op->domain;
- if ( dom == DOMID_SELF )
- dom = current->domain->domain_id;
+ domid_t dom = op->domain;

rcu_read_lock(&domlist_read_lock);

for_each_domain ( d )
- {
if ( d->domain_id >= dom )
break;
- }

if ( d == NULL )
{
diff -r b5dbf184df6c -r 778985f246a0 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/common/page_alloc.c Thu Aug 16 10:47:33 2007 -0600
@@ -54,21 +54,14 @@ boolean_param("bootscrub", opt_bootscrub
/*
* Bit width of the DMA heap.
*/
-static unsigned int dma_bitsize = CONFIG_DMA_BITSIZE;
-static unsigned long max_dma_mfn = (1UL<<(CONFIG_DMA_BITSIZE-PAGE_SHIFT))-1;
+static unsigned int dma_bitsize = CONFIG_DMA_BITSIZE;
static void __init parse_dma_bits(char *s)
{
unsigned int v = simple_strtol(s, NULL, 0);
if ( v >= (BITS_PER_LONG + PAGE_SHIFT) )
- {
dma_bitsize = BITS_PER_LONG + PAGE_SHIFT;
- max_dma_mfn = ~0UL;
- }
else if ( v > PAGE_SHIFT + 1 )
- {
dma_bitsize = v;
- max_dma_mfn = (1UL << (dma_bitsize - PAGE_SHIFT)) - 1;
- }
else
printk("Invalid dma_bits value of %u ignored.\n", v);
}
diff -r b5dbf184df6c -r 778985f246a0 xen/common/xencomm.c
--- a/xen/common/xencomm.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/common/xencomm.c Thu Aug 16 10:47:33 2007 -0600
@@ -26,35 +26,36 @@
#include <public/xen.h>
#include <public/xencomm.h>

-
#undef DEBUG
#ifdef DEBUG
-static int xencomm_debug = 1; /* extremely verbose */
+#define xc_dprintk(f, a...) printk("[xencomm]" f , ## a)
#else
-#define xencomm_debug 0
+#define xc_dprintk(f, a...) ((void)0)
#endif

+static void*
+xencomm_maddr_to_vaddr(unsigned long maddr)
+{
+ return maddr ? maddr_to_virt(maddr) : NULL;
+}
+
static unsigned long
-xencomm_inline_from_guest(void *to, const void *from, unsigned int n,
- unsigned int skip)
-{
- unsigned long src_paddr = xencomm_inline_addr(from);
-
- src_paddr += skip;
-
- while (n > 0) {
- unsigned int chunksz;
+xencomm_inline_from_guest(
+ void *to, const void *from, unsigned int n, unsigned int skip)
+{
+ unsigned long src_paddr = xencomm_inline_addr(from) + skip;
+
+ while ( n > 0 )
+ {
+ unsigned int chunksz, bytes;
unsigned long src_maddr;
- unsigned int bytes;

chunksz = PAGE_SIZE - (src_paddr % PAGE_SIZE);
-
- bytes = min(chunksz, n);
+ bytes = min(chunksz, n);

src_maddr = paddr_to_maddr(src_paddr);
- if (xencomm_debug)
- printk("%lx[%d] -> %lx\n", src_maddr, bytes, (unsigned long)to);
- memcpy(to, (void *)src_maddr, bytes);
+ xc_dprintk("%lx[%d] -> %lx\n", src_maddr, bytes, (unsigned long)to);
+ memcpy(to, maddr_to_virt(src_maddr), bytes);
src_paddr += bytes;
to += bytes;
n -= bytes;
@@ -77,36 +78,40 @@ xencomm_inline_from_guest(void *to, cons
* On success, this will be zero.
*/
unsigned long
-xencomm_copy_from_guest(void *to, const void *from, unsigned int n,
- unsigned int skip)
+xencomm_copy_from_guest(
+ void *to, const void *from, unsigned int n, unsigned int skip)
{
struct xencomm_desc *desc;
unsigned int from_pos = 0;
unsigned int to_pos = 0;
unsigned int i = 0;

- if (xencomm_is_inline(from))
+ if ( xencomm_is_inline(from) )
return xencomm_inline_from_guest(to, from, n, skip);

- /* first we need to access the descriptor */
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)from);
- if (desc == NULL)
- return n;
-
- if (desc->magic != XENCOMM_MAGIC) {
+ /* First we need to access the descriptor. */
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)from));
+ if ( desc == NULL )
+ return n;
+
+ if ( desc->magic != XENCOMM_MAGIC )
+ {
printk("%s: error: %p magic was 0x%x\n",
__func__, desc, desc->magic);
return n;
}

- /* iterate through the descriptor, copying up to a page at a time */
- while ((to_pos < n) && (i < desc->nr_addrs)) {
+ /* Iterate through the descriptor, copying up to a page at a time. */
+ while ( (to_pos < n) && (i < desc->nr_addrs) )
+ {
unsigned long src_paddr = desc->address[i];
unsigned int pgoffset;
unsigned int chunksz;
unsigned int chunk_skip;

- if (src_paddr == XENCOMM_INVALID) {
+ if ( src_paddr == XENCOMM_INVALID )
+ {
i++;
continue;
}
@@ -119,18 +124,18 @@ xencomm_copy_from_guest(void *to, const
chunksz -= chunk_skip;
skip -= chunk_skip;

- if (skip == 0 && chunksz > 0) {
+ if ( (skip == 0) && (chunksz > 0) )
+ {
unsigned long src_maddr;
unsigned long dest = (unsigned long)to + to_pos;
unsigned int bytes = min(chunksz, n - to_pos);

src_maddr = paddr_to_maddr(src_paddr + chunk_skip);
- if (src_maddr == 0)
+ if ( src_maddr == 0 )
return n - to_pos;

- if (xencomm_debug)
- printk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
- memcpy((void *)dest, (void *)src_maddr, bytes);
+ xc_dprintk("%lx[%d] -> %lx\n", src_maddr, bytes, dest);
+ memcpy((void *)dest, maddr_to_virt(src_maddr), bytes);
from_pos += bytes;
to_pos += bytes;
}
@@ -142,32 +147,28 @@ xencomm_copy_from_guest(void *to, const
}

static unsigned long
-xencomm_inline_to_guest(void *to, const void *from, unsigned int n,
- unsigned int skip)
-{
- unsigned long dest_paddr = xencomm_inline_addr(to);
-
- dest_paddr += skip;
-
- while (n > 0) {
- unsigned int chunksz;
+xencomm_inline_to_guest(
+ void *to, const void *from, unsigned int n, unsigned int skip)
+{
+ unsigned long dest_paddr = xencomm_inline_addr(to) + skip;
+
+ while ( n > 0 )
+ {
+ unsigned int chunksz, bytes;
unsigned long dest_maddr;
- unsigned int bytes;

chunksz = PAGE_SIZE - (dest_paddr % PAGE_SIZE);
-
- bytes = min(chunksz, n);
+ bytes = min(chunksz, n);

dest_maddr = paddr_to_maddr(dest_paddr);
- if (xencomm_debug)
- printk("%lx[%d] -> %lx\n", (unsigned long)from, bytes, dest_maddr);
- memcpy((void *)dest_maddr, (void *)from, bytes);
+ xc_dprintk("%lx[%d] -> %lx\n", (unsigned long)from, bytes, dest_maddr);
+ memcpy(maddr_to_virt(dest_maddr), (void *)from, bytes);
dest_paddr += bytes;
from += bytes;
n -= bytes;
}

- /* Always successful. */
+ /* Always successful. */
return 0;
}

@@ -184,35 +185,37 @@ xencomm_inline_to_guest(void *to, const
* On success, this will be zero.
*/
unsigned long
-xencomm_copy_to_guest(void *to, const void *from, unsigned int n,
- unsigned int skip)
+xencomm_copy_to_guest(
+ void *to, const void *from, unsigned int n, unsigned int skip)
{
struct xencomm_desc *desc;
unsigned int from_pos = 0;
unsigned int to_pos = 0;
unsigned int i = 0;

- if (xencomm_is_inline(to))
+ if ( xencomm_is_inline(to) )
return xencomm_inline_to_guest(to, from, n, skip);

- /* first we need to access the descriptor */
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)to);
- if (desc == NULL)
- return n;
-
- if (desc->magic != XENCOMM_MAGIC) {
+ /* First we need to access the descriptor. */
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)to));
+ if ( desc == NULL )
+ return n;
+
+ if ( desc->magic != XENCOMM_MAGIC )
+ {
printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
return n;
}

- /* iterate through the descriptor, copying up to a page at a time */
- while ((from_pos < n) && (i < desc->nr_addrs)) {
+ /* Iterate through the descriptor, copying up to a page at a time. */
+ while ( (from_pos < n) && (i < desc->nr_addrs) )
+ {
unsigned long dest_paddr = desc->address[i];
- unsigned int pgoffset;
- unsigned int chunksz;
- unsigned int chunk_skip;
-
- if (dest_paddr == XENCOMM_INVALID) {
+ unsigned int pgoffset, chunksz, chunk_skip;
+
+ if ( dest_paddr == XENCOMM_INVALID )
+ {
i++;
continue;
}
@@ -225,18 +228,18 @@ xencomm_copy_to_guest(void *to, const vo
chunksz -= chunk_skip;
skip -= chunk_skip;

- if (skip == 0 && chunksz > 0) {
+ if ( (skip == 0) && (chunksz > 0) )
+ {
unsigned long dest_maddr;
unsigned long source = (unsigned long)from + from_pos;
unsigned int bytes = min(chunksz, n - from_pos);

dest_maddr = paddr_to_maddr(dest_paddr + chunk_skip);
- if (dest_maddr == 0)
- return -1;
-
- if (xencomm_debug)
- printk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
- memcpy((void *)dest_maddr, (void *)source, bytes);
+ if ( dest_maddr == 0 )
+ return n - from_pos;
+
+ xc_dprintk("%lx[%d] -> %lx\n", source, bytes, dest_maddr);
+ memcpy(maddr_to_virt(dest_maddr), (void *)source, bytes);
from_pos += bytes;
to_pos += bytes;
}
@@ -260,38 +263,46 @@ int xencomm_add_offset(void **handle, un
struct xencomm_desc *desc;
int i = 0;

- if (xencomm_is_inline(*handle))
+ if ( xencomm_is_inline(*handle) )
return xencomm_inline_add_offset(handle, bytes);

- /* first we need to access the descriptor */
- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)*handle);
- if (desc == NULL)
+ /* First we need to access the descriptor. */
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)*handle));
+ if ( desc == NULL )
return -1;

- if (desc->magic != XENCOMM_MAGIC) {
+ if ( desc->magic != XENCOMM_MAGIC )
+ {
printk("%s error: %p magic was 0x%x\n", __func__, desc, desc->magic);
return -1;
}

- /* iterate through the descriptor incrementing addresses */
- while ((bytes > 0) && (i < desc->nr_addrs)) {
+ /* Iterate through the descriptor incrementing addresses. */
+ while ( (bytes > 0) && (i < desc->nr_addrs) )
+ {
unsigned long dest_paddr = desc->address[i];
- unsigned int pgoffset;
- unsigned int chunksz;
- unsigned int chunk_skip;
+ unsigned int pgoffset, chunksz, chunk_skip;
+
+ if ( dest_paddr == XENCOMM_INVALID )
+ {
+ i++;
+ continue;
+ }

pgoffset = dest_paddr % PAGE_SIZE;
chunksz = PAGE_SIZE - pgoffset;

chunk_skip = min(chunksz, bytes);
- if (chunk_skip == chunksz) {
- /* exhausted this page */
- desc->address[i] = XENCOMM_INVALID;
- } else {
+ if ( chunk_skip == chunksz )
+ desc->address[i] = XENCOMM_INVALID; /* exchausted this page */
+ else
desc->address[i] += chunk_skip;
- }
bytes -= chunk_skip;
- }
+
+ i++;
+ }
+
return 0;
}

@@ -300,17 +311,17 @@ int xencomm_handle_is_null(void *handle)
struct xencomm_desc *desc;
int i;

- if (xencomm_is_inline(handle))
+ if ( xencomm_is_inline(handle) )
return xencomm_inline_addr(handle) == 0;

- desc = (struct xencomm_desc *)paddr_to_maddr((unsigned long)handle);
- if (desc == NULL)
+ desc = (struct xencomm_desc *)
+ xencomm_maddr_to_vaddr(paddr_to_maddr((unsigned long)handle));
+ if ( desc == NULL )
return 1;

- for (i = 0; i < desc->nr_addrs; i++)
- if (desc->address[i] != XENCOMM_INVALID)
+ for ( i = 0; i < desc->nr_addrs; i++ )
+ if ( desc->address[i] != XENCOMM_INVALID )
return 0;

return 1;
}
-
diff -r b5dbf184df6c -r 778985f246a0 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/drivers/char/console.c Thu Aug 16 10:47:33 2007 -0600
@@ -331,13 +331,11 @@ static long guest_console_write(XEN_GUES
kbuf[kcount] = '\0';

sercon_puts(kbuf);
-
- for ( kptr = kbuf; *kptr != '\0'; kptr++ )
- {
- vga_putchar(*kptr);
- if ( opt_console_to_ring )
+ vga_puts(kbuf);
+
+ if ( opt_console_to_ring )
+ for ( kptr = kbuf; *kptr != '\0'; kptr++ )
putchar_console_ring(*kptr);
- }

if ( opt_console_to_ring )
send_guest_global_virq(dom0, VIRQ_CON_RING);
@@ -404,12 +402,10 @@ static void __putstr(const char *str)
int c;

sercon_puts(str);
+ vga_puts(str);

while ( (c = *str++) != '\0' )
- {
- vga_putchar(c);
putchar_console_ring(c);
- }

send_guest_global_virq(dom0, VIRQ_CON_RING);
}
diff -r b5dbf184df6c -r 778985f246a0 xen/drivers/video/Makefile
--- a/xen/drivers/video/Makefile Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/drivers/video/Makefile Thu Aug 16 10:47:33 2007 -0600
@@ -1,4 +1,8 @@ obj-y += font_8x14.o
-obj-y += font_8x14.o
-obj-y += font_8x16.o
-obj-y += font_8x8.o
-obj-y += vga.o
+obj-y := vga.o
+obj-$(CONFIG_X86_64) += font_8x14.o
+obj-$(CONFIG_X86_64) += font_8x16.o
+obj-$(CONFIG_X86_64) += font_8x8.o
+obj-$(CONFIG_X86_64) += vesa.o
+
+# extra dependencies
+vesa.o: font.h
diff -r b5dbf184df6c -r 778985f246a0 xen/drivers/video/vesa.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/drivers/video/vesa.c Thu Aug 16 10:47:33 2007 -0600
@@ -0,0 +1,307 @@
+/******************************************************************************
+ * vesa.c
+ *
+ * VESA linear frame buffer handling.
+ */
+
+#include <xen/config.h>
+#include <xen/compile.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/errno.h>
+#include <xen/console.h>
+#include <xen/vga.h>
+#include "font.h"
+
+#define vlfb_info vga_console_info.u.vesa_lfb
+#define text_columns (vlfb_info.width / font->width)
+#define text_rows (vlfb_info.height / font->height)
+
+static void vesa_redraw_puts(const char *s);
+static void vesa_scroll_puts(const char *s);
+
+static unsigned char *lfb, *lbuf, *text_buf;
+static const struct font_desc *font;
+static bool_t vga_compat;
+static unsigned int pixel_on;
+static unsigned int xpos, ypos;
+
+static unsigned int vram_total;
+integer_param("vesa-ram", vram_total);
+
+static unsigned int vram_remap;
+integer_param("vesa-map", vram_remap);
+
+static int font_height;
+static void __init parse_font_height(const char *s)
+{
+ if ( simple_strtoul(s, &s, 10) == 8 && (*s++ == 'x') )
+ font_height = simple_strtoul(s, &s, 10);
+ if ( *s != '\0' )
+ font_height = 0;
+}
+custom_param("font", parse_font_height);
+
+void __init vesa_early_init(void)
+{
+ unsigned int vram_vmode;
+
+ /* XXX vga_compat = !(boot_video_info.capabilities & 2); */
+
+ if ( (vlfb_info.bits_per_pixel < 8) || (vlfb_info.bits_per_pixel > 32) )
+ return;
+
+ if ( font_height == 0 ) /* choose a sensible default */
+ font = ((vlfb_info.height <= 600) ? &font_vga_8x8 :
+ (vlfb_info.height <= 768) ? &font_vga_8x14 : &font_vga_8x16);
+ else if ( font_height <= 8 )
+ font = &font_vga_8x8;
+ else if ( font_height <= 14 )
+ font = &font_vga_8x14;
+ else
+ font = &font_vga_8x16;
+
+ /* vram_vmode -- that is the amount of memory needed for the
+ * used video mode, i.e. the minimum amount of
+ * memory we need. */
+ vram_vmode = vlfb_info.height * vlfb_info.bytes_per_line;
+
+ /* vram_total -- all video memory we have. Used for mtrr
+ * entries. */
+ vram_total = vram_total ? (vram_total << 20) : (vlfb_info.lfb_size << 16);
+ vram_total = max_t(unsigned int, vram_total, vram_vmode);
+
+ /* vram_remap -- the amount of video memory we are going to
+ * use for vesafb. With modern cards it is no
+ * option to simply use vram_total as that
+ * wastes plenty of kernel address space. */
+ vram_remap = (vram_remap ?
+ (vram_remap << 20) :
+ ((vram_vmode + (1 << L2_PAGETABLE_SHIFT) - 1) &
+ ~((1 << L2_PAGETABLE_SHIFT) - 1)));
+ vram_remap = max_t(unsigned int, vram_remap, vram_vmode);
+ vram_remap = min_t(unsigned int, vram_remap, vram_total);
+}
+
+void __init vesa_init(void)
+{
+ if ( !font )
+ goto fail;
+
+ lbuf = xmalloc_bytes(vlfb_info.bytes_per_line);
+ if ( !lbuf )
+ goto fail;
+
+ text_buf = xmalloc_bytes(text_columns * text_rows);
+ if ( !text_buf )
+ goto fail;
+
+ if ( map_pages_to_xen(IOREMAP_VIRT_START,
+ vlfb_info.lfb_base >> PAGE_SHIFT,
+ vram_remap >> PAGE_SHIFT,
+ PAGE_HYPERVISOR_NOCACHE) )
+ goto fail;
+
+ lfb = memset((void *)IOREMAP_VIRT_START, 0, vram_remap);
+ memset(text_buf, 0, text_columns * text_rows);
+
+ vga_puts = vesa_redraw_puts;
+
+ printk(XENLOG_INFO "vesafb: framebuffer at 0x%x, mapped to 0x%p, "
+ "using %uk, total %uk\n",
+ vlfb_info.lfb_base, lfb,
+ vram_remap >> 10, vram_total >> 10);
+ printk(XENLOG_INFO "vesafb: mode is %dx%dx%u, linelength=%d, font %ux%u\n",
+ vlfb_info.width, vlfb_info.height,
+ vlfb_info.bits_per_pixel, vlfb_info.bytes_per_line,
+ font->width, font->height);
+ printk(XENLOG_INFO "vesafb: %scolor: size=%d:%d:%d:%d, "
+ "shift=%d:%d:%d:%d\n",
+ vlfb_info.bits_per_pixel > 8 ? "True" :
+ vga_compat ? "Pseudo" : "Static Pseudo",
+ vlfb_info.rsvd_size, vlfb_info.red_size,
+ vlfb_info.green_size, vlfb_info.blue_size,
+ vlfb_info.rsvd_pos, vlfb_info.red_pos,
+ vlfb_info.green_pos, vlfb_info.blue_pos);
+
+ if ( vlfb_info.bits_per_pixel > 8 )
+ {
+ /* Light grey in truecolor. */
+ unsigned int grey = 0xaaaaaaaa;
+ pixel_on =
+ ((grey >> (32 - vlfb_info. red_size)) << vlfb_info. red_pos) |
+ ((grey >> (32 - vlfb_info.green_size)) << vlfb_info.green_pos) |
+ ((grey >> (32 - vlfb_info. blue_size)) << vlfb_info. blue_pos);
+ }
+ else
+ {
+ /* White(ish) in default pseudocolor palette. */
+ pixel_on = 7;
+ }
+
+ return;
+
+ fail:
+ xfree(lbuf);
+ xfree(text_buf);
+}
+
+void __init vesa_endboot(void)
+{
+ xpos = 0;
+ vga_puts = vesa_scroll_puts;
+}
+
+#if defined(CONFIG_X86)
+
+#include <asm/mtrr.h>
+
+static unsigned int vesa_mtrr;
+integer_param("vesa-mtrr", vesa_mtrr);
+
+void __init vesa_mtrr_init(void)
+{
+ static const int mtrr_types[] = {
+ 0, MTRR_TYPE_UNCACHABLE, MTRR_TYPE_WRBACK,
+ MTRR_TYPE_WRCOMB, MTRR_TYPE_WRTHROUGH };
+ unsigned int size_total;
+ int rc, type;
+
+ if ( !lfb || (vesa_mtrr == 0) || (vesa_mtrr >= ARRAY_SIZE(mtrr_types)) )
+ return;
+
+ type = mtrr_types[vesa_mtrr];
+ if ( !type )
+ return;
+
+ /* Find the largest power-of-two */
+ size_total = vram_total;
+ while ( size_total & (size_total - 1) )
+ size_total &= size_total - 1;
+
+ /* Try and find a power of two to add */
+ do {
+ rc = mtrr_add(vlfb_info.lfb_base, size_total, type, 1);
+ size_total >>= 1;
+ } while ( (size_total >= PAGE_SIZE) && (rc == -EINVAL) );
+}
+
+static void lfb_flush(void)
+{
+ if ( vesa_mtrr == 3 )
+ __asm__ __volatile__ ("sfence" : : : "memory");
+}
+
+#else /* !defined(CONFIG_X86) */
+
+#define lfb_flush() ((void)0)
+
+#endif
+
+/* Render one line of text to given linear framebuffer line. */
+static void vesa_show_line(
+ const unsigned char *text_line,
+ unsigned char *video_line,
+ unsigned int nr_chars)
+{
+ unsigned int i, j, b, bpp, pixel;
+
+ bpp = (vlfb_info.bits_per_pixel + 7) >> 3;
+
+ for ( i = 0; i < font->height; i++ )
+ {
+ unsigned char *ptr = lbuf;
+
+ for ( j = 0; j < nr_chars; j++ )
+ {
+ const unsigned char *bits = font->data;
+ bits += ((text_line[j] * font->height + i) *
+ ((font->width + 7) >> 3));
+ for ( b = font->width; b--; )
+ {
+ pixel = test_bit(b, bits) ? pixel_on : 0;
+ memcpy(ptr, &pixel, bpp);
+ ptr += bpp;
+ }
+ }
+
+ memset(ptr, 0, (vlfb_info.width - nr_chars * font->width) * bpp);
+ memcpy(video_line, lbuf, vlfb_info.width * bpp);
+ video_line += vlfb_info.bytes_per_line;
+ }
+}
+
+/* Fast mode which redraws all modified parts of a 2D text buffer. */
+static void vesa_redraw_puts(const char *s)
+{
+ unsigned int i, min_redraw_y = ypos;
+ char c;
+
+ /* Paste characters into text buffer. */
+ while ( (c = *s++) != '\0' )
+ {
+ if ( (c == '\n') || (xpos >= text_columns) )
+ {
+ if ( ++ypos >= text_rows )
+ {
+ min_redraw_y = 0;
+ ypos = text_rows - 1;
+ memmove(text_buf, text_buf + text_columns,
+ ypos * text_columns);
+ memset(text_buf + ypos * text_columns, 0, xpos);
+ }
+ xpos = 0;
+ }
+
+ if ( c != '\n' )
+ text_buf[xpos++ + ypos * text_columns] = c;
+ }
+
+ /* Render modified section of text buffer to VESA linear framebuffer. */
+ for ( i = min_redraw_y; i <= ypos; i++ )
+ vesa_show_line(text_buf + i * text_columns,
+ lfb + i * font->height * vlfb_info.bytes_per_line,
+ text_columns);
+
+ lfb_flush();
+}
+
+/* Slower line-based scroll mode which interacts better with dom0. */
+static void vesa_scroll_puts(const char *s)
+{
+ unsigned int i;
+ char c;
+
+ while ( (c = *s++) != '\0' )
+ {
+ if ( (c == '\n') || (xpos >= text_columns) )
+ {
+ unsigned int bytes = (vlfb_info.width *
+ ((vlfb_info.bits_per_pixel + 7) >> 3));
+ unsigned char *src = lfb + font->height * vlfb_info.bytes_per_line;
+ unsigned char *dst = lfb;
+
+ /* New line: scroll all previous rows up one line. */
+ for ( i = font->height; i < vlfb_info.height; i++ )
+ {
+ memcpy(dst, src, bytes);
+ src += vlfb_info.bytes_per_line;
+ dst += vlfb_info.bytes_per_line;
+ }
+
+ /* Render new line. */
+ vesa_show_line(
+ text_buf,
+ lfb + (text_rows-1) * font->height * vlfb_info.bytes_per_line,
+ xpos);
+
+ xpos = 0;
+ }
+
+ if ( c != '\n' )
+ text_buf[xpos++] = c;
+ }
+
+ lfb_flush();
+}
diff -r b5dbf184df6c -r 778985f246a0 xen/drivers/video/vga.c
--- a/xen/drivers/video/vga.c Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/drivers/video/vga.c Thu Aug 16 10:47:33 2007 -0600
@@ -10,22 +10,20 @@
#include <xen/lib.h>
#include <xen/mm.h>
#include <xen/errno.h>
-#include <xen/event.h>
-#include <xen/spinlock.h>
#include <xen/console.h>
#include <xen/vga.h>
#include <asm/io.h>
-#include "font.h"

/* Filled in by arch boot code. */
struct xen_vga_console_info vga_console_info;

-static int vgacon_enabled = 0;
-static int vgacon_keep = 0;
-/*static const struct font_desc *font;*/
+static int vgacon_keep;
+static unsigned int xpos, ypos;
+static unsigned char *video;

-static int xpos, ypos;
-static unsigned char *video;
+static void vga_text_puts(const char *s);
+static void vga_noop_puts(const char *s) {}
+void (*vga_puts)(const char *) = vga_noop_puts;

/*
* 'vga=<mode-specifier>[,keep]' where <mode-specifier> is one of:
@@ -55,10 +53,16 @@ string_param("vga", opt_vga);
string_param("vga", opt_vga);

/* VGA text-mode definitions. */
-#define COLUMNS vga_console_info.u.text_mode_3.columns
-#define LINES vga_console_info.u.text_mode_3.rows
+static unsigned int columns, lines;
#define ATTRIBUTE 7
-#define VIDEO_SIZE (COLUMNS * LINES * 2)
+
+#ifdef CONFIG_X86_64
+void vesa_early_init(void);
+void vesa_endboot(void);
+#else
+#define vesa_early_init() ((void)0)
+#define vesa_endboot() ((void)0)
+#endif

void __init vga_init(void)
{
@@ -76,77 +80,61 @@ void __init vga_init(void)
switch ( vga_console_info.video_type )
{
case XEN_VGATYPE_TEXT_MODE_3:
- if ( memory_is_conventional_ram(0xB8000) )
+ if ( memory_is_conventional_ram(0xB8000) ||
+ ((video = ioremap(0xB8000, 0x8000)) == NULL) )
return;
- video = ioremap(0xB8000, 0x8000);
- if ( video == NULL )
- return;
- /* Disable cursor. */
- outw(0x200a, 0x3d4);
- memset(video, 0, VIDEO_SIZE);
+ outw(0x200a, 0x3d4); /* disable cursor */
+ columns = vga_console_info.u.text_mode_3.columns;
+ lines = vga_console_info.u.text_mode_3.rows;
+ memset(video, 0, columns * lines * 2);
+ vga_puts = vga_text_puts;
break;
case XEN_VGATYPE_VESA_LFB:
-#if 0
- /* XXX Implement me! */
- video = ioremap(vga_console_info.u.vesa_lfb.lfb_base,
- vga_console_info.u.vesa_lfb.lfb_size);
- if ( video == NULL )
- return;
- memset(video, 0, vga_console_info.u.vesa_lfb.lfb_size);
+ vesa_early_init();
break;
-#else
- return;
-#endif
default:
memset(&vga_console_info, 0, sizeof(vga_console_info));
- return;
+ break;
}
-
- vgacon_enabled = 1;
}

void __init vga_endboot(void)
{
- if ( !vgacon_enabled )
+ if ( vga_puts == vga_noop_puts )
return;

printk("Xen is %s VGA console.\n",
vgacon_keep ? "keeping" : "relinquishing");

- vgacon_enabled = vgacon_keep;
+ vesa_endboot();
+
+ if ( !vgacon_keep )
+ vga_puts = vga_noop_puts;
}

+static void vga_text_puts(const char *s)
+{
+ char c;

-static void put_newline(void)
-{
- xpos = 0;
- ypos++;
+ while ( (c = *s++) != '\0' )
+ {
+ if ( (c == '\n') || (xpos >= columns) )
+ {
+ if ( ++ypos >= lines )
+ {
+ ypos = lines - 1;
+ memmove(video, video + 2 * columns, ypos * 2 * columns);
+ memset(video + ypos * 2 * columns, 0, 2 * xpos);
+ }
+ xpos = 0;
+ }

- if ( ypos >= LINES )
- {
- ypos = LINES-1;
- memmove((char*)video,
- (char*)video + 2*COLUMNS, (LINES-1)*2*COLUMNS);
- memset((char*)video + (LINES-1)*2*COLUMNS, 0, 2*COLUMNS);
- }
-}
-
-void vga_putchar(int c)
-{
- if ( !vgacon_enabled )
- return;
-
- if ( c == '\n' )
- {
- put_newline();
- }
- else
- {
- if ( xpos >= COLUMNS )
- put_newline();
- video[(xpos + ypos * COLUMNS) * 2] = c & 0xFF;
- video[(xpos + ypos * COLUMNS) * 2 + 1] = ATTRIBUTE;
- ++xpos;
+ if ( c != '\n' )
+ {
+ video[(xpos + ypos * columns) * 2] = c;
+ video[(xpos + ypos * columns) * 2 + 1] = ATTRIBUTE;
+ xpos++;
+ }
}
}

diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/hvm.h Thu Aug 16 10:47:33 2007 -0600
@@ -95,36 +95,27 @@ struct hvm_function_table {

/*
* Examine specifics of the guest state:
- * 1) determine whether paging is enabled,
- * 2) determine whether long mode is enabled,
- * 3) determine whether PAE paging is enabled,
- * 4) determine whether NX is enabled,
- * 5) determine whether interrupts are enabled or not,
- * 6) determine the mode the guest is running in,
- * 7) return the current guest control-register value
- * 8) return the current guest segment descriptor base
- * 9) return the current guest segment descriptor
- */
- int (*paging_enabled)(struct vcpu *v);
- int (*long_mode_enabled)(struct vcpu *v);
- int (*pae_enabled)(struct vcpu *v);
- int (*nx_enabled)(struct vcpu *v);
+ * 1) determine whether interrupts are enabled or not
+ * 2) determine the mode the guest is running in
+ * 3) return the current guest segment descriptor base
+ * 4) return the current guest segment descriptor
+ */
int (*interrupts_enabled)(struct vcpu *v, enum hvm_intack);
int (*guest_x86_mode)(struct vcpu *v);
- unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
unsigned long (*get_segment_base)(struct vcpu *v, enum x86_segment seg);
void (*get_segment_register)(struct vcpu *v, enum x86_segment seg,
struct segment_register *reg);

/*
- * Re-set the value of CR3 that Xen runs on when handling VM exits
+ * Re-set the value of CR3 that Xen runs on when handling VM exits.
*/
void (*update_host_cr3)(struct vcpu *v);

/*
- * Called to inform HVM layer that a guest cr3 has changed
- */
- void (*update_guest_cr3)(struct vcpu *v);
+ * Called to inform HVM layer that a guest CRn or EFER has changed.
+ */
+ void (*update_guest_cr)(struct vcpu *v, unsigned int cr);
+ void (*update_guest_efer)(struct vcpu *v);

/*
* Called to ensure than all guest-specific mappings in a tagged TLB
@@ -189,38 +180,24 @@ void hvm_set_guest_time(struct vcpu *v,
void hvm_set_guest_time(struct vcpu *v, u64 gtime);
u64 hvm_get_guest_time(struct vcpu *v);

-static inline int
-hvm_paging_enabled(struct vcpu *v)
-{
- return hvm_funcs.paging_enabled(v);
-}
+#define hvm_paging_enabled(v) \
+ (!!((v)->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PG))
+#define hvm_pae_enabled(v) \
+ (hvm_paging_enabled(v) && ((v)->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PAE))
+#define hvm_nx_enabled(v) \
+ (!!((v)->arch.hvm_vcpu.guest_efer & EFER_NX))

#ifdef __x86_64__
-static inline int
-hvm_long_mode_enabled(struct vcpu *v)
-{
- return hvm_funcs.long_mode_enabled(v);
-}
+#define hvm_long_mode_enabled(v) \
+ ((v)->arch.hvm_vcpu.guest_efer & EFER_LMA)
#else
#define hvm_long_mode_enabled(v) (v,0)
#endif

static inline int
-hvm_pae_enabled(struct vcpu *v)
-{
- return hvm_funcs.pae_enabled(v);
-}
-
-static inline int
hvm_interrupts_enabled(struct vcpu *v, enum hvm_intack type)
{
return hvm_funcs.interrupts_enabled(v, type);
-}
-
-static inline int
-hvm_nx_enabled(struct vcpu *v)
-{
- return hvm_funcs.nx_enabled(v);
}

static inline int
@@ -244,7 +221,15 @@ hvm_update_vtpr(struct vcpu *v, unsigned
hvm_funcs.update_vtpr(v, value);
}

-void hvm_update_guest_cr3(struct vcpu *v, unsigned long guest_cr3);
+static inline void hvm_update_guest_cr(struct vcpu *v, unsigned int cr)
+{
+ hvm_funcs.update_guest_cr(v, cr);
+}
+
+static inline void hvm_update_guest_efer(struct vcpu *v)
+{
+ hvm_funcs.update_guest_efer(v);
+}

static inline void
hvm_flush_guest_tlbs(void)
@@ -257,12 +242,6 @@ void hvm_hypercall_page_initialise(struc
void *hypercall_page);

static inline unsigned long
-hvm_get_guest_ctrl_reg(struct vcpu *v, unsigned int num)
-{
- return hvm_funcs.get_guest_ctrl_reg(v, num);
-}
-
-static inline unsigned long
hvm_get_segment_base(struct vcpu *v, enum x86_segment seg)
{
return hvm_funcs.get_segment_base(v, seg);
@@ -277,7 +256,6 @@ hvm_get_segment_register(struct vcpu *v,

void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx);
-void hvm_stts(struct vcpu *v);
void hvm_migrate_timers(struct vcpu *v);
void hvm_do_resume(struct vcpu *v);

diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/support.h
--- a/xen/include/asm-x86/hvm/support.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/support.h Thu Aug 16 10:47:33 2007 -0600
@@ -234,4 +234,8 @@ void hvm_hlt(unsigned long rflags);
void hvm_hlt(unsigned long rflags);
void hvm_triple_fault(void);

+int hvm_set_cr0(unsigned long value);
+int hvm_set_cr3(unsigned long value);
+int hvm_set_cr4(unsigned long value);
+
#endif /* __ASM_X86_HVM_SUPPORT_H__ */
diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/svm/asid.h
--- a/xen/include/asm-x86/hvm/svm/asid.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/svm/asid.h Thu Aug 16 10:47:33 2007 -0600
@@ -32,20 +32,6 @@ void svm_asid_inv_asid(struct vcpu *v);
void svm_asid_inv_asid(struct vcpu *v);
void svm_asid_inc_generation(void);

-/*
- * ASID related, guest triggered events.
- */
-
-static inline void svm_asid_g_update_paging(struct vcpu *v)
-{
- svm_asid_inv_asid(v);
-}
-
-static inline void svm_asid_g_mov_to_cr3(struct vcpu *v)
-{
- svm_asid_inv_asid(v);
-}
-
static inline void svm_asid_g_invlpg(struct vcpu *v, unsigned long g_vaddr)
{
#if 0
diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/svm/vmcb.h
--- a/xen/include/asm-x86/hvm/svm/vmcb.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h Thu Aug 16 10:47:33 2007 -0600
@@ -440,11 +440,6 @@ struct arch_svm_struct {
u32 *msrpm;
int launch_core;
bool_t vmcb_in_sync; /* VMCB sync'ed with VMSAVE? */
- unsigned long cpu_shadow_cr0; /* Guest value for CR0 */
- unsigned long cpu_shadow_cr4; /* Guest value for CR4 */
- unsigned long cpu_shadow_efer; /* Guest value for EFER */
- unsigned long cpu_cr2;
- unsigned long cpu_cr3;
};

struct vmcb_struct *alloc_vmcb(void);
diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/vcpu.h
--- a/xen/include/asm-x86/hvm/vcpu.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/vcpu.h Thu Aug 16 10:47:33 2007 -0600
@@ -29,7 +29,18 @@
#define HVM_VCPU_INIT_SIPI_SIPI_STATE_WAIT_SIPI 1

struct hvm_vcpu {
- unsigned long hw_cr3; /* value we give to HW to use */
+ /* Guest control-register and EFER values, just as the guest sees them. */
+ unsigned long guest_cr[5];
+ unsigned long guest_efer;
+
+ /*
+ * Processor-visible control-register values, while guest executes.
+ * CR0, CR4: Used as a cache of VMCS contents by VMX only.
+ * CR1, CR2: Never used (guest_cr[2] is always processor-visible CR2).
+ * CR3: Always used and kept up to date by paging subsystem.
+ */
+ unsigned long hw_cr[5];
+
struct hvm_io_op io_op;
struct vlapic vlapic;
s64 cache_tsc_offset;
diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/vmx/vmcs.h
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h Thu Aug 16 10:47:33 2007 -0600
@@ -67,17 +67,11 @@ struct arch_vmx_struct {
/* Cache of cpu execution control. */
u32 exec_control;

- unsigned long cpu_cr0; /* copy of guest CR0 */
- unsigned long cpu_shadow_cr0; /* copy of guest read shadow CR0 */
- unsigned long cpu_shadow_cr4; /* copy of guest read shadow CR4 */
- unsigned long cpu_cr2; /* save CR2 */
- unsigned long cpu_cr3;
#ifdef __x86_64__
struct vmx_msr_state msr_state;
unsigned long shadow_gs;
unsigned long cstar;
#endif
- unsigned long efer;

/* Following fields are all specific to vmxassist. */
unsigned long vmxassist_enabled:1;
diff -r b5dbf184df6c -r 778985f246a0 xen/include/asm-x86/hvm/vmx/vmx.h
--- a/xen/include/asm-x86/hvm/vmx/vmx.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h Thu Aug 16 10:47:33 2007 -0600
@@ -279,8 +279,8 @@ static inline void __vmx_inject_exceptio

__vmwrite(VM_ENTRY_INTR_INFO, intr_fields);

- if (trap == TRAP_page_fault)
- HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_vmx.cpu_cr2, error_code);
+ if ( trap == TRAP_page_fault )
+ HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_vcpu.guest_cr[2], error_code);
else
HVMTRACE_2D(INJ_EXC, v, trap, error_code);
}
diff -r b5dbf184df6c -r 778985f246a0 xen/include/public/arch-x86/xen-x86_32.h
--- a/xen/include/public/arch-x86/xen-x86_32.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/public/arch-x86/xen-x86_32.h Thu Aug 16 10:47:33 2007 -0600
@@ -64,18 +64,34 @@
#define FLAT_USER_DS FLAT_RING3_DS
#define FLAT_USER_SS FLAT_RING3_SS

-/*
- * Virtual addresses beyond this are not modifiable by guest OSes. The
- * machine->physical mapping table starts at this address, read-only.
- */
+#define __HYPERVISOR_VIRT_START_PAE 0xF5800000
+#define __MACH2PHYS_VIRT_START_PAE 0xF5800000
+#define __MACH2PHYS_VIRT_END_PAE 0xF6800000
+#define HYPERVISOR_VIRT_START_PAE \
+ mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
+#define MACH2PHYS_VIRT_START_PAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
+#define MACH2PHYS_VIRT_END_PAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
+
+#define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
+#define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000
+#define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000
+#define HYPERVISOR_VIRT_START_NONPAE \
+ mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
+#define MACH2PHYS_VIRT_START_NONPAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
+#define MACH2PHYS_VIRT_END_NONPAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
+
#ifdef CONFIG_X86_PAE
-#define __HYPERVISOR_VIRT_START 0xF5800000
-#define __MACH2PHYS_VIRT_START 0xF5800000
-#define __MACH2PHYS_VIRT_END 0xF6800000
+#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
+#define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE
+#define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE
#else
-#define __HYPERVISOR_VIRT_START 0xFC000000
-#define __MACH2PHYS_VIRT_START 0xFC000000
-#define __MACH2PHYS_VIRT_END 0xFC400000
+#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_NONPAE
+#define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_NONPAE
+#define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_NONPAE
#endif

#ifndef HYPERVISOR_VIRT_START
diff -r b5dbf184df6c -r 778985f246a0 xen/include/xen/vga.h
--- a/xen/include/xen/vga.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/xen/vga.h Thu Aug 16 10:47:33 2007 -0600
@@ -15,11 +15,11 @@ extern struct xen_vga_console_info vga_c
extern struct xen_vga_console_info vga_console_info;
void vga_init(void);
void vga_endboot(void);
-void vga_putchar(int c);
+extern void (*vga_puts)(const char *);
#else
-#define vga_init() ((void)0)
-#define vga_endboot() ((void)0)
-#define vga_putchar(c) ((void)0)
+#define vga_init() ((void)0)
+#define vga_endboot() ((void)0)
+#define vga_puts(s) ((void)0)
#endif

#endif /* _XEN_VGA_H */
diff -r b5dbf184df6c -r 778985f246a0 xen/include/xen/xencomm.h
--- a/xen/include/xen/xencomm.h Thu Aug 16 10:03:26 2007 -0600
+++ b/xen/include/xen/xencomm.h Thu Aug 16 10:47:33 2007 -0600
@@ -23,13 +23,12 @@

#include <public/xen.h>

-extern unsigned long xencomm_copy_to_guest(void *to, const void *from,
- unsigned int len, unsigned int skip);
-extern unsigned long xencomm_copy_from_guest(void *to, const void *from,
- unsigned int len, unsigned int skip);
-extern int xencomm_add_offset(void **handle, unsigned int bytes);
-extern int xencomm_handle_is_null(void *ptr);
-
+unsigned long xencomm_copy_to_guest(
+ void *to, const void *from, unsigned int len, unsigned int skip);
+unsigned long xencomm_copy_from_guest(
+ void *to, const void *from, unsigned int len, unsigned int skip);
+int xencomm_add_offset(void **handle, unsigned int bytes);
+int xencomm_handle_is_null(void *ptr);

static inline int xencomm_is_inline(const void *handle)
{
@@ -39,7 +38,7 @@ static inline int xencomm_is_inline(cons

static inline unsigned long xencomm_inline_addr(const void *handle)
{
- return (unsigned long)handle & ~XENCOMM_INLINE_FLAG;
+ return (unsigned long)handle & ~XENCOMM_INLINE_FLAG;
}

/* Is the guest handle a NULL reference? */

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